All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 1m20s
2313 lines
694 KiB
JavaScript
2313 lines
694 KiB
JavaScript
var DC=Object.defineProperty;var Mx=Object.getOwnPropertySymbols;var UC=Object.prototype.hasOwnProperty,kC=Object.prototype.propertyIsEnumerable;var Cx=(d,Ot,Gt)=>Ot in d?DC(d,Ot,{enumerable:!0,configurable:!0,writable:!0,value:Gt}):d[Ot]=Gt,Ox=(d,Ot)=>{for(var Gt in Ot||(Ot={}))UC.call(Ot,Gt)&&Cx(d,Gt,Ot[Gt]);if(Mx)for(var Gt of Mx(Ot))kC.call(Ot,Gt)&&Cx(d,Gt,Ot[Gt]);return d};/*!
|
|
* PixiJS - v8.14.3
|
|
* Compiled Thu, 20 Nov 2025 12:37:45 UTC
|
|
*
|
|
* PixiJS is licensed under the MIT License.
|
|
* http://www.opensource.org/licenses/mit-license
|
|
*/var PIXI=function(d){"use strict";"use strict";var Ot=Object.defineProperty,Gt=Object.defineProperties,u0=Object.getOwnPropertyDescriptors,Ju=Object.getOwnPropertySymbols,h0=Object.prototype.hasOwnProperty,c0=Object.prototype.propertyIsEnumerable,th=(r,t,e)=>t in r?Ot(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eh=(r,t)=>{for(var e in t||(t={}))h0.call(t,e)&&th(r,e,t[e]);if(Ju)for(var e of Ju(t))c0.call(t,e)&&th(r,e,t[e]);return r},d0=(r,t)=>Gt(r,u0(t)),T=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(T||{});const Sn=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=d0(eh({},t),{ref:r})}if(typeof r=="object")r=eh({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},br=(r,t)=>{var e;return(e=Sn(r).priority)!=null?e:t},F={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Sn).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(Sn).forEach(t=>{t.type.forEach(e=>{var i,s;const n=this._addHandlers,o=this._queue;n[e]?(s=n[e])==null||s.call(n,t):(o[e]=o[e]||[],(i=o[e])==null||i.push(t))})}),this},handle(r,t,e){var i;const s=this._addHandlers,n=this._removeHandlers;s[r]=t,n[r]=e;const o=this._queue;return o[r]&&((i=o[r])==null||i.forEach(a=>t(a)),delete o[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,i=>{t.findIndex(s=>s.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((s,n)=>br(n.value,e)-br(s.value,e)))},i=>{const s=t.findIndex(n=>n.name===i.name);s!==-1&&t.splice(s,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>br(n,e)-br(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var $C=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function rh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function LC(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function NC(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function XC(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var An={exports:{}},HC=An.exports;(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,u,h){this.fn=l,this.context=u,this.once=h||!1}function n(l,u,h,c,p){if(typeof h!="function")throw new TypeError("The listener must be a function");var f=new s(h,c||l,p),m=e?e+u:u;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],h,c;if(this._eventsCount===0)return u;for(c in h=this._events)t.call(h,c)&&u.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},a.prototype.listeners=function(u){var h=e?e+u:u,c=this._events[h];if(!c)return[];if(c.fn)return[c.fn];for(var p=0,f=c.length,m=new Array(f);p<f;p++)m[p]=c[p].fn;return m},a.prototype.listenerCount=function(u){var h=e?e+u:u,c=this._events[h];return c?c.fn?1:c.length:0},a.prototype.emit=function(u,h,c,p,f,m){var _=e?e+u:u;if(!this._events[_])return!1;var g=this._events[_],b=arguments.length,y,v;if(g.fn){switch(g.once&&this.removeListener(u,g.fn,void 0,!0),b){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,h),!0;case 3:return g.fn.call(g.context,h,c),!0;case 4:return g.fn.call(g.context,h,c,p),!0;case 5:return g.fn.call(g.context,h,c,p,f),!0;case 6:return g.fn.call(g.context,h,c,p,f,m),!0}for(v=1,y=new Array(b-1);v<b;v++)y[v-1]=arguments[v];g.fn.apply(g.context,y)}else{var x=g.length,A;for(v=0;v<x;v++)switch(g[v].once&&this.removeListener(u,g[v].fn,void 0,!0),b){case 1:g[v].fn.call(g[v].context);break;case 2:g[v].fn.call(g[v].context,h);break;case 3:g[v].fn.call(g[v].context,h,c);break;case 4:g[v].fn.call(g[v].context,h,c,p);break;default:if(!y)for(A=1,y=new Array(b-1);A<b;A++)y[A-1]=arguments[A];g[v].fn.apply(g[v].context,y)}}return!0},a.prototype.on=function(u,h,c){return n(this,u,h,c,!1)},a.prototype.once=function(u,h,c){return n(this,u,h,c,!0)},a.prototype.removeListener=function(u,h,c,p){var f=e?e+u:u;if(!this._events[f])return this;if(!h)return o(this,f),this;var m=this._events[f];if(m.fn)m.fn===h&&(!p||m.once)&&(!c||m.context===c)&&o(this,f);else{for(var _=0,g=[],b=m.length;_<b;_++)(m[_].fn!==h||p&&!m[_].once||c&&m[_].context!==c)&&g.push(m[_]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(u){var h;return u?(h=e?e+u:u,this._events[h]&&o(this,h)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(An);var p0=An.exports,gt=rh(p0),f0={grad:.9,turn:360,rad:360/(2*Math.PI)},ee=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},lt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Bt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},ih=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},sh=function(r){return{r:Bt(r.r,0,255),g:Bt(r.g,0,255),b:Bt(r.b,0,255),a:Bt(r.a)}},En=function(r){return{r:lt(r.r),g:lt(r.g),b:lt(r.b),a:lt(r.a,3)}},m0=/^#([0-9a-f]{3,8})$/i,xi=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},nh=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},oh=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),u=n%6;return{r:255*[i,a,o,o,l,i][u],g:255*[l,i,i,a,o,o][u],b:255*[o,o,l,i,i,a][u],a:s}},ah=function(r){return{h:ih(r.h),s:Bt(r.s,0,100),l:Bt(r.l,0,100),a:Bt(r.a)}},lh=function(r){return{h:lt(r.h),s:lt(r.s),l:lt(r.l),a:lt(r.a,3)}},uh=function(r){return oh((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},vr=function(r){return{h:(t=nh(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},g0=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_0=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,b0=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v0=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pn={string:[[function(r){var t=m0.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?lt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?lt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=b0.exec(r)||v0.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:sh({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=g0.exec(r)||_0.exec(r);if(!t)return null;var e,i,s=ah({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(f0[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return uh(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return ee(t)&&ee(e)&&ee(i)?sh({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!ee(t)||!ee(e)||!ee(i))return null;var o=ah({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return uh(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!ee(t)||!ee(e)||!ee(i))return null;var o=function(a){return{h:ih(a.h),s:Bt(a.s,0,100),v:Bt(a.v,0,100),a:Bt(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return oh(o)},"hsv"]]},hh=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},ch=function(r){return typeof r=="string"?hh(r.trim(),Pn.string):typeof r=="object"&&r!==null?hh(r,Pn.object):[null,void 0]},jC=function(r){return ch(r)[1]},wn=function(r,t){var e=vr(r);return{h:e.h,s:Bt(e.s+100*t,0,100),l:e.l,a:e.a}},Rn=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},dh=function(r,t){var e=vr(r);return{h:e.h,s:e.s,l:Bt(e.l+100*t,0,100),a:e.a}},Ti=function(){function r(t){this.parsed=ch(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return lt(Rn(this.rgba),2)},r.prototype.isDark=function(){return Rn(this.rgba)<.5},r.prototype.isLight=function(){return Rn(this.rgba)>=.5},r.prototype.toHex=function(){return t=En(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?xi(lt(255*n)):"","#"+xi(e)+xi(i)+xi(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return En(this.rgba)},r.prototype.toRgbString=function(){return t=En(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return lh(vr(this.rgba))},r.prototype.toHslString=function(){return t=lh(vr(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=nh(this.rgba),{h:lt(t.h),s:lt(t.s),v:lt(t.v),a:lt(t.a,3)};var t},r.prototype.invert=function(){return Ht({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),Ht(wn(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ht(wn(this.rgba,-t))},r.prototype.grayscale=function(){return Ht(wn(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),Ht(dh(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),Ht(dh(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"?Ht({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):lt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=vr(this.rgba);return typeof t=="number"?Ht({h:t,s:e.s,l:e.l,a:e.a}):lt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===Ht(t).toHex()},r}(),Ht=function(r){return r instanceof Ti?r:new Ti(r)},ph=[],y0=function(r){r.forEach(function(t){ph.indexOf(t)<0&&(t(Ti,Pn),ph.push(t))})},zC=function(){return new Ti({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function x0(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,u=i[this.toHex()];if(u)return u;if(o!=null&&o.closest){var h=this.toRgb(),c=1/0,p="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var m in e){var _=(a=h,l=n[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<c&&(c=_,p=m)}return p}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}var T0=Object.defineProperty,fh=Object.getOwnPropertySymbols,S0=Object.prototype.hasOwnProperty,A0=Object.prototype.propertyIsEnumerable,mh=(r,t,e)=>t in r?T0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,E0=(r,t)=>{for(var e in t||(t={}))S0.call(t,e)&&mh(r,e,t[e]);if(fh)for(var e of fh(t))A0.call(t,e)&&mh(r,e,t[e]);return r};y0([x0]);const Ue=class vi{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 vi)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?E0({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=vi._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=vi.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ht(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof vi||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}};Ue.shared=new Ue,Ue._temp=new Ue,Ue.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let H=Ue;const gh={cullArea:null,cullable:!1,cullableChildren:!0},_h=Math.PI*2,bh=180/Math.PI,vh=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 Mn.x=0,Mn.y=0,Mn}}const Mn=new W;class M{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new W;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new W;const i=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,u=1/(i*o+n*-s),h=t.x,c=t.y;return e.x=o*u*h+-n*u*c+(l*n-a*o)*u,e.y=i*u*c+-s*u*h+(-l*i+a*s)*u,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,s=t.b,n=t.c,o=t.d,a=t.tx,l=t.ty,u=e.a,h=e.b,c=e.c,p=e.d;return this.a=i*u+s*c,this.b=i*h+s*p,this.c=n*u+o*c,this.d=n*h+o*p,this.tx=a*u+l*c+e.tx,this.ty=a*h+l*p+e.ty,this}setTransform(t,e,i,s,n,o,a,l,u){return this.a=Math.cos(a+u)*n,this.b=Math.sin(a+u)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),u=Math.abs(a+l);return u<1e-5||Math.abs(_h-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new M;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 w0.identity()}static get shared(){return P0.identity()}}const P0=new M,w0=new M;class Z{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new Z(t!=null?t:this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}const yr={default:-1};function Y(r="default"){return yr[r]===void 0&&(yr[r]=-1),++yr[r]}function R0(){for(const r in yr)delete yr[r]}const me={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class yh{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var e;let i;return this._index>0?i=this._pool[--this._index]:(i=new this._classType,this._count++),(e=i.init)==null||e.call(i,t),i}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class xh{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 yh(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const st=new xh;me.register(st);const Th={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function Cn(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}const Sh={allowChildren:!0,removeChildren(r=0,t){var e;const i=t!=null?t:this.children.length,s=i-r,n=[];if(s>0&&s<=i){for(let a=i-1;a>=r;a--){const l=this.children[a];l&&(n.push(l),l.parent=null)}Cn(this.children,r,i);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(n);for(let a=0;a<n.length;++a){const l=n[a];(e=l.parentRenderLayer)==null||e.detach(l),this.emit("childRemoved",l,this,a),n[a].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(s===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(r.parent){const s=r.parent.children.indexOf(r);if(r.parent===this&&s===t)return r;s!==-1&&r.parent.children.splice(s,1)}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(r),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",r,this,t),r.emit("added",this),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=r;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},Ah={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const i=this.children,s=i.length;for(let n=0;n<s;n++)i[n].collectRenderables(r,t,e)},collectRenderablesWithEffects(r,t,e){const{renderPipes:i}=t;for(let s=0;s<this.effects.length;s++){const n=this.effects[s];i[n.pipe].push(n,this,r)}this.collectRenderablesSimple(r,t,e);for(let s=this.effects.length-1;s>=0;s--){const n=this.effects[s];i[n.pipe].pop(n,this,r)}}};class xr{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class Eh{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const i=this._tests[e];if(i.test(t))return st.get(i.maskClass,t)}return t}returnMaskEffect(t){st.return(t)}}const Si=new Eh;F.handleByList(T.MaskEffect,Si._effectClasses);var M0=Object.defineProperty,Ph=Object.getOwnPropertySymbols,C0=Object.prototype.hasOwnProperty,O0=Object.prototype.propertyIsEnumerable,wh=(r,t,e)=>t in r?M0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rh=(r,t)=>{for(var e in t||(t={}))C0.call(t,e)&&wh(r,e,t[e]);if(Ph)for(var e of Ph(t))O0.call(t,e)&&wh(r,e,t[e]);return r};const Mh={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),Si.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=Si.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=Rh(Rh({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new xr);r=r;const i=(r==null?void 0:r.length)>0,s=((t=e.filters)==null?void 0:t.length)>0,n=i!==s;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),n&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new xr),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Ch={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let i=0;i<e.length;i++){const s=e[i];if(s.label===r||r instanceof RegExp&&r.test(s.label))return s}if(t)for(let i=0;i<e.length;i++){const s=e[i].getChildByLabel(r,!0);if(s)return s}return null},getChildrenByLabel(r,t=!1,e=[]){const i=this.children;for(let s=0;s<i.length;s++){const n=i[s];(n.label===r||r instanceof RegExp&&r.test(n.label))&&e.push(n)}if(t)for(let s=0;s<i.length;s++)i[s].getChildrenByLabel(r,!0,e);return e}},Ai=[new W,new W,new W,new W];class z{constructor(t=0,e=0,i=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new z(0,0,0,0)}clone(){return new z(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,u=i*(1-s),h=i-u,c=a-u,p=a+n+u,f=l-u,m=l+o+u,_=a+h,g=a+n-h,b=l+h,y=l+o-h;return t>=c&&t<=p&&e>=f&&e<=m&&!(t>_&&t<g&&e>b&&e<y)}intersects(t,e){if(!e){const C=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=C)return!1;const O=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>O}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Ai[0].set(t.left,t.top),l=Ai[1].set(t.left,t.bottom),u=Ai[2].set(t.right,t.top),h=Ai[3].set(t.right,t.bottom);if(u.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(u,u),e.apply(h,h),Math.max(a.x,l.x,u.x,h.x)<=i||Math.min(a.x,l.x,u.x,h.x)>=s||Math.max(a.y,l.y,u.y,h.y)<=n||Math.min(a.y,l.y,u.y,h.y)>=o))return!1;const p=c*(l.y-a.y),f=c*(a.x-l.x),m=p*i+f*n,_=p*s+f*n,g=p*i+f*o,b=p*s+f*o;if(Math.max(m,_,g,b)<=p*a.x+f*a.y||Math.min(m,_,g,b)>=p*h.x+f*h.y)return!1;const y=c*(a.y-u.y),v=c*(u.x-a.x),x=y*i+v*n,A=y*s+v*n,S=y*i+v*o,E=y*s+v*o;return!(Math.max(x,A,S,E)<=y*a.x+v*a.y||Math.min(x,A,S,E)>=y*h.x+v*h.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t||(t=new z),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}}const Oh=new M;class ot{constructor(t=1/0,e=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Oh,this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new z);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Oh,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,u=n.d,h=n.tx,c=n.ty;let p=this.minX,f=this.minY,m=this.maxX,_=this.maxY,g=o*t+l*e+h,b=a*t+u*e+c;g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*i+l*e+h,b=a*i+u*e+c,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*t+l*s+h,b=a*t+u*s+c,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),g=o*i+l*s+h,b=a*i+u*s+c,g<p&&(p=g),b<f&&(f=b),g>m&&(m=g),b>_&&(_=b),this.minX=p,this.minY=f,this.maxX=m,this.maxY=_}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:u,tx:h,ty:c}=t;let p=o*e+l*i+h,f=a*e+u*i+c;this.minX=p,this.minY=f,this.maxX=p,this.maxY=f,p=o*s+l*i+h,f=a*s+u*i+c,this.minX=p<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=o*e+l*n+h,f=a*e+u*n+c,this.minX=p<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=o*s+l*n+h,f=a*s+u*n+c,this.minX=p<this.minX?p:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=p>this.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,s){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new ot(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,s){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;s||(s=this.matrix);const u=s.a,h=s.b,c=s.c,p=s.d,f=s.tx,m=s.ty;for(let _=e;_<i;_+=2){const g=t[_],b=t[_+1],y=u*g+c*b+f,v=h*g+p*b+m;n=y<n?y:n,o=v<o?v:o,a=y>a?y:a,l=v>l?v:l}this.minX=n,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}const ht=st.getPool(M),jt=st.getPool(ot),G0=new M,Gh={getFastGlobalBounds(r,t){t||(t=new ot),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let i=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const s=!!this.effects.length;if((this.renderGroup||s)&&(i=jt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;i.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(r,i,e)}if(s){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,i.applyMatrix(o.worldTransform)),this.effects[a].addBounds(i,!0));n&&i.applyMatrix(o.worldTransform.copyTo(G0).invert()),t.addBounds(i),jt.return(i)}else this.renderGroup&&(t.addBounds(i,this.relativeGroupTransform),jt.return(i))}};function Tr(r,t,e){e.clear();let i,s;return r.parent?t?i=r.parent.worldTransform:(s=ht.get().identity(),i=Ei(r,s)):i=M.IDENTITY,Bh(r,e,i,t),s&&ht.return(s),e.isValid||e.set(0,0,0,0),e}function Bh(r,t,e,i){var s,n;if(!r.visible||!r.measurable)return;let o;i?o=r.worldTransform:(r.updateLocalTransform(),o=ht.get(),o.appendFrom(r.localTransform,e));const a=t,l=!!r.effects.length;if(l&&(t=jt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{const u=r.bounds;u&&!u.isEmpty()&&(t.matrix=o,t.addBounds(u));for(let h=0;h<r.children.length;h++)Bh(r.children[h],t,o,i)}if(l){for(let u=0;u<r.effects.length;u++)(n=(s=r.effects[u]).addBounds)==null||n.call(s,t);a.addBounds(t,M.IDENTITY),jt.return(t)}i||ht.return(o)}function Ei(r,t){const e=r.parent;return e&&(Ei(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function On(r,t){if(r===16777215||!t)return t;if(t===16777215||!r)return r;const e=r>>16&255,i=r>>8&255,s=r&255,n=t>>16&255,o=t>>8&255,a=t&255,l=e*n/255|0,u=i*o/255|0,h=s*a/255|0;return(l<<16)+(u<<8)+h}const Ih=16777215;function Sr(r,t){return r===Ih?t:t===Ih?r:On(r,t)}function ke(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const Fh={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new M,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Ei(this,ht.get().identity());return r.appendFrom(this.localTransform,e),ht.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?ke(this.renderGroup.worldColor):this.parentRenderGroup?ke(Sr(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Sr(t,e.localColor),e=e.parent;return ke(t)}};function Pi(r,t,e){return t.clear(),e||(e=M.IDENTITY),Dh(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function Dh(r,t,e,i,s){var n,o;let a;if(s)a=ht.get(),a=e.copyTo(a);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const h=r.localTransform;a=ht.get(),a.appendFrom(h,e)}const l=t,u=!!r.effects.length;if(u&&(t=jt.get().clear()),r.boundsArea)t.addRect(r.boundsArea,a);else{r.renderPipeId&&(t.matrix=a,t.addBounds(r.bounds));const h=r.children;for(let c=0;c<h.length;c++)Dh(h[c],t,a,i,!1)}if(u){for(let h=0;h<r.effects.length;h++)(o=(n=r.effects[h]).addLocalBounds)==null||o.call(n,t,i);l.addBounds(t,M.IDENTITY),jt.return(t)}ht.return(a)}function Gn(r,t){const e=r.children;for(let i=0;i<e.length;i++){const s=e[i],n=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=t.index;(t.data[a]!==n||t.data[a+1]!==o)&&(t.data[t.index]=n,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,s.children.length&&Gn(s,t)}return t.didChange}const B0=new M,Uh={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=r/t*e:this.scale.x=e},_setHeight(r,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=r/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new ot});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),Gn(this,r),r.didChange&&Pi(this,r.localBounds,B0),r.localBounds},getBounds(r,t){return Tr(this,r,t||new ot)}},kh={_onRender:null,set onRender(r){const t=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},$h={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(I0))}};function I0(r,t){return r._zIndex-t._zIndex}const Lh={getGlobalPosition(r=new W,t=!1){return this.parent?this.parent.toGlobal(this._position,r,t):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,t,e=!1){const i=this.getGlobalTransform(ht.get(),e);return t=i.apply(r,t),ht.return(i),t},toLocal(r,t,e,i){t&&(r=t.toGlobal(r,e,i));const s=this.getGlobalTransform(ht.get(),i);return e=s.applyInverse(r,e),ht.return(s),e}};class Bn{constructor(){this.uid=Y("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}function ge(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 In(r){return!(r&r-1)&&!!r}function F0(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 Ut(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var D0=Object.defineProperty,Nh=Object.getOwnPropertySymbols,U0=Object.prototype.hasOwnProperty,k0=Object.prototype.propertyIsEnumerable,Xh=(r,t,e)=>t in r?D0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hh=(r,t)=>{for(var e in t||(t={}))U0.call(t,e)&&Xh(r,e,t[e]);if(Nh)for(var e of Nh(t))k0.call(t,e)&&Xh(r,e,t[e]);return r};const jh=Object.create(null);function $0(r){const t=jh[r];return t===void 0&&(jh[r]=Y("resource")),t}const zh=class Gx extends gt{constructor(t={}){var e,i,s,n,o,a,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Hh(Hh({},Gx.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(i=t.addressModeV)!=null?i:this.addressModeV,this.addressModeW=(s=t.addressModeW)!=null?s:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(n=t.magFilter)!=null?n:this.magFilter,this.minFilter=(o=t.minFilter)!=null?o:this.minFilter,this.mipmapFilter=(a=t.mipmapFilter)!=null?a:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.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=$0(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};zh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let At=zh;var L0=Object.defineProperty,Vh=Object.getOwnPropertySymbols,N0=Object.prototype.hasOwnProperty,X0=Object.prototype.propertyIsEnumerable,Wh=(r,t,e)=>t in r?L0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yh=(r,t)=>{for(var e in t||(t={}))N0.call(t,e)&&Wh(r,e,t[e]);if(Vh)for(var e of Vh(t))X0.call(t,e)&&Wh(r,e,t[e]);return r};const Kh=class Bx extends gt{constructor(t={}){var e,i,s;super(),this.options=t,this.uid=Y("textureSource"),this._resourceType="textureSource",this._resourceId=Y("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Yh(Yh({},Bx.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(i=this.resourceWidth)!=null?i:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(s=this.resourceHeight)!=null?s:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new At(Ut(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.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=Y("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,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const s=Math.round(t*i),n=Math.round(e*i);return this.width=s/i,this.height=n/i,this._resolution=i,this.pixelWidth===s&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=n,this.emit("resize",this),this._resourceId=Y("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=In(this.pixelWidth)&&In(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Kh.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Q=Kh;const _e=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],be=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ve=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ye=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Fn=[],qh=[],wi=Math.sign;function H0(){for(let r=0;r<16;r++){const t=[];Fn.push(t);for(let e=0;e<16;e++){const i=wi(_e[r]*_e[e]+ve[r]*be[e]),s=wi(be[r]*_e[e]+ye[r]*be[e]),n=wi(_e[r]*ve[e]+ve[r]*ye[e]),o=wi(be[r]*ve[e]+ye[r]*ye[e]);for(let a=0;a<16;a++)if(_e[a]===i&&be[a]===s&&ve[a]===n&&ye[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new M;t.set(_e[r],be[r],ve[r],ye[r],0,0),qh.push(t)}}H0();const N={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>_e[r],uY:r=>be[r],vX:r=>ve[r],vY:r=>ye[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Fn[r][t],sub:(r,t)=>Fn[r][N.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?N.S:N.N:Math.abs(t)*2<=Math.abs(r)?r>0?N.E:N.W:t>0?r>0?N.SE:N.SW:r>0?N.NE:N.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=qh[N.inv(t)];s.tx=e,s.ty=i,r.append(s)},transformRectCoords:(r,t,e,i)=>{const{x:s,y:n,width:o,height:a}=r,{x:l,y:u,width:h,height:c}=t;return e===N.E?(i.set(s+l,n+u,o,a),i):e===N.S?i.set(h-n-a+l,s+u,a,o):e===N.W?i.set(h-s-o+l,c-n-a+u,o,a):e===N.N?i.set(n+l,c-s-o+u,a,o):i.set(s+l,n+u,o,a)}},Dn=()=>{};var j0=Object.defineProperty,z0=Object.defineProperties,V0=Object.getOwnPropertyDescriptors,Zh=Object.getOwnPropertySymbols,W0=Object.prototype.hasOwnProperty,Y0=Object.prototype.propertyIsEnumerable,Qh=(r,t,e)=>t in r?j0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,K0=(r,t)=>{for(var e in t||(t={}))W0.call(t,e)&&Qh(r,e,t[e]);if(Zh)for(var e of Zh(t))Y0.call(t,e)&&Qh(r,e,t[e]);return r},q0=(r,t)=>z0(r,V0(t));class Ri extends Q{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super(q0(K0({},t),{resource:e,format:i})),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Ri.extension=T.TextureSource;const Jh=new M;class Un{constructor(t,e){this.mapCoord=new M,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const i=t.orig,s=t.trim;s&&(Jh.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(Jh));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+l)/n.width,o[1]=(t.frame.y+a+l)/n.height,o[2]=(t.frame.x+t.frame.width-a+l)/n.width,o[3]=(t.frame.y+t.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&t.rotate===0,!0}}class w extends gt{constructor({source:t,label:e,frame:i,orig:s,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:u}={}){var h;if(super(),this.uid=Y("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new z,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(h=t==null?void 0:t.source)!=null?h:new Q,this.noFrame=!i,i)this.frame.copyFrom(i);else{const{width:c,height:p}=this._source;this.frame.width=c,this.frame.height=p}this.orig=s||this.frame,this.trim=n,this.rotate=l!=null?l:0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=u||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Un(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:i,height:s}=this._source,n=e.x/i,o=e.y/s,a=e.width/i,l=e.height/s;let u=this.rotate;if(u){const h=a/2,c=l/2,p=n+h,f=o+c;u=N.add(u,N.NW),t.x0=p+h*N.uX(u),t.y0=f+c*N.uY(u),u=N.add(u,2),t.x1=p+h*N.uX(u),t.y1=f+c*N.uY(u),u=N.add(u,2),t.x2=p+h*N.uX(u),t.y2=f+c*N.uY(u),u=N.add(u,2),t.x3=p+h*N.uX(u),t.y3=f+c*N.uY(u)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+l,t.x3=n,t.y3=o+l}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return this._source}}w.EMPTY=new w({label:"EMPTY",source:new Q({label:"EMPTY"})}),w.EMPTY.destroy=Dn,w.WHITE=new w({source:new Ri({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),w.WHITE.destroy=Dn;var Z0=Object.defineProperty,Q0=Object.defineProperties,J0=Object.getOwnPropertyDescriptors,tc=Object.getOwnPropertySymbols,tT=Object.prototype.hasOwnProperty,eT=Object.prototype.propertyIsEnumerable,ec=(r,t,e)=>t in r?Z0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rT=(r,t)=>{for(var e in t||(t={}))tT.call(t,e)&&ec(r,e,t[e]);if(tc)for(var e of tc(t))eT.call(t,e)&&ec(r,e,t[e]);return r},iT=(r,t)=>Q0(r,J0(t));let sT=0;class rc{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new At(this.textureOptions)}createTexture(t,e,i){const s=new Q(iT(rT({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1}));return new w({source:s,label:`texturePool_${sT++}`})}getOptimalTexture(t,e,i=1,s){let n=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);n=ge(n),o=ge(o);const a=(n<<17)+(o<<1)+(s?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let l=this._texturePool[a].pop();return l||(l=this.createTexture(n,o,s)),l.source._resolution=i,l.source.width=n/i,l.source.height=o/i,l.source.pixelWidth=n,l.source.pixelHeight=o,l.frame.x=0,l.frame.y=0,l.frame.width=t,l.frame.height=e,l.updateUvs(),this._poolKeyHash[l.uid]=a,l}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this._texturePool={}}}const et=new rc;me.register(et);class Mi{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new M,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Bn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let i=0;i<e.length;i++){const s=e[i];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(et.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i<e.length;i++)this.addChild(e[i])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let i=0;i<e.length;i++)this.removeChild(e[i])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let i=0;i<e.length;i++)this._getChildren(e[i],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const i=t.children;for(let s=0;s<i.length;s++)this._getChildren(i[s],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new M),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new M),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new M),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Ci(r,t,e={}){for(const i in t)!e[i]&&t[i]!==void 0&&(r[i]=t[i])}const kn=new Z(null),$n=new Z(null),Ln=new Z(null,1,1),Nn=new Z(null),Ar=1,Oi=2,$e=4,nT=8;class q extends gt{constructor(t={}){var e,i;super(),this.uid=Y("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new M,this.relativeGroupTransform=new M,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Z(this,0,0),this._scale=Ln,this._pivot=$n,this._origin=Nn,this._skew=kn,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Ci(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(s=>this.addChild(s)),(i=t.parent)==null||i.addChild(this)}static mixin(t){F.mixin(q,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let s=0;s<t.length;s++)this.addChild(t[s]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let s=0;s<t.length;s++)this.removeChild(t[s]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=st.get(Mi,this),this.groupTransform=M.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),st.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new M),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*bh}set angle(t){this.rotation=t*vh}get pivot(){return this._pivot===$n&&(this._pivot=new Z(this,0,0)),this._pivot}set pivot(t){this._pivot===$n&&(this._pivot=new Z(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===kn&&(this._skew=new Z(this,0,0)),this._skew}set skew(t){this._skew===kn&&(this._skew=new Z(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Ln&&(this._scale=new Z(this,1,1)),this._scale}set scale(t){this._scale===Ln&&(this._scale=new Z(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Nn&&(this._origin=new Z(this,0,0)),this._origin}set origin(t){this._origin===Nn&&(this._origin=new Z(this,0,0)),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){var i;const s=this.getLocalBounds();typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,s=this._pivot,n=this._origin,o=this._position,a=i._x,l=i._y,u=s._x,h=s._y,c=-n._x,p=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*l,e.d=this._sy*l,e.tx=o._x-(u*e.a+h*e.c)+(c*e.a+p*e.c)-c,e.ty=o._y-(u*e.b+h*e.d)+(c*e.b+p*e.d)-p}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Ar,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=H.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=Ar,this._onUpdate())}get tint(){return ke(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Oi,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|=$e,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|=$e,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|=$e,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let i;if(this.children.length&&(i=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&i)for(let s=0;s<i.length;++s)i[s].destroy(t);(e=this.renderGroup)==null||e.destroy(),this.renderGroup=null}}F.mixin(q,Sh,Gh,Lh,kh,Uh,Mh,Ch,$h,gh,Th,Fh,Ah);var zt=(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))(zt||{});class Gi{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=s}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const ic=class Ct{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 Gi(null,null,1/0),this.deltaMS=1/Ct.targetFPMS,this.elapsedMS=1/Ct.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=zt.NORMAL){return this._addListener(new Gi(t,e,i))}addOnce(t,e,i=zt.NORMAL){return this._addListener(new Gi(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Ct.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Ct.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!Ct._shared){const t=Ct._shared=new Ct;t.autoStart=!0,t._protected=!0}return Ct._shared}static get system(){if(!Ct._system){const t=Ct._system=new Ct;t.autoStart=!0,t._protected=!0}return Ct._system}};ic.targetFPMS=.06;let at=ic;class Xn{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=e.width/i*this._renderer.resolution,o=e.height/s*this._renderer.resolution,a=e.left,l=e.top,u=`translate(${a}px, ${l}px) scale(${n}, ${o})`;u!==this._lastTransform&&(this._domElement.style.transform=u,this._lastTransform=u)},this._domElement=t.domElement,this._renderer=t.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=e.contentRect.width/i*this._renderer.resolution,o=e.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||at.shared.add(this.updateTranslation,this,zt.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&at.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class Le{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Le.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new W,this.page=new W,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var Hn=/iPhone/i,sc=/iPod/i,nc=/iPad/i,oc=/\biOS-universal(?:.+)Mac\b/i,jn=/\bAndroid(?:.+)Mobile\b/i,ac=/Android/i,Ne=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Bi=/Silk/i,re=/Windows Phone/i,lc=/\bWindows(?:.+)ARM\b/i,uc=/BlackBerry/i,hc=/BB10/i,cc=/Opera Mini/i,dc=/\b(CriOS|Chrome)(?:.+)Mobile/i,pc=/Mobile(?:.+)Firefox\b/i,fc=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function oT(r){return function(t){return t.test(r)}}function mc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]!="undefined"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]!="undefined"&&(e=i[0]);var s=oT(e),n={apple:{phone:s(Hn)&&!s(re),ipod:s(sc),tablet:!s(Hn)&&(s(nc)||fc(t))&&!s(re),universal:s(oc),device:(s(Hn)||s(sc)||s(nc)||s(oc)||fc(t))&&!s(re)},amazon:{phone:s(Ne),tablet:!s(Ne)&&s(Bi),device:s(Ne)||s(Bi)},android:{phone:!s(re)&&s(Ne)||!s(re)&&s(jn),tablet:!s(re)&&!s(Ne)&&!s(jn)&&(s(Bi)||s(ac)),device:!s(re)&&(s(Ne)||s(Bi)||s(jn)||s(ac))||s(/\bokhttp\b/i)},windows:{phone:s(re),tablet:s(lc),device:s(re)||s(lc)},other:{blackberry:s(uc),blackberry10:s(hc),opera:s(cc),firefox:s(pc),chrome:s(dc),device:s(uc)||s(hc)||s(cc)||s(pc)||s(dc)},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 gc;const _c=((gc=mc.default)!=null?gc:mc)(globalThis.navigator);var aT=Object.defineProperty,bc=Object.getOwnPropertySymbols,lT=Object.prototype.hasOwnProperty,uT=Object.prototype.propertyIsEnumerable,vc=(r,t,e)=>t in r?aT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yc=(r,t)=>{for(var e in t||(t={}))lT.call(t,e)&&vc(r,e,t[e]);if(bc)for(var e of bc(t))uT.call(t,e)&&vc(r,e,t[e]);return r};const hT=9,xc=100,cT=0,dT=0,Tc=2,Sc=1,pT=-1e3,fT=-1e3,mT=2,zn=class Ix{constructor(t,e=_c){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const t=document.createElement("button");t.style.width=`${Sc}px`,t.style.height=`${Sc}px`,t.style.position="absolute",t.style.top=`${pT}px`,t.style.left=`${fT}px`,t.style.zIndex=mT.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${cT}px`,this._div.style.left=`${dT}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=Tc.toString(),this._canvasObserver=new Xn({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var t,e;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const i of this._children)(t=i._accessibleDiv)!=null&&t.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(s=>{s.parentNode&&s.parentNode.removeChild(s)}),delete this._pools[i];(e=this._div)!=null&&e.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this._updateAccessibleObjects(e[i])}init(t){const e=Ix.defaultOptions,i={accessibilityOptions:yc(yc({},e),(t==null?void 0:t.accessibilityOptions)||{})};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount||(this._androidUpdateCount=t+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&e.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const s=this._children[i];e.has(i)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,Cn(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const s=this._children[i];if(!s._accessibleActive||!s._accessibleDiv)continue;const n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const a=s.worldTransform;n.style.left=`${a.tx+o.x*a.a}px`,n.style.top=`${a.ty+o.y*a.d}px`,n.style.width=`${o.width*a.a}px`,n.style.height=`${o.height*a.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}_addChild(t){let e=this._getPool(t.accessibleType).pop();e?(e.innerHTML="",e.removeAttribute("title"),e.removeAttribute("aria-label"),e.tabIndex=0):(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=`
|
|
color: transparent;
|
|
pointer-events: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
border: 0;
|
|
outline: 0;
|
|
background: transparent;
|
|
box-sizing: border-box;
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
-moz-user-select: none;
|
|
-ms-user-select: none;
|
|
`,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${xc}px`,e.style.height=`${xc}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Tc.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:i}=t.target,s=this._renderer.events.rootBoundary,n=Object.assign(new Le(s),{target:i});s.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode!==hT||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),(t=this._canvasObserver)==null||t.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}_getPool(t){return this._pools[t]||(this._pools[t]=[]),this._pools[t]}};zn.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"accessibility"},zn.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Ac=zn;const Ec={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};F.add(Ac),F.mixin(q,Ec);class Vn{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Vn.extension=T.Application;class Wn{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,zt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?at.shared:new at,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Wn.extension=T.Application,F.add(Vn),F.add(Wn);let gT=class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this._tickerAdded||!this.domElement||(at.system.add(this._tickerUpdate,this,zt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(at.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};const Vt=new gT;class Er extends Le{constructor(){super(...arguments),this.client=new W,this.movement=new W,this.offset=new W,this.global=new W,this.screen=new W}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,u,h,c,p,f,m,_){throw new Error("Method not implemented.")}}class It extends Er{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class xe extends Er{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}xe.DOM_DELTA_PIXEL=0,xe.DOM_DELTA_LINE=1,xe.DOM_DELTA_PAGE=2;const _T=2048,bT=new W,Pr=new W;class Pc{constructor(t){this.dispatch=new gt,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t)}hitTest(t,e){Vt.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,bT.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<_T&&t!==this.rootTarget&&t.parent;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Vt.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let c=h.length-1;c>=0;c--){const p=h[c],f=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const m=t.isInteractive();(f.length>0||m)&&(m&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?u?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Vt.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=i;for(let h=l.length-1;h>=0;h--){const c=l[h],p=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,u,s,n);if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();return(p.length>0||f)&&p.push(t),p}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,Pr),!t.hitArea.contains(Pr.x,Pr.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const s=t.effects[i];if(s.containsPoint&&!s.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t!=null&&t.containsPoint?(t.worldTransform.applyInverse(e,Pr),t.containsPoint(Pr)):!1}notifyTarget(t,e){var i,s;if(!t.currentTarget.isInteractive())return;e!=null||(e=t.type);const n=`on${e}`;(s=(i=t.currentTarget)[n])==null||s.call(i,t);const o=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,o),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof It))return;const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,i,s;if(!(t instanceof It))return;this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const n=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const o=n.pointerType==="mouse"||n.pointerType==="pen",a=this.trackingData(t.pointerId),l=this.findMountedTarget(a.overTargets);if(((e=a.overTargets)==null?void 0:e.length)>0&&l!==n.target){const c=t.type==="mousemove"?"mouseout":"pointerout",p=this.createPointerEvent(t,c,l);if(this.dispatchEvent(p,"pointerout"),o&&this.dispatchEvent(p,"mouseout"),!n.composedPath().includes(l)){const f=this.createPointerEvent(t,"pointerleave",l);for(f.eventPhase=f.AT_TARGET;f.target&&!n.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),o&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(p)}if(l!==n.target){const c=t.type==="mousemove"?"mouseover":"pointerover",p=this.clonePointerEvent(n,c);this.dispatchEvent(p,"pointerover"),o&&this.dispatchEvent(p,"mouseover");let f=l==null?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==n.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const m=this.clonePointerEvent(n,"pointerenter");for(m.eventPhase=m.AT_TARGET;m.target&&m.target!==l&&m.target!==this.rootTarget.parent;)m.currentTarget=m.target,this.notifyTarget(m),o&&this.notifyTarget(m,"mouseenter"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(p)}const u=[],h=(i=this.enableGlobalMoveEvents)!=null?i:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(n,"pointermove"),h&&u.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),h&&u.push("globaltouchmove")),o&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),h&&u.push("globalmousemove"),this.cursor=(s=n.target)==null?void 0:s.cursor),u.length>0&&this.all(n,u),this._allInteractiveElements.length=0,this._hitElements.length=0,a.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof It))return;const i=this.trackingData(t.pointerId),s=this.createPointerEvent(t),n=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),n&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=(e=s.target)==null?void 0:e.cursor);const o=this.clonePointerEvent(s,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;i.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(o)}mapPointerOut(t){if(!(t instanceof It))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof It))return;const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const u=a.button===2;this.dispatchEvent(a,u?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof It))return;const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof xe))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){var s;const n=this.allocateEvent(It);return this.copyPointerData(t,n),this.copyMouseData(t,n),this.copyData(t,n),n.nativeEvent=t.nativeEvent,n.originalEvent=t,n.target=(s=i!=null?i:this.hitTest(n.global.x,n.global.y))!=null?s:this._hitElements[0],typeof e=="string"&&(n.type=e),n}createWheelEvent(t){const e=this.allocateEvent(xe);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(It);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e!=null?e:i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof It&&e instanceof It&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Er&&e instanceof Er&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const i=t.currentTarget._events[e];if(i)if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}var vT=Object.defineProperty,wc=Object.getOwnPropertySymbols,yT=Object.prototype.hasOwnProperty,xT=Object.prototype.propertyIsEnumerable,Rc=(r,t,e)=>t in r?vT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,TT=(r,t)=>{for(var e in t||(t={}))yT.call(t,e)&&Rc(r,e,t[e]);if(wc)for(var e of wc(t))xT.call(t,e)&&Rc(r,e,t[e]);return r};const ST=1,AT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Yn=class ju{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Pc(null),Vt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new It(null),this._rootWheelEvent=new xe(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(TT({},ju.defaultEventFeatures),{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,i;const{canvas:s,resolution:n}=this.renderer;this.setTargetElement(s),this.resolution=n,ju._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(i=t.eventFeatures)!=null?i:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){Vt.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Vt.pointerMoved();const e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this._normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this._bootstrapEvent(this._rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this._bootstrapEvent(this._rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,Vt.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Vt.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;Vt.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button=="undefined"&&(n.button=0),typeof n.buttons=="undefined"&&(n.buttons=1),typeof n.isPrimary=="undefined"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width=="undefined"&&(n.width=n.radiusX||1),typeof n.height=="undefined"&&(n.height=n.radiusY||1),typeof n.tiltX=="undefined"&&(n.tiltX=0),typeof n.tiltY=="undefined"&&(n.tiltY=0),typeof n.pointerType=="undefined"&&(n.pointerType="touch"),typeof n.pointerId=="undefined"&&(n.pointerId=n.identifier||0),typeof n.pressure=="undefined"&&(n.pressure=n.force||.5),typeof n.twist=="undefined"&&(n.twist=0),typeof n.tangentialPressure=="undefined"&&(n.tangentialPressure=0),typeof n.layerX=="undefined"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY=="undefined"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary=="undefined"&&(i.isPrimary=!0),typeof i.width=="undefined"&&(i.width=1),typeof i.height=="undefined"&&(i.height=1),typeof i.tiltX=="undefined"&&(i.tiltX=0),typeof i.tiltY=="undefined"&&(i.tiltY=0),typeof i.pointerType=="undefined"&&(i.pointerType="mouse"),typeof i.pointerId=="undefined"&&(i.pointerId=ST),typeof i.pressure=="undefined"&&(i.pressure=.5),typeof i.twist=="undefined"&&(i.twist=0),typeof i.tangentialPressure=="undefined"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=AT[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};Yn.extension={name:"events",type:[T.WebGLSystem,T.CanvasSystem,T.WebGPUSystem],priority:-1},Yn.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Kn=Yn;const Mc={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){var r;return(r=this._internalEventMode)!=null?r:Kn.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof Le))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};F.add(Kn),F.mixin(q,Mc);class qn{constructor(t){this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new Xn({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const i=t[e],s=i.element;if(!i.parent||i.globalDisplayStatus<7)s==null||s.remove(),t.splice(e,1),e--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const n=i.worldTransform,o=i._anchor,a=i.width*o.x,l=i.height*o.y;s.style.transformOrigin=`${a}px ${l}px`,s.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,s.style.opacity=i.groupAlpha.toString()}}}destroy(){var t;this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)(t=this._attachedDomElements[e].element)==null||t.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}qn.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"dom"};class Wt extends q{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new ot(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:s}=t;return i>=e.minX&&i<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,i;super.destroy(t),this._bounds=null;for(const s in this._gpuData)(i=(e=this._gpuData[s]).destroy)==null||i.call(e);this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:s}=e;s.blendMode.pushBlendMode(this,this.groupBlendMode,t),s[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const n=this.children,o=n.length;for(let a=0;a<o;a++)n[a].collectRenderables(t,e,i);s.blendMode.popBlendMode(t)}}var ET=Object.defineProperty,Ii=Object.getOwnPropertySymbols,Cc=Object.prototype.hasOwnProperty,Oc=Object.prototype.propertyIsEnumerable,Gc=(r,t,e)=>t in r?ET(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,PT=(r,t)=>{for(var e in t||(t={}))Cc.call(t,e)&&Gc(r,e,t[e]);if(Ii)for(var e of Ii(t))Oc.call(t,e)&&Gc(r,e,t[e]);return r},wT=(r,t)=>{var e={};for(var i in r)Cc.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ii)for(var i of Ii(r))t.indexOf(i)<0&&Oc.call(r,i)&&(e[i]=r[i]);return e};class RT extends Wt{constructor(t={}){const e=t,{element:i,anchor:s}=e,n=wT(e,["element","anchor"]);super(PT({label:"DOMContainer"},n)),this.renderPipeId="dom",this.batched=!1,this._anchor=new W(0,0),s&&(this.anchor=s),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e){t.minX=0,t.minY=0,t.maxX=0,t.maxY=0;return}const{offsetWidth:i,offsetHeight:s}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=s}destroy(t=!1){var e,i;super.destroy(t),(i=(e=this._element)==null?void 0:e.parentNode)==null||i.removeChild(this._element),this._element=null,this._anchor=null}}F.add(qn);var Et=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Et||{});const Bc={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let Ic=Bc;const L={get(){return Ic},set(r){Ic=r}};function kt(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function wr(r){return r.split("?")[0].split("#")[0]}function MT(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function CT(r,t,e){return r.replace(new RegExp(MT(t),"g"),e)}function OT(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const _t={toPosix(r){return CT(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){kt(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(kt(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=wr(this.toPosix(t!=null?t:L.get().getBaseUrl())),s=wr(this.toPosix(e!=null?e:this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?_t.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(kt(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=OT(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return kt(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let i=0;i<r.length;++i){const s=r[i];if(kt(s),s.length>0)if(e===void 0)e=s;else{const n=(t=r[i-1])!=null?t:"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(kt(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){kt(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){kt(r),t&&kt(t),r=wr(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){kt(r),r=wr(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){kt(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=wr(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;const n="";t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let o=-1,a=0,l=-1,u=!0,h=r.length-1,c=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!u){a=h+1;break}continue}l===-1&&(u=!1,l=h+1),e===46?o===-1?o=h:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||l===-1||c===0||c===1&&o===l-1&&o===a+1?l!==-1&&(a===0&&i?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(a,l)):(a===0&&i?(t.name=r.slice(1,o),t.base=r.slice(1,l)):(t.name=r.slice(a,o),t.base=r.slice(a,l)),t.ext=r.slice(o,l)),t.dir=this.dirname(r),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},Ft=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);function Fc(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Fc(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function Dc(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Fc(r,s,0,e,i)}else i.push(r);return i}const Rr=r=>!Array.isArray(r);var GT=Object.defineProperty,BT=Object.defineProperties,IT=Object.getOwnPropertyDescriptors,Uc=Object.getOwnPropertySymbols,FT=Object.prototype.hasOwnProperty,DT=Object.prototype.propertyIsEnumerable,kc=(r,t,e)=>t in r?GT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Te=(r,t)=>{for(var e in t||(t={}))FT.call(t,e)&&kc(r,e,t[e]);if(Uc)for(var e of Uc(t))DT.call(t,e)&&kc(r,e,t[e]);return r},$c=(r,t)=>BT(r,IT(t));class oe{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,i,s;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(i=t.createBundleAssetId)!=null?i:this._createBundleAssetId,this._extractAssetIdFromBundle=(s=t.extractAssetIdFromBundle)!=null?s:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return Ft(e||i,s=>typeof s=="string"?s:Array.isArray(s)?s.map(n=>{var o;return(o=n==null?void 0:n.src)!=null?o:n}):s!=null&&s.src?s.src:s,!0)}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:Te({alias:n},o))),s.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const u=this._createBundleAssetId(t,a);i.push(u),l=[a,u]}else{const u=a.map(h=>this._createBundleAssetId(t,h));i.push(...u),l=[...a,...u]}this.add($c(Te({},n),{alias:l,src:o}))}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;Ft(e).forEach(s=>{const{src:n}=s;let{data:o,format:a,loadParser:l,parser:u}=s;const h=Ft(n).map(m=>typeof m=="string"?Dc(m):Array.isArray(m)?m:[m]),c=this.getAlias(s),p=[],f=m=>{const _=this._parsers.find(g=>g.test(m));return $c(Te({},_==null?void 0:_.parse(m)),{src:m})};h.forEach(m=>{m.forEach(_=>{var g,b,y,v;let x={};if(typeof _!="object"?x=f(_):(o=(g=_.data)!=null?g:o,a=(b=_.format)!=null?b:a,(_.loadParser||_.parser)&&(l=(y=_.loadParser)!=null?y:l,u=(v=_.parser)!=null?v:u),x=Te(Te({},f(_.src)),_)),!c)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:c,data:o,format:a,loadParser:l,parser:u,progressSize:s.progressSize}),p.push(x)})}),c.forEach(m=>{this._assetMap[m]=p})})}resolveBundle(t){const e=Rr(t);t=Ft(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const u=o[l];a[this._extractAssetIdFromBundle(s,l)]=u}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Rr(t);t=Ft(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(l=>{const u=n.filter(h=>h[a]?h[a]===l:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[e],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,s;const{aliases:n,data:o,loadParser:a,parser:l,format:u,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=_t.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(i=n!=null?n:t.alias)!=null?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=Te(Te({},o||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.parser=l!=null?l:t.parser,t.format=(s=u!=null?u:t.format)!=null?s:Lc(t.src),h!==void 0&&(t.progressSize=h),t}}oe.RETINA_PREFIX=/@([0-9\.]+)x/;function Lc(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Fi=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},Nc=class yi{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof Q&&(i={texture:t,data:e});const{texture:s,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=s instanceof w?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=yi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=yi.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const u=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,h=new z(0,0,Math.floor(u.w)/this.resolution,Math.floor(u.h)/this.resolution);n.rotated?a=new z(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new z(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new z(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new w({source:this.textureSource,frame:a,orig:h,trim:l,rotate:n.rotated?2:0,defaultAnchor:n.anchor,defaultBorders:n.borders,label:s.toString()})}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*yi.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*yi.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Nc.BATCH_SIZE=1e3;let Zn=Nc;const UT=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Xc(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=_t.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{const a=Xc([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const Hc={extension:T.Asset,cache:{test:r=>r instanceof Zn,getCacheableAssets:(r,t)=>Xc(r,t,!1)},resolver:{extension:{type:T.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&UT.includes(i)},parse:r=>{var t,e;const i=r.split(".");return{resolution:parseFloat((e=(t=oe.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:T.LoadParser,priority:Et.Normal,name:"spritesheetLoader"},async testParse(r,t){return _t.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var i,s,n;const{texture:o,imageFilename:a,textureOptions:l,cachePrefix:u}=(i=t==null?void 0:t.data)!=null?i:{};let h=_t.dirname(t.src);h&&h.lastIndexOf("/")!==h.length-1&&(h+="/");let c;if(o instanceof w)c=o;else{const m=Fi(h+(a!=null?a:r.meta.image),t.src);c=(await e.load([{src:m,data:l}]))[m]}const p=new Zn({texture:c.source,data:r,cachePrefix:u});await p.parse();const f=(s=r==null?void 0:r.meta)==null?void 0:s.related_multi_packs;if(Array.isArray(f)){const m=[];for(const g of f){if(typeof g!="string")continue;let b=h+g;(n=t.data)!=null&&n.ignoreMultiPack||(b=Fi(b,t.src),m.push(e.load({src:b,data:{textureOptions:l,ignoreMultiPack:!0}})))}const _=await Promise.all(m);p.linkedSheets=_,_.forEach(g=>{g.linkedSheets=[p].concat(p.linkedSheets.filter(b=>b!==g))})}return p},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};F.add(Hc);function Qn(r,t,e){const{width:i,height:s}=e.orig,n=e.trim;if(n){const o=n.width,a=n.height;r.minX=n.x-t._x*i,r.maxX=r.minX+o,r.minY=n.y-t._y*s,r.maxY=r.minY+a}else r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*s,r.maxY=r.minY+s}var kT=Object.defineProperty,Di=Object.getOwnPropertySymbols,jc=Object.prototype.hasOwnProperty,zc=Object.prototype.propertyIsEnumerable,Vc=(r,t,e)=>t in r?kT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$T=(r,t)=>{for(var e in t||(t={}))jc.call(t,e)&&Vc(r,e,t[e]);if(Di)for(var e of Di(t))zc.call(t,e)&&Vc(r,e,t[e]);return r},LT=(r,t)=>{var e={};for(var i in r)jc.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Di)for(var i of Di(r))t.indexOf(i)<0&&zc.call(r,i)&&(e[i]=r[i]);return e};class $t extends Wt{constructor(t=w.EMPTY){t instanceof w&&(t={texture:t});const e=t,{texture:i=w.EMPTY,anchor:s,roundPixels:n,width:o,height:a}=e,l=LT(e,["texture","anchor","roundPixels","width","height"]);super($T({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=n!=null?n:!1,o!==void 0&&(this.width=o),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof w?new $t(t):new $t(w.from(t,e))}set texture(t){t||(t=w.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return Qn(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:s,height:n}=e.orig;i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const NT=new ot;function Ui(r,t,e){const i=NT;r.measurable=!0,Tr(r,e,i),t.addBoundsMask(i),r.measurable=!1}function ki(r,t,e){const i=jt.get();r.measurable=!0;const s=ht.get().identity(),n=Wc(r,e,s);Pi(r,i,n),r.measurable=!1,t.addBoundsMask(i),ht.return(s),jt.return(i)}function Wc(r,t,e){return r&&r!==t&&(Wc(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Jn{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof $t),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||Ui(this.mask,t,e)}addLocalBounds(t,e){ki(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof $t}}Jn.extension=T.MaskEffect;class to{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"}}to.extension=T.MaskEffect;class eo{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){Ui(this.mask,t,e)}addLocalBounds(t,e){ki(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof q}}eo.extension=T.MaskEffect;class Yt extends Q{constructor(t){t.resource||(t.resource=L.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const s=super.resize(t,e,i);return s&&this.resizeCanvas(),s}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Yt.extension=T.TextureSource;class ae extends Q{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ae.extension=T.TextureSource;let ro;async function io(){return ro!=null||(ro=(async()=>{var r;const t=L.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(s),t.deleteTexture(i),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ro}var XT=Object.defineProperty,HT=Object.defineProperties,jT=Object.getOwnPropertyDescriptors,Yc=Object.getOwnPropertySymbols,zT=Object.prototype.hasOwnProperty,VT=Object.prototype.propertyIsEnumerable,Kc=(r,t,e)=>t in r?XT(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,so=(r,t)=>{for(var e in t||(t={}))zT.call(t,e)&&Kc(r,e,t[e]);if(Yc)for(var e of Yc(t))VT.call(t,e)&&Kc(r,e,t[e]);return r},WT=(r,t)=>HT(r,jT(t));const $i=class Fx extends Q{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=so(so({},Fx.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=at.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await io(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(at.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(at.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(at.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};$i.extension=T.TextureSource,$i.defaultOptions=WT(so({},Q.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),$i.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Xe=$i,YT=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){return this._cache.get(t)}set(t,e){const i=Ft(t);let s;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.test(e)){s=u.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(l=>{n.set(l,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const u=s?s[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,n.get(l))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}};const V=new YT,no=[];F.handleByList(T.TextureSource,no);function KT(r={}){return oo(r)}function oo(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let s=0;s<no.length;s++){const n=no[s];if(n.test(e))return new n(i)}throw new Error(`Could not find a source type for resource: ${i.resource}`)}function qc(r={},t=!1){const e=r&&r.resource,i=e?r.resource:r,s=e?r:{resource:r};if(!t&&V.has(i))return V.get(i);const n=new w({source:oo(s)});return n.on("destroy",()=>{V.has(i)&&V.remove(i)}),t||V.set(i,n),n}function Zc(r,t=!1){return typeof r=="string"?V.get(r):r instanceof Q?new w({source:r}):qc(r,t)}w.from=Zc,Q.from=oo,F.add(Jn,to,eo,Xe,ae,Yt,Ri);class Kt{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,s;const n=this.resources[e];t!==n&&(n&&((i=t.off)==null||i.call(t,"change",this.onResourceChange,this)),(s=t.on)==null||s.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var t;const e=this.resources;for(const i in e){const s=e[i];(t=s==null?void 0:s.off)==null||t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}const Qc={};function Li(r,t,e){let i=2166136261;for(let s=0;s<t;s++)i^=r[s].uid,i=Math.imul(i,16777619),i>>>=0;return Qc[i]||qT(r,t,i,e)}function qT(r,t,e,i){const s={};let n=0;for(let a=0;a<i;a++){const l=a<t?r[a]:w.EMPTY.source;s[n++]=l.source,s[n++]=l.style}const o=new Kt(s);return Qc[e]=o,o}class Se{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const Jc=new Set,ao="8.0.0",ZT="8.3.4",He={quiet:!1,noColor:!1},Mr=(r,t,e=3)=>{if(He.quiet||Jc.has(t))return;let i=new Error().stack;const s=`${t}
|
|
Deprecated since v${r}`,n=typeof console.groupCollapsed=="function"&&!He.noColor;typeof i=="undefined"?console.warn("PixiJS Deprecation Warning: ",s):(i=i.split(`
|
|
`).splice(e).join(`
|
|
`),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",s),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",s),console.warn(i))),Jc.add(t)};Object.defineProperties(Mr,{quiet:{get:()=>He.quiet,set:r=>{He.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>He.noColor,set:r=>{He.noColor=r},enumerable:!0,configurable:!1}});function Ni(r,t){const e=r.byteLength/8|0,i=new Float64Array(r,0,e);new Float64Array(t,0,e).set(i);const s=r.byteLength-e*8;if(s>0){const n=new Uint8Array(r,e*8,s);new Uint8Array(t,e*8,s).set(n)}}const td={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var rt=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(rt||{});function je(r,t){return t.alphaMode==="no-premultiply-alpha"&&td[r]||r}let Cr;function lo(){return(!Cr||Cr!=null&&Cr.isContextLost())&&(Cr=L.get().createCanvas().getContext("webgl",{})),Cr}const QT=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
`);function JT(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
|
|
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function uo(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const i=QT.replace(/%forloop%/gi,JT(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}}finally{t.deleteShader(e)}return r}let ze=null;function ed(){var r;if(ze)return ze;const t=lo();return ze=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ze=uo(ze,t),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),ze}class rd{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}var t1=Object.defineProperty,id=Object.getOwnPropertySymbols,e1=Object.prototype.hasOwnProperty,r1=Object.prototype.propertyIsEnumerable,sd=(r,t,e)=>t in r?t1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nd=(r,t)=>{for(var e in t||(t={}))e1.call(t,e)&&sd(r,e,t[e]);if(id)for(var e of id(t))r1.call(t,e)&&sd(r,e,t[e]);return r};class od{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new rd,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const Or=[];let Xi=0;me.register({clear:()=>{if(Or.length>0)for(const r of Or)r&&r.destroy();Or.length=0,Xi=0}});function ad(){return Xi>0?Or[--Xi]:new od}function ld(r){Or[Xi++]=r}let Gr=0;const ud=class Dx{constructor(t){this.uid=Y("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=nd(nd({},Dx.defaultOptions),t),t.maxTextures||(Mr("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=ed());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:s}=t;this.attributeBuffer=new Se(i*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)ld(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!i&&i!==0?!1:(t._textureId=i,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=ad(),s=i.textures;s.clear();const n=e[this.elementStart];let o=je(n.blendMode,n.texture._source),a=n.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,h=this.indexBuffer;let c=this._batchIndexSize,p=this._batchIndexStart,f="startBatch";const m=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){const g=e[_];e[_]=null;const b=g.texture._source,y=je(g.blendMode,b),v=o!==y||a!==g.topology;if(b._batchTick===Gr&&!v){g._textureId=b._textureBindLocation,c+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(h,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,h,g._indexStart,g._attributeStart/this.vertexSize)),g._batch=i;continue}b._batchTick=Gr,(s.count>=m||v)&&(this._finishBatch(i,p,c-p,s,o,a,t,f),f="renderBatch",p=c,o=y,a=g.topology,i=ad(),s=i.textures,s.clear(),++Gr),g._textureId=b._textureBindLocation=s.count,s.ids[b.uid]=s.count,s.textures[s.count++]=b,g._batch=i,c+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(h,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,h,g._indexStart,g._attributeStart/this.vertexSize))}s.count>0&&(this._finishBatch(i,p,c-p,s,o,a,t,f),p=c,++Gr),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=c}_finishBatch(t,e,i,s,n,o,a,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=s,t.blendMode=n,t.topology=o,t.start=e,t.size=i,++Gr,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Se(e);Ni(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)s[n]=e[n];else Ni(e.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(t,e,i){t[e]=i+0,t[e+1]=i+1,t[e+2]=i+2,t[e+3]=i+0,t[e+4]=i+2,t[e+5]=i+3}packIndex(t,e,i,s){const n=t.indices,o=t.indexSize,a=t.indexOffset,l=t.attributeOffset;for(let u=0;u<o;u++)e[i++]=s+n[u+a]-l}destroy(t={}){var e;if(this.batches!==null){for(let i=0;i<this.batches.length;i++)ld(this.batches[i]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let i=0;i<this._elements.length;i++)this._elements[i]&&(this._elements[i]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};ud.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let hd=ud;var X=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(X||{});class bt extends gt{constructor(t){let{data:e,size:i}=t;const{usage:s,label:n,shrinkToFit:o}=t;super(),this.uid=Y("buffer"),this._resourceType="buffer",this._resourceId=Y("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i!=null||(i=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:i,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o!=null?o:!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&X.STATIC)}set static(t){t?this.descriptor.usage|=X.STATIC:this.descriptor.usage&=~X.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const s=this._data;if(this._data=t,this._dataInt32=null,!s||s.length!==t.length){!this.shrinkToFit&&s&&t.byteLength<s.byteLength?i&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=Y("resource"),this.emit("change",this));return}i&&this.emit("update",this)}update(t){this._updateSize=t!=null?t:this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function ho(r,t){if(!(r instanceof bt)){let e=t?X.INDEX:X.VERTEX;r instanceof Array&&(t?(r=new Uint32Array(r),e=X.INDEX|X.COPY_DST):(r=new Float32Array(r),e=X.VERTEX|X.COPY_DST)),r=new bt({data:r,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return r}function cd(r,t,e){const i=r.getAttribute(t);if(!i)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const s=i.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const u=s.BYTES_PER_ELEMENT,h=(i.offset||0)/u,c=(i.stride||2*4)/u;for(let p=h;p<s.length;p+=c){const f=s[p],m=s[p+1];f>a&&(a=f),m>l&&(l=m),f<n&&(n=f),m<o&&(o=m)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=l,e}function i1(r){return(r instanceof bt||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=ho(r.buffer,!1),r}class Ae extends gt{constructor(t={}){var e;super(),this.uid=Y("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new ot,this._boundsDirty=!0;const{attributes:i,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},i)for(const o in i)this.addAttribute(o,i[o]);this.instanceCount=(e=t.instanceCount)!=null?e:1,s&&this.addIndex(s),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const i=i1(e);this.buffers.indexOf(i.buffer)===-1&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=ho(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,cd(this,"aPosition",this._bounds)):this._bounds}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(i=>i.destroy()),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const s1=new Float32Array(1),n1=new Uint32Array(1);class dd extends Ae{constructor(){const t=new bt({data:s1,label:"attribute-batch-buffer",usage:X.VERTEX|X.COPY_DST,shrinkToFit:!1}),e=new bt({data:n1,label:"index-batch-buffer",usage:X.INDEX|X.COPY_DST,shrinkToFit:!1}),i=6*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:i,offset:0},aUV:{buffer:t,format:"float32x2",stride:i,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:i,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:i,offset:20}},indexBuffer:e})}}const co=Object.create(null),pd=Object.create(null);function Ve(r,t){let e=pd[r];return e===void 0&&(co[t]===void 0&&(co[t]=1),pd[r]=e=co[t]++),e}let Hi;function fd(){if(!Hi){Hi="mediump";const r=lo();r&&r.getShaderPrecisionFormat&&(Hi=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Hi}function md(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 gd(r,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let s=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return s==="highp"&&i!=="highp"&&(s="mediump"),`precision ${s} float;
|
|
${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function _d(r,t){return t?`#version 300 es
|
|
${r}`:r}const o1={},a1={};function bd(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?o1:a1;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`}
|
|
${r}`}function vd(r,t){return t?r.replace("#version 300 es",""):r}var l1=Object.defineProperty,yd=Object.getOwnPropertySymbols,u1=Object.prototype.hasOwnProperty,h1=Object.prototype.propertyIsEnumerable,xd=(r,t,e)=>t in r?l1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Td=(r,t)=>{for(var e in t||(t={}))u1.call(t,e)&&xd(r,e,t[e]);if(yd)for(var e of yd(t))h1.call(t,e)&&xd(r,e,t[e]);return r};const po={stripVersion:vd,ensurePrecision:gd,addProgramDefines:md,setProgramName:bd,insertVersion:_d},Br=Object.create(null),Sd=class zu{constructor(t){t=Td(Td({},zu.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:fd()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let s=t.fragment,n=t.vertex;Object.keys(po).forEach(o=>{const a=i[o];s=po[o](s,a,!0),n=po[o](n,a,!1)}),this.fragment=s,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Ve(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,Br[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Br[e]||(Br[e]=new zu(t),Br[e]._cacheKey=e),Br[e]}};Sd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let vt=Sd;const Ad={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 ie(r){var t;return(t=Ad[r])!=null?t:Ad.float32}const c1={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function Ed({source:r,entryPoint:t}){var e;const i={},s=r.indexOf(`fn ${t}`);if(s!==-1){const n=r.indexOf("->",s);if(n!==-1){const o=r.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let l;for(;(l=a.exec(o))!==null;){const u=(e=c1[l[3]])!=null?e:"float32";i[l[2]]={location:parseInt(l[1],10),format:u,stride:ie(u).stride,offset:0,instance:!1,start:0}}}}return i}function ji(r){var t,e,i;const s=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,o=/@binding\((\d+)\)/,a=/var(<[^>]+>)? (\w+)/,l=/:\s*(\w+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,h=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,p=(t=r.match(s))==null?void 0:t.map(m=>({group:parseInt(m.match(n)[1],10),binding:parseInt(m.match(o)[1],10),name:m.match(a)[2],isUniform:m.match(a)[1]==="<uniform>",type:m.match(l)[1]}));if(!p)return{groups:[],structs:[]};const f=(i=(e=r.match(u))==null?void 0:e.map(m=>{const _=m.match(c)[1],g=m.match(h).reduce((b,y)=>{const[v,x]=y.split(":");return b[v.trim()]=x.trim(),b},{});return g?{name:_,members:g}:null}).filter(({name:m})=>p.some(_=>_.type===m)))!=null?i:[];return{groups:p,structs:f}}var We=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(We||{});function Pd({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]=[]),i.isUniform?t[i.group].push({binding:i.binding,visibility:We.VERTEX|We.FRAGMENT,buffer:{type:"uniform"}}):i.type==="sampler"?t[i.group].push({binding:i.binding,visibility:We.FRAGMENT,sampler:{type:"filtering"}}):i.type==="texture_2d"&&t[i.group].push({binding:i.binding,visibility:We.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return t}function wd({groups:r}){const t=[];for(let e=0;e<r.length;e++){const i=r[e];t[i.group]||(t[i.group]={}),t[i.group][i.name]=i.binding}return t}function Rd(r,t){const e=new Set,i=new Set,s=[...r.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...r.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:s,groups:n}}const Ir=Object.create(null);class dt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,i;const{fragment:s,vertex:n,layout:o,gpuLayout:a,name:l}=t;if(this.name=l,this.fragment=s,this.vertex=n,s.source===n.source){const u=ji(s.source);this.structsAndGroups=u}else{const u=ji(n.source),h=ji(s.source);this.structsAndGroups=Rd(u,h)}this.layout=o!=null?o:wd(this.structsAndGroups),this.gpuLayout=a!=null?a:Pd(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((i=this.layout[1])==null?void 0:i.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ve(i,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Ed(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Ir[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Ir[e]||(Ir[e]=new dt(t),Ir[e]._cacheKey=e),Ir[e]}}function fo(r,t,e){if(r)for(const i in r){const s=i.toLocaleLowerCase(),n=t[s];if(n){let o=r[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}}}const d1=/\{\{(.*?)\}\}/g;function mo(r){var t,e;const i={};return((e=(t=r.match(d1))==null?void 0:t.map(s=>s.replace(/[{()}]/g,"")))!=null?e:[]).forEach(s=>{i[s]=[]}),i}function Md(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function go(r,t,e=!1){const i=[];Md(t,i),r.forEach(a=>{a.header&&Md(a.header,i)});const s=i;e&&s.sort();const n=s.map((a,l)=>` @location(${l}) ${a},`).join(`
|
|
`);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
|
|
${n}
|
|
`),o}function Cd(r,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function p1(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function f1(r){const t=/@.*?\s+/g;return r.replace(t,"")}function Od(r,t){const e=[];Cd(t,e),r.forEach(l=>{l.header&&Cd(l.header,e)});let i=0;const s=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`,
|
|
`),n=e.sort().map(l=>` var ${f1(l)};`).join(`
|
|
`),o=`return VSOutput(
|
|
${e.sort().map(l=>` ${p1(l)}`).join(`,
|
|
`)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
|
|
${s}
|
|
`),a=a.replace("{{start}}",`
|
|
${n}
|
|
`),a=a.replace("{{return}}",`
|
|
${o}
|
|
`),a}function _o(r,t){let e=r;for(const i in t){const s=t[i];s.join(`
|
|
`).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----//
|
|
${s.join(`
|
|
`)}
|
|
//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Ee=Object.create(null),bo=new Map;let m1=0;function Gd({template:r,bits:t}){const e=Id(r,t);if(Ee[e])return Ee[e];const{vertex:i,fragment:s}=g1(r,t);return Ee[e]=Fd(i,s,t),Ee[e]}function Bd({template:r,bits:t}){const e=Id(r,t);return Ee[e]||(Ee[e]=Fd(r.vertex,r.fragment,t)),Ee[e]}function g1(r,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let s=go(e,r.vertex,!0);s=Od(e,s);const n=go(i,r.fragment,!0);return{vertex:s,fragment:n}}function Id(r,t){return t.map(e=>(bo.has(e)||bo.set(e,m1++),bo.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function Fd(r,t,e){const i=mo(r),s=mo(t);return e.forEach(n=>{fo(n.vertex,i,n.name),fo(n.fragment,s,n.name)}),{vertex:_o(r,i),fragment:_o(t,s)}}const Dd=`
|
|
@in aPosition: vec2<f32>;
|
|
@in aUV: vec2<f32>;
|
|
|
|
@out @builtin(position) vPosition: vec4<f32>;
|
|
@out vUV : vec2<f32>;
|
|
@out vColor : vec4<f32>;
|
|
|
|
{{header}}
|
|
|
|
struct VSOutput {
|
|
{{struct}}
|
|
};
|
|
|
|
@vertex
|
|
fn main( {{in}} ) -> VSOutput {
|
|
|
|
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
|
var modelMatrix = mat3x3<f32>(
|
|
1.0, 0.0, 0.0,
|
|
0.0, 1.0, 0.0,
|
|
0.0, 0.0, 1.0
|
|
);
|
|
var position = aPosition;
|
|
var uv = aUV;
|
|
|
|
{{start}}
|
|
|
|
vColor = vec4<f32>(1., 1., 1., 1.);
|
|
|
|
{{main}}
|
|
|
|
vUV = uv;
|
|
|
|
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
|
|
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
|
|
|
vColor *= globalUniforms.uWorldColorAlpha;
|
|
|
|
{{end}}
|
|
|
|
{{return}}
|
|
};
|
|
`,Ud=`
|
|
@in vUV : vec2<f32>;
|
|
@in vColor : vec4<f32>;
|
|
|
|
{{header}}
|
|
|
|
@fragment
|
|
fn main(
|
|
{{in}}
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
{{start}}
|
|
|
|
var outColor:vec4<f32>;
|
|
|
|
{{main}}
|
|
|
|
var finalColor:vec4<f32> = outColor * vColor;
|
|
|
|
{{end}}
|
|
|
|
return finalColor;
|
|
};
|
|
`,kd=`
|
|
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}}
|
|
}
|
|
`,$d=`
|
|
|
|
in vec4 vColor;
|
|
in vec2 vUV;
|
|
|
|
out vec4 finalColor;
|
|
|
|
{{header}}
|
|
|
|
void main(void) {
|
|
|
|
{{start}}
|
|
|
|
vec4 outColor;
|
|
|
|
{{main}}
|
|
|
|
finalColor = outColor * vColor;
|
|
|
|
{{end}}
|
|
}
|
|
`,Ld={name:"global-uniforms-bit",vertex:{header:`
|
|
struct GlobalUniforms {
|
|
uProjectionMatrix:mat3x3<f32>,
|
|
uWorldTransformMatrix:mat3x3<f32>,
|
|
uWorldColorAlpha: vec4<f32>,
|
|
uResolution: vec2<f32>,
|
|
}
|
|
|
|
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
`}},_1={name:"global-uniforms-ubo-bit",vertex:{header:`
|
|
uniform globalUniforms {
|
|
mat3 uProjectionMatrix;
|
|
mat3 uWorldTransformMatrix;
|
|
vec4 uWorldColorAlpha;
|
|
vec2 uResolution;
|
|
};
|
|
`}},Nd={name:"global-uniforms-bit",vertex:{header:`
|
|
uniform mat3 uProjectionMatrix;
|
|
uniform mat3 uWorldTransformMatrix;
|
|
uniform vec4 uWorldColorAlpha;
|
|
uniform vec2 uResolution;
|
|
`}};var b1=Object.defineProperty,Xd=Object.getOwnPropertySymbols,v1=Object.prototype.hasOwnProperty,y1=Object.prototype.propertyIsEnumerable,Hd=(r,t,e)=>t in r?b1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,x1=(r,t)=>{for(var e in t||(t={}))v1.call(t,e)&&Hd(r,e,t[e]);if(Xd)for(var e of Xd(t))y1.call(t,e)&&Hd(r,e,t[e]);return r};function Ye({bits:r,name:t}){const e=Gd({template:{fragment:Ud,vertex:Dd},bits:[Ld,...r]});return dt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Ke({bits:r,name:t}){return new vt(x1({name:t},Bd({template:{vertex:kd,fragment:$d},bits:[Nd,...r]})))}const zi={name:"color-bit",vertex:{header:`
|
|
@in aColor: vec4<f32>;
|
|
`,main:`
|
|
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
`}},Vi={name:"color-bit",vertex:{header:`
|
|
in vec4 aColor;
|
|
`,main:`
|
|
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
`}},vo={};function T1(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i<r;i++)t.push(`@group(1) @binding(${e++}) var textureSource${i+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(`
|
|
`)}function S1(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<r;e++)e===r-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
|
|
`)}function Wi(r){return vo[r]||(vo[r]={name:"texture-batch-bit",vertex:{header:`
|
|
@in aTextureIdAndRound: vec2<u32>;
|
|
@out @interpolate(flat) vTextureId : u32;
|
|
`,main:`
|
|
vTextureId = aTextureIdAndRound.y;
|
|
`,end:`
|
|
if(aTextureIdAndRound.x == 1)
|
|
{
|
|
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
}
|
|
`},fragment:{header:`
|
|
@in @interpolate(flat) vTextureId: u32;
|
|
|
|
${T1(r)}
|
|
`,main:`
|
|
var uvDx = dpdx(vUV);
|
|
var uvDy = dpdy(vUV);
|
|
|
|
${S1(r)}
|
|
`}}),vo[r]}const yo={};function A1(r){const t=[];for(let e=0;e<r;e++)e>0&&t.push("else"),e<r-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
|
|
`)}function Yi(r){return yo[r]||(yo[r]={name:"texture-batch-bit",vertex:{header:`
|
|
in vec2 aTextureIdAndRound;
|
|
out float vTextureId;
|
|
|
|
`,main:`
|
|
vTextureId = aTextureIdAndRound.y;
|
|
`,end:`
|
|
if(aTextureIdAndRound.x == 1.)
|
|
{
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
}
|
|
`},fragment:{header:`
|
|
in float vTextureId;
|
|
|
|
uniform sampler2D uTextures[${r}];
|
|
|
|
`,main:`
|
|
|
|
${A1(r)}
|
|
`}}),yo[r]}const qe={name:"round-pixels-bit",vertex:{header:`
|
|
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
{
|
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
}
|
|
`}},Ze={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;
|
|
}
|
|
`}},xo=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],jd=xo.reduce((r,t)=>(r[t]=!0,r),{});function zd(r,t){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var E1=Object.defineProperty,Vd=Object.getOwnPropertySymbols,P1=Object.prototype.hasOwnProperty,w1=Object.prototype.propertyIsEnumerable,Wd=(r,t,e)=>t in r?E1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yd=(r,t)=>{for(var e in t||(t={}))P1.call(t,e)&&Wd(r,e,t[e]);if(Vd)for(var e of Vd(t))w1.call(t,e)&&Wd(r,e,t[e]);return r};const Kd=class Ux{constructor(t,e){this._touched=0,this.uid=Y("uniform"),this._resourceType="uniformGroup",this._resourceId=Y("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var i,s;e=Yd(Yd({},Ux.defaultOptions),e),this.uniformStructures=t;const n={};for(const o in t){const a=t[o];if(a.name=o,a.size=(i=a.size)!=null?i:1,!jd[a.type]){const l=a.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,h]=l;throw new Error(`Uniform type ${a.type} is not supported. Use type: '${u}', size: ${h} instead.`)}throw new Error(`Uniform type ${a.type} is not supported. Supported uniform types are: ${xo.join(", ")}`)}(s=a.value)!=null||(a.value=zd(a.type,a.size)),n[o]=a.value}this.uniforms=n,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ve(Object.keys(n).map(o=>`${o}-${t[o].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Kd.defaultOptions={ubo:!1,isStatic:!1};let nt=Kd;const qd={};function Ki(r){let t=qd[r];if(t)return t;const e=new Int32Array(r);for(let i=0;i<r;i++)e[i]=i;return t=qd[r]=new nt({uTextures:{value:e,type:"i32",size:r}},{isStatic:!0}),t}var yt=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.BOTH=3]="BOTH",r))(yt||{}),R1=Object.defineProperty,qi=Object.getOwnPropertySymbols,Zd=Object.prototype.hasOwnProperty,Qd=Object.prototype.propertyIsEnumerable,Jd=(r,t,e)=>t in r?R1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M1=(r,t)=>{for(var e in t||(t={}))Zd.call(t,e)&&Jd(r,e,t[e]);if(qi)for(var e of qi(t))Qd.call(t,e)&&Jd(r,e,t[e]);return r},C1=(r,t)=>{var e={};for(var i in r)Zd.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&qi)for(var i of qi(r))t.indexOf(i)<0&&Qd.call(r,i)&&(e[i]=r[i]);return e};class Pt extends gt{constructor(t){super(),this.uid=Y("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:s,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=yt.WEBGPU),i&&(o|=yt.WEBGL)),this.compatibleRenderers=o;const l={};if(!n&&!s&&(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&s&&a)for(const u in a)for(const h in a[u]){const c=a[u][h];l[c]={group:u,binding:h,name:c}}else if(e&&s&&!a){const u=e.structsAndGroups.groups;a={},u.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,l[h.name]=h})}else if(n){s={},a={},e&&e.structsAndGroups.groups.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,l[h.name]=h});let u=0;for(const h in n)l[h]||(s[99]||(s[99]=new Kt,this._ownedBindGroups.push(s[99])),l[h]={group:99,binding:u,name:h},a[99]=a[99]||{},a[99][u]=h,u++);for(const h in n){const c=h;let p=n[h];!p.source&&!p._resourceType&&(p=new nt(p));const f=l[c];f&&(s[f.group]||(s[f.group]=new Kt,this._ownedBindGroups.push(s[f.group])),s[f.group].setResource(p,f.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,l)}addResource(t,e,i){var s,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Kt,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const e=t,{gpu:i,gl:s}=e,n=C1(e,["gpu","gl"]);let o,a;return i&&(o=dt.from(i)),s&&(a=vt.from(s)),new Pt(M1({gpuProgram:o,glProgram:a},n))}}class To extends Pt{constructor(t){const e=Ke({name:"batch",bits:[Vi,Yi(t),Ze]}),i=Ye({name:"batch",bits:[zi,Wi(t),qe]});super({glProgram:e,gpuProgram:i,resources:{batchSamplers:Ki(t)}}),this.maxTextures=t}}let Fr=null;const tp=class kx extends hd{constructor(t){super(t),this.geometry=new dd,this.name=kx.extension.name,this.vertexSize=6,Fr!=null||(Fr=new To(t.maxTextures)),this.shader=Fr}packAttributes(t,e,i,s,n){const o=n<<16|t.roundPixels&65535,a=t.transform,l=a.a,u=a.b,h=a.c,c=a.d,p=a.tx,f=a.ty,{positions:m,uvs:_}=t,g=t.color,b=t.attributeOffset,y=b+t.attributeSize;for(let v=b;v<y;v++){const x=v*2,A=m[x],S=m[x+1];e[s++]=l*A+h*S+p,e[s++]=c*S+u*A+f,e[s++]=_[x],e[s++]=_[x+1],i[s++]=g,i[s++]=o}}packQuadAttributes(t,e,i,s,n){const o=t.texture,a=t.transform,l=a.a,u=a.b,h=a.c,c=a.d,p=a.tx,f=a.ty,m=t.bounds,_=m.maxX,g=m.minX,b=m.maxY,y=m.minY,v=o.uvs,x=t.color,A=n<<16|t.roundPixels&65535;e[s+0]=l*g+h*y+p,e[s+1]=c*y+u*g+f,e[s+2]=v.x0,e[s+3]=v.y0,i[s+4]=x,i[s+5]=A,e[s+6]=l*_+h*y+p,e[s+7]=c*y+u*_+f,e[s+8]=v.x1,e[s+9]=v.y1,i[s+10]=x,i[s+11]=A,e[s+12]=l*_+h*b+p,e[s+13]=c*b+u*_+f,e[s+14]=v.x2,e[s+15]=v.y2,i[s+16]=x,i[s+17]=A,e[s+18]=l*g+h*b+p,e[s+19]=c*b+u*g+f,e[s+20]=v.x3,e[s+21]=v.y3,i[s+22]=x,i[s+23]=A}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Fr=new To(t),this.shader=Fr)}destroy(){this.shader=null,super.destroy()}};tp.extension={type:[T.Batcher],name:"default"};let Zi=tp;function So(r,t,e,i,s,n,o,a=null){let l=0;e*=t,s*=n;const u=a.a,h=a.b,c=a.c,p=a.d,f=a.tx,m=a.ty;for(;l<o;){const _=r[e],g=r[e+1];i[s]=u*_+c*g+f,i[s+1]=h*_+p*g+m,s+=n,e+=t,l++}}function Ao(r,t,e,i){let s=0;for(t*=e;s<i;)r[t]=0,r[t+1]=0,t+=e,s++}function Qi(r,t,e,i,s){const n=t.a,o=t.b,a=t.c,l=t.d,u=t.tx,h=t.ty;e||(e=0),i||(i=2),s||(s=r.length/i-e);let c=e*i;for(let p=0;p<s;p++){const f=r[c],m=r[c+1];r[c]=n*f+a*m+u,r[c+1]=o*f+l*m+h,c+=i}}const O1=new M;class Ji{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,i=this.renderable;return i?On(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||O1}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}var G1=Object.defineProperty,B1=Object.defineProperties,I1=Object.getOwnPropertyDescriptors,ep=Object.getOwnPropertySymbols,F1=Object.prototype.hasOwnProperty,D1=Object.prototype.propertyIsEnumerable,rp=(r,t,e)=>t in r?G1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ts=(r,t)=>{for(var e in t||(t={}))F1.call(t,e)&&rp(r,e,t[e]);if(ep)for(var e of ep(t))D1.call(t,e)&&rp(r,e,t[e]);return r},es=(r,t)=>B1(r,I1(t));const Qe={extension:{type:T.ShapeBuilder,name:"circle"},build(r,t){let e,i,s,n,o,a;if(r.type==="circle"){const x=r;if(o=a=x.radius,o<=0)return!1;e=x.x,i=x.y,s=n=0}else if(r.type==="ellipse"){const x=r;if(o=x.halfWidth,a=x.halfHeight,o<=0||a<=0)return!1;e=x.x,i=x.y,s=n=0}else{const x=r,A=x.width/2,S=x.height/2;e=x.x+A,i=x.y+S,o=a=Math.max(0,Math.min(x.radius,Math.min(A,S))),s=A-o,n=S-a}if(s<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(s?4:0)+(n?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n,!0;let h=0,c=l*4+(s?2:0)+2,p=c,f=u,m=s+o,_=n,g=e+m,b=e-m,y=i+_;if(t[h++]=g,t[h++]=y,t[--c]=y,t[--c]=b,n){const x=i-_;t[p++]=b,t[p++]=x,t[--f]=x,t[--f]=g}for(let x=1;x<l;x++){const A=Math.PI/2*(x/l),S=s+Math.cos(A)*o,E=n+Math.sin(A)*a,C=e+S,O=e-S,P=i+E,R=i-E;t[h++]=C,t[h++]=P,t[--c]=P,t[--c]=O,t[p++]=O,t[p++]=R,t[--f]=R,t[--f]=C}m=s,_=n+a,g=e+m,b=e-m,y=i+_;const v=i-_;return t[h++]=g,t[h++]=y,t[--f]=v,t[--f]=g,s&&(t[h++]=b,t[h++]=y,t[--f]=v,t[--f]=b),!0},triangulate(r,t,e,i,s,n){if(r.length===0)return;let o=0,a=0;for(let h=0;h<r.length;h+=2)o+=r[h],a+=r[h+1];o/=r.length/2,a/=r.length/2;let l=i;t[l*e]=o,t[l*e+1]=a;const u=l++;for(let h=0;h<r.length;h+=2)t[l*e]=r[h],t[l*e+1]=r[h+1],h>0&&(s[n++]=l,s[n++]=u,s[n++]=l-1),l++;s[n++]=u+1,s[n++]=u,s[n++]=l-1}},ip=es(ts({},Qe),{extension:es(ts({},Qe.extension),{name:"ellipse"})}),sp=es(ts({},Qe),{extension:es(ts({},Qe.extension),{name:"roundedRectangle"})}),Eo=1e-4,Po=1e-4;function np(r){const t=r.length;if(t<6)return 1;let e=0;for(let i=0,s=r[t-2],n=r[t-1];i<t;i+=2){const o=r[i],a=r[i+1];e+=(o-s)*(a+n),s=o,n=a}return e<0?-1:1}function op(r,t,e,i,s,n,o,a){const l=r-e*s,u=t-i*s,h=r+e*n,c=t+i*n;let p,f;o?(p=i,f=-e):(p=-i,f=e);const m=l+p,_=u+f,g=h+p,b=c+f;return a.push(m,_),a.push(g,b),2}function Pe(r,t,e,i,s,n,o,a){const l=e-r,u=i-t;let h=Math.atan2(l,u),c=Math.atan2(s-r,n-t);a&&h<c?h+=Math.PI*2:!a&&h>c&&(c+=Math.PI*2);let p=h;const f=c-h,m=Math.abs(f),_=Math.sqrt(l*l+u*u),g=(15*m*Math.sqrt(_)/Math.PI>>0)+1,b=f/g;if(p+=b,a){o.push(r,t),o.push(e,i);for(let y=1,v=p;y<g;y++,v+=b)o.push(r,t),o.push(r+Math.sin(v)*_,t+Math.cos(v)*_);o.push(r,t),o.push(s,n)}else{o.push(e,i),o.push(r,t);for(let y=1,v=p;y<g;y++,v+=b)o.push(r+Math.sin(v)*_,t+Math.cos(v)*_),o.push(r,t);o.push(s,n),o.push(r,t)}return g*2}function ap(r,t,e,i,s,n){const o=Eo;if(r.length===0)return;const a=t;let l=a.alignment;if(t.alignment!==.5){let K=np(r);e&&(K*=-1),l=(l-.5)*K+.5}const u=new W(r[0],r[1]),h=new W(r[r.length-2],r[r.length-1]),c=i,p=Math.abs(u.x-h.x)<o&&Math.abs(u.y-h.y)<o;if(c){r=r.slice(),p&&(r.pop(),r.pop(),h.set(r[r.length-2],r[r.length-1]));const K=(u.x+h.x)*.5,fe=(h.y+u.y)*.5;r.unshift(K,fe),r.push(K,fe)}const f=s,m=r.length/2;let _=r.length;const g=f.length/2,b=a.width/2,y=b*b,v=a.miterLimit*a.miterLimit;let x=r[0],A=r[1],S=r[2],E=r[3],C=0,O=0,P=-(A-E),R=x-S,U=0,k=0,B=Math.sqrt(P*P+R*R);P/=B,R/=B,P*=b,R*=b;const mt=l,I=(1-mt)*2,D=mt*2;c||(a.cap==="round"?_+=Pe(x-P*(I-D)*.5,A-R*(I-D)*.5,x-P*I,A-R*I,x+P*D,A+R*D,f,!0)+2:a.cap==="square"&&(_+=op(x,A,P,R,I,D,!0,f))),f.push(x-P*I,A-R*I),f.push(x+P*D,A+R*D);for(let K=1;K<m-1;++K){x=r[(K-1)*2],A=r[(K-1)*2+1],S=r[K*2],E=r[K*2+1],C=r[(K+1)*2],O=r[(K+1)*2+1],P=-(A-E),R=x-S,B=Math.sqrt(P*P+R*R),P/=B,R/=B,P*=b,R*=b,U=-(E-O),k=S-C,B=Math.sqrt(U*U+k*k),U/=B,k/=B,U*=b,k*=b;const fe=S-x,mi=A-E,gi=S-C,_i=O-E,Ex=fe*gi+mi*_i,gn=mi*gi-_i*fe,bi=gn<0;if(Math.abs(gn)<.001*Math.abs(Ex)){f.push(S-P*I,E-R*I),f.push(S+P*D,E+R*D),Ex>=0&&(a.join==="round"?_+=Pe(S,E,S-P*I,E-R*I,S-U*I,E-k*I,f,!1)+4:_+=2,f.push(S-U*D,E-k*D),f.push(S+U*I,E+k*I));continue}const Px=(-P+x)*(-R+E)-(-P+S)*(-R+A),wx=(-U+C)*(-k+E)-(-U+S)*(-k+O),_n=(fe*wx-gi*Px)/gn,bn=(_i*Px-mi*wx)/gn,Hu=(_n-S)*(_n-S)+(bn-E)*(bn-E),Be=S+(_n-S)*I,Ie=E+(bn-E)*I,Fe=S-(_n-S)*D,De=E-(bn-E)*D,IC=Math.min(fe*fe+mi*mi,gi*gi+_i*_i),Rx=bi?I:D,FC=IC+Rx*Rx*y;Hu<=FC?a.join==="bevel"||Hu/y>v?(bi?(f.push(Be,Ie),f.push(S+P*D,E+R*D),f.push(Be,Ie),f.push(S+U*D,E+k*D)):(f.push(S-P*I,E-R*I),f.push(Fe,De),f.push(S-U*I,E-k*I),f.push(Fe,De)),_+=2):a.join==="round"?bi?(f.push(Be,Ie),f.push(S+P*D,E+R*D),_+=Pe(S,E,S+P*D,E+R*D,S+U*D,E+k*D,f,!0)+4,f.push(Be,Ie),f.push(S+U*D,E+k*D)):(f.push(S-P*I,E-R*I),f.push(Fe,De),_+=Pe(S,E,S-P*I,E-R*I,S-U*I,E-k*I,f,!1)+4,f.push(S-U*I,E-k*I),f.push(Fe,De)):(f.push(Be,Ie),f.push(Fe,De)):(f.push(S-P*I,E-R*I),f.push(S+P*D,E+R*D),a.join==="round"?bi?_+=Pe(S,E,S+P*D,E+R*D,S+U*D,E+k*D,f,!0)+2:_+=Pe(S,E,S-P*I,E-R*I,S-U*I,E-k*I,f,!1)+2:a.join==="miter"&&Hu/y<=v&&(bi?(f.push(Fe,De),f.push(Fe,De)):(f.push(Be,Ie),f.push(Be,Ie)),_+=2),f.push(S-U*I,E-k*I),f.push(S+U*D,E+k*D),_+=2)}x=r[(m-2)*2],A=r[(m-2)*2+1],S=r[(m-1)*2],E=r[(m-1)*2+1],P=-(A-E),R=x-S,B=Math.sqrt(P*P+R*R),P/=B,R/=B,P*=b,R*=b,f.push(S-P*I,E-R*I),f.push(S+P*D,E+R*D),c||(a.cap==="round"?_+=Pe(S-P*(I-D)*.5,E-R*(I-D)*.5,S-P*I,E-R*I,S+P*D,E+R*D,f,!1)+2:a.cap==="square"&&(_+=op(S,E,P,R,I,D,!1,f)));const mn=Po*Po;for(let K=g;K<_+g-2;++K)x=f[K*2],A=f[K*2+1],S=f[(K+1)*2],E=f[(K+1)*2+1],C=f[(K+2)*2],O=f[(K+2)*2+1],!(Math.abs(x*(E-O)+S*(O-A)+C*(A-E))<mn)&&n.push(K,K+1,K+2)}function lp(r,t,e,i){const s=Eo;if(r.length===0)return;const n=r[0],o=r[1],a=r[r.length-2],l=r[r.length-1],u=t||Math.abs(n-a)<s&&Math.abs(o-l)<s,h=e,c=r.length/2,p=h.length/2;for(let f=0;f<c;f++)h.push(r[f*2]),h.push(r[f*2+1]);for(let f=0;f<c-1;f++)i.push(p+f,p+f+1);u&&i.push(p+c-1,p)}function up(r,t,e=2){const i=t&&t.length,s=i?t[0]*e:r.length;let n=hp(r,0,s,e,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,u;if(i&&(n=N1(r,t,n,e)),r.length>80*e){a=r[0],l=r[1];let h=a,c=l;for(let p=e;p<s;p+=e){const f=r[p],m=r[p+1];f<a&&(a=f),m<l&&(l=m),f>h&&(h=f),m>c&&(c=m)}u=Math.max(h-a,c-l),u=u!==0?32767/u:0}return Dr(n,o,e,a,l,u,0),o}function hp(r,t,e,i,s){let n;if(s===Mo(r,t,e,i)>0)for(let o=t;o<e;o+=i)n=fp(o/i|0,r[o],r[o+1],n);else for(let o=e-i;o>=t;o-=i)n=fp(o/i|0,r[o],r[o+1],n);return n&&Je(n,n.next)&&($r(n),n=n.next),n}function we(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(Je(e,e.next)||J(e.prev,e,e.next)===0)){if($r(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Dr(r,t,e,i,s,n,o){if(!r)return;!o&&n&&V1(r,i,s,n);let a=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(n?k1(r,i,s,n):U1(r)){t.push(l.i,r.i,u.i),$r(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=$1(we(r),t),Dr(r,t,e,i,s,n,2)):o===2&&L1(r,t,e,i,s,n):Dr(we(r),t,e,i,s,n,1);break}}}function U1(r){const t=r.prev,e=r,i=r.next;if(J(t,e,i)>=0)return!1;const s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,u=i.y,h=Math.min(s,n,o),c=Math.min(a,l,u),p=Math.max(s,n,o),f=Math.max(a,l,u);let m=i.next;for(;m!==t;){if(m.x>=h&&m.x<=p&&m.y>=c&&m.y<=f&&Ur(s,a,n,l,o,u,m.x,m.y)&&J(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function k1(r,t,e,i){const s=r.prev,n=r,o=r.next;if(J(s,n,o)>=0)return!1;const a=s.x,l=n.x,u=o.x,h=s.y,c=n.y,p=o.y,f=Math.min(a,l,u),m=Math.min(h,c,p),_=Math.max(a,l,u),g=Math.max(h,c,p),b=wo(f,m,t,e,i),y=wo(_,g,t,e,i);let v=r.prevZ,x=r.nextZ;for(;v&&v.z>=b&&x&&x.z<=y;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&Ur(a,h,l,c,u,p,v.x,v.y)&&J(v.prev,v,v.next)>=0||(v=v.prevZ,x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==s&&x!==o&&Ur(a,h,l,c,u,p,x.x,x.y)&&J(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;v&&v.z>=b;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==s&&v!==o&&Ur(a,h,l,c,u,p,v.x,v.y)&&J(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==s&&x!==o&&Ur(a,h,l,c,u,p,x.x,x.y)&&J(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function $1(r,t){let e=r;do{const i=e.prev,s=e.next.next;!Je(i,s)&&dp(i,e,e.next,s)&&kr(i,s)&&kr(s,i)&&(t.push(i.i,e.i,s.i),$r(e),$r(e.next),e=r=s),e=e.next}while(e!==r);return we(e)}function L1(r,t,e,i,s,n){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&K1(o,a)){let l=pp(o,a);o=we(o,o.next),l=we(l,l.next),Dr(o,t,e,i,s,n,0),Dr(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function N1(r,t,e,i){const s=[];for(let n=0,o=t.length;n<o;n++){const a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,u=hp(r,a,l,i,!1);u===u.next&&(u.steiner=!0),s.push(Y1(u))}s.sort(X1);for(let n=0;n<s.length;n++)e=H1(s[n],e);return e}function X1(r,t){let e=r.x-t.x;if(e===0&&(e=r.y-t.y,e===0)){const i=(r.next.y-r.y)/(r.next.x-r.x),s=(t.next.y-t.y)/(t.next.x-t.x);e=i-s}return e}function H1(r,t){const e=j1(r,t);if(!e)return t;const i=pp(e,r);return we(i,i.next),we(e,e.next)}function j1(r,t){let e=t;const i=r.x,s=r.y;let n=-1/0,o;if(Je(r,e))return e;do{if(Je(r,e.next))return e.next;if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){const c=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(c<=i&&c>n&&(n=c,o=e.x<e.next.x?e:e.next,c===i))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,u=o.y;let h=1/0;e=o;do{if(i>=e.x&&e.x>=l&&i!==e.x&&cp(s<u?i:n,s,l,u,s<u?n:i,s,e.x,e.y)){const c=Math.abs(s-e.y)/(i-e.x);kr(e,r)&&(c<h||c===h&&(e.x>o.x||e.x===o.x&&z1(o,e)))&&(o=e,h=c)}e=e.next}while(e!==a);return o}function z1(r,t){return J(r.prev,r,t.prev)<0&&J(t.next,r,r.next)<0}function V1(r,t,e,i){let s=r;do s.z===0&&(s.z=wo(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,W1(s)}function W1(r){let t,e=1;do{let i=r,s;r=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let u=0;u<e&&(a++,o=o.nextZ,!!o);u++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;i=o}n.nextZ=null,e*=2}while(t>1);return r}function wo(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Y1(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function cp(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function Ur(r,t,e,i,s,n,o,a){return!(r===o&&t===a)&&cp(r,t,e,i,s,n,o,a)}function K1(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!q1(r,t)&&(kr(r,t)&&kr(t,r)&&Z1(r,t)&&(J(r.prev,r,t.prev)||J(r,t.prev,t))||Je(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 Je(r,t){return r.x===t.x&&r.y===t.y}function dp(r,t,e,i){const s=is(J(r,t,e)),n=is(J(r,t,i)),o=is(J(e,i,r)),a=is(J(e,i,t));return!!(s!==n&&o!==a||s===0&&rs(r,e,t)||n===0&&rs(r,i,t)||o===0&&rs(e,r,i)||a===0&&rs(e,t,i))}function rs(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 is(r){return r>0?1:r<0?-1:0}function q1(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&dp(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function kr(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 Z1(r,t){let e=r,i=!1;const s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function pp(r,t){const e=Ro(r.i,r.x,r.y),i=Ro(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function fp(r,t,e,i){const s=Ro(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function $r(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 Ro(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function WC(r,t,e,i){const s=t&&t.length,n=s?t[0]*e:r.length;let o=Math.abs(Mo(r,0,n,e));if(s)for(let l=0,u=t.length;l<u;l++){const h=t[l]*e,c=l<u-1?t[l+1]*e:r.length;o-=Math.abs(Mo(r,h,c,e))}let a=0;for(let l=0;l<i.length;l+=3){const u=i[l]*e,h=i[l+1]*e,c=i[l+2]*e;a+=Math.abs((r[u]-r[c])*(r[h+1]-r[u+1])-(r[u]-r[h])*(r[c+1]-r[u+1]))}return o===0&&a===0?0:Math.abs((a-o)/o)}function Mo(r,t,e,i){let s=0;for(let n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}function YC(r){const t=[],e=[],i=r[0][0].length;let s=0,n=0;for(const o of r){for(const a of o)for(let l=0;l<i;l++)t.push(a[l]);n&&(s+=n,e.push(s)),n=o.length}return{vertices:t,holes:e,dimensions:i}}const mp=up.default||up;function Co(r,t,e,i,s,n,o){const a=mp(r,t,2);if(!a)return;for(let u=0;u<a.length;u+=3)n[o++]=a[u]+s,n[o++]=a[u+1]+s,n[o++]=a[u+2]+s;let l=s*i;for(let u=0;u<r.length;u+=2)e[l]=r[u],e[l+1]=r[u+1],l+=i}const Q1=[],gp={extension:{type:T.ShapeBuilder,name:"polygon"},build(r,t){for(let e=0;e<r.points.length;e++)t[e]=r.points[e];return!0},triangulate(r,t,e,i,s,n){Co(r,Q1,t,e,i,s,n)}},_p={extension:{type:T.ShapeBuilder,name:"rectangle"},build(r,t){const e=r,i=e.x,s=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=i,t[1]=s,t[2]=i+n,t[3]=s,t[4]=i+n,t[5]=s+o,t[6]=i,t[7]=s+o,!0):!1},triangulate(r,t,e,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[6],t[i+o+1]=r[7],o+=e,t[i+o]=r[4],t[i+o+1]=r[5],o+=e;const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2,s[n++]=a+1,s[n++]=a+3,s[n++]=a+2}},bp={extension:{type:T.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,i,s,n){let o=0;i*=e,t[i+o]=r[0],t[i+o+1]=r[1],o+=e,t[i+o]=r[2],t[i+o+1]=r[3],o+=e,t[i+o]=r[4],t[i+o+1]=r[5];const a=i/e;s[n++]=a,s[n++]=a+1,s[n++]=a+2}};var J1=Object.defineProperty,vp=Object.getOwnPropertySymbols,tS=Object.prototype.hasOwnProperty,eS=Object.prototype.propertyIsEnumerable,yp=(r,t,e)=>t in r?J1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xp=(r,t)=>{for(var e in t||(t={}))tS.call(t,e)&&yp(r,e,t[e]);if(vp)for(var e of vp(t))eS.call(t,e)&&yp(r,e,t[e]);return r};const Tp=[{offset:0,color:"white"},{offset:1,color:"black"}],Oo=class Vu{constructor(...t){this.uid=Y("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let i=rS(t);const s=i.type==="radial"?Vu.defaultRadialOptions:Vu.defaultLinearOptions;i=xp(xp({},s),Ut(i)),this._textureSize=i.textureSize,this._wrapMode=i.wrapMode,i.type==="radial"?(this.center=i.center,this.outerCenter=(e=i.outerCenter)!=null?e:this.center,this.innerRadius=i.innerRadius,this.outerRadius=i.outerRadius,this.scale=i.scale,this.rotation=i.rotation):(this.start=i.start,this.end=i.end),this.textureSpace=i.textureSpace,this.type=i.type,i.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:H.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:s}=this.end,n=i-t,o=s-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=t;t=i,i=g,n*=-1}if(o<0){const g=e;e=s,s=g,o*=-1}}const l=this.colorStops.length?this.colorStops:Tp,u=this._textureSize,{canvas:h,context:c}=Ap(u,1),p=a?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);Sp(p,l),c.fillStyle=p,c.fillRect(0,0,u,1),this.texture=new w({source:new ae({resource:h,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),m=Math.atan2(o,n),_=new M;_.scale(f/u,1),_.rotate(m),_.translate(t,e),this.textureSpace==="local"&&_.scale(u,u),this.transform=_}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Tp,e=this._textureSize,{canvas:i,context:s}=Ap(e,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,h=this.outerRadius,c=a-h,p=l-h,f=e/(h*2),m=(n-c)*f,_=(o-p)*f,g=s.createRadialGradient(m,_,u*f,(a-c)*f,(l-p)*f,h*f);Sp(g,t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=g,s.translate(m,_),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-m,-_),s.fillRect(0,0,e,e),this.texture=new w({source:new ae({resource:i,addressMode:this._wrapMode})});const b=new M;b.scale(1/f,1/f),b.translate(c,p),this.textureSpace==="local"&&b.scale(e,e),this.transform=b}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Oo.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},Oo.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let qt=Oo;function Sp(r,t){for(let e=0;e<t.length;e++){const i=t[e];r.addColorStop(i.offset,i.color)}}function Ap(r,t){const e=L.get().createCanvas(r,t),i=e.getContext("2d");return{canvas:e,context:i}}function rS(r){var t,e;let i=(t=r[0])!=null?t:{};return(typeof i=="number"||r[1])&&(i={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:(e=r[5])!=null?e:qt.defaultLinearOptions.textureSize}),i}const iS=new M,sS=new z;function Ep(r,t,e,i){const s=t.matrix?r.copyFrom(t.matrix).invert():r.identity();if(t.textureSpace==="local"){const o=e.getBounds(sS);t.width&&o.pad(t.width);const{x:a,y:l}=o,u=1/o.width,h=1/o.height,c=-a*u,p=-l*h,f=s.a,m=s.b,_=s.c,g=s.d;s.a*=u,s.b*=u,s.c*=h,s.d*=h,s.tx=c*f+p*_+s.tx,s.ty=c*m+p*g+s.ty}else s.translate(t.texture.frame.x,t.texture.frame.y),s.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof qt)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&s.append(iS.copyFrom(i).invert()),s}const tr={};F.handleByMap(T.ShapeBuilder,tr),F.add(_p,gp,bp,Qe,ip,sp);const nS=new z,oS=new M;function Pp(r,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let s=0;s<r.instructions.length;s++){const n=r.instructions[s];if(n.action==="texture")aS(n.data,i,e);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,u=n.data.hole;o&&u&&wp(u.shapePath,l,!0,i,e),u&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=u.shapePath.shapePrimitives),wp(a,l,o,i,e)}}}function aS(r,t,e){const i=[],s=tr.rectangle,n=nS;n.x=r.dx,n.y=r.dy,n.width=r.dw,n.height=r.dh;const o=r.transform;if(!s.build(n,i))return;const{vertices:a,uvs:l,indices:u}=e,h=u.length,c=a.length/2;o&&Qi(i,o),s.triangulate(i,a,2,c,u,h);const p=r.image,f=p.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const m=st.get(Ji);m.indexOffset=h,m.indexSize=u.length-h,m.attributeOffset=c,m.attributeSize=a.length/2-c,m.baseColor=r.style,m.alpha=r.alpha,m.texture=p,m.geometryData=e,t.push(m)}function wp(r,t,e,i,s){const{vertices:n,uvs:o,indices:a}=s;r.shapePrimitives.forEach(({shape:l,transform:u,holes:h})=>{var c;const p=[],f=tr[l.type];if(!f.build(l,p))return;const m=a.length,_=n.length/2;let g="triangle-list";if(u&&Qi(p,u),e){const x=(c=l.closePath)!=null?c:!0,A=t;A.pixelLine?(lp(p,x,n,a),g="line-list"):ap(p,A,!1,x,n,a)}else if(h){const x=[],A=p.slice();lS(h).forEach(S=>{x.push(A.length/2),A.push(...S)}),Co(A,x,n,2,_,a,m)}else f.triangulate(p,n,2,_,a,m);const b=o.length/2,y=t.texture;if(y!==w.WHITE){const x=Ep(oS,t,l,u);So(n,2,_,o,b,2,n.length/2-_,x)}else Ao(o,b,2,n.length/2-_);const v=st.get(Ji);v.indexOffset=m,v.indexSize=a.length-m,v.attributeOffset=_,v.attributeSize=n.length/2-_,v.baseColor=t.color,v.alpha=t.alpha,v.texture=y,v.geometryData=s,v.topology=g,i.push(v)})}function lS(r){const t=[];for(let e=0;e<r.length;e++){const i=r[e].shape,s=[];tr[i.type].build(i,s)&&t.push(s)}return t}class Rp{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class Mp{constructor(){this.instructions=new Bn}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Zi({maxTextures:e}),this.instructions.reset()}get geometry(){return this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const Go=class Wu{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(t){var e;Wu.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Wu.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),Pp(t,e);const i=t.batchMode;t.customShader||i==="no-batch"?e.isBatchable=!1:i==="auto"?e.isBatchable=e.geometryData.vertices.length<400:e.isBatchable=!0,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=st.get(Mp,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:s}=this._gpuContextHash[t.uid],n=s.vertices.length,o=s.indices.length;for(let h=0;h<i.length;h++)i[h].applyTransform=!1;const a=e.batcher;a.ensureAttributeBuffer(n),a.ensureIndexBuffer(o),a.begin();for(let h=0;h<i.length;h++){const c=i[h];a.add(c)}a.finish(e.instructions);const l=a.geometry;l.indexBuffer.setDataWithSize(a.indexBuffer,a.indexSize,!0),l.buffers[0].setDataWithSize(a.attributeBuffer.float32View,a.attributeSize,!0);const u=a.batches;for(let h=0;h<u.length;h++){const c=u[h];c.bindGroup=Li(c.textures.textures,c.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new Rp;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(st.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(i=>{st.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context);this._gpuContextHash={},this._graphicsDataContextHash={},this._renderer=null}};Go.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"graphicsContext"},Go.defaultOptions={bezierSmoothness:.5};let ss=Go;const uS={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},Bo=0,Io=1,Fo=2,Do=3,Uo=4,ko=5,$o=class $x{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Bo)}set blend(t){!!(this.data&1<<Bo)!==t&&(this.data^=1<<Bo)}get offsets(){return!!(this.data&1<<Io)}set offsets(t){!!(this.data&1<<Io)!==t&&(this.data^=1<<Io)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<Fo)}set culling(t){!!(this.data&1<<Fo)!==t&&(this.data^=1<<Fo)}get depthTest(){return!!(this.data&1<<Do)}set depthTest(t){!!(this.data&1<<Do)!==t&&(this.data^=1<<Do)}get depthMask(){return!!(this.data&1<<ko)}set depthMask(t){!!(this.data&1<<ko)!==t&&(this.data^=1<<ko)}get clockwiseFrontFace(){return!!(this.data&1<<Uo)}set clockwiseFrontFace(t){!!(this.data&1<<Uo)!==t&&(this.data^=1<<Uo)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=uS[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new $x;return t.depthTest=!1,t.blend=!0,t}};$o.default2d=$o.for2d();let wt=$o;function hS(r,t,e,i){e[i++]=(r>>16&255)/255,e[i++]=(r>>8&255)/255,e[i++]=(r&255)/255,e[i++]=t}function er(r,t,e){const i=(r>>24&255)/255;t[e++]=(r&255)/255*i,t[e++]=(r>>8&255)/255*i,t[e++]=(r>>16&255)/255*i,t[e++]=i}class Cp{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{st.return(t)}),this.batches.length=0}}class Lo{constructor(t,e){this.state=wt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,s=this.renderer.graphicsContext.updateGpuContext(e);return!!(s.isBatchable||i!==s.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let i=0;i<e.length;i++){const s=e[i];s._batcher.updateElement(s)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const s=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const n=s.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,er(t.groupColorAlpha,n.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(t).batches;for(let n=0;n<s.length;n++){const o=s[n];i.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Cp;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,s=this.renderer.graphicsContext.getGpuContext(i),n=this.renderer._roundPixels|t._roundPixels;e.batches=s.batches.map(o=>{const a=st.get(Ji);return o.copyTo(a),a.renderable=t,a.roundPixels=n,a})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Lo.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"graphics"},F.add(Lo),F.add(ss);class ns{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;const s=this.texture.textureMatrix;return s.isSimple||(i=this._transformedUvs,(this._textureMatrixUpdateId!==s._updateID||this._uvUpdateId!==t._updateID)&&((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=s._updateID,this._uvUpdateId=t._updateID,s.multiplyUvs(e,i))),i}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class No{destroy(){}}class Xo{constructor(t,e){this.localUniforms=new nt({uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Kt({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,s=t.batched;if(e.batched=s,i!==s)return!0;if(s){const n=t._geometry;if(n.indices.length!==e.indexSize||n.positions.length!==e.vertexSize)return e.indexSize=n.indices.length,e.vertexSize=n.positions.length,!0;const o=this._getBatchableMesh(t);return o.texture.uid!==t._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,t._texture)}return!1}addRenderable(t,e){var i,s;const n=this.renderer.renderPipes.batch,o=this._getMeshData(t);if(t.didViewUpdate&&(o.indexSize=(i=t._geometry.indices)==null?void 0:i.length,o.vertexSize=(s=t._geometry.positions)==null?void 0:s.length),o.batched){const a=this._getBatchableMesh(t);a.setTexture(t._texture),a.geometry=t._geometry,n.addToBatch(a,e)}else n.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=je(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),er(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new No),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new No),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new ns;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Xo.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"mesh"},F.add(Xo);class Op{execute(t,e){const i=t.state,s=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const o=s.gl,a=t.getBuffers(e);s.shader.bind(n),s.state.set(i),s.geometry.bind(a.geometry,n.glProgram);const l=a.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?o.UNSIGNED_SHORT:o.UNSIGNED_INT;o.drawElements(o.TRIANGLES,e.particleChildren.length*6,l,0)}}function Ho(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function Gp(r){return{dynamicUpdate:Bp(r,!0),staticUpdate:Bp(r,!1)}}function Bp(r,t){const e=[];e.push(`
|
|
|
|
var index = 0;
|
|
|
|
for (let i = 0; i < ps.length; ++i)
|
|
{
|
|
const p = ps[i];
|
|
|
|
`);let i=0;for(const n in r){const o=r[n];if(t!==o.dynamic)continue;e.push(`offset = index + ${i}`),e.push(o.code);const a=ie(o.format);i+=a.stride/4}e.push(`
|
|
index += stride * 4;
|
|
}
|
|
`),e.unshift(`
|
|
var stride = ${i};
|
|
`);const s=e.join(`
|
|
`);return new Function("ps","f32v","u32v",s)}class Ip{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e;const i=this._size=(e=t.size)!=null?e:1e3,s=t.properties;let n=0,o=0;for(const c in s){const p=s[c],f=ie(p.format);p.dynamic?o+=f.stride:n+=f.stride}this._dynamicStride=o/4,this._staticStride=n/4,this.staticAttributeBuffer=new Se(i*4*n),this.dynamicAttributeBuffer=new Se(i*4*o),this.indexBuffer=Ho(i);const a=new Ae;let l=0,u=0;this._staticBuffer=new bt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:X.VERTEX|X.COPY_DST}),this._dynamicBuffer=new bt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:X.VERTEX|X.COPY_DST});for(const c in s){const p=s[c],f=ie(p.format);p.dynamic?(a.addAttribute(p.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:l*4,format:p.format}),l+=f.size):(a.addAttribute(p.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:u*4,format:p.format}),u+=f.size)}a.addIndex(this.indexBuffer);const h=this.getParticleUpdate(s);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=a}getParticleUpdate(t){const e=cS(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return Gp(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new Se(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Se(this._size*this._dynamicStride*4*4),this.indexBuffer=Ho(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const i=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const s=this.staticAttributeBuffer;this._staticUpload(t,s.float32View,s.uint32View),this._staticBuffer.setDataWithSize(s.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function cS(r){const t=[];for(const e in r){const i=r[e];t.push(e,i.code,i.dynamic?"d":"s")}return t.join("_")}var Fp=`varying vec2 vUV;
|
|
varying vec4 vColor;
|
|
|
|
uniform sampler2D uTexture;
|
|
|
|
void main(void){
|
|
vec4 color = texture2D(uTexture, vUV) * vColor;
|
|
gl_FragColor = color;
|
|
}`,Dp=`attribute vec2 aVertex;
|
|
attribute vec2 aUV;
|
|
attribute vec4 aColor;
|
|
|
|
attribute vec2 aPosition;
|
|
attribute float aRotation;
|
|
|
|
uniform mat3 uTranslationMatrix;
|
|
uniform float uRound;
|
|
uniform vec2 uResolution;
|
|
uniform vec4 uColor;
|
|
|
|
varying vec2 vUV;
|
|
varying vec4 vColor;
|
|
|
|
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
{
|
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
}
|
|
|
|
void main(void){
|
|
float cosRotation = cos(aRotation);
|
|
float sinRotation = sin(aRotation);
|
|
float x = aVertex.x * cosRotation - aVertex.y * sinRotation;
|
|
float y = aVertex.x * sinRotation + aVertex.y * cosRotation;
|
|
|
|
vec2 v = vec2(x, y);
|
|
v = v + aPosition;
|
|
|
|
gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
|
|
|
if(uRound == 1.0)
|
|
{
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
}
|
|
|
|
vUV = aUV;
|
|
vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
|
|
}
|
|
`,jo=`
|
|
struct ParticleUniforms {
|
|
uTranslationMatrix:mat3x3<f32>,
|
|
uColor:vec4<f32>,
|
|
uRound:f32,
|
|
uResolution:vec2<f32>,
|
|
};
|
|
|
|
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
{
|
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
}
|
|
|
|
@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
|
|
|
|
@group(1) @binding(0) var uTexture: texture_2d<f32>;
|
|
@group(1) @binding(1) var uSampler : sampler;
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv : vec2<f32>,
|
|
@location(1) color : vec4<f32>,
|
|
};
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aVertex: vec2<f32>,
|
|
@location(1) aPosition: vec2<f32>,
|
|
@location(2) aUV: vec2<f32>,
|
|
@location(3) aColor: vec4<f32>,
|
|
@location(4) aRotation: f32,
|
|
) -> VSOutput {
|
|
|
|
let v = vec2(
|
|
aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),
|
|
aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
|
|
) + aPosition;
|
|
|
|
var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
|
|
|
if(uniforms.uRound == 1.0) {
|
|
position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);
|
|
}
|
|
|
|
let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;
|
|
|
|
return VSOutput(
|
|
position,
|
|
aUV,
|
|
vColor,
|
|
);
|
|
}
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>,
|
|
@location(1) color: vec4<f32>,
|
|
@builtin(position) position: vec4<f32>,
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
var sample = textureSample(uTexture, uSampler, uv) * color;
|
|
|
|
return sample;
|
|
}`;class Up extends Pt{constructor(){const t=vt.from({vertex:Dp,fragment:Fp}),e=dt.from({fragment:{source:jo,entryPoint:"mainFragment"},vertex:{source:jo,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:w.WHITE.source,uSampler:new At({}),uniforms:{uTranslationMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new H(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class zo{constructor(t,e){this.state=wt.for2d(),this.localUniforms=new nt({uTranslationMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new Up,this.state=wt.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new Ip({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const i=this.renderer,s=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;s.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=je(t.blendMode,t.texture._source);const o=this.localUniforms.uniforms,a=o.uTranslationMatrix;t.worldTransform.copyTo(a),a.prepend(i.globalUniforms.globalUniformData.projectionMatrix),o.uResolution=i.globalUniforms.globalUniformData.resolution,o.uRound=i._roundPixels|t._roundPixels,er(t.groupColorAlpha,o.uColor,0),this.adaptor.execute(this,t)}destroy(){this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class Vo extends zo{constructor(t){super(t,new Op)}}Vo.extension={type:[T.WebGLPipes],name:"particle"};class kp{execute(t,e){const i=t.renderer,s=e.shader||t.defaultShader;s.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=i.texture.getTextureBindGroup(e.texture);const n=t.state,o=t.getBuffers(e);i.encoder.draw({geometry:o.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}class Wo extends zo{constructor(t){super(t,new kp)}}Wo.extension={type:[T.WebGPUPipes],name:"particle"},F.add(Vo),F.add(Wo);function os(r,t){const{texture:e,bounds:i}=r,s=t._style._getFinalPadding();Qn(i,t._anchor,e);const n=t._anchor._x*s*2,o=t._anchor._y*s*2;i.minX-=s-n,i.minY-=s-o,i.maxX-=s-n,i.maxY-=s-o}class Lr{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){}}class $p extends Lr{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{canvasText:t}=this._renderer;t.getReferenceCount(this.currentKey)>0?t.decreaseReferenceCount(this.currentKey):this.texture&&t.returnTexture(this.texture),this._renderer.runners.resolutionChange.remove(this),this._renderer=null}}class Yo{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const s=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t.resolution!==s)&&this._updateGpuText(t),t._didTextUpdate=!1,os(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new $p(this._renderer);return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Yo.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"text"};const Lp={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 Nr{constructor(t,e){this.uid=Y("fillPattern"),this._tick=0,this.transform=new M,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Lp[e].addressModeU,t.source.style.addressModeV=Lp[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var dS=fS,Ko={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},pS=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function fS(r){var t=[];return r.replace(pS,function(e,i,s){var n=i.toLowerCase();for(s=gS(s),n=="m"&&s.length>2&&(t.push([i].concat(s.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(s.length==Ko[n])return s.unshift(i),t.push(s);if(s.length<Ko[n])throw new Error("malformed path data");t.push([i].concat(s.splice(0,Ko[n])))}}),t}var mS=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function gS(r){var t=r.match(mS);return t?t.map(Number):[]}var _S=rh(dS);function Np(r,t){const e=_S(r),i=[];let s=null,n=0,o=0;for(let a=0;a<e.length;a++){const l=e[a],u=l[0],h=l;switch(u){case"M":n=h[1],o=h[2],t.moveTo(n,o);break;case"m":n+=h[1],o+=h[2],t.moveTo(n,o);break;case"H":n=h[1],t.lineTo(n,o);break;case"h":n+=h[1],t.lineTo(n,o);break;case"V":o=h[1],t.lineTo(n,o);break;case"v":o+=h[1],t.lineTo(n,o);break;case"L":n=h[1],o=h[2],t.lineTo(n,o);break;case"l":n+=h[1],o+=h[2],t.lineTo(n,o);break;case"C":n=h[5],o=h[6],t.bezierCurveTo(h[1],h[2],h[3],h[4],n,o);break;case"c":t.bezierCurveTo(n+h[1],o+h[2],n+h[3],o+h[4],n+h[5],o+h[6]),n+=h[5],o+=h[6];break;case"S":n=h[3],o=h[4],t.bezierCurveToShort(h[1],h[2],n,o);break;case"s":t.bezierCurveToShort(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"Q":n=h[3],o=h[4],t.quadraticCurveTo(h[1],h[2],n,o);break;case"q":t.quadraticCurveTo(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"T":n=h[1],o=h[2],t.quadraticCurveToShort(n,o);break;case"t":n+=h[1],o+=h[2],t.quadraticCurveToShort(n,o);break;case"A":n=h[6],o=h[7],t.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"a":n+=h[6],o+=h[7],t.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"Z":case"z":t.closePath(),i.length>0&&(s=i.pop(),s?(n=s.startX,o=s.startY):(n=0,o=0)),s=null;break;default:}u!=="Z"&&u!=="z"&&s===null&&(s={startX:n,startY:o},i.push(s))}return t}class as{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new as(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}strokeContains(t,e,i,s=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,l=(1-s)*i,u=Math.sqrt(n*n+o*o);return u<=a+l&&u>a-(i-l)}getBounds(t){return t||(t=new z),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class ls{constructor(t=0,e=0,i=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=s}clone(){return new ls(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,s=(e-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(t,e,i,s=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-s),l=i-a,u=n-l,h=o-l,c=n+a,p=o+a,f=t-this.x,m=e-this.y,_=f*f/(u*u)+m*m/(h*h),g=f*f/(c*c)+m*m/(p*p);return _>1&&g<=1}getBounds(t){return t||(t=new z),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}}function Xr(r,t,e,i,s,n){const o=r-e,a=t-i,l=s-e,u=n-i,h=o*l+a*u,c=l*l+u*u;let p=-1;c!==0&&(p=h/c);let f,m;p<0?(f=e,m=i):p>1?(f=s,m=n):(f=e+p*l,m=i+p*u);const _=r-f,g=t-m;return _*_+g*g}let bS,vS;class rr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let s=0;s<i;s+=2){const n=e[s],o=e[s+1],a=e[(s+2)%i],l=e[(s+3)%i];t+=(a-n)*(l+o)}return t<0}containsPolygon(t){const e=this.getBounds(bS),i=t.getBounds(vS);if(!e.containsRect(i))return!1;const s=t.points;for(let n=0;n<s.length;n+=2){const o=s[n],a=s[n+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new rr(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],u=this.points[o*2],h=this.points[o*2+1];l>e!=h>e&&t<(u-a)*((e-l)/(h-l))+a&&(i=!i)}return i}strokeContains(t,e,i,s=.5){const n=i*i,o=n*(1-s),a=n-o,{points:l}=this,u=l.length-(this.closePath?0:2);for(let h=0;h<u;h+=2){const c=l[h],p=l[h+1],f=l[(h+2)%l.length],m=l[(h+3)%l.length],_=Xr(t,e,c,p,f,m),g=Math.sign((f-c)*(e-p)-(m-p)*(t-c));if(_<=(g<0?a:o))return!0}return!1}getBounds(t){t||(t=new z);const e=this.points;let i=1/0,s=-1/0,n=1/0,o=-1/0;for(let a=0,l=e.length;a<l;a+=2){const u=e[a],h=e[a+1];i=u<i?u:i,s=u>s?u:s,n=h<n?h:n,o=h>o?h:o}return t.x=i,t.width=s-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const us=(r,t,e,i,s,n,o)=>{const a=r-e,l=t-i,u=Math.sqrt(a*a+l*l);return u>=s-n&&u<=s+o};class hs{constructor(t=0,e=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n}getBounds(t){return t||(t=new z),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new hs(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}strokeContains(t,e,i,s=.5){const{x:n,y:o,width:a,height:l,radius:u}=this,h=i*(1-s),c=i-h,p=n+u,f=o+u,m=a-u*2,_=l-u*2,g=n+a,b=o+l;return(t>=n-h&&t<=n+c||t>=g-c&&t<=g+h)&&e>=f&&e<=f+_||(e>=o-h&&e<=o+c||e>=b-c&&e<=b+h)&&t>=p&&t<=p+m?!0:t<p&&e<f&&us(t,e,p,f,u,c,h)||t>g-u&&e<f&&us(t,e,g-u,f,u,c,h)||t>g-u&&e>b-u&&us(t,e,g-u,b-u,u,c,h)||t<p&&e>b-u&&us(t,e,p,b-u,u,c,h)}}const yS=8,cs=11920929e-14,xS=1,qo=.01,ir=0,Re=0;function Zo(r,t,e,i,s,n,o,a,l,u){const h=Math.min(.99,Math.max(0,u!=null?u:ss.defaultOptions.bezierSmoothness));let c=(xS-h)/1;return c*=c,TS(t,e,i,s,n,o,a,l,r,c),r}function TS(r,t,e,i,s,n,o,a,l,u){Qo(r,t,e,i,s,n,o,a,l,u,0),l.push(o,a)}function Qo(r,t,e,i,s,n,o,a,l,u,h){if(h>yS)return;const c=Math.PI,p=(r+e)/2,f=(t+i)/2,m=(e+s)/2,_=(i+n)/2,g=(s+o)/2,b=(n+a)/2,y=(p+m)/2,v=(f+_)/2,x=(m+g)/2,A=(_+b)/2,S=(y+x)/2,E=(v+A)/2;if(h>0){let C=o-r,O=a-t;const P=Math.abs((e-o)*O-(i-a)*C),R=Math.abs((s-o)*O-(n-a)*C);let U,k;if(P>cs&&R>cs){if((P+R)*(P+R)<=u*(C*C+O*O)){if(ir<qo){l.push(S,E);return}const B=Math.atan2(n-i,s-e);if(U=Math.abs(B-Math.atan2(i-t,e-r)),k=Math.abs(Math.atan2(a-n,o-s)-B),U>=c&&(U=2*c-U),k>=c&&(k=2*c-k),U+k<ir){l.push(S,E);return}if(Re!==0){if(U>Re){l.push(e,i);return}if(k>Re){l.push(s,n);return}}}}else if(P>cs){if(P*P<=u*(C*C+O*O)){if(ir<qo){l.push(S,E);return}if(U=Math.abs(Math.atan2(n-i,s-e)-Math.atan2(i-t,e-r)),U>=c&&(U=2*c-U),U<ir){l.push(e,i),l.push(s,n);return}if(Re!==0&&U>Re){l.push(e,i);return}}}else if(R>cs){if(R*R<=u*(C*C+O*O)){if(ir<qo){l.push(S,E);return}if(U=Math.abs(Math.atan2(a-n,o-s)-Math.atan2(n-i,s-e)),U>=c&&(U=2*c-U),U<ir){l.push(e,i),l.push(s,n);return}if(Re!==0&&U>Re){l.push(s,n);return}}}else if(C=S-(r+o)/2,O=E-(t+a)/2,C*C+O*O<=u){l.push(S,E);return}}Qo(r,t,p,f,y,v,S,E,l,u,h+1),Qo(S,E,x,A,g,b,o,a,l,u,h+1)}const SS=8,AS=11920929e-14,ES=1,PS=.01,Xp=0;function Hp(r,t,e,i,s,n,o,a){const l=Math.min(.99,Math.max(0,a!=null?a:ss.defaultOptions.bezierSmoothness));let u=(ES-l)/1;return u*=u,wS(t,e,i,s,n,o,r,u),r}function wS(r,t,e,i,s,n,o,a){Jo(o,r,t,e,i,s,n,a,0),o.push(s,n)}function Jo(r,t,e,i,s,n,o,a,l){if(l>SS)return;const u=Math.PI,h=(t+i)/2,c=(e+s)/2,p=(i+n)/2,f=(s+o)/2,m=(h+p)/2,_=(c+f)/2;let g=n-t,b=o-e;const y=Math.abs((i-n)*b-(s-o)*g);if(y>AS){if(y*y<=a*(g*g+b*b)){if(Xp<PS){r.push(m,_);return}let v=Math.abs(Math.atan2(o-s,n-i)-Math.atan2(s-e,i-t));if(v>=u&&(v=2*u-v),v<Xp){r.push(m,_);return}}}else if(g=m-(t+n)/2,b=_-(e+o)/2,g*g+b*b<=a){r.push(m,_);return}Jo(r,t,e,h,c,m,_,a,l+1),Jo(r,m,_,p,f,n,o,a,l+1)}function ta(r,t,e,i,s,n,o,a){let l=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(i,.3333333333333333)*(l/Math.PI)))),a=Math.max(a,3);let u=l/a,h=s;u*=o?-1:1;for(let c=0;c<a+1;c++){const p=Math.cos(h),f=Math.sin(h),m=t+p*i,_=e+f*i;r.push(m,_),h+=u}}function jp(r,t,e,i,s,n){const o=r[r.length-2],a=r[r.length-1]-e,l=o-t,u=s-e,h=i-t,c=Math.abs(a*h-l*u);if(c<1e-8||n===0){(r[r.length-2]!==t||r[r.length-1]!==e)&&r.push(t,e);return}const p=a*a+l*l,f=u*u+h*h,m=a*u+l*h,_=n*Math.sqrt(p)/c,g=n*Math.sqrt(f)/c,b=_*m/p,y=g*m/f,v=_*h+g*l,x=_*u+g*a,A=l*(g+b),S=a*(g+b),E=h*(_+y),C=u*(_+y),O=Math.atan2(S-x,A-v),P=Math.atan2(C-x,E-v);ta(r,v+t,x+e,n,O,P,l*u>h*a)}const Hr=Math.PI*2,ea={centerX:0,centerY:0,ang1:0,ang2:0},ra=({x:r,y:t},e,i,s,n,o,a,l)=>{r*=e,t*=i;const u=s*r-n*t,h=n*r+s*t;return l.x=u+o,l.y=h+a,l};function RS(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,s=Math.cos(r),n=Math.sin(r),o=Math.cos(r+t),a=Math.sin(r+t);return[{x:s-n*i,y:n+s*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const zp=(r,t,e,i)=>{const s=r*i-t*e<0?-1:1;let n=r*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),s*Math.acos(n)},MS=(r,t,e,i,s,n,o,a,l,u,h,c,p)=>{const f=Math.pow(s,2),m=Math.pow(n,2),_=Math.pow(h,2),g=Math.pow(c,2);let b=f*m-f*g-m*_;b<0&&(b=0),b/=f*g+m*_,b=Math.sqrt(b)*(o===a?-1:1);const y=b*s/n*c,v=b*-n/s*h,x=u*y-l*v+(r+e)/2,A=l*y+u*v+(t+i)/2,S=(h-y)/s,E=(c-v)/n,C=(-h-y)/s,O=(-c-v)/n,P=zp(1,0,S,E);let R=zp(S,E,C,O);a===0&&R>0&&(R-=Hr),a===1&&R<0&&(R+=Hr),p.centerX=x,p.centerY=A,p.ang1=P,p.ang2=R};function Vp(r,t,e,i,s,n,o,a=0,l=0,u=0){if(n===0||o===0)return;const h=Math.sin(a*Hr/360),c=Math.cos(a*Hr/360),p=c*(t-i)/2+h*(e-s)/2,f=-h*(t-i)/2+c*(e-s)/2;if(p===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const m=Math.pow(p,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),MS(t,e,i,s,n,o,l,u,h,c,p,f,ea);let{ang1:_,ang2:g}=ea;const{centerX:b,centerY:y}=ea;let v=Math.abs(g)/(Hr/4);Math.abs(1-v)<1e-7&&(v=1);const x=Math.max(Math.ceil(v),1);g/=x;let A=r[r.length-2],S=r[r.length-1];const E={x:0,y:0};for(let C=0;C<x;C++){const O=RS(_,g),{x:P,y:R}=ra(O[0],n,o,c,h,b,y,E),{x:U,y:k}=ra(O[1],n,o,c,h,b,y,E),{x:B,y:mt}=ra(O[2],n,o,c,h,b,y,E);Zo(r,A,S,P,R,U,k,B,mt),A=B,S=mt,_+=g}}function Wp(r,t,e){var i;const s=(a,l)=>{const u=l.x-a.x,h=l.y-a.y,c=Math.sqrt(u*u+h*h),p=u/c,f=h/c;return{len:c,nx:p,ny:f}},n=(a,l)=>{a===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let o=t[t.length-1];for(let a=0;a<t.length;a++){const l=t[a%t.length],u=(i=l.radius)!=null?i:e;if(u<=0){n(a,l),o=l;continue}const h=t[(a+1)%t.length],c=s(l,o),p=s(l,h);if(c.len<1e-4||p.len<1e-4){n(a,l),o=l;continue}let f=Math.asin(c.nx*p.ny-c.ny*p.nx),m=1,_=!1;c.nx*p.nx-c.ny*-p.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,m=-1,_=!0):f>0&&(m=-1,_=!0);const g=f/2;let b,y=Math.abs(Math.cos(g)*u/Math.sin(g));y>Math.min(c.len/2,p.len/2)?(y=Math.min(c.len/2,p.len/2),b=Math.abs(y*Math.sin(g)/Math.cos(g))):b=u;const v=l.x+p.nx*y+-p.ny*b*m,x=l.y+p.ny*y+p.nx*b*m,A=Math.atan2(c.ny,c.nx)+Math.PI/2*m,S=Math.atan2(p.ny,p.nx)-Math.PI/2*m;a===0&&r.moveTo(v+Math.cos(A)*b,x+Math.sin(A)*b),r.arc(v,x,b,A,S,_),o=l}}function Yp(r,t,e,i){var s;const n=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),o=(l,u,h)=>({x:l.x+(u.x-l.x)*h,y:l.y+(u.y-l.y)*h}),a=t.length;for(let l=0;l<a;l++){const u=t[(l+1)%a],h=(s=u.radius)!=null?s:e;if(h<=0){l===0?r.moveTo(u.x,u.y):r.lineTo(u.x,u.y);continue}const c=t[l],p=t[(l+2)%a],f=n(c,u);let m;if(f<1e-4)m=u;else{const b=Math.min(f/2,h);m=o(u,c,b/f)}const _=n(p,u);let g;if(_<1e-4)g=u;else{const b=Math.min(_/2,h);g=o(u,p,b/_)}l===0?r.moveTo(m.x,m.y):r.lineTo(m.x,m.y),r.quadraticCurveTo(u.x,u.y,g.x,g.y,i)}}const CS=new z;class Kp{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new ot,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}arc(t,e,i,s,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return ta(a,t,e,i,s,n,o),this}arcTo(t,e,i,s,n){this._ensurePoly();const o=this._currentPoly.points;return jp(o,t,e,i,s,n),this}arcToSvg(t,e,i,s,n,o,a){const l=this._currentPoly.points;return Vp(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o,a){this._ensurePoly();const l=this._currentPoly;return Zo(this._currentPoly.points,l.lastX,l.lastY,t,e,i,s,n,o,a),this}quadraticCurveTo(t,e,i,s,n){this._ensurePoly();const o=this._currentPoly;return Hp(this._currentPoly.points,o.lastX,o.lastY,t,e,i,s,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const i=this.shapePrimitives,s=i.length;for(let n=0;n<t.instructions.length;n++){const o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&i.length-s>1){let n=null;for(let o=s;o<i.length;o++){const a=i[o];if(a.shape.type==="polygon"){const l=a.shape,u=n==null?void 0:n.shape;u&&u.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),i.copyWithin(o,o+1),i.length--,o--):n=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,s,n){return this.drawShape(new z(t,e,i,s),n),this}circle(t,e,i,s){return this.drawShape(new as(t,e,i),s),this}poly(t,e,i){const s=new rr(t);return s.closePath=e,this.drawShape(s,i),this}regularPoly(t,e,i,s,n=0,o){s=Math.max(s|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/s,u=[];for(let h=0;h<s;h++){const c=a-h*l;u.push(t+i*Math.cos(c),e+i*Math.sin(c))}return this.poly(u,!0,o),this}roundPoly(t,e,i,s,n,o=0,a){if(s=Math.max(s|0,3),n<=0)return this.regularPoly(t,e,i,s,o);const l=i*Math.sin(Math.PI/s)-.001;n=Math.min(n,l);const u=-1*Math.PI/2+o,h=Math.PI*2/s,c=(s-2)*Math.PI/s/2;for(let p=0;p<s;p++){const f=p*h+u,m=t+i*Math.cos(f),_=e+i*Math.sin(f),g=f+Math.PI+c,b=f-Math.PI-c,y=m+n*Math.cos(g),v=_+n*Math.sin(g),x=m+n*Math.cos(b),A=_+n*Math.sin(b);p===0?this.moveTo(y,v):this.lineTo(y,v),this.quadraticCurveTo(m,_,x,A,a)}return this.closePath()}roundShape(t,e,i=!1,s){return t.length<3?this:(i?Yp(this,t,e,s):Wp(this,t,e),this.closePath())}filletRect(t,e,i,s,n){if(n===0)return this.rect(t,e,i,s);const o=Math.min(i,s)/2,a=Math.min(o,Math.max(-o,n)),l=t+i,u=e+s,h=a<0?-a:0,c=Math.abs(a);return this.moveTo(t,e+c).arcTo(t+h,e+h,t+c,e,c).lineTo(l-c,e).arcTo(l-h,e+h,l,e+c,c).lineTo(l,u-c).arcTo(l-h,u-h,t+i-c,u,c).lineTo(t+c,u).arcTo(t+h,u-h,t,u-c,c).closePath()}chamferRect(t,e,i,s,n,o){if(n<=0)return this.rect(t,e,i,s);const a=Math.min(n,Math.min(i,s)/2),l=t+i,u=e+s,h=[t+a,e,l-a,e,l,e+a,l,u-a,l-a,u,t+a,u,t,u-a,t,e+a];for(let c=h.length-1;c>=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,i,s,n){return this.drawShape(new ls(t,e,i,s),n),this}roundRect(t,e,i,s,n,o){return this.drawShape(new hs(t,e,i,s,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new rr,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new rr,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,s=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*s+n.tx,s=n.b*o+n.d*s+n.ty}this._currentPoly.points.push(i,s)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let i=0;i<e.length;i++){const s=e[i],n=s.shape.getBounds(CS);s.transform?t.addRect(n,s.transform):t.addRect(n)}return t}}class Lt{constructor(t,e=!1){this.instructions=[],this.uid=Y("graphicsPath"),this._dirty=!0;var i;this.checkForHoles=e,typeof t=="string"?Np(t,this):this.instructions=(i=t==null?void 0:t.slice())!=null?i:[]}get shapePath(){return this._shapePath||(this._shapePath=new Kp(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,i,s,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(W.shared);let l=0,u=0;if(!o||o.action!=="bezierCurveTo")l=a.x,u=a.y;else{l=o.data[2],u=o.data[3];const h=a.x,c=a.y;l=h+(h-l),u=c+(c-u)}return this.instructions.push({action:"bezierCurveTo",data:[l,u,t,e,i,s,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,i){const s=this.instructions[this.instructions.length-1],n=this.getLastPoint(W.shared);let o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=s.data[0],a=s.data[1];const l=n.x,u=n.y;o=l+(l-o),a=u+(u-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,i]}),this._dirty=!0,this}rect(t,e,i,s,n){return this.instructions.push({action:"rect",data:[t,e,i,s,n]}),this._dirty=!0,this}circle(t,e,i,s){return this.instructions.push({action:"circle",data:[t,e,i,s]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,i,s,n,o,a){n||(n=s/2);const l=-1*Math.PI/2+o,u=i*2,h=Math.PI*2/u,c=[];for(let p=0;p<u;p++){const f=p%2?n:s,m=p*h+l;c.push(t+f*Math.cos(m),e+f*Math.sin(m))}return this.poly(c,!0,a),this}clone(t=!1){const e=new Lt;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let i=0;i<this.instructions.length;i++){const s=this.instructions[i];e.instructions.push({action:s.action,data:s.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,i=t.b,s=t.c,n=t.d,o=t.tx,a=t.ty;let l=0,u=0,h=0,c=0,p=0,f=0,m=0,_=0;for(let g=0;g<this.instructions.length;g++){const b=this.instructions[g],y=b.data;switch(b.action){case"moveTo":case"lineTo":l=y[0],u=y[1],y[0]=e*l+s*u+o,y[1]=i*l+n*u+a;break;case"bezierCurveTo":h=y[0],c=y[1],p=y[2],f=y[3],l=y[4],u=y[5],y[0]=e*h+s*c+o,y[1]=i*h+n*c+a,y[2]=e*p+s*f+o,y[3]=i*p+n*f+a,y[4]=e*l+s*u+o,y[5]=i*l+n*u+a;break;case"quadraticCurveTo":h=y[0],c=y[1],l=y[2],u=y[3],y[0]=e*h+s*c+o,y[1]=i*h+n*c+a,y[2]=e*l+s*u+o,y[3]=i*l+n*u+a;break;case"arcToSvg":l=y[5],u=y[6],m=y[0],_=y[1],y[0]=e*m+s*_,y[1]=i*m+n*_,y[5]=e*l+s*u+o,y[6]=i*l+n*u+a;break;case"circle":y[4]=jr(y[3],t);break;case"rect":y[4]=jr(y[4],t);break;case"ellipse":y[8]=jr(y[8],t);break;case"roundRect":y[5]=jr(y[5],t);break;case"addPath":y[0].transform(t);break;case"poly":y[2]=jr(y[2],t);break;default:break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,i=this.instructions[e];if(!i)return t.x=0,t.y=0,t;for(;i.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;i=this.instructions[e]}switch(i.action){case"moveTo":case"lineTo":t.x=i.data[0],t.y=i.data[1];break;case"quadraticCurveTo":t.x=i.data[2],t.y=i.data[3];break;case"bezierCurveTo":t.x=i.data[4],t.y=i.data[5];break;case"arc":case"arcToSvg":t.x=i.data[5],t.y=i.data[6];break;case"addPath":i.data[0].getLastPoint(t);break}return t}}function jr(r,t){return r?r.prepend(t):t.clone()}let ia=0;const qp=500;function Zt(...r){ia!==qp&&(ia++,ia===qp?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}function tt(r,t,e){const i=r.getAttribute(t);return i?Number(i):e}function Zp(r,t){const e=r.querySelectorAll("defs");for(let i=0;i<e.length;i++){const s=e[i];for(let n=0;n<s.children.length;n++){const o=s.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=OS(o);break;case"radialgradient":t.defs[o.id]=GS(o);break;default:break}}}}function OS(r){const t=tt(r,"x1",0),e=tt(r,"y1",0),i=tt(r,"x2",1),s=tt(r,"y2",0),n=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new qt(t,e,i,s,n==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const l=r.children[a],u=tt(l,"offset",0),h=H.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(u,h)}return o}function GS(r){return new qt(0,0,1,0)}function sa(r){const t=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const na={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function oa(r,t){const e=r.getAttribute("style"),i={},s={},n={strokeStyle:i,fillStyle:s,useFill:!1,useStroke:!1};for(const o in na){const a=r.getAttribute(o);a&&Qp(t,n,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[u,h]=l.split(":");na[u]&&Qp(t,n,u,h.trim())}}return{strokeStyle:n.useStroke?i:null,fillStyle:n.useFill?s:null,useFill:n.useFill,useStroke:n.useStroke}}function Qp(r,t,e,i){switch(e){case"stroke":if(i!=="none"){if(i.startsWith("url(")){const s=sa(i);t.strokeStyle.fill=r.defs[s]}else t.strokeStyle.color=H.shared.setValue(i).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(i);break;case"fill":if(i!=="none"){if(i.startsWith("url(")){const s=sa(i);t.fillStyle.fill=r.defs[s]}else t.fillStyle.color=H.shared.setValue(i).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(i);break;case"stroke-opacity":t.strokeStyle.alpha=Number(i);break;case"opacity":t.fillStyle.alpha=Number(i),t.strokeStyle.alpha=Number(i);break}}function Jp(r){if(r.length<=2)return!0;const t=r.map(a=>a.area).sort((a,l)=>l-a),[e,i]=t,s=t[t.length-1],n=e/i,o=i/s;return!(n>3&&o<2)}function BS(r,t=0){const e=r.instructions[t];if(!e||e.action!=="fill")throw new Error(`Expected fill instruction at index ${t}, got ${(e==null?void 0:e.action)||"undefined"}`);return e.data}function tf(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function ef(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],s=[];for(let u=0;u<e.length;u+=2)u+1<e.length&&(i.push(e[u]),s.push(e[u+1]));if(i.length===0||s.length===0)return 0;const n=Math.min(...i),o=Math.max(...i),a=Math.min(...s),l=Math.max(...s);return(o-n)*(l-a)}function aa(r,t){const e=new Lt(r,!1);for(const i of e.instructions)t.instructions.push(i)}var IS=Object.defineProperty,rf=Object.getOwnPropertySymbols,FS=Object.prototype.hasOwnProperty,DS=Object.prototype.propertyIsEnumerable,sf=(r,t,e)=>t in r?IS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ds=(r,t)=>{for(var e in t||(t={}))FS.call(t,e)&&sf(r,e,t[e]);if(rf)for(var e of rf(t))DS.call(t,e)&&sf(r,e,t[e]);return r};function nf(r,t){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const e={context:t,defs:{},path:new Lt};Zp(r,e);const i=r.children,{fillStyle:s,strokeStyle:n}=oa(r,e);for(let o=0;o<i.length;o++){const a=i[o];a.nodeName.toLowerCase()!=="defs"&&of(a,e,s,n)}return t}function of(r,t,e,i){const s=r.children,{fillStyle:n,strokeStyle:o}=oa(r,t);n&&e?e=ds(ds({},e),n):n&&(e=n),o&&i?i=ds(ds({},i),o):o&&(i=o);const a=!e&&!i;a&&(e={color:0});let l,u,h,c,p,f,m,_,g,b,y,v,x,A,S,E,C;switch(r.nodeName.toLowerCase()){case"path":{A=r.getAttribute("d");const O=r.getAttribute("fill-rule"),P=tf(A),R=O==="evenodd",U=P.length>1;if(R&&U){const k=P.map(B=>({path:B,area:ef(B)}));if(k.sort((B,mt)=>mt.area-B.area),P.length>3||!Jp(k))for(let B=0;B<k.length;B++){const mt=k[B],I=B===0;t.context.beginPath();const D=new Lt(void 0,!0);aa(mt.path,D),t.context.path(D),I?(e&&t.context.fill(e),i&&t.context.stroke(i)):t.context.cut()}else for(let B=0;B<k.length;B++){const mt=k[B],I=B%2===1;t.context.beginPath();const D=new Lt(void 0,!0);aa(mt.path,D),t.context.path(D),I?t.context.cut():(e&&t.context.fill(e),i&&t.context.stroke(i))}}else{const k=O?O==="evenodd":!0;S=new Lt(A,k),t.context.path(S),e&&t.context.fill(e),i&&t.context.stroke(i)}break}case"circle":m=tt(r,"cx",0),_=tt(r,"cy",0),g=tt(r,"r",0),t.context.ellipse(m,_,g,g),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"rect":l=tt(r,"x",0),u=tt(r,"y",0),E=tt(r,"width",0),C=tt(r,"height",0),b=tt(r,"rx",0),y=tt(r,"ry",0),b||y?t.context.roundRect(l,u,E,C,b||y):t.context.rect(l,u,E,C),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"ellipse":m=tt(r,"cx",0),_=tt(r,"cy",0),b=tt(r,"rx",0),y=tt(r,"ry",0),t.context.beginPath(),t.context.ellipse(m,_,b,y),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"line":h=tt(r,"x1",0),c=tt(r,"y1",0),p=tt(r,"x2",0),f=tt(r,"y2",0),t.context.beginPath(),t.context.moveTo(h,c),t.context.lineTo(p,f),i&&t.context.stroke(i);break;case"polygon":x=r.getAttribute("points"),v=x.match(/\d+/g).map(O=>parseInt(O,10)),t.context.poly(v,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":x=r.getAttribute("points"),v=x.match(/\d+/g).map(O=>parseInt(O,10)),t.context.poly(v,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{Zt(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(e=null);for(let O=0;O<s.length;O++)of(s[O],t,e,i)}var US=Object.defineProperty,ps=Object.getOwnPropertySymbols,af=Object.prototype.hasOwnProperty,lf=Object.prototype.propertyIsEnumerable,uf=(r,t,e)=>t in r?US(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nt=(r,t)=>{for(var e in t||(t={}))af.call(t,e)&&uf(r,e,t[e]);if(ps)for(var e of ps(t))lf.call(t,e)&&uf(r,e,t[e]);return r},kS=(r,t)=>{var e={};for(var i in r)af.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ps)for(var i of ps(r))t.indexOf(i)<0&&lf.call(r,i)&&(e[i]=r[i]);return e};function $S(r){return H.isColorLike(r)}function hf(r){return r instanceof Nr}function cf(r){return r instanceof qt}function LS(r){return r instanceof w}function NS(r,t,e){const i=H.shared.setValue(t!=null?t:0);return r.color=i.toNumber(),r.alpha=i.alpha===1?e.alpha:i.alpha,r.texture=w.WHITE,Nt(Nt({},e),r)}function XS(r,t,e){return r.texture=t,Nt(Nt({},e),r)}function df(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,Nt(Nt({},e),r)}function pf(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,Nt(Nt({},e),r)}function HS(r,t){const e=Nt(Nt({},t),r),i=H.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function le(r,t){if(r==null)return null;const e={},i=r;return $S(r)?NS(e,r,t):LS(r)?XS(e,r,t):hf(r)?df(e,r,t):cf(r)?pf(e,r,t):i.fill&&hf(i.fill)?df(i,i.fill,t):i.fill&&cf(i.fill)?pf(i,i.fill,t):HS(i,t)}function zr(r,t){const e=t,{width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l}=e,u=kS(e,["width","alignment","miterLimit","cap","join","pixelLine"]),h=le(r,u);return h?Nt({width:i,alignment:s,miterLimit:n,cap:o,join:a,pixelLine:l},h):null}var jS=Object.defineProperty,ff=Object.getOwnPropertySymbols,zS=Object.prototype.hasOwnProperty,VS=Object.prototype.propertyIsEnumerable,mf=(r,t,e)=>t in r?jS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sr=(r,t)=>{for(var e in t||(t={}))zS.call(t,e)&&mf(r,e,t[e]);if(ff)for(var e of ff(t))VS.call(t,e)&&mf(r,e,t[e]);return r};const WS=new W,gf=new M,la=class te extends gt{constructor(){super(...arguments),this.uid=Y("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new Lt,this._transform=new M,this._fillStyle=sr({},te.defaultFillStyle),this._strokeStyle=sr({},te.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new ot,this._boundsDirty=!0}clone(){const t=new te;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=sr({},this._fillStyle),t._strokeStyle=sr({},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=le(t,te.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=zr(t,te.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=le(t,te.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=le(t,te.defaultStrokeStyle),this}texture(t,e,i,s,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:s||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?H.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Lt,this}fill(t,e){let i;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="stroke"?i=s.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=le(t,te.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(W.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=zr(t,te.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,s,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,i,s,n,o),this}arcTo(t,e,i,s,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}arcToSvg(t,e,i,s,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,i,s,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,i,s,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*i+l.c*s+l.tx,l.b*i+l.d*s+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,s){return this._tick++,this._activePath.ellipse(t,e,i,s,this._transform.clone()),this}circle(t,e,i){return this._tick++,this._activePath.circle(t,e,i,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const i=this._transform;return this._activePath.lineTo(i.a*t+i.c*e+i.tx,i.b*t+i.d*e+i.ty),this}moveTo(t,e){this._tick++;const i=this._transform,s=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,o=i.b*t+i.d*e+i.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=n,s[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,i,s,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*i+o.c*s+o.tx,o.b*i+o.d*s+o.ty,n),this}rect(t,e,i,s){return this._tick++,this._activePath.rect(t,e,i,s,this._transform.clone()),this}roundRect(t,e,i,s,n){return this._tick++,this._activePath.roundRect(t,e,i,s,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,s,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,i,s,n,o),this}roundPoly(t,e,i,s,n,o){return this._tick++,this._activePath.roundPoly(t,e,i,s,n,o),this}roundShape(t,e,i,s){return this._tick++,this._activePath.roundShape(t,e,i,s),this}filletRect(t,e,i,s,n){return this._tick++,this._activePath.filletRect(t,e,i,s,n),this}chamferRect(t,e,i,s,n,o){return this._tick++,this._activePath.chamferRect(t,e,i,s,n,o),this}star(t,e,i,s,n=0,o=0){return this._tick++,this._activePath.star(t,e,i,s,n,o,this._transform.clone()),this}svg(t){return this._tick++,nf(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:sr({},this._fillStyle),strokeStyle:sr({},this._strokeStyle)}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,i,s,n,o){return t instanceof M?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,s,n,o),this)}transform(t,e,i,s,n,o){return t instanceof M?(this._transform.append(t),this):(gf.set(t,e,i,s,n,o),this._transform.append(gf),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,!this.dirty&&(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],s=i.action;if(s==="fill"){const n=i.data;t.addBounds(n.path.bounds)}else if(s==="texture"){const n=i.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(s==="stroke"){const n=i.data,o=n.style.alignment,a=n.style.width*(1-o),l=n.path.bounds;t.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return t}containsPoint(t){var e;if(!this.bounds.containsPoint(t.x,t.y))return!1;const i=this.instructions;let s=!1;for(let n=0;n<i.length;n++){const o=i[n],a=o.data,l=a.path;if(!o.action||!l)continue;const u=a.style,h=l.shapePath.shapePrimitives;for(let c=0;c<h.length;c++){const p=h[c].shape;if(!u||!p)continue;const f=h[c].transform,m=f?f.applyInverse(t,WS):t;if(o.action==="fill")s=p.contains(m.x,m.y);else{const g=u;s=p.strokeContains(m.x,m.y,g.width,g.alignment)}const _=a.hole;if(_){const g=(e=_.shapePath)==null?void 0:e.shapePrimitives;if(g)for(let b=0;b<g.length;b++)g[b].shape.contains(m.x,m.y)&&(s=!1)}if(s)return!0}}return s}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};la.defaultFillStyle={color:16777215,alpha:1,texture:w.WHITE,matrix:null,fill:null,textureSpace:"local"},la.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:w.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let pt=la;var YS=Object.defineProperty,KS=Object.defineProperties,qS=Object.getOwnPropertyDescriptors,_f=Object.getOwnPropertySymbols,ZS=Object.prototype.hasOwnProperty,QS=Object.prototype.propertyIsEnumerable,bf=(r,t,e)=>t in r?YS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rt=(r,t)=>{for(var e in t||(t={}))ZS.call(t,e)&&bf(r,e,t[e]);if(_f)for(var e of _f(t))QS.call(t,e)&&bf(r,e,t[e]);return r},JS=(r,t)=>KS(r,qS(t));const ua=class _r extends gt{constructor(t={}){super(),this.uid=Y("textStyle"),this._tick=0,t2(t);const e=Rt(Rt({},_r.defaultTextStyle),t);for(const i in e){const s=i;this[s]=e[i]}this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(Rt(Rt({},_r.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Rt({},_r.defaultDropShadow)):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy(Rt(Rt({},pt.defaultFillStyle),t),()=>{this._fill=le(Rt({},this._originalFill),pt.defaultFillStyle)})),this._fill=le(t===0?"black":t,pt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Rt(Rt({},pt.defaultStrokeStyle),t),()=>{this._stroke=zr(Rt({},this._originalStroke),pt.defaultStrokeStyle)})),this._stroke=zr(t,pt.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const t=_r.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new _r({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Rt({},this._dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var e,i,s,n;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(e=this._fill)!=null&&e.texture&&this._fill.texture.destroy(o),(i=this._originalFill)!=null&&i.texture&&this._originalFill.texture.destroy(o),(s=this._stroke)!=null&&s.texture&&this._stroke.texture.destroy(o),(n=this._originalStroke)!=null&&n.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(i,s,n)=>(i[s]===n||(i[s]=n,e==null||e(s,n),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(H.isColorLike(t)||t instanceof qt||t instanceof Nr)}};ua.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},ua.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Mt=ua;function t2(r){var t,e,i,s,n;const o=r;if(typeof o.dropShadow=="boolean"&&o.dropShadow){const a=Mt.defaultDropShadow;r.dropShadow={alpha:(t=o.dropShadowAlpha)!=null?t:a.alpha,angle:(e=o.dropShadowAngle)!=null?e:a.angle,blur:(i=o.dropShadowBlur)!=null?i:a.blur,color:(s=o.dropShadowColor)!=null?s:a.color,distance:(n=o.dropShadowDistance)!=null?n:a.distance}}if(o.strokeThickness!==void 0){const a=o.stroke;let l={};if(H.isColorLike(a))l.color=a;else if(a instanceof qt||a instanceof Nr)l.fill=a;else if(Object.hasOwnProperty.call(a,"color")||Object.hasOwnProperty.call(a,"fill"))l=a;else throw new Error("Invalid stroke value.");r.stroke=JS(Rt({},l),{width:o.strokeThickness})}if(Array.isArray(o.fillGradientStops)){if(!Array.isArray(o.fill)||o.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");o.fill.length,o.fillGradientStops.length;const a=new qt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=o.fillGradientStops.slice(),u=o.fill.map(h=>H.shared.setValue(h).toNumber());l.forEach((h,c)=>{a.addColorStop(h,u[c])}),r.fill={fill:a}}}const e2=new ot;function ha(r,t,e,i){const s=e2;s.minX=0,s.minY=0,s.maxX=r.width/i|0,s.maxY=r.height/i|0;const n=et.getOptimalTexture(s.width,s.height,i,!1);return n.source.uploadMethodId="image",n.source.resource=r,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=t/i,n.frame.height=e/i,n.source.emit("update",n.source),n.updateUvs(),n}class vf{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=L.get().createCanvas();i.width=t,i.height=e;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=ge(t),e=ge(e);const s=(t<<17)+(e<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:s}=e,n=(i<<17)+(s<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,s),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Qt=new vf;me.register(Qt);let Me=null,se=null;function r2(r,t){Me||(Me=L.get().createCanvas(256,128),se=Me.getContext("2d",{willReadFrequently:!0}),se.globalCompositeOperation="copy",se.globalAlpha=1),(Me.width<r||Me.height<t)&&(Me.width=ge(r),Me.height=ge(t))}function yf(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function xf(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function Tf(...r){var t,e,i;let s=r[0];s.canvas||(s={canvas:r[0],resolution:r[1]});const{canvas:n}=s,o=Math.min((t=s.resolution)!=null?t:1,1),a=(e=s.width)!=null?e:n.width,l=(i=s.height)!=null?i:n.height;let u=s.output;if(r2(a,l),!se)throw new TypeError("Failed to get canvas 2D context");se.drawImage(n,0,0,a,l,0,0,a*o,l*o);const h=se.getImageData(0,0,a,l).data;let c=0,p=0,f=a-1,m=l-1;for(;p<l&&yf(h,a,p);)++p;if(p===l)return z.EMPTY;for(;yf(h,a,m);)--m;for(;xf(h,a,c,p,m);)++c;for(;xf(h,a,f,p,m);)--f;return++f,++m,se.globalCompositeOperation="source-over",se.strokeRect(c,p,f-c,m-p),se.globalCompositeOperation="copy",u!=null||(u=new z),u.set(c/o,p/o,(f-c)/o,(m-p)/o),u}/**
|
|
* tiny-lru
|
|
*
|
|
* @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
* @license BSD-3-Clause
|
|
* @version 11.4.5
|
|
*/class i2{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(e=>[e,this.get(e)])}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=[];let e=this.first;for(;e!==null;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let s=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(s=Ox({},this.first),this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return s}set(t,e,i=!1,s=this.resetTtl){let n=this.items[t];return i||n!==void 0?(n.value=e,i===!1&&s&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){return t.map(e=>this.get(e))}}function Sf(r=1e3,t=0,e=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new i2(r,t,e)}const s2=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Vr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!s2.includes(s)&&(s=`"${s}"`),e[i]=s}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const ca={willReadFrequently:!0},Xt=class G{static get experimentalLetterSpacingSupported(){let t=G._experimentalLetterSpacingSupported;if(t===void 0){const e=L.get().getCanvasRenderingContext2D().prototype;t=G._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,u){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=u}static measureText(t=" ",e,i=G._canvas,s=e.wordWrap){var n;const o=`${t}-${e.styleKey}-wordWrap-${s}`;if(G._measurementCache.has(o))return G._measurementCache.get(o);const a=Vr(e),l=G.measureFont(a);l.fontSize===0&&(l.fontSize=e.fontSize,l.ascent=e.fontSize);const u=G.__context;u.font=a;const h=(s?G._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),c=new Array(h.length);let p=0;for(let y=0;y<h.length;y++){const v=G._measureText(h[y],e.letterSpacing,u);c[y]=v,p=Math.max(p,v)}const f=((n=e._stroke)==null?void 0:n.width)||0;let m=p+f;e.dropShadow&&(m+=e.dropShadow.distance);const _=e.lineHeight||l.fontSize;let g=Math.max(_,l.fontSize+f)+(h.length-1)*(_+e.leading);e.dropShadow&&(g+=e.dropShadow.distance);const b=new G(t,e,m,g,h,c,_+e.leading,p,l);return G._measurementCache.set(o,b),b}static _measureText(t,e,i){let s=!1;G.experimentalLetterSpacingSupported&&(G.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const n=i.measureText(t);let o=n.width;const a=-n.actualBoundingBoxLeft;let l=n.actualBoundingBoxRight-a;if(o>0)if(s)o-=e,l-=e;else{const u=(G.graphemeSegmenter(t).length-1)*e;o+=u,l+=u}return Math.max(o,l)}static _wordWrap(t,e,i=G._canvas){const s=i.getContext("2d",ca);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:u,whiteSpace:h}=e,c=G._collapseSpaces(h),p=G._collapseNewlines(h);let f=!c;const m=e.wordWrapWidth+u,_=G._tokenize(t);for(let g=0;g<_.length;g++){let b=_[g];if(G._isNewline(b)){if(!p){a+=G._addLine(o),f=!c,o="",n=0;continue}b=" "}if(c){const v=G.isBreakingSpace(b),x=G.isBreakingSpace(o[o.length-1]);if(v&&x)continue}const y=G._getFromCache(b,u,l,s);if(y>m)if(o!==""&&(a+=G._addLine(o),o="",n=0),G.canBreakWords(b,e.breakWords)){const v=G.wordWrapSplit(b);for(let x=0;x<v.length;x++){let A=v[x],S=A,E=1;for(;v[x+E];){const O=v[x+E];if(!G.canBreakChars(S,O,b,x,e.breakWords))A+=O;else break;S=O,E++}x+=E-1;const C=G._getFromCache(A,u,l,s);C+n>m&&(a+=G._addLine(o),f=!1,o="",n=0),o+=A,n+=C}}else{o.length>0&&(a+=G._addLine(o),o="",n=0);const v=g===_.length-1;a+=G._addLine(b,!v),f=!1,o="",n=0}else y+n>m&&(f=!1,a+=G._addLine(o),o="",n=0),(o.length>0||!G.isBreakingSpace(b)||f)&&(o+=b,n+=y)}return a+=G._addLine(o,!1),a}static _addLine(t,e=!0){return t=G._trimRight(t),t=e?`${t}
|
|
`:t,t}static _getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=G._measureText(t,e,s)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!G.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:G._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:G._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(G.isBreakingSpace(n,o)||G._isNewline(n)){i!==""&&(e.push(i),i=""),n==="\r"&&o===`
|
|
`?(e.push(`\r
|
|
`),s++):e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return G.graphemeSegmenter(t)}static measureFont(t){if(G._fonts[t])return G._fonts[t];const e=G._context;e.font=t;const i=e.measureText(G.METRICS_STRING+G.BASELINE_SYMBOL),s={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return G._fonts[t]=s,s}static clearMetrics(t=""){t?delete G._fonts[t]:G._fonts={}}static get _canvas(){if(!G.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",ca);if(i!=null&&i.measureText)return G.__canvas=e,e;t=L.get().createCanvas()}catch(e){t=L.get().createCanvas()}t.width=t.height=10,G.__canvas=t}return G.__canvas}static get _context(){return G.__context||(G.__context=G._canvas.getContext("2d",ca)),G.__context}};Xt.METRICS_STRING="|\xC9q\xC5",Xt.BASELINE_SYMBOL="M",Xt.BASELINE_MULTIPLIER=1.4,Xt.HEIGHT_MULTIPLIER=2,Xt.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),i=[];let s=0;for(const n of e)i[s++]=n.segment;return i}}return r=>[...r]})(),Xt.experimentalLetterSpacing=!1,Xt._fonts={},Xt._newlines=[10,13],Xt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Xt._measurementCache=Sf(1e3);let ct=Xt;const Af=1e5;function Wr(r,t,e,i=0){var s;if(r.texture===w.WHITE&&!r.fill)return H.shared.setValue(r.color).setAlpha((s=r.alpha)!=null?s:1).toHexa();if(r.fill){if(r.fill instanceof Nr){const n=r.fill,o=t.createPattern(n.texture.source.resource,"repeat"),a=n.transform.copyTo(M.shared);return a.scale(n.texture.frame.width,n.texture.frame.height),o.setTransform(a),o}else if(r.fill instanceof qt){const n=r.fill,o=n.type==="linear",a=n.textureSpace==="local";let l=1,u=1;a&&e&&(l=e.width+i,u=e.height+i);let h,c=!1;if(o){const{start:p,end:f}=n;h=t.createLinearGradient(p.x*l,p.y*u,f.x*l,f.y*u),c=Math.abs(f.x-p.x)<Math.abs((f.y-p.y)*.1)}else{const{center:p,innerRadius:f,outerCenter:m,outerRadius:_}=n;h=t.createRadialGradient(p.x*l,p.y*u,f*l,m.x*l,m.y*u,_*l)}if(c&&a&&e){const p=e.lineHeight/u;for(let f=0;f<e.lines.length;f++){const m=(f*e.lineHeight+i/2)/u;n.colorStops.forEach(_=>{const g=m+_.offset*p;h.addColorStop(Math.floor(g*Af)/Af,H.shared.setValue(_.color).toHex())})}}else n.colorStops.forEach(p=>{h.addColorStop(p.offset,H.shared.setValue(p.color).toHex())});return h}}else{const n=t.createPattern(r.texture.source.resource,"repeat"),o=r.matrix.copyTo(M.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}return"red"}const Ef=new z;let n2=class{getCanvasAndContext(t){const{text:e,style:i,resolution:s=1}=t,n=i._getFinalPadding(),o=ct.measureText(e||" ",i),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*s),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*s),u=Qt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(e,i,n,s,u);const h=i.trim?Tf({canvas:u.canvas,width:a,height:l,resolution:1,output:Ef}):Ef.set(0,0,a,l);return{canvasAndContext:u,frame:h}}returnCanvasAndContext(t){Qt.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,s,n){var o,a,l,u,h;const{canvas:c,context:p}=n,f=Vr(e),m=ct.measureText(t||" ",e),_=m.lines,g=m.lineHeight,b=m.lineWidths,y=m.maxLineWidth,v=m.fontProperties,x=c.height;if(p.resetTransform(),p.scale(s,s),p.textBaseline=e.textBaseline,(o=e._stroke)!=null&&o.width){const C=e._stroke;p.lineWidth=C.width,p.miterLimit=C.miterLimit,p.lineJoin=C.join,p.lineCap=C.cap}p.font=f;let A,S;const E=e.dropShadow?2:1;for(let C=0;C<E;++C){const O=e.dropShadow&&C===0,P=O?Math.ceil(Math.max(1,x)+i*2):0,R=P*s;if(O){p.fillStyle="black",p.strokeStyle="black";const B=e.dropShadow,mt=B.color,I=B.alpha;p.shadowColor=H.shared.setValue(mt).setAlpha(I).toRgbaString();const D=B.blur*s,mn=B.distance*s;p.shadowBlur=D,p.shadowOffsetX=Math.cos(B.angle)*mn,p.shadowOffsetY=Math.sin(B.angle)*mn+R}else{if(p.fillStyle=e._fill?Wr(e._fill,p,m,i*2):null,(a=e._stroke)!=null&&a.width){const B=e._stroke.width*.5+i*2;p.strokeStyle=Wr(e._stroke,p,m,B)}p.shadowColor="black"}let U=(g-v.fontSize)/2;g-v.fontSize<0&&(U=0);const k=(u=(l=e._stroke)==null?void 0:l.width)!=null?u:0;for(let B=0;B<_.length;B++)A=k/2,S=k/2+B*g+v.ascent+U,e.align==="right"?A+=y-b[B]:e.align==="center"&&(A+=(y-b[B])/2),(h=e._stroke)!=null&&h.width&&this._drawLetterSpacing(_[B],e,n,A+i,S+i-P,!0),e._fill!==void 0&&this._drawLetterSpacing(_[B],e,n,A+i,S+i-P)}}_drawLetterSpacing(t,e,i,s,n,o=!1){const{context:a}=i,l=e.letterSpacing;let u=!1;if(ct.experimentalLetterSpacingSupported&&(ct.experimentalLetterSpacing?(a.letterSpacing=`${l}px`,a.textLetterSpacing=`${l}px`,u=!0):(a.letterSpacing="0px",a.textLetterSpacing="0px")),l===0||u){o?a.strokeText(t,s,n):a.fillText(t,s,n);return}let h=s;const c=ct.graphemeSegmenter(t);let p=a.measureText(t).width,f=0;for(let m=0;m<c.length;++m){const _=c[m];o?a.strokeText(_,h,n):a.fillText(_,h,n);let g="";for(let b=m+1;b<c.length;++b)g+=c[b];f=a.measureText(g).width,h+=p-f+l,p=f}}};const nr=new n2;class da{constructor(t){this._activeTextures={},this._renderer=t}getTexture(t,e,i,s){var n;typeof t=="string"&&(t={text:t,style:i,resolution:e}),t.style instanceof Mt||(t.style=new Mt(t.style)),t.textureStyle instanceof At||(t.textureStyle=new At(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:a,textureStyle:l}=t,u=(n=t.resolution)!=null?n:this._renderer.resolution,{frame:h,canvasAndContext:c}=nr.getCanvasAndContext({text:o,style:a,resolution:u}),p=ha(c.canvas,h.width,h.height,u);if(l&&(p.source.style=l),a.trim&&(h.pad(a.padding),p.frame.copyFrom(h),p.frame.scale(1/u),p.updateUvs()),a.filters){const f=this._applyFilters(p,a.filters);return this.returnTexture(p),nr.returnCanvasAndContext(c),f}return this._renderer.texture.initSource(p._source),nr.returnCanvasAndContext(c),p}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",et.returnTexture(t,!0)}renderTextToCanvas(){}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null)}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}da.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"canvasText"},F.add(da),F.add(Yo);var o2=Object.defineProperty,fs=Object.getOwnPropertySymbols,Pf=Object.prototype.hasOwnProperty,wf=Object.prototype.propertyIsEnumerable,Rf=(r,t,e)=>t in r?o2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,a2=(r,t)=>{for(var e in t||(t={}))Pf.call(t,e)&&Rf(r,e,t[e]);if(fs)for(var e of fs(t))wf.call(t,e)&&Rf(r,e,t[e]);return r},l2=(r,t)=>{var e={};for(var i in r)Pf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fs)for(var i of fs(r))t.indexOf(i)<0&&wf.call(r,i)&&(e[i]=r[i]);return e};class or extends Wt{constructor(t){t instanceof pt&&(t={context:t});const e=t||{},{context:i,roundPixels:s}=e,n=l2(e,["context","roundPixels"]);super(a2({label:"Graphics"},n)),this.renderPipeId="graphics",i?this._context=i:this._context=this._ownedContext=new pt,this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s!=null?s:!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new or(this._context.clone()):(this._ownedContext=null,new or(this._context))}lineStyle(t,e,i){const s={};return t&&(s.width=t),e&&(s.color=e),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(t,e){const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==pt.defaultStrokeStyle.width||t.color!==pt.defaultStrokeStyle.color||t.alpha!==pt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}const Mf={name:"local-uniform-msdf-bit",vertex:{header:`
|
|
struct LocalUniforms {
|
|
uColor:vec4<f32>,
|
|
uTransformMatrix:mat3x3<f32>,
|
|
uDistance: f32,
|
|
uRound:f32,
|
|
}
|
|
|
|
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
`,main:`
|
|
vColor *= localUniforms.uColor;
|
|
modelMatrix *= localUniforms.uTransformMatrix;
|
|
`,end:`
|
|
if(localUniforms.uRound == 1)
|
|
{
|
|
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
}
|
|
`},fragment:{header:`
|
|
struct LocalUniforms {
|
|
uColor:vec4<f32>,
|
|
uTransformMatrix:mat3x3<f32>,
|
|
uDistance: f32
|
|
}
|
|
|
|
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
`,main:`
|
|
outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
|
|
`}},Cf={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));
|
|
`}},Of={name:"msdf-bit",fragment:{header:`
|
|
fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
|
|
|
|
// MSDF
|
|
var median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
|
|
// SDF
|
|
median = min(median, msdfColor.a);
|
|
|
|
var screenPxDistance = distance * (median - 0.5);
|
|
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
if (median < 0.01) {
|
|
alpha = 0.0;
|
|
} else if (median > 0.99) {
|
|
alpha = 1.0;
|
|
}
|
|
|
|
// Gamma correction for coverage-like alpha
|
|
var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
|
|
var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
|
|
var coverage: f32 = pow(shapeColor.a * alpha, gamma);
|
|
|
|
return coverage;
|
|
|
|
}
|
|
`}},Gf={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 pa,fa;class Bf extends Pt{constructor(t){const e=new nt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});pa!=null||(pa=Ye({name:"sdf-shader",bits:[zi,Wi(t),Mf,Of,qe]})),fa!=null||(fa=Ke({name:"sdf-shader",bits:[Vi,Yi(t),Cf,Gf,Ze]})),super({glProgram:fa,gpuProgram:pa,resources:{localUniforms:e,batchSamplers:Ki(t)}})}}class ma extends gt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}var u2=Object.defineProperty,If=Object.getOwnPropertySymbols,h2=Object.prototype.hasOwnProperty,c2=Object.prototype.propertyIsEnumerable,Ff=(r,t,e)=>t in r?u2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Df=(r,t)=>{for(var e in t||(t={}))h2.call(t,e)&&Ff(r,e,t[e]);if(If)for(var e of If(t))c2.call(t,e)&&Ff(r,e,t[e]);return r};const Uf=class Lx extends ma{constructor(t){var e,i,s;super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const n=Df(Df({},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=w.WHITE,o._fill.fill=null),this.applyFillAsTint=n.overrideFill;const a=o.fontSize;o.fontSize=this.baseMeasurementFontSize;const l=Vr(o);n.overrideSize?o._stroke&&(o._stroke.width*=this.baseRenderedFontSize/a):o.fontSize=this.baseRenderedFontSize=a,this._style=o,this._skipKerning=(e=n.skipKerning)!=null?e:!1,this.resolution=(i=n.resolution)!=null?i:1,this._padding=(s=n.padding)!=null?s:4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof At?n.textureStyle:new At(n.textureStyle)),this.fontMetrics=ct.measureFont(l),this.lineHeight=o.lineHeight||this.fontMetrics.fontSize||o.fontSize}ensureCharacters(t){var e,i,s,n;const o=ct.graphemeSegmenter(t).filter(x=>!this._currentChars.includes(x)).filter((x,A,S)=>S.indexOf(x)===A);if(!o.length)return;this._currentChars=[...this._currentChars,...o];let a;this._currentPageIndex===-1?a=this._nextPage():a=this.pages[this._currentPageIndex];let{canvas:l,context:u}=a.canvasAndContext,h=a.texture.source;const c=this._style;let p=this._currentX,f=this._currentY,m=this._currentMaxCharHeight;const _=this.baseRenderedFontSize/this.baseMeasurementFontSize,g=this._padding*_;let b=!1;const y=l.width/this.resolution,v=l.height/this.resolution;for(let x=0;x<o.length;x++){const A=o[x],S=ct.measureText(A,c,l,!1);S.lineHeight=S.height;const E=S.width*_,C=Math.ceil((c.fontStyle==="italic"?2:1)*E),O=S.height*_,P=C+g*2,R=O+g*2;if(b=!1,A!==`
|
|
`&&A!=="\r"&&A!==" "&&A!==" "&&(b=!0,m=Math.ceil(Math.max(R,m))),p+P>y&&(f+=m,m=R,p=0,f+m>v)){h.update();const k=this._nextPage();l=k.canvasAndContext.canvas,u=k.canvasAndContext.context,h=k.texture.source,p=0,f=0,m=0}const U=E/_-((i=(e=c.dropShadow)==null?void 0:e.distance)!=null?i:0)-((n=(s=c._stroke)==null?void 0:s.width)!=null?n:0);if(this.chars[A]={id:A.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:U,kerning:{}},b){this._drawGlyph(u,S,p+g,f+g,_,c);const k=h.width*_,B=h.height*_,mt=new z(p/k*h.width,f/B*h.height,P/k*h.width,R/B*h.height);this.chars[A].texture=new w({source:h,frame:mt}),p+=Math.ceil(P)}}h.update(),this._currentX=p,this._currentY=f,this._currentMaxCharHeight=m,this._skipKerning&&this._applyKerning(o,u)}get pageTextures(){return this.pages}_applyKerning(t,e){const i=this._measureCache;for(let s=0;s<t.length;s++){const n=t[s];for(let o=0;o<this._currentChars.length;o++){const a=this._currentChars[o];let l=i[n];l||(l=i[n]=e.measureText(n).width);let u=i[a];u||(u=i[a]=e.measureText(a).width);let h=e.measureText(n+a).width,c=h-(l+u);c&&(this.chars[n].kerning[a]=c),h=e.measureText(n+a).width,c=h-(l+u),c&&(this.chars[a].kerning[n]=c)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=Qt.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new w({source:new ae({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);const n={canvasAndContext:e,texture:s};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){var s;e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=Vr(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const n=e._stroke,o=(s=n==null?void 0:n.width)!=null?s:0;if(n&&(t.lineWidth=o,t.lineJoin=n.join,t.miterLimit=n.miterLimit,t.strokeStyle=Wr(n,t)),e._fill&&(t.fillStyle=Wr(e._fill,t)),e.dropShadow){const a=e.dropShadow,l=H.shared.setValue(a.color).toArray(),u=a.blur*i,h=a.distance*i;t.shadowColor=`rgba(${l[0]*255},${l[1]*255},${l[2]*255},${a.alpha})`,t.shadowBlur=u,t.shadowOffsetX=Math.cos(a.angle)*h,t.shadowOffsetY=Math.sin(a.angle)*h}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,s,n,o){var a;const l=e.text,u=e.fontProperties,h=o._stroke,c=((a=h==null?void 0:h.width)!=null?a:0)*n,p=i+c/2,f=s-c/2,m=u.descent*n,_=e.lineHeight*n;let g=!1;o.stroke&&c&&(g=!0,t.strokeText(l,p,f+_-m));const{shadowBlur:b,shadowOffsetX:y,shadowOffsetY:v}=t;o._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(l,p,f+_-m)),g&&(t.shadowBlur=b,t.shadowOffsetX=y,t.shadowOffsetY=v)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];Qt.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};Uf.defaultOptions={textureSize:512,style:new Mt,mipmap:!0};let ga=Uf;function ms(r,t,e,i){const s={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};s.offsetY=e.baseLineOffset;let n=s.lines[0],o=null,a=!0;const l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},u=e.baseMeasurementFontSize/t.fontSize,h=t.letterSpacing*u,c=t.wordWrapWidth*u,p=t.lineHeight?t.lineHeight*u:e.lineHeight,f=t.wordWrap&&t.breakWords,m=b=>{const y=n.width;for(let v=0;v<l.index;v++){const x=b.positions[v];n.chars.push(b.chars[v]),n.charPositions.push(x+y)}n.width+=b.width,a=!1,l.width=0,l.index=0,l.chars.length=0},_=()=>{let b=n.chars.length-1;if(i){let y=n.chars[b];for(;y===" ";)n.width-=e.chars[y].xAdvance,y=n.chars[--b]}s.width=Math.max(s.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,s.lines.push(n),s.height+=p},g=b=>b-h>c;for(let b=0;b<r.length+1;b++){let y;const v=b===r.length;v||(y=r[b]);const x=e.chars[y]||e.chars[" "];if(/(?:\s)/.test(y)||y==="\r"||y===`
|
|
`||v){if(!a&&t.wordWrap&&g(n.width+l.width)?(_(),m(l),v||n.charPositions.push(0)):(l.start=n.width,m(l),v||n.charPositions.push(0)),y==="\r"||y===`
|
|
`)_();else if(!v){const A=x.xAdvance+(x.kerning[o]||0)+h;n.width+=A,n.spaceWidth=A,n.spacesIndex.push(n.charPositions.length),n.chars.push(y)}}else{const A=x.kerning[o]||0,S=x.xAdvance+A+h;f&&g(n.width+l.width+S)&&(m(l),_()),l.positions[l.index++]=l.width+A,l.chars.push(y),l.width+=S}o=y}return _(),t.align==="center"?d2(s):t.align==="right"?p2(s):t.align==="justify"&&f2(s),s}function d2(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width/2-e.width/2;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}function p2(r){for(let t=0;t<r.lines.length;t++){const e=r.lines[t],i=r.width-e.width;for(let s=0;s<e.charPositions.length;s++)e.charPositions[s]+=i}}function f2(r){const t=r.width;for(let e=0;e<r.lines.length;e++){const i=r.lines[e];let s=0,n=i.spacesIndex[s++],o=0;const a=i.spacesIndex.length,l=(t-i.width)/a;for(let u=0;u<i.charPositions.length;u++)u===n&&(n=i.spacesIndex[s++],o+=l),i.charPositions[u]+=o}}function kf(r){if(r==="")return[];typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(s[0].length===0||s[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...Array.from(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var m2=Object.defineProperty,$f=Object.getOwnPropertySymbols,g2=Object.prototype.hasOwnProperty,_2=Object.prototype.propertyIsEnumerable,Lf=(r,t,e)=>t in r?m2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_a=(r,t)=>{for(var e in t||(t={}))g2.call(t,e)&&Lf(r,e,t[e]);if($f)for(var e of $f(t))_2.call(t,e)&&Lf(r,e,t[e]);return r};let gs=0,b2=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=Sf(1e3)}getFont(t,e){var i;let s=`${e.fontFamily}-bitmap`,n=!0;if(e._fill.fill&&!e._stroke?(s+=e._fill.fill.styleKey,n=!1):(e._stroke||e.dropShadow)&&(s=`${e.styleKey}-bitmap`,n=!1),!V.has(s)){const a=Object.create(e);a.lineHeight=0;const l=new ga(_a({style:a,overrideFill:n,overrideSize:!0},this.defaultOptions));gs++,gs>50&&Zt("BitmapText",`You have dynamically created ${gs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),l.once("destroy",()=>{gs--,V.remove(s)}),V.set(s,l)}const o=V.get(s);return(i=o.ensureCharacters)==null||i.call(o,t),o}getLayout(t,e,i=!0){const s=this.getFont(t,e),n=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(n))return this.measureCache.get(n);const o=ct.graphemeSegmenter(t),a=ms(o,e,s,i);return this.measureCache.set(n,a),a}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,s,n,o;let a=t[0];typeof a=="string"&&(a={name:a,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(i=t[2])==null?void 0:i.resolution,padding:(s=t[2])==null?void 0:s.padding,skipKerning:(n=t[2])==null?void 0:n.skipKerning});const l=a==null?void 0:a.name;if(!l)throw new Error("[BitmapFontManager] Property `name` is required.");a=_a(_a({},this.defaultOptions),a);const u=a.style,h=u instanceof Mt?u:new Mt(u),c=(o=a.dynamicFill)!=null?o:this._canUseTintForStyle(h),p=new ga({style:h,overrideFill:c,skipKerning:a.skipKerning,padding:a.padding,resolution:a.resolution,overrideSize:!1,textureStyle:a.textureStyle}),f=kf(a.chars);return p.ensureCharacters(f.join("")),V.set(`${l}-bitmap`,p),p.once("destroy",()=>V.remove(`${l}-bitmap`)),p}uninstall(t){const e=`${t}-bitmap`,i=V.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const ar=new b2;class Nf extends or{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class ba{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Xf(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);Xf(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,s=ar.getFont(t.text,t._style);i.clear(),s.distanceField.type!=="none"&&(i.customShader||(i.customShader=new Bf(this._renderer.limits.maxBatchableTextures)));const n=ct.graphemeSegmenter(t.text),o=t._style;let a=s.baseLineOffset;const l=ms(n,o,s,!0),u=o.padding,h=l.scale;let c=l.width,p=l.height+l.offsetY;o._stroke&&(c+=o._stroke.width/h,p+=o._stroke.width/h),i.translate(-t._anchor._x*c-u,-t._anchor._y*p-u).scale(h,h);const f=s.applyFillAsTint?o._fill.color:16777215;let m=s.fontMetrics.fontSize,_=s.lineHeight;o.lineHeight&&(m=o.fontSize/h,_=o.lineHeight/h);let g=(_-m)/2;g-s.baseLineOffset<0&&(g=0);for(let b=0;b<l.lines.length;b++){const y=l.lines[b];for(let v=0;v<y.charPositions.length;v++){const x=y.chars[v],A=s.chars[x];if(A!=null&&A.texture){const S=A.texture;i.texture(S,f||"black",Math.round(y.charPositions[v]+A.xOffset),Math.round(a+A.yOffset+g),S.orig.width,S.orig.height)}}a+=_}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Nf;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,s=V.get(`${i}-bitmap`),{a:n,b:o,c:a,d:l}=t.groupTransform,u=Math.sqrt(n*n+o*o),h=Math.sqrt(a*a+l*l),c=(Math.abs(u)+Math.abs(h))/2,p=s.baseRenderedFontSize/t._style.fontSize,f=c*s.distanceField.range*(1/p);e.customShader.resources.localUniforms.uniforms.uDistance=f}destroy(){this._renderer=null}}ba.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"bitmapText"};function Xf(r,t){t.groupTransform=r.groupTransform,t.groupColorAlpha=r.groupColorAlpha,t.groupColor=r.groupColor,t.groupBlendMode=r.groupBlendMode,t.globalDisplayStatus=r.globalDisplayStatus,t.groupTransform=r.groupTransform,t.localDisplayStatus=r.localDisplayStatus,t.groupAlpha=r.groupAlpha,t._roundPixels=r._roundPixels}F.add(ba);class Hf extends Lr{constructor(t){super(),this.generatingTexture=!1,this.currentKey="--",this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{htmlText:t}=this._renderer;t.getReferenceCount(this.currentKey)===null?t.returnTexturePromise(this.texturePromise):t.decreaseReferenceCount(this.currentKey),this._renderer.runners.resolutionChange.remove(this),this.texturePromise=null,this._renderer=null}}class va{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const s=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t.resolution!==s)&&this._updateGpuText(t).catch(n=>{console.error(n)}),t._didTextUpdate=!1,os(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const i=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let s=this._renderer.htmlText.getTexturePromise(t);i&&(s=s.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(i)})),e.texturePromise=s,e.currentKey=t.styleKey,e.texture=await s;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,os(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Hf(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=w.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}va.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"htmlText"};function jf(){const{userAgent:r}=L.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const zf="http://www.w3.org/2000/svg",Vf="http://www.w3.org/1999/xhtml";class ya{constructor(){this.svgRoot=document.createElementNS(zf,"svg"),this.foreignObject=document.createElementNS(zf,"foreignObject"),this.domElement=document.createElementNS(Vf,"div"),this.styleElement=document.createElementNS(Vf,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(s),this.image=L.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}}function Wf(r,t){const e=t.fontFamily,i=[],s={},n=/font-family:([^;"\s]+)/g,o=r.match(n);function a(l){s[l]||(i.push(l),s[l]=!0)}if(Array.isArray(e))for(let l=0;l<e.length;l++)a(e[l]);else a(e);o&&o.forEach(l=>{const u=l.split(":")[1].trim();a(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;a(u)}return i}async function Yf(r){const t=await(await L.get().fetch(r)).blob(),e=new FileReader;return await new Promise((i,s)=>{e.onloadend=()=>i(e.result),e.onerror=s,e.readAsDataURL(t)})}async function Kf(r,t){const e=await Yf(t);return`@font-face {
|
|
font-family: "${r.fontFamily}";
|
|
font-weight: ${r.fontWeight};
|
|
font-style: ${r.fontStyle};
|
|
src: url('${e}');
|
|
}`}const _s=new Map;async function qf(r){const t=r.filter(e=>V.has(`${e}-and-url`)).map(e=>{if(!_s.has(e)){const{entries:i}=V.get(`${e}-and-url`),s=[];i.forEach(n=>{const o=n.url,a=n.faces.map(l=>({weight:l.weight,style:l.style}));s.push(...a.map(l=>Kf({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},o)))}),_s.set(e,Promise.all(s).then(n=>n.join(`
|
|
`)))}return _s.get(e)});return(await Promise.all(t)).join(`
|
|
`)}function Zf(r,t,e,i,s){const{domElement:n,styleElement:o,svgRoot:a}=s;n.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${r}</div>`,n.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),o.textContent=i;const{width:l,height:u}=s.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(a)}function Qf(r,t){const e=Qt.getOptimalCanvasAndContext(r.width,r.height,t),{context:i}=e;return i.clearRect(0,0,r.width,r.height),i.drawImage(r,0,0),e}function Jf(r,t,e){return new Promise(async i=>{e&&await new Promise(s=>setTimeout(s,100)),r.onload=()=>{i()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}let tm;function xa(r,t,e,i){i||(i=tm||(tm=new ya));const{domElement:s,styleElement:n,svgRoot:o}=i;s.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${r}</div>`,s.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(n.textContent=e),document.body.appendChild(o);const a=s.getBoundingClientRect();o.remove();const l=t.padding*2;return{width:a.width-l,height:a.height-l}}class Ta{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===yt.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const i=this._buildTexturePromise(t).then(s=>(this._activeTextures[e].texture=s,s));return this._activeTextures[e]={texture:null,promise:i,usageCount:1},i}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(i=>{e.texture=i,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:s,textureStyle:n}=t,o=st.get(ya),a=Wf(e,i),l=await qf(a),u=xa(e,i,l,o),h=Math.ceil(Math.ceil(Math.max(1,u.width)+i.padding*2)*s),c=Math.ceil(Math.ceil(Math.max(1,u.height)+i.padding*2)*s),p=o.image,f=2;p.width=(h|0)+f,p.height=(c|0)+f;const m=Zf(e,i,s,l,o);await Jf(p,m,jf()&&a.length>0);const _=p;let g;this._createCanvas&&(g=Qf(p,s));const b=ha(g?g.canvas:_,p.width-f,p.height-f,s);return n&&(b.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(b.source),Qt.returnCanvasAndContext(g)),st.return(o),b}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){et.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}Ta.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"htmlText"},F.add(Ta),F.add(va);var v2=Object.defineProperty,em=Object.getOwnPropertySymbols,y2=Object.prototype.hasOwnProperty,x2=Object.prototype.propertyIsEnumerable,rm=(r,t,e)=>t in r?v2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,im=(r,t)=>{for(var e in t||(t={}))y2.call(t,e)&&rm(r,e,t[e]);if(em)for(var e of em(t))x2.call(t,e)&&rm(r,e,t[e]);return r};const sm=class Nx extends Ae{constructor(...t){var e;let i=(e=t[0])!=null?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]}),i=im(im({},Nx.defaultOptions),i);const s=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=i.uvs;n||(i.positions?n=new Float32Array(s.length):n=new Float32Array([0,0,1,0,1,1,0,1]));const o=i.indices||new Uint32Array([0,1,2,0,2,3]),a=i.shrinkBuffersToFit,l=new bt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:X.VERTEX|X.COPY_DST}),u=new bt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:X.VERTEX|X.COPY_DST}),h=new bt({data:o,label:"index-mesh-buffer",shrinkToFit:a,usage:X.INDEX|X.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:u,format:"float32x2",stride:2*4,offset:0}},indexBuffer:h,topology:i.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};sm.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ue=sm;var T2=Object.defineProperty,S2=Object.defineProperties,A2=Object.getOwnPropertyDescriptors,nm=Object.getOwnPropertySymbols,E2=Object.prototype.hasOwnProperty,P2=Object.prototype.propertyIsEnumerable,om=(r,t,e)=>t in r?T2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,am=(r,t)=>{for(var e in t||(t={}))E2.call(t,e)&&om(r,e,t[e]);if(nm)for(var e of nm(t))P2.call(t,e)&&om(r,e,t[e]);return r},lm=(r,t)=>S2(r,A2(t));const lr={name:"local-uniform-bit",vertex:{header:`
|
|
|
|
struct LocalUniforms {
|
|
uTransformMatrix:mat3x3<f32>,
|
|
uColor:vec4<f32>,
|
|
uRound:f32,
|
|
}
|
|
|
|
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
`,main:`
|
|
vColor *= localUniforms.uColor;
|
|
modelMatrix *= localUniforms.uTransformMatrix;
|
|
`,end:`
|
|
if(localUniforms.uRound == 1)
|
|
{
|
|
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
}
|
|
`}},um=lm(am({},lr),{vertex:lm(am({},lr.vertex),{header:lr.vertex.header.replace("group(1)","group(2)")})}),bs={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);
|
|
}
|
|
`}},hm={name:"tiling-bit",vertex:{header:`
|
|
struct TilingUniforms {
|
|
uMapCoord:mat3x3<f32>,
|
|
uClampFrame:vec4<f32>,
|
|
uClampOffset:vec2<f32>,
|
|
uTextureTransform:mat3x3<f32>,
|
|
uSizeAnchor:vec4<f32>
|
|
};
|
|
|
|
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(2) @binding(2) var uSampler: sampler;
|
|
`,main:`
|
|
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
|
|
|
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
|
`},fragment:{header:`
|
|
struct TilingUniforms {
|
|
uMapCoord:mat3x3<f32>,
|
|
uClampFrame:vec4<f32>,
|
|
uClampOffset:vec2<f32>,
|
|
uTextureTransform:mat3x3<f32>,
|
|
uSizeAnchor:vec4<f32>
|
|
};
|
|
|
|
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(2) @binding(2) var uSampler: sampler;
|
|
`,main:`
|
|
|
|
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
|
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
|
var unclamped = coord;
|
|
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
|
|
|
var bias = 0.;
|
|
|
|
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
|
{
|
|
bias = -32.;
|
|
}
|
|
|
|
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
`}},cm={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 Sa,Aa;class dm extends Pt{constructor(){Sa!=null||(Sa=Ye({name:"tiling-sprite-shader",bits:[lr,hm,qe]})),Aa!=null||(Aa=Ke({name:"tiling-sprite-shader",bits:[bs,cm,Ze]}));const t=new nt({uMapCoord:{value:new M,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new M,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Aa,gpuProgram:Sa,resources:{localUniforms:new nt({uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:w.EMPTY.source,uSampler:w.EMPTY.source.style}})}updateUniforms(t,e,i,s,n,o){const a=this.resources.tilingUniforms,l=o.width,u=o.height,h=o.textureMatrix,c=a.uniforms.uTextureTransform;c.set(i.a*l/t,i.b*l/e,i.c*u/t,i.d*u/e,i.tx/t,i.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]=s,a.uniforms.uSizeAnchor[3]=n,o&&(this.resources.uTexture=o.source,this.resources.uSampler=o.source.style)}}class pm extends ue{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 fm(r,t){const e=r.anchor.x,i=r.anchor.y;t[0]=-e*r.width,t[1]=-i*r.height,t[2]=(1-e)*r.width,t[3]=-i*r.height,t[4]=(1-e)*r.width,t[5]=(1-i)*r.height,t[6]=-e*r.width,t[7]=(1-i)*r.height}function mm(r,t,e,i){let s=0;const n=r.length/(t||2),o=i.a,a=i.b,l=i.c,u=i.d,h=i.tx,c=i.ty;for(e*=t;s<n;){const p=r[e],f=r[e+1];r[e]=o*p+l*f+h,r[e+1]=a*p+u*f+c,e+=t,s++}}function gm(r,t){const e=r.texture,i=e.frame.width,s=e.frame.height;let n=0,o=0;r.applyAnchorToTexture&&(n=r.anchor.x,o=r.anchor.y),t[0]=t[6]=-n,t[2]=t[4]=1-n,t[1]=t[3]=-o,t[5]=t[7]=1-o;const a=M.shared;a.copyFrom(r._tileTransform.matrix),a.tx/=r.width,a.ty/=r.height,a.invert(),a.scale(r.width/i,r.height/s),mm(t,2,0,a)}const vs=new pm;class _m{constructor(){this.canBatch=!0,this.geometry=new ue({indices:vs.indices.slice(),positions:vs.positions.slice(),uvs:vs.uvs.slice()})}destroy(){var t;this.geometry.destroy(),(t=this.shader)==null||t.destroy()}}class Ea{constructor(t){this._state=wt.default2d,this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const s=e.canBatch;if(s&&s===i){const{batchableMesh:n}=e;return!n._batcher.checkAndUpdateTexture(n,t.texture)}return i!==s}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const s=this._getTilingSpriteData(t),{geometry:n,canBatch:o}=s;if(o){s.batchableMesh||(s.batchableMesh=new ns);const a=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=n,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(a,e)}else i.break(e),s.shader||(s.shader=new dm),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,er(t.groupColorAlpha,i.uColor,0),this._state.blendMode=je(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:vs,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:s}=e;t.didViewUpdate&&this._updateBatchableMesh(t),s._batcher.updateElement(s)}else if(t.didViewUpdate){const{shader:s}=e;s.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new _m;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),gm(t,i.uvs),fm(t,i.positions)}destroy(){this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let s=!0;return this._renderer.type===yt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),e.canBatch}}Ea.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"},F.add(Ea);var w2=Object.defineProperty,bm=Object.getOwnPropertySymbols,R2=Object.prototype.hasOwnProperty,M2=Object.prototype.propertyIsEnumerable,vm=(r,t,e)=>t in r?w2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ym=(r,t)=>{for(var e in t||(t={}))R2.call(t,e)&&vm(r,e,t[e]);if(bm)for(var e of bm(t))M2.call(t,e)&&vm(r,e,t[e]);return r};const xm=class Xx extends ue{constructor(...t){var e;super({});let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(t){var e,i,s,n;t=ym(ym({},Xx.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(i=this.verticesY)!=null?i:t.verticesY,this.width=(s=this.width)!=null?s:t.width,this.height=(n=this.height)!=null?n:t.height;const o=this.verticesX*this.verticesY,a=[],l=[],u=[],h=this.verticesX-1,c=this.verticesY-1,p=this.width/h,f=this.height/c;for(let _=0;_<o;_++){const g=_%this.verticesX,b=_/this.verticesX|0;a.push(g*p,b*f),l.push(g/h,b/c)}const m=h*c;for(let _=0;_<m;_++){const g=_%h,b=_/h|0,y=b*this.verticesX+g,v=b*this.verticesX+g+1,x=(b+1)*this.verticesX+g,A=(b+1)*this.verticesX+g+1;u.push(y,v,x,v,A,x)}this.buffers[0].data=new Float32Array(a),this.buffers[1].data=new Float32Array(l),this.indexBuffer.data=new Uint32Array(u),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};xm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let ys=xm;var C2=Object.defineProperty,Tm=Object.getOwnPropertySymbols,O2=Object.prototype.hasOwnProperty,G2=Object.prototype.propertyIsEnumerable,Sm=(r,t,e)=>t in r?C2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Am=(r,t)=>{for(var e in t||(t={}))O2.call(t,e)&&Sm(r,e,t[e]);if(Tm)for(var e of Tm(t))G2.call(t,e)&&Sm(r,e,t[e]);return r};const Em=class Hx extends ys{constructor(t={}){t=Am(Am({},Hx.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(t){var e,i,s,n,o,a,l,u,h,c;this.width=(e=t.width)!=null?e:this.width,this.height=(i=t.height)!=null?i:this.height,this._originalWidth=(s=t.originalWidth)!=null?s:this._originalWidth,this._originalHeight=(n=t.originalHeight)!=null?n:this._originalHeight,this._leftWidth=(o=t.leftWidth)!=null?o:this._leftWidth,this._rightWidth=(a=t.rightWidth)!=null?a:this._rightWidth,this._topHeight=(l=t.topHeight)!=null?l:this._topHeight,this._bottomHeight=(u=t.bottomHeight)!=null?u:this._bottomHeight,this._anchorX=(h=t.anchor)==null?void 0:h.x,this._anchorY=(c=t.anchor)==null?void 0:c.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:s,_rightWidth:n,_topHeight:o,_bottomHeight:a,_anchorX:l,_anchorY:u}=this,h=s+n,c=e>h?1:e/h,p=o+a,f=i>p?1:i/p,m=Math.min(c,f),_=l*e,g=u*i;t[0]=t[8]=t[16]=t[24]=-_,t[2]=t[10]=t[18]=t[26]=s*m-_,t[4]=t[12]=t[20]=t[28]=e-n*m-_,t[6]=t[14]=t[22]=t[30]=e-_,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=o*m-g,t[17]=t[19]=t[21]=t[23]=i-a*m-g,t[25]=t[27]=t[29]=t[31]=i-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};Em.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let he=Em;class Pm extends ns{constructor(){super(),this.geometry=new he}destroy(){this.geometry.destroy()}}class Pa{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new Pm,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._renderer=null}}Pa.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"},F.add(Pa);class wa{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}wa.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};var B2=Object.defineProperty,xs=Object.getOwnPropertySymbols,wm=Object.prototype.hasOwnProperty,Rm=Object.prototype.propertyIsEnumerable,Mm=(r,t,e)=>t in r?B2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ra=(r,t)=>{for(var e in t||(t={}))wm.call(t,e)&&Mm(r,e,t[e]);if(xs)for(var e of xs(t))Rm.call(t,e)&&Mm(r,e,t[e]);return r},I2=(r,t)=>{var e={};for(var i in r)wm.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&xs)for(var i of xs(r))t.indexOf(i)<0&&Rm.call(r,i)&&(e[i]=r[i]);return e};const Cm=class Yu extends Pt{constructor(t){t=Ra(Ra({},Yu.defaultOptions),t),super(t),this.enabled=!0,this._state=wt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:i,gl:s}=e,n=I2(e,["gpu","gl"]);let o,a;return i&&(o=dt.from(i)),s&&(a=vt.from(s)),new Yu(Ra({gpuProgram:o,glProgram:a},n))}};Cm.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Jt=Cm;var Yr=`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();
|
|
}
|
|
`,Om=`in vec2 vTextureCoord;
|
|
out vec4 finalColor;
|
|
uniform sampler2D uTexture;
|
|
void main() {
|
|
finalColor = texture(uTexture, vTextureCoord);
|
|
}
|
|
`,Ma=`struct GlobalFilterUniforms {
|
|
uInputSize: vec4<f32>,
|
|
uInputPixel: vec4<f32>,
|
|
uInputClamp: vec4<f32>,
|
|
uOutputFrame: vec4<f32>,
|
|
uGlobalFrame: vec4<f32>,
|
|
uOutputTexture: vec4<f32>,
|
|
};
|
|
|
|
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler: sampler;
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv: vec2<f32>
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition: vec2<f32>,
|
|
) -> VSOutput {
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
filterTextureCoord(aPosition)
|
|
);
|
|
}
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>,
|
|
) -> @location(0) vec4<f32> {
|
|
return textureSample(uTexture, uSampler, uv);
|
|
}
|
|
`;class Gm extends Jt{constructor(){const t=dt.from({vertex:{source:Ma,entryPoint:"mainVertex"},fragment:{source:Ma,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=vt.from({vertex:Yr,fragment:Om,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}function Ca(r,t,e,i,s,n,o,a){const l=o-e,u=a-i,h=s-e,c=n-i,p=r-e,f=t-i,m=l*l+u*u,_=l*h+u*c,g=l*p+u*f,b=h*h+c*c,y=h*p+c*f,v=1/(m*b-_*_),x=(b*g-_*y)*v,A=(m*y-_*g)*v;return x>=0&&A>=0&&x+A<1}class Oa{constructor(t=0,e=0,i=0,s=0,n=0,o=0){this.type="triangle",this.x=t,this.y=e,this.x2=i,this.y2=s,this.x3=n,this.y3=o}contains(t,e){const i=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),s=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(i<0!=s<0&&i!==0&&s!==0)return!1;const n=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return n===0||n<0==i+s<=0}strokeContains(t,e,i,s=.5){const n=i/2,o=n*n,{x:a,x2:l,x3:u,y:h,y2:c,y3:p}=this;return Xr(t,e,a,h,l,p)<=o||Xr(t,e,l,c,u,p)<=o||Xr(t,e,u,p,a,h)<=o}clone(){return new Oa(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x2=t.x2,this.y2=t.y2,this.x3=t.x3,this.y3=t.y3,this}copyTo(t){return t.copyFrom(this),t}getBounds(t){t||(t=new z);const e=Math.min(this.x,this.x2,this.x3),i=Math.max(this.x,this.x2,this.x3),s=Math.min(this.y,this.y2,this.y3),n=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=s,t.width=i-e,t.height=n-s,t}}const Bm=new M;function Im(r,t){var e;t.clear();const i=t.matrix;for(let s=0;s<r.length;s++){const n=r[s];if(n.globalDisplayStatus<7)continue;const o=(e=n.renderGroup)!=null?e:n.parentRenderGroup;o!=null&&o.isCachedAsTexture?t.matrix=Bm.copyFrom(o.textureOffsetInverseTransform).append(n.worldTransform):o!=null&&o._parentCacheAsTextureRenderGroup?t.matrix=Bm.copyFrom(o._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(n.groupTransform):t.matrix=n.worldTransform,t.addBounds(n.bounds)}return t.matrix=i,t}const F2=new Ae({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});let D2=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new ot,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}};class Ga{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new nt({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Kt({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=i,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(i.every(f=>!f.enabled)){s.skip=!0;return}const l=s.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,o,1),s.skip)return;const u=this._getPreviousFilterData(),h=this._findFilterResolution(o);let c=0,p=0;u&&(c=u.bounds.minX,p=u.bounds.minY),this._calculateGlobalFrame(s,c,p,h,n.width,n.height),this._setupFilterTextures(s,l,e,u)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const s=t.source,n=s.resolution,o=s.antialias;if(e.every(p=>!p.enabled))return i.skip=!0,t;const a=i.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(i,a.rectangle,o,n,0),i.skip)return t;const l=n,u=0,h=0;this._calculateGlobalFrame(i,u,h,l,s.width,s.height),i.outputRenderSurface=et.getOptimalTexture(a.width,a.height,i.resolution,i.antialias),i.backTexture=w.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const c=i.outputRenderSurface;return c.source.alphaMode="premultiplied-alpha",c}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&et.returnTexture(e.backTexture),et.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const s=t.colorTexture.source._resolution,n=et.getOptimalTexture(e.width,e.height,s,!1);let o=e.minX,a=e.minY;i&&(o-=i.minX,a-=i.minY),o=Math.floor(o*s),a=Math.floor(a*s);const l=Math.ceil(e.width*s),u=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:l,height:u},{x:0,y:0}),n}applyFilter(t,e,i,s){const n=this.renderer,o=this._activeFilterData,a=o.outputRenderSurface===i,l=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let h=0,c=0;if(a){const f=this._findPreviousFilterOffset();h=f.x,c=f.y}this._updateFilterUniforms(e,i,o,h,c,u,a,s);const p=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(p,e,n)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,s=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(M.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),s.prepend(n),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){var t;return(t=this._passthroughFilter)!=null||(this._passthroughFilter=new Gm),this._passthroughFilter}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const s=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:F2,shader:t,state:t._state,topology:"triangle-list"}),i.type===yt.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,s){if(t.backTexture=w.EMPTY,t.inputTexture=et.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){i.renderTarget.finishRenderPass();const n=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,s==null?void 0:s.bounds)}i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,s,n,o){const a=t.globalFrame;a.x=e*s,a.y=i*s,a.width=n*s,a.height=o*s}_updateFilterUniforms(t,e,i,s,n,o,a,l){const u=this._filterGlobalUniforms.uniforms,h=u.uOutputFrame,c=u.uInputSize,p=u.uInputPixel,f=u.uInputClamp,m=u.uGlobalFrame,_=u.uOutputTexture;a?(h[0]=i.bounds.minX-s,h[1]=i.bounds.minY-n):(h[0]=0,h[1]=0),h[2]=t.frame.width,h[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],p[0]=t.source.pixelWidth,p[1]=t.source.pixelHeight,p[2]=1/p[0],p[3]=1/p[1],f[0]=.5*p[2],f[1]=.5*p[3],f[2]=t.frame.width*c[2]-.5*p[2],f[3]=t.frame.height*c[3]-.5*p[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=s*o,m[1]=n*o,m[2]=g.source.width*o,m[3]=g.source.height*o,e instanceof w&&(e.source.resource=null);const b=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof w?(_[0]=e.frame.width,_[1]=e.frame.height):(_[0]=b.width,_[1]=b.height),_[2]=b.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,i=this._filterStackIndex;for(;i>0;){i--;const s=this._filterStack[i];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Im(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const i=t.inputTexture,s=t.bounds,n=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)n[o].apply(this,i,t.outputRenderSurface,e);else{let l=t.inputTexture;const u=et.getOptimalTexture(s.width,s.height,l.source._resolution,!1);let h=u;for(let c=o;c<a;c++){const p=n[c];if(!p.enabled)continue;p.apply(this,l,h,!0);const f=l;l=h,h=f}n[a].apply(this,l,t.outputRenderSurface,e),et.returnTexture(u)}}_calculateFilterBounds(t,e,i,s,n){var o,a;const l=this.renderer,u=t.bounds,h=t.filters;let c=1/0,p=0,f=!0,m=!1,_=!1,g=!0,b=-1,y=-1;for(let v=0;v<h.length;v++){const x=h[v];if(x.enabled){if(b===-1&&(b=v),y=v,c=Math.min(c,x.resolution==="inherit"?s:x.resolution),p+=x.padding,x.antialias==="off"?f=!1:x.antialias==="inherit"&&f&&(f=i),x.clipToViewport||(g=!1),!(x.compatibleRenderers&l.type)){_=!1;break}if(x.blendRequired&&!((a=(o=l.backBuffer)==null?void 0:o.useBackBuffer)==null||a)){_=!1;break}_=!0,m||(m=x.blendRequired)}}if(!_){t.skip=!0;return}if(g&&u.fitBounds(0,e.width/s,0,e.height/s),u.scale(c).ceil().scale(1/c).pad((p|0)*n),!u.isPositive){t.skip=!0;return}t.antialias=f,t.resolution=c,t.blendRequired=m,t.firstEnabledIndex=b,t.lastEnabledIndex=y}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new D2),this._filterStackIndex++,t}}Ga.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"},F.add(Ga),F.add(wa);var U2={__proto__:null};const Ba=[];F.handleByNamedList(T.Environment,Ba);async function Ia(r){if(!r)for(let t=0;t<Ba.length;t++){const e=Ba[t];if(e.value.test()){await e.value.load();return}}}async function k2(r){return Ia(!r)}let Kr;function Fa(){if(typeof Kr=="boolean")return Kr;try{Kr=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(r){Kr=!1}return Kr}var xt=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(xt||{});class Da{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,o,a,l){const{name:u,items:h}=this;for(let c=0,p=h.length;c<p;c++)h[c][u](t,e,i,s,n,o,a,l);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}var $2=Object.defineProperty,Fm=Object.getOwnPropertySymbols,L2=Object.prototype.hasOwnProperty,N2=Object.prototype.propertyIsEnumerable,Dm=(r,t,e)=>t in r?$2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ts=(r,t)=>{for(var e in t||(t={}))L2.call(t,e)&&Dm(r,e,t[e]);if(Fm)for(var e of Fm(t))N2.call(t,e)&&Dm(r,e,t[e]);return r};const X2=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Um=class jx extends gt{constructor(t){var e;super(),this.uid=Y("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const i=[...X2,...(e=this.config.runners)!=null?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Ia(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash){const s=this._systemsHash[i].constructor.defaultOptions;t=Ts(Ts({},s),t)}t=Ts(Ts({},jx.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let i=0;i<this.runners.init.items.length;i++)await this.runners.init.items[i].init(t);this._initOptions=t}render(t,e){var i,s;let n=t;if(n instanceof q&&(n={container:n},e&&(n.target=e.renderTexture)),n.target||(n.target=this.view.renderTarget),n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,(i=n.clearColor)!=null||(n.clearColor=this.background.colorRgba),(s=n.clear)!=null||(n.clear=this.background.clearBeforeRender)),n.clearColor){const o=Array.isArray(n.clearColor)&&n.clearColor.length===4;n.clearColor=o?n.clearColor:H.shared.setValue(n.clearColor).toArray()}n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),n.container.visible&&(n.container.enableRenderGroup(),this.runners.prerender.emit(n),this.runners.renderStart.emit(n),this.runners.render.emit(n),this.runners.renderEnd.emit(n),this.runners.postrender.emit(n))}resize(t,e,i){const s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),i!==void 0&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){var e;const i=this;t.target||(t.target=i.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),(e=t.clear)!=null||(t.clear=xt.ALL);const{clear:s,clearColor:n,target:o}=t;H.shared.setValue(n!=null?n:this.background.colorRgba),i.renderTarget.clear(o,s,H.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Da(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}_addPipes(t,e){const i=e.reduce((s,n)=>(s[n.name]=n.value,s),{});t.forEach(s=>{const n=s.value,o=s.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&me.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Fa())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Um.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let qr=Um,Ua;function Zr(r){return Ua!==void 0||(Ua=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:qr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!L.get().getWebGLRenderingContext())return!1;let i=L.get().createCanvas().getContext("webgl",e);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch(i){return!1}})()),Ua}let ka;async function Qr(r={}){return ka!==void 0||(ka=await(async()=>{const t=L.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),ka}var H2=Object.defineProperty,km=Object.getOwnPropertySymbols,j2=Object.prototype.hasOwnProperty,z2=Object.prototype.propertyIsEnumerable,$m=(r,t,e)=>t in r?H2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jr=(r,t)=>{for(var e in t||(t={}))j2.call(t,e)&&$m(r,e,t[e]);if(km)for(var e of km(t))z2.call(t,e)&&$m(r,e,t[e]);return r};const Lm=["webgl","webgpu","canvas"];async function Nm(r){var t;let e=[];r.preference?(e.push(r.preference),Lm.forEach(o=>{o!==r.preference&&e.push(o)})):e=Lm.slice();let i,s={};for(let o=0;o<e.length;o++){const a=e[o];if(a==="webgpu"&&await Qr()){const{WebGPURenderer:l}=await Promise.resolve().then(function(){return NR});i=l,s=Jr(Jr({},r),r.webgpu);break}else if(a==="webgl"&&Zr((t=r.failIfMajorPerformanceCaveat)!=null?t:qr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await Promise.resolve().then(function(){return SR});i=l,s=Jr(Jr({},r),r.webgl);break}else if(a==="canvas")throw s=Jr({},r),new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!i)throw new Error("No available renderer for the current environment");const n=new i;return await n.init(s),n}const V2=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i,ti="8.14.3";class $a{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,ti)}static destroy(){}}$a.extension=T.Application;class La{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,ti)}destroy(){this._renderer=null}}La.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"initHook",priority:-10};var W2=Object.defineProperty,Xm=Object.getOwnPropertySymbols,Y2=Object.prototype.hasOwnProperty,K2=Object.prototype.propertyIsEnumerable,Hm=(r,t,e)=>t in r?W2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,q2=(r,t)=>{for(var e in t||(t={}))Y2.call(t,e)&&Hm(r,e,t[e]);if(Xm)for(var e of Xm(t))K2.call(t,e)&&Hm(r,e,t[e]);return r};const jm=class Ku{constructor(...t){this.stage=new q}async init(t){t=q2({},t),this.stage||(this.stage=new q),this.renderer=await Nm(t),Ku._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Ku._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};jm._plugins=[];let zm=jm;F.handleByList(T.Application,zm._plugins),F.add($a);class Na extends ma{constructor(t,e){var i;super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(o=>{const a=n.pages[parseInt(o,10)],l=s[a.id];this.pages.push({texture:l})}),Object.keys(n.chars).forEach(o=>{var a;const l=n.chars[o],{frame:u,source:h,rotate:c}=s[l.page],p=N.transformRectCoords(l,u,c,new z),f=new w({frame:p,orig:new z(0,0,l.width,l.height),source:h,rotate:c});this.chars[o]={id:o.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(a=l.kerning)!=null?a:{},texture:f}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=(i=n.distanceField)!=null?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){ar.install(t)}static uninstall(t){ar.uninstall(t)}}const Ss={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,i;const s=r.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const m in s){const _=s[m].match(/^[a-z]+/gm)[0],g=s[m].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),b={};for(const y in g){const v=g[y].split("="),x=v[0],A=v[1].replace(/"/gm,""),S=parseFloat(A),E=isNaN(S)?A:S;b[x]=E}n[_].push(b)}const o={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[a]=n.info,[l]=n.common,[u]=(t=n.distanceField)!=null?t:[];u&&(o.distanceField={range:parseInt(u.distanceRange,10),type:u.fieldType}),o.fontSize=parseInt(a.size,10),o.fontFamily=a.face,o.lineHeight=parseInt(l.lineHeight,10);const h=n.page;for(let m=0;m<h.length;m++)o.pages.push({id:parseInt(h[m].id,10)||0,file:h[m].file});const c={};o.baseLineOffset=o.lineHeight-parseInt(l.base,10);const p=n.char;for(let m=0;m<p.length;m++){const _=p[m],g=parseInt(_.id,10);let b=(i=(e=_.letter)!=null?e:_.char)!=null?i:String.fromCharCode(g);b==="space"&&(b=" "),c[g]=b,o.chars[b]={id:g,page:parseInt(_.page,10)||0,x:parseInt(_.x,10),y:parseInt(_.y,10),width:parseInt(_.width,10),height:parseInt(_.height,10),xOffset:parseInt(_.xoffset,10),yOffset:parseInt(_.yoffset,10),xAdvance:parseInt(_.xadvance,10),kerning:{}}}const f=n.kerning||[];for(let m=0;m<f.length;m++){const _=parseInt(f[m].first,10),g=parseInt(f[m].second,10),b=parseInt(f[m].amount,10);o.chars[c[g]].kerning[c[_]]=b}return o}},Xa={test(r){const t=r;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(r){var t,e;const i={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},s=r.getElementsByTagName("info")[0],n=r.getElementsByTagName("common")[0],o=r.getElementsByTagName("distanceField")[0];o&&(i.distanceField={type:o.getAttribute("fieldType"),range:parseInt(o.getAttribute("distanceRange"),10)});const a=r.getElementsByTagName("page"),l=r.getElementsByTagName("char"),u=r.getElementsByTagName("kerning");i.fontSize=parseInt(s.getAttribute("size"),10),i.fontFamily=s.getAttribute("face"),i.lineHeight=parseInt(n.getAttribute("lineHeight"),10);for(let c=0;c<a.length;c++)i.pages.push({id:parseInt(a[c].getAttribute("id"),10)||0,file:a[c].getAttribute("file")});const h={};i.baseLineOffset=i.lineHeight-parseInt(n.getAttribute("base"),10);for(let c=0;c<l.length;c++){const p=l[c],f=parseInt(p.getAttribute("id"),10);let m=(e=(t=p.getAttribute("letter"))!=null?t:p.getAttribute("char"))!=null?e:String.fromCharCode(f);m==="space"&&(m=" "),h[f]=m,i.chars[m]={id:f,page:parseInt(p.getAttribute("page"),10)||0,x:parseInt(p.getAttribute("x"),10),y:parseInt(p.getAttribute("y"),10),width:parseInt(p.getAttribute("width"),10),height:parseInt(p.getAttribute("height"),10),xOffset:parseInt(p.getAttribute("xoffset"),10),yOffset:parseInt(p.getAttribute("yoffset"),10),xAdvance:parseInt(p.getAttribute("xadvance"),10),kerning:{}}}for(let c=0;c<u.length;c++){const p=parseInt(u[c].getAttribute("first"),10),f=parseInt(u[c].getAttribute("second"),10),m=parseInt(u[c].getAttribute("amount"),10);i.chars[h[f]].kerning[h[p]]=m}return i}},Ha={test(r){return typeof r=="string"&&r.match(/<font(\s|>)/)?Xa.test(L.get().parseXML(r)):!1},parse(r){return Xa.parse(L.get().parseXML(r))}},Z2=[".xml",".fnt"],Vm={extension:{type:T.CacheParser,name:"cacheBitmapFont"},test:r=>r instanceof Na,getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Wm={extension:{type:T.LoadParser,priority:Et.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return Z2.includes(_t.extname(r).toLowerCase())},async testParse(r){return Ss.test(r)||Ha.test(r)},async parse(r,t,e){const i=Ss.test(r)?Ss.parse(r):Ha.parse(r),{src:s}=t,{pages:n}=i,o=[],a=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let h=0;h<n.length;++h){const c=n[h].file;let p=_t.join(_t.dirname(s),c);p=Fi(p,s),o.push({src:p,data:a})}const l=await e.load(o),u=o.map(h=>l[h.src]);return new Na({data:i,textures:u},s)},async load(r,t){return await(await L.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class Ym{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}const Km={extension:{type:T.CacheParser,name:"cacheTextureArray"},test:r=>Array.isArray(r)&&r.every(t=>t instanceof w),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};async function ja(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 qm={extension:{type:T.DetectionParser,priority:1},test:async()=>ja("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Zm=["png","jpg","jpeg"],Qm={extension:{type:T.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Zm],remove:async r=>r.filter(t=>!Zm.includes(t))},Q2="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ei(r){return Q2?!1:document.createElement("video").canPlayType(r)!==""}const Jm={extension:{type:T.DetectionParser,priority:0},test:async()=>ei("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},tg={extension:{type:T.DetectionParser,priority:0},test:async()=>ei("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},eg={extension:{type:T.DetectionParser,priority:0},test:async()=>ei("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},rg={extension:{type:T.DetectionParser,priority:0},test:async()=>ja("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var J2=Object.defineProperty,tA=Object.defineProperties,eA=Object.getOwnPropertyDescriptors,ig=Object.getOwnPropertySymbols,rA=Object.prototype.hasOwnProperty,iA=Object.prototype.propertyIsEnumerable,sg=(r,t,e)=>t in r?J2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ur=(r,t)=>{for(var e in t||(t={}))rA.call(t,e)&&sg(r,e,t[e]);if(ig)for(var e of ig(t))iA.call(t,e)&&sg(r,e,t[e]);return r},sA=(r,t)=>tA(r,eA(t));const ng=class vn{constructor(){this.loadOptions=ur({},vn.defaultOptions),this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var s,n;let o=null,a=null;if((e.parser||e.loadParser)&&(a=this._parserHash[e.parser||e.loadParser]),!a){for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];if(u.load&&(s=u.test)!=null&&s.call(u,t,e,this)){a=u;break}}if(!a)return null}o=await a.load(t,e,this),i.parser=a;for(let l=0;l<this.parsers.length;l++){const u=this.parsers[l];u.parse&&u.parse&&await((n=u.testParse)==null?void 0:n.call(u,o,e,this))&&(o=await u.parse(o,e,this)||o,i.parser=u)}return o})(),i}async load(t,e){this._parsersValidated||this._validateParsers();const i=typeof e=="function"?sA(ur(ur({},vn.defaultOptions),this.loadOptions),{onProgress:e}):ur(ur(ur({},vn.defaultOptions),this.loadOptions),e||{}),{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:l}=i;let u=0;const h={},c=Rr(t),p=Ft(t,_=>({alias:[_],src:_,data:{}})),f=p.reduce((_,g)=>_+(g.progressSize||1),0),m=p.map(async _=>{const g=_t.toAbsolute(_.src);h[_.src]||(await this._loadAssetWithRetry(g,_,{onProgress:s,onError:n,strategy:o,retryCount:a,retryDelay:l},h),u+=_.progressSize||1,s&&s(u/f))});return await Promise.all(m),c?h[p[0].src]:h}async unload(t){const e=Ft(t,i=>({alias:[i],src:i})).map(async i=>{var s,n;const o=_t.toAbsolute(i.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],await((n=(s=a.parser)==null?void 0:s.unload)==null?void 0:n.call(s,l,i,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id||t[e.name]||t[e.id],t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,s){let n=0;const{onError:o,strategy:a,retryCount:l,retryDelay:u}=i,h=c=>new Promise(p=>setTimeout(p,c));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),s[e.src]=await this.promiseCache[t].promise;return}catch(c){delete this.promiseCache[t],delete s[e.src],n++;const p=a!=="retry"||n>l;if(a==="retry"&&!p){o&&o(c,e),await h(u);continue}if(a==="skip"){o&&o(c,e);return}throw o&&o(c,e),new Error(`[Loader.load] Failed to load ${t}.
|
|
${c}`)}}};ng.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let og=ng;function Ce(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 Dt(r,t){const e=r.split("?")[0],i=_t.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const nA=".json",oA="application/json",ag={extension:{type:T.LoadParser,priority:Et.Low},name:"loadJson",id:"json",test(r){return Ce(r,oA)||Dt(r,nA)},async load(r){return await(await L.get().fetch(r)).json()}},aA=".txt",lA="text/plain",lg={name:"loadTxt",id:"text",extension:{type:T.LoadParser,priority:Et.Low,name:"loadTxt"},test(r){return Ce(r,lA)||Dt(r,aA)},async load(r){return await(await L.get().fetch(r)).text()}};var uA=Object.defineProperty,hA=Object.defineProperties,cA=Object.getOwnPropertyDescriptors,ug=Object.getOwnPropertySymbols,dA=Object.prototype.hasOwnProperty,pA=Object.prototype.propertyIsEnumerable,hg=(r,t,e)=>t in r?uA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fA=(r,t)=>{for(var e in t||(t={}))dA.call(t,e)&&hg(r,e,t[e]);if(ug)for(var e of ug(t))pA.call(t,e)&&hg(r,e,t[e]);return r},mA=(r,t)=>hA(r,cA(t));const gA=["normal","bold","100","200","300","400","500","600","700","800","900"],_A=[".ttf",".otf",".woff",".woff2"],bA=["font/ttf","font/otf","font/woff","font/woff2"],vA=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function cg(r){const t=_t.extname(r),e=_t.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(vA)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const yA=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function xA(r){return yA.test(r)?r:encodeURI(r)}const dg={extension:{type:T.LoadParser,priority:Et.Low},name:"loadWebFont",id:"web-font",test(r){return Ce(r,bA)||Dt(r,_A)},async load(r,t){var e,i,s,n,o,a;const l=L.get().getFontFaceSet();if(l){const u=[],h=(i=(e=t.data)==null?void 0:e.family)!=null?i:cg(r),c=(o=(n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(f=>gA.includes(f)))!=null?o:["normal"],p=(a=t.data)!=null?a:{};for(let f=0;f<c.length;f++){const m=c[f],_=new FontFace(h,`url(${xA(r)})`,mA(fA({},p),{weight:m}));await _.load(),l.add(_),u.push(_)}return V.has(`${h}-and-url`)?V.get(`${h}-and-url`).entries.push({url:r,faces:u}):V.set(`${h}-and-url`,{entries:[{url:r,faces:u}]}),u.length===1?u[0]:u}return null},unload(r){const t=Array.isArray(r)?r:[r],e=t[0].family,i=V.get(`${e}-and-url`),s=i.entries.find(n=>n.faces.some(o=>t.indexOf(o)!==-1));s.faces=s.faces.filter(n=>t.indexOf(n)===-1),s.faces.length===0&&(i.entries=i.entries.filter(n=>n!==s)),t.forEach(n=>{L.get().getFontFaceSet().delete(n)}),i.entries.length===0&&V.remove(`${e}-and-url`)}};function As(r,t=1){var e;const i=(e=oe.RETINA_PREFIX)==null?void 0:e.exec(r);return i?parseFloat(i[1]):t}function ce(r,t,e){r.label=e,r._sourceOrigin=e;const i=new w({source:r,label:e}),s=()=>{delete t.promiseCache[e],V.has(e)&&V.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&s()}),i.once("destroy",()=>{r.destroyed||s()}),i}var TA=Object.defineProperty,Es=Object.getOwnPropertySymbols,pg=Object.prototype.hasOwnProperty,fg=Object.prototype.propertyIsEnumerable,mg=(r,t,e)=>t in r?TA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,SA=(r,t)=>{for(var e in t||(t={}))pg.call(t,e)&&mg(r,e,t[e]);if(Es)for(var e of Es(t))fg.call(t,e)&&mg(r,e,t[e]);return r},AA=(r,t)=>{var e={};for(var i in r)pg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Es)for(var i of Es(r))t.indexOf(i)<0&&fg.call(r,i)&&(e[i]=r[i]);return e};const EA=".svg",PA="image/svg+xml",gg={extension:{type:T.LoadParser,priority:Et.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return Ce(r,PA)||Dt(r,EA)},async load(r,t,e){var i,s;return((s=(i=t.data)==null?void 0:i.parseAsGraphicsContext)!=null?s:this.config.parseAsGraphicsContext)?RA(r):wA(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function wA(r,t,e,i){var s,n,o,a,l,u;const h=await L.get().fetch(r),c=L.get().createImage();c.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await h.text())}`,c.crossOrigin=i,await c.decode();const p=(n=(s=t.data)==null?void 0:s.width)!=null?n:c.width,f=(a=(o=t.data)==null?void 0:o.height)!=null?a:c.height,m=((l=t.data)==null?void 0:l.resolution)||As(r),_=Math.ceil(p*m),g=Math.ceil(f*m),b=L.get().createCanvas(_,g),y=b.getContext("2d");y.imageSmoothingEnabled=!0,y.imageSmoothingQuality="high",y.drawImage(c,0,0,p*m,f*m);const v=(u=t.data)!=null?u:{},{parseAsGraphicsContext:x}=v,A=AA(v,["parseAsGraphicsContext"]),S=new ae(SA({resource:b,alphaMode:"premultiply-alpha-on-upload",resolution:m},A));return ce(S,e,r)}async function RA(r){const t=await(await L.get().fetch(r)).text(),e=new pt;return e.svg(t),e}const MA=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})();
|
|
`;let hr=null,za=class{constructor(){hr||(hr=URL.createObjectURL(new Blob([MA],{type:"application/javascript"}))),this.worker=new Worker(hr)}};za.revokeObjectURL=function(){hr&&(URL.revokeObjectURL(hr),hr=null)};const CA='(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 cr=null,_g=class{constructor(){cr||(cr=URL.createObjectURL(new Blob([CA],{type:"application/javascript"}))),this.worker=new Worker(cr)}};_g.revokeObjectURL=function(){cr&&(URL.revokeObjectURL(cr),cr=null)};let bg=0,Va,OA=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 za;e.addEventListener("message",i=>{e.terminate(),za.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Va===void 0&&(Va=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Va&&(this._createdWorkers++,t=new _g().worker,t.addEventListener("message",e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this._queue.push({id:t,arguments:e,resolve:s,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[bg]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:bg++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t==null||t(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}};const Wa=new OA;var GA=Object.defineProperty,vg=Object.getOwnPropertySymbols,BA=Object.prototype.hasOwnProperty,IA=Object.prototype.propertyIsEnumerable,yg=(r,t,e)=>t in r?GA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FA=(r,t)=>{for(var e in t||(t={}))BA.call(t,e)&&yg(r,e,t[e]);if(vg)for(var e of vg(t))IA.call(t,e)&&yg(r,e,t[e]);return r};const DA=[".jpeg",".jpg",".png",".webp",".avif"],UA=["image/jpeg","image/png","image/webp","image/avif"];async function xg(r,t){var e;const i=await L.get().fetch(r);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${i.status} ${i.statusText}`);const s=await i.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const Ya={name:"loadTextures",id:"texture",extension:{type:T.LoadParser,priority:Et.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Ce(r,UA)||Dt(r,DA)},async load(r,t,e){var i;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Wa.isImageBitmapSupported()?s=await Wa.loadImageBitmap(r,t):s=await xg(r,t):s=await new Promise((o,a)=>{s=L.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=r,s.complete?o(s):(s.onload=()=>{o(s)},s.onerror=a)});const n=new ae(FA({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((i=t.data)==null?void 0:i.resolution)||As(r)},t.data));return ce(n,e,r)},unload(r){r.destroy(!0)}};var kA=Object.defineProperty,$A=Object.defineProperties,LA=Object.getOwnPropertyDescriptors,Tg=Object.getOwnPropertySymbols,NA=Object.prototype.hasOwnProperty,XA=Object.prototype.propertyIsEnumerable,Sg=(r,t,e)=>t in r?kA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ka=(r,t)=>{for(var e in t||(t={}))NA.call(t,e)&&Sg(r,e,t[e]);if(Tg)for(var e of Tg(t))XA.call(t,e)&&Sg(r,e,t[e]);return r},Ag=(r,t)=>$A(r,LA(t));const HA=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let qa,Za;function Eg(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=wg(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function Pg(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",s),r.load();function i(){n(),t()}function s(o){n(),e(o)}function n(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",s)}})}function wg(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function jA(){const r=[],t=[];for(const e of HA){const i=Xe.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;ei(i)&&(r.push(e),t.includes(i)||t.push(i))}return{validVideoExtensions:r,validVideoMime:t}}const Rg={name:"loadVideo",id:"video",extension:{type:T.LoadParser,name:"loadVideo"},test(r){if(!qa||!Za){const{validVideoExtensions:i,validVideoMime:s}=jA();qa=i,Za=s}const t=Ce(r,Za),e=Dt(r,qa);return t||e},async load(r,t,e){var i,s;const n=Ka(Ag(Ka({},Xe.defaultOptions),{resolution:((i=t.data)==null?void 0:i.resolution)||As(r),alphaMode:((s=t.data)==null?void 0:s.alphaMode)||await io()}),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),Eg(o,r,n.crossorigin);const l=document.createElement("source");let u;if(n.mime)u=n.mime;else if(r.startsWith("data:"))u=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const h=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();u=Xe.MIME_TYPES[h]||`video/${h}`}return l.src=r,u&&(l.type=u),new Promise(h=>{const c=async()=>{const p=new Xe(Ag(Ka({},n),{resource:o}));o.removeEventListener("canplay",c),t.data.preload&&await Pg(o),h(ce(p,e,r))};n.preload&&!n.autoPlay&&o.load(),o.addEventListener("canplay",c),o.appendChild(l)})},unload(r){r.destroy(!0)}},Qa={extension:{type:T.ResolveParser,name:"resolveTexture"},test:Ya.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=oe.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Mg={extension:{type:T.ResolveParser,priority:-2,name:"resolveJson"},test:r=>oe.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Qa.parse};var zA=Object.defineProperty,Cg=Object.getOwnPropertySymbols,VA=Object.prototype.hasOwnProperty,WA=Object.prototype.propertyIsEnumerable,Og=(r,t,e)=>t in r?zA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gg=(r,t)=>{for(var e in t||(t={}))VA.call(t,e)&&Og(r,e,t[e]);if(Cg)for(var e of Cg(t))WA.call(t,e)&&Og(r,e,t[e]);return r};class Bg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new oe,this.loader=new og,this.cache=V,this._backgroundLoader=new Ym(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,i,s;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const n=(i=(e=t.texturePreference)==null?void 0:e.resolution)!=null?i:1,o=typeof n=="number"?[n]:n,a=await this._detectFormats({preferredFormats:(s=t.texturePreference)==null?void 0:s.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:a,resolution:o}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions=Gg(Gg({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=Rr(t),s=Ft(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(u=>!this.resolver.hasKey(u))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0;const l=[],u=()=>{e==null||e(l.reduce((c,p)=>c+p,0)/a)},h=o.map((c,p)=>{const f=s[c],m=Object.values(f),_=[...new Set(m.flat())].reduce((g,b)=>g+(b.progressSize||1),0);return l.push(0),a+=_,this._mapLoadToResolve(f,g=>{l[p]=g*_,u()}).then(g=>{n[c]=g})});return await Promise.all(h),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return V.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=V.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const s=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(o=>{const a=s[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(u=>{n[u]=a}),V.set(l,a)}),n}async unload(t){this._initialized||await this.init();const e=Ft(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=Ft(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{V.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const ri=new Bg;F.handleByList(T.LoadParser,ri.loader.parsers).handleByList(T.ResolveParser,ri.resolver.parsers).handleByList(T.CacheParser,ri.cache.parsers).handleByList(T.DetectionParser,ri.detections),F.add(Km,Qm,qm,rg,Jm,tg,eg,ag,lg,dg,gg,Ya,Rg,Wm,Vm,Qa,Mg);const Ig={loader:T.LoadParser,resolver:T.ResolveParser,cache:T.CacheParser,detection:T.DetectionParser};F.handle(T.Asset,r=>{const t=r.ref;Object.entries(Ig).filter(([e])=>!!t[e]).forEach(([e,i])=>{var s;return F.add(Object.assign(t[e],{extension:(s=t[e].extension)!=null?s:i}))})},r=>{const t=r.ref;Object.keys(Ig).filter(e=>!!t[e]).forEach(e=>F.remove(t[e]))});const YA={extension:{type:T.DetectionParser,priority:3},test:async()=>!!(await Qr()||Zr()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};class ii extends Q{constructor(t){super(t),this.uploadMethodId="compressed",this.resource=t.resource,this.mipLevelCount=this.resource.length}}let Ps;function Ja(){if(Ps)return Ps;const r=L.get().createCanvas(1,1).getContext("webgl");return r?(Ps=[...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"]:[]],Ps):[]}let ws;async function tl(){if(ws)return ws;const r=await L.get().getNavigator().gpu.requestAdapter();return ws=[...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"]:[]],ws}let el;async function rl(){return el!==void 0||(el=await(async()=>{const r=await Qr(),t=Zr();if(r&&t){const e=await tl(),i=Ja();return e.filter(s=>i.includes(s))}else{if(r)return await tl();if(t)return Ja()}return[]})()),el}const Fg=["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 Rs;async function si(){if(Rs!==void 0)return Rs;const r=await rl();return Rs=[...Fg,...r],Rs}const KA='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e<s;++e)for(let o=0;o<t;++o){const B=r.getImageTranscodedSizeInBytes(o,e,a),f=new Uint8Array(B);if(!r.transcodeImage(f,o,e,a,1,0))throw new Error("transcodeImage failed");m.push(f)}return m}const w={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function d(r){const a=w[r];if(a)return a;throw new Error(`Unsupported transcoderFormat: ${r}`)}const n={jsUrl:"basis/basis_transcoder.js",wasmUrl:"basis/basis_transcoder.wasm"};let u,i,c;async function l(){if(!c){const r=new URL(n.jsUrl,location.origin).href,a=new URL(n.wasmUrl,location.origin).href;importScripts(r),c=new Promise(t=>{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)}})();\n';let dr=null,Dg=class{constructor(){dr||(dr=URL.createObjectURL(new Blob([KA],{type:"application/javascript"}))),this.worker=new Worker(dr)}};Dg.revokeObjectURL=function(){dr&&(URL.revokeObjectURL(dr),dr=null)};const Ms={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.wasm"};function qA(r){Object.assign(Ms,r)}let ni;const Ug={};function ZA(r){return ni||(ni=new Dg().worker,ni.onmessage=t=>{const{success:e,url:i,textureOptions:s}=t.data;e||console.warn("Failed to load Basis texture",i),Ug[i](s)},ni.postMessage({type:"init",jsUrl:Ms.jsUrl,wasmUrl:Ms.wasmUrl,supportedTextures:r})),ni}function kg(r,t){const e=ZA(t);return new Promise(i=>{Ug[r]=i,e.postMessage({type:"load",url:r})})}const QA={extension:{type:T.LoadParser,priority:Et.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return Dt(r,[".basis"])},async load(r,t,e){const i=await si(),s=await kg(r,i),n=new ii(s);return ce(n,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function JA(r,t){const e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const s=[];for(let n=0;n<i;++n)for(let o=0;o<e;++o){const a=r.getImageTranscodedSizeInBytes(o,n,t),l=new Uint8Array(a);if(!r.transcodeImage(l,o,n,t,1,0))throw new Error("transcodeImage failed");s.push(l)}return s}const tE={"bc3-rgba-unorm":3,"bc7-rgba-unorm":6,"etc2-rgba8unorm":1,"astc-4x4-unorm":10,rgba8unorm:13,rgba4unorm:16};function eE(r){const t=tE[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const rE={MAGIC:0,SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19,PF_FLAGS:20,FOURCC:21,RGB_BITCOUNT:22,R_BIT_MASK:23,G_BIT_MASK:24,B_BIT_MASK:25,A_BIT_MASK:26},iE={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4};var il=(r=>(r[r.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",r[r.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",r[r.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",r[r.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",r[r.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",r[r.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",r[r.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",r[r.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",r[r.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",r[r.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",r[r.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",r[r.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",r[r.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",r[r.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",r[r.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",r[r.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",r[r.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",r[r.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",r[r.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",r[r.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",r[r.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",r[r.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",r[r.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",r[r.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",r[r.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",r[r.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",r[r.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",r[r.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",r[r.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",r[r.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",r[r.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",r[r.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",r[r.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",r[r.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",r[r.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",r[r.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",r[r.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",r[r.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",r[r.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",r[r.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",r[r.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",r[r.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",r[r.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",r[r.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",r[r.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",r[r.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",r[r.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",r[r.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",r[r.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",r[r.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",r[r.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",r[r.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",r[r.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",r[r.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",r[r.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",r[r.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",r[r.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",r[r.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",r[r.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",r[r.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",r[r.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",r[r.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",r[r.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",r[r.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",r[r.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",r[r.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",r[r.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",r[r.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",r[r.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",r[r.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",r[r.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",r[r.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",r[r.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",r[r.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",r[r.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",r[r.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",r[r.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",r[r.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",r[r.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",r[r.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",r[r.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",r[r.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",r[r.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",r[r.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",r[r.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",r[r.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",r[r.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",r[r.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",r[r.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",r[r.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",r[r.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",r[r.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",r[r.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",r[r.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",r[r.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",r[r.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",r[r.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",r[r.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",r[r.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",r[r.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",r[r.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",r[r.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",r[r.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",r[r.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",r[r.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",r[r.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",r[r.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",r[r.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",r[r.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",r[r.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",r[r.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",r[r.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",r))(il||{}),sl=(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))(sl||{});function ut(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var Tt=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.R8G8B8=20]="R8G8B8",r[r.A8R8G8B8=21]="A8R8G8B8",r[r.X8R8G8B8=22]="X8R8G8B8",r[r.R5G6B5=23]="R5G6B5",r[r.X1R5G5B5=24]="X1R5G5B5",r[r.A1R5G5B5=25]="A1R5G5B5",r[r.A4R4G4B4=26]="A4R4G4B4",r[r.R3G3B2=27]="R3G3B2",r[r.A8=28]="A8",r[r.A8R3G3B2=29]="A8R3G3B2",r[r.X4R4G4B4=30]="X4R4G4B4",r[r.A2B10G10R10=31]="A2B10G10R10",r[r.A8B8G8R8=32]="A8B8G8R8",r[r.X8B8G8R8=33]="X8B8G8R8",r[r.G16R16=34]="G16R16",r[r.A2R10G10B10=35]="A2R10G10B10",r[r.A16B16G16R16=36]="A16B16G16R16",r[r.A8P8=40]="A8P8",r[r.P8=41]="P8",r[r.L8=50]="L8",r[r.A8L8=51]="A8L8",r[r.A4L4=52]="A4L4",r[r.V8U8=60]="V8U8",r[r.L6V5U5=61]="L6V5U5",r[r.X8L8V8U8=62]="X8L8V8U8",r[r.Q8W8V8U8=63]="Q8W8V8U8",r[r.V16U16=64]="V16U16",r[r.A2W10V10U10=67]="A2W10V10U10",r[r.Q16W16V16U16=110]="Q16W16V16U16",r[r.R16F=111]="R16F",r[r.G16R16F=112]="G16R16F",r[r.A16B16G16R16F=113]="A16B16G16R16F",r[r.R32F=114]="R32F",r[r.G32R32F=115]="G32R32F",r[r.A32B32G32R32F=116]="A32B32G32R32F",r[r.UYVY=ut("UYVY")]="UYVY",r[r.R8G8_B8G8=ut("RGBG")]="R8G8_B8G8",r[r.YUY2=ut("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=ut("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=ut("DXT1")]="DXT1",r[r.DXT2=ut("DXT2")]="DXT2",r[r.DXT3=ut("DXT3")]="DXT3",r[r.DXT4=ut("DXT4")]="DXT4",r[r.DXT5=ut("DXT5")]="DXT5",r[r.ATI1=ut("ATI1")]="ATI1",r[r.AT1N=ut("AT1N")]="AT1N",r[r.ATI2=ut("ATI2")]="ATI2",r[r.AT2N=ut("AT2N")]="AT2N",r[r.BC4U=ut("BC4U")]="BC4U",r[r.BC4S=ut("BC4S")]="BC4S",r[r.BC5U=ut("BC5U")]="BC5U",r[r.BC5S=ut("BC5S")]="BC5S",r[r.DX10=ut("DX10")]="DX10",r))(Tt||{});const nl={[Tt.DXT1]:"bc1-rgba-unorm",[Tt.DXT2]:"bc2-rgba-unorm",[Tt.DXT3]:"bc2-rgba-unorm",[Tt.DXT4]:"bc3-rgba-unorm",[Tt.DXT5]:"bc3-rgba-unorm",[Tt.ATI1]:"bc4-r-unorm",[Tt.BC4U]:"bc4-r-unorm",[Tt.BC4S]:"bc4-r-snorm",[Tt.ATI2]:"bc5-rg-unorm",[Tt.BC5U]:"bc5-rg-unorm",[Tt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},St={70:"bc1-rgba-unorm",71:"bc1-rgba-unorm",72:"bc1-rgba-unorm-srgb",73:"bc2-rgba-unorm",74:"bc2-rgba-unorm",75:"bc2-rgba-unorm-srgb",76:"bc3-rgba-unorm",77:"bc3-rgba-unorm",78:"bc3-rgba-unorm-srgb",79:"bc4-r-unorm",80:"bc4-r-unorm",81:"bc4-r-snorm",82:"bc5-rg-unorm",83:"bc5-rg-unorm",84:"bc5-rg-snorm",94:"bc6h-rgb-ufloat",95:"bc6h-rgb-ufloat",96:"bc6h-rgb-float",97:"bc7-rgba-unorm",98:"bc7-rgba-unorm",99:"bc7-rgba-unorm-srgb",28:"rgba8unorm",29:"rgba8unorm-srgb",87:"bgra8unorm",91:"bgra8unorm-srgb",41:"r32float",49:"rg8unorm",56:"r16uint",61:"r8unorm",24:"rgb10a2unorm",11:"rgba16uint",13:"rgba16sint",10:"rgba16float",54:"r16float",34:"rg16float",16:"rg32float",2:"rgba32float"},$={MAGIC_VALUE:542327876,MAGIC_SIZE:4,HEADER_SIZE:124,HEADER_DX10_SIZE:20,PIXEL_FORMAT_FLAGS:{ALPHAPIXELS:1,ALPHA:2,FOURCC:4,RGB:64,RGBA:65,YUV:512,LUMINANCE:131072,LUMINANCEA:131073},RESOURCE_MISC_TEXTURECUBE:4,HEADER_FIELDS:rE,HEADER_DX10_FIELDS:iE,DXGI_FORMAT:il,D3D10_RESOURCE_DIMENSION:sl,D3DFMT:Tt},$g={"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 Lg(r,t){const{format:e,fourCC:i,width:s,height:n,dataOffset:o,mipmapCount:a}=nE(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${i} ${e}, supported: ${t}`);if(a<=1)return{format:e,width:s,height:n,resource:[new Uint8Array(r,o)],alphaMode:"no-premultiply-alpha"};const l=sE(e,s,n,o,a,r);return{format:e,width:s,height:n,resource:l,alphaMode:"no-premultiply-alpha"}}function sE(r,t,e,i,s,n){const o=[],a=$g[r];let l=t,u=e,h=i;for(let c=0;c<s;++c){const p=Math.ceil(Math.max(4,l)/4)*4,f=Math.ceil(Math.max(4,u)/4)*4,m=a?p/4*f/4*a:l*u*4,_=new Uint8Array(n,h,m);o.push(_),h+=m,l=Math.max(l>>1,1),u=Math.max(u>>1,1)}return o}function nE(r){const t=new Uint32Array(r,0,$.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[$.HEADER_FIELDS.MAGIC]!==$.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[$.HEADER_FIELDS.HEIGHT],i=t[$.HEADER_FIELDS.WIDTH],s=Math.max(1,t[$.HEADER_FIELDS.MIPMAP_COUNT]),n=t[$.HEADER_FIELDS.PF_FLAGS],o=t[$.HEADER_FIELDS.FOURCC],a=oE(t,n,o,r),l=$.MAGIC_SIZE+$.HEADER_SIZE+(o===$.D3DFMT.DX10?$.HEADER_DX10_SIZE:0);return{format:a,fourCC:o,width:i,height:e,dataOffset:l,mipmapCount:s}}function oE(r,t,e,i){if(t&$.PIXEL_FORMAT_FLAGS.FOURCC){if(e===$.D3DFMT.DX10){const s=new Uint32Array(i,$.MAGIC_SIZE+$.HEADER_SIZE,$.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(s[$.HEADER_DX10_FIELDS.MISC_FLAG]===$.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(s[$.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===$.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const n=s[$.HEADER_DX10_FIELDS.DXGI_FORMAT];if(n in St)return St[n];throw new Error(`DDSParser cannot parse texture data with DXGI format ${n}`)}if(e in nl)return nl[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&$.PIXEL_FORMAT_FLAGS.RGB||t&$.PIXEL_FORMAT_FLAGS.RGBA)return aE(r);throw t&$.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&$.PIXEL_FORMAT_FLAGS.LUMINANCE||t&$.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&$.PIXEL_FORMAT_FLAGS.ALPHA||t&$.PIXEL_FORMAT_FLAGS.ALPHAPIXELS?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}function aE(r){const t=r[$.HEADER_FIELDS.RGB_BITCOUNT],e=r[$.HEADER_FIELDS.R_BIT_MASK],i=r[$.HEADER_FIELDS.G_BIT_MASK],s=r[$.HEADER_FIELDS.B_BIT_MASK],n=r[$.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&i===65280&&s===16711680&&n===4278190080)return St[$.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&i===65280&&s===255&&n===4278190080)return St[$.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&i===1047552&&s===1023&&n===3221225472)return St[$.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&i===4294901760&&s===0&&n===0)return St[$.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&i===0&&s===0&&n===0)return St[$.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&i===992&&s===31&&n===32768)return St[$.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&i===2016&&s===31&&n===0)return St[$.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&i===240&&s===15&&n===61440)return St[$.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&i===0&&s===0&&n===65280)return St[$.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&i===0&&s===0&&n===0)return St[$.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&i===0&&s===0&&n===0)return St[$.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration:
|
|
bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = ${n}`)}const lE={extension:{type:T.LoadParser,priority:Et.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return Dt(r,[".dds"])},async load(r,t,e){const i=await si(),s=await(await fetch(r)).arrayBuffer(),n=Lg(s,i),o=new ii(n);return ce(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var Ng=(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))(Ng||{}),uE=(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))(uE||{}),hE=(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))(hE||{});const it={FILE_HEADER_SIZE:64,FILE_IDENTIFIER:[171,75,84,88,32,49,49,187,13,10,26,10],FORMATS_TO_COMPONENTS:{6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:{33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,36283:.5,36284:.5,36285:1,36286:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,37808:1,37840:1,37809:.8,37841:.8,37810:.64,37842:.64,37811:.53375,37843:.53375,37812:.445,37844:.445,37813:.4,37845:.4,37814:.33375,37846:.33375,37815:.25,37847:.25,37816:.32,37848:.32,37817:.26625,37849:.26625,37818:.2,37850:.2,37819:.16,37851:.16,37820:.13375,37852:.13375,37821:.11125,37853:.11125,36492:1,36493:1,36494:1,36495:1},INTERNAL_FORMAT_TO_TEXTURE_FORMATS:{33776:"bc1-rgba-unorm",33777:"bc1-rgba-unorm",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",35916:"bc1-rgba-unorm-srgb",35917:"bc1-rgba-unorm-srgb",35918:"bc2-rgba-unorm-srgb",35919:"bc3-rgba-unorm-srgb",36283:"bc4-r-unorm",36284:"bc4-r-snorm",36285:"bc5-rg-unorm",36286:"bc5-rg-snorm",37488:"eac-r11unorm",37490:"eac-rg11snorm",37492:"etc2-rgb8unorm",37496:"etc2-rgba8unorm",37493:"etc2-rgb8unorm-srgb",37497:"etc2-rgba8unorm-srgb",37494:"etc2-rgb8a1unorm",37495:"etc2-rgb8a1unorm-srgb",37808:"astc-4x4-unorm",37840:"astc-4x4-unorm-srgb",37809:"astc-5x4-unorm",37841:"astc-5x4-unorm-srgb",37810:"astc-5x5-unorm",37842:"astc-5x5-unorm-srgb",37811:"astc-6x5-unorm",37843:"astc-6x5-unorm-srgb",37812:"astc-6x6-unorm",37844:"astc-6x6-unorm-srgb",37813:"astc-8x5-unorm",37845:"astc-8x5-unorm-srgb",37814:"astc-8x6-unorm",37846:"astc-8x6-unorm-srgb",37815:"astc-8x8-unorm",37847:"astc-8x8-unorm-srgb",37816:"astc-10x5-unorm",37848:"astc-10x5-unorm-srgb",37817:"astc-10x6-unorm",37849:"astc-10x6-unorm-srgb",37818:"astc-10x8-unorm",37850:"astc-10x8-unorm-srgb",37819:"astc-10x10-unorm",37851:"astc-10x10-unorm-srgb",37820:"astc-12x10-unorm",37852:"astc-12x10-unorm-srgb",37821:"astc-12x12-unorm",37853:"astc-12x12-unorm-srgb",36492:"bc7-rgba-unorm",36493:"bc7-rgba-unorm-srgb",36494:"bc6h-rgb-float",36495:"bc6h-rgb-ufloat",35907:"rgba8unorm-srgb",36759:"rgba8snorm",36220:"rgba8uint",36238:"rgba8sint",6408:"rgba8unorm"},FIELDS:{FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},TYPES_TO_BYTES_PER_COMPONENT:{5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},TYPES_TO_BYTES_PER_PIXEL:{32819:2,32820:2,33635:2},ENDIANNESS:67305985};function Xg(r,t){const e=new DataView(r);if(!fE(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:i,glType:s,glFormat:n,glInternalFormat:o,pixelWidth:a,pixelHeight:l,numberOfMipmapLevels:u,offset:h}=pE(e),c=it.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 p=dE(s,n,o),f=cE(e,s,p,a,l,h,u,i);return{format:c,width:a,height:l,resource:f,alphaMode:"no-premultiply-alpha"}}function cE(r,t,e,i,s,n,o,a){const l=i+3&-4,u=s+3&-4;let h=i*s;t===0&&(h=l*u);let c=h*e,p=i,f=s,m=l,_=u,g=n;const b=new Array(o);for(let y=0;y<o;y++){const v=r.getUint32(g,a);let x=g+4;b[y]=new Uint8Array(r.buffer,x,c),x+=c,g+=v+4,g=g%4!==0?g+4-g%4:g,p=p>>1||1,f=f>>1||1,m=p+4-1&-4,_=f+4-1&-4,c=m*_*e}return b}function dE(r,t,e){let i=it.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(it.TYPES_TO_BYTES_PER_COMPONENT[r]?i=it.TYPES_TO_BYTES_PER_COMPONENT[r]*it.FORMATS_TO_COMPONENTS[t]:i=it.TYPES_TO_BYTES_PER_PIXEL[r]),i===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return i}function pE(r){const t=r.getUint32(it.FIELDS.ENDIANNESS,!0)===it.ENDIANNESS,e=r.getUint32(it.FIELDS.GL_TYPE,t),i=r.getUint32(it.FIELDS.GL_FORMAT,t),s=r.getUint32(it.FIELDS.GL_INTERNAL_FORMAT,t),n=r.getUint32(it.FIELDS.PIXEL_WIDTH,t),o=r.getUint32(it.FIELDS.PIXEL_HEIGHT,t)||1,a=r.getUint32(it.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(it.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(it.FIELDS.NUMBER_OF_FACES,t),h=r.getUint32(it.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),c=r.getUint32(it.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(o===0||a!==1)throw new Error("Only 2D textures are supported");if(u!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(l!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:i,glInternalFormat:s,pixelWidth:n,pixelHeight:o,numberOfMipmapLevels:h,offset:it.FILE_HEADER_SIZE+c}}function fE(r){for(let t=0;t<it.FILE_IDENTIFIER.length;t++)if(r.getUint8(t)!==it.FILE_IDENTIFIER[t])return!1;return!0}const mE={extension:{type:T.LoadParser,priority:Et.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return Dt(r,".ktx")},async load(r,t,e){const i=await si(),s=await(await fetch(r)).arrayBuffer(),n=Xg(s,i),o=new ii(n);return ce(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},gE='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e<o.length;e++)o[e]=n(o[e]);r.format=s[t].convertedFormat}}function i(r){const t=r.byteLength/3,n=new Uint32Array(t);for(let o=0;o<t;++o)n[o]=r[o*3]+(r[o*3+1]<<8)+(r[o*3+2]<<16)+4278190080;return new Uint8Array(n.buffer)}function d(r){const t=[];for(let n=0;n<r.numLevels;n++){const o=r.getImageData(n,0,0),e=new Uint8Array(o.byteLength);e.set(o),t.push(e)}return t}const w={6408:"rgba8unorm",32856:"bgra8unorm",32857:"rgb10a2unorm",33189:"depth16unorm",33190:"depth24plus",33321:"r8unorm",33323:"rg8unorm",33325:"r16float",33326:"r32float",33327:"rg16float",33328:"rg32float",33329:"r8sint",33330:"r8uint",33331:"r16sint",33332:"r16uint",33333:"r32sint",33334:"r32uint",33335:"rg8sint",33336:"rg8uint",33337:"rg16sint",33338:"rg16uint",33339:"rg32sint",33340:"rg32uint",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",34836:"rgba32float",34842:"rgba16float",35056:"depth24plus-stencil8",35898:"rg11b10ufloat",35901:"rgb9e5ufloat",35907:"rgba8unorm-srgb",36012:"depth32float",36013:"depth32float-stencil8",36168:"stencil8",36208:"rgba32uint",36214:"rgba16uint",36220:"rgba8uint",36226:"rgba32sint",36232:"rgba16sint",36238:"rgba8sint",36492:"bc7-rgba-unorm",36756:"r8snorm",36757:"rg8snorm",36759:"rgba8snorm",37496:"etc2-rgba8unorm",37808:"astc-4x4-unorm"};function p(r){const t=w[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const h={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function F(r){const t=h[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function U(r){return r.classId===2?F(r.vkFormat):p(r.glInternalformat)}const T={"bc3-rgba-unorm":"BC3_RGBA","bc7-rgba-unorm":"BC7_M5_RGBA","etc2-rgba8unorm":"ETC2_RGBA","astc-4x4-unorm":"ASTC_4x4_RGBA",rgba8unorm:"RGBA32",rg11b10ufloat:"R11F_G11F_B10F"};function y(r){const t=T[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const a={jsUrl:"",wasmUrl:""};let l,u,c;async function g(){if(!c){const r=new URL(a.jsUrl,location.origin).href,t=new URL(a.wasmUrl,location.origin).href;importScripts(r),c=new Promise(n=>{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=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 pr=null;class Hg{constructor(){pr||(pr=URL.createObjectURL(new Blob([gE],{type:"application/javascript"}))),this.worker=new Worker(pr)}}Hg.revokeObjectURL=function(){pr&&(URL.revokeObjectURL(pr),pr=null)};const Cs={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.wasm"};function _E(r){Object.assign(Cs,r)}let oi;const jg={};function bE(r){return oi||(oi=new Hg().worker,oi.onmessage=t=>{const{success:e,url:i,textureOptions:s}=t.data;e||console.warn("Failed to load KTX texture",i),jg[i](s)},oi.postMessage({type:"init",jsUrl:Cs.jsUrl,wasmUrl:Cs.wasmUrl,supportedTextures:r})),oi}function zg(r,t){const e=bE(t);return new Promise(i=>{jg[r]=i,e.postMessage({type:"load",url:r})})}const vE={extension:{type:T.LoadParser,priority:Et.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return Dt(r,".ktx2")},async load(r,t,e){const i=await si(),s=await zg(r,i),n=new ii(s);return ce(n,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},ol={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:Vg},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:Vg}};function yE(r){const t=r.format;if(ol[t]){const e=ol[t].convertFunction,i=r.resource;for(let s=0;s<i.length;s++)i[s]=e(i[s]);r.format=ol[t].convertedFormat}}function Vg(r){const t=r.byteLength/3,e=new Uint32Array(t);for(let i=0;i<t;++i)e[i]=r[i*3]+(r[i*3+1]<<8)+(r[i*3+2]<<16)+4278190080;return new Uint8Array(e.buffer)}function xE(r){const t=[];for(let e=0;e<r.numLevels;e++){const i=r.getImageData(e,0,0),s=new Uint8Array(i.byteLength);s.set(i),t.push(s)}return t}const TE={6408:"rgba8unorm",32856:"bgra8unorm",32857:"rgb10a2unorm",33189:"depth16unorm",33190:"depth24plus",33321:"r8unorm",33323:"rg8unorm",33325:"r16float",33326:"r32float",33327:"rg16float",33328:"rg32float",33329:"r8sint",33330:"r8uint",33331:"r16sint",33332:"r16uint",33333:"r32sint",33334:"r32uint",33335:"rg8sint",33336:"rg8uint",33337:"rg16sint",33338:"rg16uint",33339:"rg32sint",33340:"rg32uint",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",34836:"rgba32float",34842:"rgba16float",35056:"depth24plus-stencil8",35898:"rg11b10ufloat",35901:"rgb9e5ufloat",35907:"rgba8unorm-srgb",36012:"depth32float",36013:"depth32float-stencil8",36168:"stencil8",36208:"rgba32uint",36214:"rgba16uint",36220:"rgba8uint",36226:"rgba32sint",36232:"rgba16sint",36238:"rgba8sint",36492:"bc7-rgba-unorm",36756:"r8snorm",36757:"rg8snorm",36759:"rgba8snorm",37496:"etc2-rgba8unorm",37808:"astc-4x4-unorm"};function Wg(r){const t=TE[r];if(t)return t;throw new Error(`Unsupported glInternalFormat: ${r}`)}const SE={23:"rgb8unorm",37:"rgba8unorm",43:"rgba8unorm-srgb"};function Yg(r){const t=SE[r];if(t)return t;throw new Error(`Unsupported VkFormat: ${r}`)}function AE(r){return r.classId===2?Yg(r.vkFormat):Wg(r.glInternalformat)}const EE={"bc3-rgba-unorm":"BC3_RGBA","bc7-rgba-unorm":"BC7_M5_RGBA","etc2-rgba8unorm":"ETC2_RGBA","astc-4x4-unorm":"ASTC_4x4_RGBA",rgba8unorm:"RGBA32",rg11b10ufloat:"R11F_G11F_B10F"};function PE(r){const t=EE[r];if(t)return t;throw new Error(`Unsupported transcoderFormat: ${r}`)}const Os=["basis","bc7","bc6h","astc","etc2","bc5","bc4","bc3","bc2","bc1","eac"],wE={extension:T.ResolveParser,test:r=>Dt(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let i;const s=r.split(".");if(s.length>2){const n=s[s.length-2];Os.includes(n)&&(i=n)}else i=s[s.length-1];return{resolution:parseFloat((e=(t=oe.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i,src:r}}};let Gs;const RE={extension:{type:T.DetectionParser,priority:2},test:async()=>!!(await Qr()||Zr()),add:async r=>{const t=await rl();return Gs=ME(t),[...Gs,...r]},remove:async r=>Gs?r.filter(t=>!(t in Gs)):r};function ME(r){const t=["basis"],e={};return r.forEach(i=>{const s=i.split("-")[0];s&&!e[s]&&(e[s]=!0,t.push(s))}),t.sort((i,s)=>{const n=Os.indexOf(i),o=Os.indexOf(s);return n===-1?1:o===-1?-1:n-o}),t}const CE=new ot,al=class{cull(t,e,i=!0){this._cullRecursive(t,e,i)}_cullRecursive(t,e,i=!0){var s;if(t.cullable&&t.measurable&&t.includeInBuild){const n=(s=t.cullArea)!=null?s:Tr(t,i,CE);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n<t.children.length;n++)this._cullRecursive(t.children[n],e,i)}};al.shared=new al;let Kg=al;class qg{static init(t){this._renderRef=this.render.bind(this),this.render=()=>{var e;const i=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;Kg.shared.cull(this.stage,this.renderer.screen,i),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}qg.extension={priority:10,type:T.Application,name:"culler"};const OE={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return U2})}};var Zg=`
|
|
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}
|
|
}
|
|
`,Qg=`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();
|
|
}
|
|
`,Jg=`
|
|
struct GlobalFilterUniforms {
|
|
uInputSize:vec4<f32>,
|
|
uInputPixel:vec4<f32>,
|
|
uInputClamp:vec4<f32>,
|
|
uOutputFrame:vec4<f32>,
|
|
uGlobalFrame:vec4<f32>,
|
|
uOutputTexture:vec4<f32>,
|
|
};
|
|
|
|
struct BlendUniforms {
|
|
uBlend:f32,
|
|
};
|
|
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler : sampler;
|
|
@group(0) @binding(3) var uBackTexture: texture_2d<f32>;
|
|
|
|
@group(1) @binding(0) var<uniform> blendUniforms : BlendUniforms;
|
|
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv : vec2<f32>
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
}
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition : vec2<f32>,
|
|
) -> VSOutput {
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
filterTextureCoord(aPosition)
|
|
);
|
|
}
|
|
|
|
{FUNCTIONS}
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
|
|
var back = textureSample(uBackTexture, uSampler, uv);
|
|
var front = textureSample(uTexture, uSampler, uv);
|
|
var blendedAlpha = front.a + back.a * (1.0 - front.a);
|
|
|
|
var out = vec4<f32>(0.0,0.0,0.0,0.0);
|
|
|
|
{MAIN}
|
|
|
|
return out;
|
|
}`,GE=Object.defineProperty,t_=Object.getOwnPropertySymbols,BE=Object.prototype.hasOwnProperty,IE=Object.prototype.propertyIsEnumerable,e_=(r,t,e)=>t in r?GE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,r_=(r,t)=>{for(var e in t||(t={}))BE.call(t,e)&&e_(r,e,t[e]);if(t_)for(var e of t_(t))IE.call(t,e)&&e_(r,e,t[e]);return r};class FE extends Jt{constructor(t){const e=t.gpu,i=i_(r_({source:Jg},e)),s=dt.from({vertex:{source:i,entryPoint:"mainVertex"},fragment:{source:i,entryPoint:"mainFragment"}}),n=t.gl,o=i_(r_({source:Zg},n)),a=vt.from({vertex:Qg,fragment:o}),l=new nt({uBlend:{value:1,type:"f32"}});super({gpuProgram:s,glProgram:a,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:w.EMPTY}})}}function i_(r){const{source:t,functions:e,main:i}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}const DE=`
|
|
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;
|
|
}
|
|
`,UE=`
|
|
fn getLuminosity(c: vec3<f32>) -> f32
|
|
{
|
|
return 0.3*c.r + 0.59*c.g + 0.11*c.b;
|
|
}
|
|
|
|
fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32>
|
|
{
|
|
var modLum: f32 = lum - getLuminosity(c);
|
|
var color: vec3<f32> = c.rgb + modLum;
|
|
|
|
// clip back into legal range
|
|
modLum = getLuminosity(color);
|
|
let modLumVec = vec3<f32>(modLum);
|
|
|
|
let cMin: f32 = min(color.r, min(color.g, color.b));
|
|
let cMax: f32 = max(color.r, max(color.g, color.b));
|
|
|
|
if(cMin < 0.0)
|
|
{
|
|
color = mix(modLumVec, color, modLum / (modLum - cMin));
|
|
}
|
|
|
|
if(cMax > 1.0)
|
|
{
|
|
color = mix(modLumVec, color, (1 - modLum) / (cMax - modLum));
|
|
}
|
|
|
|
return color;
|
|
}
|
|
|
|
fn getSaturation(c: vec3<f32>) -> f32
|
|
{
|
|
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
|
|
}
|
|
|
|
fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32>
|
|
{
|
|
var colorSorted = cSorted;
|
|
|
|
if(colorSorted.z > colorSorted.x)
|
|
{
|
|
colorSorted.y = (((colorSorted.y - colorSorted.x) * s) / (colorSorted.z - colorSorted.x));
|
|
colorSorted.z = s;
|
|
}
|
|
else
|
|
{
|
|
colorSorted.y = 0;
|
|
colorSorted.z = 0;
|
|
}
|
|
|
|
colorSorted.x = 0;
|
|
|
|
return colorSorted;
|
|
}
|
|
|
|
fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32>
|
|
{
|
|
var color = c;
|
|
|
|
if (color.r <= color.g && color.r <= color.b)
|
|
{
|
|
if (color.g <= color.b)
|
|
{
|
|
color = vec3<f32>(setSaturationMinMidMax(color.rgb, s)).rgb;
|
|
}
|
|
else
|
|
{
|
|
color = vec3<f32>(setSaturationMinMidMax(color.rbg, s)).rbg;
|
|
}
|
|
}
|
|
else if (color.g <= color.r && color.g <= color.b)
|
|
{
|
|
if (color.r <= color.b)
|
|
{
|
|
color = vec3<f32>(setSaturationMinMidMax(color.grb, s)).grb;
|
|
}
|
|
else
|
|
{
|
|
color = vec3<f32>(setSaturationMinMidMax(color.gbr, s)).gbr;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Using bgr for both fixes part of hue
|
|
if (color.r <= color.g)
|
|
{
|
|
color = vec3<f32>(setSaturationMinMidMax(color.brg, s)).brg;
|
|
}
|
|
else
|
|
{
|
|
color = vec3<f32>(setSaturationMinMidMax(color.bgr, s)).bgr;
|
|
}
|
|
}
|
|
|
|
return color;
|
|
}
|
|
`;var s_=`
|
|
in vec2 vTextureCoord;
|
|
|
|
out vec4 finalColor;
|
|
|
|
uniform float uAlpha;
|
|
uniform sampler2D uTexture;
|
|
|
|
void main()
|
|
{
|
|
finalColor = texture(uTexture, vTextureCoord) * uAlpha;
|
|
}
|
|
`,ll=`struct GlobalFilterUniforms {
|
|
uInputSize:vec4<f32>,
|
|
uInputPixel:vec4<f32>,
|
|
uInputClamp:vec4<f32>,
|
|
uOutputFrame:vec4<f32>,
|
|
uGlobalFrame:vec4<f32>,
|
|
uOutputTexture:vec4<f32>,
|
|
};
|
|
|
|
struct AlphaUniforms {
|
|
uAlpha:f32,
|
|
};
|
|
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler : sampler;
|
|
|
|
@group(1) @binding(0) var<uniform> alphaUniforms : AlphaUniforms;
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv : vec2<f32>
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
}
|
|
|
|
fn getSize() -> vec2<f32>
|
|
{
|
|
return gfu.uGlobalFrame.zw;
|
|
}
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition : vec2<f32>,
|
|
) -> VSOutput {
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
filterTextureCoord(aPosition)
|
|
);
|
|
}
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>,
|
|
@builtin(position) position: vec4<f32>
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
var sample = textureSample(uTexture, uSampler, uv);
|
|
|
|
return sample * alphaUniforms.uAlpha;
|
|
}`,kE=Object.defineProperty,$E=Object.defineProperties,LE=Object.getOwnPropertyDescriptors,Bs=Object.getOwnPropertySymbols,n_=Object.prototype.hasOwnProperty,o_=Object.prototype.propertyIsEnumerable,a_=(r,t,e)=>t in r?kE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ul=(r,t)=>{for(var e in t||(t={}))n_.call(t,e)&&a_(r,e,t[e]);if(Bs)for(var e of Bs(t))o_.call(t,e)&&a_(r,e,t[e]);return r},NE=(r,t)=>$E(r,LE(t)),XE=(r,t)=>{var e={};for(var i in r)n_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Bs)for(var i of Bs(r))t.indexOf(i)<0&&o_.call(r,i)&&(e[i]=r[i]);return e};const l_=class zx extends Jt{constructor(t){t=ul(ul({},zx.defaultOptions),t);const e=dt.from({vertex:{source:ll,entryPoint:"mainVertex"},fragment:{source:ll,entryPoint:"mainFragment"}}),i=vt.from({vertex:Yr,fragment:s_,name:"alpha-filter"}),s=t,{alpha:n}=s,o=XE(s,["alpha"]),a=new nt({uAlpha:{value:n,type:"f32"}});super(NE(ul({},o),{gpuProgram:e,glProgram:i,resources:{alphaUniforms:a}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};l_.defaultOptions={alpha:1};let HE=l_;const hl={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},jE=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," finalColor = vec4(0.0);"," %blur%","}"].join(`
|
|
`);function u_(r){const t=hl[r],e=t.length;let i=jE,s="";const n="finalColor += texture(uTexture, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
|
|
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const zE=`
|
|
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 h_(r,t){const e=Math.ceil(r/2);let i=zE,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * pixelStrength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * pixelStrength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
|
|
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i=i.replace("%dimension%",t?"z":"w"),i}function c_(r,t){const e=h_(t,r),i=u_(t);return vt.from({vertex:e,fragment:i,name:`blur-${r?"horizontal":"vertical"}-pass-filter`})}var d_=`
|
|
|
|
struct GlobalFilterUniforms {
|
|
uInputSize:vec4<f32>,
|
|
uInputPixel:vec4<f32>,
|
|
uInputClamp:vec4<f32>,
|
|
uOutputFrame:vec4<f32>,
|
|
uGlobalFrame:vec4<f32>,
|
|
uOutputTexture:vec4<f32>,
|
|
};
|
|
|
|
struct BlurUniforms {
|
|
uStrength:f32,
|
|
};
|
|
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler : sampler;
|
|
|
|
@group(1) @binding(0) var<uniform> blurUniforms : BlurUniforms;
|
|
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
%blur-struct%
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
}
|
|
|
|
fn getSize() -> vec2<f32>
|
|
{
|
|
return gfu.uGlobalFrame.zw;
|
|
}
|
|
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition : vec2<f32>,
|
|
) -> VSOutput {
|
|
|
|
let filteredCord = filterTextureCoord(aPosition);
|
|
|
|
let pixelStrength = gfu.uInputSize.%dimension% * blurUniforms.uStrength;
|
|
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
%blur-vertex-out%
|
|
);
|
|
}
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@builtin(position) position: vec4<f32>,
|
|
%blur-fragment-in%
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
var finalColor = vec4(0.0);
|
|
|
|
%blur-sampling%
|
|
|
|
return finalColor;
|
|
}`;function p_(r,t){const e=hl[t],i=e.length,s=[],n=[],o=[];for(let c=0;c<t;c++){s[c]=`@location(${c}) offset${c}: vec2<f32>,`,r?n[c]=`filteredCord + vec2(${c-i+1} * pixelStrength, 0.0),`:n[c]=`filteredCord + vec2(0.0, ${c-i+1} * pixelStrength),`;const p=c<i?c:t-c-1,f=e[p].toString();o[c]=`finalColor += textureSample(uTexture, uSampler, offset${c}) * ${f};`}const a=s.join(`
|
|
`),l=n.join(`
|
|
`),u=o.join(`
|
|
`),h=d_.replace("%blur-struct%",a).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",a).replace("%blur-sampling%",u).replace("%dimension%",r?"z":"w");return dt.from({vertex:{source:h,entryPoint:"mainVertex"},fragment:{source:h,entryPoint:"mainFragment"}})}var VE=Object.defineProperty,f_=Object.getOwnPropertySymbols,WE=Object.prototype.hasOwnProperty,YE=Object.prototype.propertyIsEnumerable,m_=(r,t,e)=>t in r?VE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cl=(r,t)=>{for(var e in t||(t={}))WE.call(t,e)&&m_(r,e,t[e]);if(f_)for(var e of f_(t))YE.call(t,e)&&m_(r,e,t[e]);return r};const g_=class Vx extends Jt{constructor(t){t=cl(cl({},Vx.defaultOptions),t);const e=c_(t.horizontal,t.kernelSize),i=p_(t.horizontal,t.kernelSize);super(cl({glProgram:e,gpuProgram:i,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._uniforms=this.resources.blurUniforms.uniforms}apply(t,e,i,s){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=et.getSameSizeTexture(e);let o=e,a=n;this._state.blend=!1;const l=t.renderer.type===yt.WEBGPU;for(let u=0;u<this.passes-1;u++){t.applyFilter(this,o,a,u===0?!0:l);const h=a;a=o,o=h}this._state.blend=!0,t.applyFilter(this,o,i,s),et.returnTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}};g_.defaultOptions={strength:8,quality:4,kernelSize:5};let Is=g_;var KE=Object.defineProperty,qE=Object.defineProperties,ZE=Object.getOwnPropertyDescriptors,Fs=Object.getOwnPropertySymbols,__=Object.prototype.hasOwnProperty,b_=Object.prototype.propertyIsEnumerable,v_=(r,t,e)=>t in r?KE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ai=(r,t)=>{for(var e in t||(t={}))__.call(t,e)&&v_(r,e,t[e]);if(Fs)for(var e of Fs(t))b_.call(t,e)&&v_(r,e,t[e]);return r},QE=(r,t)=>qE(r,ZE(t)),JE=(r,t)=>{var e={};for(var i in r)__.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Fs)for(var i of Fs(r))t.indexOf(i)<0&&b_.call(r,i)&&(e[i]=r[i]);return e};class y_ extends Jt{constructor(...t){var e;let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={strength:i},t[1]!==void 0&&(i.quality=t[1]),t[2]!==void 0&&(i.resolution=t[2]||"inherit"),t[3]!==void 0&&(i.kernelSize=t[3])),i=ai(ai({},Is.defaultOptions),i);const s=i,{strength:n,strengthX:o,strengthY:a,quality:l}=s,u=JE(s,["strength","strengthX","strengthY","quality"]);super(QE(ai({},u),{compatibleRenderers:yt.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new Is(ai({horizontal:!0},i)),this.blurYFilter=new Is(ai({horizontal:!1},i)),this.quality=l,this.strengthX=o!=null?o:n,this.strengthY=a!=null?a:n,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=et.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,a,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,a,i,s),et.returnTexture(a)}else o?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,i,s)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,i,s))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return this.strength}set blur(t){this.strength=t}get blurX(){return this.strengthX}set blurX(t){this.strengthX=t}get blurY(){return this.strengthY}set blurY(t){this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}y_.defaultOptions={strength:8,quality:4,kernelSize:5};var x_=`
|
|
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);
|
|
}
|
|
`,dl=`struct GlobalFilterUniforms {
|
|
uInputSize:vec4<f32>,
|
|
uInputPixel:vec4<f32>,
|
|
uInputClamp:vec4<f32>,
|
|
uOutputFrame:vec4<f32>,
|
|
uGlobalFrame:vec4<f32>,
|
|
uOutputTexture:vec4<f32>,
|
|
};
|
|
|
|
struct ColorMatrixUniforms {
|
|
uColorMatrix:array<vec4<f32>, 5>,
|
|
uAlpha:f32,
|
|
};
|
|
|
|
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler : sampler;
|
|
@group(1) @binding(0) var<uniform> colorMatrixUniforms : ColorMatrixUniforms;
|
|
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv : vec2<f32>,
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition : vec2<f32>,
|
|
) -> VSOutput {
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
filterTextureCoord(aPosition),
|
|
);
|
|
}
|
|
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>,
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
|
|
var c = textureSample(uTexture, uSampler, uv);
|
|
|
|
if (colorMatrixUniforms.uAlpha == 0.0) {
|
|
return c;
|
|
}
|
|
|
|
|
|
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
|
if (c.a > 0.0) {
|
|
c.r /= c.a;
|
|
c.g /= c.a;
|
|
c.b /= c.a;
|
|
}
|
|
|
|
var cm = colorMatrixUniforms.uColorMatrix;
|
|
|
|
|
|
var result = vec4<f32>(0.);
|
|
|
|
result.r = (cm[0][0] * c.r);
|
|
result.r += (cm[0][1] * c.g);
|
|
result.r += (cm[0][2] * c.b);
|
|
result.r += (cm[0][3] * c.a);
|
|
result.r += cm[1][0];
|
|
|
|
result.g = (cm[1][1] * c.r);
|
|
result.g += (cm[1][2] * c.g);
|
|
result.g += (cm[1][3] * c.b);
|
|
result.g += (cm[2][0] * c.a);
|
|
result.g += cm[2][1];
|
|
|
|
result.b = (cm[2][2] * c.r);
|
|
result.b += (cm[2][3] * c.g);
|
|
result.b += (cm[3][0] * c.b);
|
|
result.b += (cm[3][1] * c.a);
|
|
result.b += cm[3][2];
|
|
|
|
result.a = (cm[3][3] * c.r);
|
|
result.a += (cm[4][0] * c.g);
|
|
result.a += (cm[4][1] * c.b);
|
|
result.a += (cm[4][2] * c.a);
|
|
result.a += cm[4][3];
|
|
|
|
var rgb = mix(c.rgb, result.rgb, colorMatrixUniforms.uAlpha);
|
|
|
|
rgb.r *= result.a;
|
|
rgb.g *= result.a;
|
|
rgb.b *= result.a;
|
|
|
|
return vec4(rgb, result.a);
|
|
}`,tP=Object.defineProperty,eP=Object.defineProperties,rP=Object.getOwnPropertyDescriptors,T_=Object.getOwnPropertySymbols,iP=Object.prototype.hasOwnProperty,sP=Object.prototype.propertyIsEnumerable,S_=(r,t,e)=>t in r?tP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nP=(r,t)=>{for(var e in t||(t={}))iP.call(t,e)&&S_(r,e,t[e]);if(T_)for(var e of T_(t))sP.call(t,e)&&S_(r,e,t[e]);return r},oP=(r,t)=>eP(r,rP(t));class aP extends Jt{constructor(t={}){const e=new nt({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),i=dt.from({vertex:{source:dl,entryPoint:"mainVertex"},fragment:{source:dl,entryPoint:"mainFragment"}}),s=vt.from({vertex:Yr,fragment:x_,name:"color-matrix-filter"});super(oP(nP({},t),{gpuProgram:i,glProgram:s,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.matrix,t),i=this._colorMatrix(i)),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=i,this.resources.colorMatrixUniforms.update()}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=H.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,u=o*(1-i)-a*s,h=o*(1-i)+a*s,c=o*(1-i)+a*s,p=i+o*(1-i),f=o*(1-i)-a*s,m=o*(1-i)-a*s,_=o*(1-i)+a*s,g=i+o*(1-i),b=[l,u,h,0,0,c,p,f,0,0,m,_,g,0,0,0,0,0,1,0];this._loadMatrix(b,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t||(t=.2),e||(e=.15),i||(i=16770432),s||(s=3375104);const o=H.shared,[a,l,u]=o.setValue(i).toArray(),[h,c,p]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,u,t,0,h,c,p,e,0,a-h,l-c,u-p,0,0];this._loadMatrix(f,n)}night(t,e){t||(t=.1);const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var A_=`
|
|
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));
|
|
}
|
|
`,E_=`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();
|
|
}
|
|
`,pl=`
|
|
struct GlobalFilterUniforms {
|
|
uInputSize:vec4<f32>,
|
|
uInputPixel:vec4<f32>,
|
|
uInputClamp:vec4<f32>,
|
|
uOutputFrame:vec4<f32>,
|
|
uGlobalFrame:vec4<f32>,
|
|
uOutputTexture:vec4<f32>,
|
|
};
|
|
|
|
struct DisplacementUniforms {
|
|
uFilterMatrix:mat3x3<f32>,
|
|
uScale:vec2<f32>,
|
|
uRotation:mat2x2<f32>
|
|
};
|
|
|
|
|
|
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler : sampler;
|
|
|
|
@group(1) @binding(0) var<uniform> filterUniforms : DisplacementUniforms;
|
|
@group(1) @binding(1) var uMapTexture: texture_2d<f32>;
|
|
@group(1) @binding(2) var uMapSampler : sampler;
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv : vec2<f32>,
|
|
@location(1) filterUv : vec2<f32>,
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
}
|
|
|
|
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
}
|
|
|
|
fn getSize() -> vec2<f32>
|
|
{
|
|
|
|
|
|
return gfu.uGlobalFrame.zw;
|
|
}
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition : vec2<f32>,
|
|
) -> VSOutput {
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
filterTextureCoord(aPosition),
|
|
getFilterCoord(aPosition)
|
|
);
|
|
}
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>,
|
|
@location(1) filterUv: vec2<f32>,
|
|
@builtin(position) position: vec4<f32>
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
var map = textureSample(uMapTexture, uMapSampler, filterUv);
|
|
|
|
var offset = gfu.uInputSize.zw * (filterUniforms.uRotation * (map.xy - 0.5)) * filterUniforms.uScale;
|
|
|
|
return textureSample(uTexture, uSampler, clamp(uv + offset, gfu.uInputClamp.xy, gfu.uInputClamp.zw));
|
|
}`,lP=Object.defineProperty,uP=Object.defineProperties,hP=Object.getOwnPropertyDescriptors,Ds=Object.getOwnPropertySymbols,P_=Object.prototype.hasOwnProperty,w_=Object.prototype.propertyIsEnumerable,R_=(r,t,e)=>t in r?lP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cP=(r,t)=>{for(var e in t||(t={}))P_.call(t,e)&&R_(r,e,t[e]);if(Ds)for(var e of Ds(t))w_.call(t,e)&&R_(r,e,t[e]);return r},dP=(r,t)=>uP(r,hP(t)),pP=(r,t)=>{var e={};for(var i in r)P_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ds)for(var i of Ds(r))t.indexOf(i)<0&&w_.call(r,i)&&(e[i]=r[i]);return e};class fP extends Jt{constructor(...t){let e=t[0];e instanceof $t&&(e={sprite:e,scale:t[1]});const i=e,{sprite:s,scale:n}=i,o=pP(i,["sprite","scale"]);let a=n!=null?n:20;typeof a=="number"&&(a=new W(a,a));const l=new nt({uFilterMatrix:{value:new M,type:"mat3x3<f32>"},uScale:{value:a,type:"vec2<f32>"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2<f32>"}}),u=vt.from({vertex:E_,fragment:A_,name:"displacement-filter"}),h=dt.from({vertex:{source:pl,entryPoint:"mainVertex"},fragment:{source:pl,entryPoint:"mainFragment"}}),c=s.texture.source;super(dP(cP({},o),{gpuProgram:h,glProgram:u,resources:{filterUniforms:l,uMapTexture:c,uMapSampler:c.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,s){const n=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(n.uFilterMatrix,this._sprite);const o=this._sprite.worldTransform,a=Math.sqrt(o.a*o.a+o.b*o.b),l=Math.sqrt(o.c*o.c+o.d*o.d);a!==0&&l!==0&&(n.uRotation[0]=o.a/a,n.uRotation[1]=o.b/a,n.uRotation[2]=o.c/l,n.uRotation[3]=o.d/l),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,i,s)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var M_=`
|
|
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;
|
|
}
|
|
`,fl=`
|
|
|
|
struct GlobalFilterUniforms {
|
|
uInputSize:vec4<f32>,
|
|
uInputPixel:vec4<f32>,
|
|
uInputClamp:vec4<f32>,
|
|
uOutputFrame:vec4<f32>,
|
|
uGlobalFrame:vec4<f32>,
|
|
uOutputTexture:vec4<f32>,
|
|
};
|
|
|
|
struct NoiseUniforms {
|
|
uNoise:f32,
|
|
uSeed:f32,
|
|
};
|
|
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler : sampler;
|
|
|
|
@group(1) @binding(0) var<uniform> noiseUniforms : NoiseUniforms;
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv : vec2<f32>
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
}
|
|
|
|
fn getSize() -> vec2<f32>
|
|
{
|
|
return gfu.uGlobalFrame.zw;
|
|
}
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition : vec2<f32>,
|
|
) -> VSOutput {
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
filterTextureCoord(aPosition)
|
|
);
|
|
}
|
|
|
|
fn rand(co:vec2<f32>) -> f32
|
|
{
|
|
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
}
|
|
|
|
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>,
|
|
@builtin(position) position: vec4<f32>
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
var pixelPosition = globalTextureCoord(position.xy);// / (getSize());//- gfu.uOutputFrame.xy);
|
|
|
|
|
|
var sample = textureSample(uTexture, uSampler, uv);
|
|
var randomValue = rand(pixelPosition.xy * noiseUniforms.uSeed);
|
|
var diff = (randomValue - 0.5) * noiseUniforms.uNoise;
|
|
|
|
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
|
if (sample.a > 0.0) {
|
|
sample.r /= sample.a;
|
|
sample.g /= sample.a;
|
|
sample.b /= sample.a;
|
|
}
|
|
|
|
sample.r += diff;
|
|
sample.g += diff;
|
|
sample.b += diff;
|
|
|
|
// Premultiply alpha again.
|
|
sample.r *= sample.a;
|
|
sample.g *= sample.a;
|
|
sample.b *= sample.a;
|
|
|
|
return sample;
|
|
}`,mP=Object.defineProperty,gP=Object.defineProperties,_P=Object.getOwnPropertyDescriptors,Us=Object.getOwnPropertySymbols,C_=Object.prototype.hasOwnProperty,O_=Object.prototype.propertyIsEnumerable,G_=(r,t,e)=>t in r?mP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ml=(r,t)=>{for(var e in t||(t={}))C_.call(t,e)&&G_(r,e,t[e]);if(Us)for(var e of Us(t))O_.call(t,e)&&G_(r,e,t[e]);return r},bP=(r,t)=>gP(r,_P(t)),vP=(r,t)=>{var e={};for(var i in r)C_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Us)for(var i of Us(r))t.indexOf(i)<0&&O_.call(r,i)&&(e[i]=r[i]);return e};const B_=class Wx extends Jt{constructor(t={}){t=ml(ml({},Wx.defaultOptions),t);const e=dt.from({vertex:{source:fl,entryPoint:"mainVertex"},fragment:{source:fl,entryPoint:"mainFragment"}}),i=vt.from({vertex:Yr,fragment:M_,name:"noise-filter"}),s=t,{noise:n,seed:o}=s,a=vP(s,["noise","seed"]);super(bP(ml({},a),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new nt({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=n,this.seed=o!=null?o:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};B_.defaultOptions={noise:.5};let yP=B_;var I_=`in vec2 vMaskCoord;
|
|
in vec2 vTextureCoord;
|
|
|
|
uniform sampler2D uTexture;
|
|
uniform sampler2D uMaskTexture;
|
|
|
|
uniform float uAlpha;
|
|
uniform vec4 uMaskClamp;
|
|
uniform float uInverse;
|
|
|
|
out vec4 finalColor;
|
|
|
|
void main(void)
|
|
{
|
|
float clip = step(3.5,
|
|
step(uMaskClamp.x, vMaskCoord.x) +
|
|
step(uMaskClamp.y, vMaskCoord.y) +
|
|
step(vMaskCoord.x, uMaskClamp.z) +
|
|
step(vMaskCoord.y, uMaskClamp.w));
|
|
|
|
// TODO look into why this is needed
|
|
float npmAlpha = uAlpha;
|
|
vec4 original = texture(uTexture, vTextureCoord);
|
|
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
|
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
|
|
float a = alphaMul * masky.r * npmAlpha * clip;
|
|
|
|
if (uInverse == 1.0) {
|
|
a = 1.0 - a;
|
|
}
|
|
|
|
finalColor = original * a;
|
|
}
|
|
`,F_=`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);
|
|
}
|
|
`,gl=`struct GlobalFilterUniforms {
|
|
uInputSize:vec4<f32>,
|
|
uInputPixel:vec4<f32>,
|
|
uInputClamp:vec4<f32>,
|
|
uOutputFrame:vec4<f32>,
|
|
uGlobalFrame:vec4<f32>,
|
|
uOutputTexture:vec4<f32>,
|
|
};
|
|
|
|
struct MaskUniforms {
|
|
uFilterMatrix:mat3x3<f32>,
|
|
uMaskClamp:vec4<f32>,
|
|
uAlpha:f32,
|
|
uInverse:f32,
|
|
};
|
|
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(0) @binding(2) var uSampler : sampler;
|
|
|
|
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
|
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
|
|
|
struct VSOutput {
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) uv : vec2<f32>,
|
|
@location(1) filterUv : vec2<f32>,
|
|
};
|
|
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
{
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
|
|
return vec4(position, 0.0, 1.0);
|
|
}
|
|
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
}
|
|
|
|
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
}
|
|
|
|
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
{
|
|
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
}
|
|
|
|
fn getSize() -> vec2<f32>
|
|
{
|
|
return gfu.uGlobalFrame.zw;
|
|
}
|
|
|
|
@vertex
|
|
fn mainVertex(
|
|
@location(0) aPosition : vec2<f32>,
|
|
) -> VSOutput {
|
|
return VSOutput(
|
|
filterVertexPosition(aPosition),
|
|
filterTextureCoord(aPosition),
|
|
getFilterCoord(aPosition)
|
|
);
|
|
}
|
|
|
|
@fragment
|
|
fn mainFragment(
|
|
@location(0) uv: vec2<f32>,
|
|
@location(1) filterUv: vec2<f32>,
|
|
@builtin(position) position: vec4<f32>
|
|
) -> @location(0) vec4<f32> {
|
|
|
|
var maskClamp = filterUniforms.uMaskClamp;
|
|
var uAlpha = filterUniforms.uAlpha;
|
|
|
|
var clip = step(3.5,
|
|
step(maskClamp.x, filterUv.x) +
|
|
step(maskClamp.y, filterUv.y) +
|
|
step(filterUv.x, maskClamp.z) +
|
|
step(filterUv.y, maskClamp.w));
|
|
|
|
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
|
var source = textureSample(uTexture, uSampler, uv);
|
|
var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
|
|
|
|
var a: f32 = alphaMul * mask.r * uAlpha * clip;
|
|
|
|
if (filterUniforms.uInverse == 1.0) {
|
|
a = 1.0 - a;
|
|
}
|
|
|
|
return source * a;
|
|
}
|
|
`,xP=Object.defineProperty,TP=Object.defineProperties,SP=Object.getOwnPropertyDescriptors,ks=Object.getOwnPropertySymbols,D_=Object.prototype.hasOwnProperty,U_=Object.prototype.propertyIsEnumerable,k_=(r,t,e)=>t in r?xP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,AP=(r,t)=>{for(var e in t||(t={}))D_.call(t,e)&&k_(r,e,t[e]);if(ks)for(var e of ks(t))U_.call(t,e)&&k_(r,e,t[e]);return r},EP=(r,t)=>TP(r,SP(t)),PP=(r,t)=>{var e={};for(var i in r)D_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ks)for(var i of ks(r))t.indexOf(i)<0&&U_.call(r,i)&&(e[i]=r[i]);return e};class $_ extends Jt{constructor(t){const e=t,{sprite:i}=e,s=PP(e,["sprite"]),n=new Un(i.texture),o=new nt({uFilterMatrix:{value:new M,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),a=dt.from({vertex:{source:gl,entryPoint:"mainVertex"},fragment:{source:gl,entryPoint:"mainFragment"}}),l=vt.from({vertex:F_,fragment:I_,name:"mask-filter"});super(EP(AP({},s),{gpuProgram:a,glProgram:l,clipToViewport:!1,resources:{filterUniforms:o,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=n}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(t,e,i,s){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,i,s)}}var wP=`fn getLuminosity(c: vec3<f32>) -> f32 {
|
|
return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b;
|
|
}
|
|
|
|
fn setLuminosity(c: vec3<f32>, lum: f32) -> vec3<f32> {
|
|
let d: f32 = lum - getLuminosity(c);
|
|
let newColor: vec3<f32> = c.rgb + vec3<f32>(d, d, d);
|
|
|
|
// clip back into legal range
|
|
let newLum: f32 = getLuminosity(newColor);
|
|
let cMin: f32 = min(newColor.r, min(newColor.g, newColor.b));
|
|
let cMax: f32 = max(newColor.r, max(newColor.g, newColor.b));
|
|
|
|
let t1: f32 = newLum / (newLum - cMin);
|
|
let t2: f32 = (1.0 - newLum) / (cMax - newLum);
|
|
|
|
let finalColor = mix(vec3<f32>(newLum, newLum, newLum), newColor, select(select(1.0, t2, cMax > 1.0), t1, cMin < 0.0));
|
|
|
|
return finalColor;
|
|
}
|
|
|
|
fn getSaturation(c: vec3<f32>) -> f32 {
|
|
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
|
|
}
|
|
|
|
// Set saturation if color components are sorted in ascending order.
|
|
fn setSaturationMinMidMax(cSorted: vec3<f32>, s: f32) -> vec3<f32> {
|
|
var result: vec3<f32>;
|
|
if (cSorted.z > cSorted.x) {
|
|
let newY = (((cSorted.y - cSorted.x) * s) / (cSorted.z - cSorted.x));
|
|
result = vec3<f32>(0.0, newY, s);
|
|
} else {
|
|
result = vec3<f32>(0.0, 0.0, 0.0);
|
|
}
|
|
return vec3<f32>(result.x, result.y, result.z);
|
|
}
|
|
|
|
fn setSaturation(c: vec3<f32>, s: f32) -> vec3<f32> {
|
|
var result: vec3<f32> = c;
|
|
|
|
if (c.r <= c.g && c.r <= c.b) {
|
|
if (c.g <= c.b) {
|
|
result = setSaturationMinMidMax(result, s);
|
|
} else {
|
|
var temp: vec3<f32> = vec3<f32>(result.r, result.b, result.g);
|
|
temp = setSaturationMinMidMax(temp, s);
|
|
result = vec3<f32>(temp.r, temp.b, temp.g);
|
|
}
|
|
} else if (c.g <= c.r && c.g <= c.b) {
|
|
if (c.r <= c.b) {
|
|
var temp: vec3<f32> = vec3<f32>(result.g, result.r, result.b);
|
|
temp = setSaturationMinMidMax(temp, s);
|
|
result = vec3<f32>(temp.g, temp.r, temp.b);
|
|
} else {
|
|
var temp: vec3<f32> = vec3<f32>(result.g, result.b, result.r);
|
|
temp = setSaturationMinMidMax(temp, s);
|
|
result = vec3<f32>(temp.g, temp.b, temp.r);
|
|
}
|
|
} else {
|
|
if (c.r <= c.g) {
|
|
var temp: vec3<f32> = vec3<f32>(result.b, result.r, result.g);
|
|
temp = setSaturationMinMidMax(temp, s);
|
|
result = vec3<f32>(temp.b, temp.r, temp.g);
|
|
} else {
|
|
var temp: vec3<f32> = vec3<f32>(result.b, result.g, result.r);
|
|
temp = setSaturationMinMidMax(temp, s);
|
|
result = vec3<f32>(temp.b, temp.g, temp.r);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}`;const L_=class Yx{constructor(t){this._tick=()=>{this._destroyed||(this.timeout=setTimeout(this._processQueue,0))},this._processQueue=()=>{if(this._destroyed)return;const{queue:e}=this;let i=0;for(;e.length&&i<Yx.uploadsPerFrame;){const s=e.shift();this.uploadQueueItem(s),i++}e.length?at.system.addOnce(this._tick,this,zt.UTILITY):this._resolve()},this.renderer=t,this.queue=[],this.resolves=[]}getQueue(){return[...this.queue]}add(t){const e=Array.isArray(t)?t:[t];for(const i of e)i instanceof q?this._addContainer(i):this.resolveQueueItem(i,this.queue);return this}_addContainer(t){this.resolveQueueItem(t,this.queue);for(const e of t.children)this._addContainer(e)}upload(t){return t&&this.add(t),new Promise(e=>{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),at.system.addOnce(this._tick,this,zt.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let i=0;i<this.queue.length;i++){const s=this.queue[i];t[s.uid]||(t[s.uid]=!0,this.queue[e++]=s)}this.queue.length=e}destroy(){this._destroyed=!0,clearTimeout(this.timeout)}_resolve(){const{resolves:t}=this,e=t.slice(0);t.length=0;for(const i of e)i()}};L_.uploadsPerFrame=4;let N_=L_;var RP=Object.defineProperty,$s=Object.getOwnPropertySymbols,X_=Object.prototype.hasOwnProperty,H_=Object.prototype.propertyIsEnumerable,j_=(r,t,e)=>t in r?RP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,MP=(r,t)=>{for(var e in t||(t={}))X_.call(t,e)&&j_(r,e,t[e]);if($s)for(var e of $s(t))H_.call(t,e)&&j_(r,e,t[e]);return r},CP=(r,t)=>{var e={};for(var i in r)X_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&$s)for(var i of $s(r))t.indexOf(i)<0&&H_.call(r,i)&&(e[i]=r[i]);return e};class fr extends Wt{constructor(...t){var e;let i=t[0];i instanceof Ae&&(i={geometry:i,shader:t[1]},t[3]&&(i.geometry.topology=t[3]));const s=i,{geometry:n,shader:o,texture:a,roundPixels:l,state:u}=s,h=CP(s,["geometry","shader","texture","roundPixels","state"]);super(MP({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:w.WHITE,this.state=u!=null?u:wt.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=l!=null?l:!1}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=w.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||this.state.data&12?!1:this._geometry instanceof ue?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let l=0;l+2<a;l+=n){const u=o[l]*2,h=o[l+1]*2,c=o[l+2]*2;if(Ca(e,i,s[u],s[u+1],s[h],s[h+1],s[c],s[c+1]))return!0}}else{const o=s.length/2;for(let a=0;a+2<o;a+=n){const l=a*2,u=(a+1)*2,h=(a+2)*2;if(Ca(e,i,s[l],s[l+1],s[u],s[u+1],s[h],s[h+1]))return!0}}return!1}destroy(t){var e;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}(e=this._geometry)==null||e.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}var OP=Object.defineProperty,GP=Object.defineProperties,BP=Object.getOwnPropertyDescriptors,Ls=Object.getOwnPropertySymbols,z_=Object.prototype.hasOwnProperty,V_=Object.prototype.propertyIsEnumerable,W_=(r,t,e)=>t in r?OP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,IP=(r,t)=>{for(var e in t||(t={}))z_.call(t,e)&&W_(r,e,t[e]);if(Ls)for(var e of Ls(t))V_.call(t,e)&&W_(r,e,t[e]);return r},FP=(r,t)=>GP(r,BP(t)),DP=(r,t)=>{var e={};for(var i in r)z_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ls)for(var i of Ls(r))t.indexOf(i)<0&&V_.call(r,i)&&(e[i]=r[i]);return e};class li extends $t{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:s=1,autoPlay:n=!1,autoUpdate:o=!0,loop:a=!0,onComplete:l=null,onFrameChange:u=null,onLoop:h=null,textures:c,updateAnchor:p=!1}=i,f=DP(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[m]=c;super(FP(IP({},f),{texture:m instanceof w?m:m.texture})),this._textures=null,this._durations=null,this._autoUpdate=o,this._isConnectedToTicker=!1,this.animationSpeed=s,this.loop=a,this.updateAnchor=p,this.onComplete=l,this.onFrameChange=u,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=c,n&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(at.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(at.shared.add(this.update,this,zt.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,i=this.animationSpeed*e,s=this.currentFrame;if(this._durations!==null){let n=this._currentTime%1*this._durations[this.currentFrame];for(n+=i/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];const o=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*o,this._currentTime+=o;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=i;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if(typeof t=="boolean"?t:t!=null&&t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(i=>{this.texture!==i&&i.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(w.from(t[i]));return new li(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(w.from(t[i]));return new li(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof w)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(let e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}this._previousFrame=null,this.gotoAndStop(0),this._updateTexture()}get currentFrame(){let t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}set currentFrame(t){if(t<0||t>this.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(at.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(at.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Y_{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new M,this.observer=e,this.position=new Z(this,0,0),this.scale=new Z(this,1,1),this.pivot=new Z(this,0,0),this.skew=new Z(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this.dirty=!1),t}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}var UP=Object.defineProperty,Ns=Object.getOwnPropertySymbols,K_=Object.prototype.hasOwnProperty,q_=Object.prototype.propertyIsEnumerable,Z_=(r,t,e)=>t in r?UP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ui=(r,t)=>{for(var e in t||(t={}))K_.call(t,e)&&Z_(r,e,t[e]);if(Ns)for(var e of Ns(t))q_.call(t,e)&&Z_(r,e,t[e]);return r},kP=(r,t)=>{var e={};for(var i in r)K_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ns)for(var i of Ns(r))t.indexOf(i)<0&&q_.call(r,i)&&(e[i]=r[i]);return e};const Q_=class yn extends Wt{constructor(...t){let e=t[0]||{};e instanceof w&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=ui(ui({},yn.defaultOptions),e);const i=e!=null?e:{},{texture:s,anchor:n,tilePosition:o,tileScale:a,tileRotation:l,width:u,height:h,applyAnchorToTexture:c,roundPixels:p}=i,f=kP(i,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(ui({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=s,this._width=u!=null?u:s.width,this._height=h!=null?h:s.height,this._tileTransform=new Y_({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=o,this.tileScale=a,this.tileRotation=l,this.roundPixels=p!=null?p:!1}static from(t,e={}){return typeof t=="string"?new yn(ui({texture:V.get(t)},e)):new yn(ui({texture:t},e))}get uvRespectAnchor(){return Mr(ao,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Mr(ao,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){typeof t=="number"?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=w.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}containsPoint(t){const e=this._width,i=this._height,s=-e*this._anchor._x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this._anchor._y,t.y>=n&&t.y<=n+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};Q_.defaultOptions={texture:w.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let J_=Q_;var $P=Object.defineProperty,Xs=Object.getOwnPropertySymbols,tb=Object.prototype.hasOwnProperty,eb=Object.prototype.propertyIsEnumerable,rb=(r,t,e)=>t in r?$P(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,LP=(r,t)=>{for(var e in t||(t={}))tb.call(t,e)&&rb(r,e,t[e]);if(Xs)for(var e of Xs(t))eb.call(t,e)&&rb(r,e,t[e]);return r},NP=(r,t)=>{var e={};for(var i in r)tb.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Xs)for(var i of Xs(r))t.indexOf(i)<0&&eb.call(r,i)&&(e[i]=r[i]);return e};class Hs extends Wt{constructor(t,e){const i=t,{text:s,resolution:n,style:o,anchor:a,width:l,height:u,roundPixels:h}=i,c=NP(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(LP({},c)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s!=null?s:"",this.style=o,this.resolution=n!=null?n:null,this.allowChildren=!1,this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=h!=null?h:!1,l!==void 0&&(this.width=l),u!==void 0&&(this.height=u)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,s=-e*this.anchor.x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function js(r,t){var e;let i=(e=r[0])!=null?e:{};return(typeof i=="string"||r[1])&&(i={text:i,style:r[1]}),i}class zs extends Hs{constructor(...t){const e=js(t,"Text");super(e,Mt),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof At?e.textureStyle:new At(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=nr.getCanvasAndContext({text:this.text,style:this._style,resolution:1});nr.returnCanvasAndContext(o),i=n.width,s=n.height}else{const n=ct.measureText(this._text,this._style);i=n.width,s=n.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}}class ib extends N_{resolveQueueItem(t,e){return t instanceof q?this.resolveContainerQueueItem(t,e):t instanceof Q||t instanceof w?e.push(t.source):t instanceof pt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof $t||t instanceof J_||t instanceof fr?e.push(t.texture.source):t instanceof zs?e.push(t):t instanceof or?e.push(t.context):t instanceof li&&t.textures.forEach(i=>{i.source?e.push(i.source):e.push(i.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;return s.source}else if(i.action==="fill"){const{texture:s}=i.data.style;return s.source}return null}}class _l extends Hs{constructor(...t){var e,i,s;const n=js(t,"BitmapText");(e=n.style)!=null||(n.style=n.style||{}),(s=(i=n.style).fill)!=null||(i.fill=16777215),super(n,Mt),this.renderPipeId="bitmapText"}updateBounds(){const t=this._bounds,e=this._anchor,i=ar.measureText(this.text,this._style),s=i.scale,n=i.offsetY*s;let o=i.width*s,a=i.height*s;const l=this._style._stroke;l&&(o+=l.width,a+=l.width),t.minX=-e._x*o,t.maxX=t.minX+o,t.minY=-e._y*(a+n),t.maxY=t.minY+a}set resolution(t){}get resolution(){return this._resolution}}function sb(r){const t=r._stroke,e=r._fill,i=[`div { ${[`color: ${H.shared.setValue(e.color).toHex()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-wrap: ${r.breakWords?"break-all":"break-word"}`,`max-width: ${r.wordWrapWidth}px`]:[],...t?[ob(t)]:[],...r.dropShadow?[nb(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return XP(r.tagStyles,i),i.join(" ")}function nb(r){const t=H.shared.setValue(r.color).setAlpha(r.alpha).toHexa(),e=Math.round(Math.cos(r.angle)*r.distance),i=Math.round(Math.sin(r.angle)*r.distance),s=`${e}px ${i}px`;return r.blur>0?`text-shadow: ${s} ${r.blur}px ${t}`:`text-shadow: ${s} ${t}`}function ob(r){return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${H.shared.setValue(r.color).toHex()}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${H.shared.setValue(r.color).toHex()}`,"paint-order: stroke"].join(";")}const ab={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"},lb={fill:r=>`color: ${H.shared.setValue(r).toHex()}`,breakWords:r=>`word-wrap: ${r?"break-all":"break-word"}`,stroke:ob,dropShadow:nb};function XP(r,t){for(const e in r){const i=r[e],s=[];for(const n in i)lb[n]?s.push(lb[n](i[n])):ab[n]&&s.push(ab[n].replace("{{VALUE}}",i[n]));t.push(`${e} { ${s.join(";")} }`)}}var HP=Object.defineProperty,ub=Object.getOwnPropertySymbols,jP=Object.prototype.hasOwnProperty,zP=Object.prototype.propertyIsEnumerable,hb=(r,t,e)=>t in r?HP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cb=(r,t)=>{for(var e in t||(t={}))jP.call(t,e)&&hb(r,e,t[e]);if(ub)for(var e of ub(t))zP.call(t,e)&&hb(r,e,t[e]);return r};class Vs extends Mt{constructor(t={}){var e,i;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(i=t.tagStyles)!=null?i:{}}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new Vs({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?cb({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides,tagStyles:cb({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=sb(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}class db extends Hs{constructor(...t){const e=js(t,"HtmlText");super(e,Vs),this.renderPipeId="htmlText",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof At?e.textureStyle:new At(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor,i=xa(this.text,this._style),{width:s,height:n}=i;t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}get text(){return this._text}set text(t){const e=this._sanitiseText(t.toString());super.text=e}_sanitiseText(t){return this._removeInvalidHtmlTags(t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," "))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class pb extends ib{uploadQueueItem(t){t instanceof Q?this.uploadTextureSource(t):t instanceof zs?this.uploadText(t):t instanceof db?this.uploadHTMLText(t):t instanceof _l?this.uploadBitmapText(t):t instanceof pt&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:s}=i.data;this.uploadTextureSource(s.source)}else if(i.action==="fill"){const{texture:s}=i.data.style;this.uploadTextureSource(s.source)}return null}}class fb extends pb{destroy(){super.destroy(),clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}fb.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"prepare"};class bl{constructor(){this._tempState=wt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const s=t.renderer,n=this._didUploadHash[i.uid];s.shader.bind(i,n),n||(this._didUploadHash[i.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const s=e.textures.textures;for(let n=0;n<e.textures.count;n++)i.texture.bind(s[n],n);i.geometry.draw(e.topology,e.size,e.start)}}bl.extension={type:[T.WebGLPipesAdaptor],name:"batch"};function VP(r){const t=[];let e=0;for(let i=0;i<r;i++)t[e]={texture:{sampleType:"float",viewDimension:"2d",multisampled:!1},binding:e,visibility:GPUShaderStage.FRAGMENT},e++,t[e]={sampler:{type:"filtering"},binding:e,visibility:GPUShaderStage.FRAGMENT},e++;return t}function WP(r){const t={};let e=0;for(let i=0;i<r;i++)t[`textureSource${i+1}`]=e++,t[`textureSampler${i+1}`]=e++;return t}const Ws=wt.for2d();class vl{start(t,e,i){const s=t.renderer,n=s.encoder,o=i.gpuProgram;this._shader=i,this._geometry=e,n.setGeometry(e,o),Ws.blendMode="normal",s.pipeline.getPipeline(e,o,Ws);const a=s.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(t,e){const i=this._shader.gpuProgram,s=t.renderer,n=s.encoder;if(!e.bindGroup){const l=e.textures;e.bindGroup=Li(l.textures,l.count,s.limits.maxBatchableTextures)}Ws.blendMode=e.blendMode;const o=s.bindGroup.getBindGroup(e.bindGroup,i,1),a=s.pipeline.getPipeline(this._geometry,i,Ws,e.topology);e.bindGroup._touch(s.textureGC.count),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}vl.extension={type:[T.WebGPUPipesAdaptor],name:"batch"};const yl=class Kx{constructor(t,e){this.state=wt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null);var i,s;this.renderer=t,this._adaptor=e,(s=(i=this._adaptor).init)==null||s.call(i,this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new Zi({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const i in this._activeBatches)this._activeBatches[i].begin()}addToBatch(t,e){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(e);let i=this._activeBatches[t.batcherName];i||(i=this._activeBatches[t.batcherName]=Kx.getBatcher(t.batcherName),i.begin()),this._activeBatch=i}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const i in e){const s=e[i],n=s.geometry;n.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),n.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const i in e){const s=e[i],n=s.geometry;s.dirty&&(s.dirty=!1,n.buffers[0].update(s.attributeSize*4))}}execute(t){if(t.action==="startBatch"){const e=t.batcher,i=e.geometry,s=e.shader;this._adaptor.start(this,i,s)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};yl.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"batch"},yl._availableBatchers=Object.create(null);let xl=yl;F.handleByMap(T.Batcher,xl._availableBatchers),F.add(Zi);function YP(r){const t=r.split(/([\n{}])/g).map(i=>i.trim()).filter(i=>i.length);let e="";return t.map(i=>{let s=e+i;return i==="{"?e+=" ":i==="}"&&(e=e.substr(0,e.length-4),s=e+i),s}).join(`
|
|
`)}const mb={name:"texture-bit",vertex:{header:`
|
|
|
|
struct TextureUniforms {
|
|
uTextureMatrix:mat3x3<f32>,
|
|
}
|
|
|
|
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
`,main:`
|
|
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
`},fragment:{header:`
|
|
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
@group(2) @binding(1) var uSampler: sampler;
|
|
|
|
|
|
`,main:`
|
|
outColor = textureSample(uTexture, uSampler, vUV);
|
|
`}},gb={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);
|
|
`}},KP=new ot;let qP=class extends xr{constructor(){super(),this.filters=[new $_({sprite:new $t(w.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}};class Tl{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const s=this._renderer;if(s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const n=t.mask;n.includeInBuild=!0,n.collectRenderables(i,s,null),n.includeInBuild=!1}s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){const s=st.get(qP);if(s.inverse=t.inverse,i){t.mask.mask.measurable=!0;const n=Tr(t.mask.mask,!0,KP);t.mask.mask.measurable=!1,n.ceil();const o=e.renderTarget.renderTarget.colorTexture.source,a=et.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});const l=s.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:a})}else s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const s=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===yt.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const s=this._activeMaskStage.pop();i&&et.returnTexture(s.filterTexture),st.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Tl.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"alphaMask"};class Sl{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;this._colorStackIndex--;const n=s[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}Sl.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"colorMask"};class ZP{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){Ui(this.mask,t,e)}addLocalBounds(t,e){ki(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}destroy(){this.reset()}}class Al{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var s,n;const o=t,a=this._renderer;a.renderPipes.batch.break(i),a.renderPipes.blendMode.setBlendMode(o.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=o.mask;l.includeInBuild=!0,this._maskHash.has(o)||this._maskHash.set(o,{instructionsStart:0,instructionsLength:0});const u=this._maskHash.get(o);u.instructionsStart=i.instructionSize,l.collectRenderables(i,a,null),l.includeInBuild=!1,a.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const h=i.instructionSize-u.instructionsStart-1;u.instructionsLength=h;const c=a.renderTarget.renderTarget.uid;(n=(s=this._maskStackHash)[c])!=null||(s[c]=0)}pop(t,e,i){const s=t,n=this._renderer;n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(t);for(let a=0;a<o.instructionsLength;a++)i.instructions[i.instructionSize++]=i.instructions[o.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e,i;const s=this._renderer,n=s.renderTarget.renderTarget.uid;let o=(i=(e=this._maskStackHash)[n])!=null?i:e[n]=0;t.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(rt.RENDERING_MASK_ADD,o),o++,s.colorMask.setMask(0)):t.action==="pushMaskEnd"?(t.inverse?s.stencil.setStencilMode(rt.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(rt.MASK_ACTIVE,o),s.colorMask.setMask(15)):t.action==="popMaskBegin"?(s.colorMask.setMask(0),o!==0?s.stencil.setStencilMode(rt.RENDERING_MASK_REMOVE,o):(s.renderTarget.clear(null,xt.STENCIL),s.stencil.setStencilMode(rt.DISABLED,o)),o--):t.action==="popMaskEnd"&&(t.inverse?s.stencil.setStencilMode(rt.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(rt.MASK_ACTIVE,o),s.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Al.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"stencilMask"};var hi=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(hi||{});class _b{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class El{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this.destroyAll(),this._renderer=null,this._gl=null,this._gpuBuffers={},this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,i=this.getGlBuffer(t);e.bindBuffer(i.type,i.buffer)}bindBufferBase(t,e){const{_gl:i}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,i.bindBufferBase(i.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let i=0,s=this._nextBindBaseIndex;for(;i<2;){s>=this._maxBindings&&(s=this._minBaseLocation,i++);const n=this._boundBufferBases[s];if(n&&n._lastBindCallId===this._bindCallId){s++;continue}break}return e=s,this._nextBindBaseIndex=s+1,i>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,s){const{_gl:n}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,i*256,s||256)}updateBuffer(t){const{_gl:e}=this,i=this.getGlBuffer(t);if(t._updateID===i.updateID)return i;i.updateID=t._updateID,e.bindBuffer(i.type,i.buffer);const s=t.data,n=t.descriptor.usage&X.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return s?i.byteLength>=s.byteLength?e.bufferSubData(i.type,0,s,0,t._updateSize/s.BYTES_PER_ELEMENT):(i.byteLength=s.byteLength,e.bufferData(i.type,s,n)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,n)),i}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)this._gpuBuffers[e]&&t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){if(!this._gpuBuffers[t.uid])return;const i=this._gpuBuffers[t.uid],s=this._gl;e||s.deleteBuffer(i.buffer),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=hi.ARRAY_BUFFER;t.descriptor.usage&X.INDEX?i=hi.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&X.UNIFORM&&(i=hi.UNIFORM_BUFFER);const s=new _b(e.createBuffer(),i);return this._gpuBuffers[t.uid]=s,t.on("destroy",this.onBufferDestroy,this),s}resetState(){this._boundBufferBases=Object.create(null)}}El.extension={type:[T.WebGLSystem],name:"buffer"};var QP=Object.defineProperty,JP=Object.defineProperties,tw=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertySymbols,ew=Object.prototype.hasOwnProperty,rw=Object.prototype.propertyIsEnumerable,vb=(r,t,e)=>t in r?QP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ys=(r,t)=>{for(var e in t||(t={}))ew.call(t,e)&&vb(r,e,t[e]);if(bb)for(var e of bb(t))rw.call(t,e)&&vb(r,e,t[e]);return r},yb=(r,t)=>JP(r,tw(t));const Pl=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,i;t=Ys(Ys({},qx.defaultOptions),t);let s=this.multiView=t.multiView;if(t.context&&s&&(Zt("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),s=!1),s?this.canvas=L.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const n=this._renderer.background.alpha<1,o=(e=t.premultipliedAlpha)!=null?e:!0,a=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:n,premultipliedAlpha:o,antialias:a,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(i=t.powerPreference)!=null?i:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&Zt("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof L.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let i;const s=this.canvas;if(t===2&&(i=s.getContext("webgl2",e)),!i&&(i=s.getContext("webgl",e),!i))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=i,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions=yb(Ys({},e),{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")});else{this.extensions=yb(Ys({},e),{colorBufferFloat:t.getExtension("EXT_color_buffer_float")});const i=t.getExtension("WEBGL_provoking_vertex");i&&i.provokingVertexWEBGL(i.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const i=this.supports,s=this.webGLVersion===2,n=this.extensions;i.uint32Indices=s||!!n.uint32ElementIndex,i.uniformBufferObject=s,i.vertexArrayObject=s||!!n.vertexArrayObject,i.srgbTextures=s||!!n.srgb,i.nonPowOf2wrapping=s,i.nonPowOf2mipmaps=s,i.msaa=s,i.uint32Indices}};Pl.extension={type:[T.WebGLSystem],name:"context"},Pl.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let xb=Pl;function wl(r,t){var e,i,s;for(const n in r.attributes){const o=r.attributes[n],a=t[n];a?((e=o.format)!=null||(o.format=a.format),(i=o.offset)!=null||(o.offset=a.offset),(s=o.instance)!=null||(o.instance=a.instance)):Zt(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}iw(r)}function iw(r){var t,e;const{buffers:i,attributes:s}=r,n={},o={};for(const a in i){const l=i[a];n[l.uid]=0,o[l.uid]=0}for(const a in s){const l=s[a];n[l.buffer.uid]+=ie(l.format).stride}for(const a in s){const l=s[a];(t=l.stride)!=null||(l.stride=n[l.buffer.uid]),(e=l.start)!=null||(l.start=o[l.buffer.uid]),o[l.buffer.uid]+=ie(l.format).stride}}var Ks=(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))(Ks||{}),Rl=(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))(Rl||{}),Tb=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Tb||{}),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 Sb={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 Ab(r){var t;return(t=Sb[r])!=null?t:Sb.float32}const sw={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Ml{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=s=>e.bindVertexArrayOES(s),t.deleteVertexArray=s=>e.deleteVertexArrayOES(s));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(s,n,o,a)=>{i.drawArraysInstancedANGLE(s,n,o,a)},t.drawElementsInstanced=(s,n,o,a,l)=>{i.drawElementsInstancedANGLE(s,n,o,a,l)},t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const s=this.getVao(t,e);this._activeVao!==s&&(this._activeVao=s,i.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.updateBuffer(s)}}checkCompatibility(t,e){const i=t.attributes,s=e._attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e._attributeData,n=["g",t.uid];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}getVao(t,e){var i;return((i=this._geometryVaoHash[t.uid])==null?void 0:i[e._key])||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const s=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const o=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const a=this._geometryVaoHash[t.uid];let l=a[o];if(l)return a[e._key]=l,l;wl(t,e._attributeData);const u=t.buffers;l=s.createVertexArray(),s.bindVertexArray(l);for(let h=0;h<u.length;h++){const c=u[h];n.bind(c)}return this.activateVao(t,e),a[e._key]=l,a[o]=l,s.bindVertexArray(null),l}onGeometryDestroy(t,e){const i=this._geometryVaoHash[t.uid],s=this.gl;if(i){if(e)for(const n in i)this._activeVao!==i[n]&&this.unbind(),s.deleteVertexArray(i[n]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const s in this._geometryVaoHash[i]){const n=this._geometryVaoHash[i];this._activeVao!==n&&this.unbind(),e.deleteVertexArray(n[s])}this._geometryVaoHash[i]=null}}activateVao(t,e){var i,s;const n=this._renderer.gl,o=this._renderer.buffer,a=t.attributes;t.indexBuffer&&o.bind(t.indexBuffer);let l=null;for(const u in a){const h=a[u],c=h.buffer,p=o.getGlBuffer(c),f=e._attributeData[u];if(f){l!==p&&(o.bind(c),l=p);const m=f.location;n.enableVertexAttribArray(m);const _=ie(h.format),g=Ab(h.format);if(((i=f.format)==null?void 0:i.substring(1,4))==="int"?n.vertexAttribIPointer(m,_.size,g,h.stride,h.offset):n.vertexAttribPointer(m,_.size,g,_.normalised,h.stride,h.offset),h.instance)if(this.hasInstance){const b=(s=h.divisor)!=null?s:1;n.vertexAttribDivisor(m,b)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this._renderer,o=this._activeGeometry,a=sw[t||o.topology];if(s!=null||(s=o.instanceCount),o.indexBuffer){const l=o.indexBuffer.data.BYTES_PER_ELEMENT,u=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;s!==1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,u,(i||0)*l,s):n.drawElements(a,e||o.indexBuffer.data.length,u,(i||0)*l)}else s!==1?n.drawArraysInstanced(a,i||0,e||o.getSize(),s):n.drawArrays(a,i||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null,this._geometryVaoHash={}}}Ml.extension={type:[T.WebGLSystem],name:"geometry"};var nw=Object.defineProperty,Eb=Object.getOwnPropertySymbols,ow=Object.prototype.hasOwnProperty,aw=Object.prototype.propertyIsEnumerable,Pb=(r,t,e)=>t in r?nw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wb=(r,t)=>{for(var e in t||(t={}))ow.call(t,e)&&Pb(r,e,t[e]);if(Eb)for(var e of Eb(t))aw.call(t,e)&&Pb(r,e,t[e]);return r};const lw=new Ae({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Cl=class Zx{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}=wb(wb({},Zx.defaultOptions),t);this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(Zt("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=wt.for2d();const s=new vt({vertex:`
|
|
attribute vec2 aPosition;
|
|
out vec2 vUv;
|
|
|
|
void main() {
|
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
|
|
vUv = (aPosition + 1.0) / 2.0;
|
|
|
|
// flip dem UVs
|
|
vUv.y = 1.0 - vUv.y;
|
|
}`,fragment:`
|
|
in vec2 vUv;
|
|
out vec4 finalColor;
|
|
|
|
uniform sampler2D uTexture;
|
|
|
|
void main() {
|
|
finalColor = texture(uTexture, vUv);
|
|
}`,name:"big-triangle"});this._bigTriangleShader=new Pt({glProgram:s,resources:{uTexture:w.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:lw,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new w({source:new Q({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};Cl.extension={type:[T.WebGLSystem],name:"backBuffer",priority:1},Cl.defaultOptions={useBackBuffer:!1};let Rb=Cl;class Ol{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)))}}Ol.extension={type:[T.WebGLSystem],name:"colorMask"};class Gl{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:i,shader:s,state:n,skipSync:o,topology:a,size:l,start:u,instanceCount:h}=t;e.shader.bind(s,o),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,l,u,h!=null?h:i.instanceCount)}destroy(){this._renderer=null}}Gl.extension={type:[T.WebGLSystem],name:"encoder"};class Bl{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=uo(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}Bl.extension={type:[T.WebGLSystem],name:"limits"};class Mb{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const ne=[];ne[rt.NONE]=void 0,ne[rt.DISABLED]={stencilWriteMask:0,stencilReadMask:0},ne[rt.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},ne[rt.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},ne[rt.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},ne[rt.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Il{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:rt.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:rt.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=rt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,n=ne[t],o=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===rt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,s.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}}Il.extension={type:[T.WebGLSystem],name:"stencil"};class Fl{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Fa())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new bt({data:new Float32Array(e.layout.size/4),usage:X.UNIFORM|X.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let i=this._syncFunctionHash[e];if(!i){const s=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(s),o=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const s=this.getUniformGroupData(t);t.buffer||(t.buffer=new bt({data:new Float32Array(s.layout.size/4),usage:X.UNIFORM|X.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),i||(i=0),s.syncFunction(t.uniforms,e,n,i),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}const Dl={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function Cb(r){const t=r.map(n=>({data:n,offset:0,size:0})),e=16;let i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(i=Dl[o.data.type],!i)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(i=Math.max(i,e)*o.data.size);const a=i===12?16:i;o.size=i;const l=s%e;l>0&&e-l<a?s+=(e-l)%16:s+=(i-l%i)%i,o.offset=s,s+=i}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}const de=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
|
|
var matrix = uv[name].toArray(true);
|
|
data[offset] = matrix[0];
|
|
data[offset + 1] = matrix[1];
|
|
data[offset + 2] = matrix[2];
|
|
data[offset + 4] = matrix[3];
|
|
data[offset + 5] = matrix[4];
|
|
data[offset + 6] = matrix[5];
|
|
data[offset + 8] = matrix[6];
|
|
data[offset + 9] = matrix[7];
|
|
data[offset + 10] = matrix[8];
|
|
`,uniform:`
|
|
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
|
|
v = uv[name];
|
|
data[offset] = v.x;
|
|
data[offset + 1] = v.y;
|
|
data[offset + 2] = v.width;
|
|
data[offset + 3] = v.height;
|
|
`,uniform:`
|
|
cv = ud[name].value;
|
|
v = uv[name];
|
|
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
cv[0] = v.x;
|
|
cv[1] = v.y;
|
|
cv[2] = v.width;
|
|
cv[3] = v.height;
|
|
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
}
|
|
`},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
|
|
v = uv[name];
|
|
data[offset] = v.x;
|
|
data[offset + 1] = v.y;
|
|
`,uniform:`
|
|
cv = ud[name].value;
|
|
v = uv[name];
|
|
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
cv[0] = v.x;
|
|
cv[1] = v.y;
|
|
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
}
|
|
`},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
|
|
v = uv[name];
|
|
data[offset] = v.red;
|
|
data[offset + 1] = v.green;
|
|
data[offset + 2] = v.blue;
|
|
data[offset + 3] = v.alpha;
|
|
`,uniform:`
|
|
cv = ud[name].value;
|
|
v = uv[name];
|
|
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
cv[0] = v.red;
|
|
cv[1] = v.green;
|
|
cv[2] = v.blue;
|
|
cv[3] = v.alpha;
|
|
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
}
|
|
`},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
|
|
v = uv[name];
|
|
data[offset] = v.red;
|
|
data[offset + 1] = v.green;
|
|
data[offset + 2] = v.blue;
|
|
`,uniform:`
|
|
cv = ud[name].value;
|
|
v = uv[name];
|
|
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
cv[0] = v.red;
|
|
cv[1] = v.green;
|
|
cv[2] = v.blue;
|
|
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
}
|
|
`}];function Ul(r,t,e,i){const s=[`
|
|
var v = null;
|
|
var v2 = null;
|
|
var t = 0;
|
|
var index = 0;
|
|
var name = null;
|
|
var arrayOffset = null;
|
|
`];let n=0;for(let a=0;a<r.length;a++){const l=r[a],u=l.data.name;let h=!1,c=0;for(let p=0;p<de.length;p++)if(de[p].test(l.data)){c=l.offset/4,s.push(`name = "${u}";`,`offset += ${c-n};`,de[p][t]||de[p].ubo),h=!0;break}if(!h)if(l.data.size>1)c=l.offset/4,s.push(e(l,c-n));else{const p=i[l.data.type];c=l.offset/4,s.push(`
|
|
v = uv.${u};
|
|
offset += ${c-n};
|
|
${p};
|
|
`)}n=c}const o=s.join(`
|
|
`);return new Function("uv","data","dataInt32","offset",o)}var uw=Object.defineProperty,hw=Object.defineProperties,cw=Object.getOwnPropertyDescriptors,Ob=Object.getOwnPropertySymbols,dw=Object.prototype.hasOwnProperty,pw=Object.prototype.propertyIsEnumerable,Gb=(r,t,e)=>t in r?uw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fw=(r,t)=>{for(var e in t||(t={}))dw.call(t,e)&&Gb(r,e,t[e]);if(Ob)for(var e of Ob(t))pw.call(t,e)&&Gb(r,e,t[e]);return r},mw=(r,t)=>hw(r,cw(t));function mr(r,t){return`
|
|
for (let i = 0; i < ${r*t}; i++) {
|
|
data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
|
|
}
|
|
`}const kl={f32:`
|
|
data[offset] = v;`,i32:`
|
|
dataInt32[offset] = v;`,"vec2<f32>":`
|
|
data[offset] = v[0];
|
|
data[offset + 1] = v[1];`,"vec3<f32>":`
|
|
data[offset] = v[0];
|
|
data[offset + 1] = v[1];
|
|
data[offset + 2] = v[2];`,"vec4<f32>":`
|
|
data[offset] = v[0];
|
|
data[offset + 1] = v[1];
|
|
data[offset + 2] = v[2];
|
|
data[offset + 3] = v[3];`,"vec2<i32>":`
|
|
dataInt32[offset] = v[0];
|
|
dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
|
|
dataInt32[offset] = v[0];
|
|
dataInt32[offset + 1] = v[1];
|
|
dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
|
|
dataInt32[offset] = v[0];
|
|
dataInt32[offset + 1] = v[1];
|
|
dataInt32[offset + 2] = v[2];
|
|
dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
|
|
data[offset] = v[0];
|
|
data[offset + 1] = v[1];
|
|
data[offset + 4] = v[2];
|
|
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
|
data[offset] = v[0];
|
|
data[offset + 1] = v[1];
|
|
data[offset + 2] = v[2];
|
|
data[offset + 4] = v[3];
|
|
data[offset + 5] = v[4];
|
|
data[offset + 6] = v[5];
|
|
data[offset + 8] = v[6];
|
|
data[offset + 9] = v[7];
|
|
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
|
for (let i = 0; i < 16; i++) {
|
|
data[offset + i] = v[i];
|
|
}`,"mat3x2<f32>":mr(3,2),"mat4x2<f32>":mr(4,2),"mat2x3<f32>":mr(2,3),"mat4x3<f32>":mr(4,3),"mat2x4<f32>":mr(2,4),"mat3x4<f32>":mr(3,4)},Bb=mw(fw({},kl),{"mat2x2<f32>":`
|
|
data[offset] = v[0];
|
|
data[offset + 1] = v[1];
|
|
data[offset + 2] = v[2];
|
|
data[offset + 3] = v[3];
|
|
`});function Ib(r,t){const e=Math.max(Dl[r.data.type]/16,1),i=r.data.value.length/r.data.size,s=(4-i%4)%4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
v = uv.${r.data.name};
|
|
offset += ${t};
|
|
|
|
arrayOffset = offset;
|
|
|
|
t = 0;
|
|
|
|
for(var i=0; i < ${r.data.size*e}; i++)
|
|
{
|
|
for(var j = 0; j < ${i}; j++)
|
|
{
|
|
${n}[arrayOffset++] = v[t++];
|
|
}
|
|
${s!==0?`arrayOffset += ${s};`:""}
|
|
}
|
|
`}function Fb(r){return Ul(r,"uboStd40",Ib,kl)}class $l extends Fl{constructor(){super({createUboElements:Cb,generateUboSync:Fb})}}$l.extension={type:[T.WebGLSystem],name:"ubo"};class Db{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new z}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new z}copyToTexture(t,e,i,s,n){const o=this._renderTargetSystem,a=this._renderer,l=o.getGpuRenderTarget(t),u=a.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),a.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,n.x,n.y,i.x,i.y,s.width,s.height),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem,o=t.colorTexture,a=n.getGpuRenderTarget(t);let l=s.y;t.isRoot&&(l=o.pixelHeight-s.height),t.colorTextures.forEach(c=>{this._renderer.texture.unbind(c)});const u=this._renderer.gl;u.bindFramebuffer(u.FRAMEBUFFER,a.framebuffer);const h=this._viewPortCache;(h.x!==s.x||h.y!==l||h.width!==s.width||h.height!==s.height)&&(h.x=s.x,h.y=l,h.width=s.width,h.height=s.height,u.viewport(s.x,l,s.width,s.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,i=new Mb;return t.colorTexture instanceof Yt?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),e.bindFramebuffer(e.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const s=this._renderTargetSystem;typeof e=="boolean"&&(e=e?xt.ALL:xt.NONE);const n=this._renderer.gl;if(e&xt.COLOR){i!=null||(i=s.defaultClearColor);const o=this._clearColorCache,a=i;(o[0]!==a[0]||o[1]!==a[1]||o[2]!==a[2]||o[3]!==a[3])&&(o[0]=a[0],o[1]=a[1],o[2]=a[2],o[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,s=i.gl,n=s.createFramebuffer();if(e.resolveTargetFramebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((o,a)=>{const l=o.source;l.antialias&&(i.context.supports.msaa?e.msaa=!0:Zt("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(l,0);const u=i.texture.getGlSource(l).texture;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,3553,u,0)}),e.msaa){const o=s.createFramebuffer();e.framebuffer=o,s.bindFramebuffer(s.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{const u=s.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,t.colorTextures.forEach((s,n)=>{n!==0&&s.source.resize(i.width,i.height,i._resolution)}),e.msaa){const s=this._renderer,n=s.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{const u=a.source;s.texture.bindSource(u,0);const h=s.texture.getGlSource(u).internalFormat,c=e.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,c),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,h,u.pixelWidth,u.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,c)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&Yt.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&Yt.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}function Ub(r,t,e,i,s,n){const o=n?1:-1;return r.identity(),r.a=1/i*2,r.d=o*(1/s*2),r.tx=-1-t*r.a,r.ty=-o-e*r.d,r}var gw=Object.defineProperty,kb=Object.getOwnPropertySymbols,_w=Object.prototype.hasOwnProperty,bw=Object.prototype.propertyIsEnumerable,$b=(r,t,e)=>t in r?gw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vw=(r,t)=>{for(var e in t||(t={}))_w.call(t,e)&&$b(r,e,t[e]);if(kb)for(var e of kb(t))bw.call(t,e)&&$b(r,e,t[e]);return r};const Oe=new Map;me.register(Oe);function Ll(r,t){if(!Oe.has(r)){const e=new w({source:new Yt(vw({resource:r},t))}),i=()=>{Oe.get(r)===e&&Oe.delete(r)};e.once("destroy",i),e.source.once("destroy",i),Oe.set(r,e)}return Oe.get(r)}function yw(r){return Oe.has(r)}function Lb(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var xw=Object.defineProperty,Nb=Object.getOwnPropertySymbols,Tw=Object.prototype.hasOwnProperty,Sw=Object.prototype.propertyIsEnumerable,Xb=(r,t,e)=>t in r?xw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hb=(r,t)=>{for(var e in t||(t={}))Tw.call(t,e)&&Xb(r,e,t[e]);if(Nb)for(var e of Nb(t))Sw.call(t,e)&&Xb(r,e,t[e]);return r};const jb=class Qx{constructor(t={}){if(this.uid=Y("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=Hb(Hb({},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;e<t.colorTextures;e++)this.colorTextures.push(new Q({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(i=>i.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof w||t.depthStencilTexture instanceof Q?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new Q({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{s&&o===0||n.source.resize(t,e,i)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,i)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};jb.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let qs=jb;class Nl{constructor(t){this.rootViewPort=new z,this.viewport=new z,this.onRenderTargetChange=new Da("onRenderTargetChange"),this.projectionMatrix=new M,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:s}){var n,o;this._renderTargetStack.length=0,this.push(t,e,i,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Lb(this.rootRenderTarget),(o=(n=this.adaptor).prerender)==null||o.call(n,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,s){const n=this.getRenderTarget(t),o=this.renderTarget!==n;this.renderTarget=n,this.renderSurface=t;const a=this.getGpuRenderTarget(n);(n.pixelWidth!==a.width||n.pixelHeight!==a.height)&&(this.adaptor.resizeGpuRenderTarget(n),a.width=n.pixelWidth,a.height=n.pixelHeight);const l=n.colorTexture,u=this.viewport,h=l.pixelWidth,c=l.pixelHeight;if(!s&&t instanceof w&&(s=t.frame),s){const p=l._resolution;u.x=s.x*p+.5|0,u.y=s.y*p+.5|0,u.width=s.width*p+.5|0,u.height=s.height*p+.5|0}else u.x=0,u.y=0,u.width=h,u.height=c;return Ub(this.projectionMatrix,0,0,u.width/l.resolution,u.height/l.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,u),o&&this.onRenderTargetChange.emit(n),n}clear(t,e=xt.ALL,i){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,i,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=xt.ALL,i,s){const n=this.bind(t,e,i,s);return this._renderTargetStack.push({renderTarget:n,frame:s}),n}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){var e;return t.isTexture&&(t=t.source),(e=this._renderSurfaceToRenderTargetHash.get(t))!=null?e:this._initRenderTarget(t)}copyToTexture(t,e,i,s,n){i.x<0&&(s.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(s.height+=i.y,n.y-=i.y,i.y=0);const{pixelWidth:o,pixelHeight:a}=t;return s.width=Math.min(s.width,o-i.x),s.height=Math.min(s.height,a-i.y),this.adaptor.copyToTexture(t,e,i,s,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return Yt.test(t)&&(t=Ll(t).source),t instanceof qs?e=t:t instanceof Q&&(e=new qs({colorTextures:[t]}),t.source instanceof Yt&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const i=this._gpuRenderTargetHash[e.uid];i&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(i))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}class Xl extends Nl{constructor(t){super(t),this.adaptor=new Db,this.adaptor.init(t,this)}}Xl.extension={type:[T.WebGLSystem],name:"renderTarget"};class Zs extends gt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=Y("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Y("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Y("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function zb(r,t){const e=[],i=[`
|
|
var g = s.groups;
|
|
var sS = r.shader;
|
|
var p = s.glProgram;
|
|
var ugS = r.uniformGroup;
|
|
var resources;
|
|
`];let s=!1,n=0;const o=t._getProgramData(r.glProgram);for(const l in r.groups){const u=r.groups[l];e.push(`
|
|
resources = g[${l}].resources;
|
|
`);for(const h in u.resources){const c=u.resources[h];if(c instanceof nt)if(c.ubo){const p=r._uniformBindMap[l][Number(h)];e.push(`
|
|
sS.bindUniformBlock(
|
|
resources[${h}],
|
|
'${p}',
|
|
${r.glProgram._uniformBlockData[p].index}
|
|
);
|
|
`)}else e.push(`
|
|
ugS.updateUniformGroup(resources[${h}], p, sD);
|
|
`);else if(c instanceof Zs){const p=r._uniformBindMap[l][Number(h)];e.push(`
|
|
sS.bindUniformBlock(
|
|
resources[${h}],
|
|
'${p}',
|
|
${r.glProgram._uniformBlockData[p].index}
|
|
);
|
|
`)}else if(c instanceof Q){const p=r._uniformBindMap[l][h],f=o.uniformData[p];f&&(s||(s=!0,i.push(`
|
|
var tS = r.texture;
|
|
`)),t._gl.uniform1i(f.location,n),e.push(`
|
|
tS.bind(resources[${h}], ${n});
|
|
`),n++)}}}const a=[...i,...e].join(`
|
|
`);return new Function("r","s","sD",a)}class Aw{}class Vb{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 Hl(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function jl(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function zl(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return jl(2*t);case"bvec3":return jl(3*t);case"bvec4":return jl(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let Qs=null;const Wb={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},Ew={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function Vl(r,t){if(!Qs){const e=Object.keys(Wb);Qs={};for(let i=0;i<e.length;++i){const s=e[i];Qs[r[s]]=Wb[s]}}return Qs[t]}function Yb(r,t){const e=Vl(r,t);return Ew[e]||"float32"}function Kb(r,t,e=!1){const i={},s=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){const a=t.getActiveAttrib(r,o);if(a.name.startsWith("gl_"))continue;const l=Yb(t,a.type);i[a.name]={location:0,format:l,stride:ie(l).stride,offset:0,instance:!1,start:0}}const n=Object.keys(i);if(e){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)i[n[o]].location=o,t.bindAttribLocation(r,o,n[o]);t.linkProgram(r)}else for(let o=0;o<n.length;o++)i[n[o]].location=t.getAttribLocation(r,n[o]);return i}function qb(r,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){const n=t.getActiveUniformBlockName(r,s),o=t.getUniformBlockIndex(r,n),a=t.getActiveUniformBlockParameter(r,s,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:o,size:a}}return e}function Zb(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Vl(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:zl(l,n.size)}}return e}function Qb(r,t){const e=r.getShaderSource(t).split(`
|
|
`).map((u,h)=>`${h}: ${u}`),i=r.getShaderInfoLog(t),s=i.split(`
|
|
`),n={},o=s.map(u=>parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(u=>u&&!n[u]?(n[u]=!0,!0):!1),a=[""];o.forEach(u=>{e[u-1]=`%c${e[u-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
|
|
`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Jb(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Qb(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Qb(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function tv(r,t){const e=Hl(r,r.VERTEX_SHADER,t.vertex),i=Hl(r,r.FRAGMENT_SHADER,t.fragment),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=t.transformFeedbackVaryings;n&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Jb(r,s,e,i),t._attributeData=Kb(s,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Zb(s,r),t._uniformBlockData=qb(s,r),r.deleteShader(e),r.deleteShader(i);const o={};for(const a in t._uniformData){const l=t._uniformData[a];o[a]={location:r.getUniformLocation(s,a),value:zl(l.type,l.size)}}return new Vb(s,o)}const Js={textureCount:0,blockIndex:0};class Wl{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;Js.textureCount=0,Js.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),i(this._renderer,t,Js)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Js)}bindUniformBlock(t,e,i=0){const s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);const a=t.buffer,l=s.updateBuffer(a),u=s.freeLocationForBufferBase(l);if(o){const{offset:c,size:p}=t;c===0&&p===a.data.byteLength?s.bindBufferBase(l,u):s.bindBufferRange(l,u,c)}else s.getLastBindBaseLocation(l)!==u&&s.bindBufferBase(l,u);const h=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==u&&(n.uniformBlockBindings[i]=u,this._renderer.gl.uniformBlockBinding(n.program,h,u))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=tv(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._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return zb(t,e)}resetState(){this._activeProgram=null}}Wl.extension={type:[T.WebGLSystem],name:"shader"};const ev={f32:`if (cv !== v) {
|
|
cu.value = v;
|
|
gl.uniform1f(location, v);
|
|
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
gl.uniform2f(location, v[0], v[1]);
|
|
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
gl.uniform3f(location, v[0], v[1], v[2]);
|
|
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
cv[3] = v[3];
|
|
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
}`,i32:`if (cv !== v) {
|
|
cu.value = v;
|
|
gl.uniform1i(location, v);
|
|
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
gl.uniform2i(location, v[0], v[1]);
|
|
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
cv[3] = v[3];
|
|
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
}`,u32:`if (cv !== v) {
|
|
cu.value = v;
|
|
gl.uniform1ui(location, v);
|
|
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
gl.uniform2ui(location, v[0], v[1]);
|
|
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
cv[3] = v[3];
|
|
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
}`,bool:`if (cv !== v) {
|
|
cu.value = v;
|
|
gl.uniform1i(location, v);
|
|
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
gl.uniform2i(location, v[0], v[1]);
|
|
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
cv[0] = v[0];
|
|
cv[1] = v[1];
|
|
cv[2] = v[2];
|
|
cv[3] = v[3];
|
|
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
}`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},rv={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function iv(r,t){const e=[`
|
|
var v = null;
|
|
var cv = null;
|
|
var cu = null;
|
|
var t = 0;
|
|
var gl = renderer.gl;
|
|
var name = null;
|
|
`];for(const i in r.uniforms){if(!t[i]){r.uniforms[i]instanceof nt?r.uniforms[i].ubo?e.push(`
|
|
renderer.shader.bindUniformBlock(uv.${i}, "${i}");
|
|
`):e.push(`
|
|
renderer.shader.updateUniformGroup(uv.${i});
|
|
`):r.uniforms[i]instanceof Zs&&e.push(`
|
|
renderer.shader.bindBufferResource(uv.${i}, "${i}");
|
|
`);continue}const s=r.uniformStructures[i];let n=!1;for(let o=0;o<de.length;o++){const a=de[o];if(s.type===a.type&&a.test(s)){e.push(`name = "${i}";`,de[o].uniform),n=!0;break}}if(!n){const o=(s.size===1?ev:rv)[s.type].replace("location",`ud["${i}"].location`);e.push(`
|
|
cu = ud["${i}"];
|
|
cv = cu.value;
|
|
v = uv["${i}"];
|
|
${o};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
|
|
`))}class Yl{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const s=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==s.uniformDirtyGroups[t.uid])&&(s.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(s.uniformData,t.uniforms,this._renderer,i))}_getUniformSyncFunction(t,e){var i;return((i=this._uniformGroupSyncHash[t._signature])==null?void 0:i[e._key])||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),s=this._getSignature(t,e._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[s],i[e._key]}_generateUniformsSync(t,e){return iv(t,e)}_getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}Yl.extension={type:[T.WebGLSystem],name:"uniformGroup"};function Pw(r){return r=r.replaceAll("texture2D","texture").replaceAll("gl_FragColor","finalColor").replaceAll("varying","in"),r=`
|
|
out vec4 finalColor;
|
|
${r}
|
|
`,r}const ww={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Rw(r){return ww[r]}function sv(r){const t={};if(t.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t.add=[r.ONE,r.ONE],t.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof L.get().getWebGLRenderingContext()))t.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const e=r.getExtension("EXT_blend_minmax");e&&(t.min=[r.ONE,r.ONE,r.ONE,r.ONE,e.MIN_EXT,e.MIN_EXT],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,e.MAX_EXT,e.MAX_EXT])}return t}const Mw=0,Cw=1,Ow=2,Gw=3,Bw=4,Iw=5,nv=class qu{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[Mw]=this.setBlend,this.map[Cw]=this.setOffset,this.map[Ow]=this.setCullFace,this.map[Gw]=this.setDepthTest,this.map[Bw]=this.setFrontFace,this.map[Iw]=this.setDepthMask,this.checks=[],this.defaultState=wt.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=sv(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e>>=1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t||(t=this.defaultState);for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this._updateCheck(qu._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(qu._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};nv.extension={type:[T.WebGLSystem],name:"state"};let ov=nv;class av{constructor(t){this.target=Rl.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=j.UNSIGNED_BYTE,this.internalFormat=Ks.RGBA,this.format=Ks.RGBA,this.samplerType=0}}const lv={id:"buffer",upload(r,t,e){t.width===r.width||t.height===r.height?e.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,t.format,t.type,r.resource):e.texImage2D(t.target,0,t.internalFormat,r.width,r.height,0,t.format,t.type,r.resource),t.width=r.width,t.height=r.height}},Fw={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},uv={id:"compressed",upload(r,t,e){e.pixelStorei(e.UNPACK_ALIGNMENT,4);let i=r.pixelWidth,s=r.pixelHeight;const n=!!Fw[r.format];for(let o=0;o<r.resource.length;o++){const a=r.resource[o];n?e.compressedTexImage2D(e.TEXTURE_2D,o,t.internalFormat,i,s,0,a):e.texImage2D(e.TEXTURE_2D,o,t.internalFormat,i,s,0,t.format,t.type,a),i=Math.max(i>>1,1),s=Math.max(s>>1,1)}}},Kl={id:"image",upload(r,t,e,i){const s=t.width,n=t.height,o=r.pixelWidth,a=r.pixelHeight,l=r.resourceWidth,u=r.resourceHeight;l<o||u<a?((s!==o||n!==a)&&e.texImage2D(t.target,0,t.internalFormat,o,a,0,t.format,t.type,null),i===2?e.texSubImage2D(e.TEXTURE_2D,0,0,0,l,u,t.format,t.type,r.resource):e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,r.resource)):s===o&&n===a?e.texSubImage2D(e.TEXTURE_2D,0,0,0,t.format,t.type,r.resource):i===2?e.texImage2D(t.target,0,t.internalFormat,o,a,0,t.format,t.type,r.resource):e.texImage2D(t.target,0,t.internalFormat,t.format,t.type,r.resource),t.width=o,t.height=a}},hv={id:"video",upload(r,t,e,i){if(!r.isValid){e.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Kl.upload(r,t,e,i)}},ql={linear:9729,nearest:9728},cv={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},tn={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},dv={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Zl(r,t,e,i,s,n,o,a){const l=n;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=tn[o?"clamp-to-edge":r.addressModeU],h=tn[o?"clamp-to-edge":r.addressModeV],c=tn[o?"clamp-to-edge":r.addressModeW];t[s](l,t.TEXTURE_WRAP_S,u),t[s](l,t.TEXTURE_WRAP_T,h),t.TEXTURE_WRAP_R&&t[s](l,t.TEXTURE_WRAP_R,c)}if((!a||r.magFilter!=="linear")&&t[s](l,t.TEXTURE_MAG_FILTER,ql[r.magFilter]),e){if(!a||r.mipmapFilter!=="linear"){const u=cv[r.minFilter][r.mipmapFilter];t[s](l,t.TEXTURE_MIN_FILTER,u)}}else t[s](l,t.TEXTURE_MIN_FILTER,ql[r.minFilter]);if(i&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[s](l,i.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[s](l,t.TEXTURE_COMPARE_FUNC,dv[r.compare])}function pv(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 Dw=Object.defineProperty,Uw=Object.defineProperties,kw=Object.getOwnPropertyDescriptors,fv=Object.getOwnPropertySymbols,$w=Object.prototype.hasOwnProperty,Lw=Object.prototype.propertyIsEnumerable,mv=(r,t,e)=>t in r?Dw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ge=(r,t)=>{for(var e in t||(t={}))$w.call(t,e)&&mv(r,e,t[e]);if(fv)for(var e of fv(t))Lw.call(t,e)&&mv(r,e,t[e]);return r},Nw=(r,t)=>Uw(r,kw(t));function gv(r,t){let e={},i=r.RGBA;return r instanceof L.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},i=r.RGBA8),Ge(Ge(Ge(Ge(Ge(Ge(Nw(Ge({r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA},e),{rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:i,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8}),t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}function _v(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 Xw(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;e<t;e+=4){const i=r[e+3];if(i!==0){const s=255.001/i;r[e]=r[e]*s+.5,r[e+1]=r[e+1]*s+.5,r[e+2]=r[e+2]*s+.5}}}const Hw=4;class Ql{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:Kl,buffer:lv,video:hv,compressed:uv},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_glTextures"),this._renderer.renderableGC.addManagedHash(this,"_glSamplers")}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=gv(t,this._renderer.context.extensions),this._mapFormatToType=_v(t),this._mapFormatToFormat=pv(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(w.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=w.EMPTY.source);const s=this.getGlSource(t);i.bindTexture(s.target,s.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const s=this._getGlSampler(t);this._boundSamplers[e]!==s&&(this._boundSamplers[e]=s,i.bindSampler(e,s))}unbind(t){const e=t.source,i=this._boundTextures,s=this._gl;for(let n=0;n<i.length;n++)if(i[n]===e){this._activateLocation(n);const o=this.getGlSource(e);s.bindTexture(o.target,null),i[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new av(e.createTexture());if(i.type=this._mapFormatToType[t.format],i.internalFormat=this._mapFormatToInternalFormat[t.format],i.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const s=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(s))+1}return this._glTextures[t.uid]=i,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),i}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const i=this._gl,s=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,Zl(t.style,i,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,i.texture),this._boundTextures[this._activeTextureLocation]=t;const s=t.alphaMode==="premultiply-alpha-on-upload";this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const i=this.getGlSource(t);this._gl.generateMipmap(i.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Zl(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",i,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:s}=this.getPixels(t),n=L.get().createCanvas();n.width=i,n.height=s;const o=n.getContext("2d");if(o){const a=o.createImageData(i,s);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){const e=t.source.resolution,i=t.frame,s=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),o=new Uint8Array(Hw*s*n),a=this._renderer,l=a.renderTarget.getRenderTarget(t),u=a.renderTarget.getGpuRenderTarget(l),h=a.gl;return h.bindFramebuffer(h.FRAMEBUFFER,u.resolveTargetFramebuffer),h.readPixels(Math.round(i.x*e),Math.round(i.y*e),s,n,h.RGBA,h.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:s,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._glTextures=null,this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(w.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Ql.extension={type:[T.WebGLSystem],name:"texture"};class Jl{contextChange(t){const e=new nt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,s=Ke({name:"graphics",bits:[Vi,Yi(i),bs,Ze]});this.shader=new Pt({glProgram:s,resources:{localUniforms:e,batchSamplers:Ki(i)}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(i);s.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(s),n.geometry.bind(a.geometry,s.glProgram);const u=l.instructions;for(let h=0;h<l.instructionSize;h++){const c=u[h];if(c.size){for(let p=0;p<c.textures.count;p++)n.texture.bind(c.textures.textures[p],p);n.geometry.draw(c.topology,c.size,c.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}Jl.extension={type:[T.WebGLPipesAdaptor],name:"graphics"};class tu{init(){const t=Ke({name:"mesh",bits:[bs,gb,Ze]});this._shader=new Pt({glProgram:t,resources:{uTexture:w.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new M}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return}else{s=this._shader;const n=e.texture,o=n.source;s.resources.uTexture=o,s.resources.uSampler=o.style,s.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}s.groups[100]=i.globalUniforms.bindGroup,s.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}tu.extension={type:[T.WebGLPipesAdaptor],name:"mesh"};class eu{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}eu.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"customRender"};function en(r,t){const e=r.instructionSet,i=e.instructions;for(let s=0;s<e.instructionSize;s++){const n=i[s];t[n.renderPipeId].execute(n)}}const jw=new M;class ru{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(st.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){var i;const s=(i=t._batchableRenderGroup)!=null?i:t._batchableRenderGroup=st.get(Lr);s.renderable=t.root,s.transform=t.root.relativeGroupTransform,s.texture=t.texture,s.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(s,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=jw.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),en(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),en(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}ru.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"renderGroup"};function rn(r,t){t||(t=0);for(let e=t;e<r.length&&r[e];e++)r[e]=null}const zw=new q,bv=$e|Ar|Oi;function iu(r,t=!1){vv(r);const e=r.childrenToUpdate,i=r.updateTick++;for(const s in e){const n=Number(s),o=e[s],a=o.list,l=o.index;for(let u=0;u<l;u++){const h=a[u];h.parentRenderGroup===r&&h.relativeRenderGroupDepth===n&&su(h,i,0)}rn(a,l),o.index=0}if(t)for(let s=0;s<r.renderGroupChildren.length;s++)iu(r.renderGroupChildren[s],t)}function vv(r){const t=r.root;let e;if(r.renderGroupParent){const i=r.renderGroupParent;r.worldTransform.appendFrom(t.relativeGroupTransform,i.worldTransform),r.worldColor=Sr(t.groupColor,i.worldColor),e=t.groupAlpha*i.worldAlpha}else r.worldTransform.copyFrom(t.localTransform),r.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function su(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const i=r.localTransform;r.updateLocalTransform();const s=r.parent;if(s&&!s.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(i,s.relativeGroupTransform),e&bv&&yv(r,s,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&bv&&yv(r,zw,e)),!r.renderGroup){const n=r.children,o=n.length;for(let u=0;u<o;u++)su(n[u],t,e);const a=r.parentRenderGroup,l=r;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function yv(r,t,e){if(e&Ar){r.groupColor=Sr(r.localColor,t.groupColor);let i=r.localAlpha*t.groupAlpha;i=i<0?0:i>1?1:i,r.groupAlpha=i,r.groupColorAlpha=r.groupColor+((i*255|0)<<24)}e&Oi&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&$e&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function xv(r,t){const{list:e}=r.childrenRenderablesToUpdate;let i=!1;for(let s=0;s<r.childrenRenderablesToUpdate.index;s++){const n=e[s];if(i=t[n.renderPipeId].validateRenderable(n),i)break}return r.structureDidChange=i,i}const Vw=new M;class nu{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,s=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,o=Vw;e&&(o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const a=n.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),en(t.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=i,t.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){var i,s;if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let n=t.renderGroupChildren.length-1;n>=0;n--)this._updateCachedRenderGroups(t.renderGroupChildren[n],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const n=t.root.getLocalBounds();n.ceil();const o=t.texture;t.texture&&et.returnTexture(t.texture,!0);const a=this._renderer,l=t.textureOptions.resolution||a.view.resolution,u=(i=t.textureOptions.antialias)!=null?i:a.view.antialias,h=(s=t.textureOptions.scaleMode)!=null?s:"linear",c=et.getOptimalTexture(n.width,n.height,l,u);c._source.style=new At({scaleMode:h}),t.texture=c,t._textureBounds||(t._textureBounds=new ot),t._textureBounds.copyFrom(n),o!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(et.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?rn(t.childrenRenderablesToUpdate.list,0):xv(t,i),iu(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!(t.isCachedAsTexture&&!t.textureNeedsUpdate))for(let s=0;s<t.renderGroupChildren.length;s++)this._updateRenderGroups(t.renderGroupChildren[s])}_updateRenderables(t){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let s=0;s<i;s++){const n=e[s];n.didViewUpdate&&t.updateRenderable(n)}rn(e,i)}_buildInstructions(t,e){const i=t.root,s=t.instructionSet;s.reset();const n=e.renderPipes?e:e.batch.renderer,o=n.renderPipes;o.batch.buildStart(s),o.blendMode.buildStart(),o.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(s,n,null),o.batch.buildEnd(s),o.blendMode.buildEnd(s)}}nu.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"renderGroup"};class ou{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new Lr;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}ou.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"sprite"};var Ww=Object.defineProperty,Tv=Object.getOwnPropertySymbols,Yw=Object.prototype.hasOwnProperty,Kw=Object.prototype.propertyIsEnumerable,Sv=(r,t,e)=>t in r?Ww(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Av=(r,t)=>{for(var e in t||(t={}))Yw.call(t,e)&&Sv(r,e,t[e]);if(Tv)for(var e of Tv(t))Kw.call(t,e)&&Sv(r,e,t[e]);return r};const au=class Jx{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new H(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=Av(Av({},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(){}};au.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"background",priority:0},au.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Ev=au;const ci={};F.handle(T.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");ci[r.name]=r.ref},r=>{delete ci[r.name]});class lu{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,i){this._blendModeStack.push(e),this.setBlendMode(t,e,i)}popBlendMode(t){var e;this._blendModeStack.pop();const i=(e=this._blendModeStack[this._activeBlendMode.length-1])!=null?e:"normal";this.setBlendMode(null,i,t)}setBlendMode(t,e,i){var s;const n=t instanceof Mi;if(this._activeBlendMode===e){this._isAdvanced&&t&&!n&&((s=this._renderableList)==null||s.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(i),this._activeBlendMode=e,t&&(this._isAdvanced=!!ci[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,i))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const i=this._activeBlendMode;if(!ci[i])return;const s=this._ensureFilterEffect(i),n=t instanceof Mi,o={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:n?null:[t],container:n?t.root:null,canBundle:!1};this._renderableList=o.renderables,e.add(o)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new xr,e.filters=[new ci[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}lu.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"blendMode"};var qw=Object.defineProperty,Pv=Object.getOwnPropertySymbols,Zw=Object.prototype.hasOwnProperty,Qw=Object.prototype.propertyIsEnumerable,wv=(r,t,e)=>t in r?qw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,uu=(r,t)=>{for(var e in t||(t={}))Zw.call(t,e)&&wv(r,e,t[e]);if(Pv)for(var e of Pv(t))Qw.call(t,e)&&wv(r,e,t[e]);return r};const hu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},cu=class t0{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof q||t instanceof w?uu({target:t},e):uu(uu({},e),t)}async image(t){const e=L.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,t0.defaultImageOptions);const{format:e,quality:i}=t,s=this.canvas(t);if(s.toBlob!==void 0)return new Promise((n,o)=>{s.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},hu[e],i)});if(s.toDataURL!==void 0)return s.toDataURL(hu[e],i);if(s.convertToBlob!==void 0){const n=await s.convertToBlob({type:hu[e],quality:i});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof w)return i.texture.generateCanvas(e);const s=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(s);return s.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,s=e instanceof w?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(s);return e instanceof q&&s.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof w?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),s=document.createElement("a");s.download=(e=t.filename)!=null?e:"image.png",s.href=i.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){var e;const i=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const s=this.canvas(t),n=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const o=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",o)}destroy(){this._renderer=null}};cu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"extract"},cu.defaultImageOptions={format:"png",quality:1};let Rv=cu;class sn extends w{static create(t){return new sn({source:new Q(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}var Jw=Object.defineProperty,tR=Object.defineProperties,eR=Object.getOwnPropertyDescriptors,Mv=Object.getOwnPropertySymbols,rR=Object.prototype.hasOwnProperty,iR=Object.prototype.propertyIsEnumerable,Cv=(r,t,e)=>t in r?Jw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,sR=(r,t)=>{for(var e in t||(t={}))rR.call(t,e)&&Cv(r,e,t[e]);if(Mv)for(var e of Mv(t))iR.call(t,e)&&Cv(r,e,t[e]);return r},nR=(r,t)=>tR(r,eR(t));const oR=new z,aR=new ot,lR=[0,0,0,0];class du{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof q&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,s=t.antialias||this._renderer.view.antialias,n=t.target;let o=t.clearColor;o?o=Array.isArray(o)&&o.length===4?o:H.shared.setValue(o).toArray():o=lR;const a=((e=t.frame)==null?void 0:e.copyTo(oR))||Pi(n,aR).rectangle;a.width=Math.max(a.width,1/i)|0,a.height=Math.max(a.height,1/i)|0;const l=sn.create(nR(sR({},t.textureSourceOptions),{width:a.width,height:a.height,resolution:i,antialias:s})),u=M.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:u,target:l,clearColor:o}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}du.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"textureGenerator"};class pu{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:i,worldColor:s,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new M,worldColor:4294967295,offset:new W},l={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:i||a.worldTransformMatrix,worldColor:s||a.worldColor,offset:n||a.offset,bindGroup:null},u=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(u);const h=u.uniforms;h.uProjectionMatrix=l.projectionMatrix,h.uResolution=l.resolution,h.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),h.uWorldTransformMatrix.tx-=l.offset.x,h.uWorldTransformMatrix.ty-=l.offset.y,er(l.worldColor,h.uWorldColorAlpha,0),u.update();let c;this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(u,!1):(c=this._bindGroupPool.pop()||new Kt,this._activeBindGroups.push(c),c.setResource(u,0)),l.bindGroup=c,this._currentGlobalUniformData=l}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===yt.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new nt({uProjectionMatrix:{value:new M,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new M,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}pu.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"globalUniforms"};let uR=1;class fu{constructor(){this._tasks=[],this._offset=0}init(){at.system.add(this._update,this)}repeat(t,e,i=!0){const s=uR++;let n=0;return i&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t){this._tasks.splice(e,1);return}}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const i=this._tasks[e];if(t-i.offset-i.last>=i.duration){const s=t-i.start;i.func(s),i.last=t}}}destroy(){at.system.remove(this._update,this),this._tasks.length=0}}fu.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"scheduler",priority:0};let Ov=!1;function Gv(r){if(!Ov){if(L.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${ti} (${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 ${ti} - ${r} - http://www.pixijs.com/`);Ov=!0}}class nn{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===yt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Gv(e)}}}nn.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"hello",priority:-2},nn.defaultOptions={hello:!1};function Bv(r){let t=!1;for(const i in r)if(r[i]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const i in r){const s=r[i];s&&(e[i]=s)}return e}function Iv(r){let t=0;for(let e=0;e<r.length;e++)r[e]==null?t++:r[e-t]=r[e];return r.length-=t,r}var hR=Object.defineProperty,Fv=Object.getOwnPropertySymbols,cR=Object.prototype.hasOwnProperty,dR=Object.prototype.propertyIsEnumerable,Dv=(r,t,e)=>t in r?hR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uv=(r,t)=>{for(var e in t||(t={}))cR.call(t,e)&&Dv(r,e,t[e]);if(Fv)for(var e of Fv(t))dR.call(t,e)&&Dv(r,e,t[e]);return r};let pR=0;const mu=class e0{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(t){t=Uv(Uv({},e0.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedHashes)e.context[e.hash]=Bv(e.context[e.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedArrays)Iv(e.context[e.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=pR++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(t._lastUsed===-1&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){var t,e,i,s;const n=this._now,o=this._managedRenderables,a=this._renderer.renderPipes;let l=0;for(let u=0;u<o.length;u++){const h=o[u];if(h===null){l++;continue}const c=(t=h.renderGroup)!=null?t:h.parentRenderGroup,p=(i=(e=c==null?void 0:c.instructionSet)==null?void 0:e.gcTick)!=null?i:-1;if(((s=c==null?void 0:c.gcTick)!=null?s:0)===p&&(h._lastUsed=n),n-h._lastUsed>this.maxUnusedTime){if(!h.destroyed){const f=a;c&&(c.structureDidChange=!0),f[h.renderPipeId].destroyRenderable(h)}h._lastUsed=-1,l++,h.off("destroyed",this._removeRenderable,this)}else o[u-l]=h}o.length-=l}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}};mu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"renderableGC",priority:0},mu.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let kv=mu;var fR=Object.defineProperty,$v=Object.getOwnPropertySymbols,mR=Object.prototype.hasOwnProperty,gR=Object.prototype.propertyIsEnumerable,Lv=(r,t,e)=>t in r?fR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nv=(r,t)=>{for(var e in t||(t={}))mR.call(t,e)&&Lv(r,e,t[e]);if($v)for(var e of $v(t))gR.call(t,e)&&Lv(r,e,t[e]);return r};const gu=class r0{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(t){var e;t=Nv(Nv({},r0.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<t.length;e++){const i=t[e];i.autoGarbageCollect&&i.resource&&i._touched>-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=null}};gu.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"textureGC"},gu.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Xv=gu;var _R=Object.defineProperty,Hv=Object.getOwnPropertySymbols,bR=Object.prototype.hasOwnProperty,vR=Object.prototype.propertyIsEnumerable,jv=(r,t,e)=>t in r?_R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zv=(r,t)=>{for(var e in t||(t={}))bR.call(t,e)&&jv(r,e,t[e]);if(Hv)for(var e of Hv(t))vR.call(t,e)&&jv(r,e,t[e]);return r};const _u=class i0{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=zv(zv({},i0.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new z(0,0,t.width,t.height),this.canvas=t.canvas||L.get().createCanvas(),this.antialias=!!t.antialias,this.texture=Ll(this.canvas,t),this.renderTarget=new qs({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};_u.extension={type:[T.WebGLSystem,T.WebGPUSystem,T.CanvasSystem],name:"view",priority:0},_u.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Vv=_u;const bu=[Ev,pu,nn,Vv,nu,Xv,du,Rv,La,kv,fu],vu=[lu,xl,ou,ru,Tl,Al,Sl,eu],yR=[...bu,$l,Rb,xb,Bl,El,Ql,Xl,Ml,Yl,Wl,Gl,ov,Il,Ol],xR=[...vu],TR=[bl,tu,Jl],Wv=[],Yv=[],Kv=[];F.handleByNamedList(T.WebGLSystem,Wv),F.handleByNamedList(T.WebGLPipes,Yv),F.handleByNamedList(T.WebGLPipesAdaptor,Kv),F.add(...yR,...xR,...TR);class qv extends qr{constructor(){const t={name:"webgl",type:yt.WEBGL,systems:Wv,renderPipes:Yv,renderPipeAdaptors:Kv};super(t)}}var SR={__proto__:null,WebGLRenderer:qv};class yu{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var s;const n=this._gpu.device,o=e.layout[i],a=[],l=this._renderer;for(const c in o){const p=(s=t.resources[c])!=null?s:t.resources[o[c]];let f;if(p._resourceType==="uniformGroup"){const m=p;l.ubo.updateUniformGroup(m);const _=m.buffer;f={buffer:l.buffer.getGPUBuffer(_),offset:0,size:_.descriptor.size}}else if(p._resourceType==="buffer"){const m=p;f={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(p._resourceType==="bufferResource"){const m=p;f={buffer:l.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size}}else if(p._resourceType==="textureSampler"){const m=p;f=l.texture.getGpuSampler(m)}else if(p._resourceType==="textureSource"){const m=p;f=l.texture.getGpuSource(m).createView({})}a.push({binding:o[c],resource:f})}const u=l.shader.getProgramData(e).bindGroups[i],h=n.createBindGroup({layout:u,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}}yu.extension={type:[T.WebGPUSystem],name:"bindGroup"};class xu{constructor(t){this._gpuBuffers=Object.create(null),t.renderableGC.addManagedHash(this,"_gpuBuffers")}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),i=t.data;return t._updateID&&i&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,i.buffer,0,(t._updateSize||i.byteLength)+3&-4)),e}destroyAll(){var t;for(const e in this._gpuBuffers)(t=this._gpuBuffers[e])==null||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));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(Ni(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._destroyBuffer(t)}destroy(){this.destroyAll(),this._gpuBuffers={}}_destroyBuffer(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]&&(this._gpuBuffers[t.uid].destroy(),this._gpuBuffers[t.uid]=null)}}xu.extension={type:[T.WebGPUSystem],name:"buffer"};class Zv{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let i=e+t*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i<t.length;i++)this.data[e/4+i]=t[i];return e}destroy(){this.data=null}}class Tu{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}Tu.extension={type:[T.WebGPUSystem],name:"colorMask"};class on{constructor(t){this._renderer=t}async init(t){return this._initPromise?this._initPromise:(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await L.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),s=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:s}}destroy(){this.gpu=null,this._renderer=null}}on.extension={type:[T.WebGPUSystem],name:"device"},on.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var AR=Object.defineProperty,Qv=Object.getOwnPropertySymbols,ER=Object.prototype.hasOwnProperty,PR=Object.prototype.propertyIsEnumerable,Jv=(r,t,e)=>t in r?AR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ty=(r,t)=>{for(var e in t||(t={}))ER.call(t,e)&&Jv(r,e,t[e]);if(Qv)for(var e of Qv(t))PR.call(t,e)&&Jv(r,e,t[e]);return r};class Su{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,i,s){const n=this._renderer.pipeline.getPipeline(t,e,i,s);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const s=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,s)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const s in i)this._setVertexBuffer(parseInt(s,10),t.attributes[i[s]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const s=t.groups[i];e||this._syncBindGroup(s),this.setBindGroup(i,s,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const i=t.resources[e];i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(t){const{geometry:e,shader:i,state:s,topology:n,size:o,start:a,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,s,n),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,u),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,l!=null?l:e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),l!=null?l:e.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=ty({},this._boundVertexBuffer),s=this._boundIndexBuffer,n=ty({},this._boundBindGroup);this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(const a in i)this._setVertexBuffer(a,i[a]);for(const a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(s)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}Su.extension={type:[T.WebGPUSystem],name:"encoder",priority:1};class Au{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}Au.extension={type:[T.WebGPUSystem],name:"limits"};class Eu{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:rt.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid];i.stencilMode=t,i.stencilReference=e;const s=this._renderer;s.pipeline.setStencilMode(t),s.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Eu.extension={type:[T.WebGPUSystem],name:"stencil"};const di={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function ey(r){const t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i<t.length;i++){const s=t[i];let n=di[s.data.type].size;const o=di[s.data.type].align;if(!di[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(n=Math.max(n,o)*s.data.size),e=Math.ceil(e/o)*o,s.size=n,s.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function ry(r,t){const{size:e,align:i}=di[r.data.type],s=(i-e)/4,n=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
v = uv.${r.data.name};
|
|
${t!==0?`offset += ${t};`:""}
|
|
|
|
arrayOffset = offset;
|
|
|
|
t = 0;
|
|
|
|
for(var i=0; i < ${r.data.size*(e/4)}; i++)
|
|
{
|
|
for(var j = 0; j < ${e/4}; j++)
|
|
{
|
|
${n}[arrayOffset++] = v[t++];
|
|
}
|
|
${s!==0?`arrayOffset += ${s};`:""}
|
|
}
|
|
`}function iy(r){return Ul(r,"uboWgsl",ry,Bb)}class Pu extends Fl{constructor(){super({createUboElements:ey,generateUboSync:iy})}}Pu.extension={type:[T.WebGPUSystem],name:"ubo"};const pe=128;class wu{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new Zv({minUniformOffsetAlignment:pe});const e=256/pe;for(let i=0;i<e;i++){let s=X.UNIFORM|X.COPY_DST;i===0&&(s|=X.COPY_SRC),this._buffers.push(new bt({data:this._batchBuffer.data,usage:s}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const i=t.buffer.data,s=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,s/4),this._bindGroupHash[t.uid]=this._getBindGroup(s/pe),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,i=this._batchBuffer.addGroup(e);return this._getBufferResource(i/pe)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/pe)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/pe;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Zs({buffer:e,offset:(t/2|0)*256,size:pe})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Kt({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const i=this._renderer.gpu.device.createCommandEncoder();for(let s=1;s<this._buffers.length;s++){const n=this._buffers[s];i.copyBufferToBuffer(t.getGPUBuffer(e),pe,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([i.finish()])}destroy(){var t;for(let e=0;e<this._bindGroups.length;e++)(t=this._bindGroups[e])==null||t.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}wu.extension={type:[T.WebGPUPipes],name:"uniformBatch"};var wR=Object.defineProperty,RR=Object.defineProperties,MR=Object.getOwnPropertyDescriptors,sy=Object.getOwnPropertySymbols,CR=Object.prototype.hasOwnProperty,OR=Object.prototype.propertyIsEnumerable,ny=(r,t,e)=>t in r?wR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GR=(r,t)=>{for(var e in t||(t={}))CR.call(t,e)&&ny(r,e,t[e]);if(sy)for(var e of sy(t))OR.call(t,e)&&ny(r,e,t[e]);return r},BR=(r,t)=>RR(r,MR(t));const IR={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function FR(r,t,e,i,s){return r<<24|t<<16|e<<10|i<<5|s}function DR(r,t,e,i){return e<<6|r<<3|i<<1|t}class Ru{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(rt.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._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,i,s){const n=this.getPipeline(t,e,i);s.setPipeline(n)}getPipeline(t,e,i,s){t._layoutKey||(wl(t,e.attributeData),this._generateBufferKey(t)),s||(s=t.topology);const n=FR(t._layoutKey,e._layoutKey,i.data,i._blendModeId,IR[s]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,i,s),this._pipeCache[n])}_createPipeline(t,e,i,s){const n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(i);a[0].writeMask=this._stencilMode===rt.RENDERING_MASK_ADD?0:this._colorMask;const l=this._renderer.shader.getProgramData(e).pipeline,u={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:a},primitive:{topology:s,cullMode:i.cullMode},layout:l,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(u.depthStencil=BR(GR({},this._stencilState),{format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"})),n.createRenderPipeline(u)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let i=0;const s=Object.keys(t.attributes).sort();for(let o=0;o<s.length;o++){const a=t.attributes[s[o]];e[i++]=a.offset,e[i++]=a.format,e[i++]=a.stride,e[i++]=a.instance}const n=e.join("|");return t._layoutKey=Ve(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const s=Object.keys(t.attributeData).sort();for(let o=0;o<s.length;o++){const a=t.attributeData[s[o]];e[i++]=a.location}const n=e.join("|");return t._attributeLocationsKey=Ve(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const s=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<s.length;a++){const l=Object.values(s[a].attributes)[0].shaderLocation;for(const u in o)if(o[u].location===l){n[a]=u;break}}return this._bindingNamesCache[i]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const s=[];return t.buffers.forEach(n=>{var o;const a={arrayStride:0,stepMode:"vertex",attributes:[]},l=a.attributes;for(const u in e.attributeData){const h=t.attributes[u];((o=h.divisor)!=null?o:1)!==1&&Zt(`Attribute ${u} has an invalid divisor value of '${h.divisor}'. WebGPU only supports a divisor value of 1`),h.buffer===n&&(a.arrayStride=h.stride,a.stepMode=h.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:h.offset,format:h.format}))}l.length&&s.push(a)}),this._bufferLayoutsCache[i]=s,s}_updatePipeHash(){const t=DR(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}}Ru.extension={type:[T.WebGPUSystem],name:"pipeline"};class oy{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class ay{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,s,n){const o=this._renderer,a=this._getGpuColorTexture(t),l=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:i},{texture:l,origin:n},s),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem.getGpuRenderTarget(t),o=this.getDescriptor(t,e,i);n.descriptor=o,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,i){typeof e=="boolean"&&(e=e?xt.ALL:xt.NONE);const s=this._renderTargetSystem,n=s.getGpuRenderTarget(t),o=t.colorTextures.map((l,u)=>{const h=n.contexts[u];let c,p;h?c=h.getCurrentTexture().createView():c=this._renderer.texture.getGpuSource(l).createView({mipLevelCount:1}),n.msaaTextures[u]&&(p=c,c=this._renderer.texture.getTextureView(n.msaaTextures[u]));const f=e&xt.COLOR?"clear":"load";return i!=null||(i=s.defaultClearColor),{view:c,resolveTarget:p,clearValue:i,storeOp:"store",loadOp:f}});let a;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const l=e&xt.STENCIL?"clear":"load",u=e&xt.DEPTH?"clear":"load";a={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:l,depthClearValue:1,depthLoadOp:u,depthStoreOp:"store"}}return{colorAttachments:o,depthStencilAttachment:a}}clear(t,e=!0,i,s){if(!e)return;const{gpu:n,encoder:o}=this._renderer,a=n.device;if(o.commandEncoder===null){const l=a.createCommandEncoder(),u=this.getDescriptor(t,e,i),h=l.beginRenderPass(u);h.setViewport(s.x,s.y,s.width,s.height,0,1),h.end();const c=l.finish();a.queue.submit([c])}else this.startRenderPass(t,e,i,s)}initGpuRenderTarget(t){t.isRoot=!0;const e=new oy;return t.colorTextures.forEach((i,s)=>{if(i instanceof Yt){const n=i.resource.getContext("webgpu"),o=i.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[s]=n}if(e.msaa=i.source.antialias,i.source.antialias){const n=new Q({width:0,height:0,sampleCount:4});e.msaaTextures[s]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,s)=>{const n=e.msaaTextures[s];n==null||n.resize(i.source.width,i.source.height,i.source._resolution)})}}class Mu extends Nl{constructor(t){super(t),this.adaptor=new ay,this.adaptor.init(t,this)}}Mu.extension={type:[T.WebGPUSystem],name:"renderTarget"};class Cu{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,i=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),s={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(s)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}Cu.extension={type:[T.WebGPUSystem],name:"shader"};const ft={};ft.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},ft.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},ft.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},ft.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ft.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ft.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},ft["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},ft["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},ft["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},ft.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},ft.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},ft.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class Ou{constructor(){this.defaultState=new wt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:ft[t.blendMode]||ft.normal}]}destroy(){this.gpu=null}}Ou.extension={type:[T.WebGPUSystem],name:"state"};const ly={type:"image",upload(r,t,e){const i=r.resource,s=(r.pixelWidth|0)*(r.pixelHeight|0),n=i.byteLength/s;e.device.queue.writeTexture({texture:t},i,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelWidth*n},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},Gu={"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}},UR={blockBytes:4,blockWidth:1,blockHeight:1},uy={type:"compressed",upload(r,t,e){let i=r.pixelWidth,s=r.pixelHeight;const n=Gu[r.format]||UR;for(let o=0;o<r.resource.length;o++){const a=r.resource[o],l=Math.ceil(i/n.blockWidth)*n.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:o},a,{offset:0,bytesPerRow:l},{width:Math.ceil(i/n.blockWidth)*n.blockWidth,height:Math.ceil(s/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),s=Math.max(s>>1,1)}}},Bu={type:"image",upload(r,t,e){const i=r.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){const a=L.get().createCanvas(i.width,i.height);a.getContext("2d").drawImage(i,0,0,i.width,i.height),r.resource=a}const s=Math.min(t.width,r.resourceWidth||r.pixelWidth),n=Math.min(t.height,r.resourceHeight||r.pixelHeight),o=r.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,premultipliedAlpha:o},{width:s,height:n})}},hy={type:"video",upload(r,t,e){Bu.upload(r,t,e)}};class cy{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
|
|
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
|
|
|
|
struct VertexOutput {
|
|
@builtin(position) position : vec4<f32>,
|
|
@location(0) texCoord : vec2<f32>,
|
|
};
|
|
|
|
@vertex
|
|
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
|
|
var output : VertexOutput;
|
|
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
|
|
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
|
|
return output;
|
|
}
|
|
|
|
@group(0) @binding(0) var imgSampler : sampler;
|
|
@group(0) @binding(1) var img : texture_2d<f32>;
|
|
|
|
@fragment
|
|
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
|
return textureSample(img, imgSampler, texCoord);
|
|
}
|
|
`})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const s=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(l)}const o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let l=0;l<s;++l){let u=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),h=n?1:0;for(let c=1;c<t.mipLevelCount;++c){const p=i.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),f=o.beginRenderPass({colorAttachments:[{view:p,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),m=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:u}]});f.setPipeline(e),f.setBindGroup(0,m),f.draw(3,1,0,0),f.end(),u=p}}if(!n){const l={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s};for(let u=1;u<t.mipLevelCount;++u)o.copyTextureToTexture({texture:i,mipLevel:u-1},{texture:t,mipLevel:u},l),l.width=Math.ceil(l.width/2),l.height=Math.ceil(l.height/2)}return this.device.queue.submit([o.finish()]),n||i.destroy(),t}}class Iu{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:Bu,buffer:ly,video:hy,compressed:uy},this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){return this._gpuSources[t.uid]?this._gpuSources[t.uid]:this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=Gu[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},s=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,o={label:t.label,size:{width:s,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpuSources[t.uid]=this._gpu.device.createTexture(o);return this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),a}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new cy(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 Kt({0:e,1:e.style,2:new nt({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){var e;const i=t.source;return(e=this._textureViewHash[i.uid])!=null?e:this._createTextureView(i)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),s=L.get().createCanvas();s.width=t.source.pixelWidth,s.height=t.source.pixelHeight;const n=s.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:L.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:s.width,height:s.height}),e.gpu.device.queue.submit([i.finish()]),s}getPixels(t){const e=this.generateCanvas(t),i=Qt.getOptimalCanvasAndContext(e.width,e.height),s=i.context;s.drawImage(e,0,0);const{width:n,height:o}=e,a=s.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return Qt.returnCanvasAndContext(i),{pixels:l,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),i=this._bindGroupHash[e];i==null||i.destroy(),this._bindGroupHash[e]=null}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Iu.extension={type:[T.WebGPUSystem],name:"texture"};class Fu{constructor(){this._maxTextures=0}contextChange(t){const e=new nt({uTransformMatrix:{value:new M,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=Ye({name:"graphics",bits:[zi,Wi(this._maxTextures),um,qe]});this.shader=new Pt({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(i),u=n.encoder;u.setGeometry(a.geometry,s.gpuProgram);const h=n.globalUniforms.bindGroup;u.setBindGroup(0,h,s.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);u.setBindGroup(2,c,s.gpuProgram);const p=l.instructions;let f=null;for(let m=0;m<l.instructionSize;m++){const _=p[m];if(_.topology!==f&&(f=_.topology,u.setPipelineFromGeometryProgramAndState(a.geometry,s.gpuProgram,t.state,_.topology)),s.groups[1]=_.bindGroup,!_.gpuBindGroup){const g=_.textures;_.bindGroup=Li(g.textures,g.count,this._maxTextures),_.gpuBindGroup=n.bindGroup.getBindGroup(_.bindGroup,s.gpuProgram,1)}u.setBindGroup(1,_.bindGroup,s.gpuProgram),u.renderPassEncoder.drawIndexed(_.size,1,_.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}Fu.extension={type:[T.WebGPUPipesAdaptor],name:"graphics"};class Du{init(){const t=Ye({name:"mesh",bits:[lr,mb,qe]});this._shader=new Pt({gpuProgram:t,resources:{uTexture:w.EMPTY._source,uSampler:w.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new M}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(!s)s=this._shader,s.groups[2]=i.texture.getTextureBindGroup(e.texture);else if(!s.gpuProgram)return;const n=s.gpuProgram;if(n.autoAssignGlobalUniforms&&(s.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const o=t.localUniforms;s.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Du.extension={type:[T.WebGPUPipesAdaptor],name:"mesh"};const kR=[...bu,Pu,Su,on,Au,xu,Iu,Mu,Cu,Ou,Ru,Tu,Eu,yu],$R=[...vu,wu],LR=[vl,Du,Fu],dy=[],py=[],fy=[];F.handleByNamedList(T.WebGPUSystem,dy),F.handleByNamedList(T.WebGPUPipes,py),F.handleByNamedList(T.WebGPUPipesAdaptor,fy),F.add(...kR,...$R,...LR);class my extends qr{constructor(){const t={name:"webgpu",type:yt.WEBGPU,systems:dy,renderPipes:py,renderPipeAdaptors:fy};super(t)}}var NR={__proto__:null,WebGPURenderer:my};const XR={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},HR=new Proxy(XR,{get(r,t){return r[t]}});var Uu=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(Uu||{});const jR=new Proxy(Uu,{get(r,t){return r[t]}});var ku=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(ku||{});const zR=new Proxy(ku,{get(r,t){return r[t]}});class VR{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,u=t.y/n+a;i=N.add(i,N.NW),this.x0=l+o*N.uX(i),this.y0=u+a*N.uY(i),i=N.add(i,2),this.x1=l+o*N.uX(i),this.y1=u+a*N.uY(i),i=N.add(i,2),this.x2=l+o*N.uX(i),this.y2=u+a*N.uY(i),i=N.add(i,2),this.x3=l+o*N.uX(i),this.y3=u+a*N.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}function WR(r){const t=r.toString(),e=t.indexOf("{"),i=t.lastIndexOf("}");if(e===-1||i===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,i).trim()}function YR(r,t){return r.getFastGlobalBounds(!0,t)}var KR=Object.defineProperty,an=Object.getOwnPropertySymbols,gy=Object.prototype.hasOwnProperty,_y=Object.prototype.propertyIsEnumerable,by=(r,t,e)=>t in r?KR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qR=(r,t)=>{for(var e in t||(t={}))gy.call(t,e)&&by(r,e,t[e]);if(an)for(var e of an(t))_y.call(t,e)&&by(r,e,t[e]);return r},ZR=(r,t)=>{var e={};for(var i in r)gy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&an)for(var i of an(r))t.indexOf(i)<0&&_y.call(r,i)&&(e[i]=r[i]);return e};class QR extends Wt{constructor(t){var e,i;typeof t=="function"&&(t={render:t});const s=t,{render:n}=s,o=ZR(s,["render"]);super(qR({label:"RenderContainer"},o)),this.renderPipeId="customRender",this.batched=!1,n&&(this.render=n),this.containsPoint=(e=t.containsPoint)!=null?e:()=>!1,this.addBounds=(i=t.addBounds)!=null?i:()=>!1}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function JR(r,t,e){const i=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,i,null)}function tM(r,t){const e=t._scale,i=t._pivot,s=t._position,n=e._x,o=e._y,a=i._x,l=i._y;r.a=t._cx*n,r.b=t._sx*n,r.c=t._cy*o,r.d=t._sy*o,r.tx=s._x-(a*r.a+l*r.c),r.ty=s._y-(a*r.b+l*r.d)}function eM(r,t,e){const i=r.a,s=r.b,n=r.c,o=r.d,a=r.tx,l=r.ty,u=t.a,h=t.b,c=t.c,p=t.d;e.a=i*u+s*c,e.b=i*h+s*p,e.c=n*u+o*c,e.d=n*h+o*p,e.tx=a*u+l*c+t.tx,e.ty=a*h+l*p+t.ty}function rM(r){r instanceof Lt&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],i=[],s=r.path.shapePath,n=r.textureMatrix;s.shapePrimitives.forEach(({shape:a,transform:l})=>{const u=i.length,h=t.length/2,c=[],p=tr[a.type];p.build(a,c),l&&Qi(c,l),p.triangulate(c,t,2,h,i,u);const f=e.length/2;n?(l&&n.append(l.clone().invert()),So(t,2,h,e,f,2,t.length/2-h,n)):Ao(e,f,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(i),o):new ue({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(i)})}var iM=Object.defineProperty,vy=Object.getOwnPropertySymbols,sM=Object.prototype.hasOwnProperty,nM=Object.prototype.propertyIsEnumerable,yy=(r,t,e)=>t in r?iM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xy=(r,t)=>{for(var e in t||(t={}))sM.call(t,e)&&yy(r,e,t[e]);if(vy)for(var e of vy(t))nM.call(t,e)&&yy(r,e,t[e]);return r};const Ty=class s0 extends q{constructor(t={}){t=xy(xy({},s0.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;e<t.length;e++){const i=t[e];if(i.parentRenderLayer){if(i.parentRenderLayer===this)continue;i.parentRenderLayer.detach(i)}this.renderLayerChildren.push(i),i.parentRenderLayer=this;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)}return t[0]}detach(...t){for(let e=0;e<t.length;e++){const i=t[e],s=this.renderLayerChildren.indexOf(i);s!==-1&&this.renderLayerChildren.splice(s,1),i.parentRenderLayer=null;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0)}return t[0]}detachAll(){const t=this.renderLayerChildren;for(let e=0;e<t.length;e++)t[e].parentRenderLayer=null;this.renderLayerChildren.length=0}collectRenderables(t,e,i){const s=this.renderLayerChildren,n=s.length;this.sortableChildren&&this.sortRenderLayerChildren();for(let o=0;o<n;o++)s[o].parent||Zt("Container must be added to both layer and scene graph. Layers only handle render order - the scene graph is required for transforms (addChild)",s[o]),s[o].collectRenderables(t,e,this)}sortRenderLayerChildren(){this.renderLayerChildren.sort(this.sortFunction)}_getGlobalBoundsRecursive(t,e,i){if(!t)return;const s=this.renderLayerChildren;for(let n=0;n<s.length;n++)s[n]._getGlobalBoundsRecursive(!0,e,this)}getFastGlobalBounds(t,e){return super.getFastGlobalBounds(t,e)}addChild(...t){throw new Error("RenderLayer.addChild() is not available. Please use RenderLayer.attach()")}removeChild(...t){throw new Error("RenderLayer.removeChild() is not available. Please use RenderLayer.detach()")}removeChildren(t,e){throw new Error("RenderLayer.removeChildren() is not available. Please use RenderLayer.detach()")}removeChildAt(t){throw new Error("RenderLayer.removeChildAt() is not available")}getChildAt(t){throw new Error("RenderLayer.getChildAt() is not available")}setChildIndex(t,e){throw new Error("RenderLayer.setChildIndex() is not available")}getChildIndex(t){throw new Error("RenderLayer.getChildIndex() is not available")}addChildAt(t,e){throw new Error("RenderLayer.addChildAt() is not available")}swapChildren(t,e){throw new Error("RenderLayer.swapChildren() is not available")}reparentChild(...t){throw new Error("RenderLayer.reparentChild() is not available with the render layer")}reparentChildAt(t,e){throw new Error("RenderLayer.reparentChildAt() is not available with the render layer")}};Ty.defaultOptions={sortableChildren:!1,sortFunction:(r,t)=>r.zIndex-t.zIndex};let oM=Ty;function Sy(r,t,e,i){const s=e.buffers[0],n=s.data,{verticesX:o,verticesY:a}=e,l=r/(o-1),u=t/(a-1);let h=0;const c=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],b=i[6],y=i[7],v=i[8];for(let x=0;x<n.length;x+=2){const A=h%o*l,S=(h/o|0)*u,E=c*A+p*S+f,C=m*A+_*S+g,O=b*A+y*S+v;n[x]=E/O,n[x+1]=C/O,h++}s.update()}function Ay(r,t){const e=t[0],i=t[1],s=t[2],n=t[3],o=t[4],a=t[5],l=t[6],u=t[7],h=t[8];return r[0]=o*h-a*u,r[1]=s*u-i*h,r[2]=i*a-s*o,r[3]=a*l-n*h,r[4]=e*h-s*l,r[5]=s*n-e*a,r[6]=n*u-o*l,r[7]=i*l-e*u,r[8]=e*o-i*n,r}function Ey(r,t,e){const i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],l=t[5],u=t[6],h=t[7],c=t[8],p=e[0],f=e[1],m=e[2],_=e[3],g=e[4],b=e[5],y=e[6],v=e[7],x=e[8];return r[0]=p*i+f*o+m*u,r[1]=p*s+f*a+m*h,r[2]=p*n+f*l+m*c,r[3]=_*i+g*o+b*u,r[4]=_*s+g*a+b*h,r[5]=_*n+g*l+b*c,r[6]=y*i+v*o+x*u,r[7]=y*s+v*a+x*h,r[8]=y*n+v*l+x*c,r}function aM(r,t,e){const i=e[0],s=e[1],n=e[2];return r[0]=t[0]*i+t[1]*s+t[2]*n,r[1]=t[3]*i+t[4]*s+t[5]*n,r[2]=t[6]*i+t[7]*s+t[8]*n,r}const lM=[0,0,0,0,0,0,0,0,0],uM=[0,0,0],ln=[0,0,0];function Py(r,t,e,i,s,n,o,a,l){const u=lM;u[0]=t,u[1]=i,u[2]=n,u[3]=e,u[4]=s,u[5]=o,u[6]=1,u[7]=1,u[8]=1;const h=Ay(r,u);ln[0]=a,ln[1]=l,ln[2]=1;const c=aM(uM,h,ln),p=r;return r[0]=c[0],r[1]=0,r[2]=0,r[3]=0,r[4]=c[1],r[5]=0,r[6]=0,r[7]=0,r[8]=c[2],Ey(r,p,u)}const hM=[0,0,0,0,0,0,0,0,0],cM=[0,0,0,0,0,0,0,0,0];function wy(r,t,e,i,s,n,o,a,l,u,h,c,p,f,m,_,g){const b=Py(hM,t,e,n,o,u,h,f,m),y=Py(cM,i,s,a,l,c,p,_,g);return Ey(r,Ay(b,b),y)}class Ry extends ys{constructor(t){super(t),this._projectionMatrix=[0,0,0,0,0,0,0,0,0];const{width:e,height:i}=t;this.corners=[0,0,e,0,e,i,0,i]}setCorners(t,e,i,s,n,o,a,l){const u=this.corners;u[0]=t,u[1]=e,u[2]=i,u[3]=s,u[4]=n,u[5]=o,u[6]=a,u[7]=l,this.updateProjection()}updateProjection(){const{width:t,height:e}=this,i=this.corners,s=wy(this._projectionMatrix,0,0,i[0],i[1],t,0,i[2],i[3],t,e,i[4],i[5],0,e,i[6],i[7]);Sy(t,e,this,s)}}var dM=Object.defineProperty,pM=Object.defineProperties,fM=Object.getOwnPropertyDescriptors,un=Object.getOwnPropertySymbols,My=Object.prototype.hasOwnProperty,Cy=Object.prototype.propertyIsEnumerable,Oy=(r,t,e)=>t in r?dM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$u=(r,t)=>{for(var e in t||(t={}))My.call(t,e)&&Oy(r,e,t[e]);if(un)for(var e of un(t))Cy.call(t,e)&&Oy(r,e,t[e]);return r},mM=(r,t)=>pM(r,fM(t)),gM=(r,t)=>{var e={};for(var i in r)My.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&un)for(var i of un(r))t.indexOf(i)<0&&Cy.call(r,i)&&(e[i]=r[i]);return e};const Gy=class n0 extends fr{constructor(t){t=$u($u({},n0.defaultOptions),t);const e=t,{texture:i,verticesX:s,verticesY:n}=e,o=gM(e,["texture","verticesX","verticesY"]),a=new Ry(Ut({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(Ut(mM($u({},o),{geometry:a}))),this._texture=i,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){const t=this.geometry;if(!t)return;const{width:e,height:i}=this.texture;(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.updateProjection())}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,i,s,n,o,a,l){this.geometry.setCorners(t,e,i,s,n,o,a,l)}};Gy.defaultOptions={texture:w.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let _M=Gy;var bM=Object.defineProperty,vM=Object.defineProperties,yM=Object.getOwnPropertyDescriptors,hn=Object.getOwnPropertySymbols,By=Object.prototype.hasOwnProperty,Iy=Object.prototype.propertyIsEnumerable,Fy=(r,t,e)=>t in r?bM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xM=(r,t)=>{for(var e in t||(t={}))By.call(t,e)&&Fy(r,e,t[e]);if(hn)for(var e of hn(t))Iy.call(t,e)&&Fy(r,e,t[e]);return r},TM=(r,t)=>vM(r,yM(t)),SM=(r,t)=>{var e={};for(var i in r)By.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&hn)for(var i of hn(r))t.indexOf(i)<0&&Iy.call(r,i)&&(e[i]=r[i]);return e};class AM extends fr{constructor(t){const e=t,{texture:i,verticesX:s,verticesY:n}=e,o=SM(e,["texture","verticesX","verticesY"]),a=new ys(Ut({width:i.width,height:i.height,verticesX:s,verticesY:n}));super(Ut(TM(xM({},o),{geometry:a,texture:i}))),this.texture=i,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:i}=this.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var EM=Object.defineProperty,Dy=Object.getOwnPropertySymbols,PM=Object.prototype.hasOwnProperty,wM=Object.prototype.propertyIsEnumerable,Uy=(r,t,e)=>t in r?EM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ky=(r,t)=>{for(var e in t||(t={}))PM.call(t,e)&&Uy(r,e,t[e]);if(Dy)for(var e of Dy(t))wM.call(t,e)&&Uy(r,e,t[e]);return r};const $y=class o0 extends ue{constructor(t){const{width:e,points:i,textureScale:s}=ky(ky({},o0.defaultOptions),t);super({positions:new Float32Array(i.length*4),uvs:new Float32Array(i.length*4),indices:new Uint32Array((i.length-1)*6)}),this.points=i,this._width=e,this.textureScale=s,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),s=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),s.data=new Uint16Array((t.length-1)*6));const n=i.data,o=s.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,l=t[0];const u=this._width*this.textureScale,h=t.length;for(let p=0;p<h;p++){const f=p*4;if(this.textureScale>0){const m=l.x-t[p].x,_=l.y-t[p].y,g=Math.sqrt(m*m+_*_);l=t[p],a+=g/u}else a=p/(h-1);n[f]=a,n[f+1]=0,n[f+2]=a,n[f+3]=1}let c=0;for(let p=0;p<h-1;p++){const f=p*2;o[c++]=f,o[c++]=f+1,o[c++]=f+2,o[c++]=f+2,o[c++]=f+1,o[c++]=f+3}i.update(),s.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],i,s=0,n=0;const o=this.buffers[0].data,a=t.length,l=this.textureScale>0?this.textureScale*this._width/2:this._width/2;for(let u=0;u<a;u++){const h=t[u],c=u*4;u<t.length-1?i=t[u+1]:i=h,n=-(i.x-e.x),s=i.y-e.y;let p=(1-u/(a-1))*10;p>1&&(p=1);const f=Math.sqrt(s*s+n*n);f<1e-6?(s=0,n=0):(s/=f,n/=f,s*=l,n*=l),o[c]=h.x+s,o[c+1]=h.y+n,o[c+2]=h.x-s,o[c+3]=h.y-n,e=h}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};$y.defaultOptions={width:200,points:[],textureScale:0};let Ly=$y;var RM=Object.defineProperty,MM=Object.defineProperties,CM=Object.getOwnPropertyDescriptors,cn=Object.getOwnPropertySymbols,Ny=Object.prototype.hasOwnProperty,Xy=Object.prototype.propertyIsEnumerable,Hy=(r,t,e)=>t in r?RM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lu=(r,t)=>{for(var e in t||(t={}))Ny.call(t,e)&&Hy(r,e,t[e]);if(cn)for(var e of cn(t))Xy.call(t,e)&&Hy(r,e,t[e]);return r},OM=(r,t)=>MM(r,CM(t)),GM=(r,t)=>{var e={};for(var i in r)Ny.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&cn)for(var i of cn(r))t.indexOf(i)<0&&Xy.call(r,i)&&(e[i]=r[i]);return e};const jy=class a0 extends fr{constructor(t){const e=Lu(Lu({},a0.defaultOptions),t),{texture:i,points:s,textureScale:n}=e,o=GM(e,["texture","points","textureScale"]),a=new Ly(Ut({width:i.height,points:s,textureScale:n}));n>0&&(i.source.style.addressMode="repeat"),super(Ut(OM(Lu({},o),{texture:i,geometry:a}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};jy.defaultOptions={textureScale:0};let BM=jy;var IM=Object.defineProperty,FM=Object.defineProperties,DM=Object.getOwnPropertyDescriptors,dn=Object.getOwnPropertySymbols,zy=Object.prototype.hasOwnProperty,Vy=Object.prototype.propertyIsEnumerable,Wy=(r,t,e)=>t in r?IM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,UM=(r,t)=>{for(var e in t||(t={}))zy.call(t,e)&&Wy(r,e,t[e]);if(dn)for(var e of dn(t))Vy.call(t,e)&&Wy(r,e,t[e]);return r},kM=(r,t)=>FM(r,DM(t)),$M=(r,t)=>{var e={};for(var i in r)zy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&dn)for(var i of dn(r))t.indexOf(i)<0&&Vy.call(r,i)&&(e[i]=r[i]);return e};class LM extends fr{constructor(t){const e=t,{texture:i,vertices:s,uvs:n,indices:o,topology:a}=e,l=$M(e,["texture","vertices","uvs","indices","topology"]),u=new ue(Ut({positions:s,uvs:n,indices:o,topology:a}));super(Ut(kM(UM({},l),{texture:i,geometry:u}))),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(t){this.geometry.getBuffer("aPosition").data=t}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}function NM(r,t){const{width:e,height:i}=r.frame;return t.scale(1/e,1/i),t}var XM=Object.defineProperty,Yy=Object.getOwnPropertySymbols,HM=Object.prototype.hasOwnProperty,jM=Object.prototype.propertyIsEnumerable,Ky=(r,t,e)=>t in r?XM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qy=(r,t)=>{for(var e in t||(t={}))HM.call(t,e)&&Ky(r,e,t[e]);if(Yy)for(var e of Yy(t))jM.call(t,e)&&Ky(r,e,t[e]);return r};const Zy=class Zu{constructor(t){if(t instanceof w)this.texture=t,Ci(this,Zu.defaultOptions,{});else{const e=qy(qy({},Zu.defaultOptions),t);Ci(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return ke(this._tint)}set tint(t){this._tint=H.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};Zy.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let zM=Zy;const Nu={vertex:{attributeName:"aVertex",format:"float32x2",code:`
|
|
const texture = p.texture;
|
|
const sx = p.scaleX;
|
|
const sy = p.scaleY;
|
|
const ax = p.anchorX;
|
|
const ay = p.anchorY;
|
|
const trim = texture.trim;
|
|
const orig = texture.orig;
|
|
|
|
if (trim)
|
|
{
|
|
w1 = trim.x - (ax * orig.width);
|
|
w0 = w1 + trim.width;
|
|
|
|
h1 = trim.y - (ay * orig.height);
|
|
h0 = h1 + trim.height;
|
|
}
|
|
else
|
|
{
|
|
w1 = -ax * (orig.width);
|
|
w0 = w1 + orig.width;
|
|
|
|
h1 = -ay * (orig.height);
|
|
h0 = h1 + orig.height;
|
|
}
|
|
|
|
f32v[offset] = w1 * sx;
|
|
f32v[offset + 1] = h1 * sy;
|
|
|
|
f32v[offset + stride] = w0 * sx;
|
|
f32v[offset + stride + 1] = h1 * sy;
|
|
|
|
f32v[offset + (stride * 2)] = w0 * sx;
|
|
f32v[offset + (stride * 2) + 1] = h0 * sy;
|
|
|
|
f32v[offset + (stride * 3)] = w1 * sx;
|
|
f32v[offset + (stride * 3) + 1] = h0 * sy;
|
|
`,dynamic:!1},position:{attributeName:"aPosition",format:"float32x2",code:`
|
|
var x = p.x;
|
|
var y = p.y;
|
|
|
|
f32v[offset] = x;
|
|
f32v[offset + 1] = y;
|
|
|
|
f32v[offset + stride] = x;
|
|
f32v[offset + stride + 1] = y;
|
|
|
|
f32v[offset + (stride * 2)] = x;
|
|
f32v[offset + (stride * 2) + 1] = y;
|
|
|
|
f32v[offset + (stride * 3)] = x;
|
|
f32v[offset + (stride * 3) + 1] = y;
|
|
`,dynamic:!0},rotation:{attributeName:"aRotation",format:"float32",code:`
|
|
var rotation = p.rotation;
|
|
|
|
f32v[offset] = rotation;
|
|
f32v[offset + stride] = rotation;
|
|
f32v[offset + (stride * 2)] = rotation;
|
|
f32v[offset + (stride * 3)] = rotation;
|
|
`,dynamic:!1},uvs:{attributeName:"aUV",format:"float32x2",code:`
|
|
var uvs = p.texture.uvs;
|
|
|
|
f32v[offset] = uvs.x0;
|
|
f32v[offset + 1] = uvs.y0;
|
|
|
|
f32v[offset + stride] = uvs.x1;
|
|
f32v[offset + stride + 1] = uvs.y1;
|
|
|
|
f32v[offset + (stride * 2)] = uvs.x2;
|
|
f32v[offset + (stride * 2) + 1] = uvs.y2;
|
|
|
|
f32v[offset + (stride * 3)] = uvs.x3;
|
|
f32v[offset + (stride * 3) + 1] = uvs.y3;
|
|
`,dynamic:!1},color:{attributeName:"aColor",format:"unorm8x4",code:`
|
|
const c = p.color;
|
|
|
|
u32v[offset] = c;
|
|
u32v[offset + stride] = c;
|
|
u32v[offset + (stride * 2)] = c;
|
|
u32v[offset + (stride * 3)] = c;
|
|
`,dynamic:!1}};var VM=Object.defineProperty,WM=Object.defineProperties,YM=Object.getOwnPropertyDescriptors,pn=Object.getOwnPropertySymbols,Qy=Object.prototype.hasOwnProperty,Jy=Object.prototype.propertyIsEnumerable,tx=(r,t,e)=>t in r?VM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gr=(r,t)=>{for(var e in t||(t={}))Qy.call(t,e)&&tx(r,e,t[e]);if(pn)for(var e of pn(t))Jy.call(t,e)&&tx(r,e,t[e]);return r},ex=(r,t)=>WM(r,YM(t)),KM=(r,t)=>{var e={};for(var i in r)Qy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&pn)for(var i of pn(r))t.indexOf(i)<0&&Jy.call(r,i)&&(e[i]=r[i]);return e};const qM=new ot(0,0,0,0),rx=class Qu extends Wt{constructor(t={}){t=ex(gr(gr({},Qu.defaultOptions),t),{dynamicProperties:gr(gr({},Qu.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:i,shader:s,roundPixels:n,texture:o,particles:a}=e,l=KM(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(gr({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=o||null,this.shader=s,this._properties={};for(const u in Nu){const h=Nu[u],c=i[u];this._properties[u]=ex(gr({},h),{dynamic:c})}this.allowChildren=!0,this.roundPixels=n!=null?n:!1,this.particleChildren=a!=null?a:[]}addParticle(...t){for(let e=0;e<t.length;e++)this.particleChildren.push(t[e]);return this.onViewUpdate(),t[0]}removeParticle(...t){let e=!1;for(let i=0;i<t.length;i++){const s=this.particleChildren.indexOf(t[i]);s>-1&&(this.particleChildren.splice(s,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return qM}updateBounds(){}destroy(t=!1){var e,i,s;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const n=typeof t=="boolean"?t:t==null?void 0:t.textureSource,o=(i=this.texture)!=null?i:(e=this.particleChildren[0])==null?void 0:e.texture;o&&o.destroy(n)}this.texture=null,(s=this.shader)==null||s.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const i=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),i}removeParticleAt(t){const e=this.particleChildren.splice(t,1);return this.onViewUpdate(),e[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(...t){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(...t){throw new Error("ParticleContainer.removeChild() is not available. Please use ParticleContainer.removeParticle()")}removeChildren(t,e){throw new Error("ParticleContainer.removeChildren() is not available. Please use ParticleContainer.removeParticles()")}removeChildAt(t){throw new Error("ParticleContainer.removeChildAt() is not available. Please use ParticleContainer.removeParticleAt()")}getChildAt(t){throw new Error("ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()")}setChildIndex(t,e){throw new Error("ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()")}getChildIndex(t){throw new Error("ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()")}addChildAt(t,e){throw new Error("ParticleContainer.addChildAt() is not available. Please use ParticleContainer.addParticleAt()")}swapChildren(t,e){throw new Error("ParticleContainer.swapChildren() is not available. Please use ParticleContainer.swapParticles()")}reparentChild(...t){throw new Error("ParticleContainer.reparentChild() is not available with the particle container")}reparentChildAt(t,e){throw new Error("ParticleContainer.reparentChildAt() is not available with the particle container")}};rx.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let ZM=rx;var QM=Object.defineProperty,fn=Object.getOwnPropertySymbols,ix=Object.prototype.hasOwnProperty,sx=Object.prototype.propertyIsEnumerable,nx=(r,t,e)=>t in r?QM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JM=(r,t)=>{for(var e in t||(t={}))ix.call(t,e)&&nx(r,e,t[e]);if(fn)for(var e of fn(t))sx.call(t,e)&&nx(r,e,t[e]);return r},tC=(r,t)=>{var e={};for(var i in r)ix.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fn)for(var i of fn(r))t.indexOf(i)<0&&sx.call(r,i)&&(e[i]=r[i]);return e};const ox=class l0 extends Wt{constructor(t){var e,i,s,n,o,a,l,u,h,c;t instanceof w&&(t={texture:t});const p=t,{width:f,height:m,anchor:_,leftWidth:g,rightWidth:b,topHeight:y,bottomHeight:v,texture:x,roundPixels:A}=p,S=tC(p,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(JM({label:"NineSliceSprite"},S)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(i=g!=null?g:(e=x==null?void 0:x.defaultBorders)==null?void 0:e.left)!=null?i:he.defaultOptions.leftWidth,this._topHeight=(n=y!=null?y:(s=x==null?void 0:x.defaultBorders)==null?void 0:s.top)!=null?n:he.defaultOptions.topHeight,this._rightWidth=(a=b!=null?b:(o=x==null?void 0:x.defaultBorders)==null?void 0:o.right)!=null?a:he.defaultOptions.rightWidth,this._bottomHeight=(u=v!=null?v:(l=x==null?void 0:x.defaultBorders)==null?void 0:l.bottom)!=null?u:he.defaultOptions.bottomHeight,this._width=(h=f!=null?f:x.width)!=null?h:he.defaultOptions.width,this._height=(c=m!=null?m:x.height)!=null?c:he.defaultOptions.height,this.allowChildren=!1,this.texture=x!=null?x:l0.defaultOptions.texture,this.roundPixels=A!=null?A:!1,this._anchor=new Z({_onUpdate:()=>{this.onViewUpdate()}}),_?this.anchor=_:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return this._width}set width(t){this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this._height=t,this.onViewUpdate()}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=w.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}};ox.defaultOptions={texture:w.EMPTY};let ax=ox;class eC extends ax{constructor(...t){let e=t[0];e instanceof w&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}function lx(r){const{text:t,style:e,chars:i}=r,s=e,n=ar.getFont(t,s),o=ct.graphemeSegmenter(t),a=ms(o,s,n,!0),l=a.scale,u=[],h=[],c=[],p=e.lineHeight?e.lineHeight:n.lineHeight*l;let f=0;for(const m of a.lines){if(m.chars.length===0)continue;const _=new q({label:"line"});_.y=f,c.push(_);let g=new q({label:"word"}),b=0;for(let y=0;y<m.chars.length;y++){const v=m.chars[y];if(!v||!n.chars[v])continue;const x=v===" ",A=y===m.chars.length-1;let S;i.length>0?(S=i.shift(),S.text=v,S.style=s,S.label=`char-${v}`,S.x=m.charPositions[y]*l-m.charPositions[b]*l):S=new _l({text:v,style:s,label:`char-${v}`,x:m.charPositions[y]*l-m.charPositions[b]*l}),x||(u.push(S),g.addChild(S)),(x||A)&&g.children.length>0&&(g.x=m.charPositions[b]*l,h.push(g),_.addChild(g),g=new q({label:"word"}),b=y+1)}f+=p}return{chars:u,lines:c,words:h}}var ux=Object.getOwnPropertySymbols,rC=Object.prototype.hasOwnProperty,iC=Object.prototype.propertyIsEnumerable,sC=(r,t)=>{var e={};for(var i in r)rC.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ux)for(var i of ux(r))t.indexOf(i)<0&&iC.call(r,i)&&(e[i]=r[i]);return e};class Xu extends q{constructor(t){const e=t,{text:i,style:s,autoSplit:n,lineAnchor:o,wordAnchor:a,charAnchor:l}=e,u=sC(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(u),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=i,this._autoSplit=n,this._lineAnchor=o,this._wordAnchor=a,this._charAnchor=l,this.style=s}split(){const t=this.splitFn();this.chars=t.chars,this.words=t.words,this.lines=t.lines,this.addChild(...this.lines),this.charAnchor=this._charAnchor,this.wordAnchor=this._wordAnchor,this.lineAnchor=this._lineAnchor,this._dirty=!1,this._canReuseChars=!0}get text(){return this._originalText}set text(t){this._originalText=t,this.lines.forEach(e=>e.destroy({children:!0})),this.lines.length=0,this.words.length=0,this.chars.length=0,this._canReuseChars=!1,this.onTextUpdate()}_setOrigin(t,e,i){let s;typeof t=="number"?s={x:t,y:t}:s={x:t.x,y:t.y},e.forEach(n=>{const o=n.getLocalBounds(),a=o.minX+o.width*s.x,l=o.minY+o.height*s.y;n.origin.set(a,l)}),this[i]=t}get lineAnchor(){return this._lineAnchor}set lineAnchor(t){this._setOrigin(t,this.lines,"_lineAnchor")}get wordAnchor(){return this._wordAnchor}set wordAnchor(t){this._setOrigin(t,this.words,"_wordAnchor")}get charAnchor(){return this._charAnchor}set charAnchor(t){this._setOrigin(t,this.chars,"_charAnchor")}get style(){return this._style}set style(t){t||(t={}),this._style=new Mt(t),this.words.forEach(e=>e.destroy()),this.words.length=0,this.lines.forEach(e=>e.destroy()),this.lines.length=0,this._canReuseChars=!0,this.onTextUpdate()}onTextUpdate(){this._dirty=!0,this._autoSplit&&this.split()}destroy(t){super.destroy(t),this.chars=[],this.words=[],this.lines=[],(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._originalText=""}}var nC=Object.defineProperty,oC=Object.defineProperties,aC=Object.getOwnPropertyDescriptors,hx=Object.getOwnPropertySymbols,lC=Object.prototype.hasOwnProperty,uC=Object.prototype.propertyIsEnumerable,cx=(r,t,e)=>t in r?nC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pi=(r,t)=>{for(var e in t||(t={}))lC.call(t,e)&&cx(r,e,t[e]);if(hx)for(var e of hx(t))uC.call(t,e)&&cx(r,e,t[e]);return r},hC=(r,t)=>oC(r,aC(t));const dx=class xn extends Xu{constructor(t){const e=pi(pi({},xn.defaultOptions),t);super(e)}static from(t,e){const i=hC(pi(pi({},xn.defaultOptions),e),{text:t.text,style:new Mt(t.style)});return new xn(pi({},i))}splitFn(){return lx({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};dx.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let cC=dx;function dC(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;case"left":default:return 0}}function px(r){return r==="\r"||r===`
|
|
`||r===`\r
|
|
`}function pC(r,t,e){const i=[];let s=t.lines[0],n="",o=[],a=0;return e.wordWrap=!1,r.forEach(l=>{const u=/^\s*$/.test(l),h=px(l),c=n.length===0&&u;if(u&&!h&&c)return;h||(n+=l);const p=ct.measureText(l,e);o.push({char:l,metric:p}),n.length>=s.length&&(i.push({line:n,chars:o,width:o.reduce((f,m)=>f+m.metric.width,0)}),o=[],n="",a++,s=t.lines[a])}),i}function fx(r){var t,e;const{text:i,style:s,chars:n}=r,o=s,a=ct.measureText(i,o),l=ct.graphemeSegmenter(i),u=pC(l,a,o.clone()),h=o.align,c=a.lineWidths.reduce((y,v)=>Math.max(y,v),0),p=[],f=[],m=[];let _=0;const g=((t=o.stroke)==null?void 0:t.width)||0,b=((e=o.dropShadow)==null?void 0:e.distance)||0;return u.forEach((y,v)=>{const x=new q({label:`line-${v}`});x.y=_,f.push(x);const A=a.lineWidths[v];let S=dC(h,A,c),E=new q({label:"word"});E.x=S,y.chars.forEach((C,O)=>{if(C.metric.width!==0){if(px(C.char)){S+=C.metric.width-g;return}if(C.char===" ")E.children.length>0&&(m.push(E),x.addChild(E)),S+=C.metric.width+o.letterSpacing-g,E=new q({label:"word"}),E.x=S;else{let P;n.length>0?(P=n.shift(),P.text=C.char,P.style=o,P.setFromMatrix(M.IDENTITY),P.x=S-E.x-b*O):P=new zs({text:C.char,style:o,x:S-E.x-b*O}),p.push(P),E.addChild(P),S+=C.metric.width+o.letterSpacing-g}}}),E.children.length>0&&(m.push(E),x.addChild(E)),_+=a.lineHeight}),{chars:p,lines:f,words:m}}var fC=Object.defineProperty,mC=Object.defineProperties,gC=Object.getOwnPropertyDescriptors,mx=Object.getOwnPropertySymbols,_C=Object.prototype.hasOwnProperty,bC=Object.prototype.propertyIsEnumerable,gx=(r,t,e)=>t in r?fC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fi=(r,t)=>{for(var e in t||(t={}))_C.call(t,e)&&gx(r,e,t[e]);if(mx)for(var e of mx(t))bC.call(t,e)&&gx(r,e,t[e]);return r},vC=(r,t)=>mC(r,gC(t));const _x=class Tn extends Xu{constructor(t){const e=fi(fi({},Tn.defaultOptions),t);super(e)}static from(t,e){const i=vC(fi(fi({},Tn.defaultOptions),e),{text:t.text,style:new Mt(t.style)});return new Tn(fi({},i))}splitFn(){return fx({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};_x.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let yC=_x;const bx=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function xC(r){const t=[];let e=0;for(let i=0;i<bx.length;i++){const s=`_${bx[i]}`;t[e++]=r[s]}return e=vx(r._fill,t,e),e=SC(r._stroke,t,e),e=AC(r.dropShadow,t,e),e=TC(r.filters,t,e),t.join("-")}function TC(r,t,e){if(!r)return e;for(const i of r)t[e++]=i.uid;return e}function vx(r,t,e){var i;return r&&(t[e++]=r.color,t[e++]=r.alpha,t[e++]=(i=r.fill)==null?void 0:i.styleKey),e}function SC(r,t,e){return r&&(e=vx(r,t,e),t[e++]=r.width,t[e++]=r.alignment,t[e++]=r.cap,t[e++]=r.join,t[e++]=r.miterLimit),e}function AC(r,t,e){return r&&(t[e++]=r.alpha,t[e++]=r.angle,t[e++]=r.blur,t[e++]=r.distance,t[e++]=H.shared.setValue(r.color).toNumber()),e}async function EC(r,t,e=200){const i=await t.extract.base64(r);await t.encoder.commandFinished;const s=e;console.log(`logging texture ${r.source.width}px ${r.source.height}px`);const n=["font-size: 1px;",`padding: ${s}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}var PC=Object.defineProperty,wC=Object.defineProperties,RC=Object.getOwnPropertyDescriptors,yx=Object.getOwnPropertySymbols,MC=Object.prototype.hasOwnProperty,CC=Object.prototype.propertyIsEnumerable,xx=(r,t,e)=>t in r?PC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tx=(r,t)=>{for(var e in t||(t={}))MC.call(t,e)&&xx(r,e,t[e]);if(yx)for(var e of yx(t))CC.call(t,e)&&xx(r,e,t[e]);return r},OC=(r,t)=>wC(r,RC(t));const GC=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let BC=0;function Sx(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=GC[BC++]);let i="";for(let o=0;o<t;o++)i+=" ";let s=r.label;!s&&r instanceof $t&&(s=`sprite:${r.texture.label}`);let n=`%c ${i}|- ${s} (worldX:${r.worldTransform.tx}, relativeRenderX:${r.relativeGroupTransform.tx}, renderX:${r.groupTransform.tx}, localX:${r.x})`;r.renderGroup&&(n+=" (RenderGroup)"),r.filters&&(n+="(*filters)"),console.log(n,`color:${e.color}; font-weight:bold;`),t++;for(let o=0;o<r.children.length;o++){const a=r.children[o];Sx(a,t,Tx({},e))}}function Ax(r,t=0,e={index:0,color:"#000000"}){let i="";for(let n=0;n<t;n++)i+=" ";const s=`%c ${i}- ${e.index}: ${r.root.label} worldX:${r.worldTransform.tx}`;console.log(s,`color:${e.color}; font-weight:bold;`),t++;for(let n=0;n<r.renderGroupChildren.length;n++){const o=r.renderGroupChildren[n];Ax(o,t,OC(Tx({},e),{index:n}))}}return d.AbstractBitmapFont=ma,d.AbstractRenderer=qr,d.AbstractSplitText=Xu,d.AbstractText=Hs,d.AccessibilitySystem=Ac,d.AlphaFilter=HE,d.AlphaMask=Jn,d.AlphaMaskPipe=Tl,d.AnimatedSprite=li,d.Application=zm,d.ApplicationInitHook=$a,d.Assets=ri,d.AssetsClass=Bg,d.BLEND_TO_NPM=td,d.BUFFER_TYPE=hi,d.BackgroundLoader=Ym,d.BackgroundSystem=Ev,d.Batch=od,d.BatchGeometry=dd,d.BatchTextureArray=rd,d.BatchableGraphics=Ji,d.BatchableHTMLText=Hf,d.BatchableMesh=ns,d.BatchableSprite=Lr,d.BatchableText=$p,d.Batcher=hd,d.BatcherPipe=xl,d.BigPool=st,d.BindGroup=Kt,d.BindGroupSystem=yu,d.BitmapFont=Na,d.BitmapFontManager=ar,d.BitmapText=_l,d.BitmapTextGraphics=Nf,d.BitmapTextPipe=ba,d.BlendModeFilter=FE,d.BlendModePipe=lu,d.BlurFilter=y_,d.BlurFilterPass=Is,d.Bounds=ot,d.BrowserAdapter=Bc,d.Buffer=bt,d.BufferImageSource=Ri,d.BufferResource=Zs,d.BufferUsage=X,d.CLEAR=xt,d.Cache=V,d.CanvasObserver=Xn,d.CanvasPool=Qt,d.CanvasPoolClass=vf,d.CanvasSource=Yt,d.CanvasTextGenerator=nr,d.CanvasTextMetrics=ct,d.CanvasTextPipe=Yo,d.CanvasTextSystem=da,d.Circle=as,d.Color=H,d.ColorMask=to,d.ColorMaskPipe=Sl,d.ColorMatrixFilter=aP,d.CompressedSource=ii,d.Container=q,d.Culler=Kg,d.CullerPlugin=qg,d.CustomRenderPipe=eu,d.D3D10_RESOURCE_DIMENSION=sl,d.D3DFMT=Tt,d.DATA_URI=V2,d.DDS=$,d.DEG_TO_RAD=vh,d.DEPRECATED_SCALE_MODES=ku,d.DEPRECATED_WRAP_MODES=Uu,d.DOMAdapter=L,d.DOMContainer=RT,d.DOMPipe=qn,d.DRAW_MODES=HR,d.DXGI_FORMAT=il,d.DXGI_TO_TEXTURE_FORMAT=St,d.DefaultBatcher=Zi,d.DefaultShader=To,d.DisplacementFilter=fP,d.DynamicBitmapFont=ga,d.Ellipse=ls,d.EventBoundary=Pc,d.EventEmitter=gt,d.EventSystem=Kn,d.EventsTicker=Vt,d.ExtensionType=T,d.ExtractSystem=Rv,d.FOURCC_TO_TEXTURE_FORMAT=nl,d.FederatedContainer=Mc,d.FederatedEvent=Le,d.FederatedMouseEvent=Er,d.FederatedPointerEvent=It,d.FederatedWheelEvent=xe,d.FillGradient=qt,d.FillPattern=Nr,d.Filter=Jt,d.FilterEffect=xr,d.FilterPipe=wa,d.FilterSystem=Ga,d.FontStylePromiseCache=_s,d.GAUSSIAN_VALUES=hl,d.GL_FORMATS=Ks,d.GL_INTERNAL_FORMAT=Ng,d.GL_TARGETS=Rl,d.GL_TYPES=j,d.GL_WRAP_MODES=Tb,d.GenerateTextureSystem=du,d.Geometry=Ae,d.GlBackBufferSystem=Rb,d.GlBatchAdaptor=bl,d.GlBuffer=_b,d.GlBufferSystem=El,d.GlColorMaskSystem=Ol,d.GlContextSystem=xb,d.GlEncoderSystem=Gl,d.GlGeometrySystem=Ml,d.GlGraphicsAdaptor=Jl,d.GlLimitsSystem=Bl,d.GlMeshAdaptor=tu,d.GlParticleContainerAdaptor=Op,d.GlParticleContainerPipe=Vo,d.GlProgram=vt,d.GlProgramData=Vb,d.GlRenderTarget=Mb,d.GlRenderTargetAdaptor=Db,d.GlRenderTargetSystem=Xl,d.GlShaderSystem=Wl,d.GlStateSystem=ov,d.GlStencilSystem=Il,d.GlTexture=av,d.GlTextureSystem=Ql,d.GlUboSystem=$l,d.GlUniformGroupSystem=Yl,d.GlobalResourceRegistry=me,d.GlobalUniformSystem=pu,d.GpuBatchAdaptor=vl,d.GpuBlendModesToPixi=ft,d.GpuBufferSystem=xu,d.GpuColorMaskSystem=Tu,d.GpuDeviceSystem=on,d.GpuEncoderSystem=Su,d.GpuGraphicsAdaptor=Fu,d.GpuGraphicsContext=Rp,d.GpuLimitsSystem=Au,d.GpuMeshAdapter=Du,d.GpuMipmapGenerator=cy,d.GpuParticleContainerAdaptor=kp,d.GpuParticleContainerPipe=Wo,d.GpuProgram=dt,d.GpuRenderTarget=oy,d.GpuRenderTargetAdaptor=ay,d.GpuRenderTargetSystem=Mu,d.GpuShaderSystem=Cu,d.GpuStateSystem=Ou,d.GpuStencilModesToPixi=ne,d.GpuStencilSystem=Eu,d.GpuTextureSystem=Iu,d.GpuUboSystem=Pu,d.GpuUniformBatchPipe=wu,d.Graphics=or,d.GraphicsContext=pt,d.GraphicsContextRenderData=Mp,d.GraphicsContextSystem=ss,d.GraphicsGpuData=Cp,d.GraphicsPath=Lt,d.GraphicsPipe=Lo,d.HTMLText=db,d.HTMLTextPipe=va,d.HTMLTextRenderData=ya,d.HTMLTextStyle=Vs,d.HTMLTextSystem=Ta,d.HelloSystem=nn,d.IGLUniformData=Aw,d.ImageSource=ae,d.InstructionSet=Bn,d.KTX=it,d.Loader=og,d.LoaderParserPriority=Et,d.MaskEffectManager=Si,d.MaskEffectManagerClass=Eh,d.MaskFilter=$_,d.Matrix=M,d.Mesh=fr,d.MeshGeometry=ue,d.MeshGpuData=No,d.MeshPipe=Xo,d.MeshPlane=AM,d.MeshRope=BM,d.MeshSimple=LM,d.NOOP=Dn,d.NineSliceGeometry=he,d.NineSlicePlane=eC,d.NineSliceSprite=ax,d.NineSliceSpriteGpuData=Pm,d.NineSliceSpritePipe=Pa,d.NoiseFilter=yP,d.ObservablePoint=Z,d.PI_2=_h,d.Particle=zM,d.ParticleBuffer=Ip,d.ParticleContainer=ZM,d.ParticleContainerPipe=zo,d.ParticleShader=Up,d.PassthroughFilter=Gm,d.PerspectiveMesh=_M,d.PerspectivePlaneGeometry=Ry,d.PipelineSystem=Ru,d.PlaneGeometry=ys,d.Point=W,d.Polygon=rr,d.Pool=yh,d.PoolGroupClass=xh,d.PrepareBase=N_,d.PrepareQueue=ib,d.PrepareSystem=fb,d.PrepareUpload=pb,d.QuadGeometry=pm,d.RAD_TO_DEG=bh,d.Rectangle=z,d.RenderContainer=QR,d.RenderGroup=Mi,d.RenderGroupPipe=ru,d.RenderGroupSystem=nu,d.RenderLayer=oM,d.RenderTarget=qs,d.RenderTargetSystem=Nl,d.RenderTexture=sn,d.RenderableGCSystem=kv,d.RendererInitHook=La,d.RendererType=yt,d.ResizePlugin=Vn,d.Resolver=oe,d.RopeGeometry=Ly,d.RoundedRectangle=hs,d.SCALE_MODES=zR,d.STENCIL_MODES=rt,d.SVGParser=nf,d.SchedulerSystem=fu,d.ScissorMask=ZP,d.SdfShader=Bf,d.Shader=Pt,d.ShaderStage=We,d.ShapePath=Kp,d.SharedRenderPipes=vu,d.SharedSystems=bu,d.SplitBitmapText=cC,d.SplitText=yC,d.Sprite=$t,d.SpritePipe=ou,d.Spritesheet=Zn,d.State=wt,d.StencilMask=eo,d.StencilMaskPipe=Al,d.SystemRunner=Da,d.TEXTURE_FORMAT_BLOCK_SIZE=$g,d.Text=zs,d.TextStyle=Mt,d.Texture=w,d.TextureGCSystem=Xv,d.TextureMatrix=Un,d.TexturePool=et,d.TexturePoolClass=rc,d.TextureSource=Q,d.TextureStyle=At,d.TextureUvs=VR,d.Ticker=at,d.TickerListener=Gi,d.TickerPlugin=Wn,d.TilingSprite=J_,d.TilingSpriteGpuData=_m,d.TilingSpritePipe=Ea,d.TilingSpriteShader=dm,d.Transform=Y_,d.Triangle=Oa,d.UNIFORM_TO_ARRAY_SETTERS=rv,d.UNIFORM_TO_SINGLE_SETTERS=ev,d.UNIFORM_TYPES_MAP=jd,d.UNIFORM_TYPES_VALUES=xo,d.UPDATE_BLEND=Oi,d.UPDATE_COLOR=Ar,d.UPDATE_PRIORITY=zt,d.UPDATE_TRANSFORM=nT,d.UPDATE_VISIBLE=$e,d.UboBatch=Zv,d.UboSystem=Fl,d.UniformGroup=nt,d.VERSION=ti,d.VideoSource=Xe,d.ViewContainer=Wt,d.ViewSystem=Vv,d.ViewableBuffer=Se,d.WGSL_ALIGN_SIZE_DATA=di,d.WGSL_TO_STD40_SIZE=Dl,d.WRAP_MODES=jR,d.WebGLRenderer=qv,d.WebGPURenderer=my,d.WorkerManager=Wa,d.accessibilityTarget=Ec,d.addBits=fo,d.addMaskBounds=Ui,d.addMaskLocalBounds=ki,d.addProgramDefines=md,d.alphaFrag=s_,d.alphaWgsl=ll,d.appendSVGPath=aa,d.applyMatrix=mm,d.applyProjectiveTransformationToPlane=Sy,d.applyStyleParams=Zl,d.assignWithIgnore=Ci,d.autoDetectEnvironment=k2,d.autoDetectRenderer=Nm,d.autoDetectSource=KT,d.basisTranscoderUrls=Ms,d.bgr2rgb=ke,d.bitmapFontCachePlugin=Vm,d.bitmapFontTextParser=Ss,d.bitmapFontXMLParser=Xa,d.bitmapFontXMLStringParser=Ha,d.bitmapTextSplit=lx,d.blendTemplateFrag=Zg,d.blendTemplateVert=Qg,d.blendTemplateWgsl=Jg,d.blockDataMap=Gu,d.blurTemplateWgsl=d_,d.boundsPool=jt,d.browserExt=OE,d.buildAdaptiveBezier=Zo,d.buildAdaptiveQuadratic=Hp,d.buildArc=ta,d.buildArcTo=jp,d.buildArcToSvg=Vp,d.buildCircle=Qe,d.buildContextBatches=Pp,d.buildEllipse=ip,d.buildGeometryFromPath=rM,d.buildLine=ap,d.buildPixelLine=lp,d.buildPolygon=gp,d.buildRectangle=_p,d.buildRoundedRectangle=sp,d.buildSimpleUvs=Ao,d.buildTriangle=bp,d.buildUvs=So,d.cacheAsTextureMixin=Th,d.cacheTextureArray=Km,d.calculatePathArea=ef,d.calculateProjection=Ub,d.canvasTextSplit=fx,d.checkChildrenDidChange=Gn,d.checkDataUrl=Ce,d.checkExtension=Dt,d.checkForNestedPattern=Jp,d.checkMaxIfStatementsInShader=uo,d.childrenHelperMixin=Sh,d.cleanArray=Iv,d.cleanHash=Bv,d.clearList=rn,d.closePointEps=Eo,d.collectAllRenderables=JR,d.collectRenderablesMixin=Ah,d.color32BitToUniform=er,d.colorBit=zi,d.colorBitGl=Vi,d.colorMatrixFilterFrag=x_,d.colorMatrixFilterWgsl=dl,d.colorToUniform=hS,d.compareModeToGlCompare=dv,d.compileHighShader=Gd,d.compileHighShaderGl=Bd,d.compileHighShaderGlProgram=Ke,d.compileHighShaderGpuProgram=Ye,d.compileHooks=mo,d.compileInputs=go,d.compileOutputs=Od,d.compileShader=Hl,d.compute2DProjection=wy,d.convertFormatIfRequired=yE,d.convertToList=Ft,d.copySearchParams=Fi,d.createIdFromString=Ve,d.createIndicesForQuads=Ho,d.createLevelBuffers=JA,d.createLevelBuffersFromKTX=xE,d.createStringVariations=Dc,d.createTexture=ce,d.createUboElementsSTD40=Cb,d.createUboElementsWGSL=ey,d.createUboSyncFunction=Ul,d.createUboSyncFunctionSTD40=Fb,d.createUboSyncFunctionWGSL=iy,d.crossOrigin=Eg,d.cullingMixin=gh,d.curveEps=Po,d.defaultFilterVert=Yr,d.defaultValue=zl,d.definedProps=Ut,d.deprecation=Mr,d.detectAvif=qm,d.detectBasis=YA,d.detectCompressed=RE,d.detectDefaults=Qm,d.detectMp4=Jm,d.detectOgv=tg,d.detectVideoAlphaMode=io,d.detectWebm=eg,d.detectWebp=rg,d.determineCrossOrigin=wg,d.displacementFrag=A_,d.displacementVert=E_,d.displacementWgsl=pl,d.earcut=mp,d.effectsMixin=Mh,d.ensureAttributes=wl,d.ensureIsBuffer=ho,d.ensurePrecision=gd,d.ensureTextOptions=js,d.executeInstructions=en,d.extensions=F,d.extractAttributesFromGlProgram=Kb,d.extractAttributesFromGpuProgram=Ed,d.extractFontFamilies=Wf,d.extractStructAndGroups=ji,d.extractSubpaths=tf,d.extractSvgUrlId=sa,d.fastCopy=Ni,d.findMixin=Ch,d.fontStringFromTextStyle=Vr,d.formatShader=YP,d.fragmentGPUTemplate=Ud,d.fragmentGlTemplate=$d,d.generateArraySyncSTD40=Ib,d.generateArraySyncWGSL=ry,d.generateBlurFragSource=u_,d.generateBlurGlProgram=c_,d.generateBlurProgram=p_,d.generateBlurVertSource=h_,d.generateGPULayout=VP,d.generateGpuLayoutGroups=Pd,d.generateLayout=WP,d.generateLayoutHash=wd,d.generateParticleUpdateFunction=Gp,d.generateProgram=tv,d.generateShaderSyncCode=zb,d.generateTextStyleKey=xC,d.generateTextureBatchBit=Wi,d.generateTextureBatchBitGl=Yi,d.generateTextureMatrix=Ep,d.generateUniformsSync=iv,d.getAdjustedBlendModeBlend=je,d.getAttributeInfoFromFormat=ie,d.getBatchSamplersUniformGroup=Ki,d.getBitmapTextLayout=ms,d.getCanvasBoundingBox=Tf,d.getCanvasFillStyle=Wr,d.getCanvasTexture=Ll,d.getDefaultUniformValue=zd,d.getFastGlobalBounds=YR,d.getFastGlobalBoundsMixin=Gh,d.getFillInstructionData=BS,d.getFontCss=qf,d.getFontFamilyName=cg,d.getGeometryBounds=cd,d.getGlTypeFromFormat=Ab,d.getGlobalBounds=Tr,d.getGlobalMixin=Fh,d.getGlobalRenderableBounds=Im,d.getLocalBounds=Pi,d.getMaxFragmentPrecision=fd,d.getMaxTexturesPerBatch=ed,d.getOrientationOfPoints=np,d.getPo2TextureFromSource=ha,d.getResolutionOfUrl=As,d.getSVGUrl=Zf,d.getSupportedCompressedTextureFormats=rl,d.getSupportedGPUCompressedTextureFormats=tl,d.getSupportedGlCompressedTextureFormats=Ja,d.getSupportedTextureFormats=si,d.getTemporaryCanvasFromImage=Qf,d.getTestContext=lo,d.getTextureBatchBindGroup=Li,d.getTextureDefaultMatrix=NM,d.getTextureFormatFromKTXTexture=AE,d.getUboData=qb,d.getUniformData=Zb,d.getUrlExtension=Lc,d.glFormatToGPUFormat=Wg,d.glUploadBufferImageResource=lv,d.glUploadCompressedTextureResource=uv,d.glUploadImageResource=Kl,d.glUploadVideoResource=hv,d.globalUniformsBit=Ld,d.globalUniformsBitGl=Nd,d.globalUniformsUBOBitGl=_1,d.gpuFormatToBasisTranscoderFormat=eE,d.gpuFormatToKTXBasisTranscoderFormat=PE,d.gpuUploadBufferImageResource=ly,d.gpuUploadCompressedTextureResource=uy,d.gpuUploadImageResource=Bu,d.gpuUploadVideoResource=hy,d.groupD8=N,d.hasCachedCanvasTexture=yw,d.hslWgsl=wP,d.hslgl=DE,d.hslgpu=UE,d.injectBits=_o,d.insertVersion=_d,d.isMobile=_c,d.isPow2=In,d.isRenderingToScreen=Lb,d.isSafari=jf,d.isSingleItem=Rr,d.isWebGLSupported=Zr,d.isWebGPUSupported=Qr,d.ktxTranscoderUrls=Cs,d.loadBasis=QA,d.loadBasisOnWorker=kg,d.loadBitmapFont=Wm,d.loadDDS=lE,d.loadEnvironmentExtensions=Ia,d.loadFontAsBase64=Yf,d.loadFontCSS=Kf,d.loadImageBitmap=xg,d.loadJson=ag,d.loadKTX=mE,d.loadKTX2=vE,d.loadKTX2onWorker=zg,d.loadSVGImage=Jf,d.loadSvg=gg,d.loadTextures=Ya,d.loadTxt=lg,d.loadVideoTextures=Rg,d.loadWebFont=dg,d.localUniformBit=lr,d.localUniformBitGl=bs,d.localUniformBitGroup2=um,d.localUniformMSDFBit=Mf,d.localUniformMSDFBitGl=Cf,d.log2=F0,d.logDebugTexture=EC,d.logProgramError=Jb,d.logRenderGroupScene=Ax,d.logScene=Sx,d.mSDFBit=Of,d.mSDFBitGl=Gf,d.mapFormatToGlFormat=pv,d.mapFormatToGlInternalFormat=gv,d.mapFormatToGlType=_v,d.mapGlToVertexFormat=Yb,d.mapSize=Rw,d.mapType=Vl,d.mapWebGLBlendModesToPixi=sv,d.maskFrag=I_,d.maskVert=F_,d.maskWgsl=gl,d.matrixPool=ht,d.measureHtmlText=xa,d.measureMixin=Uh,d.migrateFragmentFromV7toV8=Pw,d.mipmapScaleModeToGlFilter=cv,d.multiplyColors=Sr,d.multiplyHexColors=On,d.nextPow2=ge,d.noiseFrag=M_,d.noiseWgsl=fl,d.nonCompressedFormats=Fg,d.normalizeExtensionPriority=br,d.onRenderMixin=kh,d.parseDDS=Lg,d.parseFunctionBody=WR,d.parseKTX=Xg,d.parseSVGDefinitions=Zp,d.parseSVGFloatAttribute=tt,d.parseSVGPath=Np,d.parseSVGStyle=oa,d.particleData=Nu,d.particlesFrag=Fp,d.particlesVert=Dp,d.particlesWgsl=jo,d.passthroughFrag=Om,d.passthroughWgsl=Ma,d.path=_t,d.pointInTriangle=Ca,d.preloadVideo=Pg,d.removeItems=Cn,d.removeStructAndGroupDuplicates=Rd,d.resetUids=R0,d.resolveCharacters=kf,d.resolveCompressedTextureUrl=wE,d.resolveJsonUrl=Mg,d.resolveTextureUrl=Qa,d.resourceToTexture=qc,d.roundPixelsBit=qe,d.roundPixelsBitGl=Ze,d.roundedShapeArc=Wp,d.roundedShapeQuadraticCurve=Yp,d.sayHello=Gv,d.scaleModeToGlFilter=ql,d.setBasisTranscoderPath=qA,d.setKTXTranscoderPath=_E,d.setPositions=fm,d.setProgramName=bd,d.setUvs=gm,d.shapeBuilders=tr,d.sortMixin=$h,d.spritesheetAsset=Hc,d.squaredDistanceToLineSegment=Xr,d.stripVersion=vd,d.styleAttributes=na,d.testImageFormat=ja,d.testVideoFormat=ei,d.textStyleToCSS=sb,d.textureBit=mb,d.textureBitGl=gb,d.textureFrom=Zc,d.tilingBit=hm,d.tilingBitGl=cm,d.toFillStyle=le,d.toLocalGlobalMixin=Lh,d.toStrokeStyle=zr,d.transformVertices=Qi,d.triangulateWithHoles=Co,d.uboSyncFunctionsSTD40=kl,d.uboSyncFunctionsWGSL=Bb,d.uid=Y,d.uniformParsers=de,d.unpremultiplyAlpha=Xw,d.unsafeEvalSupported=Fa,d.updateLocalTransform=tM,d.updateQuadBounds=Qn,d.updateRenderGroupTransform=vv,d.updateRenderGroupTransforms=iu,d.updateTextBounds=os,d.updateTransformAndChildren=su,d.updateTransformBackwards=Ei,d.updateWorldTransform=eM,d.v8_0_0=ao,d.v8_3_4=ZT,d.validFormats=Os,d.validateRenderables=xv,d.vertexGPUTemplate=Dd,d.vertexGlTemplate=kd,d.vkFormatToGPUFormat=Yg,d.warn=Zt,d.wrapModeToGlAddress=tn,d}({});
|
|
//# sourceMappingURL=pixi.min.js.map
|