/*! * PixiJS - v8.4.1 * Compiled Thu, 19 Sep 2024 10:28:58 UTC * * PixiJS is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */var cv=Object.defineProperty,dv=Object.defineProperties,pv=Object.getOwnPropertyDescriptors,Ml=Object.getOwnPropertySymbols,fv=Object.prototype.hasOwnProperty,mv=Object.prototype.propertyIsEnumerable,Ol=(r,t,e)=>t in r?cv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cl=(r,t)=>{for(var e in t||(t={}))fv.call(t,e)&&Ol(r,e,t[e]);if(Ml)for(var e of Ml(t))mv.call(t,e)&&Ol(r,e,t[e]);return r},gv=(r,t)=>dv(r,pv(t)),v=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(v||{});const rn=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=gv(Cl({},t),{ref:r})}if(typeof r=="object")r=Cl({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},lr=(r,t)=>{var e;return(e=rn(r).priority)!=null?e:t},D={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(rn).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(rn).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)=>lr(n.value,e)-lr(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)=>lr(n,e)-lr(i,e)))},s=>{const i=t.indexOf(s.ref);i!==-1&&t.splice(i,1)})}};var zP=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function sn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function VP(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function WP(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function YP(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function s(){return this instanceof s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(s){var i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return r[s]}})}),e}var nn={exports:{}},KP=nn.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(u,l,h){this.fn=u,this.context=l,this.once=h||!1}function n(u,l,h,c,d){if(typeof h!="function")throw new TypeError("The listener must be a function");var p=new i(h,c||u,d),f=e?e+l:l;return u._events[f]?u._events[f].fn?u._events[f]=[u._events[f],p]:u._events[f].push(p):(u._events[f]=p,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new s:delete u._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],h,c;if(this._eventsCount===0)return l;for(c in h=this._events)t.call(h,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=e?e+l:l,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"},nt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},wt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Gl=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Il=function(r){return{r:wt(r.r,0,255),g:wt(r.g,0,255),b:wt(r.b,0,255),a:wt(r.a)}},on=function(r){return{r:nt(r.r),g:nt(r.g),b:nt(r.b),a:nt(r.a,3)}},xv=/^#([0-9a-f]{3,8})$/i,ls=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Bl=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}},Fl=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),u=s*(1-(1-t+n)*e),l=n%6;return{r:255*[s,a,o,o,u,s][l],g:255*[u,s,s,a,o,o][l],b:255*[o,o,u,s,s,a][l],a:i}},Dl=function(r){return{h:Gl(r.h),s:wt(r.s,0,100),l:wt(r.l,0,100),a:wt(r.a)}},Ul=function(r){return{h:nt(r.h),s:nt(r.s),l:nt(r.l),a:nt(r.a,3)}},kl=function(r){return Fl((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},hr=function(r){return{h:(t=Bl(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},vv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Tv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an={string:[[function(r){var t=xv.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?nt(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?nt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Tv.exec(r)||Sv.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Il({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=vv.exec(r)||yv.exec(r);if(!t)return null;var e,s,i=Dl({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(bv[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return kl(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 jt(t)&&jt(e)&&jt(s)?Il({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(!jt(t)||!jt(e)||!jt(s))return null;var o=Dl({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return kl(o)},"hsl"],[function(r){var t=r.h,e=r.s,s=r.v,i=r.a,n=i===void 0?1:i;if(!jt(t)||!jt(e)||!jt(s))return null;var o=function(a){return{h:Gl(a.h),s:wt(a.s,0,100),v:wt(a.v,0,100),a:wt(a.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return Fl(o)},"hsv"]]},$l=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=on(this.rgba),e=t.r,s=t.g,i=t.b,o=(n=t.a)<1?ls(nt(255*n)):"","#"+ls(e)+ls(s)+ls(i)+o;var t,e,s,i,n,o},r.prototype.toRgb=function(){return on(this.rgba)},r.prototype.toRgbString=function(){return t=on(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 Ul(hr(this.rgba))},r.prototype.toHslString=function(){return t=Ul(hr(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=Bl(this.rgba),{h:nt(t.h),s:nt(t.s),v:nt(t.v),a:nt(t.a,3)};var t},r.prototype.invert=function(){return Ut({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),Ut(un(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ut(un(this.rgba,-t))},r.prototype.grayscale=function(){return Ut(un(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Ut(Nl(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Ut(Nl(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"?Ut({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):nt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=hr(this.rgba);return typeof t=="number"?Ut({h:t,s:e.s,l:e.l,a:e.a}):nt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Ut(t).toHex()},r}(),Ut=function(r){return r instanceof hs?r:new hs(r)},Xl=[],Ev=function(r){r.forEach(function(t){Xl.indexOf(t)<0&&(t(hs,an),Xl.push(t))})},ZP=function(){return new hs({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function Av(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,u,l=s[this.toHex()];if(l)return l;if(o!=null&&o.closest){var h=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var g=(a=h,u=n[f],Math.pow(a.r-u.r,2)+Math.pow(a.g-u.g,2)+Math.pow(a.b-u.b,2));gt in r?wv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Mv=(r,t)=>{for(var e in t||(t={}))Pv.call(t,e)&&jl(r,e,t[e]);if(Hl)for(var e of Hl(t))Rv.call(t,e)&&jl(r,e,t[e]);return r};Ev([Av]);const Me=class rs{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 rs)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?Mv({},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]=rs._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(i<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,i,n=255]=t,e/=255,s/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=rs.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ut(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 rs||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}};Me.shared=new Me,Me._temp=new Me,Me.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let z=Me;const zl={cullArea:null,cullable:!1,cullableChildren:!0},Vl=Math.PI*2,Wl=180/Math.PI,Yl=Math.PI/180;class W{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new W(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}static get shared(){return hn.x=0,hn.y=0,hn}}const hn=new W;class C{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 W;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 W;const s=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,u=this.ty,l=1/(s*o+n*-i),h=t.x,c=t.y;return e.x=o*l*h+-n*l*c+(u*n-a*o)*l,e.y=s*l*c+-i*l*h+(-u*s+a*i)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),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,u=t.ty,l=e.a,h=e.b,c=e.c,d=e.d;return this.a=s*l+i*c,this.b=s*h+i*d,this.c=n*l+o*c,this.d=n*h+o*d,this.tx=a*l+u*c+e.tx,this.ty=a*h+u*d+e.ty,this}setTransform(t,e,s,i,n,o,a,u,l){return this.a=Math.cos(a+l)*n,this.b=Math.sin(a+l)*n,this.c=-Math.sin(a-u)*o,this.d=Math.cos(a-u)*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),u=Math.atan2(s,e),l=Math.abs(a+u);return l<1e-5||Math.abs(Vl-l)<1e-5?(t.rotation=u,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=u),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*s+o.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,i=this.d,n=this.tx,o=t*i-e*s;return this.a=i/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-i*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new C;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}static get IDENTITY(){return Cv.identity()}static get shared(){return Ov.identity()}}const Ov=new C,Cv=new C;class st{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new st(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 cr={default:-1};function Z(r="default"){return cr[r]===void 0&&(cr[r]=-1),++cr[r]}function Gv(){for(const r in cr)delete cr[r]}class cs{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,(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(){this._pool.length=0,this._index=0}}class Kl{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new cs(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{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}}const X=new Kl;function cn(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&&s<=e){for(let o=e-1;o>=r;o--){const a=this.children[o];a&&(i.push(a),a.parent=null)}cn(this.children,r,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(i);for(let o=0;o=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(r.parent){const i=r.parent.children.indexOf(r);if(r.parent===this&&i===t)return r;i!==-1&&r.parent.children.splice(i,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r.didViewUpdate=!1,r._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=r;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),r.setFromMatrix(e),r}};class dr{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;ee.priority-s.priority);const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0),this._updateIsSimple()},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),ds.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=ds.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new dr);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 dr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Jl={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=u&&t<=l&&e>=h&&e<=c&&!(t>d&&tf&&et.right?t.right:this.right)<=R)return!1;const T=this.yt.bottom?t.bottom:this.bottom)>T}const s=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=s||o<=n)return!1;const a=ps[0].set(t.left,t.top),u=ps[1].set(t.left,t.bottom),l=ps[2].set(t.right,t.top),h=ps[3].set(t.right,t.bottom);if(l.x<=a.x||u.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(u,u),e.apply(l,l),e.apply(h,h),Math.max(a.x,u.x,l.x,h.x)<=s||Math.min(a.x,u.x,l.x,h.x)>=i||Math.max(a.y,u.y,l.y,h.y)<=n||Math.min(a.y,u.y,l.y,h.y)>=o))return!1;const d=c*(u.y-a.y),p=c*(a.x-u.x),f=d*s+p*n,g=d*i+p*n,m=d*s+p*o,_=d*i+p*o;if(Math.max(f,g,m,_)<=d*a.x+p*a.y||Math.min(f,g,m,_)>=d*h.x+p*h.y)return!1;const x=c*(a.y-l.y),b=c*(l.x-a.x),y=x*s+b*n,S=x*i+b*n,P=x*s+b*o,w=x*i+b*o;return!(Math.max(y,S,P,w)<=x*a.x+b*a.y||Math.min(y,S,P,w)>=x*h.x+b*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}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 V,t.copyFrom(this),t}}const th=new C;class ht{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=th,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 V);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=th,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,u=n.c,l=n.d,h=n.tx,c=n.ty;let d=this.minX,p=this.minY,f=this.maxX,g=this.maxY,m=o*t+u*e+h,_=a*t+l*e+c;mf&&(f=m),_>g&&(g=_),m=o*s+u*e+h,_=a*s+l*e+c,mf&&(f=m),_>g&&(g=_),m=o*t+u*i+h,_=a*t+l*i+c,mf&&(f=m),_>g&&(g=_),m=o*s+u*i+h,_=a*s+l*i+c,mf&&(f=m),_>g&&(g=_),this.minX=d,this.minY=p,this.maxX=f,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*e+u*n+h,p=a*e+l*n+c,this.minX=dthis.maxX?d:this.maxX,this.maxY=p>this.maxY?p:this.maxY,d=o*i+u*n+h,p=a*i+l*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 ht(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,u=this.maxY;i||(i=this.matrix);const l=i.a,h=i.b,c=i.c,d=i.d,p=i.tx,f=i.ty;for(let g=e;ga?x:a,u=b>u?b:u}this.minX=n,this.minY=o,this.maxX=a,this.maxY=u}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}]`}}const kt=new cs(C),$t=new cs(ht);function pr(r,t,e){e.clear();let s,i;return r.parent?t?s=r.parent.worldTransform:(i=kt.get().identity(),s=fr(r,i)):s=C.IDENTITY,dn(r,e,s,t),i&&kt.return(i),e.isValid||e.set(0,0,0,0),e}function dn(r,t,e,s){var i,n;if(!r.visible||!r.measurable)return;let o;s?o=r.worldTransform:(r.updateLocalTransform(),o=kt.get(),o.appendFrom(r.localTransform,e));const a=t,u=!!r.effects.length;if(u&&(t=$t.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{r.addBounds&&(t.matrix=o,r.addBounds(t));for(let l=0;l-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(i)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(Q.prototype,Object.getOwnPropertyDescriptors(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.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=X.get(ah,this),this.groupTransform=C.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),X.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new C),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Wl}set angle(t){this.rotation=t*Yl}get pivot(){return this._pivot===gn&&(this._pivot=new st(this,0,0)),this._pivot}set pivot(t){this._pivot===gn&&(this._pivot=new st(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===mn&&(this._skew=new st(this,0,0)),this._skew}set skew(t){this._skew===mn&&(this._skew=new st(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===_n&&(this._scale=new st(this,1,1)),this._scale}set scale(t){this._scale===_n&&(this._scale=new st(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var s;const i=this.getLocalBounds();typeof t=="object"?(e=(s=t.height)!=null?s:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}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._position,o=s._x,a=s._y,u=i._x,l=i._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=n._x-(u*e.a+l*e.c),e.ty=n._y-(u*e.b+l*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=mr,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=z.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=mr,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ms,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|=Oe,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Oe,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|=Oe,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;const s=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let i=0;i1&&typeof MSStream=="undefined"};function Uv(r){return function(t){return t.test(r)}}function vh(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=Uv(e),n={apple:{phone:i(bn)&&!i(zt),ipod:i(lh),tablet:!i(bn)&&(i(hh)||xh(t))&&!i(zt),universal:i(ch),device:(i(bn)||i(lh)||i(hh)||i(ch)||xh(t))&&!i(zt)},amazon:{phone:i(Ce),tablet:!i(Ce)&&i(gs),device:i(Ce)||i(gs)},android:{phone:!i(zt)&&i(Ce)||!i(zt)&&i(xn),tablet:!i(zt)&&!i(Ce)&&!i(xn)&&(i(gs)||i(dh)),device:!i(zt)&&(i(Ce)||i(gs)||i(xn)||i(dh))||i(/\bokhttp\b/i)},windows:{phone:i(zt),tablet:i(ph),device:i(zt)||i(ph)},other:{blackberry:i(fh),blackberry10:i(mh),opera:i(gh),firefox:i(bh),chrome:i(_h),device:i(fh)||i(mh)||i(gh)||i(bh)||i(_h)},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 yh;const kv=(yh=vh.default)!=null?yh:vh,Th=kv(globalThis.navigator),$v=9,_s=100,Lv=0,Nv=0,Sh=2,Eh=1,Xv=-1e3,Hv=-1e3,jv=2;class vn{constructor(t,e=Th){this._mobileInfo=e,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook();const s=document.createElement("div");s.style.width=`${_s}px`,s.style.height=`${_s}px`,s.style.position="absolute",s.style.top=`${Lv}px`,s.style.left=`${Nv}px`,s.style.zIndex=Sh.toString(),this._div=s,this._renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width=`${Eh}px`,t.style.height=`${Eh}px`,t.style.position="absolute",t.style.top=`${Xv}px`,t.style.left=`${Hv}px`,t.style.zIndex=jv.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(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),(t=this._renderer.view.canvas.parentNode)==null||t.appendChild(this._div))}_deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),(t=this._div.parentNode)==null||t.removeChild(this._div))}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)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._pool.pop();e||(e=document.createElement("button"),e.style.width=`${_s}px`,e.style.height=`${_s}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Sh.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),this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{container:s}=t.target,i=this._renderer.events.rootBoundary,n=Object.assign(new rr(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===$v&&this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}vn.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"accessibility"};const Ah={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1};D.add(vn),Q.mixin(Ah);class yn{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,s=n}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}yn.extension=v.Application;var Vt=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Vt||{});class bs{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 wh=class Et{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 bs(null,null,1/0),this.deltaMS=1/Et.targetFPMS,this.elapsedMS=1/Et.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=Vt.NORMAL){return this._addListener(new bs(t,e,s))}addOnce(t,e,s=Vt.NORMAL){return this._addListener(new bs(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ut.shared:new ut,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Tn.extension=v.Application,D.add(yn),D.add(Tn);let zv=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||(ut.system.add(this._tickerUpdate,this,Vt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(ut.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(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}))}_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 u=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:u&&!n(t,s)&&i(t,s)?l?[t]:[]:null}hitTestRecursive(t,e,s,i,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Wt.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children,l=s;for(let h=u.length-1;h>=0;h--){const c=u[h],d=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,l,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.includeInBuild||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,_r),!t.hitArea.contains(_r.x,_r.y)))return!0;if(t.effects&&t.effects.length)for(let s=0;s0&&u!==n.target){const c=t.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(t,c,u);if(this.dispatchEvent(d,"pointerout"),o&&this.dispatchEvent(d,"mouseout"),!n.composedPath().includes(u)){const p=this.createPointerEvent(t,"pointerleave",u);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(u!==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=u==null?void 0:u.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!==u&&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 l=[],h=(s=this.enableGlobalMoveEvents)!=null?s:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(n,"pointermove"),h&&l.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),h&&l.push("globaltouchmove")),o&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),h&&l.push("globalmousemove"),this.cursor=(i=n.target)==null?void 0:i.cursor),l.length>0&&this.all(n,l),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof Pt))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 Pt))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 Pt))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 u=s.button===2;this.notifyTarget(s,u?"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 u=i.clicksByButton[t.button];if(u.target===a.target&&e-u.timeStamp<200?++u.clickCount:u.clickCount=1,u.target=a.target,u.timeStamp=e,a.detail=u.clickCount,a.pointerType==="mouse"){const l=a.button===2;this.dispatchEvent(a,l?"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 Pt))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 pe))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?Yv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zv=(r,t)=>{for(var e in t||(t={}))Kv.call(t,e)&&Mh(r,e,t[e]);if(Rh)for(var e of Rh(t))qv.call(t,e)&&Mh(r,e,t[e]);return r};const Qv=1,Jv={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Sn=class _l{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Ph(null),Wt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Pt(null),this._rootWheelEvent=new pe(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(Zv({},_l.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,_l._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(){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{u.off(r,a,o)}),n?u.once(r,a,o):u.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 rr))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}};D.add(En),Q.mixin(Oh);var vt=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(vt||{});const Ch={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},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 Gh=Ch;const k={get(){return Gh},set(r){Gh=r}};function Gt(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function br(r){return r.split("?")[0].split("#")[0]}function ty(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ey(r,t,e){return r.replace(new RegExp(ty(t),"g"),e)}function ry(r,t){let e="",s=0,i=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a2){const u=e.lastIndexOf("/");if(u!==e.length-1){u===-1?(e="",s=0):(e=e.slice(0,u),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 ft={toPosix(r){return ey(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){Gt(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(Gt(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const s=br(this.toPosix(t!=null?t:k.get().getBaseUrl())),i=br(this.toPosix(e!=null?e:this.rootname(s)));return r=this.toPosix(r),r.startsWith("/")?ft.join(i,r.slice(1)):this.isAbsolute(r)?r:this.join(s,r)},normalize(r){if(Gt(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=ry(r,!1),r.length>0&&s&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Gt(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(Gt(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){Gt(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){Gt(r),t&&Gt(t),r=br(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 u=r.charCodeAt(n);if(u===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(u===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){Gt(r),r=br(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){Gt(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=br(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,u=-1,l=!0,h=r.length-1,c=0;for(;h>=i;--h){if(e=r.charCodeAt(h),e===47){if(!l){a=h+1;break}continue}u===-1&&(l=!1,u=h+1),e===46?o===-1?o=h:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||u===-1||c===0||c===1&&o===u-1&&o===a+1?u!==-1&&(a===0&&s?t.base=t.name=r.slice(1,u):t.base=t.name=r.slice(a,u)):(a===0&&s?(t.name=r.slice(1,o),t.base=r.slice(1,u)):(t.name=r.slice(a,o),t.base=r.slice(a,u)),t.ext=r.slice(o,u)),t.dir=this.dirname(r),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},Rt=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(s=>typeof s=="string"||e?t(s):s):r);function Ih(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)}),Ih(r,i,0,e,s)}else s.push(r);return s}const xr=r=>!Array.isArray(r);var sy=Object.defineProperty,iy=Object.defineProperties,ny=Object.getOwnPropertyDescriptors,Fh=Object.getOwnPropertySymbols,oy=Object.prototype.hasOwnProperty,ay=Object.prototype.propertyIsEnumerable,Dh=(r,t,e)=>t in r?sy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ge=(r,t)=>{for(var e in t||(t={}))oy.call(t,e)&&Dh(r,e,t[e]);if(Fh)for(var e of Fh(t))ay.call(t,e)&&Dh(r,e,t[e]);return r},uy=(r,t)=>iy(r,ny(t));class Jt{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 Rt(e||s,i=>typeof i=="string"?i:Array.isArray(i)?i.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):i!=null&&i.src?i.src:i,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Ge({alias:n},o))),i.forEach(n=>{const o=n.src,a=n.alias;let u;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);s.push(l),u=[a,l]}else{const l=a.map(h=>this._createBundleAssetId(t,h));s.push(...l),u=[...a,...l]}this.add(uy(Ge({},n),{alias:u,src:o}))}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;Rt(e).forEach(i=>{const{src:n}=i;let{data:o,format:a,loadParser:u}=i;const l=Rt(n).map(d=>typeof d=="string"?Bh(d):Array.isArray(d)?d:[d]),h=this.getAlias(i),c=[];l.forEach(d=>{d.forEach(p=>{var f,g,m;let _={};if(typeof p!="object"){_.src=p;for(let x=0;x{this._assetMap[d]=c})})}resolveBundle(t){const e=xr(t);t=Rt(t);const s={};return t.forEach(i=>{const n=this._bundles[i];if(n){const o=this.resolve(n),a={};for(const u in o){const l=o[u];a[this._extractAssetIdFromBundle(i,u)]=l}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=xr(t);t=Rt(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(u=>{const l=n.filter(h=>h[a]?h[a]===u:!1);l.length&&(n=l)})}),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,format:u}=e;return(this._basePath||this._rootPath)&&(t.src=ft.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=Ge(Ge({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.format=(i=u!=null?u:t.format)!=null?i:Uh(t.src),t}}Jt.RETINA_PREFIX=/@([0-9\.]+)x/;function Uh(r){return r.split(".").pop().split("?").shift().split("#").shift()}const xs=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},fe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],me=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ge=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],_e=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],An=[],kh=[],vs=Math.sign;function ly(){for(let r=0;r<16;r++){const t=[];An.push(t);for(let e=0;e<16;e++){const s=vs(fe[r]*fe[e]+ge[r]*me[e]),i=vs(me[r]*fe[e]+_e[r]*me[e]),n=vs(fe[r]*ge[e]+ge[r]*_e[e]),o=vs(me[r]*ge[e]+_e[r]*_e[e]);for(let a=0;a<16;a++)if(fe[a]===s&&me[a]===i&&ge[a]===n&&_e[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new C;t.set(fe[r],me[r],ge[r],_e[r],0,0),kh.push(t)}}ly();const U={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=>fe[r],uY:r=>me[r],vX:r=>ge[r],vY:r=>_e[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>An[r][t],sub:(r,t)=>An[r][U.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?U.S:U.N:Math.abs(t)*2<=Math.abs(r)?r>0?U.E:U.W:t>0?r>0?U.SE:U.SW:r>0?U.NE:U.NW,matrixAppendRotationInv:(r,t,e=0,s=0)=>{const i=kh[U.inv(t)];i.tx=e,i.ty=s,r.append(i)}},wn=()=>{};function be(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Pn(r){return!(r&r-1)&&!!r}function hy(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 Lt(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var cy=Object.defineProperty,$h=Object.getOwnPropertySymbols,dy=Object.prototype.hasOwnProperty,py=Object.prototype.propertyIsEnumerable,Lh=(r,t,e)=>t in r?cy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nh=(r,t)=>{for(var e in t||(t={}))dy.call(t,e)&&Lh(r,e,t[e]);if($h)for(var e of $h(t))py.call(t,e)&&Lh(r,e,t[e]);return r};const Xh=Object.create(null);function fy(r){const t=Xh[r];return t===void 0&&(Xh[r]=Z("resource")),t}const Hh=class Bx extends pt{constructor(t={}){var e,s,i,n,o,a,u;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Nh(Nh({},Bx.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=(u=t.maxAnisotropy)!=null?u:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=fy(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Hh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let jh=Hh;var my=Object.defineProperty,zh=Object.getOwnPropertySymbols,gy=Object.prototype.hasOwnProperty,_y=Object.prototype.propertyIsEnumerable,Vh=(r,t,e)=>t in r?my(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wh=(r,t)=>{for(var e in t||(t={}))gy.call(t,e)&&Vh(r,e,t[e]);if(zh)for(var e of zh(t))_y.call(t,e)&&Vh(r,e,t[e]);return r};const Yh=class Fx extends pt{constructor(t={}){var e,s,i;super(),this.options=t,this.uid=Z("textureSource"),this._resourceType="textureSource",this._resourceId=Z("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Wh(Wh({},Fx.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(s=this.resourceWidth)!=null?s:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(i=this.resourceHeight)!=null?i:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new jh(Lt(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=Z("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const i=Math.round(t*s),n=Math.round(e*s);return this.width=i/s,this.height=n/s,this._resolution=s,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Z("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=Pn(this.pixelWidth)&&Pn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Yh.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let tt=Yh;var by=Object.defineProperty,xy=Object.defineProperties,vy=Object.getOwnPropertyDescriptors,Kh=Object.getOwnPropertySymbols,yy=Object.prototype.hasOwnProperty,Ty=Object.prototype.propertyIsEnumerable,qh=(r,t,e)=>t in r?by(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sy=(r,t)=>{for(var e in t||(t={}))yy.call(t,e)&&qh(r,e,t[e]);if(Kh)for(var e of Kh(t))Ty.call(t,e)&&qh(r,e,t[e]);return r},Ey=(r,t)=>xy(r,vy(t));class ys extends tt{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(Ey(Sy({},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}}ys.extension=v.TextureSource;const Zh=new C;class Rn{constructor(t,e){this.mapCoord=new C,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let i=0;i{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ss.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ss.BATCH_SIZE;for(;e-t{this._batchIndex*ss.BATCH_SIZE{s[i]=t}),Object.keys(t.textures).forEach(i=>{s[i]=t.textures[i]}),!e){const i=ft.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Jh([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const tc={extension:v.Asset,cache:{test:r=>r instanceof Mn,getCacheableAssets:(r,t)=>Jh(r,t,!1)},resolver:{extension:{type:v.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&Ay.includes(s)},parse:r=>{var t,e;const s=r.split(".");return{resolution:parseFloat((e=(t=Jt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:v.LoadParser,priority:vt.Normal,name:"spritesheetLoader"},async testParse(r,t){return ft.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var s,i,n;const{texture:o,imageFilename:a}=(s=t==null?void 0:t.data)!=null?s:{};let u=ft.dirname(t.src);u&&u.lastIndexOf("/")!==u.length-1&&(u+="/");let l;if(o instanceof A)l=o;else{const d=xs(u+(a!=null?a:r.meta.image),t.src);l=(await e.load([d]))[d]}const h=new Mn(l.source,r);await h.parse();const c=(i=r==null?void 0:r.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(c)){const d=[];for(const f of c){if(typeof f!="string")continue;let g=u+f;(n=t.data)!=null&&n.ignoreMultiPack||(g=xs(g,t.src),d.push(e.load({src:g,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);h.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[h].concat(h.linkedSheets.filter(g=>g!==f))})}return h},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};D.add(tc);function vr(r,t,e,s){const{width:i,height:n}=e.orig,o=e.trim;if(o){const a=o.width,u=o.height;r.minX=o.x-t._x*i-s,r.maxX=r.minX+a,r.minY=o.y-t._y*n-s,r.maxY=r.minY+u}else r.minX=-t._x*i-s,r.maxX=r.minX+i,r.minY=-t._y*n-s,r.maxY=r.minY+n}class xe extends Q{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new ht(0,1,0,0),this._boundsDirty=!0}_updateBounds(){}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:s,y:i}=t;return s>=e.minX&&s<=e.maxX&&i>=e.minY&&i<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}var wy=Object.defineProperty,Ts=Object.getOwnPropertySymbols,ec=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,sc=(r,t,e)=>t in r?wy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Py=(r,t)=>{for(var e in t||(t={}))ec.call(t,e)&&sc(r,e,t[e]);if(Ts)for(var e of Ts(t))rc.call(t,e)&&sc(r,e,t[e]);return r},Ry=(r,t)=>{var e={};for(var s in r)ec.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ts)for(var s of Ts(r))t.indexOf(s)<0&&rc.call(r,s)&&(e[s]=r[s]);return e};class Dt extends xe{constructor(t=A.EMPTY){t instanceof A&&(t={texture:t});const e=t,{texture:s=A.EMPTY,anchor:i,roundPixels:n,width:o,height:a}=e,u=Ry(e,["texture","anchor","roundPixels","width","height"]);super(Py({label:"Sprite"},u)),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new st({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:s.defaultAnchor&&(this.anchor=s.defaultAnchor),this.texture=s,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof A?new Dt(t):new Dt(A.from(t,e))}set texture(t){t||(t=A.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){vr(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:i,height:n}=e.orig;s.maxX=-t._x*i,s.minX=s.maxX+i,s.maxY=-t._y*n,s.minY=s.maxY+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._bounds=null,this._sourceBounds=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 My=new ht;function Ss(r,t,e){const s=My;r.measurable=!0,pr(r,e,s),t.addBoundsMask(s),r.measurable=!1}function Es(r,t,e){const s=$t.get();r.measurable=!0;const i=kt.get().identity(),n=On(r,e,i);fs(r,s,n),r.measurable=!1,t.addBoundsMask(s),kt.return(i),$t.return(s)}function On(r,t,e){return r&&r!==t&&(On(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Cn{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Dt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){Ss(this.mask,t,e)}addLocalBounds(t,e){Es(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}}Cn.extension=v.MaskEffect;class Gn{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"}}Gn.extension=v.MaskEffect;class In{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.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Ss(this.mask,t,e)}addLocalBounds(t,e){Es(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Q}}In.extension=v.MaskEffect;class Yt extends tt{constructor(t){t.resource||(t.resource=k.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;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(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"))}}Yt.extension=v.TextureSource;class ve extends tt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=k.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0,t.resource.width,t.resource.height),t.resource=e}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}}ve.extension=v.TextureSource;let Bn;async function Fn(){return Bn!=null||(Bn=(async()=>{var r;const t=document.createElement("canvas").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"})()),Bn}var Oy=Object.defineProperty,Cy=Object.defineProperties,Gy=Object.getOwnPropertyDescriptors,ic=Object.getOwnPropertySymbols,Iy=Object.prototype.hasOwnProperty,By=Object.prototype.propertyIsEnumerable,nc=(r,t,e)=>t in r?Oy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dn=(r,t)=>{for(var e in t||(t={}))Iy.call(t,e)&&nc(r,e,t[e]);if(ic)for(var e of ic(t))By.call(t,e)&&nc(r,e,t[e]);return r},Fy=(r,t)=>Cy(r,Gy(t));const As=class Dx extends tt{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=Dn(Dn({},Dx.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ut.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Fn(),this._load=new Promise((s,i)=>{this.isValid?s(this):(this._resolve=s,this._reject=i,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ut.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||(ut.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ut.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};As.extension=v.TextureSource,As.defaultOptions=Fy(Dn({},tt.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),As.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let yr=As,Dy=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=Rt(t);let i;for(let u=0;u{n.set(u,e)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(u=>{this._cacheMap.set(u,a)}),o.forEach(u=>{const l=i?i[u]:e;this._cache.has(u)&&this._cache.get(u),this._cache.set(u,n.get(u))})}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 Y=new Dy,Un=[];D.handleByList(v.TextureSource,Un);function Uy(r={}){return kn(r)}function kn(r={}){const t=r&&r.resource,e=t?r.resource:r,s=t?r:{resource:r};for(let i=0;i{Y.has(s)&&Y.remove(s)}),t||Y.set(s,n),n}function ac(r,t=!1){return typeof r=="string"?Y.get(r):r instanceof tt?new A({source:r}):oc(r,t)}A.from=ac,tt.from=kn,D.add(Cn,Gn,In,yr,ve,Yt,ys);class Nt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const i=t[s];this.setResource(i,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var s,i;const n=this.resources[e];t!==n&&(n&&((s=t.off)==null||s.call(t,"change",this.onResourceChange,this)),(i=t.on)==null||i.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var t;const e=this.resources;for(const s in e){const i=e[s];(t=i.off)==null||t.call(i,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}let Tr;function $n(){return(!Tr||Tr!=null&&Tr.isContextLost())&&(Tr=k.get().createCanvas().getContext("webgl",{})),Tr}const ky=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function $y(r){let t="";for(let e=0;e0&&(t+=` else `),e>>=0;return lc[e]||Ly(r,t,e)}let Ln=0;function Ly(r,t,e){const s={};let i=0;Ln||(Ln=ye());for(let o=0;o0){const n=new Uint8Array(r,e*8,i);new Uint8Array(t,e*8,i).set(n)}}const hc={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var it=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",r[r.NONE=4]="NONE",r))(it||{});function Sr(r,t){return t.alphaMode==="no-premultiply-alpha"&&hc[r]||r}class cc{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;tt in r?Ny(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fc=(r,t)=>{for(var e in t||(t={}))Xy.call(t,e)&&pc(r,e,t[e]);if(dc)for(var e of dc(t))Hy.call(t,e)&&pc(r,e,t[e]);return r};class mc{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new cc,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const gc=[];let Xn=0;function _c(){return Xn>0?gc[--Xn]:new mc}function bc(r){gc[Xn++]=r}let Er=0;const xc=class Ki{constructor(t={}){this.uid=Z("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[];var e;Ki.defaultOptions.maxTextures=(e=Ki.defaultOptions.maxTextures)!=null?e:ye(),t=fc(fc({},Ki.defaultOptions),t);const{maxTextures:s,attributesInitialSize:i,indicesInitialSize:n}=t;this.attributeBuffer=new Nn(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=s}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 a=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,l=this.indexBuffer;let h=this._batchIndexSize,c=this._batchIndexStart,d="startBatch";const p=this.maxTextures;for(let f=this.elementStart;f=p||x)&&(this._finishBatch(s,c,h-c,i,o,t,d),d="renderBatch",c=h,o=_,s=_c(),i=s.textures,i.clear(),++Er),g._textureId=m._textureBindLocation=i.count,i.ids[m.uid]=i.count,i.textures[i.count++]=m,g._batch=s,h+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,a,u,g._attributeStart,g._textureId),this.packQuadIndex(l,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,a,u,g._attributeStart,g._textureId),this.packIndex(g,l,g._indexStart,g._attributeStart/this.vertexSize))}i.count>0&&(this._finishBatch(s,c,h-c,i,o,t,d),c=h,++Er),this.elementStart=this.elementSize,this._batchIndexStart=c,this._batchIndexSize=h}_finishBatch(t,e,s,i,n,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=i,t.blendMode=n,t.start=e,t.size=s,++Er,this.batches[this.batchIndex++]=t,o.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 Nn(e);Ps(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const i=s>65535?new Uint32Array(s):new Uint16Array(s);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(H||{});class yt extends pt{constructor(t){let{data:e,size:s}=t;const{usage:i,label:n,shrinkToFit:o}=t;super(),this.uid=Z("buffer"),this._resourceType="buffer",this._resourceId=Z("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=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 static(){return!!(this.descriptor.usage&H.STATIC)}set static(t){t?this.descriptor.usage|=H.STATIC:this.descriptor.usage&=~H.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const i=this._data;if(this._data=t,i.length!==t.length){!this.shrinkToFit&&t.byteLengtha&&(a=p),f>u&&(u=f),pe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const zy=new Float32Array(1),Vy=new Uint32Array(1);class Tc extends Be{constructor(){const t=new yt({data:zy,label:"attribute-batch-buffer",usage:H.VERTEX|H.COPY_DST,shrinkToFit:!1}),e=new yt({data:Vy,label:"index-batch-buffer",usage:H.INDEX|H.COPY_DST,shrinkToFit:!1}),s=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:4*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:5*4}},indexBuffer:e})}}const jn=Object.create(null),Sc=Object.create(null);function Fe(r,t){let e=Sc[r];return e===void 0&&(jn[t]===void 0&&(jn[t]=1),Sc[r]=e=jn[t]++),e}let Rs;function Ec(){if(!Rs){Rs="mediump";const r=$n();r&&r.getShaderPrecisionFormat&&(Rs=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Rs}function Ac(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 wc(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 Pc(r,t){return t?`#version 300 es ${r}`:r}const Wy={},Yy={};function Rc(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Wy:Yy;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} ${r}`}function Mc(r,t){return t?r.replace("#version 300 es",""):r}var Ky=Object.defineProperty,Oc=Object.getOwnPropertySymbols,qy=Object.prototype.hasOwnProperty,Zy=Object.prototype.propertyIsEnumerable,Cc=(r,t,e)=>t in r?Ky(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gc=(r,t)=>{for(var e in t||(t={}))qy.call(t,e)&&Cc(r,e,t[e]);if(Oc)for(var e of Oc(t))Zy.call(t,e)&&Cc(r,e,t[e]);return r};const zn={stripVersion:Mc,ensurePrecision:wc,addProgramDefines:Ac,setProgramName:Rc,insertVersion:Pc},Vn=Object.create(null),Ic=class bl{constructor(t){t=Gc(Gc({},bl.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ec()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let i=t.fragment,n=t.vertex;Object.keys(zn).forEach(o=>{const a=s[o];i=zn[o](i,a,!0),n=zn[o](n,a,!1)}),this.fragment=i,this.vertex=n,this._key=Fe(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Vn[e]||(Vn[e]=new bl(t)),Vn[e]}};Ic.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Mt=Ic;const Bc={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 De(r){var t;return(t=Bc[r])!=null?t:Bc.float32}const Qy={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function Fc({source:r,entryPoint:t}){var e;const s={},i=r.indexOf(`fn ${t}`);if(i!==-1){const n=r.indexOf("->",i);if(n!==-1){const o=r.substring(i,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let u;for(;(u=a.exec(o))!==null;){const l=(e=Qy[u[3]])!=null?e:"float32";s[u[2]]={location:parseInt(u[1],10),format:l,stride:De(l).stride,offset:0,instance:!1,start:0}}}}return s}function Ms(r){var t,e,s;const i=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,u=/:\s*(\w+)/,l=/struct\s+(\w+)\s*{([^}]+)}/g,h=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,d=(t=r.match(i))==null?void 0:t.map(f=>({group:parseInt(f.match(n)[1],10),binding:parseInt(f.match(o)[1],10),name:f.match(a)[2],isUniform:f.match(a)[1]==="",type:f.match(u)[1]}));if(!d)return{groups:[],structs:[]};const p=(s=(e=r.match(l))==null?void 0:e.map(f=>{const g=f.match(c)[1],m=f.match(h).reduce((_,x)=>{const[b,y]=x.split(":");return _[b.trim()]=y.trim(),_},{});return m?{name:g,members:m}:null}).filter(({name:f})=>d.some(g=>g.type===f)))!=null?s:[];return{groups:d,structs:p}}var Ue=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Ue||{});function Dc({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 Wn=Object.create(null);class At{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,s;const{fragment:i,vertex:n,layout:o,gpuLayout:a,name:u}=t;if(this.name=u,this.fragment=i,this.vertex=n,i.source===n.source){const l=Ms(i.source);this.structsAndGroups=l}else{const l=Ms(n.source),h=Ms(i.source);this.structsAndGroups=kc(l,h)}this.layout=o!=null?o:Uc(this.structsAndGroups),this.gpuLayout=a!=null?a:Dc(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=Fe(s,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Fc(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Wn[e]||(Wn[e]=new At(t)),Wn[e]}}function Yn(r,t,e){if(r)for(const s in r){const i=s.toLocaleLowerCase(),n=t[i];if(n){let o=r[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const $c=/\{\{(.*?)\}\}/g;function Kn(r){var t,e;const s={};return((e=(t=r.match($c))==null?void 0:t.map(i=>i.replace(/[{()}]/g,"")))!=null?e:[]).forEach(i=>{s[i]=[]}),s}function Lc(r,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function qn(r,t,e=!1){const s=[];Lc(t,s),r.forEach(a=>{a.header&&Lc(a.header,s)});const i=s;e&&i.sort();const n=i.map((a,u)=>` @location(${u}) ${a},`).join(` `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` ${n} `),o}function Nc(r,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(r))!==null;)t.push(e[1])}function Jy(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function t0(r){const t=/@.*?\s+/g;return r.replace(t,"")}function Xc(r,t){const e=[];Nc(t,e),r.forEach(u=>{u.header&&Nc(u.header,e)});let s=0;const i=e.sort().map(u=>u.indexOf("builtin")>-1?u:`@location(${s++}) ${u}`).join(`, `),n=e.sort().map(u=>` var ${t0(u)};`).join(` `),o=`return VSOutput( ${e.sort().map(u=>` ${Jy(u)}`).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 Zn(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 Te=Object.create(null),Qn=new Map;let e0=0;function Hc({template:r,bits:t}){const e=zc(r,t);if(Te[e])return Te[e];const{vertex:s,fragment:i}=r0(r,t);return Te[e]=Vc(s,i,t),Te[e]}function jc({template:r,bits:t}){const e=zc(r,t);return Te[e]||(Te[e]=Vc(r.vertex,r.fragment,t)),Te[e]}function r0(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let i=qn(e,r.vertex,!0);i=Xc(e,i);const n=qn(s,r.fragment,!0);return{vertex:i,fragment:n}}function zc(r,t){return t.map(e=>(Qn.has(e)||Qn.set(e,e0++),Qn.get(e))).sort((e,s)=>e-s).join("-")+r.vertex+r.fragment}function Vc(r,t,e){const s=Kn(r),i=Kn(t);return e.forEach(n=>{Yn(n.vertex,s,n.name),Yn(n.fragment,i,n.name)}),{vertex:Zn(r,s),fragment:Zn(t,i)}}const Wc=` @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}} }; `,Yc=` @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; }; `,Kc=` 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}} } `,qc=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,Zc={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},s0={name:"global-uniforms-ubo-bit",vertex:{header:` uniform globalUniforms { mat3 uProjectionMatrix; mat3 uWorldTransformMatrix; vec4 uWorldColorAlpha; vec2 uResolution; }; `}},Qc={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};var i0=Object.defineProperty,Jc=Object.getOwnPropertySymbols,n0=Object.prototype.hasOwnProperty,o0=Object.prototype.propertyIsEnumerable,td=(r,t,e)=>t in r?i0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,a0=(r,t)=>{for(var e in t||(t={}))n0.call(t,e)&&td(r,e,t[e]);if(Jc)for(var e of Jc(t))o0.call(t,e)&&td(r,e,t[e]);return r};function ke({bits:r,name:t}){const e=Hc({template:{fragment:Yc,vertex:Wc},bits:[Zc,...r]});return At.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function $e({bits:r,name:t}){return new Mt(a0({name:t},jc({template:{vertex:Kc,fragment:qc},bits:[Qc,...r]})))}const Os={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Cs={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Jn={};function u0(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 l0(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; ${u0(r)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${l0(r)} `}}),Jn[r]}const to={};function h0(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; } `}},Ne={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; } `}},eo=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],ed=eo.reduce((r,t)=>(r[t]=!0,r),{});function rd(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 c0=Object.defineProperty,sd=Object.getOwnPropertySymbols,d0=Object.prototype.hasOwnProperty,p0=Object.prototype.propertyIsEnumerable,id=(r,t,e)=>t in r?c0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nd=(r,t)=>{for(var e in t||(t={}))d0.call(t,e)&&id(r,e,t[e]);if(sd)for(var e of sd(t))p0.call(t,e)&&id(r,e,t[e]);return r};const od=class Ux{constructor(t,e){this._touched=0,this.uid=Z("uniform"),this._resourceType="uniformGroup",this._resourceId=Z("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var s,i;e=nd(nd({},Ux.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,!ed[a.type])throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${eo.join(", ")}`);(i=a.value)!=null||(a.value=rd(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Fe(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};od.defaultOptions={ubo:!1,isStatic:!1};let rt=od;const ad={};function Bs(r){let t=ad[r];if(t)return t;const e=new Int32Array(r);for(let s=0;s(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(mt||{}),f0=Object.defineProperty,Fs=Object.getOwnPropertySymbols,ud=Object.prototype.hasOwnProperty,ld=Object.prototype.propertyIsEnumerable,hd=(r,t,e)=>t in r?f0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,m0=(r,t)=>{for(var e in t||(t={}))ud.call(t,e)&&hd(r,e,t[e]);if(Fs)for(var e of Fs(t))ld.call(t,e)&&hd(r,e,t[e]);return r},g0=(r,t)=>{var e={};for(var s in r)ud.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Fs)for(var s of Fs(r))t.indexOf(s)<0&&ld.call(r,s)&&(e[s]=r[s]);return e};class Ct extends pt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=mt.WEBGPU),s&&(o|=mt.WEBGL)),this.compatibleRenderers=o;const u={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&i&&a)for(const l in a)for(const h in a[l]){const c=a[l][h];u[c]={group:l,binding:h,name:c}}else if(e&&i&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,u[h.name]=h})}else if(n){i={},a={},e&&e.structsAndGroups.groups.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,u[h.name]=h});let l=0;for(const h in n)u[h]||(i[99]||(i[99]=new Nt,this._ownedBindGroups.push(i[99])),u[h]={group:99,binding:l,name:h},a[99]=a[99]||{},a[99][l]=h,l++);for(const h in n){const c=h;let d=n[h];!d.source&&!d._resourceType&&(d=new rt(d));const p=u[c];p&&(i[p.group]||(i[p.group]=new Nt,this._ownedBindGroups.push(i[p.group])),i[p.group].setResource(d,p.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 Nt,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.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(i=>{i.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const e=t,{gpu:s,gl:i}=e,n=g0(e,["gpu","gl"]);let o,a;return s&&(o=At.from(s)),i&&(a=Mt.from(i)),new Ct(m0({gpuProgram:o,glProgram:a},n))}}class cd extends Ct{constructor(t){const e=$e({name:"batch",bits:[Cs,Is(t),Ne]}),s=ke({name:"batch",bits:[Os,Gs(t),Le]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Bs(t)}})}}let dd=null;const pd=class kx extends vc{constructor(){super(...arguments),this.geometry=new Tc,this.shader=dd||(dd=new cd(this.maxTextures)),this.name=kx.extension.name,this.vertexSize=6}packAttributes(t,e,s,i,n){const o=n<<16|t.roundPixels&65535,a=t.transform,u=a.a,l=a.b,h=a.c,c=a.d,d=a.tx,p=a.ty,{positions:f,uvs:g}=t,m=t.color,_=t.attributeOffset,x=_+t.attributeSize;for(let b=_;b>16&255,s=r>>8&255,i=r&255,n=t>>16&255,o=t>>8&255,a=t&255,u=e*n/255,l=s*o/255,h=i*a/255;return(u<<16)+(l<<8)+h}const b0=new C;class ks{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?gd(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)||b0}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}reset(){this.applyTransform=!0,this.renderable=null}}var x0=Object.defineProperty,v0=Object.defineProperties,y0=Object.getOwnPropertyDescriptors,_d=Object.getOwnPropertySymbols,T0=Object.prototype.hasOwnProperty,S0=Object.prototype.propertyIsEnumerable,bd=(r,t,e)=>t in r?x0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$s=(r,t)=>{for(var e in t||(t={}))T0.call(t,e)&&bd(r,e,t[e]);if(_d)for(var e of _d(t))S0.call(t,e)&&bd(r,e,t[e]);return r},Ls=(r,t)=>v0(r,y0(t));const Kt={extension:{type:v.ShapeBuilder,name:"circle"},build(r,t){let e,s,i,n,o,a;if(r.type==="circle"){const y=r;e=y.x,s=y.y,o=a=y.radius,i=n=0}else if(r.type==="ellipse"){const y=r;e=y.x,s=y.y,o=y.halfWidth,a=y.halfHeight,i=n=0}else{const y=r,S=y.width/2,P=y.height/2;e=y.x+S,s=y.y+P,o=a=Math.max(0,Math.min(y.radius,Math.min(S,P))),i=S-o,n=P-a}if(!(o>=0&&a>=0&&i>=0&&n>=0))return t;const u=Math.ceil(2.3*Math.sqrt(o+a)),l=u*8+(i?4:0)+(n?4:0);if(l===0)return t;if(u===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,t;let h=0,c=u*4+(i?2:0)+2,d=c,p=l,f=i+o,g=n,m=e+f,_=e-f,x=s+g;if(t[h++]=m,t[h++]=x,t[--c]=x,t[--c]=_,n){const y=s-g;t[d++]=_,t[d++]=y,t[--p]=y,t[--p]=m}for(let y=1;y0&&(i[n++]=u,i[n++]=l,i[n++]=u-1),u++;i[n++]=l+1,i[n++]=l,i[n++]=u-1}},xd=Ls($s({},Kt),{extension:Ls($s({},Kt.extension),{name:"ellipse"})}),vd=Ls($s({},Kt),{extension:Ls($s({},Kt.extension),{name:"roundedRectangle"})}),yd=1e-4,no=1e-4;function Td(r){const t=r.length;if(t<6)return 1;let e=0;for(let s=0,i=r[t-2],n=r[t-1];sc&&(c+=Math.PI*2);let d=h;const p=c-h,f=Math.abs(p),g=Math.sqrt(u*u+l*l),m=(15*f*Math.sqrt(g)/Math.PI>>0)+1,_=p/m;if(d+=_,a){o.push(r,t),o.push(e,s);for(let x=1,b=d;x=0&&(h.join==="round"?x+=Se(T,E,T-O*I,E-G*I,T-K*I,E-L*I,m,!1)+4:x+=2,m.push(T-K*F,E-L*F),m.push(T+K*I,E+L*I));continue}const wl=(-O+w)*(-G+E)-(-O+T)*(-G+R),Pl=(-K+N)*(-L+E)-(-K+T)*(-L+$),as=(Qt*Pl-or*wl)/os,us=(ar*wl-nr*Pl)/os,en=(as-T)*(as-T)+(us-E)*(us-E),le=T+(as-T)*I,he=E+(us-E)*I,ce=T-(as-T)*F,de=E-(us-E)*F,lv=Math.min(Qt*Qt+nr*nr,or*or+ar*ar),Rl=ur?I:F,hv=lv+Rl*Rl*S;en<=hv?h.join==="bevel"||en/S>P?(ur?(m.push(le,he),m.push(T+O*F,E+G*F),m.push(le,he),m.push(T+K*F,E+L*F)):(m.push(T-O*I,E-G*I),m.push(ce,de),m.push(T-K*I,E-L*I),m.push(ce,de)),x+=2):h.join==="round"?ur?(m.push(le,he),m.push(T+O*F,E+G*F),x+=Se(T,E,T+O*F,E+G*F,T+K*F,E+L*F,m,!0)+4,m.push(le,he),m.push(T+K*F,E+L*F)):(m.push(T-O*I,E-G*I),m.push(ce,de),x+=Se(T,E,T-O*I,E-G*I,T-K*I,E-L*I,m,!1)+4,m.push(T-K*I,E-L*I),m.push(ce,de)):(m.push(le,he),m.push(ce,de)):(m.push(T-O*I,E-G*I),m.push(T+O*F,E+G*F),h.join==="round"?ur?x+=Se(T,E,T+O*F,E+G*F,T+K*F,E+L*F,m,!0)+2:x+=Se(T,E,T-O*I,E-G*I,T-K*I,E-L*I,m,!1)+2:h.join==="miter"&&en/S<=P&&(ur?(m.push(ce,de),m.push(ce,de)):(m.push(le,he),m.push(le,he)),x+=2),m.push(T-K*I,E-L*I),m.push(T+K*F,E+L*F),x+=2)}w=r[(_-2)*2],R=r[(_-2)*2+1],T=r[(_-1)*2],E=r[(_-1)*2+1],O=-(R-E),G=w-T,xt=Math.sqrt(O*O+G*G),O/=xt,G/=xt,O*=y,G*=y,m.push(T-O*I,E-G*I),m.push(T+O*F,E+G*F),f||(h.cap==="round"?x+=Se(T-O*(I-F)*.5,E-G*(I-F)*.5,T-O*I,E-G*I,T+O*F,E+G*F,m,!1)+2:h.cap==="square"&&(x+=Sd(T,E,O,G,I,F,!1,m)));const uv=no*no;for(let q=b;q80*e){a=l=r[0],u=h=r[1];for(var f=e;fl&&(l=c),d>h&&(h=d);p=Math.max(l-a,h-u),p=p!==0?32767/p:0}return Ar(n,o,e,a,u,p,0),o}function Ad(r,t,e,s,i){var n,o;if(i===uo(r,t,e,s)>0)for(n=t;n=t;n-=s)o=Rd(n,r[n],r[n+1],o);return o&&Hs(o,o.next)&&(Pr(o),o=o.next),o}function Ee(r,t){if(!r)return r;t||(t=r);var e=r,s;do if(s=!1,!e.steiner&&(Hs(e,e.next)||J(e.prev,e,e.next)===0)){if(Pr(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Ar(r,t,e,s,i,n,o){if(r){!o&&n&&I0(r,s,i,n);for(var a=r,u,l;r.prev!==r.next;){if(u=r.prev,l=r.next,n?A0(r,s,i,n):E0(r)){t.push(u.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Pr(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=w0(Ee(r),t,e),Ar(r,t,e,s,i,n,2)):o===2&&P0(r,t,e,s,i,n):Ar(Ee(r),t,e,s,i,n,1);break}}}}function E0(r){var t=r.prev,e=r,s=r.next;if(J(t,e,s)>=0)return!1;for(var i=t.x,n=e.x,o=s.x,a=t.y,u=e.y,l=s.y,h=in?i>o?i:o:n>o?n:o,p=a>u?a>l?a:l:u>l?u:l,f=s.next;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=c&&f.y<=p&&Xe(i,a,n,u,o,l,f.x,f.y)&&J(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function A0(r,t,e,s){var i=r.prev,n=r,o=r.next;if(J(i,n,o)>=0)return!1;for(var a=i.x,u=n.x,l=o.x,h=i.y,c=n.y,d=o.y,p=au?a>l?a:l:u>l?u:l,m=h>c?h>d?h:d:c>d?c:d,_=oo(p,f,t,e,s),x=oo(g,m,t,e,s),b=r.prevZ,y=r.nextZ;b&&b.z>=_&&y&&y.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==i&&b!==o&&Xe(a,h,u,c,l,d,b.x,b.y)&&J(b.prev,b,b.next)>=0||(b=b.prevZ,y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&Xe(a,h,u,c,l,d,y.x,y.y)&&J(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;b&&b.z>=_;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==i&&b!==o&&Xe(a,h,u,c,l,d,b.x,b.y)&&J(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;y&&y.z<=x;){if(y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&Xe(a,h,u,c,l,d,y.x,y.y)&&J(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function w0(r,t,e){var s=r;do{var i=s.prev,n=s.next.next;!Hs(i,n)&&wd(i,s,s.next,n)&&wr(i,n)&&wr(n,i)&&(t.push(i.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),Pr(s),Pr(s.next),s=r=n),s=s.next}while(s!==r);return Ee(s)}function P0(r,t,e,s,i,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&D0(o,a)){var u=Pd(o,a);o=Ee(o,o.next),u=Ee(u,u.next),Ar(o,t,e,s,i,n,0),Ar(u,t,e,s,i,n,0);return}a=a.next}o=o.next}while(o!==r)}function R0(r,t,e,s){var i=[],n,o,a,u,l;for(n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){var a=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=s&&a>n&&(n=a,o=e.x=e.x&&e.x>=l&&s!==e.x&&Xe(io.x||e.x===o.x&&G0(o,e)))&&(o=e,c=d)),e=e.next;while(e!==u);return o}function G0(r,t){return J(r.prev,r,t.prev)<0&&J(t.next,r,r.next)<0}function I0(r,t,e,s){var i=r;do i.z===0&&(i.z=oo(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,B0(i)}function B0(r){var t,e,s,i,n,o,a,u,l=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,s=e,a=0,t=0;t0||u>0&&s;)a!==0&&(u===0||!s||e.z<=s.z)?(i=e,e=e.nextZ,a--):(i=s,s=s.nextZ,u--),n?n.nextZ=i:r=i,i.prevZ=n,n=i;e=s}n.nextZ=null,l*=2}while(o>1);return r}function oo(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 F0(r){var 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 D0(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!U0(r,t)&&(wr(r,t)&&wr(t,r)&&k0(r,t)&&(J(r.prev,r,t.prev)||J(r,t.prev,t))||Hs(r,t)&&J(r.prev,r,r.next)>0&&J(t.prev,t,t.next)>0)}function J(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Hs(r,t){return r.x===t.x&&r.y===t.y}function wd(r,t,e,s){var i=zs(J(r,t,e)),n=zs(J(r,t,s)),o=zs(J(e,s,r)),a=zs(J(e,s,t));return!!(i!==n&&o!==a||i===0&&js(r,e,t)||n===0&&js(r,s,t)||o===0&&js(e,r,s)||a===0&&js(e,t,s))}function js(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 zs(r){return r>0?1:r<0?-1:0}function U0(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&wd(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function wr(r,t){return J(r.prev,r,r.next)<0?J(r,t,r.next)>=0&&J(r,r.prev,t)>=0:J(r,t,r.prev)<0||J(r,r.next,t)<0}function k0(r,t){var e=r,s=!1,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 Pd(r,t){var e=new ao(r.i,r.x,r.y),s=new ao(t.i,t.x,t.y),i=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function Rd(r,t,e,s){var i=new ao(r,t,e);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Pr(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function ao(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Xs.deviation=function(r,t,e,s){var i=t&&t.length,n=i?t[0]*e:r.length,o=Math.abs(uo(r,0,n,e));if(i)for(var a=0,u=t.length;a0&&(s+=r[i-1].length,e.holes.push(s))}return e};var $0=Ns.exports,Md=sn($0);function lo(r,t,e,s,i,n,o){const a=Md(r,t,2);if(!a)return;for(let l=0;l=0&&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),t},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}},po={extension:{type:v.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,t},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}},Rr={};D.handleByMap(v.ShapeBuilder,Rr),D.add(co,ho,po,Kt,xd,vd);const N0=new V;function Od(r,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let i=0;i{var p;const f=u.length,g=o.length/2,m=[],_=Rr[h.type];if(_.build(h,m),c&&Us(m,c),s){const S=(p=h.closePath)!=null?p:!0;Ed(m,t,!1,S,o,2,g,u,f)}else if(e&&l===d){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],P=m.slice();H0(e.shapePath).forEach(w=>{S.push(P.length/2),P.push(...w)}),lo(P,S,o,2,g,u,f)}else _.triangulate(m,o,2,g,u,f);const x=a.length/2,b=t.texture;if(b!==A.WHITE){const S=t.matrix;S&&(c&&S.append(c.clone().invert()),so(o,2,g,a,x,2,o.length/2-g,S))}else io(a,x,2,o.length/2-g);const y=X.get(ks);y.indexOffset=f,y.indexSize=u.length-f,y.attributeOffset=g,y.attributeSize=o.length/2-g,y.baseColor=t.color,y.alpha=t.alpha,y.texture=b,y.geometryData=n,i.push(y)})}function H0(r){if(!r)return[];const t=r.shapePrimitives,e=[];for(let s=0;s{X.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};fo.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"graphicsContext"},fo.defaultOptions={bezierSmoothness:.5};let Vs=fo;const j0={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},mo=0,go=1,_o=2,bo=3,xo=4,vo=5,yo=class $x{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<>16&255)/255,e[s++]=(r>>8&255)/255,e[s++]=(r&255)/255,e[s++]=t}function Mr(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 To{constructor(t,e){this.state=It.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=t.context,s=!!this._graphicsBatchesHash[t.uid],i=this.renderer.graphicsContext.updateGpuContext(e);return!!(i.isBatchable||s!==i.isBatchable)}addRenderable(t,e){const s=this.renderer.graphicsContext.updateGpuContext(t.context);t._didGraphicsUpdate&&(t._didGraphicsUpdate=!1,this._rebuild(t)),s.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._graphicsBatchesHash[t.uid];if(e)for(let s=0;s{const a=X.get(ks);return o.copyTo(a),a.renderable=t,a.roundPixels=i,a});return this._graphicsBatchesHash[t.uid]===void 0&&t.on("destroyed",this._destroyRenderableBound),this._graphicsBatchesHash[t.uid]=n,n}_removeBatchForRenderable(t){this._graphicsBatchesHash[t].forEach(e=>{X.return(e)}),this._graphicsBatchesHash[t]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const t in this._graphicsBatchesHash)this._removeBatchForRenderable(t);this._graphicsBatchesHash=null}}To.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"graphics"},D.add(To),D.add(Vs);class Ws{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,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 Nt({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),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),a=t.texture;if(o.texture._source!==a._source&&o.texture._source!==a._source)return!o._batcher.checkAndUpdateTexture(o,a)}return!1}addRenderable(t,e){const s=this.renderer.renderPipes.batch,{batched:i}=this._getMeshData(t);if(i){const n=this._getBatchableMesh(t);n.texture=t._texture,n.geometry=t._geometry,s.addToBatch(n,e)}else s.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._gpuBatchableMeshHash[t.uid];e.texture=t._texture,e.geometry=t._geometry,e._batcher.updateElement(e)}}destroyRenderable(t){this._meshDataHash[t.uid]=null;const e=this._gpuBatchableMeshHash[t.uid];e&&(X.return(e),this._gpuBatchableMeshHash[t.uid]=null),t.off("destroyed",this._destroyRenderableBound)}execute(t){if(!t.isRenderable)return;t.state.blendMode=Sr(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Mr(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){return this._meshDataHash[t.uid]||this._initMeshData(t)}_initMeshData(t){var e,s;return this._meshDataHash[t.uid]={batched:t.batched,indexSize:(e=t._geometry.indices)==null?void 0:e.length,vertexSize:(s=t._geometry.positions)==null?void 0:s.length},t.on("destroyed",this._destroyRenderableBound),this._meshDataHash[t.uid]}_getBatchableMesh(t){return this._gpuBatchableMeshHash[t.uid]||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=X.get(Ws);return e.renderable=t,e.texture=t._texture,e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,this._gpuBatchableMeshHash[t.uid]=e,e}destroy(){for(const t in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[t]&&X.return(this._gpuBatchableMeshHash[t]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}So.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"mesh"},D.add(So);class Ys{constructor(){this.batcherName="default",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}}class Eo{constructor(t){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const t in this._gpuText){const e=this._gpuText[t];if(!e)continue;const s=e.batchableSprite.renderable;s._autoResolution&&(s._resolution=this._renderer.resolution,s.onViewUpdate())}}validateRenderable(t){const e=this._getGpuText(t),s=t._getKey();if(e.currentKey!==s){const{width:i,height:n}=this._renderer.canvasText.getTextureSize(t.text,t.resolution,t._style);return!(this._renderer.canvasText.getReferenceCount(e.currentKey)===1&&i===e.texture._source.width&&n===e.texture._source.height)}return!1}addRenderable(t,e){const s=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t).batchableSprite;t._didTextUpdate&&this._updateText(t),e._batcher.updateElement(e)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(t.uid)}_destroyRenderableById(t){const e=this._gpuText[t];this._renderer.canvasText.decreaseReferenceCount(e.currentKey),X.return(e.batchableSprite),this._gpuText[t]=null}_updateText(t){const e=t._getKey(),s=this._getGpuText(t),i=s.batchableSprite;s.currentKey!==e&&this._updateGpuText(t),t._didTextUpdate=!1;const n=t._style.padding;vr(i.bounds,t._anchor,i.texture,n)}_updateGpuText(t){const e=this._getGpuText(t),s=e.batchableSprite;e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),e.texture=s.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t._getKey(),s.texture=e.texture}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:null,currentKey:"--",batchableSprite:X.get(Ys)};return e.batchableSprite.renderable=t,e.batchableSprite.transform=t.groupTransform,e.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},e.batchableSprite.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuText[t.uid]=e,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,this._updateText(t),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Eo.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"text"};class Bd{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=k.get().createCanvas();s.width=t,s.height=e;const i=s.getContext("2d");return{canvas:s,context:i}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=be(t),e=be(e);const i=(t<<17)+(e<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:i}=e,n=(s<<17)+(i<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Xt=new Bd;var V0=Object.defineProperty,W0=Object.defineProperties,Y0=Object.getOwnPropertyDescriptors,Fd=Object.getOwnPropertySymbols,K0=Object.prototype.hasOwnProperty,q0=Object.prototype.propertyIsEnumerable,Dd=(r,t,e)=>t in r?V0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Z0=(r,t)=>{for(var e in t||(t={}))K0.call(t,e)&&Dd(r,e,t[e]);if(Fd)for(var e of Fd(t))q0.call(t,e)&&Dd(r,e,t[e]);return r},Q0=(r,t)=>W0(r,Y0(t));let J0=0;class Ud{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1}createTexture(t,e,s){const i=new tt(Q0(Z0({},this.textureOptions),{width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!0}));return new A({source:i,label:`texturePool_${J0++}`})}getOptimalTexture(t,e,s=1,i){let n=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);n=be(n),o=be(o);const a=(n<<17)+(o<<1)+(i?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let u=this._texturePool[a].pop();return u||(u=this.createTexture(n,o,i)),u.source._resolution=s,u.source.width=n/s,u.source.height=o/s,u.source.pixelWidth=n,u.source.pixelHeight=o,u.frame.x=0,u.frame.y=0,u.frame.width=t,u.frame.height=e,u.updateUvs(),this._poolKeyHash[u.uid]=a,u}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t){const e=this._poolKeyHash[t.uid];this._texturePool[e].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let i=0;i`${i.offset}-${i.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Nd.defaultTextureSize=256;let He=Nd;const Xd={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Or{constructor(t,e){this.uid=Z("fillPattern"),this.transform=new C,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Xd[e].addressModeU,t.source.style.addressModeV=Xd[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var t1=r1,Ao={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e1=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function r1(r){var t=[];return r.replace(e1,function(e,s,i){var n=s.toLowerCase();for(i=i1(i),n=="m"&&i.length>2&&(t.push([s].concat(i.splice(0,2))),n="l",s=s=="m"?"l":"L");;){if(i.length==Ao[n])return i.unshift(s),t.push(i);if(i.length0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:}l!=="Z"&&l!=="z"&&i===null&&(i={startX:n,startY:o},s.push(i))}return t}class Zi{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Zi(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){if(this.radius===0)return!1;const i=this.x-t,n=this.y-e,o=this.radius,a=s/2,u=Math.sqrt(i*i+n*n);return uo-a}getBounds(t){return t=t||new V,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 Qi{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 Qi(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){const{halfWidth:i,halfHeight:n}=this;if(i<=0||n<=0)return!1;const o=s/2,a=i-o,u=n-o,l=i+o,h=n+o,c=t-this.x,d=e-this.y,p=c*c/(a*a)+d*d/(u*u),f=c*c/(l*l)+d*d/(h*h);return p>1&&f<=1}getBounds(t){return t=t||new V,t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}function Cr(r,t,e,s,i,n){const o=r-e,a=t-s,u=i-e,l=n-s,h=o*u+a*l,c=u*u+l*l;let d=-1;c!==0&&(d=h/c);let p,f;d<0?(p=e,f=s):d>1?(p=i,f=n):(p=e+d*u,f=s+d*l);const g=r-p,m=t-f;return g*g+m*m}class sr{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<(l-a)*((e-u)/(h-u))+a&&(s=!s)}return s}strokeContains(t,e,s){const i=s/2,n=i*i,{points:o}=this,a=o.length-(this.closePath?0:2);for(let u=0;ui?l: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]}}const Ks=(r,t,e,s,i,n)=>{const o=r-e,a=t-s,u=Math.sqrt(o*o+a*a);return u>=i-n&&u<=i+n};class Ji{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 V,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Ji(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let i=t-(this.x+s),n=e-(this.y+s);const o=s*s;if(i*i+n*n<=o||(i=t-(this.x+this.width-s),i*i+n*n<=o)||(n=e-(this.y+this.height-s),i*i+n*n<=o)||(i=t-(this.x+s),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,s){const{x:i,y:n,width:o,height:a,radius:u}=this,l=s/2,h=i+u,c=n+u,d=o-u*2,p=a-u*2,f=i+o,g=n+a;return(t>=i-l&&t<=i+l||t>=f-l&&t<=f+l)&&e>=c&&e<=c+p||(e>=n-l&&e<=n+l||e>=g-l&&e<=g+l)&&t>=h&&t<=h+d?!0:tf-u&&ef-u&&e>g-u&&Ks(t,e,f-u,g-u,u,l)||tg-u&&Ks(t,e,h,g-u,u,l)}}const o1=8,qs=11920929e-14,a1=1,wo=.01,je=0,Ae=0;function Po(r,t,e,s,i,n,o,a,u,l){const h=Math.min(.99,Math.max(0,l!=null?l:Vs.defaultOptions.bezierSmoothness));let c=(a1-h)/1;return c*=c,u1(t,e,s,i,n,o,a,u,r,c),r}function u1(r,t,e,s,i,n,o,a,u,l){Ro(r,t,e,s,i,n,o,a,u,l,0),u.push(o,a)}function Ro(r,t,e,s,i,n,o,a,u,l,h){if(h>o1)return;const c=Math.PI,d=(r+e)/2,p=(t+s)/2,f=(e+i)/2,g=(s+n)/2,m=(i+o)/2,_=(n+a)/2,x=(d+f)/2,b=(p+g)/2,y=(f+m)/2,S=(g+_)/2,P=(x+y)/2,w=(b+S)/2;if(h>0){let R=o-r,T=a-t;const E=Math.abs((e-o)*T-(s-a)*R),N=Math.abs((i-o)*T-(n-a)*R);let $,O;if(E>qs&&N>qs){if((E+N)*(E+N)<=l*(R*R+T*T)){if(je=c&&($=2*c-$),O>=c&&(O=2*c-O),$+OAe){u.push(e,s);return}if(O>Ae){u.push(i,n);return}}}}else if(E>qs){if(E*E<=l*(R*R+T*T)){if(je=c&&($=2*c-$),$Ae){u.push(e,s);return}}}else if(N>qs){if(N*N<=l*(R*R+T*T)){if(je=c&&($=2*c-$),$Ae){u.push(i,n);return}}}else if(R=P-(r+o)/2,T=w-(t+a)/2,R*R+T*T<=l){u.push(P,w);return}}Ro(r,t,d,p,x,b,P,w,u,l,h+1),Ro(P,w,y,S,m,_,o,a,u,l,h+1)}const l1=8,h1=11920929e-14,c1=1,d1=.01,jd=0;function zd(r,t,e,s,i,n,o,a){const u=Math.min(.99,Math.max(0,a!=null?a:Vs.defaultOptions.bezierSmoothness));let l=(c1-u)/1;return l*=l,p1(t,e,s,i,n,o,r,l),r}function p1(r,t,e,s,i,n,o,a){Mo(o,r,t,e,s,i,n,a,0),o.push(i,n)}function Mo(r,t,e,s,i,n,o,a,u){if(u>l1)return;const l=Math.PI,h=(t+s)/2,c=(e+i)/2,d=(s+n)/2,p=(i+o)/2,f=(h+d)/2,g=(c+p)/2;let m=n-t,_=o-e;const x=Math.abs((s-n)*_-(i-o)*m);if(x>h1){if(x*x<=a*(m*m+_*_)){if(jd=l&&(b=2*l-b),bn||o&&n>i)&&(u=2*Math.PI-u),a=a||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(u/Math.PI))),a=Math.max(a,3);let l=u/a,h=i;l*=o?-1:1;for(let c=0;ch*a)}const Gr=Math.PI*2,Co={centerX:0,centerY:0,ang1:0,ang2:0},Go=({x:r,y:t},e,s,i,n,o,a,u)=>{r*=e,t*=s;const l=i*r-n*t,h=n*r+i*t;return u.x=l+o,u.y=h+a,u};function f1(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 Wd=(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)},m1=(r,t,e,s,i,n,o,a,u,l,h,c,d)=>{const p=Math.pow(i,2),f=Math.pow(n,2),g=Math.pow(h,2),m=Math.pow(c,2);let _=p*f-p*m-f*g;_<0&&(_=0),_/=p*m+f*g,_=Math.sqrt(_)*(o===a?-1:1);const x=_*i/n*c,b=_*-n/i*h,y=l*x-u*b+(r+e)/2,S=u*x+l*b+(t+s)/2,P=(h-x)/i,w=(c-b)/n,R=(-h-x)/i,T=(-c-b)/n,E=Wd(1,0,P,w);let N=Wd(P,w,R,T);a===0&&N>0&&(N-=Gr),a===1&&N<0&&(N+=Gr),d.centerX=y,d.centerY=S,d.ang1=E,d.ang2=N};function Yd(r,t,e,s,i,n,o,a=0,u=0,l=0){if(n===0||o===0)return;const h=Math.sin(a*Gr/360),c=Math.cos(a*Gr/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)),m1(t,e,s,i,n,o,u,l,h,c,d,p,Co);let{ang1:g,ang2:m}=Co;const{centerX:_,centerY:x}=Co;let b=Math.abs(m)/(Gr/4);Math.abs(1-b)<1e-7&&(b=1);const y=Math.max(Math.ceil(b),1);m/=y;let S=r[r.length-2],P=r[r.length-1];const w={x:0,y:0};for(let R=0;R{const l=u.x-a.x,h=u.y-a.y,c=Math.sqrt(l*l+h*h),d=l/c,p=h/c;return{len:c,nx:d,ny:p}},n=(a,u)=>{a===0?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y)};let o=t[t.length-1];for(let a=0;a0&&(f=-1,g=!0);const m=p/2;let _,x=Math.abs(Math.cos(m)*l/Math.sin(m));x>Math.min(c.len/2,d.len/2)?(x=Math.min(c.len/2,d.len/2),_=Math.abs(x*Math.sin(m)/Math.cos(m))):_=l;const b=u.x+d.nx*x+-d.ny*_*f,y=u.y+d.ny*x+d.nx*_*f,S=Math.atan2(c.ny,c.nx)+Math.PI/2*f,P=Math.atan2(d.ny,d.nx)-Math.PI/2*f;a===0&&r.moveTo(b+Math.cos(S)*_,y+Math.sin(S)*_),r.arc(b,y,_,S,P,g),o=u}}function qd(r,t,e,s){var i;const n=(u,l)=>Math.sqrt((u.x-l.x)**2+(u.y-l.y)**2),o=(u,l,h)=>({x:u.x+(l.x-u.x)*h,y:u.y+(l.y-u.y)*h}),a=t.length;for(let u=0;u=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 Qi(t,e,s,i),n),this}roundRect(t,e,s,i,n,o){return this.drawShape(new Ji(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 sr,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 sr,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;et in r?_1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zs=(r,t)=>{for(var e in t||(t={}))b1.call(t,e)&&Jd(r,e,t[e]);if(Qd)for(var e of Qd(t))x1.call(t,e)&&Jd(r,e,t[e]);return r};function tp(r,t){if(typeof r=="string"){const s=document.createElement("div");s.innerHTML=r.trim(),r=s.querySelector("svg")}const e={context:t,path:new ue};return ep(r,e,null,null),t}function ep(r,t,e,s){const i=r.children,{fillStyle:n,strokeStyle:o}=v1(r);n&&e?e=Zs(Zs({},e),n):n&&(e=n),o&&s?s=Zs(Zs({},s),o):o&&(s=o),t.context.fillStyle=e,t.context.strokeStyle=s;let a,u,l,h,c,d,p,f,g,m,_,x,b,y,S,P,w;switch(r.nodeName.toLowerCase()){case"path":y=r.getAttribute("d"),S=new ue(y),t.context.path(S),e&&t.context.fill(),s&&t.context.stroke();break;case"circle":p=ot(r,"cx",0),f=ot(r,"cy",0),g=ot(r,"r",0),t.context.ellipse(p,f,g,g),e&&t.context.fill(),s&&t.context.stroke();break;case"rect":a=ot(r,"x",0),u=ot(r,"y",0),P=ot(r,"width",0),w=ot(r,"height",0),m=ot(r,"rx",0),_=ot(r,"ry",0),m||_?t.context.roundRect(a,u,P,w,m||_):t.context.rect(a,u,P,w),e&&t.context.fill(),s&&t.context.stroke();break;case"ellipse":p=ot(r,"cx",0),f=ot(r,"cy",0),m=ot(r,"rx",0),_=ot(r,"ry",0),t.context.beginPath(),t.context.ellipse(p,f,m,_),e&&t.context.fill(),s&&t.context.stroke();break;case"line":l=ot(r,"x1",0),h=ot(r,"y1",0),c=ot(r,"x2",0),d=ot(r,"y2",0),t.context.beginPath(),t.context.moveTo(l,h),t.context.lineTo(c,d),s&&t.context.stroke();break;case"polygon":b=r.getAttribute("points"),x=b.match(/\d+/g).map(R=>parseInt(R,10)),t.context.poly(x,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=r.getAttribute("points"),x=b.match(/\d+/g).map(R=>parseInt(R,10)),t.context.poly(x,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}for(let R=0;Rt in r?y1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qt=(r,t)=>{for(var e in t||(t={}))rp.call(t,e)&&ip(r,e,t[e]);if(Qs)for(var e of Qs(t))sp.call(t,e)&&ip(r,e,t[e]);return r},T1=(r,t)=>{var e={};for(var s in r)rp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Qs)for(var s of Qs(r))t.indexOf(s)<0&&sp.call(r,s)&&(e[s]=r[s]);return e};function S1(r){return z.isColorLike(r)}function np(r){return r instanceof Or}function op(r){return r instanceof He}function E1(r,t,e){const s=z.shared.setValue(t!=null?t:0);return r.color=s.toNumber(),r.alpha=s.alpha===1?e.alpha:s.alpha,r.texture=A.WHITE,qt(qt({},e),r)}function ap(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,qt(qt({},e),r)}function up(r,t,e){return t.buildLinearGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,qt(qt({},e),r)}function A1(r,t){var e;const s=qt(qt({},t),r);if(s.texture){if(s.texture!==A.WHITE){const o=((e=s.matrix)==null?void 0:e.invert())||new C;o.translate(s.texture.frame.x,s.texture.frame.y),o.scale(1/s.texture.source.width,1/s.texture.source.height),s.matrix=o}const n=s.texture.source.style;n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update())}const i=z.shared.setValue(s.color);return s.alpha*=i.alpha,s.color=i.toNumber(),s.matrix=s.matrix?s.matrix.clone():null,s}function te(r,t){if(r==null)return null;const e={},s=r;return S1(r)?E1(e,r,t):np(r)?ap(e,r,t):op(r)?up(e,r,t):s.fill&&np(s.fill)?ap(s,s.fill,t):s.fill&&op(s.fill)?up(s,s.fill,t):A1(s,t)}function Br(r,t){const e=t,{width:s,alignment:i,miterLimit:n,cap:o,join:a}=e,u=T1(e,["width","alignment","miterLimit","cap","join"]),l=te(r,u);return l?qt({width:s,alignment:i,miterLimit:n,cap:o,join:a},l):null}var w1=Object.defineProperty,lp=Object.getOwnPropertySymbols,P1=Object.prototype.hasOwnProperty,R1=Object.prototype.propertyIsEnumerable,hp=(r,t,e)=>t in r?w1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ze=(r,t)=>{for(var e in t||(t={}))P1.call(t,e)&&hp(r,e,t[e]);if(lp)for(var e of lp(t))R1.call(t,e)&&hp(r,e,t[e]);return r};const M1=new W,cp=new C,Io=class Ht extends pt{constructor(){super(...arguments),this.uid=Z("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new ue,this._transform=new C,this._fillStyle=ze({},Ht.defaultFillStyle),this._strokeStyle=ze({},Ht.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new ht,this._boundsDirty=!0}clone(){const t=new Ht;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=ze({},this._fillStyle),t._strokeStyle=ze({},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=te(t,Ht.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Br(t,Ht.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=te(t,Ht.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=te(t,Ht.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?z.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ue,this}fill(t,e){let s;const i=this.instructions[this.instructions.length-1];return this._tick===0&&i&&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=te(t,Ht.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(W.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&&s.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Br(t,Ht.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 u=this._transform;return this._activePath.arcToSvg(t,e,s,i,n,u.a*o+u.c*a+u.tx,u.b*o+u.d*a+u.ty),this}bezierCurveTo(t,e,s,i,n,o,a){this._tick++;const u=this._transform;return this._activePath.bezierCurveTo(u.a*t+u.c*e+u.tx,u.b*t+u.d*e+u.ty,u.a*s+u.c*i+u.tx,u.b*s+u.d*i+u.ty,u.a*n+u.c*o+u.tx,u.b*n+u.d*o+u.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++,tp(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:ze({},this._fillStyle),strokeStyle:ze({},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 C?(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 C?(this._transform.append(t),this):(cp.set(t,e,s,i,n,o),this._transform.append(cp),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const t=this._bounds;t.clear();for(let e=0;et in r?G1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tt=(r,t)=>{for(var e in t||(t={}))F1.call(t,e)&&mp(r,e,t[e]);if(fp)for(var e of fp(t))D1.call(t,e)&&mp(r,e,t[e]);return r},U1=(r,t)=>I1(r,B1(t));const Fo=class er extends pt{constructor(t={}){super(),k1(t);const e=Tt(Tt({},er.defaultTextStyle),t);for(const s in e){const i=s;this[i]=e[s]}this.update()}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(Tt(Tt({},er.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Tt({},er.defaultDropShadow)):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){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.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(Tt(Tt({},ct.defaultFillStyle),t),()=>{this._fill=te(Tt({},this._originalFill),ct.defaultFillStyle)})),this._fill=te(t===0?"black":t,ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Tt(Tt({},ct.defaultStrokeStyle),t),()=>{this._stroke=Br(Tt({},this._originalStroke),ct.defaultStrokeStyle)})),this._stroke=Br(t,ct.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Bo(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=er.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new er({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Tt({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var e,s,i,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(s=this._originalFill)!=null&&s.texture&&this._originalFill.texture.destroy(o),(i=this._stroke)!=null&&i.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,i,n)=>(s[i]=n,e==null||e(i,n),this.update(),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(z.isColorLike(t)||t instanceof He||t instanceof Or)}};Fo.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},Fo.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 St=Fo;function k1(r){var t,e,s,i,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=St.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 u={};if(z.isColorLike(a))u.color=a;else if(a instanceof He||a instanceof Or)u.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))u=a;else throw new Error("Invalid stroke value.");r.stroke=U1(Tt({},u),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){let a;r.fontSize==null?r.fontSize=St.defaultTextStyle.fontSize:typeof r.fontSize=="string"?a=parseInt(r.fontSize,10):a=r.fontSize;const u=new He(0,0,0,a*1.7),l=o.fillGradientStops.map(h=>z.shared.setValue(h).toNumber());l.forEach((h,c)=>{const d=c/(l.length-1);u.addColorStop(d,h)}),r.fill={fill:u}}}const $1=new ht;function Do(r,t,e,s){const i=$1;i.minX=0,i.minY=0,i.maxX=r.width/s|0,i.maxY=r.height/s|0;const n=lt.getOptimalTexture(i.width,i.height,s,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/s,n.frame.height=e/s,n.source.emit("update",n.source),n.updateUvs(),n}const L1=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Fr(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)&&!L1.includes(i)&&(i=`"${i}"`),e[s]=i}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const Uo={willReadFrequently:!0},Bt=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=k.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,i,n,o,a,u,l){this.text=t,this.style=e,this.width=s,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=u,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,i=e.wordWrap){var n;const o=`${t}:${e.styleKey}`;if(M._measurementCache[o])return M._measurementCache[o];const a=Fr(e),u=M.measureFont(a);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize);const l=M.__context;l.font=a;const h=(i?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),c=new Array(h.length);let d=0;for(let _=0;_0&&(i?n-=e:n+=(M.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,s=M._canvas){const i=s.getContext("2d",Uo);let n=0,o="",a="";const u=Object.create(null),{letterSpacing:l,whiteSpace:h}=e,c=M._collapseSpaces(h),d=M._collapseNewlines(h);let p=!c;const f=e.wordWrapWidth+l,g=M._tokenize(t);for(let m=0;mf)if(o!==""&&(a+=M._addLine(o),o="",n=0),M.canBreakWords(_,e.breakWords)){const b=M.wordWrapSplit(_);for(let y=0;yf&&(a+=M._addLine(o),p=!1,o="",n=0),o+=S,n+=R}}else{o.length>0&&(a+=M._addLine(o),o="",n=0);const b=m===g.length-1;a+=M._addLine(_,!b),p=!1,o="",n=0}else x+n>f&&(p=!1,a+=M._addLine(o),o="",n=0),(o.length>0||!M.isBreakingSpace(_)||p)&&(o+=_,n+=x)}return a+=M._addLine(o,!1),a}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,s,i){let n=s[t];return typeof n!="number"&&(n=M._measureText(t,e,i)+e,s[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let i=0;i{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),Bt.experimentalLetterSpacing=!1,Bt._fonts={},Bt._newlines=[10,13],Bt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Bt._measurementCache={};let Ft=Bt;function Dr(r,t){var e;if(r.texture===A.WHITE&&!r.fill)return z.shared.setValue(r.color).setAlpha((e=r.alpha)!=null?e:1).toHexa();if(r.fill){if(r.fill instanceof Or){const s=r.fill,i=t.createPattern(s.texture.source.resource,"repeat"),n=s.transform.copyTo(C.shared);return n.scale(s.texture.frame.width,s.texture.frame.height),i.setTransform(n),i}else if(r.fill instanceof He){const s=r.fill;if(s.type==="linear"){const i=t.createLinearGradient(s.x0,s.y0,s.x1,s.y1);return s.gradientStops.forEach(n=>{i.addColorStop(n.offset,z.shared.setValue(n.color).toHex())}),i}}}else{const s=t.createPattern(r.texture.source.resource,"repeat"),i=r.matrix.copyTo(C.shared);return i.scale(r.texture.frame.width,r.texture.frame.height),s.setTransform(i),s}return"red"}class ko{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,s){const i=Ft.measureText(t||" ",s);let n=Math.ceil(Math.ceil(Math.max(1,i.width)+s.padding*2)*e),o=Math.ceil(Math.ceil(Math.max(1,i.height)+s.padding*2)*e);return n=Math.ceil(n-1e-6),o=Math.ceil(o-1e-6),n=be(n),o=be(o),{width:n,height:o}}getTexture(t,e,s,i){typeof t=="string"&&(ro("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof St||(t.style=new St(t.style));const{texture:n,canvasAndContext:o}=this.createTextureAndCanvas(t);return this._renderer.texture.initSource(n._source),Xt.returnCanvasAndContext(o),n}createTextureAndCanvas(t){var e;const{text:s,style:i}=t,n=(e=t.resolution)!=null?e:this._renderer.resolution,o=Ft.measureText(s||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+i.padding*2)*n),u=Math.ceil(Math.ceil(Math.max(1,o.height)+i.padding*2)*n),l=Xt.getOptimalCanvasAndContext(a,u),{canvas:h}=l;this.renderTextToCanvas(s,i,n,l);const c=Do(h,a,u,n);if(i.trim){const d=Ld(h,n);c.frame.copyFrom(d),c.updateUvs()}return{texture:c,canvasAndContext:l}}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t._getKey();if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const{texture:s,canvasAndContext:i}=this.createTextureAndCanvas(t);return this._activeTextures[e]={canvasAndContext:i,texture:s,usageCount:1},s}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];if(e.usageCount--,e.usageCount===0){Xt.returnCanvasAndContext(e.canvasAndContext),lt.returnTexture(e.texture);const s=e.texture.source;s.resource=null,s.uploadMethodId="unknown",s.alphaMode="no-premultiply-alpha",this._activeTextures[t]=null}}getReferenceCount(t){return this._activeTextures[t].usageCount}renderTextToCanvas(t,e,s,i){var n,o,a,u,l,h,c;const{canvas:d,context:p}=i,f=Fr(e),g=Ft.measureText(t||" ",e),m=g.lines,_=g.lineHeight,x=g.lineWidths,b=g.maxLineWidth,y=g.fontProperties,S=d.height;p.resetTransform(),p.scale(s,s);const P=e.padding*2;if(p.clearRect(0,0,g.width+4+P,g.height+4+P),(n=e._stroke)!=null&&n.width){const E=e._stroke;p.lineWidth=E.width,p.miterLimit=E.miterLimit,p.lineJoin=E.join,p.lineCap=E.cap}p.font=f;let w,R;const T=e.dropShadow?2:1;for(let E=0;Et in r?N1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,X1=(r,t)=>{for(var e in t||(t={}))gp.call(t,e)&&bp(r,e,t[e]);if(Js)for(var e of Js(t))_p.call(t,e)&&bp(r,e,t[e]);return r},H1=(r,t)=>{var e={};for(var s in r)gp.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Js)for(var s of Js(r))t.indexOf(s)<0&&_p.call(r,s)&&(e[s]=r[s]);return e};class ir extends xe{constructor(t){t instanceof ct&&(t={context:t});const e=t||{},{context:s,roundPixels:i}=e,n=H1(e,["context","roundPixels"]);super(X1({label:"Graphics"},n)),this.renderPipeId="graphics",s?this._context=s:this._context=this._ownedContext=new ct,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i!=null?i:!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new ir(this._context.clone()):(this._ownedContext=null,new ir(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&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==ct.defaultStrokeStyle.width||t.color!==ct.defaultStrokeStyle.color||t.alpha!==ct.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}const xp={name:"local-uniform-msdf-bit",vertex:{header:` struct LocalUniforms { uColor:vec4, uTransformMatrix:mat3x3, uDistance: f32, uRound:f32, } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` vColor *= localUniforms.uColor; modelMatrix *= localUniforms.uTransformMatrix; `,end:` if(localUniforms.uRound == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` struct LocalUniforms { uColor:vec4, uTransformMatrix:mat3x3, uDistance: f32 } @group(2) @binding(0) var localUniforms : LocalUniforms; `,main:` outColor = vec4(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance)); `}},vp={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)); `}},yp={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; } `}},Tp={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 $o,Lo;class Sp extends Ct{constructor(){const t=new rt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new C,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=ye();$o!=null||($o=ke({name:"sdf-shader",bits:[Os,Gs(e),xp,yp,Le]})),Lo!=null||(Lo=$e({name:"sdf-shader",bits:[Cs,Is(e),vp,Tp,Ne]})),super({glProgram:Lo,gpuProgram:$o,resources:{localUniforms:t,batchSamplers:Bs(e)}})}}let No=0;const Ep=500;function ee(...r){No!==Ep&&(No++,No===Ep?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}class Xo extends pt{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)}}function Ho(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,s=r.length;et in r?j1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pp=(r,t)=>{for(var e in t||(t={}))z1.call(t,e)&&wp(r,e,t[e]);if(Ap)for(var e of Ap(t))V1.call(t,e)&&wp(r,e,t[e]);return r};const Rp=class Lx extends Xo{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._currentPageIndex=-1,this._skipKerning=!1;const n=Pp(Pp({},Lx.defaultOptions),t);this._textureSize=n.textureSize,this._mipmap=n.mipmap;const o=n.style.clone();n.overrideFill&&(o._fill.color=16777215,o._fill.alpha=1,o._fill.texture=A.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const u=Fr(o);n.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(s=n.resolution)!=null?s:1,this._padding=(i=n.padding)!=null?i:4,this.fontMetrics=Ft.measureFont(u),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,s,i,n;const o=Ho(t).filter(b=>!this._currentChars.includes(b)).filter((b,y,S)=>S.indexOf(b)===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:u,context:l}=a.canvasAndContext,h=a.texture.source;const c=this._style;let d=this._currentX,p=this._currentY;const f=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*f,m=c.fontStyle==="italic"?2:1;let _=0,x=!1;for(let b=0;bthis._textureSize&&(p+=_,_=T,d=0,p+_>this._textureSize)){h.update();const N=this._nextPage();u=N.canvasAndContext.canvas,l=N.canvasAndContext.context,h=N.texture.source,p=0}const E=P/f-((s=(e=c.dropShadow)==null?void 0:e.distance)!=null?s:0)-((n=(i=c._stroke)==null?void 0:i.width)!=null?n:0);if(this.chars[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:E,kerning:{}},x){this._drawGlyph(l,S,d+g,p+g,f,c);const N=h.width*f,$=h.height*f,O=new V(d/N*h.width,p/$*h.height,R/N*h.width,T/$*h.height);this.chars[y].texture=new A({source:h,frame:O}),d+=Math.ceil(R)}}h.update(),this._currentX=d,this._currentY=p,this._skipKerning&&this._applyKerning(o,l)}get pageTextures(){return this.pages}_applyKerning(t,e){const s=this._measureCache;for(let i=0;i{const g=n.width;for(let m=0;m{let f=n.chars.length-1;if(s){let g=n.chars[f];for(;g===" ";)n.width-=e.chars[g].xAdvance,g=n.chars[--f]}i.width=Math.max(i.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(n),i.height+=e.lineHeight},c=e.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*c,p=t.wordWrapWidth*c;for(let f=0;fp?(h(),l(u),m||n.charPositions.push(0)):(u.start=n.width,l(u),m||n.charPositions.push(0)),g==="\r"||g===` `)n.width!==0&&h();else if(!m){const x=_.xAdvance+(_.kerning[o]||0)+d;n.width+=x,n.spaceWidth=x,n.spacesIndex.push(n.charPositions.length),n.chars.push(g)}}else{const x=_.kerning[o]||0,b=_.xAdvance+x+d;u.positions[u.index++]=u.width+x,u.chars.push(g),u.width+=b}o=g}return h(),t.align==="center"?W1(i):t.align==="right"?Y1(i):t.align==="justify"&&K1(i),i}function W1(r){for(let t=0;tt in r?q1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vo=(r,t)=>{for(var e in t||(t={}))Z1.call(t,e)&&Op(r,e,t[e]);if(Mp)for(var e of Mp(t))Q1.call(t,e)&&Op(r,e,t[e]);return r};let ti=0,J1=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}}getFont(t,e){var s;let i=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke)i+=e._fill.fill.styleKey,n=!1;else if(e._stroke||e.dropShadow){let a=e.styleKey;a=a.substring(0,a.lastIndexOf("-")),i=`${a}-bitmap`,n=!1}if(!Y.has(i)){const a=new jo(Vo({style:e,overrideFill:n,overrideSize:!0},this.defaultOptions));ti++,ti>50&&ee("BitmapText",`You have dynamically created ${ti} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{ti--,Y.remove(i)}),Y.set(i,a)}const o=Y.get(i);return(s=o.ensureCharacters)==null||s.call(o,t),o}getLayout(t,e,s=!0){const i=this.getFont(t,e);return zo([...t],e,i,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var e,s,i,n;let o=t[0];typeof o=="string"&&(o={name:o,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 a=o==null?void 0:o.name;if(!a)throw new Error("[BitmapFontManager] Property `name` is required.");o=Vo(Vo({},this.defaultOptions),o);const u=o.style,l=u instanceof St?u:new St(u),h=l._fill.fill!==null&&l._fill.fill!==void 0,c=new jo({style:l,overrideFill:h,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1}),d=Ho(o.chars);return c.ensureCharacters(d.join("")),Y.set(`${a}-bitmap`,c),c.once("destroy",()=>Y.remove(`${a}-bitmap`)),c}uninstall(t){const e=`${t}-bitmap`,s=Y.get(e);s&&(Y.remove(e),s.destroy())}};const Ur=new J1;class Wo{constructor(t){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const s=this._getGpuBitmapText(t);Cp(t,s),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,s)),this._renderer.renderPipes.graphics.addRenderable(s,e),s.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){const e=this._gpuBitmapText[t].context;e.customShader&&(X.return(e.customShader),e.customShader=null),X.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){const e=this._getGpuBitmapText(t);Cp(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:s}=e,i=Ur.getFont(t.text,t._style);s.clear(),i.distanceField.type!=="none"&&(s.customShader||(s.customShader=X.get(Sp)));const n=Array.from(t.text),o=t._style;let a=i.baseLineOffset;const u=zo(n,o,i,!0);let l=0;const h=o.padding,c=u.scale;let d=u.width,p=u.height+u.offsetY;o._stroke&&(d+=o._stroke.width/c,p+=o._stroke.width/c),s.translate(-t._anchor._x*d-h,-t._anchor._y*p-h).scale(c,c);const f=i.applyFillAsTint?o._fill.color:16777215;for(let g=0;g{console.error(o)}),t._didTextUpdate=!1;const n=t._style.padding;vr(i.bounds,t._anchor,i.texture,n)}async _updateGpuText(t){var e;t._didTextUpdate=!1;const s=this._getGpuText(t);if(s.generatingTexture)return;const i=t._getKey();this._renderer.htmlText.decreaseReferenceCount(s.currentKey),s.generatingTexture=!0,s.currentKey=i;const n=(e=t.resolution)!=null?e:this._renderer.resolution,o=await this._renderer.htmlText.getManagedTexture(t.text,n,t._style,t._getKey()),a=s.batchableSprite;a.texture=s.texture=o,s.generatingTexture=!1,s.textureNeedsUploading=!0,t.onViewUpdate();const u=t._style.padding;vr(a.bounds,t._anchor,a.texture,u)}_getGpuText(t){return this._gpuText[t.uid]||this.initGpuText(t)}initGpuText(t){const e={texture:A.EMPTY,currentKey:"--",batchableSprite:X.get(Ys),textureNeedsUploading:!1,generatingTexture:!1},s=e.batchableSprite;return s.renderable=t,s.transform=t.groupTransform,s.texture=A.EMPTY,s.bounds={minX:0,maxX:1,minY:0,maxY:0},s.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,this._gpuText[t.uid]=e,t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuText)this._destroyRenderableById(t);this._gpuText=null,this._renderer=null}}Yo.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"htmlText"};function Gp(){const{userAgent:r}=k.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Ko="http://www.w3.org/2000/svg",qo="http://www.w3.org/1999/xhtml";class Zo{constructor(){this.svgRoot=document.createElementNS(Ko,"svg"),this.foreignObject=document.createElementNS(Ko,"foreignObject"),this.domElement=document.createElementNS(qo,"div"),this.styleElement=document.createElementNS(qo,"style"),this.image=new Image;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)}}function Ip(r){const t=r._stroke,e=r._fill,s=[`div { ${[`color: ${z.shared.setValue(e.color).toHex()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-wrap: ${r.breakWords?"break-all":"break-word"}`,`max-width: ${r.wordWrapWidth}px`]:[],...t?[Fp(t)]:[],...r.dropShadow?[Bp(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return tT(r.tagStyles,s),s.join(" ")}function Bp(r){const t=z.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),e=Math.round(Math.cos(r.angle)*r.distance),s=Math.round(Math.sin(r.angle)*r.distance),i=`${e}px ${s}px`;return r.blur>0?`text-shadow: ${i} ${r.blur}px ${t}`:`text-shadow: ${i} ${t}`}function Fp(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${z.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${z.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const Dp={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"},Up={fill:r=>`color: ${z.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:Fp,dropShadow:Bp};function tT(r,t){for(const e in r){const s=r[e],i=[];for(const n in s)Up[n]?i.push(Up[n](s[n])):Dp[n]&&i.push(Dp[n].replace("{{VALUE}}",s[n]));t.push(`${e} { ${i.join(";")} }`)}}var eT=Object.defineProperty,kp=Object.getOwnPropertySymbols,rT=Object.prototype.hasOwnProperty,sT=Object.prototype.propertyIsEnumerable,$p=(r,t,e)=>t in r?eT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,iT=(r,t)=>{for(var e in t||(t={}))rT.call(t,e)&&$p(r,e,t[e]);if(kp)for(var e of kp(t))sT.call(t,e)&&$p(r,e,t[e]);return r};class Re extends St{constructor(t={}){var e,s;super(t),this._cssOverrides=[],(e=this.cssOverrides)!=null||(this.cssOverrides=t.cssOverrides),this.tagStyles=(s=t.tagStyles)!=null?s:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Bo(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new Re({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?iT({},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})}get cssStyle(){return this._cssStyle||(this._cssStyle=Ip(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}}function Lp(r,t){const e=t.fontFamily,s=[],i={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(u){i[u]||(s.push(u),i[u]=!0)}if(Array.isArray(e))for(let u=0;u{const l=u.split(":")[1].trim();a(l)});for(const u in t.tagStyles){const l=t.tagStyles[u].fontFamily;a(l)}return s}async function Np(r){const t=await(await k.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 Qo(r,t){const e=await Np(t);return`@font-face { font-family: "${r.fontFamily}"; src: url('${e}'); font-weight: ${r.fontWeight}; font-style: ${r.fontStyle}; }`}const kr=new Map;async function Xp(r,t,e){const s=r.filter(i=>Y.has(`${i}-and-url`)).map((i,n)=>{if(!kr.has(i)){const{url:o}=Y.get(`${i}-and-url`);n===0?kr.set(i,Qo({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:i},o)):kr.set(i,Qo({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:i},o))}return kr.get(i)});return(await Promise.all(s)).join(` `)}function Hp(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:u,height:l}=i.image;return a.setAttribute("width",u.toString()),a.setAttribute("height",l.toString()),new XMLSerializer().serializeToString(a)}function jp(r,t){const e=Xt.getOptimalCanvasAndContext(r.width,r.height,t),{context:s}=e;return s.clearRect(0,0,r.width,r.height),s.drawImage(r,0,0),Xt.returnCanvasAndContext(e),e.canvas}function zp(r,t,e){return new Promise(async s=>{e&&await new Promise(i=>setTimeout(i,100)),r.onload=()=>{s()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}let Vp;function Jo(r,t,e,s){s=s||Vp||(Vp=new Zo);const{domElement:i,styleElement:n,svgRoot:o}=s;i.innerHTML=`
${r}
`,i.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=i.getBoundingClientRect();o.remove();const u=Ft.measureFont(t.fontStyle).descent,l=t.padding*2;return{width:a.width-l,height:a.height+u-l}}class ei{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===mt.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,s,i){if(this._activeTextures[i])return this._increaseReferenceCount(i),this._activeTextures[i].promise;const n=this._buildTexturePromise(t,e,s).then(o=>(this._activeTextures[i].texture=o,o));return this._activeTextures[i]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,s){const i=X.get(Zo),n=Lp(t,s),o=await Xp(n,s,Re.defaultTextStyle),a=Jo(t,s,o,i),u=Math.ceil(Math.ceil(Math.max(1,a.width)+s.padding*2)*e),l=Math.ceil(Math.ceil(Math.max(1,a.height)+s.padding*2)*e),h=i.image,c=2;h.width=(u|0)+c,h.height=(l|0)+c;const d=Hp(t,s,e,o,i);await zp(h,d,Gp()&&n.length>0);let p=h;this._createCanvas&&(p=jp(h,e));const f=Do(p,h.width-c,h.height-c,e);return this._createCanvas&&this._renderer.texture.initSource(f.source),X.return(i),f}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(s=>{e.texture=s,this._cleanUp(e)}).catch(()=>{}),this._activeTextures[t]=null))}_cleanUp(t){lt.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}}ei.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"htmlText"},ei.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"},D.add(ei),D.add(Yo);var nT=Object.defineProperty,Wp=Object.getOwnPropertySymbols,oT=Object.prototype.hasOwnProperty,aT=Object.prototype.propertyIsEnumerable,Yp=(r,t,e)=>t in r?nT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Kp=(r,t)=>{for(var e in t||(t={}))oT.call(t,e)&&Yp(r,e,t[e]);if(Wp)for(var e of Wp(t))aT.call(t,e)&&Yp(r,e,t[e]);return r};const qp=class Nx extends Be{constructor(...t){var e;let s=(e=t[0])!=null?e:{};s instanceof Float32Array&&(s={positions:s,uvs:t[1],indices:t[2]}),s=Kp(Kp({},Nx.defaultOptions),s);const i=s.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=s.uvs||new Float32Array([0,0,1,0,1,1,0,1]),o=s.indices||new Uint32Array([0,1,2,0,2,3]),a=s.shrinkBuffersToFit,u=new yt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:H.VERTEX|H.COPY_DST}),l=new yt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:H.VERTEX|H.COPY_DST}),h=new yt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:H.INDEX|H.COPY_DST});super({attributes:{aPosition:{buffer:u,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:l,format:"float32x2",stride:2*4,offset:0}},indexBuffer:h,topology:s.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};qp.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let re=qp;var uT=Object.defineProperty,lT=Object.defineProperties,hT=Object.getOwnPropertyDescriptors,Zp=Object.getOwnPropertySymbols,cT=Object.prototype.hasOwnProperty,dT=Object.prototype.propertyIsEnumerable,Qp=(r,t,e)=>t in r?uT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jp=(r,t)=>{for(var e in t||(t={}))cT.call(t,e)&&Qp(r,e,t[e]);if(Zp)for(var e of Zp(t))dT.call(t,e)&&Qp(r,e,t[e]);return r},tf=(r,t)=>lT(r,hT(t));const Ve={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); } `}},ef=tf(Jp({},Ve),{vertex:tf(Jp({},Ve.vertex),{header:Ve.vertex.header.replace("group(1)","group(2)")})}),ri={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); } `}},rf={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); `}},sf={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 ta,ea;class nf extends Ct{constructor(){ta!=null||(ta=ke({name:"tiling-sprite-shader",bits:[Ve,rf,Le]})),ea!=null||(ea=$e({name:"tiling-sprite-shader",bits:[ri,sf,Ne]}));const t=new rt({uMapCoord:{value:new C,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new C,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:ea,gpuProgram:ta,resources:{localUniforms:new rt({uTransformMatrix:{value:new C,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:A.EMPTY.source,uSampler:A.EMPTY.source.style}})}updateUniforms(t,e,s,i,n,o){const a=this.resources.tilingUniforms,u=o.width,l=o.height,h=o.textureMatrix,c=a.uniforms.uTextureTransform;c.set(s.a*u/t,s.b*u/e,s.c*l/t,s.d*l/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 of extends re{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 af(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 uf(r,t,e,s){let i=0;const n=r.length/(t||2),o=s.a,a=s.b,u=s.c,l=s.d,h=s.tx,c=s.ty;for(e*=t;it in r?pT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,df=(r,t)=>{for(var e in t||(t={}))fT.call(t,e)&&cf(r,e,t[e]);if(hf)for(var e of hf(t))mT.call(t,e)&&cf(r,e,t[e]);return r};const pf=class Xx extends re{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=df(df({},Xx.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=[],u=[],l=[],h=this.verticesX-1,c=this.verticesY-1,d=this.width/h,p=this.height/c;for(let g=0;gt in r?gT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gf=(r,t)=>{for(var e in t||(t={}))_T.call(t,e)&&mf(r,e,t[e]);if(ff)for(var e of ff(t))bT.call(t,e)&&mf(r,e,t[e]);return r};const _f=class Hx extends ii{constructor(t={}){t=gf(gf({},Hx.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,s,i,n,o,a,u,l;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=(u=t.topHeight)!=null?u:this._topHeight,this._bottomHeight=(l=t.bottomHeight)!=null?l:this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,e=this._leftWidth+this._rightWidth,s=this.width>e?1:this.width/e,i=this._topHeight+this._bottomHeight,n=this.height>i?1:this.height/i,o=Math.min(s,n);t[9]=t[11]=t[13]=t[15]=this._topHeight*o,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*o,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*o,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*o,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};_f.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let se=_f;class sa{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t}addRenderable(t,e){const s=this._getGpuSprite(t);t._didSpriteUpdate&&this._updateBatchableSprite(t,s),this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._gpuSpriteHash[t.uid];t._didSpriteUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=t._texture,s=this._getGpuSprite(t);return s.texture._source!==e._source?!s._batcher.checkAndUpdateTexture(s,e):!1}destroyRenderable(t){const e=this._gpuSpriteHash[t.uid];X.return(e.geometry),X.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(t,e){t._didSpriteUpdate=!1,e.geometry.update(t),e.texture=t._texture}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=X.get(Ws);return e.geometry=X.get(se),e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._didSpriteUpdate=!0,this._gpuSpriteHash[t.uid]=e,t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(const t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}sa.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"nineSliceSprite"},D.add(sa);class ia{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}}ia.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"filter"};const xT=new C;function bf(r,t){return t.clear(),na(r,t),t.isValid||t.set(0,0,0,0),r.renderGroup?t.applyMatrix(r.renderGroup.localTransform):t.applyMatrix(r.parentRenderGroup.worldTransform),t}function na(r,t){if(r.localDisplayStatus!==7||!r.measurable)return;const e=!!r.effects.length;let s=t;if((r.renderGroup||e)&&(s=$t.get().clear()),r.boundsArea)t.addRect(r.boundsArea,r.worldTransform);else{if(r.renderPipeId){const n=r.bounds;s.addFrame(n.minX,n.minY,n.maxX,n.maxY,r.groupTransform)}const i=r.children;for(let n=0;n"},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 Nt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){var e,s;const i=this.renderer,n=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const o=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,n.length===0){o.skip=!0;return}const a=o.bounds;t.renderables?xf(t.renderables,a):t.filterEffect.filterArea?(a.clear(),a.addRect(t.filterEffect.filterArea),a.applyMatrix(t.container.worldTransform)):bf(t.container,a);const u=i.renderTarget.renderTarget.colorTexture.source;let l=1/0,h=0,c=!0,d=!1,p=!1;for(let g=0;g0?this._filterStack[this._filterStackIndex-1].bounds:null,u=t.renderTarget.getRenderTarget(e.previousRenderSurface);n=this.getBackTexture(u,i,a)}e.backTexture=n;const o=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(s.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),t.globalUniforms.pop(),o.length===1)o[0].apply(this,s,e.previousRenderSurface,!1),lt.returnTexture(s);else{let a=e.inputTexture,u=lt.getOptimalTexture(i.width,i.height,a.source._resolution,!1),l=0;for(l=0;l0&&this._filterStack[c].skip;)--c;c>0&&(h=this._filterStack[c].inputTexture.source._resolution);const d=this._filterGlobalUniforms,p=d.uniforms,f=p.uOutputFrame,g=p.uInputSize,m=p.uInputPixel,_=p.uInputClamp,x=p.uGlobalFrame,b=p.uOutputTexture;if(l){let P=this._filterStackIndex;for(;P>0;){P--;const w=this._filterStack[this._filterStackIndex-1];if(!w.skip){u.x=w.bounds.minX,u.y=w.bounds.minY;break}}f[0]=a.minX-u.x,f[1]=a.minY-u.y}else f[0]=0,f[1]=0;f[2]=e.frame.width,f[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[1],m[0]=e.source.pixelWidth,m[1]=e.source.pixelHeight,m[2]=1/m[0],m[3]=1/m[1],_[0]=.5*m[2],_[1]=.5*m[3],_[2]=e.frame.width*g[2]-.5*m[2],_[3]=e.frame.height*g[3]-.5*m[3];const y=this.renderer.renderTarget.rootRenderTarget.colorTexture;x[0]=u.x*h,x[1]=u.y*h,x[2]=y.source.width*h,x[3]=y.source.height*h;const S=this.renderer.renderTarget.getRenderTarget(s);if(n.renderTarget.bind(s,!!i),s instanceof A?(b[0]=s.frame.width,b[1]=s.frame.height):(b[0]=S.width,b[1]=S.height),b[2]=S.isRoot?-1:1,d.update(),n.renderPipes.uniformBatch){const P=n.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(P,0)}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:vT,shader:t,state:t._state,topology:"triangle-list"}),n.type===mt.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new ht,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}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(C.shared);return n.invert(),i.prepend(n),i.scale(1/e.texture.frame.width,1/e.texture.frame.height),i.translate(e.anchor.x,e.anchor.y),i}}oa.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"filter"},D.add(oa),D.add(ia);var yT={__proto__:null};const aa=[];D.handleByNamedList(v.Environment,aa);async function ua(r){if(!r)for(let t=0;t(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))(gt||{});class ha{constructor(t){this.items=[],this._name=t}emit(t,e,s,i,n,o,a,u){const{name:l,items:h}=this;for(let c=0,d=h.length;ct in r?ST(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ni=(r,t)=>{for(var e in t||(t={}))ET.call(t,e)&&yf(r,e,t[e]);if(vf)for(var e of vf(t))AT.call(t,e)&&yf(r,e,t[e]);return r};const wT=["init","destroy","contextChange","resolutionChange","reset","renderEnd","renderStart","render","update","postrender","prerender"],Tf=class jx extends pt{constructor(t){var e;super(),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=[...wT,...(e=this.config.runners)!=null?e:[]];this._addRunners(...s),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await ua(e),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=ni(ni({},i),t)}t=ni(ni({},jx.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let s=0;s{this.runners[e]=new ha(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)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!la())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Tf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Lr=Tf,ca;function Nr(r){return ca!==void 0||(ca=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Lr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!k.get().getWebGLRenderingContext())return!1;let s=k.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}})()),ca}let da;async function Xr(r={}){return da!==void 0||(da=await(async()=>{const t=k.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),da}var PT=Object.defineProperty,Sf=Object.getOwnPropertySymbols,RT=Object.prototype.hasOwnProperty,MT=Object.prototype.propertyIsEnumerable,Ef=(r,t,e)=>t in r?PT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hr=(r,t)=>{for(var e in t||(t={}))RT.call(t,e)&&Ef(r,e,t[e]);if(Sf)for(var e of Sf(t))MT.call(t,e)&&Ef(r,e,t[e]);return r};const Af=["webgl","webgpu","canvas"];async function wf(r){var t;let e=[];r.preference?(e.push(r.preference),Af.forEach(o=>{o!==r.preference&&e.push(o)})):e=Af.slice();let s,i={};for(let o=0;ot in r?CT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BT=(r,t)=>{for(var e in t||(t={}))GT.call(t,e)&&Rf(r,e,t[e]);if(Pf)for(var e of Pf(t))IT.call(t,e)&&Rf(r,e,t[e]);return r};const Mf=class yl{constructor(...t){this.stage=new Q}async init(t){t=BT({},t),this.renderer=await wf(t),yl._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=yl._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}};Mf._plugins=[];let Of=Mf;D.handleByList(v.Application,Of._plugins),D.add(pa);class ma extends Xo{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)],u=i[a.id];this.pages.push({texture:u})}),Object.keys(n.chars).forEach(o=>{var a;const u=n.chars[o],{frame:l,source:h}=i[u.page],c=new V(u.x+l.x,u.y+l.y,u.width,u.height),d=new A({source:h,frame:c});this.chars[o]={id:o.codePointAt(0),xOffset:u.xOffset,yOffset:u.yOffset,xAdvance:u.xAdvance,kerning:(a=u.kerning)!=null?a:{},texture:d}}),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;t")?ga.test(k.get().parseXML(r)):!1},parse(r){return ga.parse(k.get().parseXML(r))}},FT=[".xml",".fnt"],Cf={extension:{type:v.CacheParser,name:"cacheBitmapFont"},test:r=>r instanceof ma,getCacheableAssets(r,t){const e={};return r.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Gf={extension:{type:v.LoadParser,priority:vt.Normal},name:"loadBitmapFont",test(r){return FT.includes(ft.extname(r).toLowerCase())},async testParse(r){return oi.test(r)||_a.test(r)},async parse(r,t,e){const s=oi.test(r)?oi.parse(r):_a.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 h=0;hu[h.src]);return new ma({data:s,textures:l},i)},async load(r,t){return await(await k.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 If{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 A),getCacheableAssets:(r,t)=>{const e={};return r.forEach(s=>{t.forEach((i,n)=>{e[s+(n===0?"":n+1)]=i})}),e}};async function ba(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 Ff={extension:{type:v.DetectionParser,priority:1},test:async()=>ba("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Df=["png","jpg","jpeg"],Uf={extension:{type:v.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Df],remove:async r=>r.filter(t=>!Df.includes(t))},DT="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ai(r){return DT?!1:document.createElement("video").canPlayType(r)!==""}const kf={extension:{type:v.DetectionParser,priority:0},test:async()=>ai("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},$f={extension:{type:v.DetectionParser,priority:0},test:async()=>ai("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Lf={extension:{type:v.DetectionParser,priority:0},test:async()=>ai("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Nf={extension:{type:v.DetectionParser,priority:0},test:async()=>ba("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var UT=Object.defineProperty,kT=Object.defineProperties,$T=Object.getOwnPropertyDescriptors,Xf=Object.getOwnPropertySymbols,LT=Object.prototype.hasOwnProperty,NT=Object.prototype.propertyIsEnumerable,Hf=(r,t,e)=>t in r?UT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,XT=(r,t)=>{for(var e in t||(t={}))LT.call(t,e)&&Hf(r,e,t[e]);if(Xf)for(var e of Xf(t))NT.call(t,e)&&Hf(r,e,t[e]);return r},HT=(r,t)=>kT(r,$T(t));class jf{constructor(){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.loadParser&&(a=this._parserHash[e.loadParser]),!a){for(let u=0;u({alias:[l],src:l,data:{}})),a=o.length,u=o.map(async l=>{const h=ft.toAbsolute(l.src);if(!i[l.src])try{this.promiseCache[h]||(this.promiseCache[h]=this._getLoadPromiseAndParser(h,l)),i[l.src]=await this.promiseCache[h].promise,e&&e(++s/a)}catch(c){throw delete this.promiseCache[h],delete i[l.src],new Error(`[Loader.load] Failed to load ${h}. ${c}`)}});return await Promise.all(u),n?i[o[0].src]:i}async unload(t){const e=Rt(t,s=>({alias:[s],src:s})).map(async s=>{var i,n;const o=ft.toAbsolute(s.src),a=this.promiseCache[o];if(a){const u=await a.promise;delete this.promiseCache[o],await((n=(i=a.parser)==null?void 0:i.unload)==null?void 0:n.call(i,u,s,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name&&t[e.name],HT(XT({},t),{[e.name]:e})),{})}}function we(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 Ot(r,t){const e=r.split("?")[0],s=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const jT=".json",zT="application/json",zf={extension:{type:v.LoadParser,priority:vt.Low},name:"loadJson",test(r){return we(r,zT)||Ot(r,jT)},async load(r){return await(await k.get().fetch(r)).json()}},VT=".txt",WT="text/plain",Vf={name:"loadTxt",extension:{type:v.LoadParser,priority:vt.Low,name:"loadTxt"},test(r){return we(r,WT)||Ot(r,VT)},async load(r){return await(await k.get().fetch(r)).text()}};var YT=Object.defineProperty,KT=Object.defineProperties,qT=Object.getOwnPropertyDescriptors,Wf=Object.getOwnPropertySymbols,ZT=Object.prototype.hasOwnProperty,QT=Object.prototype.propertyIsEnumerable,Yf=(r,t,e)=>t in r?YT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JT=(r,t)=>{for(var e in t||(t={}))ZT.call(t,e)&&Yf(r,e,t[e]);if(Wf)for(var e of Wf(t))QT.call(t,e)&&Yf(r,e,t[e]);return r},tS=(r,t)=>KT(r,qT(t));const eS=["normal","bold","100","200","300","400","500","600","700","800","900"],rS=[".ttf",".otf",".woff",".woff2"],sS=["font/ttf","font/otf","font/woff","font/woff2"],iS=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Kf(r){const t=ft.extname(r),e=ft.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(iS)){s=!1;break}let i=e.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}const nS=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function oS(r){return nS.test(r)?r:encodeURI(r)}const qf={extension:{type:v.LoadParser,priority:vt.Low},name:"loadWebFont",test(r){return we(r,sS)||Ot(r,rS)},async load(r,t){var e,s,i,n,o,a;const u=k.get().getFontFaceSet();if(u){const l=[],h=(s=(e=t.data)==null?void 0:e.family)!=null?s:Kf(r),c=(o=(n=(i=t.data)==null?void 0:i.weights)==null?void 0:n.filter(p=>eS.includes(p)))!=null?o:["normal"],d=(a=t.data)!=null?a:{};for(let p=0;p{Y.remove(t.family),k.get().getFontFaceSet().delete(t)})}};function ui(r,t=1){var e;const s=(e=Jt.RETINA_PREFIX)==null?void 0:e.exec(r);return s?parseFloat(s[1]):t}function ie(r,t,e){r.label=e,r._sourceOrigin=e;const s=new A({source:r,label:e}),i=()=>{delete t.promiseCache[e],Y.has(e)&&Y.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&i()}),s.once("destroy",()=>{r.destroyed||i()}),s}var aS=Object.defineProperty,li=Object.getOwnPropertySymbols,Zf=Object.prototype.hasOwnProperty,Qf=Object.prototype.propertyIsEnumerable,Jf=(r,t,e)=>t in r?aS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uS=(r,t)=>{for(var e in t||(t={}))Zf.call(t,e)&&Jf(r,e,t[e]);if(li)for(var e of li(t))Qf.call(t,e)&&Jf(r,e,t[e]);return r},lS=(r,t)=>{var e={};for(var s in r)Zf.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&&Qf.call(r,s)&&(e[s]=r[s]);return e};const hS=".svg",cS="image/svg+xml",tm={extension:{type:v.LoadParser,priority:vt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return we(r,cS)||Ot(r,hS)},async load(r,t,e){var s;return((s=t.data.parseAsGraphicsContext)!=null?s:this.config.parseAsGraphicsContext)?pS(r):dS(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function dS(r,t,e,s){var i,n,o,a,u;const l=await(await k.get().fetch(r)).blob(),h=URL.createObjectURL(l),c=new Image;c.src=h,c.crossOrigin=s,await c.decode(),URL.revokeObjectURL(h);const d=document.createElement("canvas"),p=d.getContext("2d"),f=((i=t.data)==null?void 0:i.resolution)||ui(r),g=(o=(n=t.data)==null?void 0:n.width)!=null?o:c.width,m=(u=(a=t.data)==null?void 0:a.height)!=null?u:c.height;d.width=g*f,d.height=m*f,p.drawImage(c,0,0,g*f,m*f);const _=t.data,{parseAsGraphicsContext:x}=_,b=lS(_,["parseAsGraphicsContext"]),y=new ve(uS({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:f},b));return ie(y,e,r)}async function pS(r){const t=await(await k.get().fetch(r)).text(),e=new ct;return e.svg(t),e}const fS=`(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 We=null,xa=class{constructor(){We||(We=URL.createObjectURL(new Blob([fS],{type:"application/javascript"}))),this.worker=new Worker(We)}};xa.revokeObjectURL=function(){We&&(URL.revokeObjectURL(We),We=null)};const mS='(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 Ye=null,em=class{constructor(){Ye||(Ye=URL.createObjectURL(new Blob([mS],{type:"application/javascript"}))),this.worker=new Worker(Ye)}};em.revokeObjectURL=function(){Ye&&(URL.revokeObjectURL(Ye),Ye=null)};let rm=0,va,gS=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 xa;e.addEventListener("message",s=>{e.terminate(),xa.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(){va===void 0&&(va=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){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const 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[rm]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:rm++,id:s})}};const ya=new gS;var _S=Object.defineProperty,sm=Object.getOwnPropertySymbols,bS=Object.prototype.hasOwnProperty,xS=Object.prototype.propertyIsEnumerable,im=(r,t,e)=>t in r?_S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vS=(r,t)=>{for(var e in t||(t={}))bS.call(t,e)&&im(r,e,t[e]);if(sm)for(var e of sm(t))xS.call(t,e)&&im(r,e,t[e]);return r};const yS=[".jpeg",".jpg",".png",".webp",".avif"],TS=["image/jpeg","image/png","image/webp","image/avif"];async function nm(r,t){var e;const s=await k.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 Ta={name:"loadTextures",extension:{type:v.LoadParser,priority:vt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return we(r,TS)||Ot(r,yS)},async load(r,t,e){var s;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ya.isImageBitmapSupported()?i=await ya.loadImageBitmap(r,t):i=await nm(r,t):i=await new Promise(o=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=r,i.complete?o(i):i.onload=()=>{o(i)}});const n=new ve(vS({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((s=t.data)==null?void 0:s.resolution)||ui(r)},t.data));return ie(n,e,r)},unload(r){r.destroy(!0)}};var SS=Object.defineProperty,ES=Object.defineProperties,AS=Object.getOwnPropertyDescriptors,om=Object.getOwnPropertySymbols,wS=Object.prototype.hasOwnProperty,PS=Object.prototype.propertyIsEnumerable,am=(r,t,e)=>t in r?SS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sa=(r,t)=>{for(var e in t||(t={}))wS.call(t,e)&&am(r,e,t[e]);if(om)for(var e of om(t))PS.call(t,e)&&am(r,e,t[e]);return r},um=(r,t)=>ES(r,AS(t));const lm=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],RS=lm.map(r=>`video/${r.substring(1)}`);function hm(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=dm(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function cm(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 dm(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":""}const pm={name:"loadVideo",extension:{type:v.LoadParser,name:"loadVideo"},test(r){const t=we(r,RS),e=Ot(r,lm);return t||e},async load(r,t,e){var s,i;const n=Sa(um(Sa({},yr.defaultOptions),{resolution:((s=t.data)==null?void 0:s.resolution)||ui(r),alphaMode:((i=t.data)==null?void 0:i.alphaMode)||await Fn()}),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),hm(o,r,n.crossorigin);const u=document.createElement("source");let l;if(r.startsWith("data:"))l=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const h=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();l=yr.MIME_TYPES[h]||`video/${h}`}return u.src=r,l&&(u.type=l),new Promise(h=>{const c=async()=>{const d=new yr(um(Sa({},n),{resource:o}));o.removeEventListener("canplay",c),t.data.preload&&await cm(o),h(ie(d,e,r))};o.addEventListener("canplay",c),o.appendChild(u)})},unload(r){r.destroy(!0)}},Ea={extension:{type:v.ResolveParser,name:"resolveTexture"},test:Ta.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=Jt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},fm={extension:{type:v.ResolveParser,priority:-2,name:"resolveJson"},test:r=>Jt.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Ea.parse};class mm{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Jt,this.loader=new jf,this.cache=Y,this._backgroundLoader=new If(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 u=t.manifest;typeof u=="string"&&(u=await this.load(u)),this.resolver.addManifest(u)}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)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=xr(t),i=Rt(t).map(a=>{if(typeof a!="string"){const u=this.resolver.getAlias(a);return u.some(l=>!this.resolver.hasKey(l))&&this.add(a),Array.isArray(u)?u[0]:u}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,u=0;const l=()=>{e==null||e(++a/u)},h=o.map(c=>{const d=i[c];return u+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(p=>{n[c]=p})});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 Y.get(t);const e={};for(let s=0;s{const a=i[o.src],u=[o.src];o.alias&&u.push(...o.alias),u.forEach(l=>{n[l]=a}),Y.set(u,a)}),n}async unload(t){this._initialized||await this.init();const e=Rt(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=Rt(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=>{Y.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 zr=new mm;D.handleByList(v.LoadParser,zr.loader.parsers).handleByList(v.ResolveParser,zr.resolver.parsers).handleByList(v.CacheParser,zr.cache.parsers).handleByList(v.DetectionParser,zr.detections),D.add(Bf,Uf,Ff,Nf,kf,$f,Lf,zf,Vf,qf,tm,Ta,pm,Gf,Cf,Ea,fm);const gm={loader:v.LoadParser,resolver:v.ResolveParser,cache:v.CacheParser,detection:v.DetectionParser};D.handle(v.Asset,r=>{const t=r.ref;Object.entries(gm).filter(([e])=>!!t[e]).forEach(([e,s])=>{var i;return D.add(Object.assign(t[e],{extension:(i=t[e].extension)!=null?i:s}))})},r=>{const t=r.ref;Object.keys(gm).filter(e=>!!t[e]).forEach(e=>D.remove(t[e]))});const MS={extension:{type:v.DetectionParser,priority:3},test:async()=>!!(await Xr()||Nr()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class Vr extends tt{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let hi;function Aa(){if(hi)return hi;const r=document.createElement("canvas").getContext("webgl");return r?(hi=[...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"]:[]],hi):[]}let ci;async function wa(){if(ci)return ci;const r=await k.get().getNavigator().gpu.requestAdapter();return ci=[...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"]:[]],ci}let Pa;async function Ra(){return Pa!==void 0||(Pa=await(async()=>{const r=await Xr(),t=Nr();if(r&&t){const e=await wa(),s=Aa();return e.filter(i=>s.includes(i))}else{if(r)return await wa();if(t)return Aa()}return[]})()),Pa}const _m=["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 di;async function Wr(){if(di!==void 0)return di;const r=await Ra();return di=[..._m,...r],di}const OS='(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 Ke=null,bm=class{constructor(){Ke||(Ke=URL.createObjectURL(new Blob([OS],{type:"application/javascript"}))),this.worker=new Worker(Ke)}};bm.revokeObjectURL=function(){Ke&&(URL.revokeObjectURL(Ke),Ke=null)};const pi={jsUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.js",wasmUrl:"https://files.pixijs.download/transcoders/basis/basis_transcoder.wasm"};function CS(r){Object.assign(pi,r)}let Yr;const xm={};function GS(r){return Yr||(Yr=new bm().worker,Yr.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load Basis texture",s),xm[s](i)},Yr.postMessage({type:"init",jsUrl:pi.jsUrl,wasmUrl:pi.wasmUrl,supportedTextures:r})),Yr}function vm(r,t){const e=GS(t);return new Promise(s=>{xm[r]=s,e.postMessage({type:"load",url:r})})}const IS={extension:{type:v.LoadParser,priority:vt.High,name:"loadBasis"},name:"loadBasis",test(r){return Ot(r,[".basis"])},async load(r,t,e){const s=await Wr(),i=await vm(r,s),n=new Vr(i);return ie(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function BS(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))(Ma||{}),Oa=(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))(Oa||{});function at(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var _t=(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=at("UYVY")]="UYVY",r[r.R8G8_B8G8=at("RGBG")]="R8G8_B8G8",r[r.YUY2=at("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=at("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=at("DXT1")]="DXT1",r[r.DXT2=at("DXT2")]="DXT2",r[r.DXT3=at("DXT3")]="DXT3",r[r.DXT4=at("DXT4")]="DXT4",r[r.DXT5=at("DXT5")]="DXT5",r[r.ATI1=at("ATI1")]="ATI1",r[r.AT1N=at("AT1N")]="AT1N",r[r.ATI2=at("ATI2")]="ATI2",r[r.AT2N=at("AT2N")]="AT2N",r[r.BC4U=at("BC4U")]="BC4U",r[r.BC4S=at("BC4S")]="BC4S",r[r.BC5U=at("BC5U")]="BC5U",r[r.BC5S=at("BC5S")]="BC5S",r[r.DX10=at("DX10")]="DX10",r))(_t||{});const Ca={[_t.DXT1]:"bc1-rgba-unorm",[_t.DXT2]:"bc2-rgba-unorm",[_t.DXT3]:"bc2-rgba-unorm",[_t.DXT4]:"bc3-rgba-unorm",[_t.DXT5]:"bc3-rgba-unorm",[_t.ATI1]:"bc4-r-unorm",[_t.BC4U]:"bc4-r-unorm",[_t.BC4S]:"bc4-r-snorm",[_t.ATI2]:"bc5-rg-unorm",[_t.BC5U]:"bc5-rg-unorm",[_t.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},bt={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"},B={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:US,HEADER_DX10_FIELDS:kS,DXGI_FORMAT:Ma,D3D10_RESOURCE_DIMENSION:Oa,D3DFMT:_t},ym={"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 Tm(r,t){const{format:e,fourCC:s,width:i,height:n,dataOffset:o,mipmapCount:a}=LS(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 u=$S(e,i,n,o,a,r);return{format:e,width:i,height:n,resource:u,alphaMode:"no-premultiply-alpha"}}function $S(r,t,e,s,i,n){const o=[],a=ym[r];let u=t,l=e,h=s;for(let c=0;c>1,1),l=Math.max(l>>1,1)}return o}function LS(r){const t=new Uint32Array(r,0,B.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[B.HEADER_FIELDS.MAGIC]!==B.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[B.HEADER_FIELDS.HEIGHT],s=t[B.HEADER_FIELDS.WIDTH],i=Math.max(1,t[B.HEADER_FIELDS.MIPMAP_COUNT]),n=t[B.HEADER_FIELDS.PF_FLAGS],o=t[B.HEADER_FIELDS.FOURCC],a=NS(t,n,o,r),u=B.MAGIC_SIZE+B.HEADER_SIZE+(o===B.D3DFMT.DX10?B.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:s,height:e,dataOffset:u,mipmapCount:i}}function NS(r,t,e,s){if(t&B.PIXEL_FORMAT_FLAGS.FOURCC){if(e===B.D3DFMT.DX10){const i=new Uint32Array(s,B.MAGIC_SIZE+B.HEADER_SIZE,B.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(i[B.HEADER_DX10_FIELDS.MISC_FLAG]===B.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(i[B.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===B.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=i[B.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in bt)return bt[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in Ca)return Ca[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&B.PIXEL_FORMAT_FLAGS.RGB||t&B.PIXEL_FORMAT_FLAGS.RGBA)return XS(r);throw t&B.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&B.PIXEL_FORMAT_FLAGS.LUMINANCE||t&B.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&B.PIXEL_FORMAT_FLAGS.ALPHA||t&B.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 XS(r){const t=r[B.HEADER_FIELDS.RGB_BITCOUNT],e=r[B.HEADER_FIELDS.R_BIT_MASK],s=r[B.HEADER_FIELDS.G_BIT_MASK],i=r[B.HEADER_FIELDS.B_BIT_MASK],n=r[B.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&s===65280&&i===16711680&&n===4278190080)return bt[B.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&s===65280&&i===255&&n===4278190080)return bt[B.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&s===1047552&&i===1023&&n===3221225472)return bt[B.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&s===4294901760&&i===0&&n===0)return bt[B.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&s===0&&i===0&&n===0)return bt[B.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&s===992&&i===31&&n===32768)return bt[B.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&s===2016&&i===31&&n===0)return bt[B.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&s===240&&i===15&&n===61440)return bt[B.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&s===0&&i===0&&n===65280)return bt[B.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&s===0&&i===0&&n===0)return bt[B.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&s===0&&i===0&&n===0)return bt[B.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}`)}const HS={extension:{type:v.LoadParser,priority:vt.High,name:"loadDDS"},name:"loadDDS",test(r){return Ot(r,[".dds"])},async load(r,t,e){const s=await Wr(),i=await(await fetch(r)).arrayBuffer(),n=Tm(i,s),o=new Vr(n);return ie(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var Sm=(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))(Sm||{}),jS=(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))(jS||{}),zS=(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))(zS||{});const VS={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"},WS=[171,75,84,88,32,49,49,187,13,10,26,10],YS={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},KS=64,qS=67305985,ZS={5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},QS={6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},JS={32819:2,32820:2,33635:2},t2={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},et={FILE_HEADER_SIZE:KS,FILE_IDENTIFIER:WS,FORMATS_TO_COMPONENTS:QS,INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:t2,INTERNAL_FORMAT_TO_TEXTURE_FORMATS:VS,FIELDS:YS,TYPES_TO_BYTES_PER_COMPONENT:ZS,TYPES_TO_BYTES_PER_PIXEL:JS,ENDIANNESS:qS};function Em(r,t){const e=new DataView(r);if(!i2(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:s,glType:i,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:u,numberOfMipmapLevels:l,offset:h}=s2(e),c=et.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=r2(i,n,o),p=e2(e,i,d,a,u,h,l,s);return{format:c,width:a,height:u,resource:p,alphaMode:"no-premultiply-alpha"}}function e2(r,t,e,s,i,n,o,a){const u=s+3&-4,l=i+3&-4;let h=s*i;t===0&&(h=u*l);let c=h*e,d=s,p=i,f=u,g=l,m=n;const _=new Array(o);for(let x=0;x>1||1,p=p>>1||1,f=d+4-1&-4,g=p+4-1&-4,c=f*g*e}return _}function r2(r,t,e){let s=et.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(et.TYPES_TO_BYTES_PER_COMPONENT[r]?s=et.TYPES_TO_BYTES_PER_COMPONENT[r]*et.FORMATS_TO_COMPONENTS[t]:s=et.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 s2(r){const t=r.getUint32(et.FIELDS.ENDIANNESS,!0)===et.ENDIANNESS,e=r.getUint32(et.FIELDS.GL_TYPE,t),s=r.getUint32(et.FIELDS.GL_FORMAT,t),i=r.getUint32(et.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(et.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(et.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(et.FIELDS.PIXEL_DEPTH,t)||1,u=r.getUint32(et.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,l=r.getUint32(et.FIELDS.NUMBER_OF_FACES,t),h=r.getUint32(et.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),c=r.getUint32(et.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(o===0||a!==1)throw new Error("Only 2D textures are supported");if(l!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==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:et.FILE_HEADER_SIZE+c}}function i2(r){for(let t=0;tt.destroy(!0)):r.destroy(!0)}},o2='(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=y(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,o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}})();\n';let qe=null;class Am{constructor(){qe||(qe=URL.createObjectURL(new Blob([o2],{type:"application/javascript"}))),this.worker=new Worker(qe)}}Am.revokeObjectURL=function(){qe&&(URL.revokeObjectURL(qe),qe=null)};const fi={jsUrl:"https://files.pixijs.download/transcoders/ktx/libktx.js",wasmUrl:"https://files.pixijs.download/transcoders/ktx/libktx.wasm"};function a2(r){Object.assign(fi,r)}let Kr;const wm={};function u2(r){return Kr||(Kr=new Am().worker,Kr.onmessage=t=>{const{success:e,url:s,textureOptions:i}=t.data;e||console.warn("Failed to load KTX texture",s),wm[s](i)},Kr.postMessage({type:"init",jsUrl:fi.jsUrl,wasmUrl:fi.wasmUrl,supportedTextures:r})),Kr}function Pm(r,t){const e=u2(t);return new Promise(s=>{wm[r]=s,e.postMessage({type:"load",url:r})})}const l2={extension:{type:v.LoadParser,priority:vt.High,name:"loadKTX2"},name:"loadKTX2",test(r){return Ot(r,".ktx2")},async load(r,t,e){const s=await Wr(),i=await Pm(r,s),n=new Vr(i);return ie(n,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Ga={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:Rm},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:Rm}};function h2(r){const t=r.format;if(Ga[t]){const e=Ga[t].convertFunction,s=r.resource;for(let i=0;iOt(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];mi.includes(n)&&(s=n)}else s=i[i.length-1];return{resolution:parseFloat((e=(t=Jt.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:s,src:r}}};let gi;const b2={extension:{type:v.DetectionParser,priority:2},test:async()=>!!(await Xr()||Nr()),add:async r=>{const t=await Ra();return gi=x2(t),[...gi,...r]},remove:async r=>gi?r.filter(t=>!(t in gi)):r};function x2(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=mi.indexOf(s),o=mi.indexOf(i);return n===-1?1:o===-1?-1:n-o}),t}const v2=new ht,Ia=class{cull(t,e,s=!0){this._cullRecursive(t,e,s)}_cullRecursive(t,e,s=!0){var i;if(t.cullable&&t.measurable&&t.includeInBuild){const n=(i=t.cullArea)!=null?i:pr(t,s,v2);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n{Cm.shared.cull(this.stage,this.renderer.screen),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}Gm.extension={priority:10,type:v.Application,name:"culler"};const y2={extension:{type:v.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return yT})}};var T2=Object.defineProperty,_i=Object.getOwnPropertySymbols,Im=Object.prototype.hasOwnProperty,Bm=Object.prototype.propertyIsEnumerable,Fm=(r,t,e)=>t in r?T2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ba=(r,t)=>{for(var e in t||(t={}))Im.call(t,e)&&Fm(r,e,t[e]);if(_i)for(var e of _i(t))Bm.call(t,e)&&Fm(r,e,t[e]);return r},S2=(r,t)=>{var e={};for(var s in r)Im.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&_i)for(var s of _i(r))t.indexOf(s)<0&&Bm.call(r,s)&&(e[s]=r[s]);return e};const Dm=class Tl extends Ct{constructor(t){t=Ba(Ba({},Tl.defaultOptions),t),super(t),this.enabled=!0,this._state=It.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.addResource("uTexture",0,1)}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=S2(e,["gpu","gl"]);let o,a;return s&&(o=At.from(s)),i&&(a=Mt.from(i)),new Tl(Ba({gpuProgram:o,glProgram:a},n))}};Dm.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let Zt=Dm;var Um=` 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} } `,km=`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(); } `,$m=` 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; }`,E2=Object.defineProperty,Lm=Object.getOwnPropertySymbols,A2=Object.prototype.hasOwnProperty,w2=Object.prototype.propertyIsEnumerable,Nm=(r,t,e)=>t in r?E2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xm=(r,t)=>{for(var e in t||(t={}))A2.call(t,e)&&Nm(r,e,t[e]);if(Lm)for(var e of Lm(t))w2.call(t,e)&&Nm(r,e,t[e]);return r};class P2 extends Zt{constructor(t){const e=t.gpu,s=Hm(Xm({source:$m},e)),i=At.from({vertex:{source:s,entryPoint:"mainVertex"},fragment:{source:s,entryPoint:"mainFragment"}}),n=t.gl,o=Hm(Xm({source:Um},n)),a=Mt.from({vertex:km,fragment:o}),u=new rt({uBlend:{value:1,type:"f32"}});super({gpuProgram:i,glProgram:a,blendRequired:!0,resources:{blendUniforms:u,uBackTexture:A.EMPTY}})}}function Hm(r){const{source:t,functions:e,main:s}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",s)}const R2=` 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; } `,M2=` 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 bi=`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(); } `,jm=` in vec2 vTextureCoord; out vec4 finalColor; uniform float uAlpha; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vTextureCoord) * uAlpha; } `,Fa=`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; }`,O2=Object.defineProperty,C2=Object.defineProperties,G2=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertySymbols,zm=Object.prototype.hasOwnProperty,Vm=Object.prototype.propertyIsEnumerable,Wm=(r,t,e)=>t in r?O2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Da=(r,t)=>{for(var e in t||(t={}))zm.call(t,e)&&Wm(r,e,t[e]);if(xi)for(var e of xi(t))Vm.call(t,e)&&Wm(r,e,t[e]);return r},I2=(r,t)=>C2(r,G2(t)),B2=(r,t)=>{var e={};for(var s in r)zm.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&xi)for(var s of xi(r))t.indexOf(s)<0&&Vm.call(r,s)&&(e[s]=r[s]);return e};const Ym=class zx extends Zt{constructor(t){t=Da(Da({},zx.defaultOptions),t);const e=At.from({vertex:{source:Fa,entryPoint:"mainVertex"},fragment:{source:Fa,entryPoint:"mainFragment"}}),s=Mt.from({vertex:bi,fragment:jm,name:"alpha-filter"}),i=t,{alpha:n}=i,o=B2(i,["alpha"]),a=new rt({uAlpha:{value:n,type:"f32"}});super(I2(Da({},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}};Ym.defaultOptions={alpha:1};let F2=Ym;const Ua={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]},D2=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(` `);function Km(r){const t=Ua[r],e=t.length;let s=D2,i="";const n="finalColor += texture(uTexture, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a=e&&(o=r-a-1),u=u.replace("%value%",t[o].toString()),i+=u,i+=` `}return s=s.replace("%blur%",i),s=s.replace("%size%",r.toString()),s}const U2=` in vec2 aPosition; uniform float uStrength; out vec2 vBlurTexCoords[%size%]; uniform vec4 uInputSize; uniform vec4 uOutputFrame; uniform vec4 uOutputTexture; vec4 filterVertexPosition( void ) { vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy; position.x = position.x * (2.0 / uOutputTexture.x) - 1.0; position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z; return vec4(position, 0.0, 1.0); } vec2 filterTextureCoord( void ) { return aPosition * (uOutputFrame.zw * uInputSize.zw); } void main(void) { gl_Position = filterVertexPosition(); float pixelStrength = uInputSize.%dimension% * uStrength; vec2 textureCoord = filterTextureCoord(); %blur% }`;function qm(r,t){const e=Math.ceil(r/2);let s=U2,i="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o, 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 Jm(r,t){const e=Ua[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?k2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ka=(r,t)=>{for(var e in t||(t={}))$2.call(t,e)&&eg(r,e,t[e]);if(tg)for(var e of tg(t))L2.call(t,e)&&eg(r,e,t[e]);return r};const rg=class Vx extends Zt{constructor(t){t=ka(ka({},Vx.defaultOptions),t);const e=Zm(t.horizontal,t.kernelSize),s=Jm(t.horizontal,t.kernelSize);super(ka({glProgram:e,gpuProgram:s,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._uniforms=this.resources.blurUniforms.uniforms}apply(t,e,s,i){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,s,i);else{const n=lt.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const u=t.renderer.type===mt.WEBGPU;for(let l=0;lt in r?N2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qr=(r,t)=>{for(var e in t||(t={}))sg.call(t,e)&&ng(r,e,t[e]);if(yi)for(var e of yi(t))ig.call(t,e)&&ng(r,e,t[e]);return r},j2=(r,t)=>X2(r,H2(t)),z2=(r,t)=>{var e={};for(var s in r)sg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&yi)for(var s of yi(r))t.indexOf(s)<0&&ig.call(r,s)&&(e[s]=r[s]);return e};class og extends Zt{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=qr(qr({},vi.defaultOptions),s);const i=s,{strength:n,strengthX:o,strengthY:a,quality:u}=i,l=z2(i,["strength","strengthX","strengthY","quality"]);super(j2(qr({},l),{compatibleRenderers:mt.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new vi(qr({horizontal:!0},s)),this.blurYFilter=new vi(qr({horizontal:!1},s)),this.quality=u,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=lt.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),lt.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()}}og.defaultOptions={strength:8,quality:4,kernelSize:5};var ag=` 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); } `,$a=`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); }`,V2=Object.defineProperty,W2=Object.defineProperties,Y2=Object.getOwnPropertyDescriptors,ug=Object.getOwnPropertySymbols,K2=Object.prototype.hasOwnProperty,q2=Object.prototype.propertyIsEnumerable,lg=(r,t,e)=>t in r?V2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Z2=(r,t)=>{for(var e in t||(t={}))K2.call(t,e)&&lg(r,e,t[e]);if(ug)for(var e of ug(t))q2.call(t,e)&&lg(r,e,t[e]);return r},Q2=(r,t)=>W2(r,Y2(t));class J2 extends Zt{constructor(t={}){const e=new rt({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=At.from({vertex:{source:$a,entryPoint:"mainVertex"},fragment:{source:$a,entryPoint:"mainFragment"}}),i=Mt.from({vertex:bi,fragment:ag,name:"color-matrix-filter"});super(Q2(Z2({},t),{gpuProgram:s,glProgram:i,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){let s=t;e&&(this._multiply(s,this.matrix,t),s=this._colorMatrix(s)),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=s,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}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const 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]=z.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),u=s+(1-s)*o,l=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,g=o*(1-s)+a*i,m=s+o*(1-s),_=[u,l,h,0,0,c,d,p,0,0,f,g,m,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,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,s,i,n){t=t||.2,e=e||.15,s=s||16770432,i=i||3375104;const o=z.shared,[a,u,l]=o.setValue(s).toArray(),[h,c,d]=o.setValue(i).toArray(),p=[.3,.59,.11,0,0,a,u,l,t,0,h,c,d,e,0,a-h,u-c,l-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 hg=` 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)); } `,cg=`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(); } `,La=` 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)); }`,tE=Object.defineProperty,eE=Object.defineProperties,rE=Object.getOwnPropertyDescriptors,Ti=Object.getOwnPropertySymbols,dg=Object.prototype.hasOwnProperty,pg=Object.prototype.propertyIsEnumerable,fg=(r,t,e)=>t in r?tE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sE=(r,t)=>{for(var e in t||(t={}))dg.call(t,e)&&fg(r,e,t[e]);if(Ti)for(var e of Ti(t))pg.call(t,e)&&fg(r,e,t[e]);return r},iE=(r,t)=>eE(r,rE(t)),nE=(r,t)=>{var e={};for(var s in r)dg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ti)for(var s of Ti(r))t.indexOf(s)<0&&pg.call(r,s)&&(e[s]=r[s]);return e};class oE extends Zt{constructor(...t){let e=t[0];e instanceof Dt&&(e={sprite:e,scale:t[1]});const s=e,{sprite:i,scale:n}=s,o=nE(s,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new W(a,a));const u=new rt({uFilterMatrix:{value:new C,type:"mat3x3"},uScale:{value:a,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),l=Mt.from({vertex:cg,fragment:hg,name:"displacement-filter"}),h=At.from({vertex:{source:La,entryPoint:"mainVertex"},fragment:{source:La,entryPoint:"mainFragment"}}),c=i.texture.source;super(iE(sE({},o),{gpuProgram:h,glProgram:l,resources:{filterUniforms:u,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),u=Math.sqrt(o.c*o.c+o.d*o.d);a!==0&&u!==0&&(n.uRotation[0]=o.a/a,n.uRotation[1]=o.b/a,n.uRotation[2]=o.c/u,n.uRotation[3]=o.d/u),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,s,i)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var mg=` 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; } `,Na=` 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; }`,aE=Object.defineProperty,uE=Object.defineProperties,lE=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,gg=Object.prototype.hasOwnProperty,_g=Object.prototype.propertyIsEnumerable,bg=(r,t,e)=>t in r?aE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xa=(r,t)=>{for(var e in t||(t={}))gg.call(t,e)&&bg(r,e,t[e]);if(Si)for(var e of Si(t))_g.call(t,e)&&bg(r,e,t[e]);return r},hE=(r,t)=>uE(r,lE(t)),cE=(r,t)=>{var e={};for(var s in r)gg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Si)for(var s of Si(r))t.indexOf(s)<0&&_g.call(r,s)&&(e[s]=r[s]);return e};const xg=class Wx extends Zt{constructor(t={}){t=Xa(Xa({},Wx.defaultOptions),t);const e=At.from({vertex:{source:Na,entryPoint:"mainVertex"},fragment:{source:Na,entryPoint:"mainFragment"}}),s=Mt.from({vertex:bi,fragment:mg,name:"noise-filter"}),i=t,{noise:n,seed:o}=i,a=cE(i,["noise","seed"]);super(hE(Xa({},a),{gpuProgram:e,glProgram:s,resources:{noiseUniforms:new rt({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}};xg.defaultOptions={noise:.5};let dE=xg;var vg=`in vec2 vMaskCoord; in vec2 vTextureCoord; uniform sampler2D uTexture; uniform sampler2D uMaskTexture; uniform float uAlpha; uniform vec4 uMaskClamp; out vec4 finalColor; void main(void) { float clip = step(3.5, step(uMaskClamp.x, vMaskCoord.x) + step(uMaskClamp.y, vMaskCoord.y) + step(vMaskCoord.x, uMaskClamp.z) + step(vMaskCoord.y, uMaskClamp.w)); // TODO look into why this is needed float npmAlpha = uAlpha; vec4 original = texture(uTexture, vTextureCoord); vec4 masky = texture(uMaskTexture, vMaskCoord); float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a); original *= (alphaMul * masky.r * uAlpha * clip); finalColor = original; } `,yg=`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); } `,Ha=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, uOutputFrame:vec4, uGlobalFrame:vec4, uOutputTexture:vec4, }; struct MaskUniforms { uFilterMatrix:mat3x3, uMaskClamp:vec4, 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 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 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 npmAlpha = 0.0; var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a); var a = (alphaMul * mask.r) * clip; return vec4(source.rgb, source.a) * a; }`,pE=Object.defineProperty,fE=Object.defineProperties,mE=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,Tg=Object.prototype.hasOwnProperty,Sg=Object.prototype.propertyIsEnumerable,Eg=(r,t,e)=>t in r?pE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gE=(r,t)=>{for(var e in t||(t={}))Tg.call(t,e)&&Eg(r,e,t[e]);if(Ei)for(var e of Ei(t))Sg.call(t,e)&&Eg(r,e,t[e]);return r},_E=(r,t)=>fE(r,mE(t)),bE=(r,t)=>{var e={};for(var s in r)Tg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ei)for(var s of Ei(r))t.indexOf(s)<0&&Sg.call(r,s)&&(e[s]=r[s]);return e};class Ag extends Zt{constructor(t){const e=t,{sprite:s}=e,i=bE(e,["sprite"]),n=new Rn(s.texture),o=new rt({uFilterMatrix:{value:new C,type:"mat3x3"},uMaskClamp:{value:n.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"}}),a=At.from({vertex:{source:Ha,entryPoint:"mainVertex"},fragment:{source:Ha,entryPoint:"mainFragment"}}),u=Mt.from({vertex:yg,fragment:vg,name:"mask-filter"});super(_E(gE({},i),{gpuProgram:a,glProgram:u,resources:{filterUniforms:o,uMaskTexture:s.texture.source}})),this.sprite=s,this._textureMatrix=n}apply(t,e,s,i){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,s,i)}}var xE=`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; }`;function ja(r,t,e,s,i,n,o,a){const u=o-e,l=a-s,h=i-e,c=n-s,d=r-e,p=t-s,f=u*u+l*l,g=u*h+l*c,m=u*d+l*p,_=h*h+c*c,x=h*d+c*p,b=1/(f*_-g*g),y=(_*m-g*x)*b,S=(f*x-g*m)*b;return y>=0&&S>=0&&y+S<1}class El{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){const i=s/2,n=i*i,{x:o,x2:a,x3:u,y:l,y2:h,y3:c}=this;return Cr(t,e,o,l,a,c)<=n||Cr(t,e,a,h,u,c)<=n||Cr(t,e,u,c,o,l)<=n}clone(){return new El(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 V;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 wg=class Yx{constructor(t){this._tick=()=>{this.timeout=setTimeout(this._processQueue,0)},this._processQueue=()=>{const{queue:e}=this;let s=0;for(;e.length&&s{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),ut.system.addOnce(this._tick,this,Vt.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let s=0;st in r?vE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yE=(r,t)=>{for(var e in t||(t={}))Rg.call(t,e)&&Og(r,e,t[e]);if(Ai)for(var e of Ai(t))Mg.call(t,e)&&Og(r,e,t[e]);return r},TE=(r,t)=>{var e={};for(var s in r)Rg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Ai)for(var s of Ai(r))t.indexOf(s)<0&&Mg.call(r,s)&&(e[s]=r[s]);return e};class Ze extends xe{constructor(...t){var e;let s=t[0];s instanceof Be&&(s={geometry:s,shader:t[1]},t[3]&&(s.geometry.topology=t[3]));const i=s,{geometry:n,shader:o,texture:a,roundPixels:u,state:l}=i,h=TE(i,["geometry","shader","texture","roundPixels","state"]);super(yE({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:A.WHITE,this.state=l!=null?l:It.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=u!=null?u:!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=A.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||this.state.data&12?!1:this._geometry instanceof re?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}addBounds(t){t.addBounds(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 u=0;u+2t in r?SE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wE=(r,t)=>{for(var e in t||(t={}))Cg.call(t,e)&&Ig(r,e,t[e]);if(wi)for(var e of wi(t))Gg.call(t,e)&&Ig(r,e,t[e]);return r},PE=(r,t)=>EE(r,AE(t)),RE=(r,t)=>{var e={};for(var s in r)Cg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&wi)for(var s of wi(r))t.indexOf(s)<0&&Gg.call(r,s)&&(e[s]=r[s]);return e};class is extends Dt{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const s=e,{textures:i,autoUpdate:n}=s,o=RE(s,["textures","autoUpdate"]),[a]=i;super(PE(wE({},o),{texture:a instanceof A?a:a.texture})),this._textures=null,this._durations=null,this._autoUpdate=n!=null?n:!0,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=i}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(ut.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(ut.shared.add(this.update,this,Vt.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.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),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?(ut.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(ut.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Bg{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new C,this.observer=e,this.position=new st(this,0,0),this.scale=new st(this,1,1),this.pivot=new st(this,0,0),this.skew=new st(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1),t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}var ME=Object.defineProperty,Pi=Object.getOwnPropertySymbols,Fg=Object.prototype.hasOwnProperty,Dg=Object.prototype.propertyIsEnumerable,Ug=(r,t,e)=>t in r?ME(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zr=(r,t)=>{for(var e in t||(t={}))Fg.call(t,e)&&Ug(r,e,t[e]);if(Pi)for(var e of Pi(t))Dg.call(t,e)&&Ug(r,e,t[e]);return r},OE=(r,t)=>{var e={};for(var s in r)Fg.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Pi)for(var s of Pi(r))t.indexOf(s)<0&&Dg.call(r,s)&&(e[s]=r[s]);return e};const kg=class qi extends xe{constructor(...t){let e=t[0]||{};e instanceof A&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=Zr(Zr({},qi.defaultOptions),e);const s=e!=null?e:{},{texture:i,anchor:n,tilePosition:o,tileScale:a,tileRotation:u,width:l,height:h,applyAnchorToTexture:c,roundPixels:d}=s,p=OE(s,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(Zr({label:"TilingSprite"},p)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new st({_onUpdate:()=>{this.onViewUpdate()}}),this._applyAnchorToTexture=c,this.texture=i,this._width=l!=null?l:i.width,this._height=h!=null?h:i.height,this._tileTransform=new Bg({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=u,this.roundPixels=d!=null?d:!1}static from(t,e={}){return typeof t=="string"?new qi(Zr({texture:Y.get(t)},e)):new qi(Zr({texture:t},e))}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}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}set texture(t){t||(t=A.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.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.maxX=-e._x*s,t.minX=t.maxX+s,t.maxY=-e._y*i,t.minY=t.maxY+i}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}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)}onViewUpdate(){if(this._boundsDirty=!0,this._didTilingSpriteUpdate=!0,this._didViewChangeTick++,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}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}};kg.defaultOptions={texture:A.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let $g=kg;var CE=Object.defineProperty,Ri=Object.getOwnPropertySymbols,Lg=Object.prototype.hasOwnProperty,Ng=Object.prototype.propertyIsEnumerable,Xg=(r,t,e)=>t in r?CE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GE=(r,t)=>{for(var e in t||(t={}))Lg.call(t,e)&&Xg(r,e,t[e]);if(Ri)for(var e of Ri(t))Ng.call(t,e)&&Xg(r,e,t[e]);return r},IE=(r,t)=>{var e={};for(var s in r)Lg.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&&Ng.call(r,s)&&(e[s]=r[s]);return e};class Mi extends xe{constructor(t,e){const s=t,{text:i,resolution:n,style:o,anchor:a,width:u,height:l,roundPixels:h}=s,c=IE(s,["text","resolution","style","anchor","width","height","roundPixels"]);super(GE({},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 st({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=h!=null?h:!1,u!==void 0&&(this.width=u),l!==void 0&&(this.height=l)}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 bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}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)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}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(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function Oi(r,t){var e;let s=(e=r[0])!=null?e:{};return(typeof s=="string"||r[1])&&(s={text:s,style:r[1]}),s}class za extends Mi{constructor(...t){const e=Oi(t,"Text");super(e,St),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=Ft.measureText(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}}class Hg extends Pg{resolveQueueItem(t,e){return t instanceof Q?this.resolveContainerQueueItem(t,e):t instanceof tt||t instanceof A?e.push(t.source):t instanceof ct&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof Dt||t instanceof $g||t instanceof Ze?e.push(t.texture.source):t instanceof za?e.push(t):t instanceof ir?e.push(t.context):t instanceof is&&t.textures.forEach(s=>{s.source?e.push(s.source):e.push(s.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getContextRenderData(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 jg extends Mi{constructor(...t){var e,s,i;const n=Oi(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(i=(s=n.style).fill)!=null||(s.fill=16777215),super(n,St),this.renderPipeId="bitmapText"}_updateBounds(){const t=this._bounds,e=this._anchor,s=Ur.measureText(this.text,this._style),i=s.scale,n=s.offsetY*i;let o=s.width*i,a=s.height*i;const u=this._style._stroke;u&&(o+=u.width,a+=u.width),t.minX=-e._x*o,t.maxX=t.minX+o,t.minY=-e._y*(a+n),t.maxY=t.minY+a}}class zg extends Mi{constructor(...t){const e=Oi(t,"HtmlText");super(e,Re),this.renderPipeId="htmlText"}_updateBounds(){const t=this._bounds,e=this._anchor,s=Jo(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}}class Vg extends Hg{uploadQueueItem(t){t instanceof tt?this.uploadTextureSource(t):t instanceof za?this.uploadText(t):t instanceof zg?this.uploadHTMLText(t):t instanceof jg?this.uploadBitmapText(t):t instanceof ct&&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.getContextRenderData(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 Wg extends Vg{destroy(){clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}Wg.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"prepare"};class Va{constructor(){this._didUpload=!1,this._tempState=It.for2d()}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(t,e,s){const i=t.renderer;i.shader.bind(s,this._didUpload),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,s.glProgram)}execute(t,e){const s=t.renderer;this._didUpload=!0,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 Yg={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); `}},Kg={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); `}};function qg(r,t){const e=r.root,s=r.instructionSet;s.reset();const i=t.renderPipes?t:t.batch.renderer,n=i.renderPipes;n.batch.buildStart(s),n.blendMode.buildStart(),n.colorMask.buildStart(),e.sortableChildren&&e.sortChildren(),Zg(e,s,i,!0),n.batch.buildEnd(s),n.blendMode.buildEnd(s)}function Qr(r,t,e){const s=e.renderPipes?e:e.batch.renderer;r.globalDisplayStatus<7||!r.includeInBuild||(r.sortableChildren&&r.sortChildren(),r.isSimple?UE(r,t,s):Zg(r,t,s,!1))}function UE(r,t,e){if(r.renderPipeId){const{renderPipes:s,renderableGC:i}=e;s.blendMode.setBlendMode(r,r.groupBlendMode,t),r.didViewUpdate=!1,s[r.renderPipeId].addRenderable(r,t),i.addRenderable(r,t)}if(!r.renderGroup){const s=r.children,i=s.length;for(let n=0;n=0;u--){const l=r.effects[u];i[l.pipe].pop(l,r,t)}}}const kE=new ht;let $E=class extends dr{constructor(){super(),this.filters=[new Ag({sprite:new Dt(A.EMPTY),resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}};class qa{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,s){const i=this._renderer;if(i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,canBundle:!1,maskedContainer:e}),t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,Qr(n,s,i),n.includeInBuild=!1}i.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,canBundle:!1})}execute(t){const e=this._renderer,s=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const i=X.get($E);if(s){t.mask.mask.measurable=!0;const n=pr(t.mask.mask,!0,kE);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=lt.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const u=i.sprite;u.texture=a,u.worldTransform.tx=n.minX,u.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&<.returnTexture(i.filterTexture),X.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}qa.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"alphaMask"};class Za{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const i=this._colorStack;this._colorStackIndex--;const n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._colorStack=null}}Za.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"colorMask"};class LE{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){Ss(this.mask,t,e)}addLocalBounds(t,e){Es(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}reset(){this.mask.measurable=!0,this.mask=null}destroy(){this.reset()}}class Qa{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,s){var i,n;const o=t,a=this._renderer;a.renderPipes.batch.break(s),a.renderPipes.blendMode.setBlendMode(o.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,canBundle:!1});const u=o.mask;u.includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0});const l=this._maskHash.get(o);l.instructionsStart=s.instructionSize,Qr(u,s,a),u.includeInBuild=!1,a.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,canBundle:!1});const h=s.instructionSize-l.instructionsStart-1;l.instructionsLength=h;const c=a.renderTarget.renderTarget.uid;(n=(i=this._maskStackHash)[c])!=null||(i[c]=0)}pop(t,e,s){const i=t,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(i.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Jr||{});class Qg{constructor(t,e){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class Ja{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=t}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(t){return this._gpuBuffers[t.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;if(this._boundBufferBases[e]!==t){const i=this.getGlBuffer(t);this._boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,i.buffer)}}bindBufferRange(t,e,s){const{_gl:i}=this;s=s||0;const n=this.getGlBuffer(t);i.bindBufferRange(i.UNIFORM_BUFFER,e||0,n.buffer,s*256,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;if(s.byteLength>=t.data.byteLength)e.bufferSubData(s.type,0,i,0,t._updateSize/i.BYTES_PER_ELEMENT);else{const n=t.descriptor.usage&H.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=i.byteLength,e.bufferData(s.type,i,n)}return s}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const s=this._gpuBuffers[t.uid],i=this._gl;e||i.deleteBuffer(s.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let s=Jr.ARRAY_BUFFER;t.descriptor.usage&H.INDEX?s=Jr.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&H.UNIFORM&&(s=Jr.UNIFORM_BUFFER);const i=new Qg(e.createBuffer(),s);return this._gpuBuffers[t.uid]=i,t.on("destroy",this.onBufferDestroy,this),i}}Ja.extension={type:[v.WebGLSystem],name:"buffer"};var NE=Object.defineProperty,XE=Object.defineProperties,HE=Object.getOwnPropertyDescriptors,Jg=Object.getOwnPropertySymbols,jE=Object.prototype.hasOwnProperty,zE=Object.prototype.propertyIsEnumerable,t_=(r,t,e)=>t in r?NE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gi=(r,t)=>{for(var e in t||(t={}))jE.call(t,e)&&t_(r,e,t[e]);if(Jg)for(var e of Jg(t))zE.call(t,e)&&t_(r,e,t[e]);return r},e_=(r,t)=>XE(r,HE(t));const tu=class qx{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=Gi(Gi({},qx.defaultOptions),t);let i=this.multiView=t.multiView;if(t.context&&i&&(ee("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),i=!1),i?this.canvas=k.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&&ee("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._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}};tu.extension={type:[v.WebGLSystem],name:"context"},tu.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let r_=tu;function eu(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)):ee(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}VE(r)}function VE(r){var t,e;const{buffers:s,attributes:i}=r,n={},o={};for(const a in s){const u=s[a];n[u.uid]=0,o[u.uid]=0}for(const a in i){const u=i[a];n[u.buffer.uid]+=De(u.format).stride}for(const a in i){const u=i[a];(t=u.stride)!=null||(u.stride=n[u.buffer.uid]),(e=u.start)!=null||(u.start=o[u.buffer.uid]),o[u.buffer.uid]+=De(u.format).stride}}var Ii=(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))(Ii||{}),ru=(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))(ru||{}),s_=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(s_||{}),j=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(j||{});const i_={uint8x2:j.UNSIGNED_BYTE,uint8x4:j.UNSIGNED_BYTE,sint8x2:j.BYTE,sint8x4:j.BYTE,unorm8x2:j.UNSIGNED_BYTE,unorm8x4:j.UNSIGNED_BYTE,snorm8x2:j.BYTE,snorm8x4:j.BYTE,uint16x2:j.UNSIGNED_SHORT,uint16x4:j.UNSIGNED_SHORT,sint16x2:j.SHORT,sint16x4:j.SHORT,unorm16x2:j.UNSIGNED_SHORT,unorm16x4:j.UNSIGNED_SHORT,snorm16x2:j.SHORT,snorm16x4:j.SHORT,float16x2:j.HALF_FLOAT,float16x4:j.HALF_FLOAT,float32:j.FLOAT,float32x2:j.FLOAT,float32x3:j.FLOAT,float32x4:j.FLOAT,uint32:j.UNSIGNED_INT,uint32x2:j.UNSIGNED_INT,uint32x3:j.UNSIGNED_INT,uint32x4:j.UNSIGNED_INT,sint32:j.INT,sint32x2:j.INT,sint32x3:j.INT,sint32x4:j.INT};function n_(r){var t;return(t=i_[r])!=null?t:i_.float32}const WE={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class su{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=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,u)=>{s.drawElementsInstancedANGLE(i,n,o,a,u)},t.vertexAttribDivisor=(i,n)=>s.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(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()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let s=0;s1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,l,(s||0)*u,i):n.drawElements(a,e||o.indexBuffer.data.length,l,(s||0)*u)}else i>1?n.drawArraysInstanced(a,s||0,e||o.getSize(),i):n.drawArrays(a,s||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}su.extension={type:[v.WebGLSystem],name:"geometry"};var YE=Object.defineProperty,o_=Object.getOwnPropertySymbols,KE=Object.prototype.hasOwnProperty,qE=Object.prototype.propertyIsEnumerable,a_=(r,t,e)=>t in r?YE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,u_=(r,t)=>{for(var e in t||(t={}))KE.call(t,e)&&a_(r,e,t[e]);if(o_)for(var e of o_(t))qE.call(t,e)&&a_(r,e,t[e]);return r};const ZE=new Be({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),iu=class Zx{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:s}=u_(u_({},Zx.defaultOptions),t);this.useBackBuffer=e,this._antialias=s,this._renderer.context.supports.msaa||(ee("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=It.for2d();const i=new Mt({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 Ct({glProgram:i,resources:{uTexture:A.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(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:ZE,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new A({source:new tt({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)}};iu.extension={type:[v.WebGLSystem],name:"backBuffer",priority:1},iu.defaultOptions={useBackBuffer:!1};let l_=iu;class nu{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)))}}nu.extension={type:[v.WebGLSystem],name:"colorMask"};class ou{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:u,start:l,instanceCount:h}=t;e.shader.bind(i,o),e.geometry.bind(s,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,u,l,h!=null?h:s.instanceCount)}destroy(){this._renderer=null}}ou.extension={type:[v.WebGLSystem],name:"encoder"};class h_{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const ne=[];ne[it.NONE]=void 0,ne[it.DISABLED]={stencilWriteMask:0,stencilReadMask:0},ne[it.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},ne[it.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},ne[it.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};class au{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:it.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this._stencilCache.enabled=!1,this._stencilCache.stencilMode=it.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:it.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=ne[t],o=this._stencilCache;if(s.stencilMode=t,s.stencilReference=e,t===it.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,i.disable(i.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,i.enable(i.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}au.extension={type:[v.WebGLSystem],name:"stencil"};class uu{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!la())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 yt({data:new Float32Array(e.layout.size/4),usage:H.UNIFORM|H.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);return t.buffer||(t.buffer=new yt({data:new Float32Array(i.layout.size/4),usage:H.UNIFORM|H.COPY_DST})),e||(e=t.buffer.data),s||(s=0),i.syncFunction(t.uniforms,e,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 lu={f32:4,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function c_(r){const t=r.map(n=>({data:n,offset:0,size:0}));let e=0,s=0,i=0;for(let n=0;n1&&(e=Math.max(e,16)*o.data.size),o.size=e,s%e!==0&&s<16){const a=s%e%16;s+=a,i+=a}s+e>16?(i=Math.ceil(i/16)*16,o.offset=i,i+=e,s=e):(o.offset=i,s+=e,i+=e)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}const oe=[{type:"mat3x3",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 hu(r,t,e,s){const i=[` var v = null; var v2 = null; var t = 0; var index = 0; var name = null; var arrayOffset = null; `];let n=0;for(let a=0;a1)c=u.offset/4,i.push(e(u,c-n));else{const d=s[u.data.type];c=u.offset/4,i.push(` v = uv.${l}; offset += ${c-n}; ${d}; `)}n=c}const o=i.join(` `);return new Function("uv","data","offset",o)}var QE=Object.defineProperty,JE=Object.defineProperties,tA=Object.getOwnPropertyDescriptors,d_=Object.getOwnPropertySymbols,eA=Object.prototype.hasOwnProperty,rA=Object.prototype.propertyIsEnumerable,p_=(r,t,e)=>t in r?QE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sA=(r,t)=>{for(var e in t||(t={}))eA.call(t,e)&&p_(r,e,t[e]);if(d_)for(var e of d_(t))rA.call(t,e)&&p_(r,e,t[e]);return r},iA=(r,t)=>JE(r,tA(t));function Qe(r,t){return` for (let i = 0; i < ${r*t}; i++) { data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i]; } `}const cu={f32:` data[offset] = v;`,i32:` data[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];`,"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":Qe(3,2),"mat4x2":Qe(4,2),"mat2x3":Qe(2,3),"mat4x3":Qe(4,3),"mat2x4":Qe(2,4),"mat3x4":Qe(3,4)},f_=iA(sA({},cu),{"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3]; `});function m_(r,t){const e=Math.max(lu[r.data.type]/16,1),s=r.data.value.length/r.data.size,i=(4-s%4)%4;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++) { data[arrayOffset++] = v[t++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function g_(r){return hu(r,"uboStd40",m_,cu)}class du extends uu{constructor(){super({createUboElements:c_,generateUboSync:g_})}}du.extension={type:[v.WebGLSystem],name:"ubo"};class __{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new V}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new V}copyToTexture(t,e,s,i,n){const o=this._renderTargetSystem,a=this._renderer,u=o.getGpuRenderTarget(t),l=a.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,u.resolveTargetFramebuffer),a.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,n.x,n.y,s.x,s.y,i.width,i.height),e}startRenderPass(t,e=!0,s,i){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let u=i.y;t.isRoot&&(u=o.pixelHeight-i.height),t.colorTextures.forEach(c=>{this._renderer.texture.unbind(c)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,a.framebuffer);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)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,s)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)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)}initGpuRenderTarget(t){const e=this._renderer.gl,s=new h_,i=t.colorTexture;return Yt.test(i.resource)?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),s.framebuffer=null,s):(this._initColor(t,s),e.bindFramebuffer(e.FRAMEBUFFER,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=null}clear(t,e,s){if(!e)return;const i=this._renderTargetSystem;typeof e=="boolean"&&(e=e?gt.ALL:gt.NONE);const n=this._renderer.gl;if(e>.COLOR){s!=null||(s=i.defaultClearColor);const o=this._clearColorCache,a=s;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const s=this._renderer,i=s.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const u=o.source;u.antialias&&(s.context.supports.msaa?e.msaa=!0:ee("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),s.texture.bindSource(u,0);const l=s.texture.getGlSource(u).texture;i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,3553,l,0)}),e.msaa){const o=i.createFramebuffer();e.framebuffer=o,i.bindFramebuffer(i.FRAMEBUFFER,o),t.colorTextures.forEach((a,u)=>{const l=i.createRenderbuffer();e.msaaRenderBuffer[u]=l})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const s=t.colorTexture.source;if(e.width=s.pixelWidth,e.height=s.pixelHeight,t.colorTextures.forEach((i,n)=>{n!==0&&i.source.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.colorTextures.forEach((a,u)=>{const l=a.source;i.texture.bindSource(l,0);const h=i.texture.getGlSource(l).internalFormat,c=e.msaaRenderBuffer[u];n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,h,l.pixelWidth,l.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+u,n.RENDERBUFFER,c)})}}_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)}postrender(t){if(this._renderer.context.multiView&&Yt.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,s=t.colorTexture;s.context2D.drawImage(e,0,s.pixelHeight-e.height)}}}function b_(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}var nA=Object.defineProperty,x_=Object.getOwnPropertySymbols,oA=Object.prototype.hasOwnProperty,aA=Object.prototype.propertyIsEnumerable,v_=(r,t,e)=>t in r?nA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uA=(r,t)=>{for(var e in t||(t={}))oA.call(t,e)&&v_(r,e,t[e]);if(x_)for(var e of x_(t))aA.call(t,e)&&v_(r,e,t[e]);return r};const Je=new Map;function pu(r,t){if(!Je.has(r)){const e=new A({source:new Yt(uA({resource:r},t))}),s=()=>{Je.get(r)===e&&Je.delete(r)};e.once("destroy",s),e.source.once("destroy",s),Je.set(r,e)}return Je.get(r)}function lA(r){return Je.has(r)}function y_(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var hA=Object.defineProperty,T_=Object.getOwnPropertySymbols,cA=Object.prototype.hasOwnProperty,dA=Object.prototype.propertyIsEnumerable,S_=(r,t,e)=>t in r?hA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,E_=(r,t)=>{for(var e in t||(t={}))cA.call(t,e)&&S_(r,e,t[e]);if(T_)for(var e of T_(t))dA.call(t,e)&&S_(r,e,t[e]);return r};const A_=class Qx{constructor(t={}){if(this.uid=Z("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=E_(E_({},Qx.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;es.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof A||t.depthStencilTexture instanceof tt?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new tt({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,s=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(t,e,s)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,s)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};A_.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Bi=A_;class fu{constructor(t){this.rootViewPort=new V,this.viewport=new V,this.onRenderTargetChange=new ha("onRenderTargetChange"),this.projectionMatrix=new C,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:s,frame:i}){this._renderTargetStack.length=0,this.push(t,e,s,i),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=y_(this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,s,i){const n=this.getRenderTarget(t),o=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const a=this.getGpuRenderTarget(n);(n.pixelWidth!==a.width||n.pixelHeight!==a.height)&&(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight);const u=n.colorTexture,l=this.viewport,h=u.pixelWidth,c=u.pixelHeight;if(!i&&t instanceof A&&(i=t.frame),i){const d=u._resolution;l.x=i.x*d+.5|0,l.y=i.y*d+.5|0,l.width=i.width*d+.5|0,l.height=i.height*d+.5|0}else l.x=0,l.y=0,l.width=h,l.height=c;return b_(this.projectionMatrix,0,0,l.width/u.resolution,l.height/u.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,s,l),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=gt.ALL,s){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,s,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=gt.ALL,s,i){const n=this.bind(t,e,s,i);return this._renderTargetStack.push({renderTarget:n,frame:i}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,s,i,n){s.x<0&&(i.width+=s.x,n.x-=s.x,s.x=0),s.y<0&&(i.height+=s.y,n.y-=s.y,s.y=0);const{pixelWidth:o,pixelHeight:a}=t;return i.width=Math.min(i.width,o-s.x),i.height=Math.min(i.height,a-s.y),this.adaptor.copyToTexture(t,e,s,i,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Yt.test(t)&&(t=pu(t).source),t instanceof Bi?e=t:t instanceof tt&&(e=new Bi({colorTextures:[t]}),Yt.test(t.source.resource)&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const s=this._gpuRenderTargetHash[e.uid];s&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(s))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}}class mu extends fu{constructor(t){super(t),this.adaptor=new __,this.adaptor.init(t,this)}}mu.extension={type:[v.WebGLSystem],name:"renderTarget"};class Fi extends pt{constructor({buffer:t,offset:e,size:s}){super(),this.uid=Z("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Z("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Z("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}function w_(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,o=0;const a=t._getProgramData(r.glProgram);for(const l in r.groups){const h=r.groups[l];e.push(` resources = g[${l}].resources; `);for(const c in h.resources){const d=h.resources[c];if(d instanceof rt)d.ubo?e.push(` sS.bindUniformBlock( resources[${c}], sS._uniformBindMap[${l}[${c}], ${n++} ); `):e.push(` ugS.updateUniformGroup(resources[${c}], p, sD); `);else if(d instanceof Fi)e.push(` sS.bindUniformBlock( resources[${c}], sS._uniformBindMap[${l}[${c}], ${n++} ); `);else if(d instanceof tt){const p=r._uniformBindMap[l][c],f=a.uniformData[p];f&&(i||(i=!0,s.push(` var tS = r.texture; `)),t._gl.uniform1i(f.location,o),e.push(` tS.bind(resources[${c}], ${o}); `),o++)}}}const u=[...s,...e].join(` `);return new Function("r","s","sD",u)}class pA{}class P_{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 gu(r,t,e){const s=r.createShader(t);return r.shaderSource(s,e),r.compileShader(s),s}function _u(r){const t=new Array(r);for(let e=0;eo>a?1:-1);for(let o=0;o`${h}: ${l}`),s=r.getShaderInfoLog(t),i=s.split(` `),n={},o=i.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const u=e.join(` `);a[0]=u,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function B_(r,t,e,s){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||I_(r,e),r.getShaderParameter(s,r.COMPILE_STATUS)||I_(r,s),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function F_(r,t){const e=gu(r,r.VERTEX_SHADER,t.vertex),s=gu(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)||B_(r,i,e,s),t._attributeData=O_(i,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=G_(i,r),t._uniformBlockData=C_(i,r),r.deleteShader(e),r.deleteShader(s);const o={};for(const a in t._uniformData){const u=t._uniformData[a];o[a]={location:r.getUniformLocation(i,a),value:bu(u.type,u.size)}}return new P_(i,o)}const Ui={textureCount:0,blockIndex:0};class vu{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._maxBindings=t.MAX_UNIFORM_BUFFER_BINDINGS?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null,this.maxTextures=ye()}bind(t,e){if(this._setProgram(t.glProgram),e)return;Ui.textureCount=0,Ui.blockIndex=0;let s=this._shaderSyncFunctions[t.glProgram._key];s||(s=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),s(this._renderer,t,Ui)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Ui)}bindUniformBlock(t,e,s=0){const i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o&&this._renderer.ubo.updateUniformGroup(t),i.updateBuffer(t.buffer);let a=this._boundUniformsIdsToIndexHash[t.uid];if(a===void 0){const h=this._nextIndex++%this._maxBindings,c=this._boundIndexToUniformsHash[h];c&&(this._boundUniformsIdsToIndexHash[c.uid]=void 0),a=this._boundUniformsIdsToIndexHash[t.uid]=h,this._boundIndexToUniformsHash[h]=t,o?i.bindBufferRange(t.buffer,h,t.offset):i.bindBufferBase(t.buffer,h)}const u=this._gl,l=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[s]!==a&&(n.uniformBlockBindings[s]=a,u.uniformBlockBinding(n.program,l,a))}_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]=F_(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(t,e){return w_(t,e)}}vu.extension={type:[v.WebGLSystem],name:"shader"};const D_={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);"},U_={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 k_(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 rt?r.uniforms[s].ubo?e.push(` renderer.shader.bindUniformBlock(uv.${s}, "${s}"); `):e.push(` renderer.shader.updateUniformGroup(uv.${s}); `):r.uniforms[s]instanceof Fi&&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),i=Math.max(i>>1,1)}}},Tu={id:"image",upload(r,t,e,s){const i=r.alphaMode==="premultiply-alpha-on-upload";e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i);const n=t.width,o=t.height,a=r.pixelWidth,u=r.pixelHeight,l=r.resourceWidth,h=r.resourceHeight;l1){const l=Math.min(r.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](u,s.TEXTURE_MAX_ANISOTROPY_EXT,l)}r.compare&&t[i](u,t.TEXTURE_COMPARE_FUNC,W_[r.compare])}function Y_(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 AA=Object.defineProperty,wA=Object.defineProperties,PA=Object.getOwnPropertyDescriptors,K_=Object.getOwnPropertySymbols,RA=Object.prototype.hasOwnProperty,MA=Object.prototype.propertyIsEnumerable,q_=(r,t,e)=>t in r?AA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pe=(r,t)=>{for(var e in t||(t={}))RA.call(t,e)&&q_(r,e,t[e]);if(K_)for(var e of K_(t))MA.call(t,e)&&q_(r,e,t[e]);return r},OA=(r,t)=>wA(r,PA(t));function Z_(r,t){let e={},s=r.RGBA;return r instanceof k.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),Pe(Pe(Pe(Pe(Pe(Pe(OA(Pe({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 Q_(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 CA(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",s.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,s=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,s,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const s=this.getGlSource(t);this._gl.generateMipmap(s.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,Eu(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 this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:s,height:i}=this.getPixels(t),n=k.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(GA*i*n),a=this._renderer,u=a.renderTarget.getRenderTarget(t),l=a.renderTarget.getGpuRenderTarget(u),h=a.gl;return h.bindFramebuffer(h.FRAMEBUFFER,l.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.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._renderer=null}}Au.extension={type:[v.WebGLSystem],name:"texture"};class wu{init(){const t=new rt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new C,type:"mat3x3"},uRound:{value:0,type:"f32"}}),e=ye(),s=$e({name:"graphics",bits:[Cs,Is(e),ri,Ne]});this.shader=new Ct({glProgram:s,resources:{localUniforms:t,batchSamplers:Bs(e)}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:u}=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 l=u.instructions;for(let h=0;h",value:new C}}}})}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}}Pu.extension={type:[v.WebGLPipesAdaptor],name:"mesh"};class Ru{constructor(t){this._renderer=t}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}Ru.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"customRender"};function Mu(r,t){const e=r.instructionSet,s=e.instructions;for(let i=0;i>16&255,i=r>>8&255,n=r&255,o=t>>16&255,a=t>>8&255,u=t&255,l=s+(o-s)*e,h=i+(a-i)*e,c=n+(u-n)*e;return(l<<16)+(h<<8)+c}const tr=16777215;function Iu(r,t){return r===tr||t===tr?r+t-tr:Gu(r,t,.5)}function IA(r,t,e){const s=(e>>24&255)/255,i=t*s*255,n=((r&255)<<16)+(r&65280)+(r>>16&255),o=e&16777215;let a;return n===tr||o===tr?a=n+o-tr:a=Gu(n,o,.5),a+(i<<24)}const BA=new Q,J_=Oe|mr|ms;function Bu(r,t=!1){tb(r);const e=r.childrenToUpdate,s=r.updateTick++;for(const i in e){const n=Number(i),o=e[i],a=o.list,u=o.index;for(let l=0;l1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function Fu(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=e|r._updateFlags,r.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),e&J_&&eb(r,i,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(s),e&J_&&eb(r,BA,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&ms&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&Oe&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function rb(r,t){const{list:e,index:s}=r.childrenRenderablesToUpdate;let i=!1;for(let n=0;nt in r?UA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nb=(r,t)=>{for(var e in t||(t={}))kA.call(t,e)&&ib(r,e,t[e]);if(sb)for(var e of sb(t))$A.call(t,e)&&ib(r,e,t[e]);return r};const ku=class Jx{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new z(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=nb(nb({},Jx.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(){}};ku.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"background",priority:0},ku.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let ob=ku;const ts={};D.handle(v.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");ts[r.name]=r.ref},r=>{delete ts[r.name]});class $u{constructor(t){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t}setBlendMode(t,e,s){if(this._activeBlendMode===e){this._isAdvanced&&this._renderableList.push(t);return}this._activeBlendMode=e,this._isAdvanced&&this._endAdvancedBlendMode(s),this._isAdvanced=!!ts[e],this._isAdvanced&&(this._beginAdvancedBlendMode(s),this._renderableList.push(t))}_beginAdvancedBlendMode(t){this._renderer.renderPipes.batch.break(t);const e=this._activeBlendMode;if(!ts[e])return;let s=this._filterHash[e];s||(s=this._filterHash[e]=new dr,s.filters=[new ts[e]]);const i={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:s,canBundle:!1};this._renderableList=i.renderables,t.add(i)}_endAdvancedBlendMode(t){this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}$u.extension={type:[v.WebGLPipes,v.WebGPUPipes,v.CanvasPipes],name:"blendMode"};var LA=Object.defineProperty,ab=Object.getOwnPropertySymbols,NA=Object.prototype.hasOwnProperty,XA=Object.prototype.propertyIsEnumerable,ub=(r,t,e)=>t in r?LA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lu=(r,t)=>{for(var e in t||(t={}))NA.call(t,e)&&ub(r,e,t[e]);if(ab)for(var e of ab(t))XA.call(t,e)&&ub(r,e,t[e]);return r};const Nu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Xu=class tv{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Q||t instanceof A?Lu({target:t},e):Lu(Lu({},e),t)}async image(t){const e=new Image;return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,tv.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 u=new FileReader;u.onload=()=>n(u.result),u.onerror=o,u.readAsDataURL(a)},Nu[e],s)});if(i.toDataURL!==void 0)return i.toDataURL(Nu[e],s);if(i.convertToBlob!==void 0){const n=await i.convertToBlob({type:Nu[e],quality:s});return new Promise((o,a)=>{const u=new FileReader;u.onload=()=>o(u.result),u.onerror=a,u.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 A)return s.texture.generateCanvas(e);const i=s.textureGenerator.generateTexture(t),n=s.texture.generateCanvas(i);return i.destroy(),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,s=this._renderer,i=e instanceof A?e:s.textureGenerator.generateTexture(t),n=s.texture.getPixels(i);return e instanceof Q&&i.destroy(),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof A?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}};Xu.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"extract"},Xu.defaultImageOptions={format:"png",quality:1};let lb=Xu;class tn extends A{static create(t){return new tn({source:new tt(t)})}resize(t,e,s){return this.source.resize(t,e,s),this}}var HA=Object.defineProperty,jA=Object.defineProperties,zA=Object.getOwnPropertyDescriptors,hb=Object.getOwnPropertySymbols,VA=Object.prototype.hasOwnProperty,WA=Object.prototype.propertyIsEnumerable,cb=(r,t,e)=>t in r?HA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,YA=(r,t)=>{for(var e in t||(t={}))VA.call(t,e)&&cb(r,e,t[e]);if(hb)for(var e of hb(t))WA.call(t,e)&&cb(r,e,t[e]);return r},KA=(r,t)=>jA(r,zA(t));const qA=new V,ZA=new ht,QA=[0,0,0,0];class Hu{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof Q&&(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:z.shared.setValue(o).toArray():o=QA;const a=((e=t.frame)==null?void 0:e.copyTo(qA))||fs(n,ZA).rectangle;a.width=Math.max(a.width,1/s)|0,a.height=Math.max(a.height,1/s)|0;const u=tn.create(KA(YA({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:s,antialias:i})),l=C.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:l,target:u,clearColor:o}),u.source.updateMipmaps(),u}destroy(){this._renderer=null}}Hu.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGenerator"};class ju{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 C,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{isStatic:!0})}destroy(){this._renderer=null}}ju.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"globalUniforms"};let JA=1;class zu{constructor(){this._tasks=[]}init(){ut.system.add(this._update,this)}repeat(t,e){const s=JA++;return this._tasks.push({func:t,duration:e,start:performance.now(),last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e=s.duration){const i=t-s.start;s.func(i),s.last=t}}}destroy(){ut.system.remove(this._update,this),this._tasks.length=0}}zu.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"scheduler",priority:0};let db=!1;function pb(r){if(!db){if(k.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${jr} (${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 ${jr} - ${r} - http://www.pixijs.com/`);db=!0}}class Li{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}`),pb(e)}}}Li.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"hello",priority:-2},Li.defaultOptions={hello:!1};var tw=Object.defineProperty,fb=Object.getOwnPropertySymbols,ew=Object.prototype.hasOwnProperty,rw=Object.prototype.propertyIsEnumerable,mb=(r,t,e)=>t in r?tw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gb=(r,t)=>{for(var e in t||(t={}))ew.call(t,e)&&mb(r,e,t[e]);if(fb)for(var e of fb(t))rw.call(t,e)&&mb(r,e,t[e]);return r};const Vu=class ev{constructor(t){this._managedRenderables=[],this._renderer=t}init(t){t=gb(gb({},ev.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency):this._renderer.scheduler.cancel(this._handler))}prerender(){this._now=performance.now()}addRenderable(t,e){this.enabled&&(t._lastUsed=this._now,t._lastInstructionTick===-1&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastInstructionTick=e.tick)}run(){var t,e,s;const i=performance.now(),n=this._managedRenderables,o=this._renderer.renderPipes;let a=0;for(let u=0;uthis.maxUnusedTime?(l.destroyed||o[l.renderPipeId].destroyRenderable(l),l._lastInstructionTick=-1,a++,l.off("destroyed",this._removeRenderable,this)):n[u-a]=l}n.length=n.length-a}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}};Vu.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"renderableGC"},Vu.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let _b=Vu;var sw=Object.defineProperty,bb=Object.getOwnPropertySymbols,iw=Object.prototype.hasOwnProperty,nw=Object.prototype.propertyIsEnumerable,xb=(r,t,e)=>t in r?sw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vb=(r,t)=>{for(var e in t||(t={}))iw.call(t,e)&&xb(r,e,t[e]);if(bb)for(var e of bb(t))nw.call(t,e)&&xb(r,e,t[e]);return r};const Wu=class rv{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){var e;t=vb(vb({},rv.defaultOptions),t),this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=(e=t.textureGCAMaxIdle)!=null?e:t.textureGCMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e-1&&this.count-s._touched>this.maxIdle&&(s._touched=-1,s.unload())}}destroy(){this._renderer=null}};Wu.extension={type:[v.WebGLSystem,v.WebGPUSystem],name:"textureGC"},Wu.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:60*60,textureGCCheckCountMax:600};let yb=Wu;var ow=Object.defineProperty,Tb=Object.getOwnPropertySymbols,aw=Object.prototype.hasOwnProperty,uw=Object.prototype.propertyIsEnumerable,Sb=(r,t,e)=>t in r?ow(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Eb=(r,t)=>{for(var e in t||(t={}))aw.call(t,e)&&Sb(r,e,t[e]);if(Tb)for(var e of Tb(t))uw.call(t,e)&&Sb(r,e,t[e]);return r};const Yu=class sv{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(t){t=Eb(Eb({},sv.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new V(0,0,t.width,t.height),this.canvas=t.canvas||k.get().createCanvas(),this.antialias=!!t.antialias,this.texture=pu(this.canvas,t),this.renderTarget=new Bi({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}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)}};Yu.extension={type:[v.WebGLSystem,v.WebGPUSystem,v.CanvasSystem],name:"view",priority:0},Yu.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Ab=Yu;const Ku=[ob,ju,Li,Ab,Du,yb,Hu,lb,fa,_b,zu],qu=[$u,Ka,Uu,Ou,qa,Qa,Za,Ru],lw=[...Ku,du,l_,r_,Ja,Au,mu,su,yu,vu,ou,N_,au,nu],hw=[...qu],cw=[Va,Pu,wu],wb=[],Pb=[],Rb=[];D.handleByNamedList(v.WebGLSystem,wb),D.handleByNamedList(v.WebGLPipes,Pb),D.handleByNamedList(v.WebGLPipesAdaptor,Rb),D.add(...lw,...hw,...cw);class Mb extends Lr{constructor(){const t={name:"webgl",type:mt.WEBGL,systems:wb,renderPipes:Pb,renderPipeAdaptors:Rb};super(t)}}var dw={__proto__:null,WebGLRenderer:Mb};class Zu{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,s){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,s)}_createBindGroup(t,e,s){var i;const n=this._gpu.device,o=e.layout[s],a=[],u=this._renderer;for(const c in o){const d=(i=t.resources[c])!=null?i:t.resources[o[c]];let p;if(d._resourceType==="uniformGroup"){const f=d;u.ubo.updateUniformGroup(f);const g=f.buffer;p={buffer:u.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(d._resourceType==="buffer"){const f=d;p={buffer:u.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(d._resourceType==="bufferResource"){const f=d;p={buffer:u.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(d._resourceType==="textureSampler"){const f=d;p=u.texture.getGpuSampler(f)}else if(d._resourceType==="textureSource"){const f=d;p=u.texture.getGpuSource(f).createView({})}a.push({binding:o[c],resource:p})}const l=u.shader.getProgramData(e).bindGroups[s],h=n.createBindGroup({layout:l,entries:a});return this._hash[t._key]=h,h}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}Zu.extension={type:[v.WebGPUSystem],name:"bindGroup"};class Qu{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),s=t.data;return t._updateID&&s&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,s.buffer,0,(t._updateSize||s.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(Ps(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}Qu.extension={type:[v.WebGPUSystem],name:"buffer"};function pw(r,t){const e=r.descriptor.size,s=t.gpu.device,i=new yt({data:new Float32Array(24e5),usage:H.MAP_READ|H.COPY_DST}),n=t.buffer.createGPUBuffer(i),o=s.createCommandEncoder();o.copyBufferToBuffer(t.buffer.getGPUBuffer(r),0,n,0,e),s.queue.submit([o.finish()]),n.mapAsync(GPUMapMode.READ,0,e).then(()=>{n.getMappedRange(0,e),n.unmap()})}class Ob{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;s{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await k.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),s=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),i=await e.requestDevice({requiredFeatures:s});return{adapter:e,device:i}}destroy(){this.gpu=null,this._renderer=null}}Ni.extension={type:[v.WebGPUSystem],name:"device"},Ni.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var fw=Object.defineProperty,Cb=Object.getOwnPropertySymbols,mw=Object.prototype.hasOwnProperty,gw=Object.prototype.propertyIsEnumerable,Gb=(r,t,e)=>t in r?fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ib=(r,t)=>{for(var e in t||(t={}))mw.call(t,e)&&Gb(r,e,t[e]);if(Cb)for(var e of Cb(t))gw.call(t,e)&&Gb(r,e,t[e]);return r};class tl{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,s,i){const n=this._renderer.pipeline.getPipeline(t,e,s,i);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,s){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const i=this._renderer.bindGroup.getBindGroup(e,s,t);this.renderPassEncoder.setBindGroup(t,i)}setGeometry(t,e){const s=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const i in s)this._setVertexBuffer(i,t.attributes[s[i]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const s in t.groups){const i=t.groups[s];e||this._syncBindGroup(i),this.setBindGroup(s,i,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const s=t.resources[e];s.isUniformGroup&&this._renderer.ubo.updateUniformGroup(s)}}draw(t){const{geometry:e,shader:s,state:i,topology:n,size:o,start:a,instanceCount:u,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,s.gpuProgram,i,n),this.setGeometry(e,s.gpuProgram),this._setShaderBindGroups(s,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,u||e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),u||e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,s=Ib({},this._boundVertexBuffer),i=this._boundIndexBuffer,n=Ib({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in s)this._setVertexBuffer(a,s[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(i)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}tl.extension={type:[v.WebGPUSystem],name:"encoder",priority:1};class el{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:it.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const s=this._renderTargetStencilState[this._activeRenderTarget.uid];s.stencilMode=t,s.stencilReference=e;const i=this._renderer;i.pipeline.setStencilMode(t),i.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}el.extension={type:[v.WebGPUSystem],name:"stencil"};const es={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 Bb(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 Fb(r,t){const{size:e,align:s}=es[r.data.type],i=(s-e)/4;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++) { data[arrayOffset++] = v[t++]; } ${i!==0?`arrayOffset += ${i};`:""} } `}function Db(r){return hu(r,"uboWgsl",Fb,f_)}class rl extends uu{constructor(){super({createUboElements:Bb,generateUboSync:Db})}}rl.extension={type:[v.WebGPUSystem],name:"ubo"};const ae=128;class sl{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new Ob({minUniformOffsetAlignment:ae});const e=256/ae;for(let s=0;st in r?_w(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tw=(r,t)=>{for(var e in t||(t={}))vw.call(t,e)&&kb(r,e,t[e]);if(Ub)for(var e of Ub(t))yw.call(t,e)&&kb(r,e,t[e]);return r},Sw=(r,t)=>bw(r,xw(t));const Ew={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function Aw(r,t,e,s,i){return r<<24|t<<16|e<<10|s<<5|i}function ww(r,t,e,s){return e<<6|r<<3|s<<1|t}class il{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(it.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=ne[t],this._updatePipeHash())}setPipeline(t,e,s,i){const n=this.getPipeline(t,e,s);i.setPipeline(n)}getPipeline(t,e,s,i){t._layoutKey||(eu(t,e.attributeData),this._generateBufferKey(t)),i=i||t.topology;const n=Aw(t._layoutKey,e._layoutKey,s.data,s._blendModeId,Ew[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,s,i),this._pipeCache[n])}_createPipeline(t,e,s,i){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(s);a[0].writeMask=this._stencilMode===it.RENDERING_MASK_ADD?0:this._colorMask;const u=this._renderer.shader.getProgramData(e).pipeline,l={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:i,cullMode:s.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(l.depthStencil=Sw(Tw({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:s.depthTest,depthCompare:s.depthTest?"less":"always"})),n.createRenderPipeline(l)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let s=0;const i=Object.keys(t.attributes).sort();for(let o=0;o{var o;const a={arrayStride:0,stepMode:"vertex",attributes:[]},u=a.attributes;for(const l in e.attributeData){const h=t.attributes[l];((o=h.divisor)!=null?o:1)!==1&&ee(`Attribute ${l} 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",u.push({shaderLocation:e.attributeData[l].location,offset:h.offset,format:h.format}))}u.length&&i.push(a)}),this._bufferLayoutsCache[s]=i,i}_updatePipeHash(){const t=ww(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}il.extension={type:[v.WebGPUSystem],name:"pipeline"};class $b{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class Lb{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,s,i,n){const o=this._renderer,a=this._getGpuColorTexture(t),u=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:s},{texture:u,origin:n},i),e}startRenderPass(t,e=!0,s,i){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,s);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(i)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,s){typeof e=="boolean"&&(e=e?gt.ALL:gt.NONE);const i=this._renderTargetSystem,n=i.getGpuRenderTarget(t),o=t.colorTextures.map((u,l)=>{const h=n.contexts[l];let c,d;h?c=h.getCurrentTexture().createView():c=this._renderer.texture.getGpuSource(u).createView({mipLevelCount:1}),n.msaaTextures[l]&&(d=c,c=this._renderer.texture.getTextureView(n.msaaTextures[l]));const p=e>.COLOR?"clear":"load";return s!=null||(s=i.defaultClearColor),{view:c,resolveTarget:d,clearValue:s,storeOp:"store",loadOp:p}});let a;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const u=e>.STENCIL?"clear":"load",l=e>.DEPTH?"clear":"load";a={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:u,depthClearValue:1,depthLoadOp:l,depthStoreOp:"store"}}return{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,s,i){if(!e)return;const{gpu:n,encoder:o}=this._renderer,a=n.device;if(o.commandEncoder===null){const u=a.createCommandEncoder(),l=this.getDescriptor(t,e,s),h=u.beginRenderPass(l);h.setViewport(i.x,i.y,i.width,i.height,0,1),h.end();const c=u.finish();a.queue.submit([c])}else this.startRenderPass(t,e,s,i)}initGpuRenderTarget(t){t.isRoot=!0;const e=new $b;return t.colorTextures.forEach((s,i)=>{if(Yt.test(s.resource)){const n=s.resource.getContext("webgpu"),o=s.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[i]=n}if(e.msaa=s.source.antialias,s.source.antialias){const n=new tt({width:0,height:0,sampleCount:4});e.msaaTextures[i]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((s,i)=>{const n=e.msaaTextures[i];n==null||n.resize(s.source.width,s.source.height,s.source._resolution)})}}class nl extends fu{constructor(t){super(t),this.adaptor=new Lb,this.adaptor.init(t,this)}}nl.extension={type:[v.WebGPUSystem],name:"renderTarget"};class ol{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t,this.maxTextures=t.device.limits.maxSampledTexturesPerShaderStage}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}}ol.extension={type:[v.WebGPUSystem],name:"shader"};const dt={};dt.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},dt.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},dt.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},dt.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},dt.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},dt.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},dt["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},dt["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},dt["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},dt.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},dt.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},dt.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class al{constructor(){this.defaultState=new It,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:dt[t.blendMode]||dt.normal}]}destroy(){this.gpu=null}}al.extension={type:[v.WebGPUSystem],name:"state"};const Nb={type:"image",upload(r,t,e){const s=r.resource,i=(r.pixelWidth|0)*(r.pixelHeight|0),n=s.byteLength/i;e.device.queue.writeTexture({texture:t},s,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelHeight*n},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},ul={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},Pw={blockBytes:4,blockWidth:1,blockHeight:1},Xb={type:"compressed",upload(r,t,e){let s=r.pixelWidth,i=r.pixelHeight;const n=ul[r.format]||Pw;for(let o=0;o>1,1),i=Math.max(i>>1,1)}}},ll={type:"image",upload(r,t,e){const s=r.resource;if(!s)return;const i=Math.min(t.width,r.resourceWidth||r.pixelWidth),n=Math.min(t.height,r.resourceHeight||r.pixelHeight),o=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:s},{texture:t,premultipliedAlpha:o},{width:i,height:n})}},Hb={type:"video",upload(r,t,e){ll.upload(r,t,e)}};class jb{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:` var 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 u={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(u)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let u=0;u1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new jb(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){var e;return(e=this._bindGroupHash[t.uid])!=null?e:this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Nt({0:e,1:e.style,2:new rt({uTextureMatrix:{type:"mat3x3",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var e;const s=t.source;return(e=this._textureViewHash[s.uid])!=null?e:this._createTextureView(s)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,s=e.gpu.device.createCommandEncoder(),i=k.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:k.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=Xt.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),u=new Uint8ClampedArray(a.data.buffer);return Xt.returnCanvasAndContext(s),{pixels:u,width:n,height:o}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),s=this._bindGroupHash[e];s==null||s.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}hl.extension={type:[v.WebGPUSystem],name:"texture"};class cl{init(){const t=new rt({uTransformMatrix:{value:new C,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),e=ke({name:"graphics",bits:[Os,Gs(ye()),ef,Le]});this.shader=new Ct({gpuProgram:e,resources:{localUniforms:t}})}execute(t,e){const s=e.context,i=s.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:u}=o.getContextRenderData(s),l=n.encoder;l.setPipelineFromGeometryProgramAndState(a.geometry,i.gpuProgram,t.state),l.setGeometry(a.geometry,i.gpuProgram);const h=n.globalUniforms.bindGroup;l.setBindGroup(0,h,i.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);l.setBindGroup(2,c,i.gpuProgram);const d=u.instructions;for(let p=0;p",value:new C}}}})}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(!0),this._shader=null}}dl.extension={type:[v.WebGPUPipesAdaptor],name:"mesh"};const Rw=[...Ku,rl,tl,Ni,Qu,hl,nl,ol,al,il,Ju,el,Zu],Mw=[...qu,sl],Ow=[Wa,dl,cl],zb=[],Vb=[],Wb=[];D.handleByNamedList(v.WebGPUSystem,zb),D.handleByNamedList(v.WebGPUPipes,Vb),D.handleByNamedList(v.WebGPUPipesAdaptor,Wb),D.add(...Rw,...Mw,...Ow);class Yb extends Lr{constructor(){const t={name:"webgpu",type:mt.WEBGPU,systems:zb,renderPipes:Vb,renderPipeAdaptors:Wb};super(t)}}var Cw={__proto__:null,WebGPURenderer:Yb};const Gw={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},Iw=new Proxy(Gw,{get(r,t){return r[t]}}),Bw=new V(0,0,1,1);function Fw(r,t,e){e||(e=Bw);const s=t.pixelWidth,i=t.pixelHeight;return r.x=e.x*s|0,r.y=e.y*i|0,r.width=e.width*s|0,r.height=e.height*i|0,r}var Kb=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Kb||{}),pl=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(pl||{});const Dw=new Proxy(pl,{get(r,t){return r[t]}});var fl=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(fl||{});const Uw=new Proxy(fl,{get(r,t){return r[t]}});class kw{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,u=t.x/i+o,l=t.y/n+a;s=U.add(s,U.NW),this.x0=u+o*U.uX(s),this.y0=l+a*U.uY(s),s=U.add(s,2),this.x1=u+o*U.uX(s),this.y1=l+a*U.uY(s),s=U.add(s,2),this.x2=u+o*U.uX(s),this.y2=l+a*U.uY(s),s=U.add(s,2),this.x3=u+o*U.uX(s),this.y3=l+a*U.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}}let $w=0;function Lw(){return $w++}function Nw(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()}var Xw=Object.defineProperty,Xi=Object.getOwnPropertySymbols,qb=Object.prototype.hasOwnProperty,Zb=Object.prototype.propertyIsEnumerable,Qb=(r,t,e)=>t in r?Xw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hw=(r,t)=>{for(var e in t||(t={}))qb.call(t,e)&&Qb(r,e,t[e]);if(Xi)for(var e of Xi(t))Zb.call(t,e)&&Qb(r,e,t[e]);return r},jw=(r,t)=>{var e={};for(var s in r)qb.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Xi)for(var s of Xi(r))t.indexOf(s)<0&&Zb.call(r,s)&&(e[s]=r[s]);return e};class zw extends Q{constructor(t){var e,s;typeof t=="function"&&(t={render:t});const i=t,{render:n}=i,o=jw(i,["render"]);super(Hw({label:"RenderContainer"},o)),this.batched=!1,this._lastUsed=0,this._lastInstructionTick=-1,this.bounds=new ht,this.canBundle=!1,this.renderPipeId="customRender",n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:()=>!1,this.addBounds=(s=t.addBounds)!=null?s:()=>!1}render(t){}}function Vw(r,t){const e=t._scale,s=t._pivot,i=t._position,n=e._x,o=e._y,a=s._x,u=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+u*r.c),r.ty=i._y-(a*r.b+u*r.d)}function Ww(r,t,e){const s=r.a,i=r.b,n=r.c,o=r.d,a=r.tx,u=r.ty,l=t.a,h=t.b,c=t.c,d=t.d;e.a=s*l+i*c,e.b=s*h+i*d,e.c=n*l+o*c,e.d=n*h+o*d,e.tx=a*l+u*c+t.tx,e.ty=a*h+u*d+t.ty}const Yw={rectangle:co,polygon:ho,triangle:po,circle:Kt,ellipse:Kt,roundedRectangle:Kt};function Kw(r){r instanceof ue&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],s=[],i=r.path.shapePath,n=r.textureMatrix;i.shapePrimitives.forEach(({shape:a,transform:u})=>{const l=s.length,h=t.length/2,c=[],d=Yw[a.type];d.build(a,c),u&&Us(c,u),d.triangulate(c,t,2,h,s,l);const p=e.length/2;n?(u&&n.append(u.clone().invert()),so(t,2,h,e,p,2,t.length/2-h,n)):io(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 re({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(s)})}function Jb(r,t,e,s){const i=e.buffers[0],n=i.data,{verticesX:o,verticesY:a}=e,u=r/(o-1),l=t/(a-1);let h=0;const c=s[0],d=s[1],p=s[2],f=s[3],g=s[4],m=s[5],_=s[6],x=s[7],b=s[8];for(let y=0;yt in r?eP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ml=(r,t)=>{for(var e in t||(t={}))nx.call(t,e)&&ax(r,e,t[e]);if(ji)for(var e of ji(t))ox.call(t,e)&&ax(r,e,t[e]);return r},iP=(r,t)=>rP(r,sP(t)),nP=(r,t)=>{var e={};for(var s in r)nx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&ji)for(var s of ji(r))t.indexOf(s)<0&&ox.call(r,s)&&(e[s]=r[s]);return e};const ux=class iv extends Ze{constructor(t){t=ml(ml({},iv.defaultOptions),t);const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=nP(e,["texture","verticesX","verticesY"]),a=new ix(Lt({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(Lt(iP(ml({},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,u){this.geometry.setCorners(t,e,s,i,n,o,a,u)}};ux.defaultOptions={texture:A.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let oP=ux;var aP=Object.defineProperty,uP=Object.defineProperties,lP=Object.getOwnPropertyDescriptors,zi=Object.getOwnPropertySymbols,lx=Object.prototype.hasOwnProperty,hx=Object.prototype.propertyIsEnumerable,cx=(r,t,e)=>t in r?aP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hP=(r,t)=>{for(var e in t||(t={}))lx.call(t,e)&&cx(r,e,t[e]);if(zi)for(var e of zi(t))hx.call(t,e)&&cx(r,e,t[e]);return r},cP=(r,t)=>uP(r,lP(t)),dP=(r,t)=>{var e={};for(var s in r)lx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&zi)for(var s of zi(r))t.indexOf(s)<0&&hx.call(r,s)&&(e[s]=r[s]);return e};class pP extends Ze{constructor(t){const e=t,{texture:s,verticesX:i,verticesY:n}=e,o=dP(e,["texture","verticesX","verticesY"]),a=new ii(Lt({width:s.width,height:s.height,verticesX:i,verticesY:n}));super(Lt(cP(hP({},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 fP=Object.defineProperty,dx=Object.getOwnPropertySymbols,mP=Object.prototype.hasOwnProperty,gP=Object.prototype.propertyIsEnumerable,px=(r,t,e)=>t in r?fP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fx=(r,t)=>{for(var e in t||(t={}))mP.call(t,e)&&px(r,e,t[e]);if(dx)for(var e of dx(t))gP.call(t,e)&&px(r,e,t[e]);return r};const mx=class nv extends re{constructor(t){const{width:e,points:s,textureScale:i}=fx(fx({},nv.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,u=t[0];const l=this._width*this.textureScale,h=t.length;for(let d=0;d0){const f=u.x-t[d].x,g=u.y-t[d].y,m=Math.sqrt(f*f+g*g);u=t[d],a+=m/l}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 l=0;l1&&(d=1);const p=Math.sqrt(i*i+n*n);p<1e-6?(i=0,n=0):(i/=p,n/=p,i*=u,n*=u),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()}};mx.defaultOptions={width:200,points:[],textureScale:0};let gx=mx;var _P=Object.defineProperty,bP=Object.defineProperties,xP=Object.getOwnPropertyDescriptors,Vi=Object.getOwnPropertySymbols,_x=Object.prototype.hasOwnProperty,bx=Object.prototype.propertyIsEnumerable,xx=(r,t,e)=>t in r?_P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gl=(r,t)=>{for(var e in t||(t={}))_x.call(t,e)&&xx(r,e,t[e]);if(Vi)for(var e of Vi(t))bx.call(t,e)&&xx(r,e,t[e]);return r},vP=(r,t)=>bP(r,xP(t)),yP=(r,t)=>{var e={};for(var s in r)_x.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Vi)for(var s of Vi(r))t.indexOf(s)<0&&bx.call(r,s)&&(e[s]=r[s]);return e};const vx=class ov extends Ze{constructor(t){const e=gl(gl({},ov.defaultOptions),t),{texture:s,points:i,textureScale:n}=e,o=yP(e,["texture","points","textureScale"]),a=new gx(Lt({width:s.height,points:i,textureScale:n}));n>0&&(s.source.style.addressMode="repeat"),super(Lt(vP(gl({},o),{texture:s,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};vx.defaultOptions={textureScale:0};let TP=vx;var SP=Object.defineProperty,EP=Object.defineProperties,AP=Object.getOwnPropertyDescriptors,Wi=Object.getOwnPropertySymbols,yx=Object.prototype.hasOwnProperty,Tx=Object.prototype.propertyIsEnumerable,Sx=(r,t,e)=>t in r?SP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wP=(r,t)=>{for(var e in t||(t={}))yx.call(t,e)&&Sx(r,e,t[e]);if(Wi)for(var e of Wi(t))Tx.call(t,e)&&Sx(r,e,t[e]);return r},PP=(r,t)=>EP(r,AP(t)),RP=(r,t)=>{var e={};for(var s in r)yx.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Wi)for(var s of Wi(r))t.indexOf(s)<0&&Tx.call(r,s)&&(e[s]=r[s]);return e};class MP extends Ze{constructor(t){const e=t,{texture:s,vertices:i,uvs:n,indices:o,topology:a}=e,u=RP(e,["texture","vertices","uvs","indices","topology"]),l=new re(Lt({positions:i,uvs:n,indices:o,topology:a}));super(Lt(PP(wP({},u),{texture:s,geometry:l}))),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 OP(r,t){const{width:e,height:s}=r.frame;return t.scale(1/e,1/s),t}var CP=Object.defineProperty,Yi=Object.getOwnPropertySymbols,Ex=Object.prototype.hasOwnProperty,Ax=Object.prototype.propertyIsEnumerable,wx=(r,t,e)=>t in r?CP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GP=(r,t)=>{for(var e in t||(t={}))Ex.call(t,e)&&wx(r,e,t[e]);if(Yi)for(var e of Yi(t))Ax.call(t,e)&&wx(r,e,t[e]);return r},IP=(r,t)=>{var e={};for(var s in r)Ex.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&Yi)for(var s of Yi(r))t.indexOf(s)<0&&Ax.call(r,s)&&(e[s]=r[s]);return e};const Px=class av extends xe{constructor(t){var e,s,i,n,o,a,u,l,h,c;t instanceof A&&(t={texture:t});const d=t,{width:p,height:f,leftWidth:g,rightWidth:m,topHeight:_,bottomHeight:x,texture:b,roundPixels:y}=d,S=IP(d,["width","height","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(GP({label:"NineSliceSprite"},S)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=(s=g!=null?g:(e=b==null?void 0:b.defaultBorders)==null?void 0:e.left)!=null?s:se.defaultOptions.leftWidth,this._topHeight=(n=_!=null?_:(i=b==null?void 0:b.defaultBorders)==null?void 0:i.top)!=null?n:se.defaultOptions.topHeight,this._rightWidth=(a=m!=null?m:(o=b==null?void 0:b.defaultBorders)==null?void 0:o.right)!=null?a:se.defaultOptions.rightWidth,this._bottomHeight=(l=x!=null?x:(u=b==null?void 0:b.defaultBorders)==null?void 0:u.bottom)!=null?l:se.defaultOptions.bottomHeight,this.bounds.maxX=this._width=(h=p!=null?p:b.width)!=null?h:se.defaultOptions.width,this.bounds.maxY=this._height=(c=f!=null?f:b.height)!=null?c:se.defaultOptions.height,this.allowChildren=!1,this.texture=b!=null?b:av.defaultOptions.texture,this.roundPixels=y!=null?y:!1}get bounds(){return this._bounds}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=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.bounds.maxX=this._width=t,this.bounds.maxY=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=A.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}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}};Px.defaultOptions={texture:A.EMPTY};let Rx=Px;class BP extends Rx{constructor(...t){let e=t[0];e instanceof A&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}function FP(r,t){return t instanceof St||t instanceof Re?t:r==="html"?new Re(t):new St(t)}async function DP(r,t,e=200){const s=await t.extract.base64(r);await t.encoder.commandFinished;const i=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var UP=Object.defineProperty,kP=Object.defineProperties,$P=Object.getOwnPropertyDescriptors,Mx=Object.getOwnPropertySymbols,LP=Object.prototype.hasOwnProperty,NP=Object.prototype.propertyIsEnumerable,Ox=(r,t,e)=>t in r?UP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cx=(r,t)=>{for(var e in t||(t={}))LP.call(t,e)&&Ox(r,e,t[e]);if(Mx)for(var e of Mx(t))NP.call(t,e)&&Ox(r,e,t[e]);return r},XP=(r,t)=>kP(r,$P(t));const HP=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let jP=0;function Gx(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=HP[jP++]);let s="";for(let o=0;o