dsh-pet-live2d 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +56 -0
  2. package/README.md +425 -0
  3. package/cordis.patch.yml +8 -0
  4. package/docs/README.md +14 -0
  5. package/docs/downscale-fix.png +0 -0
  6. package/docs/preview.png +0 -0
  7. package/lib/client.js +3525 -0
  8. package/lib/index.js +1027 -0
  9. package/lib/live2d-vendor.js +997 -0
  10. package/package.json +61 -0
  11. package/pets/ds-whale-girl/LICENSE +37 -0
  12. package/pets/ds-whale-girl/README.md +67 -0
  13. package/pets/ds-whale-girl/c_0120.model3.json +249 -0
  14. package/pets/ds-whale-girl/catalog.json +310 -0
  15. package/pets/ds-whale-girl/expressions/angry.exp3.json +55 -0
  16. package/pets/ds-whale-girl/expressions/blank-eyes.exp3.json +10 -0
  17. package/pets/ds-whale-girl/expressions/cat-paws.exp3.json +20 -0
  18. package/pets/ds-whale-girl/expressions/claw-recolor.exp3.json +10 -0
  19. package/pets/ds-whale-girl/expressions/claw.exp3.json +10 -0
  20. package/pets/ds-whale-girl/expressions/cry.exp3.json +60 -0
  21. package/pets/ds-whale-girl/expressions/dark-tablecloth.exp3.json +11 -0
  22. package/pets/ds-whale-girl/expressions/dizzy.exp3.json +40 -0
  23. package/pets/ds-whale-girl/expressions/draw-brush.exp3.json +10 -0
  24. package/pets/ds-whale-girl/expressions/draw-eraser.exp3.json +10 -0
  25. package/pets/ds-whale-girl/expressions/draw-undo.exp3.json +10 -0
  26. package/pets/ds-whale-girl/expressions/drool.exp3.json +10 -0
  27. package/pets/ds-whale-girl/expressions/excited.exp3.json +65 -0
  28. package/pets/ds-whale-girl/expressions/exclaim.exp3.json +10 -0
  29. package/pets/ds-whale-girl/expressions/facial-red.exp3.json +10 -0
  30. package/pets/ds-whale-girl/expressions/glasses-oval.exp3.json +10 -0
  31. package/pets/ds-whale-girl/expressions/glasses-round.exp3.json +10 -0
  32. package/pets/ds-whale-girl/expressions/glasses-square.exp3.json +10 -0
  33. package/pets/ds-whale-girl/expressions/gloomy.exp3.json +10 -0
  34. package/pets/ds-whale-girl/expressions/hands-peace.exp3.json +10 -0
  35. package/pets/ds-whale-girl/expressions/headband.exp3.json +11 -0
  36. package/pets/ds-whale-girl/expressions/heart-pop.exp3.json +10 -0
  37. package/pets/ds-whale-girl/expressions/heartbeat.exp3.json +10 -0
  38. package/pets/ds-whale-girl/expressions/ketchup-squeeze.exp3.json +10 -0
  39. package/pets/ds-whale-girl/expressions/love-eyes.exp3.json +60 -0
  40. package/pets/ds-whale-girl/expressions/menu-press.exp3.json +10 -0
  41. package/pets/ds-whale-girl/expressions/naughty.exp3.json +20 -0
  42. package/pets/ds-whale-girl/expressions/omurice.exp3.json +16 -0
  43. package/pets/ds-whale-girl/expressions/parfait.exp3.json +10 -0
  44. package/pets/ds-whale-girl/expressions/phone-recolor.exp3.json +10 -0
  45. package/pets/ds-whale-girl/expressions/ponytail.exp3.json +11 -0
  46. package/pets/ds-whale-girl/expressions/question.exp3.json +10 -0
  47. package/pets/ds-whale-girl/expressions/sad.exp3.json +35 -0
  48. package/pets/ds-whale-girl/expressions/soul-out.exp3.json +10 -0
  49. package/pets/ds-whale-girl/expressions/sparkle.exp3.json +10 -0
  50. package/pets/ds-whale-girl/expressions/star-eyes.exp3.json +10 -0
  51. package/pets/ds-whale-girl/expressions/sticker-bow.exp3.json +10 -0
  52. package/pets/ds-whale-girl/expressions/sticker-cat.exp3.json +10 -0
  53. package/pets/ds-whale-girl/expressions/sticker-rabbit.exp3.json +10 -0
  54. package/pets/ds-whale-girl/expressions/sunglasses.exp3.json +20 -0
  55. package/pets/ds-whale-girl/expressions/sweat.exp3.json +10 -0
  56. package/pets/ds-whale-girl/expressions/tongue-out.exp3.json +26 -0
  57. package/pets/ds-whale-girl/expressions/whale-on-desk.exp3.json +11 -0
  58. package/pets/ds-whale-girl/expressions/whale.exp3.json +11 -0
  59. package/pets/ds-whale-girl/model/c_0120.cdi3.json +1802 -0
  60. package/pets/ds-whale-girl/model/c_0120.moc3 +0 -0
  61. package/pets/ds-whale-girl/model/c_0120.physics3.json +2396 -0
  62. package/pets/ds-whale-girl/motions/bubble-gum.motion3.json +369 -0
  63. package/pets/ds-whale-girl/motions/hammer.motion3.json +1120 -0
  64. package/pets/ds-whale-girl/motions/idle.motion3.json +4746 -0
  65. package/pets/ds-whale-girl/motions/ketchup.motion3.json +768 -0
  66. package/pets/ds-whale-girl/motions/open-case.motion3.json +116 -0
  67. package/pets/ds-whale-girl/motions/selfie-quick.motion3.json +47 -0
  68. package/pets/ds-whale-girl/motions/selfie.motion3.json +671 -0
  69. package/pets/ds-whale-girl/motions/spray-water.motion3.json +31 -0
  70. package/pets/ds-whale-girl/pet.json +599 -0
  71. package/pets/ds-whale-girl/previews/idle.png +0 -0
  72. package/pets/ds-whale-girl/textures/texture_00.png +0 -0
  73. package/pets/ds-whale-girl/textures/texture_01.png +0 -0
  74. package/pets/ds-whale-girl/voice.json +46 -0
  75. package/pets/ds-whale-girl//345/256/211/350/243/205/350/257/264/346/230/216.md +30 -0
  76. package/src/vendor-entry.ts +28 -0
@@ -0,0 +1,997 @@
1
+ (()=>{var NE=Object.create;var Ic=Object.defineProperty;var HE=Object.getOwnPropertyDescriptor;var zE=Object.getOwnPropertyNames;var WE=Object.getPrototypeOf,XE=Object.prototype.hasOwnProperty;var p=(s,t)=>()=>(s&&(t=s(s=0)),t);var jE=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Mr=(s,t)=>{for(var e in t)Ic(s,e,{get:t[e],enumerable:!0})},YE=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of zE(t))!XE.call(s,i)&&i!==e&&Ic(s,i,{get:()=>t[i],enumerable:!(r=HE(t,i))||r.enumerable});return s};var $E=(s,t,e)=>(e=s!=null?NE(WE(s)):{},YE(t||!s||!s.__esModule?Ic(e,"default",{value:s,enumerable:!0}):e,s));var y,Fc,Dn,U,A=p(()=>{"use strict";y=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.TextureUploaderWebGL="texture-uploader-webgl",s.TextureUploaderWebGPU="texture-uploader-webgpu",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(y||{}),Fc=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Dn=(s,t)=>Fc(s).priority??t,U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Fc).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...s){return s.map(Fc).forEach(t=>{t.type.forEach(e=>{let r=this._addHandlers,i=this._queue;r[e]?r[e]?.(t):(i[e]=i[e]||[],i[e]?.push(t))})}),this},handle(s,t,e){let r=this._addHandlers,i=this._removeHandlers;if(r[s]||i[s])throw new Error(`Extension type ${s} already has a handler`);r[s]=t,i[s]=e;let n=this._queue;return n[s]&&(n[s]?.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,r=>{t.findIndex(n=>n.name===r.name)>=0||(t.push({name:r.name,value:r.ref}),t.sort((n,o)=>Dn(o.value,e)-Dn(n.value,e)))},r=>{let i=t.findIndex(n=>n.name===r.name);i!==-1&&t.splice(i,1)})},handleByList(s,t,e=-1){return this.handle(s,r=>{t.includes(r.ref)||(t.push(r.ref),t.sort((i,n)=>Dn(n,e)-Dn(i,e)))},r=>{let i=t.indexOf(r.ref);i!==-1&&t.splice(i,1)})},mixin(s,...t){for(let e of t)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(e))}}});var Fg=jE((Lk,kc)=>{"use strict";var qE=Object.prototype.hasOwnProperty,ue="~";function On(){}Object.create&&(On.prototype=Object.create(null),new On().__proto__||(ue=!1));function KE(s,t,e){this.fn=s,this.context=t,this.once=e||!1}function Ig(s,t,e,r,i){if(typeof e!="function")throw new TypeError("The listener must be a function");var n=new KE(e,r||s,i),o=ue?ue+t:t;return s._events[o]?s._events[o].fn?s._events[o]=[s._events[o],n]:s._events[o].push(n):(s._events[o]=n,s._eventsCount++),s}function il(s,t){--s._eventsCount===0?s._events=new On:delete s._events[t]}function re(){this._events=new On,this._eventsCount=0}re.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)qE.call(e,r)&&t.push(ue?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};re.prototype.listeners=function(t){var e=ue?ue+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,n=r.length,o=new Array(n);i<n;i++)o[i]=r[i].fn;return o};re.prototype.listenerCount=function(t){var e=ue?ue+t:t,r=this._events[e];return r?r.fn?1:r.length:0};re.prototype.emit=function(t,e,r,i,n,o){var a=ue?ue+t:t;if(!this._events[a])return!1;var l=this._events[a],h=arguments.length,u,c;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,i),!0;case 5:return l.fn.call(l.context,e,r,i,n),!0;case 6:return l.fn.call(l.context,e,r,i,n,o),!0}for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var f=l.length,d;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),h){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,r);break;case 4:l[c].fn.call(l[c].context,e,r,i);break;default:if(!u)for(d=1,u=new Array(h-1);d<h;d++)u[d-1]=arguments[d];l[c].fn.apply(l[c].context,u)}}return!0};re.prototype.on=function(t,e,r){return Ig(this,t,e,r,!1)};re.prototype.once=function(t,e,r){return Ig(this,t,e,r,!0)};re.prototype.removeListener=function(t,e,r,i){var n=ue?ue+t:t;if(!this._events[n])return this;if(!e)return il(this,n),this;var o=this._events[n];if(o.fn)o.fn===e&&(!i||o.once)&&(!r||o.context===r)&&il(this,n);else{for(var a=0,l=[],h=o.length;a<h;a++)(o[a].fn!==e||i&&!o[a].once||r&&o[a].context!==r)&&l.push(o[a]);l.length?this._events[n]=l.length===1?l[0]:l:il(this,n)}return this};re.prototype.removeAllListeners=function(t){var e;return t?(e=ue?ue+t:t,this._events[e]&&il(this,e)):(this._events=new On,this._eventsCount=0),this};re.prototype.off=re.prototype.removeListener;re.prototype.addListener=re.prototype.on;re.prefixed=ue;re.EventEmitter=re;typeof kc<"u"&&(kc.exports=re)});var kg,q,Qt=p(()=>{kg=$E(Fg(),1),q=kg.default});var ZE,wr,Yt,Fe,Hg,Lg,Lc,JE,nl,zg,Wg,Dg,Og,Gg,Gn,QE,tA,eA,rA,Gc,Ug,sA,Dc,Oc,Vg,Uc,qe,Ng,Xg,jg=p(()=>{ZE={grad:.9,turn:360,rad:360/(2*Math.PI)},wr=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},Yt=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},Fe=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Hg=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Lg=function(s){return{r:Fe(s.r,0,255),g:Fe(s.g,0,255),b:Fe(s.b,0,255),a:Fe(s.a)}},Lc=function(s){return{r:Yt(s.r),g:Yt(s.g),b:Yt(s.b),a:Yt(s.a,3)}},JE=/^#([0-9a-f]{3,8})$/i,nl=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},zg=function(s){var t=s.r,e=s.g,r=s.b,i=s.a,n=Math.max(t,e,r),o=n-Math.min(t,e,r),a=o?n===t?(e-r)/o:n===e?2+(r-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},Wg=function(s){var t=s.h,e=s.s,r=s.v,i=s.a;t=t/360*6,e/=100,r/=100;var n=Math.floor(t),o=r*(1-e),a=r*(1-(t-n)*e),l=r*(1-(1-t+n)*e),h=n%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:i}},Dg=function(s){return{h:Hg(s.h),s:Fe(s.s,0,100),l:Fe(s.l,0,100),a:Fe(s.a)}},Og=function(s){return{h:Yt(s.h),s:Yt(s.s),l:Yt(s.l),a:Yt(s.a,3)}},Gg=function(s){return Wg((e=(t=s).s,{h:t.h,s:(e*=((r=t.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:t.a}));var t,e,r},Gn=function(s){return{h:(t=zg(s)).h,s:(i=(200-(e=t.s))*(r=t.v)/100)>0&&i<200?e*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,r,i},QE=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tA=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,eA=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rA=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gc={string:[[function(s){var t=JE.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?Yt(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?Yt(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=eA.exec(s)||rA.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Lg({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(s){var t=QE.exec(s)||tA.exec(s);if(!t)return null;var e,r,i=Dg({h:(e=t[1],r=t[2],r===void 0&&(r="deg"),Number(e)*(ZE[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Gg(i)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,r=s.b,i=s.a,n=i===void 0?1:i;return wr(t)&&wr(e)&&wr(r)?Lg({r:Number(t),g:Number(e),b:Number(r),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,r=s.l,i=s.a,n=i===void 0?1:i;if(!wr(t)||!wr(e)||!wr(r))return null;var o=Dg({h:Number(t),s:Number(e),l:Number(r),a:Number(n)});return Gg(o)},"hsl"],[function(s){var t=s.h,e=s.s,r=s.v,i=s.a,n=i===void 0?1:i;if(!wr(t)||!wr(e)||!wr(r))return null;var o=(function(a){return{h:Hg(a.h),s:Fe(a.s,0,100),v:Fe(a.v,0,100),a:Fe(a.a)}})({h:Number(t),s:Number(e),v:Number(r),a:Number(n)});return Wg(o)},"hsv"]]},Ug=function(s,t){for(var e=0;e<t.length;e++){var r=t[e][0](s);if(r)return[r,t[e][1]]}return[null,void 0]},sA=function(s){return typeof s=="string"?Ug(s.trim(),Gc.string):typeof s=="object"&&s!==null?Ug(s,Gc.object):[null,void 0]},Dc=function(s,t){var e=Gn(s);return{h:e.h,s:Fe(e.s+100*t,0,100),l:e.l,a:e.a}},Oc=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},Vg=function(s,t){var e=Gn(s);return{h:e.h,s:e.s,l:Fe(e.l+100*t,0,100),a:e.a}},Uc=(function(){function s(t){this.parsed=sA(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return Yt(Oc(this.rgba),2)},s.prototype.isDark=function(){return Oc(this.rgba)<.5},s.prototype.isLight=function(){return Oc(this.rgba)>=.5},s.prototype.toHex=function(){return t=Lc(this.rgba),e=t.r,r=t.g,i=t.b,o=(n=t.a)<1?nl(Yt(255*n)):"","#"+nl(e)+nl(r)+nl(i)+o;var t,e,r,i,n,o},s.prototype.toRgb=function(){return Lc(this.rgba)},s.prototype.toRgbString=function(){return t=Lc(this.rgba),e=t.r,r=t.g,i=t.b,(n=t.a)<1?"rgba("+e+", "+r+", "+i+", "+n+")":"rgb("+e+", "+r+", "+i+")";var t,e,r,i,n},s.prototype.toHsl=function(){return Og(Gn(this.rgba))},s.prototype.toHslString=function(){return t=Og(Gn(this.rgba)),e=t.h,r=t.s,i=t.l,(n=t.a)<1?"hsla("+e+", "+r+"%, "+i+"%, "+n+")":"hsl("+e+", "+r+"%, "+i+"%)";var t,e,r,i,n},s.prototype.toHsv=function(){return t=zg(this.rgba),{h:Yt(t.h),s:Yt(t.s),v:Yt(t.v),a:Yt(t.a,3)};var t},s.prototype.invert=function(){return qe({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),qe(Dc(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),qe(Dc(this.rgba,-t))},s.prototype.grayscale=function(){return qe(Dc(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),qe(Vg(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),qe(Vg(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?qe({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Yt(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=Gn(this.rgba);return typeof t=="number"?qe({h:t,s:e.s,l:e.l,a:e.a}):Yt(e.h)},s.prototype.isEqual=function(t){return this.toHex()===qe(t).toHex()},s})(),qe=function(s){return s instanceof Uc?s:new Uc(s)},Ng=[],Xg=function(s){s.forEach(function(t){Ng.indexOf(t)<0&&(t(Uc,Gc),Ng.push(t))})}});function Yg(s,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"},r={};for(var i in e)r[e[i]]=i;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=r[this.toHex()];if(h)return h;if(o?.closest){var u=this.toRgb(),c=1/0,f="black";if(!n.length)for(var d in e)n[d]=new s(e[d]).toRgb();for(var m in e){var g=(a=u,l=n[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<c&&(c=g,f=m)}return f}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new s(l).toRgb():null},"name"])}var $g=p(()=>{});var hi,Z,se=p(()=>{jg();$g();Xg([Yg]);hi=class Un{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 Un)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?{...t}:t}_isSourceEqual(t,e){let r=typeof t;if(r!==typeof e)return!1;if(r==="number"||r==="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((n,o)=>n===e[o]);if(t!==null&&e!==null){let n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){let[t,e,r,i]=this._components;return{r:t,g:e,b:r,a:i}}toRgb(){let[t,e,r]=this._components;return{r:t,g:e,b:r}}toRgbaString(){let[t,e,r]=this.toUint8RgbArray();return`rgba(${t},${e},${r},${this.alpha})`}toUint8RgbArray(t){let[e,r,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(r*255),t[2]=Math.round(i*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);let[e,r,i,n]=this._components;return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);let[e,r,i]=this._components;return t[0]=e,t[1]=r,t[2]=i,t}toNumber(){return this._int}toBgrNumber(){let[t,e,r]=this.toUint8RgbArray();return(r<<16)+(e<<8)+t}toLittleEndianNumber(){let t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){let[e,r,i,n]=Un._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=r,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let r=this._int>>16&255,i=this._int>>8&255,n=this._int&255;return e&&(r=r*t+.5|0,i=i*t+.5|0,n=n*t+.5|0),(t*255<<24)+(r<<16)+(i<<8)+n}toHex(){let t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){let e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,r,i,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){let o=t;e=(o>>16&255)/255,r=(o>>8&255)/255,i=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,r,i,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,r,i,n=255]=t,e/=255,r/=255,i/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){let a=Un.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}let o=qe(t);o.isValid()&&({r:e,g:r,b:i,a:n}=o.rgba,e/=255,r/=255,i/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=r,this._components[2]=i,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[t,e,r]=this._components;this._int=(t*255<<16)+(e*255<<8)+(r*255|0)}_clamp(t,e=0,r=1){return typeof t=="number"?Math.min(Math.max(t,e),r):(t.forEach((i,n)=>{t[n]=Math.min(Math.max(i,e),r)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Un||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}};hi.shared=new hi;hi._temp=new hi;hi.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;Z=hi});var qg,Kg=p(()=>{"use strict";qg={cullArea:null,cullable:!1,cullableChildren:!0}});var Zg,Jg,Qg,Vc=p(()=>{"use strict";Zg=Math.PI*2,Jg=180/Math.PI,Qg=Math.PI/180});var et,Nc,ke=p(()=>{"use strict";et=class s{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new s(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}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Nc.x=0,Nc.y=0,Nc}},Nc=new et});var R,iA,nA,nt=p(()=>{Vc();ke();R=class s{constructor(t=1,e=0,r=0,i=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=r,this.d=i,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,r,i,n,o){return this.a=t,this.b=e,this.c=r,this.d=i,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));let r=e||this.array;return t?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(t,e){e=e||new et;let r=t.x,i=t.y;return e.x=this.a*r+this.c*i+this.tx,e.y=this.b*r+this.d*i+this.ty,e}applyInverse(t,e){e=e||new et;let r=this.a,i=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(r*o+n*-i),u=t.x,c=t.y;return e.x=o*h*u+-n*h*c+(l*n-a*o)*h,e.y=r*h*c+-i*h*u+(-l*r+a*i)*h,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){let e=Math.cos(t),r=Math.sin(t),i=this.a,n=this.c,o=this.tx;return this.a=i*e-this.b*r,this.b=i*r+this.b*e,this.c=n*e-this.d*r,this.d=n*r+this.d*e,this.tx=o*e-this.ty*r,this.ty=o*r+this.ty*e,this}append(t){let e=this.a,r=this.b,i=this.c,n=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*r+t.b*n,this.c=t.c*e+t.d*i,this.d=t.c*r+t.d*n,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*r+t.ty*n+this.ty,this}appendFrom(t,e){let r=t.a,i=t.b,n=t.c,o=t.d,a=t.tx,l=t.ty,h=e.a,u=e.b,c=e.c,f=e.d;return this.a=r*h+i*c,this.b=r*u+i*f,this.c=n*h+o*c,this.d=n*u+o*f,this.tx=a*h+l*c+e.tx,this.ty=a*u+l*f+e.ty,this}setTransform(t,e,r,i,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(r*this.a+i*this.c),this.ty=e-(r*this.b+i*this.d),this}prepend(t){let e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){let r=this.a,i=this.c;this.a=r*t.a+this.b*t.c,this.b=r*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){let e=this.a,r=this.b,i=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-i,n),l=Math.atan2(r,e),h=Math.abs(a+l);return h<1e-5||Math.abs(Zg-h)<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+r*r),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*r+o.y*n),t}invert(){let t=this.a,e=this.b,r=this.c,i=this.d,n=this.tx,o=t*i-e*r;return this.a=i/o,this.b=-e/o,this.c=-r/o,this.d=t/o,this.tx=(r*this.ty-i*n)/o,this.ty=-(t*this.ty-e*n)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let t=new s;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}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return nA.identity()}static get shared(){return iA.identity()}},iA=new R,nA=new R});var Ct,Vn=p(()=>{"use strict";Ct=class s{constructor(t,e,r){this._x=e||0,this._y=r||0,this._observer=t}clone(t){return new s(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}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}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))}}});function $(s="default"){return Hc[s]===void 0&&(Hc[s]=-1),++Hc[s]}var Hc,Gt=p(()=>{"use strict";Hc={default:-1}});var t_,J,e_,ui,N,Rt=p(()=>{"use strict";t_=new Set,J="8.0.0",e_="8.3.4",ui={quiet:!1,noColor:!1},N=((s,t,e=3)=>{if(ui.quiet||t_.has(t))return;let r=new Error().stack,i=`${t}
2
+ Deprecated since v${s}`,n=typeof console.groupCollapsed=="function"&&!ui.noColor;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",i):(r=r.split(`
3
+ `).splice(e).join(`
4
+ `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",i),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i),console.warn(r))),t_.add(t)});Object.defineProperties(N,{quiet:{get:()=>ui.quiet,set:s=>{ui.quiet=s},enumerable:!0,configurable:!1},noColor:{get:()=>ui.noColor,set:s=>{ui.noColor=s},enumerable:!0,configurable:!1}})});function O(...s){zc!==r_&&(zc++,zc===r_?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}var zc,r_,pt=p(()=>{"use strict";zc=0,r_=500});var Le,bs=p(()=>{"use strict";Le={_registeredResources:new Set,register(s){this._registeredResources.add(s)},unregister(s){this._registeredResources.delete(s)},release(){this._registeredResources.forEach(s=>s.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(s){return this._registeredResources.has(s)},reset(){this._registeredResources.clear()}}});var ol,s_=p(()=>{"use strict";ol=class{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){let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),e.init?.(t),e}return(t){t.reset?.(),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}}});var Wc,Pt,Er=p(()=>{bs();s_();Wc=class{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 ol(t)),this._poolsByClass.get(t)}stats(){let t={};return this._poolsByClass.forEach(e=>{let r=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[r]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}},Pt=new Wc;Le.register(Pt)});var i_,n_=p(()=>{Rt();i_={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(s){typeof s=="boolean"&&s===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===!0?{}:s))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){N("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}}});function al(s,t,e){let r=s.length,i;if(t>=r||e===0)return;e=t+e>r?r-t:e;let n=r-e;for(i=t;i<n;++i)s[i]=s[i+e];s.length=n}var Xc=p(()=>{"use strict"});var o_,a_=p(()=>{Xc();Rt();o_={allowChildren:!0,removeChildren(s=0,t){let e=t??this.children.length,r=e-s,i=[];if(r>0&&r<=e){for(let o=e-1;o>=s;o--){let a=this.children[o];a&&(i.push(a),a.parent=null)}al(this.children,s,e);let n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(i);for(let o=0;o<i.length;++o){let a=i[o];a.parentRenderLayer?.detach(a),this.emit("childRemoved",a,this,o),i[o].emit("removed",this)}return i.length>0&&this._didViewChangeTick++,i}else if(r===0&&this.children.length===0)return i;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){let t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){let t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||N(J,"addChildAt: Only Containers will be allowed to add children in v8.0.0");let{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);let r=s.parent===this;if(s.parent){let n=s.parent.children.indexOf(s);if(r){if(n===t)return s;s.parent.children.splice(n,1)}else s.removeFromParent()}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s._updateFlags=15;let i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),r||(this.emit("childAdded",s,this,t),s.emit("added",this)),s},swapChildren(s,t){if(s===t)return;let e=this.getChildIndex(s),r=this.getChildIndex(t);this.children[e]=t,this.children[r]=s;let i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;let e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);let r=this.worldTransform.clone();return r.invert(),e.prepend(r),s.setFromMatrix(e),s},replaceChild(s,t){s.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(s)),t.setFromMatrix(s.localTransform),t.updateLocalTransform(),this.removeChild(s)}}});var l_,h_=p(()=>{"use strict";l_={collectRenderables(s,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,t,e))},collectRenderablesSimple(s,t,e){let r=this.children,i=r.length;for(let n=0;n<i;n++)r[n].collectRenderables(s,t,e)},collectRenderablesWithEffects(s,t,e){let{renderPipes:r}=t;for(let i=0;i<this.effects.length;i++){let n=this.effects[i];r[n.pipe].push(n,this,s)}this.collectRenderablesSimple(s,t,e);for(let i=this.effects.length-1;i>=0;i--){let n=this.effects[i];r[n.pipe].pop(n,this,s)}}}});var Ar,ll=p(()=>{"use strict";Ar=class{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}}});var jc,hl,u_=p(()=>{A();Er();jc=class{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++){let r=this._tests[e];if(r.test(t))return Pt.get(r.maskClass,t)}return t}returnMaskEffect(t){Pt.return(t)}},hl=new jc;U.handleByList(y.MaskEffect,hl._effectClasses)});var c_,d_=p(()=>{ll();u_();c_={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){let s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0)},addEffect(s){this.effects.indexOf(s)===-1&&(this.effects.push(s),this.effects.sort((e,r)=>e.priority-r.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(s){let t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(s){let t=this._maskEffect;t?.mask!==s&&(t&&(this.removeEffect(t),hl.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=hl.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},set filters(s){!Array.isArray(s)&&s&&(s=[s]);let t=this._filterEffect||(this._filterEffect=new Ar);s=s;let e=s?.length>0,r=t.filters?.length>0,i=e!==r;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),i&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){return this._filterEffect?.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Ar),this._filterEffect.filterArea=s},get filterArea(){return this._filterEffect?.filterArea}}});var f_,p_=p(()=>{Rt();f_={label:null,get name(){return N(J,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){N(J,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){let e=this.children;for(let r=0;r<e.length;r++){let i=e[r];if(i.label===s||s instanceof RegExp&&s.test(i.label))return i}if(t)for(let r=0;r<e.length;r++){let n=e[r].getChildByLabel(s,!0);if(n)return n}return null},getChildrenByLabel(s,t=!1,e=[]){let r=this.children;for(let i=0;i<r.length;i++){let n=r[i];(n.label===s||s instanceof RegExp&&s.test(n.label))&&e.push(n)}if(t)for(let i=0;i<r.length;i++)r[i].getChildrenByLabel(s,!0,e);return e}}});var ul,rt,te=p(()=>{ke();ul=[new et,new et,new et,new et],rt=class s{constructor(t=0,e=0,r=0,i=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(r),this.height=Number(i)}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 s(0,0,0,0)}clone(){return new s(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,r,i=.5){let{width:n,height:o}=this;if(n<=0||o<=0)return!1;let a=this.x,l=this.y,h=r*(1-i),u=r-h,c=a-h,f=a+n+h,d=l-h,m=l+o+h,g=a+u,_=a+n-u,x=l+u,S=l+o-u;return t>=c&&t<=f&&e>=d&&e<=m&&!(t>g&&t<_&&e>x&&e<S)}intersects(t,e){if(!e){let E=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=E)return!1;let B=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>B}let r=this.left,i=this.right,n=this.top,o=this.bottom;if(i<=r||o<=n)return!1;let a=ul[0].set(t.left,t.top),l=ul[1].set(t.left,t.bottom),h=ul[2].set(t.right,t.top),u=ul[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;let c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=r||Math.min(a.x,l.x,h.x,u.x)>=i||Math.max(a.y,l.y,h.y,u.y)<=n||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;let f=c*(l.y-a.y),d=c*(a.x-l.x),m=f*r+d*n,g=f*i+d*n,_=f*r+d*o,x=f*i+d*o;if(Math.max(m,g,_,x)<=f*a.x+d*a.y||Math.min(m,g,_,x)>=f*u.x+d*u.y)return!1;let S=c*(a.y-h.y),v=c*(h.x-a.x),b=S*r+v*n,C=S*i+v*n,T=S*r+v*o,P=S*i+v*o;return!(Math.max(b,C,T,P)<=S*a.x+v*a.y||Math.min(b,C,T,P)>=S*u.x+v*u.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){let e=Math.max(this.x,t.x),r=Math.min(this.x+this.width,t.x+t.width),i=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(r-e,0),this.y=i,this.height=Math.max(n-i,0),this}ceil(t=1,e=.001){let r=Math.ceil((this.x+this.width-e)*t)/t,i=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=r-this.x,this.height=i-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){let e=Math.min(this.x,t.x),r=Math.max(this.x+this.width,t.x+t.width),i=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=r-e,this.y=i,this.height=n-i,this}getBounds(t){return t||(t=new s),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;let e=t.x,r=t.y,i=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&r>=this.y&&r<this.y+this.height&&i>=this.x&&i<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,r,i){return this.x=t,this.y=e,this.width=r,this.height=i,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}});var m_,ot,ie=p(()=>{nt();te();m_=new R,ot=class s{constructor(t=1/0,e=1/0,r=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=m_,this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new rt);let 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=m_,this}set(t,e,r,i){this.minX=t,this.minY=e,this.maxX=r,this.maxY=i}addFrame(t,e,r,i,n){n||(n=this.matrix);let o=n.a,a=n.b,l=n.c,h=n.d,u=n.tx,c=n.ty,f=this.minX,d=this.minY,m=this.maxX,g=this.maxY,_=o*t+l*e+u,x=a*t+h*e+c;_<f&&(f=_),x<d&&(d=x),_>m&&(m=_),x>g&&(g=x),_=o*r+l*e+u,x=a*r+h*e+c,_<f&&(f=_),x<d&&(d=x),_>m&&(m=_),x>g&&(g=x),_=o*t+l*i+u,x=a*t+h*i+c,_<f&&(f=_),x<d&&(d=x),_>m&&(m=_),x>g&&(g=x),_=o*r+l*i+u,x=a*r+h*i+c,_<f&&(f=_),x<d&&(d=x),_>m&&(m=_),x>g&&(g=x),this.minX=f,this.minY=d,this.maxX=m,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){let e=this.minX,r=this.minY,i=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:h,tx:u,ty:c}=t,f=o*e+l*r+u,d=a*e+h*r+c;this.minX=f,this.minY=d,this.maxX=f,this.maxY=d,f=o*i+l*r+u,d=a*i+h*r+c,this.minX=f<this.minX?f:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=d>this.maxY?d:this.maxY,f=o*e+l*n+u,d=a*e+h*n+c,this.minX=f<this.minX?f:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=d>this.maxY?d:this.maxY,f=o*i+l*n+u,d=a*i+h*n+c,this.minX=f<this.minX?f:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=d>this.maxY?d: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,r,i){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<r&&(this.minY=r),this.maxY>i&&(this.maxY=i),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new s(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){let e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){let 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,r,i){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;i||(i=this.matrix);let h=i.a,u=i.b,c=i.c,f=i.d,d=i.tx,m=i.ty;for(let g=e;g<r;g+=2){let _=t[g],x=t[g+1],S=h*_+c*x+d,v=u*_+f*x+m;n=S<n?S:n,o=v<o?v:o,a=S>a?S: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}}});var Ut,Te,vs=p(()=>{nt();Er();ie();Ut=Pt.getPool(R),Te=Pt.getPool(ot)});var oA,g_,__=p(()=>{nt();ie();vs();oA=new R,g_={getFastGlobalBounds(s,t){t||(t=new ot),t.clear(),this._getGlobalBoundsRecursive(!!s,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);let e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(s,t,e){let r=t;if(s&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;let i=!!this.effects.length;if((this.renderGroup||i)&&(r=Te.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){let o=this.bounds;r.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}let n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(s,r,e)}if(i){let n=!1,o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,r.applyMatrix(o.worldTransform)),this.effects[a].addBounds(r,!0));n&&r.applyMatrix(o.worldTransform.copyTo(oA).invert()),t.addBounds(r),Te.return(r)}else this.renderGroup&&(t.addBounds(r,this.relativeGroupTransform),Te.return(r))}}});function ci(s,t,e){e.clear();let r,i;return s.parent?t?r=s.parent.worldTransform:(i=Ut.get().identity(),r=cl(s,i)):r=R.IDENTITY,x_(s,e,r,t),i&&Ut.return(i),e.isValid||e.set(0,0,0,0),e}function x_(s,t,e,r){if(!s.visible||!s.measurable)return;let i;r?i=s.worldTransform:(s.updateLocalTransform(),i=Ut.get(),i.appendFrom(s.localTransform,e));let n=t,o=!!s.effects.length;if(o&&(t=Te.get().clear()),s.boundsArea)t.addRect(s.boundsArea,i);else{let a=s.bounds;a&&!a.isEmpty()&&(t.matrix=i,t.addBounds(a));for(let l=0;l<s.children.length;l++)x_(s.children[l],t,i,r)}if(o){for(let a=0;a<s.effects.length;a++)s.effects[a].addBounds?.(t);n.addBounds(t,R.IDENTITY),Te.return(t)}r||Ut.return(i)}function cl(s,t){let e=s.parent;return e&&(cl(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}var Nn=p(()=>{nt();vs()});function or(s,t){if(s===16777215||!t)return t;if(t===16777215||!s)return s;let e=s>>16&255,r=s>>8&255,i=s&255,n=t>>16&255,o=t>>8&255,a=t&255,l=e*n/255|0,h=r*o/255|0,u=i*a/255|0;return(l<<16)+(h<<8)+u}var Hn=p(()=>{"use strict"});function di(s,t){return s===y_?t:t===y_?s:or(s,t)}var y_,Yc=p(()=>{Hn();y_=16777215});function Br(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}var b_,dl=p(()=>{nt();Nn();vs();Yc();b_={getGlobalAlpha(s){if(s)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(s=new R,t){if(t)return s.copyFrom(this.worldTransform);this.updateLocalTransform();let e=cl(this,Ut.get().identity());return s.appendFrom(this.localTransform,e),Ut.return(e),s},getGlobalTint(s){if(s)return this.renderGroup?Br(this.renderGroup.worldColor):this.parentRenderGroup?Br(di(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=di(t,e.localColor),e=e.parent;return Br(t)}}});function fi(s,t,e){return t.clear(),e||(e=R.IDENTITY),v_(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function v_(s,t,e,r,i){let n;if(i)n=Ut.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();let l=s.localTransform;n=Ut.get(),n.appendFrom(l,e)}let o=t,a=!!s.effects.length;if(a&&(t=Te.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,t.addBounds(s.bounds));let l=s.children;for(let h=0;h<l.length;h++)v_(l[h],t,n,r,!1)}if(a){for(let l=0;l<s.effects.length;l++)s.effects[l].addLocalBounds?.(t,r);o.addBounds(t,R.IDENTITY),Te.return(t)}Ut.return(n)}var fl=p(()=>{nt();vs()});function $c(s,t){let e=s.children;for(let r=0;r<e.length;r++){let i=e[r],n=i.uid,o=(i._didViewChangeTick&65535)<<16|i._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,i.children.length&&$c(i,t)}return t.didChange}var S_=p(()=>{"use strict"});var aA,T_,C_=p(()=>{nt();ie();Nn();fl();S_();aA=new R,T_={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(s,t){let e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=s/t*e:this.scale.x=e},_setHeight(s,t){let e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=s/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new ot});let s=this._localBoundsCacheData;return s.index=1,s.didChange=!1,s.data[0]!==this._didViewChangeTick&&(s.didChange=!0,s.data[0]=this._didViewChangeTick),$c(this,s),s.didChange&&fi(this,s.localBounds,aA),s.localBounds},getBounds(s,t){return ci(this,s,t||new ot)}}});var P_,M_=p(()=>{"use strict";P_={_onRender:null,set onRender(s){let t=this.renderGroup||this.parentRenderGroup;if(!s){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=s},get onRender(){return this._onRender}}});function lA(s,t){return s._zIndex-t._zIndex}var w_,E_=p(()=>{"use strict";w_={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(s){this._zIndex!==s&&(this._zIndex=s,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(lA))}}});var A_,B_=p(()=>{ke();vs();A_={getGlobalPosition(s=new et,t=!1){return this.parent?this.parent.toGlobal(this._position,s,t):(s.x=this._position.x,s.y=this._position.y),s},toGlobal(s,t,e=!1){let r=this.getGlobalTransform(Ut.get(),e);return t=r.apply(s,t),Ut.return(r),t},toLocal(s,t,e,r){t&&(s=t.toGlobal(s,e,r));let i=this.getGlobalTransform(Ut.get(),r);return e=i.applyInverse(s,e),Ut.return(i),e}}});var $r,pl=p(()=>{Gt();$r=class{constructor(){this.uid=$("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 pi(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function qc(s){return!(s&s-1)&&!!s}var ml=p(()=>{"use strict"});function gl(s){let t={};for(let e in s)s[e]!==void 0&&(t[e]=s[e]);return t}var Kc=p(()=>{"use strict"});function hA(s){let t=R_[s];return t===void 0&&(R_[s]=$("resource")),t}var R_,I_,Rr,zn=p(()=>{Qt();Gt();Rt();R_=Object.create(null);I_=class F_ extends q{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...F_.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){N(J,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){let t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=hA(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};I_.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};Rr=I_});var k_,ut,ce=p(()=>{Qt();ml();Kc();Gt();zn();k_=class L_ extends q{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=$("textureSource"),this._resourceType="textureSource",this._resourceId=$("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...L_.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=t.transient??!1,this.alphaMode=t.alphaMode,this.style=new Rr(gl(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.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){let t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=$("resource"),this.emit("change",this),this.emit("unload",this);for(let t in this._gpuData)this._gpuData[t]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){let{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){let{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,r){r||(r=this._resolution),t||(t=this.width),e||(e=this.height);let i=Math.round(t*r),n=Math.round(e*r);return this.width=i/r,this.height=n/r,this._resolution=r,this.pixelWidth===i&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=n,this.emit("resize",this),this._resourceId=$("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=qc(this.pixelWidth)&&qc(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};k_.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};ut=k_});function uA(){for(let s=0;s<16;s++){let t=[];Zc.push(t);for(let e=0;e<16;e++){let r=_l(Ss[s]*Ss[e]+Cs[s]*Ts[e]),i=_l(Ts[s]*Ss[e]+Ps[s]*Ts[e]),n=_l(Ss[s]*Cs[e]+Cs[s]*Ps[e]),o=_l(Ts[s]*Cs[e]+Ps[s]*Ps[e]);for(let a=0;a<16;a++)if(Ss[a]===r&&Ts[a]===i&&Cs[a]===n&&Ps[a]===o){t.push(a);break}}}for(let s=0;s<16;s++){let t=new R;t.set(Ss[s],Ts[s],Cs[s],Ps[s],0,0),D_.push(t)}}var Ss,Ts,Cs,Ps,Zc,D_,_l,Q,mi=p(()=>{nt();Ss=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ts=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Cs=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ps=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Zc=[],D_=[],_l=Math.sign;uA();Q={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:s=>Ss[s],uY:s=>Ts[s],vX:s=>Cs[s],vY:s=>Ps[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Zc[s][t],sub:(s,t)=>Zc[s][Q.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?Q.S:Q.N:Math.abs(t)*2<=Math.abs(s)?s>0?Q.E:Q.W:t>0?s>0?Q.SE:Q.SW:s>0?Q.NE:Q.NW,matrixAppendRotationInv:(s,t,e=0,r=0,i=0,n=0)=>{let o=D_[Q.inv(t)],a=o.a,l=o.b,h=o.c,u=o.d,c=e-Math.min(0,a*i,h*n,a*i+h*n),f=r-Math.min(0,l*i,u*n,l*i+u*n),d=s.a,m=s.b,g=s.c,_=s.d;s.a=a*d+l*g,s.b=a*m+l*_,s.c=h*d+u*g,s.d=h*m+u*_,s.tx=c*d+f*g+s.tx,s.ty=c*m+f*_+s.ty},transformRectCoords:(s,t,e,r)=>{let{x:i,y:n,width:o,height:a}=s,{x:l,y:h,width:u,height:c}=t;return e===Q.E?(r.set(i+l,n+h,o,a),r):e===Q.S?r.set(u-n-a+l,i+h,a,o):e===Q.W?r.set(u-i-o+l,c-n-a+h,o,a):e===Q.N?r.set(n+l,c-i-o+h,a,o):r.set(i+l,n+h,o,a)}}});var Jc,O_=p(()=>{"use strict";Jc=()=>{}});var Ms,Qc=p(()=>{A();ce();Ms=class extends ut{constructor(t){let e=t.resource||new Float32Array(t.width*t.height*4),r=t.format;r||(e instanceof Float32Array?r="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?r="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?r="rgba16uint":(e instanceof Int8Array,r="bgra8unorm")),super({...t,resource:e,format:r}),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}};Ms.extension=y.TextureSource});var G_,gi,td=p(()=>{nt();G_=new R,gi=class{constructor(t,e){this.mapCoord=new R,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture?.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);let r=this.mapCoord;for(let i=0;i<t.length;i+=2){let n=t[i],o=t[i+1];e[i]=n*r.a+o*r.c+r.tx,e[i+1]=n*r.b+o*r.d+r.ty}return e}update(){let t=this._texture;this._updateID++;let 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);let r=t.orig,i=t.trim;i&&(G_.set(r.width/i.width,0,0,r.height/i.height,-i.x/i.width,-i.y/i.height),this.mapCoord.append(G_));let 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}}});var F,yt=p(()=>{Qt();mi();te();Gt();Rt();O_();Qc();ce();td();F=class extends q{constructor({source:t,label:e,frame:r,orig:i,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:h}={}){if(super(),this.uid=$("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new rt,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=t?.source??new ut,this.noFrame=!r,r)this.frame.copyFrom(r);else{let{width:u,height:c}=this._source;this.frame.width=u,this.frame.height=c}this.orig=i||this.frame,this.trim=n,this.rotate=l??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=h||!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 gi(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){let{uvs:t,frame:e}=this,{width:r,height:i}=this._source,n=e.x/r,o=e.y/i,a=e.width/r,l=e.height/i,h=this.rotate;if(h){let u=a/2,c=l/2,f=n+u,d=o+c;h=Q.add(h,Q.NW),t.x0=f+u*Q.uX(h),t.y0=d+c*Q.uY(h),h=Q.add(h,2),t.x1=f+u*Q.uX(h),t.y1=d+c*Q.uY(h),h=Q.add(h,2),t.x2=f+u*Q.uX(h),t.y2=d+c*Q.uY(h),h=Q.add(h,2),t.x3=f+u*Q.uX(h),t.y3=d+c*Q.uY(h)}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 N(J,"Texture.baseTexture is now Texture.source"),this._source}};F.EMPTY=new F({label:"EMPTY",source:new ut({label:"EMPTY"})});F.EMPTY.destroy=Jc;F.WHITE=new F({source:new Ms({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});F.WHITE.destroy=Jc});var cA,ed,Vt,_i=p(()=>{ml();bs();ce();yt();zn();cA=0,ed=class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Rr(this.textureOptions)}createTexture(t,e,r,i){let n=new ut({...this.textureOptions,width:t,height:e,resolution:1,antialias:r,autoGarbageCollect:!1,autoGenerateMipmaps:i});return new F({source:n,label:`texturePool_${cA++}`})}getOptimalTexture(t,e,r=1,i,n=!1){let o=Math.ceil(t*r-1e-6),a=Math.ceil(e*r-1e-6);o=pi(o),a=pi(a);let l=i?1:0,h=n?1:0,u=(o<<17)+(a<<2)+(h<<1)+l;this._texturePool[u]||(this._texturePool[u]=[]);let c=this._texturePool[u].pop();return c||(c=this.createTexture(o,a,i,n)),c.source._resolution=r,c.source.width=o/r,c.source.height=a/r,c.source.pixelWidth=o,c.source.pixelHeight=a,c.frame.x=0,c.frame.y=0,c.frame.width=t,c.frame.height=e,c.updateUvs(),this._poolKeyHash[c.uid]=u,c}getSameSizeTexture(t,e=!1){let r=t.source;return this.getOptimalTexture(t.width,t.height,r._resolution,e)}returnTexture(t,e=!1){let r=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[r].push(t)}clear(t){if(t=t!==!1,t)for(let e in this._texturePool){let r=this._texturePool[e];if(r)for(let i=0;i<r.length;i++)r[i].destroy(!0)}this._texturePool={}}},Vt=new ed;Le.register(Vt)});var ws,rd=p(()=>{nt();pl();_i();ws=class{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new R,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 $r,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;let e=t.children;for(let r=0;r<e.length;r++){let i=e[r];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Vt.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;let t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(let t in this.childrenToUpdate){let 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){let 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);let e=t.children;for(let r=0;r<e.length;r++)this.addChild(e[r])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}let e=t.children;for(let r=0;r<e.length;r++)this.removeChild(e[r])}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=[]){let e=this.root.children;for(let r=0;r<e.length;r++)this._getChildren(e[r],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;let r=t.children;for(let i=0;i<r.length;i++)this._getChildren(r[i],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new R),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new R),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;let t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new R),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 U_(s,t,e={}){for(let r in t)!e[r]&&t[r]!==void 0&&(s[r]=t[r])}var V_=p(()=>{"use strict"});var sd,xl,id,yl,xi,Wn,Es,Mt,Ke=p(()=>{Qt();se();Kg();A();nt();Vc();Vn();Gt();Rt();pt();Er();n_();a_();h_();d_();p_();__();dl();C_();M_();E_();B_();rd();V_();sd=new Ct(null),xl=new Ct(null),id=new Ct(null,1,1),yl=new Ct(null),xi=1,Wn=2,Es=4,Mt=class s extends q{constructor(t={}){super(),this.uid=$("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 R,this.relativeGroupTransform=new R,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Ct(this,0,0),this._scale=id,this._pivot=xl,this._origin=yl,this._skew=sd,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=[],U_(this,t,{children:!0,parent:!0,effects:!0}),t.children?.forEach(e=>this.addChild(e)),t.parent?.addChild(this)}static mixin(t){N("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),U.mixin(s,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(this.allowChildren||N(J,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let i=0;i<t.length;i++)this.addChild(t[i]);return t[0]}let e=t[0],r=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),r&&(r.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,r&&r.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 i=0;i<t.length;i++)this.removeChild(t[i]);return t[0]}let e=t[0],r=this.children.indexOf(e);return r>-1&&(this._didViewChangeTick++,this.children.splice(r,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,r),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;let t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=Pt.get(ws,this),this.groupTransform=R.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let t=this.parentRenderGroup;t?.removeChild(this),Pt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new R),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Jg}set angle(t){this.rotation=t*Qg}get pivot(){return this._pivot===xl&&(this._pivot=new Ct(this,0,0)),this._pivot}set pivot(t){this._pivot===xl&&(this._pivot=new Ct(this,0,0),this._origin!==yl&&O("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===sd&&(this._skew=new Ct(this,0,0)),this._skew}set skew(t){this._skew===sd&&(this._skew=new Ct(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===id&&(this._scale=new Ct(this,1,1)),this._scale}set scale(t){this._scale===id&&(this._scale=new Ct(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===yl&&(this._origin=new Ct(this,0,0)),this._origin}set origin(t){this._origin===yl&&(this._origin=new Ct(this,0,0),this._pivot!==xl&&O("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),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){let e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){let e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});let 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){let r=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,r.width),e!==void 0&&this._setHeight(e,r.height)}_updateSkew(){let t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX:this.scale.x,typeof t.scaleY=="number"?t.scaleY:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){let t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;let e=this.localTransform,r=this._scale,i=this._pivot,n=this._origin,o=this._position,a=r._x,l=r._y,h=i._x,u=i._y,c=-n._x,f=-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-(h*e.a+u*e.c)+(c*e.a+f*e.c)-c,e.ty=o._y-(h*e.b+u*e.d)+(c*e.b+f*e.d)-f}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=xi,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){let r=Z.shared.setValue(t??16777215).toBgrNumber();r!==this.localColor&&(this.localColor=r,this._updateFlags|=xi,this._onUpdate())}get tint(){return Br(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Wn,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){let e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Es,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){let e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Es,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){let e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Es,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;this.destroyed=!0;let e;if(this.children.length&&(e=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?.children)&&e)for(let i=0;i<e.length;++i)e[i].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}};U.mixin(Mt,o_,g_,A_,P_,T_,c_,f_,w_,qg,i_,b_,l_)});var ar,Xn=p(()=>{"use strict";ar=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(ar||{})});var yi,N_=p(()=>{"use strict";yi=class{constructor(t,e=null,r=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=r,this._once=i}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));let 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);let e=this.next;return this.next=t?null:e,this.previous=null,e}}});var H_,St,As=p(()=>{Xn();N_();H_=class Ce{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 yi(null,null,1/0),this.deltaMS=1/Ce.targetFPMS,this.elapsedMS=1/Ce.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,r=ar.NORMAL){return this._addListener(new yi(t,e,r))}addOnce(t,e,r=ar.NORMAL){return this._addListener(new yi(t,e,r,!0))}_addListener(t){let e=this._head.next,r=this._head;if(!e)t.connect(r);else{for(;e;){if(t.priority>e.priority){t.connect(r);break}r=e,e=e.next}t.previous||t.connect(r)}return this._startIfPossible(),this}remove(t,e){let r=this._head.next;for(;r;)r.match(t,e)?r=r.destroy():r=r.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){let n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Ce.targetFPMS;let r=this._head,i=r.next;for(;i;)i=i.emit(this);r.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){let e=Math.min(Math.max(0,t)/1e3,Ce.targetFPMS);this._maxElapsedMS=1/e,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t<this.minFPS&&(this.minFPS=t),this._minElapsedMS=1/(t/1e3))}static get shared(){if(!Ce._shared){let t=Ce._shared=new Ce;t.autoStart=!0,t._protected=!0}return Ce._shared}static get system(){if(!Ce._system){let t=Ce._system=new Ce;t.autoStart=!0,t._protected=!0}return Ce._system}};H_.targetFPMS=.06;St=H_});var bi,nd=p(()=>{Xn();As();bi=class{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let e=this._canvas.getBoundingClientRect(),r=this._canvas.width,i=this._canvas.height,n=e.width/r*this._renderer.resolution,o=e.height/i*this._renderer.resolution,a=e.left,l=e.top,h=`translate(${a}px, ${l}px) scale(${n}, ${o})`;h!==this._lastTransform&&(this._domElement.style.transform=h,this._lastTransform=h)},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(let e of t){if(e.target!==this._canvas)continue;let r=this.canvas.width,i=this.canvas.height,n=e.contentRect.width/r*this._renderer.resolution,o=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||St.shared.add(this.updateTranslation,this,ar.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&St.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}});var qr,bl=p(()=>{ke();qr=class s{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=s.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new et,this.page=new et,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,r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,r,i,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}});function dA(s){return function(t){return t.test(s)}}function jn(s){var t={userAgent:"",platform:"",maxTouchPoints:0};!s&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof s=="string"?t.userAgent=s:s&&s.userAgent&&(t={userAgent:s.userAgent,platform:s.platform,maxTouchPoints:s.maxTouchPoints||0});var e=t.userAgent,r=e.split("[FBAN");typeof r[1]<"u"&&(e=r[0]),r=e.split("Twitter"),typeof r[1]<"u"&&(e=r[0]);var i=dA(e),n={apple:{phone:i(od)&&!i(Ir),ipod:i(z_),tablet:!i(od)&&(i(W_)||Q_(t))&&!i(Ir),universal:i(X_),device:(i(od)||i(z_)||i(W_)||i(X_)||Q_(t))&&!i(Ir)},amazon:{phone:i(vi),tablet:!i(vi)&&i(vl),device:i(vi)||i(vl)},android:{phone:!i(Ir)&&i(vi)||!i(Ir)&&i(ad),tablet:!i(Ir)&&!i(vi)&&!i(ad)&&(i(vl)||i(j_)),device:!i(Ir)&&(i(vi)||i(vl)||i(ad)||i(j_))||i(/\bokhttp\b/i)},windows:{phone:i(Ir),tablet:i(Y_),device:i(Ir)||i(Y_)},other:{blackberry:i($_),blackberry10:i(q_),opera:i(K_),firefox:i(J_),chrome:i(Z_),device:i($_)||i(q_)||i(K_)||i(J_)||i(Z_)},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 od,z_,W_,X_,ad,j_,vi,vl,Ir,Y_,$_,q_,K_,Z_,J_,Q_,ld=p(()=>{od=/iPhone/i,z_=/iPod/i,W_=/iPad/i,X_=/\biOS-universal(?:.+)Mac\b/i,ad=/\bAndroid(?:.+)Mobile\b/i,j_=/Android/i,vi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,vl=/Silk/i,Ir=/Windows Phone/i,Y_=/\bWindows(?:.+)ARM\b/i,$_=/BlackBerry/i,q_=/BB10/i,K_=/Opera Mini/i,Z_=/\b(CriOS|Chrome)(?:.+)Mobile/i,J_=/Mobile(?:.+)Firefox\b/i,Q_=function(s){return typeof s<"u"&&s.platform==="MacIntel"&&typeof s.maxTouchPoints=="number"&&s.maxTouchPoints>1&&typeof MSStream>"u"}});var tx=p(()=>{ld();ld()});var fA,ex,rx=p(()=>{tx();fA=jn.default??jn,ex=fA(globalThis.navigator)});var pA,sx,mA,gA,ix,nx,_A,xA,yA,hd,ax,lx=p(()=>{nd();bl();A();rx();Xc();pA=9,sx=100,mA=0,gA=0,ix=2,nx=1,_A=-1e3,xA=-1e3,yA=2,hd=class ox{constructor(t,e=ex){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(){let t=document.createElement("button");t.style.width=`${nx}px`,t.style.height=`${nx}px`,t.style.position="absolute",t.style.top=`${_A}px`,t.style.left=`${xA}px`,t.style.zIndex=yA.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=`${mA}px`,this._div.style.left=`${gA}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=ix.toString(),this._canvasObserver=new bi({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);let t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{let 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(){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(let t of this._children)t._accessibleDiv?.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;for(let t in this._pools)this._pools[t].forEach(r=>{r.parentNode&&r.parentNode.removeChild(r)}),delete this._pools[t];this._div?.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);let e=t.children;if(e)for(let r=0;r<e.length;r++)this._updateAccessibleObjects(e[r])}init(t){let r={accessibilityOptions:{...ox.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=r.accessibilityOptions.debug,this._activateOnTab=r.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=r.accessibilityOptions.deactivateOnMouseMove,r.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){let 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;let e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(let r of this._children)r._renderId===this._renderId&&e.add(this._children.indexOf(r))}for(let r=this._children.length-1;r>=0;r--){let i=this._children[r];e.has(r)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,al(this._children,r,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let r=0;r<this._children.length;r++){let i=this._children[r];if(!i._accessibleActive||!i._accessibleDiv)continue;let n=i._accessibleDiv,o=i.hitArea||i.getBounds().rectangle;if(i.hitArea){let a=i.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);let{width:e,height:r}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>r&&(t.height=r-t.y)}_addChild(t){let r=this._getPool(t.accessibleType).pop();r?(r.innerHTML="",r.removeAttribute("title"),r.removeAttribute("aria-label"),r.tabIndex=0):(t.accessibleType==="button"?r=document.createElement("button"):(r=document.createElement(t.accessibleType),r.style.cssText=`
5
+ color: transparent;
6
+ pointer-events: none;
7
+ padding: 0;
8
+ margin: 0;
9
+ border: 0;
10
+ outline: 0;
11
+ background: transparent;
12
+ box-sizing: border-box;
13
+ user-select: none;
14
+ -webkit-user-select: none;
15
+ -moz-user-select: none;
16
+ -ms-user-select: none;
17
+ `,t.accessibleText&&(r.innerText=t.accessibleText)),r.style.width=`${sx}px`,r.style.height=`${sx}px`,r.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",r.style.position="absolute",r.style.zIndex=ix.toString(),r.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?r.setAttribute("aria-live","off"):r.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?r.setAttribute("aria-relevant","additions"):r.setAttribute("aria-relevant","text"),r.addEventListener("click",this._onClick.bind(this)),r.addEventListener("focus",this._onFocus.bind(this)),r.addEventListener("focusout",this._onFocusOut.bind(this))),r.style.pointerEvents=t.accessiblePointerEvents,r.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?r.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(r.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&r.setAttribute("aria-label",t.accessibleHint),t.interactive?r.tabIndex=t.tabIndex:r.tabIndex=0,this.debug&&this._updateDebugHTML(r),t._accessibleActive=!0,t._accessibleDiv=r,r.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){let{container:r}=t.target,i=this._renderer.events.rootBoundary,n=Object.assign(new qr(i),{target:r});i.rootTarget=this._renderer.lastObjectRendered,e.forEach(o=>i.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode!==pA||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.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]}};hd.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"accessibility"};hd.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};ax=hd});var hx,ux=p(()=>{"use strict";hx={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}});var cx=p(()=>{A();Ke();lx();ux();U.add(ax);U.mixin(Mt,hx)});var Yn,dx=p(()=>{A();nd();Yn=class{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 bi({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){let t=this._attachedDomElements;if(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){let r=t[e],i=r.element;if(!r.parent||r.globalDisplayStatus<7)i?.remove(),t.splice(e,1),e--;else{this._domElement.contains(i)||(i.style.position="absolute",i.style.pointerEvents="auto",this._domElement.appendChild(i));let n=r.worldTransform,o=r._anchor,a=r.width*o.x,l=r.height*o.y;i.style.transformOrigin=`${a}px ${l}px`,i.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,i.style.opacity=r.groupAlpha.toString()}}}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++)this._attachedDomElements[t].element?.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}};Yn.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"dom"}});var Si,ud=p(()=>{ie();Ke();Si=class extends Mt{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new ot(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=t.autoGarbageCollect??!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){let e=this.bounds,{x:r,y:i}=t;return r>=e.minX&&r<=e.maxX&&i>=e.minY&&i<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(let t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,r){let{renderPipes:i}=e;i.blendMode.pushBlendMode(this,this.groupBlendMode,t);let o=i[this.renderPipeId];o?.addRenderable&&o.addRenderable(this,t),this.didViewUpdate=!1;let a=this.children,l=a.length;for(let h=0;h<l;h++)a[h].collectRenderables(t,e,r);i.blendMode.popBlendMode(t)}}});var fx=p(()=>{A();dx();U.add(Yn)});var cd,Ze,dd=p(()=>{Xn();As();cd=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||(St.system.add(this._tickerUpdate,this,ar.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(St.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}let 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}},Ze=new cd});var Fr,Sl=p(()=>{ke();bl();Fr=class extends qr{constructor(){super(...arguments),this.client=new et,this.movement=new et,this.offset=new et,this.global=new et,this.screen=new et}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,r){return t.worldTransform.applyInverse(r||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,i,n,o,a,l,h,u,c,f,d,m,g){throw new Error("Method not implemented.")}}});var de,fd=p(()=>{Sl();de=class extends Fr{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!")}}});var lr,pd=p(()=>{Sl();lr=class extends Fr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};lr.DOM_DELTA_PIXEL=0;lr.DOM_DELTA_LINE=1;lr.DOM_DELTA_PAGE=2});var bA,vA,$n,Tl,px=p(()=>{Qt();ke();pt();dd();Sl();fd();pd();bA=2048,vA=new et,$n=new et,Tl=class{constructor(t){this.dispatch=new q,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((r,i)=>r.priority-i.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;let e=this.mappingTable[t.type];if(e)for(let r=0,i=e.length;r<i;r++)e[r].fn(t);else O(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Ze.pauseUpdate=!0;let i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[i](this.rootTarget,this.rootTarget.eventMode,vA.set(t,e),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(t,e){if(!t.target)return;let r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let i=0,n=r.length-1;i<n;i++)if(t.currentTarget=r[i],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 i=r.length-2;i>=0;i--)if(t.currentTarget=r[i],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(r.length===0)return;t.eventPhase=t.BUBBLING_PHASE;let i=Array.isArray(e)?e:[e];for(let n=r.length-1;n>=0;n--)i.forEach(o=>{t.currentTarget=r[n],this.notifyTarget(t,o)})}propagationPath(t){let e=[t];for(let r=0;r<bA&&t!==this.rootTarget&&t.parent;r++){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,r,i,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Ze.pauseUpdate=!1),t.interactiveChildren&&t.children){let u=t.children;for(let c=u.length-1;c>=0;c--){let f=u[c],d=this.hitTestMoveRecursive(f,this._isInteractive(e)?e:f.eventMode,r,i,n,o||n(t,r));if(d){if(d.length>0&&!d[d.length-1].parent)continue;let m=t.isInteractive();(d.length>0||m)&&(m&&this._allInteractiveElements.push(t),d.push(t)),this._hitElements.length===0&&(this._hitElements=d),a=!0}}}let l=this._isInteractive(e),h=t.isInteractive();return h&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,r)&&i(t,r)?h?[t]:[]:null}hitTestRecursive(t,e,r,i,n){if(this._interactivePrune(t)||n(t,r))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Ze.pauseUpdate=!1),t.interactiveChildren&&t.children){let l=t.children,h=r;for(let u=l.length-1;u>=0;u--){let c=l[u],f=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,h,i,n);if(f){if(f.length>0&&!f[f.length-1].parent)continue;let d=t.isInteractive();return(f.length>0||d)&&f.push(t),f}}}let o=this._isInteractive(e),a=t.isInteractive();return o&&i(t,r)?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,$n),!t.hitArea.contains($n.x,$n.y)))return!0;if(t.effects&&t.effects.length)for(let r=0;r<t.effects.length;r++){let i=t.effects[r];if(i.containsPoint&&!i.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return t.hitArea?!0:t?.containsPoint?(t.worldTransform.applyInverse(e,$n),t.containsPoint($n)):!1}notifyTarget(t,e){if(!t.currentTarget.isInteractive())return;e??(e=t.type);let r=`on${e}`;t.currentTarget[r]?.(t);let i=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,i),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof de)){O("EventBoundary cannot map a non-pointer event as a pointer event");return}let e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){let i=e.button===2;this.dispatchEvent(e,i?"rightdown":"mousedown")}let r=this.trackingData(t.pointerId);r.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof de)){O("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;let e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;let r=e.pointerType==="mouse"||e.pointerType==="pen",i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.overTargets);if(i.overTargets?.length>0&&n!==e.target){let l=t.type==="mousemove"?"mouseout":"pointerout",h=this.createPointerEvent(t,l,n);if(this.dispatchEvent(h,"pointerout"),r&&this.dispatchEvent(h,"mouseout"),!e.composedPath().includes(n)){let u=this.createPointerEvent(t,"pointerleave",n);for(u.eventPhase=u.AT_TARGET;u.target&&!e.composedPath().includes(u.target);)u.currentTarget=u.target,this.notifyTarget(u),r&&this.notifyTarget(u,"mouseleave"),u.target=u.target.parent;this.freeEvent(u)}this.freeEvent(h)}if(n!==e.target){let l=t.type==="mousemove"?"mouseover":"pointerover",h=this.clonePointerEvent(e,l);this.dispatchEvent(h,"pointerover"),r&&this.dispatchEvent(h,"mouseover");let u=n?.parent;for(;u&&u!==this.rootTarget.parent&&u!==e.target;)u=u.parent;if(!u||u===this.rootTarget.parent){let f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),r&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(h)}let o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),r&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=e.target?.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,i.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof de)){O("EventBoundary cannot map a non-pointer event as a pointer event");return}let e=this.trackingData(t.pointerId),r=this.createPointerEvent(t),i=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),i&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=r.target?.cursor);let n=this.clonePointerEvent(r,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof de)){O("EventBoundary cannot map a non-pointer event as a pointer event");return}let e=this.trackingData(t.pointerId);if(e.overTargets){let r=t.pointerType==="mouse"||t.pointerType==="pen",i=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",i);this.dispatchEvent(n),r&&this.dispatchEvent(n,"mouseout");let o=this.createPointerEvent(t,"pointerleave",i);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),r&&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 de)){O("EventBoundary cannot map a non-pointer event as a pointer event");return}let e=performance.now(),r=this.createPointerEvent(t);if(this.dispatchEvent(r,"pointerup"),r.pointerType==="touch")this.dispatchEvent(r,"touchend");else if(r.pointerType==="mouse"||r.pointerType==="pen"){let a=r.button===2;this.dispatchEvent(r,a?"rightup":"mouseup")}let i=this.trackingData(t.pointerId),n=this.findMountedTarget(i.pressTargetsByButton[t.button]),o=n;if(n&&!r.composedPath().includes(n)){let a=n;for(;a&&!r.composedPath().includes(a);){if(r.currentTarget=a,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch")this.notifyTarget(r,"touchendoutside");else if(r.pointerType==="mouse"||r.pointerType==="pen"){let l=r.button===2;this.notifyTarget(r,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete i.pressTargetsByButton[t.button],o=a}if(o){let a=this.clonePointerEvent(r,"click");a.target=o,a.path=null,i.clicksByButton[t.button]||(i.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});let l=i.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){let h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(r)}mapPointerUpOutside(t){if(!(t instanceof de)){O("EventBoundary cannot map a non-pointer event as a pointer event");return}let e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),i=this.createPointerEvent(t);if(r){let n=r;for(;n;)i.currentTarget=n,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch"?this.notifyTarget(i,"touchendoutside"):(i.pointerType==="mouse"||i.pointerType==="pen")&&this.notifyTarget(i,i.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(i)}mapWheel(t){if(!(t instanceof lr)){O("EventBoundary cannot map a non-wheel event as a wheel event");return}let e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){let i=this.allocateEvent(de);return this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.nativeEvent=t.nativeEvent,i.originalEvent=t,i.target=r??this.hitTest(i.global.x,i.global.y)??this._hitElements[0],typeof e=="string"&&(i.type=e),i}createWheelEvent(t){let e=this.allocateEvent(lr);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){let r=this.allocateEvent(de);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof de&&e instanceof de&&(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 Fr&&e instanceof Fr&&(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,[]);let 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!");let e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){let r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let i=0,n=r.length;i<n&&!t.propagationImmediatelyStopped;i++)r[i].once&&t.currentTarget.removeListener(e,r[i].fn,void 0,!0),r[i].fn.call(r[i].context,t)}}});var SA,TA,gd,Cl,_d=p(()=>{A();px();dd();fd();pd();SA=1,TA={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},gd=class md{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Tl(null),Ze.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new de(null),this._rootWheelEvent=new lr(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...md.defaultEventFeatures},{set:(e,r,i)=>(r==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=i),e[r]=i,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){let{canvas:e,resolution:r}=this.renderer;this.setTargetElement(e),this.resolution=r,md._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){Ze.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;let r=this.cursorStyles[t];if(r)switch(typeof r){case"string":e&&(this.domElement.style.cursor=r);break;case"function":r(t);break;case"object":e&&Object.assign(this.domElement.style,r);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;let e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let r=0,i=e.length;r<i;r++){let n=e[r],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,Ze.pointerMoved();let e=this._normalizeToPointerData(t);for(let r=0,i=e.length;r<i;r++){let n=this._bootstrapEvent(this._rootPointerEvent,e[r]);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]);let r=e!==this.domElement?"outside":"",i=this._normalizeToPointerData(t);for(let n=0,o=i.length;n<o;n++){let a=this._bootstrapEvent(this._rootPointerEvent,i[n]);a.type+=r,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=this._normalizeToPointerData(t);for(let r=0,i=e.length;r<i;r++){let n=this._bootstrapEvent(this._rootPointerEvent,e[r]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;let e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,Ze.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Ze.addTickerListener();let 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;Ze.removeTickerListener();let 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,r){let i=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-i.left)*(this.domElement.width/i.width)*n,t.y=(r-i.top)*(this.domElement.height/i.height)*n}_normalizeToPointerData(t){let e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let r=0,i=t.changedTouches.length;r<i;r++){let n=t.changedTouches[r];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,n.altKey??(n.altKey=t.altKey),n.ctrlKey??(n.ctrlKey=t.ctrlKey),n.metaKey??(n.metaKey=t.metaKey),n.shiftKey??(n.shiftKey=t.shiftKey),e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){let r=t;typeof r.isPrimary>"u"&&(r.isPrimary=!0),typeof r.width>"u"&&(r.width=1),typeof r.height>"u"&&(r.height=1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="mouse"),typeof r.pointerId>"u"&&(r.pointerId=SA),typeof r.pressure>"u"&&(r.pressure=.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),r.isNormalized=!0,e.push(r)}else e.push(t);return e}normalizeWheelEvent(t){let 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=TA[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}};gd.extension={name:"events",type:[y.WebGLSystem,y.CanvasSystem,y.WebGPUSystem],priority:-1};gd.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};Cl=gd});var mx,gx=p(()=>{_d();bl();mx={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(s){this.eventMode=s?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Cl.defaultEventMode},set eventMode(s){this._internalEventMode=s},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(s,t,e){let r=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;s=r?`${s}capture`:s;let a=typeof t=="function"?t:t.handleEvent,l=this;i&&i.addEventListener("abort",()=>{l.off(s,a,o)}),n?l.once(s,a,o):l.on(s,a,o)},removeEventListener(s,t,e){let r=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,i=typeof t=="function"?void 0:t;s=r?`${s}capture`:s,t=typeof t=="function"?t:t.handleEvent,this.off(s,t,i)},dispatchEvent(s){if(!(s instanceof qr))throw new Error("Container cannot propagate events outside of the Federated Events API");return s.defaultPrevented=!1,s.path=null,s.target=this,s.manager.dispatchEvent(s),!s.defaultPrevented}}});var _x=p(()=>{A();Ke();_d();gx();U.add(Cl);U.mixin(Mt,mx)});var $t,kr=p(()=>{"use strict";$t=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))($t||{})});var xx,yx=p(()=>{"use strict";xx={createCanvas:(s,t)=>{let e=document.createElement("canvas");return e.width=s,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")}});var bx,D,ct=p(()=>{yx();bx=xx,D={get(){return bx},set(s){bx=s}}});function Je(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function qn(s){return s.split("?")[0].split("#")[0]}function CA(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function PA(s,t,e){return s.replace(new RegExp(CA(t),"g"),e)}function MA(s,t){let e="",r=0,i=-1,n=0,o=-1;for(let a=0;a<=s.length;++a){if(a<s.length)o=s.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||n===1))if(i!==a-1&&n===2){if(e.length<2||r!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){let l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",r=0):(e=e.slice(0,l),r=e.length-1-e.lastIndexOf("/")),i=a,n=0;continue}}else if(e.length===2||e.length===1){e="",r=0,i=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",r=2)}else e.length>0?e+=`/${s.slice(i+1,a)}`:e=s.slice(i+1,a),r=a-i-1;i=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}var wt,Kr=p(()=>{ct();wt={toPosix(s){return PA(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){Je(s),s=this.toPosix(s);let t=/^file:\/\/\//.exec(s);if(t)return t[0];let e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(Je(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;let r=qn(this.toPosix(t??D.get().getBaseUrl())),i=qn(this.toPosix(e??this.rootname(r)));return s=this.toPosix(s),s.startsWith("/")?wt.join(i,s.slice(1)):this.isAbsolute(s)?s:this.join(r,s)},normalize(s){if(Je(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="",e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));let r=s.endsWith("/");return s=MA(s,!1),s.length>0&&r&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return Je(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e<s.length;++e){let r=s[e];if(Je(r),r.length>0)if(t===void 0)t=r;else{let i=s[e-1]??"";this.joinExtensions.includes(this.extname(i).toLowerCase())?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(Je(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0),e=t===47,r=-1,i=!0,n=this.getProtocol(s),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!i){r=a;break}}else i=!1;return r===-1?e?"/":this.isUrl(o)?n+s:n:e&&r===1?"//":n+s.slice(0,r)},rootname(s){Je(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){let e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){Je(s),t&&Je(t),s=qn(this.toPosix(s));let e=0,r=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let o=t.length-1,a=-1;for(n=s.length-1;n>=0;--n){let l=s.charCodeAt(n);if(l===47){if(!i){e=n+1;break}}else a===-1&&(i=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(r=n):(o=-1,r=a))}return e===r?r=a:r===-1&&(r=s.length),s.slice(e,r)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!i){e=n+1;break}}else r===-1&&(i=!1,r=n+1);return r===-1?"":s.slice(e,r)},extname(s){Je(s),s=qn(this.toPosix(s));let t=-1,e=0,r=-1,i=!0,n=0;for(let o=s.length-1;o>=0;--o){let a=s.charCodeAt(o);if(a===47){if(!i){e=o+1;break}continue}r===-1&&(i=!1,r=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||r===-1||n===0||n===1&&t===r-1&&t===e+1?"":s.slice(t,r)},parse(s){Je(s);let t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=qn(this.toPosix(s));let e=s.charCodeAt(0),r=this.isAbsolute(s),i,n="";t.root=this.rootname(s),r||this.hasProtocol(s)?i=1:i=0;let o=-1,a=0,l=-1,h=!0,u=s.length-1,c=0;for(;u>=i;--u){if(e=s.charCodeAt(u),e===47){if(!h){a=u+1;break}continue}l===-1&&(h=!1,l=u+1),e===46?o===-1?o=u: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&&r?t.base=t.name=s.slice(1,l):t.base=t.name=s.slice(a,l)):(a===0&&r?(t.name=s.slice(1,o),t.base=s.slice(1,l)):(t.name=s.slice(a,o),t.base=s.slice(a,l)),t.ext=s.slice(o,l)),t.dir=this.dirname(s),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]}});var fe,Kn=p(()=>{"use strict";fe=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(r=>typeof r=="string"||e?t(r):r):s)});function vx(s,t,e,r,i){let n=t[e];for(let o=0;o<n.length;o++){let a=n[o];e<t.length-1?vx(s.replace(r[e],a),t,e+1,r,i):i.push(s.replace(r[e],a))}}function Sx(s){let t=/\{(.*?)\}/g,e=s.match(t),r=[];if(e){let i=[];e.forEach(n=>{let o=n.substring(1,n.length-1).split(",");i.push(o)}),vx(s,i,0,e,r)}else r.push(s);return r}var Tx=p(()=>{"use strict"});var Bs,Pl=p(()=>{"use strict";Bs=s=>!Array.isArray(s)});function wA(s){return s.split(".").pop().split("?").shift().split("#").shift()}var Pe,Ti=p(()=>{pt();Kr();Kn();Tx();Pl();Pe=class{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){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??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{let e=t;this._defaultSearchParams=Object.keys(e).map(r=>`${encodeURIComponent(r)}=${encodeURIComponent(e[r])}`).join("&")}}getAlias(t){let{alias:e,src:r}=t;return fe(e||r,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>o?.src??o):n?.src?n.src:n,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&O("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){let r=[],i=e;Array.isArray(e)||(i=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),i.forEach(n=>{let o=n.src,a=n.alias,l;if(typeof a=="string"){let h=this._createBundleAssetId(t,a);r.push(h),l=[a,h]}else{let h=a.map(u=>this._createBundleAssetId(t,u));r.push(...h),l=[...a,...h]}this.add({...n,alias:l,src:o})}),this._bundles[t]=r}add(t){let e=[];Array.isArray(t)?e.push(...t):e.push(t);let r;r=n=>{this.hasKey(n)&&O(`[Resolver] already has key: ${n} overwriting`)},fe(e).forEach(n=>{let{src:o}=n,{data:a,format:l,loadParser:h,parser:u}=n,c=fe(o).map(g=>typeof g=="string"?Sx(g):Array.isArray(g)?g:[g]),f=this.getAlias(n);Array.isArray(f)?f.forEach(r):r(f);let d=[],m=g=>{let _=this._parsers.find(x=>x.test(g));return{src:g,..._?.parse(g)}};c.forEach(g=>{g.forEach(_=>{let x={};if(typeof _!="object"?x=m(_):(a=_.data??a,l=_.format??l,(_.loadParser||_.parser)&&(h=_.loadParser??h,u=_.parser??u),x={...m(_.src),..._}),!f)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:f,data:a,format:l,loadParser:h,parser:u,progressSize:n.progressSize}),d.push(x)})}),f.forEach(g=>{this._assetMap[g]=d})})}resolveBundle(t){let e=Bs(t);t=fe(t);let r={};return t.forEach(i=>{let n=this._bundles[i];if(n){let o=this.resolve(n),a={};for(let l in o){let h=o[l];a[this._extractAssetIdFromBundle(i,l)]=h}r[i]=a}}),e?r[t[0]]:r}resolveUrl(t){let e=this.resolve(t);if(typeof t!="string"){let r={};for(let i in e)r[i]=e[i].src;return r}return e.src}resolve(t){let e=Bs(t);t=fe(t);let r={};return t.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let n=this._assetMap[i],o=this._getPreferredOrder(n);o?.priority.forEach(a=>{o.params[a].forEach(l=>{let h=n.filter(u=>u[a]?u[a]===l:!1);h.length&&(n=h)})}),this._resolverHash[i]=n[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});r[i]=this._resolverHash[i]}),e?r[t[0]]:r}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){let r=t[e],i=this._preferredOrder.find(n=>n.params.format.includes(r.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;let e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){let{aliases:r,data:i,loadParser:n,parser:o,format:a,progressSize:l}=e;return(this._basePath||this._rootPath)&&(t.src=wt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=r??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...i||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??wA(t.src),l!==void 0&&(t.progressSize=l),t}};Pe.RETINA_PREFIX=/@([0-9\.]+)x/});var Zn,xd=p(()=>{"use strict";Zn=(s,t)=>{let e=t.split("?")[1];return e&&(s+=`?${e}`),s}});var Cx,yd,Px=p(()=>{te();ce();yt();Cx=class Jn{constructor(t,e){this.linkedSheets=[];let r=t;t?.source instanceof ut&&(r={texture:t,data:e});let{texture:i,data:n,cachePrefix:o=""}=r;this.cachePrefix=o,this._texture=i instanceof F?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=n;let a=parseFloat(n.meta.scale);a?(this.resolution=a,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Jn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let r=t,i=e?1/0:Jn.BATCH_SIZE;for(;r-t<i&&r<this._frameKeys.length;){let n=this._frameKeys[r],o=this._frames[n],a=o.frame;if(a){let l=null,h=null,u=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,c=new rt(0,0,Math.floor(u.w)/this.resolution,Math.floor(u.h)/this.resolution);o.rotated?l=new rt(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):l=new rt(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(h=new rt(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new F({source:this.textureSource,frame:l,orig:c,trim:h,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}r++}}_processAnimations(){let t=this.data.animations||{};for(let e in t){this.animations[e]=[];for(let r=0;r<t[e].length;r++){let i=t[e][r];this.animations[e].push(this.textures[i])}}}_parseComplete(){let t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Jn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Jn.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(let e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Cx.BATCH_SIZE=1e3;yd=Cx});function Mx(s,t,e){let r={};if(s.forEach(i=>{r[i]=t}),Object.keys(t.textures).forEach(i=>{r[`${t.cachePrefix}${i}`]=t.textures[i]}),!e){let i=wt.dirname(s[0]);t.linkedSheets.forEach((n,o)=>{let a=Mx([`${i}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(r,a)})}return r}var EA,wx,Ex=p(()=>{kr();Ti();xd();A();yt();Kr();Px();EA=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];wx={extension:y.Asset,cache:{test:s=>s instanceof yd,getCacheableAssets:(s,t)=>Mx(s,t,!1)},resolver:{extension:{type:y.ResolveParser,name:"resolveSpritesheet"},test:s=>{let e=s.split("?")[0].split("."),r=e.pop(),i=e.pop();return r==="json"&&EA.includes(i)},parse:s=>{let t=s.split(".");return{resolution:parseFloat(Pe.RETINA_PREFIX.exec(s)?.[1]??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:y.LoadParser,priority:$t.Normal,name:"spritesheetLoader"},async testParse(s,t){return wt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){let{texture:r,imageFilename:i,textureOptions:n,cachePrefix:o}=t?.data??{},a=wt.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(r instanceof F)l=r;else{let c=Zn(a+(i??s.meta.image),t.src);l=(await e.load([{src:c,data:n}]))[c]}let h=new yd({texture:l.source,data:s,cachePrefix:o});await h.parse();let u=s?.meta?.related_multi_packs;if(Array.isArray(u)){let c=[];for(let d of u){if(typeof d!="string")continue;let m=a+d;t.data?.ignoreMultiPack||(m=Zn(m,t.src),c.push(e.load({src:m,data:{textureOptions:n,ignoreMultiPack:!0}})))}let f=await Promise.all(c);h.linkedSheets=f,f.forEach(d=>{d.linkedSheets=[h].concat(h.linkedSheets.filter(m=>m!==d))})}return h},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}}});var Ml=p(()=>{A();Ex();U.add(wx)});function Ax(s,t,e){let{width:r,height:i}=e.orig,n=e.trim;if(n){let o=n.width,a=n.height;s.minX=n.x-t._x*r,s.maxX=s.minX+o,s.minY=n.y-t._y*i,s.maxY=s.minY+a}else s.minX=-t._x*r,s.maxX=s.minX+r,s.minY=-t._y*i,s.maxY=s.minY+i}var Bx=p(()=>{"use strict"});var Rs,bd=p(()=>{Vn();yt();Bx();Rt();ud();Rs=class s extends Si{constructor(t=F.EMPTY){t instanceof F&&(t={texture:t});let{texture:e=F.EMPTY,anchor:r,roundPixels:i,width:n,height:o,...a}=t;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Ct({_onUpdate:()=>{this.onViewUpdate()}}),r?this.anchor=r:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=i??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof F?new s(t):new s(F.from(t,e))}set texture(t){t||(t=F.EMPTY);let 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 Ax(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return N("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){let t=this._anchor,e=this._texture,r=this._bounds,{width:i,height:n}=e.orig;r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*n,r.maxY=r.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t?.texture){let r=typeof t=="boolean"?t:t?.textureSource;this._texture.destroy(r)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}});function wl(s,t,e){let r=AA;s.measurable=!0,ci(s,e,r),t.addBoundsMask(r),s.measurable=!1}var AA,vd=p(()=>{ie();Nn();AA=new ot});function El(s,t,e){let r=Te.get();s.measurable=!0;let i=Ut.get().identity(),n=Rx(s,e,i);fi(s,r,n),s.measurable=!1,t.addBoundsMask(r),Ut.return(i),Te.return(r)}function Rx(s,t,e){return s?(s!==t&&(Rx(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(O("Mask bounds, renderable is not inside the root container"),e)}var Sd=p(()=>{fl();vs();pt()});var Qn,Ix=p(()=>{A();bd();vd();Sd();Qn=class{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Rs),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||wl(this.mask,t,e)}addLocalBounds(t,e){El(this.mask,t,e)}containsPoint(t,e){let r=this.mask;return e(r,t)}destroy(){this.reset()}static test(t){return t instanceof Rs}};Qn.extension=y.MaskEffect});var to,Fx=p(()=>{A();to=class{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}};to.extension=y.MaskEffect});var eo,kx=p(()=>{A();Ke();vd();Sd();eo=class{constructor(t){this.priority=0,this.pipe="stencilMask",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){wl(this.mask,t,e)}addLocalBounds(t,e){El(this.mask,t,e)}containsPoint(t,e){let r=this.mask;return e(r,t)}destroy(){this.reset()}static test(t){return t instanceof Mt}};eo.extension=y.MaskEffect});var It,Zr=p(()=>{ct();A();ce();It=class extends ut{constructor(t){t.resource||(t.resource=D.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,r=this._resolution){let i=super.resize(t,e,r);return i&&this.resizeCanvas(),i}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}};It.extension=y.TextureSource});var xe,Ci=p(()=>{A();ce();xe=class extends ut{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}};xe.extension=y.TextureSource});async function Al(){return Td??(Td=(async()=>{let t=D.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";let e=await new Promise(o=>{let 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";let r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r);let i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,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);let n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(r),t.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Td}var Td,Cd=p(()=>{ct()});var Bl,Is,Pd=p(()=>{A();As();Cd();ce();Bl=class Lx extends ut{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Lx.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){let t=St.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;let t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await Al(),this._load=new Promise((r,i)=>{this.isValid?r(this):(this._resolve=r,this._reject=i,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){let t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){let t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();let t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(St.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||(St.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(St.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Bl.extension=y.TextureSource;Bl.defaultOptions={...ut.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Bl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};Is=Bl});var Md,ft,Pi=p(()=>{pt();Kn();Md=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){let e=this._cache.get(t);return e||O(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){let r=fe(t),i;for(let l=0;l<this.parsers.length;l++){let h=this.parsers[l];if(h.test(e)){i=h.getCacheableAssets(r,e);break}}let n=new Map(Object.entries(i||{}));i||r.forEach(l=>{n.set(l,e)});let o=[...n.keys()],a={cacheKeys:o,keys:r};r.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{let h=i?i[l]:e;this._cache.has(l)&&this._cache.get(l)!==h&&O("[Cache] already has key:",l),this._cache.set(l,n.get(l))})}remove(t){if(!this._cacheMap.has(t)){O(`[Assets] Asset id ${t} was not found in the Cache`);return}let 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}},ft=new Md});function Dx(s={}){let t=s&&s.resource,e=t?s.resource:s,r=t?s:{resource:s};for(let i=0;i<wd.length;i++){let n=wd[i];if(n.test(e))return new n(r)}throw new Error(`Could not find a source type for resource: ${r.resource}`)}function Ox(s={},t=!1){let e=s&&s.resource,r=e?s.resource:s,i=e?s:{resource:s};if(!t&&ft.has(r))return ft.get(r);let n=new F({source:Dx(i)});return n.on("destroy",()=>{ft.has(r)&&ft.remove(r)}),t||ft.set(r,n),n}function Gx(s,t=!1){return typeof s=="string"?ft.get(s):s instanceof ut?new F({source:s}):Ox(s,t)}var wd,Ed=p(()=>{Pi();A();ce();yt();wd=[];U.handleByList(y.TextureSource,wd);F.from=Gx;ut.from=Dx});var Rl=p(()=>{A();Ix();Fx();kx();Qc();Zr();Ci();Pd();Ed();U.add(Qn,to,eo,Is,xe,It,Ms)});function Ux(s){let t=D.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=s,e.fillRect(0,0,6,1),t}function Il(){if(Mi!==void 0)return Mi;try{let s=Ux("#ff00ff"),t=Ux("#ffff00"),r=D.get().createCanvas(6,1).getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(s,0,0),r.drawImage(t,2,0);let i=r.getImageData(2,0,1,1);if(!i)Mi=!1;else{let n=i.data;Mi=n[0]===255&&n[1]===0&&n[2]===0}}catch{Mi=!1}return Mi}var Mi,Ad=p(()=>{ct()});var K,wi=p(()=>{se();ct();mi();Ad();K={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Il(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{let t=s.source,e=t?.resource;if(!e)return null;let r=t.alphaMode==="premultiplied-alpha",i=t.resourceWidth??t.pixelWidth,n=t.resourceHeight??t.pixelHeight,o=i!==t.pixelWidth||n!==t.pixelHeight;if(r){if((e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)&&!o)return e;let a=K._unpremultipliedCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas}if(e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof ArrayBuffer){let a=K._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;let l=D.get().createCanvas(t.pixelWidth,t.pixelHeight),h=l.getContext("2d"),u=h.createImageData(t.pixelWidth,t.pixelHeight),c=u.data,f=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(t.format==="bgra8unorm")for(let d=0;d<c.length&&d+3<f.length;d+=4)c[d]=f[d+2],c[d+1]=f[d+1],c[d+2]=f[d],c[d+3]=f[d+3];else c.set(f.subarray(0,c.length));return h.putImageData(u,0,0),K._canvasSourceCache.set(t,{canvas:l,resourceId:t._resourceId}),l}if(r){let a=D.get().createCanvas(t.pixelWidth,t.pixelHeight),l=a.getContext("2d",{willReadFrequently:!0});a.width=t.pixelWidth,a.height=t.pixelHeight,l.drawImage(e,0,0);let h=l.getImageData(0,0,a.width,a.height),u=h.data;for(let c=0;c<u.length;c+=4){let f=u[c+3];if(f>0){let d=255/f;u[c]=Math.min(255,u[c]*d+.5),u[c+1]=Math.min(255,u[c+1]*d+.5),u[c+2]=Math.min(255,u[c+2]*d+.5)}}return l.putImageData(h,0,0),K._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){let a=K._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;let l=D.get().createCanvas(t.pixelWidth,t.pixelHeight),h=l.getContext("2d");return l.width=t.pixelWidth,l.height=t.pixelHeight,h.drawImage(e,0,0),K._canvasSourceCache.set(t,{canvas:l,resourceId:t._resourceId}),l}return e},getTintedCanvas:(s,t)=>{let e=s.texture,r=Z.shared.setValue(t).toHex(),i=e.tintCache||(e.tintCache={}),n=i[r],o=e.source._resourceId;if(n?.tintId===o)return n;let a=n&&"getContext"in n?n:D.get().createCanvas();if(K.tintMethod(e,t,a),a.tintId=o,K.convertTintToImage&&a.toDataURL!==void 0){let l=D.get().createImage();l.src=a.toDataURL(),l.tintId=o,i[r]=l}else i[r]=a;return i[r]},getTintedPattern:(s,t)=>{let e=Z.shared.setValue(t).toHex(),r=s.patternCache||(s.patternCache={}),i=s.source._resourceId,n=r[e];return n?.tintId===i||(K.canvas||(K.canvas=D.get().createCanvas()),K.tintMethod(s,t,K.canvas),n=K.canvas.getContext("2d").createPattern(K.canvas,"repeat"),n.tintId=i,r[e]=n),n},applyPatternTransform:(s,t,e=!0)=>{if(!t)return;let r=s;if(!r.setTransform)return;let i=globalThis.DOMMatrix;if(!i)return;let n=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);r.setTransform(e?n.inverse():n)},tintWithMultiply:(s,t,e)=>{let r=e.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;let a=Q.isVertical(o),l=a?i.height:i.width,h=a?i.width:i.height;e.width=Math.ceil(l),e.height=Math.ceil(h),r.save(),r.fillStyle=Z.shared.setValue(t).toHex(),r.fillRect(0,0,l,h),r.globalCompositeOperation="multiply";let u=K.getCanvasSource(s);if(!u){r.restore();return}o&&K._applyInverseRotation(r,o,i.width,i.height),r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithOverlay:(s,t,e)=>{let r=e.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;let a=Q.isVertical(o),l=a?i.height:i.width,h=a?i.width:i.height;e.width=Math.ceil(l),e.height=Math.ceil(h),r.save(),r.globalCompositeOperation="copy",r.fillStyle=Z.shared.setValue(t).toHex(),r.fillRect(0,0,l,h),r.globalCompositeOperation="destination-atop";let u=K.getCanvasSource(s);if(!u){r.restore();return}o&&K._applyInverseRotation(r,o,i.width,i.height),r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithPerPixel:(s,t,e)=>{let r=e.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;let a=Q.isVertical(o),l=a?i.height:i.width,h=a?i.width:i.height;e.width=Math.ceil(l),e.height=Math.ceil(h),r.save(),r.globalCompositeOperation="copy";let u=K.getCanvasSource(s);if(!u){r.restore();return}o&&K._applyInverseRotation(r,o,i.width,i.height),r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore();let c=t>>16&255,f=t>>8&255,d=t&255,m=r.getImageData(0,0,l,h),g=m.data;for(let _=0;_<g.length;_+=4)g[_]=g[_]*c/255,g[_+1]=g[_+1]*f/255,g[_+2]=g[_+2]*d/255;r.putImageData(m,0,0)},_applyInverseRotation:(s,t,e,r)=>{let i=Q.inv(t),n=Q.uX(i),o=Q.uY(i),a=Q.vX(i),l=Q.vY(i),h=-Math.min(0,n*e,a*r,n*e+a*r),u=-Math.min(0,o*e,l*r,o*e+l*r);s.transform(n,o,a,l,h,u)}};K.tintMethod=K.canUseMultiply?K.tintWithMultiply:K.tintWithPerPixel});var Bd,Lr,Fl=p(()=>{ct();ml();bs();Bd=class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){let r=D.get().createCanvas();r.width=t,r.height=e;let i=r.getContext("2d");return{canvas:r,context:i}}getOptimalCanvasAndContext(t,e,r=1){t=Math.ceil(t*r-1e-6),e=Math.ceil(e*r-1e-6),t=pi(t),e=pi(e);let i=(t<<17)+(e<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){let e=t.canvas,{width:r,height:i}=e,n=(r<<17)+(i<<1);t.context.resetTransform(),t.context.clearRect(0,0,r,i),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}},Lr=new Bd;Le.register(Lr)});function Vx(s,t,e,r,i,n){let o=s-e,a=t-r,l=i-e,h=n-r,u=o*l+a*h,c=l*l+h*h,f=-1;c!==0&&(f=u/c);let d,m;f<0?(d=e,m=r):f>1?(d=i,m=n):(d=e+f*l,m=r+f*h);let g=s-d,_=t-m;return g*g+_*_}var Nx=p(()=>{"use strict"});var kl,Hx=p(()=>{te();kl=class s{constructor(t=0,e=0,r=0){this.type="circle",this.x=t,this.y=e,this.radius=r}clone(){return new s(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;let r=this.radius*this.radius,i=this.x-t,n=this.y-e;return i*=i,n*=n,i+n<=r}strokeContains(t,e,r,i=.5){if(this.radius===0)return!1;let n=this.x-t,o=this.y-e,a=this.radius,l=(1-i)*r,h=Math.sqrt(n*n+o*o);return h<=a+l&&h>a-(r-l)}getBounds(t){return t||(t=new rt),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}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}});var Ll,zx=p(()=>{te();Ll=class s{constructor(t=0,e=0,r=0,i=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=r,this.halfHeight=i}clone(){return new s(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let r=(t-this.x)/this.halfWidth,i=(e-this.y)/this.halfHeight;return r*=r,i*=i,r+i<=1}strokeContains(t,e,r,i=.5){let{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;let a=r*(1-i),l=r-a,h=n-l,u=o-l,c=n+a,f=o+a,d=t-this.x,m=e-this.y,g=d*d/(h*h)+m*m/(u*u),_=d*d/(c*c)+m*m/(f*f);return g>1&&_<=1}getBounds(t){return t||(t=new rt),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}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}});var BA,RA,Ei,Wx=p(()=>{Rt();Nx();te();Ei=class s{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){let r=[];for(let i=0,n=e.length;i<n;i++)r.push(e[i].x,e[i].y);e=r}this.points=e,this.closePath=!0}isClockwise(){let t=0,e=this.points,r=e.length;for(let i=0;i<r;i+=2){let n=e[i],o=e[i+1],a=e[(i+2)%r],l=e[(i+3)%r];t+=(a-n)*(l+o)}return t<0}containsPolygon(t){let e=this.getBounds(BA),r=t.getBounds(RA);if(!e.containsRect(r))return!1;let i=t.points;for(let n=0;n<i.length;n+=2){let o=i[n],a=i[n+1];if(!this.contains(o,a))return!1}return!0}clone(){let t=this.points.slice(),e=new s(t);return e.closePath=this.closePath,e}contains(t,e){let r=!1,i=this.points.length/2;for(let n=0,o=i-1;n<i;o=n++){let a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],u=this.points[o*2+1];l>e!=u>e&&t<(h-a)*((e-l)/(u-l))+a&&(r=!r)}return r}strokeContains(t,e,r,i=.5){let n=r*r,o=n*(1-i),a=n-o,{points:l}=this,h=l.length-(this.closePath?0:2);for(let u=0;u<h;u+=2){let c=l[u],f=l[u+1],d=l[(u+2)%l.length],m=l[(u+3)%l.length],g=Vx(t,e,c,f,d,m),_=Math.sign((d-c)*(e-f)-(m-f)*(t-c));if(g<=(_<0?a:o))return!0}return!1}getBounds(t){t||(t=new rt);let e=this.points,r=1/0,i=-1/0,n=1/0,o=-1/0;for(let a=0,l=e.length;a<l;a+=2){let h=e[a],u=e[a+1];r=h<r?h:r,i=h>i?h:i,n=u<n?u:n,o=u>o?u:o}return t.x=r,t.width=i-r,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}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return N("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return N("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}});var Dl,Ol,Xx=p(()=>{te();Dl=(s,t,e,r,i,n,o)=>{let a=s-e,l=t-r,h=Math.sqrt(a*a+l*l);return h>=i-n&&h<=i+o},Ol=class s{constructor(t=0,e=0,r=0,i=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=r,this.height=i,this.radius=n}getBounds(t){return t||(t=new rt),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new s(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){let r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+r&&e<=this.y+this.height-r||t>=this.x+r&&t<=this.x+this.width-r)return!0;let i=t-(this.x+r),n=e-(this.y+r),o=r*r;if(i*i+n*n<=o||(i=t-(this.x+this.width-r),i*i+n*n<=o)||(n=e-(this.y+this.height-r),i*i+n*n<=o)||(i=t-(this.x+r),i*i+n*n<=o))return!0}return!1}strokeContains(t,e,r,i=.5){let{x:n,y:o,width:a,height:l,radius:h}=this,u=r*(1-i),c=r-u,f=n+h,d=o+h,m=a-h*2,g=l-h*2,_=n+a,x=o+l;return(t>=n-u&&t<=n+c||t>=_-c&&t<=_+u)&&e>=d&&e<=d+g||(e>=o-u&&e<=o+c||e>=x-c&&e<=x+u)&&t>=f&&t<=f+m?!0:t<f&&e<d&&Dl(t,e,f,d,h,c,u)||t>_-h&&e<d&&Dl(t,e,_-h,d,h,c,u)||t>_-h&&e>x-h&&Dl(t,e,_-h,x-h,h,c,u)||t<f&&e>x-h&&Dl(t,e,f,x-h,h,c,u)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}});function Gl(s,t){t.clear();let e=t.matrix;for(let r=0;r<s.length;r++){let i=s[r];if(i.globalDisplayStatus<7)continue;let n=i.renderGroup??i.parentRenderGroup;n?.isCachedAsTexture?t.matrix=jx.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n?._parentCacheAsTextureRenderGroup?t.matrix=jx.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):t.matrix=i.worldTransform,t.addBounds(i.bounds)}return t.matrix=e,t}var jx,Rd=p(()=>{nt();jx=new R});function Yx(s,t,e,r,i=!1){let n=IA;n.minX=0,n.minY=0,n.maxX=s.width/r|0,n.maxY=s.height/r|0;let o=Vt.getOptimalTexture(n.width,n.height,r,!1,i);return o.source.uploadMethodId="image",o.source.resource=s,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=t/r,o.frame.height=e/r,o.source.emit("update",o.source),o.updateUvs(),o}var IA,$x=p(()=>{_i();ie();IA=new ot});function qx(s){return typeof s.getCanvasFilterString=="function"}var Id,ro,Kx=p(()=>{A();wi();Fl();ie();Rd();$x();Id=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new ot,this.cssFilterString=""}},ro=class{constructor(t){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=t}push(t){let e=this._pushFilterFrame(),r=t.filterEffect.filters;if(e.skip=!1,e.useClip=!1,e.filters=r,e.container=t.container,e.cssFilterString="",r.every(l=>!l.enabled)){e.skip=!0;return}let i=[],n=1;for(let l of r){if(!l.enabled)continue;if(!qx(l)){this._warnUnsupportedFilter(l);continue}let h=l.getCanvasFilterString();if(h===null){this._warnUnsupportedFilter(l);continue}h&&i.push(h)}if(i.length===0&&n===1){e.skip=!0;return}e.cssFilterString=i.join(" "),this._calculateFilterArea(t,e.bounds),e.useClip=!!t.filterEffect.filterArea;let o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),e.useClip&&Number.isFinite(e.bounds.width)&&Number.isFinite(e.bounds.height)&&e.bounds.width>0&&e.bounds.height>0){let l=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(e.bounds.x*l,e.bounds.y*l,e.bounds.width*l,e.bounds.height*l),o.clip()}else e.useClip=!1;n!==1&&(this._alphaMultiplier*=n),e.cssFilterString&&(o.filter=a!=="none"?`${a} ${e.cssFilterString}`:e.cssFilterString)}pop(){let t=this._popFilterFrame();if(t.skip)return;let e=this._savedStates.pop();if(!e)return;let r=this.renderer.canvasContext.activeContext;t.useClip?r.restore():r.filter=e.filter,this._alphaMultiplier=e.alphaMultiplier}generateFilteredTexture({texture:t,filters:e}){if(!e?.length||e.every(x=>!x.enabled))return t;let r=[],i=1;for(let x of e){if(!x.enabled)continue;if(!qx(x)){this._warnUnsupportedFilter(x);continue}let S=x.getCanvasFilterString();if(S===null){this._warnUnsupportedFilter(x);continue}S&&r.push(S)}if(r.length===0&&i===1)return t;let n=K.getCanvasSource(t);if(!n)return t;let o=t.frame,a=t.source._resolution??t.source.resolution??1,l=o.width,h=o.height,u=Lr.getOptimalCanvasAndContext(l,h,a),{canvas:c,context:f}=u;f.setTransform(1,0,0,1,0,0),f.clearRect(0,0,c.width,c.height),r.length&&(f.filter=r.join(" ")),i!==1&&(f.globalAlpha=i);let d=o.x*a,m=o.y*a,g=l*a,_=h*a;return f.drawImage(n,d,m,g,_,0,0,g,_),f.filter="none",f.globalAlpha=1,Yx(c,l,h,a)}_calculateFilterArea(t,e){if(t.renderables?Gl(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){let i=(t.container.renderGroup||t.container.parentRenderGroup)?.cacheToLocalTransform;i&&e.applyMatrix(i)}}_warnUnsupportedFilter(t){let e=t?.constructor?.name||"Filter";this._warnedFilterTypes.has(e)||(this._warnedFilterTypes.add(e),console.warn(`CanvasRenderer: filter "${e}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new Id),this._filterStackIndex++,t}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}};ro.extension={type:[y.CanvasSystem],name:"filter"}});var so,Zx=p(()=>{A();so=class{constructor(t){this._renderer=t}push(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.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}};so.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"filter"}});function Dr(s,t){let e=Jx[s];return e===void 0&&(Fd[t]===void 0&&(Fd[t]=1),Jx[s]=e=Fd[t]++),e}var Fd,Jx,io=p(()=>{"use strict";Fd=Object.create(null),Jx=Object.create(null)});function Vl(){return(!Ul||Ul?.isContextLost())&&(Ul=D.get().createCanvas().getContext("webgl",{})),Ul}var Ul,kd=p(()=>{ct()});function Qx(){if(!Nl){Nl="mediump";let s=Vl();s&&s.getShaderPrecisionFormat&&(Nl=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Nl}var Nl,ty=p(()=>{kd()});function ey(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),`
18
+
19
+ #ifdef GL_ES // This checks if it is WebGL1
20
+ #define in varying
21
+ #define finalColor gl_FragColor
22
+ #define texture texture2D
23
+ #endif
24
+ ${s}
25
+ `):`
26
+
27
+ #ifdef GL_ES // This checks if it is WebGL1
28
+ #define in attribute
29
+ #define out varying
30
+ #endif
31
+ ${s}
32
+ `}var ry=p(()=>{"use strict"});function sy(s,t,e){let r=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let i=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i==="highp"&&r!=="highp"&&(i="mediump"),`precision ${i} float;
33
+ ${s}`}else if(r!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}var iy=p(()=>{"use strict"});function ny(s,t){return t?`#version 300 es
34
+ ${s}`:s}var oy=p(()=>{"use strict"});function ay(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";let r=e?FA:kA;return r[t]?(r[t]++,t+=`-${r[t]}`):r[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`}
35
+ ${s}`}var FA,kA,ly=p(()=>{"use strict";FA={},kA={}});function hy(s,t){return t?s.replace("#version 300 es",""):s}var uy=p(()=>{"use strict"});var Ld,no,cy,De,Fs=p(()=>{io();ty();ry();iy();oy();ly();uy();Ld={stripVersion:hy,ensurePrecision:sy,addProgramDefines:ey,setProgramName:ay,insertVersion:ny},no=Object.create(null),cy=class Dd{constructor(t){t={...Dd.defaultOptions,...t};let e=t.fragment.indexOf("#version 300 es")!==-1,r={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Qx()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e},i=t.fragment,n=t.vertex;Object.keys(Ld).forEach(o=>{let a=r[o];i=Ld[o](i,a,!0),n=Ld[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Dr(`${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,no[this._cacheKey]=null}static from(t){let e=`${t.vertex}:${t.fragment}`;return no[e]||(no[e]=new Dd(t),no[e]._cacheKey=e),no[e]}};cy.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};De=cy});function Or(s){return dy[s]??dy.float32}var dy,oo=p(()=>{"use strict";dy={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 py(s,t){let e;for(;(e=fy.exec(s))!==null;){let r=LA[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:r,stride:Or(r).stride,offset:0,instance:!1,start:0}}fy.lastIndex=0}function DA(s){return s.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function my({source:s,entryPoint:t}){let e={},r=DA(s),i=r.indexOf(`fn ${t}(`);if(i===-1)return e;let n=r.indexOf("->",i);if(n===-1)return e;let o=r.substring(i,n);if(py(o,e),Object.keys(e).length===0){let a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){let l=a[1],h=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),u=r.match(h);u&&py(u[1],e)}}return e}var LA,fy,gy=p(()=>{oo();LA={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",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},fy=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g});function Hl(s){let t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,r=/@binding\((\d+)\)/,i=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,h=s.match(t)?.map(c=>({group:parseInt(c.match(e)[1],10),binding:parseInt(c.match(r)[1],10),name:c.match(i)[2],isUniform:c.match(i)[1]==="<uniform>",type:c.match(n)[1]}));if(!h)return{groups:[],structs:[]};let u=s.match(o)?.map(c=>{let f=c.match(l)[1],d=c.match(a).reduce((m,g)=>{let[_,x]=g.split(":");return m[_.trim()]=x.trim(),m},{});return d?{name:f,members:d}:null}).filter(({name:c})=>h.some(f=>f.type===c||f.type.includes(`<${c}>`)))??[];return{groups:h,structs:u}}var _y=p(()=>{"use strict"});var Jr,xy=p(()=>{"use strict";Jr=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(Jr||{})});function yy({groups:s}){let t=[];for(let e=0;e<s.length;e++){let r=s[e];t[r.group]||(t[r.group]=[]),r.isUniform?t[r.group].push({binding:r.binding,visibility:Jr.VERTEX|Jr.FRAGMENT,buffer:{type:"uniform"}}):r.type==="sampler"?t[r.group].push({binding:r.binding,visibility:Jr.FRAGMENT,sampler:{type:"filtering"}}):r.type==="texture_2d"||r.type.startsWith("texture_2d<")?t[r.group].push({binding:r.binding,visibility:Jr.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):r.type==="texture_2d_array"||r.type.startsWith("texture_2d_array<")?t[r.group].push({binding:r.binding,visibility:Jr.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(r.type==="texture_cube"||r.type.startsWith("texture_cube<"))&&t[r.group].push({binding:r.binding,visibility:Jr.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}var by=p(()=>{xy()});function vy({groups:s}){let t=[];for(let e=0;e<s.length;e++){let r=s[e];t[r.group]||(t[r.group]={}),t[r.group][r.name]=r.binding}return t}var Sy=p(()=>{"use strict"});function Ty(s,t){let e=new Set,r=new Set,i=[...s.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),n=[...s.groups,...t.groups].filter(o=>{let a=`${o.name}-${o.binding}`;return r.has(a)?!1:(r.add(a),!0)});return{structs:i,groups:n}}var Cy=p(()=>{"use strict"});var ao,Oe,Ai=p(()=>{io();gy();_y();by();Sy();Cy();ao=Object.create(null),Oe=class s{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;let{fragment:e,vertex:r,layout:i,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=r,e.source===r.source){let a=Hl(e.source);this.structsAndGroups=a}else{let a=Hl(r.source),l=Hl(e.source);this.structsAndGroups=Ty(a,l)}this.layout=i??vy(this.structsAndGroups),this.gpuLayout=n??yy(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){let{vertex:t,fragment:e}=this,r=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Dr(r,"program")}get attributeData(){return this._attributeData??(this._attributeData=my(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,ao[this._cacheKey]=null}static from(t){let e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return ao[e]||(ao[e]=new s(t),ao[e]._cacheKey=e),ao[e]}}});var ne,ks=p(()=>{"use strict";ne=class{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(let r in t){let i=t[r];this.setResource(i,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;let t=[],e=0;for(let r in this.resources)t[e++]=this.resources[r]._resourceId;this._key=t.join("|")}setResource(t,e){let r=this.resources[e];t!==r&&(r?.off?.("change",this.onResourceChange,this),t.on?.("change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){let r=this.resources;for(let i in r)r[i]._gcLastUsed=t,r[i]._touched=e}destroy(){let t=this.resources;for(let e in t)t[e]?.off?.("change",this.onResourceChange,this);this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}});var qt,Gr=p(()=>{"use strict";qt=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.CANVAS=4]="CANVAS",s[s.BOTH=3]="BOTH",s))(qt||{})});var Od,Py,My=p(()=>{"use strict";Od=["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>"],Py=Od.reduce((s,t)=>(s[t]=!0,s),{})});function wy(s,t){switch(s){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 Ey=p(()=>{"use strict"});var Ay,Nt,Qe=p(()=>{Gt();io();My();Ey();Ay=class By{constructor(t,e){this._touched=0,this.uid=$("uniform"),this._resourceType="uniformGroup",this._resourceId=$("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...By.defaultOptions,...e},this.uniformStructures=t;let r={};for(let i in t){let n=t[i];if(n.name=i,n.size=n.size??1,!Py[n.type]){let o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){let[,a,l]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${l} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Od.join(", ")}`)}n.value??(n.value=wy(n.type,n.size)),r[i]=n.value}this.uniforms=r,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Dr(Object.keys(r).map(i=>`${i}-${t[i].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ay.defaultOptions={ubo:!1,isStatic:!1};Nt=Ay});var oe,Qr=p(()=>{Qt();Gt();Fs();ks();Ai();Gr();Qe();oe=class s extends q{constructor(t){super(),this.uid=$("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:r,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=r,o===void 0&&(o=0,e&&(o|=qt.WEBGPU),r&&(o|=qt.WEBGL)),this.compatibleRenderers=o;let l={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&i&&a)for(let h in a)for(let u in a[h]){let c=a[h][u];l[c]={group:h,binding:u,name:c}}else if(e&&i&&!a){let h=e.structsAndGroups.groups;a={},h.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,l[u.name]=u})}else if(n){i={},a={},e&&e.structsAndGroups.groups.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,l[c.name]=c});let h=0;for(let u in n)l[u]||(i[99]||(i[99]=new ne,this._ownedBindGroups.push(i[99])),l[u]={group:99,binding:h,name:u},a[99]=a[99]||{},a[99][h]=u,h++);for(let u in n){let c=u,f=n[u];!f.source&&!f._resourceType&&(f=new Nt(f));let d=l[c];d&&(i[d.group]||(i[d.group]=new ne,this._ownedBindGroups.push(i[d.group])),i[d.group].setResource(f,d.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,l)}addResource(t,e,r){var i,n;(i=this._uniformBindMap)[e]||(i[e]={}),(n=this._uniformBindMap[e])[r]||(n[r]=t),this.groups[e]||(this.groups[e]=new ne,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){let r={};for(let i in e){let n=e[i];Object.defineProperty(r,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return r}destroy(t=!1){this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(e=>{e.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){let{gpu:e,gl:r,...i}=t,n,o;return e&&(n=Oe.from(e)),r&&(o=De.from(r)),new s({gpuProgram:n,glProgram:o,...i})}}});var OA,Gd,Ud,Vd,Nd,Hd,zd,Wd,Kt,hr=p(()=>{"use strict";OA={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},Gd=0,Ud=1,Vd=2,Nd=3,Hd=4,zd=5,Wd=class Ry{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Gd)}set blend(t){!!(this.data&1<<Gd)!==t&&(this.data^=1<<Gd)}get offsets(){return!!(this.data&1<<Ud)}set offsets(t){!!(this.data&1<<Ud)!==t&&(this.data^=1<<Ud)}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<<Vd)}set culling(t){!!(this.data&1<<Vd)!==t&&(this.data^=1<<Vd)}get depthTest(){return!!(this.data&1<<Nd)}set depthTest(t){!!(this.data&1<<Nd)!==t&&(this.data^=1<<Nd)}get depthMask(){return!!(this.data&1<<zd)}set depthMask(t){!!(this.data&1<<zd)!==t&&(this.data^=1<<zd)}get clockwiseFrontFace(){return!!(this.data&1<<Hd)}set clockwiseFrontFace(t){!!(this.data&1<<Hd)!==t&&(this.data^=1<<Hd)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=OA[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){let t=new Ry;return t.depthTest=!1,t.blend=!0,t}};Wd.default2d=Wd.for2d();Kt=Wd});var Iy,zl,jd=p(()=>{Fs();Ai();Qr();hr();Iy=class Xd extends oe{constructor(t){t={...Xd.defaultOptions,...t},super(t),this.enabled=!0,this._state=Kt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,r,i){t.applyFilter(this,e,r,i)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){let{gpu:e,gl:r,...i}=t,n,o;return e&&(n=Oe.from(e)),r&&(o=De.from(r)),new Xd({gpuProgram:n,glProgram:o,...i})}};Iy.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};zl=Iy});var Fy,ky=p(()=>{Fy=`in vec2 aPosition;
36
+ out vec2 vTextureCoord;
37
+
38
+ uniform vec4 uInputSize;
39
+ uniform vec4 uOutputFrame;
40
+ uniform vec4 uOutputTexture;
41
+
42
+ vec4 filterVertexPosition( void )
43
+ {
44
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
45
+
46
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
47
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
48
+
49
+ return vec4(position, 0.0, 1.0);
50
+ }
51
+
52
+ vec2 filterTextureCoord( void )
53
+ {
54
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
55
+ }
56
+
57
+ void main(void)
58
+ {
59
+ gl_Position = filterVertexPosition();
60
+ vTextureCoord = filterTextureCoord();
61
+ }
62
+ `});var Ly,Dy=p(()=>{Ly=`in vec2 vTextureCoord;
63
+ out vec4 finalColor;
64
+ uniform sampler2D uTexture;
65
+ void main() {
66
+ finalColor = texture(uTexture, vTextureCoord);
67
+ }
68
+ `});var Yd,Oy=p(()=>{Yd=`struct GlobalFilterUniforms {
69
+ uInputSize: vec4<f32>,
70
+ uInputPixel: vec4<f32>,
71
+ uInputClamp: vec4<f32>,
72
+ uOutputFrame: vec4<f32>,
73
+ uGlobalFrame: vec4<f32>,
74
+ uOutputTexture: vec4<f32>,
75
+ };
76
+
77
+ @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
78
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
79
+ @group(0) @binding(2) var uSampler: sampler;
80
+
81
+ struct VSOutput {
82
+ @builtin(position) position: vec4<f32>,
83
+ @location(0) uv: vec2<f32>
84
+ };
85
+
86
+ fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
87
+ {
88
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
89
+
90
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
91
+ position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
92
+
93
+ return vec4(position, 0.0, 1.0);
94
+ }
95
+
96
+ fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
97
+ {
98
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
99
+ }
100
+
101
+ @vertex
102
+ fn mainVertex(
103
+ @location(0) aPosition: vec2<f32>,
104
+ ) -> VSOutput {
105
+ return VSOutput(
106
+ filterVertexPosition(aPosition),
107
+ filterTextureCoord(aPosition)
108
+ );
109
+ }
110
+
111
+ @fragment
112
+ fn mainFragment(
113
+ @location(0) uv: vec2<f32>,
114
+ ) -> @location(0) vec4<f32> {
115
+ return textureSample(uTexture, uSampler, uv);
116
+ }
117
+ `});var Wl,Gy=p(()=>{Fs();Ai();jd();ky();Dy();Oy();Wl=class extends zl{constructor(){let t=Oe.from({vertex:{source:Yd,entryPoint:"mainVertex"},fragment:{source:Yd,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=De.from({vertex:Fy,fragment:Ly,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}});var xt,Ls=p(()=>{"use strict";xt=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(xt||{})});var pe,Bi=p(()=>{Qt();Gt();Ls();pe=class extends q{constructor(t){let{data:e,size:r}=t,{usage:i,label:n,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=$("buffer"),this._resourceType="buffer",this._resourceId=$("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,r??(r=e?.byteLength);let a=!!e;this.descriptor={size:r,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=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&xt.STATIC)}set static(t){t?this.descriptor.usage|=xt.STATIC:this.descriptor.usage&=~xt.STATIC}setDataWithSize(t,e,r){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){r&&this.emit("update",this);return}let i=this._data;if(this._data=t,this._dataInt32=null,!i||i.length!==t.length){!this.shrinkToFit&&i&&t.byteLength<i.byteLength?r&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=$("resource"),this.emit("change",this));return}r&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}unload(){this.emit("unload",this);for(let t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}});function $d(s,t){if(!(s instanceof pe)){let e=t?xt.INDEX:xt.VERTEX;s instanceof Array&&(t?(s=new Uint32Array(s),e=xt.INDEX|xt.COPY_DST):(s=new Float32Array(s),e=xt.VERTEX|xt.COPY_DST)),s=new pe({data:s,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return s}var Uy=p(()=>{Bi();Ls()});function Vy(s,t,e){let r=s.getAttribute(t);if(!r)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;let i=r.buffer.data,n=1/0,o=1/0,a=-1/0,l=-1/0,h=i.BYTES_PER_ELEMENT,u=(r.offset||0)/h,c=(r.stride||8)/h;for(let f=u;f<i.length;f+=c){let d=i[f],m=i[f+1];d>a&&(a=d),m>l&&(l=m),d<n&&(n=d),m<o&&(o=m)}return e.minX=n,e.minY=o,e.maxX=a,e.maxY=l,e}var Ny=p(()=>{"use strict"});function GA(s){return(s instanceof pe||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=$d(s.buffer,!1),s}var ts,Xl=p(()=>{Qt();ie();Gt();Bi();Uy();Ny();ts=class extends q{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=$("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new ot,this._boundsDirty=!0;let{attributes:e,indexBuffer:r,topology:i}=t;if(this.buffers=[],this.attributes={},e)for(let n in e)this.addAttribute(n,e[n]);this.instanceCount=t.instanceCount??1,r&&this.addIndex(r),this.topology=i||"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(let t in this.attributes){let e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){let r=GA(e);this.buffers.indexOf(r.buffer)===-1&&(this.buffers.push(r.buffer),r.buffer.on("update",this.onBufferUpdate,this),r.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=r}addIndex(t){this.indexBuffer=$d(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Vy(this,"aPosition",this._bounds)):this._bounds}unload(){this.emit("unload",this);for(let t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(e=>e.destroy()),this.unload(),this.indexBuffer?.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}});var UA,qd,lo,Hy=p(()=>{A();Gy();nt();ks();Xl();Qe();yt();_i();Gr();ie();Rd();pt();UA=new ts({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),qd=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}},lo=class{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 ne({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=r,i.container=t.container,i.outputRenderSurface=e.renderTarget.renderSurface;let n=e.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(r.every(d=>!d.enabled)){i.skip=!0;return}let l=i.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(i,e.renderTarget.rootViewPort,a,o,1),i.skip)return;let h=this._getPreviousFilterData(),u=this._findFilterResolution(o),c=0,f=0;h&&(c=h.bounds.minX,f=h.bounds.minY),this._calculateGlobalFrame(i,c,f,u,n.width,n.height),this._setupFilterTextures(i,l,e,h)}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=e;let i=t.source,n=i.resolution,o=i.antialias;if(e.every(d=>!d.enabled))return r.skip=!0,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,o,n,0),r.skip)return t;let l=n;this._calculateGlobalFrame(r,0,0,l,i.width,i.height),r.outputRenderSurface=Vt.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=F.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);let f=r.outputRenderSurface;return f.source.alphaMode="premultiplied-alpha",f}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&Vt.returnTexture(e.backTexture),Vt.returnTexture(e.inputTexture))}getBackTexture(t,e,r){let i=t.colorTexture.source._resolution,n=Vt.getOptimalTexture(e.width,e.height,i,!1),o=e.minX,a=e.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*i),a=Math.floor(a*i);let l=Math.ceil(e.width*i),h=Math.ceil(e.height*i);return this.renderer.renderTarget.copyToTexture(t,n,{x:o,y:a},{width:l,height:h},{x:0,y:0}),n}applyFilter(t,e,r,i){let n=this.renderer,o=this._activeFilterData,l=o.outputRenderSurface===r,h=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(h),c=0,f=0;if(l){let m=this._findPreviousFilterOffset();c=m.x,f=m.y}this._updateFilterUniforms(e,r,o,c,f,u,l,i);let d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,n)}calculateSpriteMatrix(t,e){let r=this._activeFilterData,i=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=e.worldTransform.copyTo(R.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/e.texture.orig.width,1/e.texture.orig.height),i.translate(e.anchor.x,e.anchor.y),i}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Wl),this._passthroughFilter}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){let i=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:UA,shader:t,state:t._state,topology:"triangle-list"}),r.type===qt.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,r,i){if(t.backTexture=F.EMPTY,t.inputTexture=Vt.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){r.renderTarget.finishRenderPass();let n=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,i?.bounds)}r.renderTarget.bind(t.inputTexture,!0),r.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,r,i,n,o){let a=t.globalFrame;a.x=e*i,a.y=r*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(t,e,r,i,n,o,a,l){let h=this._filterGlobalUniforms.uniforms,u=h.uOutputFrame,c=h.uInputSize,f=h.uInputPixel,d=h.uInputClamp,m=h.uGlobalFrame,g=h.uOutputTexture;a?(u[0]=r.bounds.minX-i,u[1]=r.bounds.minY-n):(u[0]=0,u[1]=0),u[2]=t.frame.width,u[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],f[0]=t.source.pixelWidth,f[1]=t.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=t.frame.width*c[2]-.5*f[2],d[3]=t.frame.height*c[3]-.5*f[3];let _=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=i*o,m[1]=n*o,m[2]=_.source.width*o,m[3]=_.source.height*o,e instanceof F&&(e.source.resource=null);let x=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof F?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=x.width,g[1]=x.height),g[2]=x.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,r=this._filterStackIndex;for(;r>0;){r--;let i=this._filterStack[r];if(!i.skip){t=i.bounds.minX,e=i.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Gl(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){let i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){let r=t.inputTexture,i=t.bounds,n=t.filters,o=t.firstEnabledIndex,a=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o===a)n[o].apply(this,r,t.outputRenderSurface,e);else{let l=t.inputTexture,h=Vt.getOptimalTexture(i.width,i.height,l.source._resolution,!1),u=h;for(let c=o;c<a;c++){let f=n[c];if(!f.enabled)continue;f.apply(this,l,u,!0);let d=l;l=u,u=d}n[a].apply(this,l,t.outputRenderSurface,e),Vt.returnTexture(h)}}_calculateFilterBounds(t,e,r,i,n){let o=this.renderer,a=t.bounds,l=t.filters,h=1/0,u=0,c=!0,f=!1,d=!1,m=!0,g=-1,_=-1;for(let x=0;x<l.length;x++){let S=l[x];if(!S.enabled)continue;if(g===-1&&(g=x),_=x,h=Math.min(h,S.resolution==="inherit"?i:S.resolution),u+=S.padding,S.antialias==="off"?c=!1:S.antialias==="inherit"&&c&&(c=r),S.clipToViewport||(m=!1),!!!(S.compatibleRenderers&o.type)){d=!1;break}if(S.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){O("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=!0,f||(f=S.blendRequired)}if(!d){t.skip=!0;return}if(m&&a.fitBounds(0,e.width/i,0,e.height/i),a.scale(h).ceil().scale(1/h).pad((u|0)*n),!a.isPositive){t.skip=!0;return}t.antialias=c,t.resolution=h,t.blendRequired=f,t.firstEnabledIndex=g,t.lastEnabledIndex=_}_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 qd),this._filterStackIndex++,t}};lo.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"filter"}});var Kd=p(()=>{A();Kx();Zx();Hy();U.add(lo,ro);U.add(so)});var VA={};var zy=p(()=>{cx();fx();_x();Ml();Rl();Kd()});var Wy,Xy=p(()=>{A();Wy={extension:{type:y.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>(zy(),VA))}}});var NA={};var jy=p(()=>{Ml();Rl();Kd()});var Yy,$y=p(()=>{A();Yy={extension:{type:y.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(jy(),NA))}}});async function qy(s){if(!s)for(let t=0;t<Zd.length;t++){let e=Zd[t];if(e.value.test()){await e.value.load();return}}}var Zd,Ky=p(()=>{A();Zd=[];U.handleByNamedList(y.Environment,Zd)});function jl(){if(typeof ho=="boolean")return ho;try{ho=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ho=!1}return ho}var ho,Jd=p(()=>{"use strict"});function Zl(s,t,e=2){let r=t&&t.length,i=r?t[0]*e:s.length;po.size&&po.clear();let n=tb(s,0,i,e,!0),o=[];if(!n||n.next===n.prev)return o;let a=0,l=0,h=0;if(r&&(n=jA(s,t,n,e)),s.length>80*e){a=s[0],l=s[1];let u=a,c=l;for(let f=e;f<i;f+=e){let d=s[f],m=s[f+1];d<a&&(a=d),m<l&&(l=m),d>u&&(u=d),m>c&&(c=m)}h=Math.max(u-a,c-l),h=h!==0?32767/h:0}return tf(n,o,a,l,h),o}function tb(s,t,e,r,i){let n=null;if(i===nB(s,t,e,r)>0)for(let o=t;o<e;o+=r)n=Qy(o/r|0,s[o],s[o+1],n);else for(let o=e-r;o>=t;o-=r)n=Qy(o/r|0,s[o],s[o+1],n);return n&&mo(n,n.next)&&(_o(n),n=n.next),n}function Os(s,t=s){let e=t===s,r=s,i;do i=!1,r!==r.next&&(po.size===0||!po.has(r))&&(mo(r,r.next)||Ht(r.prev,r,r.next)===0)?((e||r===t)&&(t=r.prev),Qd=!0,_o(r),r=r.prev,i=!0):(e||r!==t)&&(r=r.next,i=!e);while(i||r!==t);return t}function tf(s,t,e,r,i){i&&QA(s,e,r,i);let n=s,o=!1;for(;s.prev!==s.next;){let a=s.prev,l=s.next;if(Ht(a,s,l)<0&&(i?zA(s,e,r,i):HA(s))){t.push(a.i,s.i,l.i),_o(s),s=l,n=l;continue}if(s=l,s===n){if(Qd=!1,s=Os(s),Qd){n=s;continue}if(!o){s=WA(s,t),n=s,o=!0;continue}XA(s,t,e,r,i);break}}}function HA(s){let t=s.prev,e=s,r=s.next,i=t.x,n=e.x,o=r.x,a=t.y,l=e.y,h=r.y,u=Math.min(i,n,o),c=Math.min(a,l,h),f=Math.max(i,n,o),d=Math.max(a,l,h),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=c&&m.y<=d&&!(i===m.x&&a===m.y)&&Kl(i,a,n,l,o,h,m.x,m.y)&&Ht(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function zA(s,t,e,r){let i=s.prev,n=s,o=s.next,a=i.x,l=n.x,h=o.x,u=i.y,c=n.y,f=o.y,d=Math.min(a,l,h),m=Math.min(u,c,f),g=Math.max(a,l,h),_=Math.max(u,c,f),x=nf(d,m,t,e,r),S=nf(g,_,t,e,r),v=s.prevZ;for(;v&&v.z>=x;){if(v.x>=d&&v.x<=g&&v.y>=m&&v.y<=_&&v!==o&&!(a===v.x&&u===v.y)&&Kl(a,u,l,c,h,f,v.x,v.y)&&Ht(v.prev,v,v.next)>=0)return!1;v=v.prevZ}let b=s.nextZ;for(;b&&b.z<=S;){if(b.x>=d&&b.x<=g&&b.y>=m&&b.y<=_&&b!==o&&!(a===b.x&&u===b.y)&&Kl(a,u,l,c,h,f,b.x,b.y)&&Ht(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function WA(s,t){let e=s,r=!1;do{let i=e.prev,n=e.next.next;sb(i,e,e.next,n,!1)&&go(i,n)&&go(n,i)&&(t.push(i.i,e.i,n.i),_o(e),_o(e.next),e=s=n,r=!0),e=e.next}while(e!==s);return r?Os(e):e}function XA(s,t,e,r,i){let n=s;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&rB(n,o)){let a=ib(n,o);n=Os(n,n.next),a=Os(a,a.next),tf(n,t,e,r,i),tf(a,t,e,r,i);return}o=o.next}n=n.next}while(n!==s)}function jA(s,t,e,r){let i=[];for(let n=0,o=t.length;n<o;n++){let a=t[n]*r,l=n<o-1?t[n+1]*r:s.length,h=tb(s,a,l,r,!1);h===h.next&&po.add(h),i.push(eB(h))}i.sort(YA),qA(s.length/r,t.length),rb(e,e),ef=!0;for(let n=0;n<i.length;n++)e=$A(i[n],e);return ef=!1,Os(e)}function YA(s,t){return s.x-t.x||s.y-t.y||(s.next.y-s.y)/(s.next.x-s.x)-(t.next.y-t.y)/(t.next.x-t.x)}function $A(s,t){let e=ZA(s,t);if(!e)return t;let r=ib(e,s),i=r.next;return rb(e,i.next),Os(r,r.next),Os(e,e.next)}function qA(s,t){let e=Math.ceil((s+2*t)/eb)+t+2;Ft.length<e*4&&(Ft=new Float64Array(e*4)),ql=0}function rb(s,t){let e=s;do{let r=ql++;rf[r]=e;let i=1/0,n=1/0,o=-1/0,a=-1/0,l=0;do{let u=e.next;e.z=r,e.x<i&&(i=e.x),e.x>o&&(o=e.x),e.y<n&&(n=e.y),e.y>a&&(a=e.y),u.x<i&&(i=u.x),u.x>o&&(o=u.x),u.y<n&&(n=u.y),u.y>a&&(a=u.y),e=u}while(++l<eb&&e!==t);sf[r]=e;let h=r*4;Ft[h]=i,Ft[h+1]=n,Ft[h+2]=o,Ft[h+3]=a}while(e!==t)}function KA(s,t){let e=s.z*4;t.x<Ft[e]&&(Ft[e]=t.x),t.y<Ft[e+1]&&(Ft[e+1]=t.y),t.x>Ft[e+2]&&(Ft[e+2]=t.x),t.y>Ft[e+3]&&(Ft[e+3]=t.y)}function Zy(s){let t=sf[s];for(;t.prev.next!==t;)t=t.next;return sf[s]=t,t}function Jy(s){let t=rf[s];for(;t.prev.next!==t;)t=t.next;return rf[s]=t,t}function ZA(s,t){let e=t,r=s.x,i=s.y,n=-1/0,o;if(mo(s,e))return e;for(let f=0,d=0;f<ql;f++,d+=4){if(i<Ft[d+1]||i>Ft[d+3]||Ft[d]>r||Ft[d+2]<=n)continue;let m=Zy(f);e=Jy(f);do{if(e.prev.next===e){if(mo(s,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let g=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(g<=r&&g>n&&(n=g,o=e.x<e.next.x?e:e.next,g===r))return o}}e=e.next}while(e!==m)}if(!o)return null;let a=o.x,l=o.y,h=Math.min(i,l),u=Math.max(i,l),c=1/0;for(let f=0,d=0;f<ql;f++,d+=4){if(Ft[d+2]<a||Ft[d]>r||Ft[d+3]<h||Ft[d+1]>u)continue;let m=Zy(f);e=Jy(f);do{if(e.prev.next===e&&r>=e.x&&e.x>=a&&r!==e.x&&Kl(i<l?r:n,i,a,l,i<l?n:r,i,e.x,e.y)){let g=Math.abs(i-e.y)/(r-e.x);(go(e,s)||e.y===i&&e.next.y===i&&e.next.x>r)&&(g<c||g===c&&(e.x>o.x||e.x===o.x&&JA(o,e)))&&(o=e,c=g)}e=e.next}while(e!==m)}return o}function JA(s,t){return Ht(s.prev,s,t.prev)<0&&Ht(t.next,s,s.next)<0}function QA(s,t,e,r){let i=s,n=0;do i.z=nf(i.x,i.y,t,e,r),Ge[n++]=i,i=i.next;while(i!==s);tB(n);let o=null;for(let a=0;a<n;a++){let l=Ge[a];l.prevZ=o,o&&(o.nextZ=l),o=l}o.nextZ=null}function tB(s){if(s<=32){for(let t=1;t<s;t++){let e=Ge[t],r=e.z,i=t-1;for(;i>=0&&Ge[i].z>r;)Ge[i+1]=Ge[i],i--;Ge[i+1]=e}return}Ds.length<s&&(Ds=new Uint32Array(s),co=new Uint32Array(s),uo=new Array(s));for(let t=0;t<s;t++)Ds[t]=Ge[t].z;Yl(s,Ge,Ds,uo,co,0),Yl(s,uo,co,Ge,Ds,8),Yl(s,Ge,Ds,uo,co,16),Yl(s,uo,co,Ge,Ds,24)}function Yl(s,t,e,r,i,n){fo.fill(0);for(let a=0;a<s;a++)fo[e[a]>>>n&255]++;let o=0;for(let a=0;a<256;a++){let l=fo[a];fo[a]=o,o+=l}for(let a=0;a<s;a++){let l=e[a],h=fo[l>>>n&255]++;r[h]=t[a],i[h]=l}}function nf(s,t,e,r,i){return s=(s-e)*i|0,t=(t-r)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function eB(s){let t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function Kl(s,t,e,r,i,n,o,a){return(i-o)*(t-a)>=(s-o)*(n-a)&&(s-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(i-o)*(r-a)}function rB(s,t){let e=mo(s,t)&&Ht(s.prev,s,s.next)>0&&Ht(t.prev,t,t.next)>0;return s.next.i!==t.i&&(e||go(s,t)&&go(t,s)&&(Ht(s.prev,s,t.prev)!==0||Ht(s,t.prev,t)!==0))&&!sB(s,t)&&(e||iB(s,t))}function Ht(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function mo(s,t){return s.x===t.x&&s.y===t.y}function sb(s,t,e,r,i=!0){let n=Ht(s,t,e),o=Ht(s,t,r),a=Ht(e,r,s),l=Ht(e,r,t);return(n>0&&o<0||n<0&&o>0)&&(a>0&&l<0||a<0&&l>0)?!0:i?!!(n===0&&$l(s,e,t)||o===0&&$l(s,r,t)||a===0&&$l(e,s,r)||l===0&&$l(e,t,r)):!1}function $l(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function sB(s,t){let e=Math.min(s.x,t.x),r=Math.max(s.x,t.x),i=Math.min(s.y,t.y),n=Math.max(s.y,t.y),o=s;do{let a=o.next;if(o.x>r&&a.x>r||o.x<e&&a.x<e||o.y>n&&a.y>n||o.y<i&&a.y<i){o=a;continue}if(o.i!==s.i&&a.i!==s.i&&o.i!==t.i&&a.i!==t.i&&sb(o,a,s,t))return!0;o=a}while(o!==s);return!1}function go(s,t){return Ht(s.prev,s,s.next)<0?Ht(s,t,s.next)>=0&&Ht(s,s.prev,t)>=0:Ht(s,t,s.prev)<0||Ht(s,s.next,t)<0}function iB(s,t){let e=s,r=!1,i=(s.x+t.x)/2,n=(s.y+t.y)/2;do{let o=e.next;e.y>n!=o.y>n&&i<(o.x-e.x)*(n-e.y)/(o.y-e.y)+e.x&&(r=!r),e=o}while(e!==s);return r}function ib(s,t){let e=of(s.i,s.x,s.y),r=of(t.i,t.x,t.y),i=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,r.next=e,e.prev=r,n.next=r,r.prev=n,r}function Qy(s,t,e,r){let i=of(s,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function _o(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ),ef&&KA(s.prev,s.next)}function of(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function nB(s,t,e,r){let i=0;for(let n=t,o=e-r;n<e;n+=r)i+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return i}var po,Qd,ef,eb,Ft,ql,rf,sf,Ge,uo,Ds,co,fo,nb=p(()=>{po=new Set,Qd=!1;ef=!1;eb=16,Ft=new Float64Array(0),ql=0,rf=[],sf=[];Ge=[],uo=[],Ds=new Uint32Array(0),co=new Uint32Array(0),fo=new Uint32Array(256)});var ob,ab=p(()=>{nb();Qt();ob=Zl.default||Zl});var Zt,Ri=p(()=>{"use strict";Zt=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(Zt||{})});var Ii,af=p(()=>{"use strict";Ii=class{constructor(t){this.items=[],this._name=t}emit(t,e,r,i,n,o,a,l){let{name:h,items:u}=this;for(let c=0,f=u.length;c<f;c++)u[c][h](t,e,r,i,n,o,a,l);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){let 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 oB,lb,ur,Fi=p(()=>{se();Ky();Ke();Jd();Gt();Rt();bs();Ri();af();Qt();oB=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],lb=class hb extends q{constructor(t){super(),this.tick=0,this.uid=$("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;let e=[...oB,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){let e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await qy(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(let r in this._systemsHash)t={...this._systemsHash[r].constructor.defaultOptions,...t};t={...hb.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let r=0;r<this.runners.init.items.length;r++)await this.runners.init.items[r].init(t);this._initOptions=t}render(t,e){this.tick++;let r=t;if(r instanceof Mt&&(r={container:r},e&&(N(J,"passing a second argument is deprecated, please use render options instead"),r.target=e.renderTexture)),r.target||(r.target=this.view.renderTarget),r.target===this.view.renderTarget&&(this._lastObjectRendered=r.container,r.clearColor??(r.clearColor=this.background.colorRgba),r.clear??(r.clear=this.background.clearBeforeRender)),r.clearColor){let i=Array.isArray(r.clearColor)&&r.clearColor.length===4;r.clearColor=i?r.clearColor:Z.shared.setValue(r.clearColor).toArray()}r.transform||(r.container.updateLocalTransform(),r.transform=r.container.localTransform),r.container.visible&&(r.container.enableRenderGroup(),this.runners.prerender.emit(r),this.runners.renderStart.emit(r),this.runners.render.emit(r),this.runners.renderEnd.emit(r),this.runners.postrender.emit(r))}resize(t,e,r){let i=this.view.resolution;this.view.resize(t,e,r),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),r!==void 0&&r!==i&&this.runners.resolutionChange.emit(r)}clear(t={}){let e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=Zt.ALL);let{clear:r,clearColor:i,target:n,mipLevel:o,layer:a}=t;Z.shared.setValue(i??this.background.colorRgba),e.renderTarget.clear(n,r,Z.shared.toArray(),o??0,a??0)}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 Ii(e)})}_addSystems(t){let e;for(e in t){let r=t[e];this._addSystem(r.value,r.name)}}_addSystem(t,e){let r=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=r,this._systemsHash[e]=r;for(let i in this.runners)this.runners[i].add(r);return this}_addPipes(t,e){let r=e.reduce((i,n)=>(i[n.name]=n.value,i),{});t.forEach(i=>{let n=i.value,o=i.name,a=r[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)&&Le.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!jl())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()}};lb.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};ur=lb});function ub(s){return Jl!==void 0||(Jl=(()=>{let t={stencil:!0,failIfMajorPerformanceCaveat:s??ur.defaultOptions.failIfMajorPerformanceCaveat};try{if(!D.get().getWebGLRenderingContext())return!1;let r=D.get().createCanvas().getContext("webgl",t),i=!!r?.getContextAttributes()?.stencil;if(r){let n=r.getExtension("WEBGL_lose_context");n&&n.loseContext()}return r=null,i}catch{return!1}})()),Jl}var Jl,cb=p(()=>{ct();Fi()});async function db(s={}){return Ql!==void 0||(Ql=await(async()=>{let t=D.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Ql}var Ql,fb=p(()=>{ct()});function ki(s,t,e){let r=2166136261;for(let i=0;i<t;i++)r^=s[i].uid,r=Math.imul(r,16777619),r>>>=0;return pb[r]||aB(s,t,r,e)}function aB(s,t,e,r){let i={},n=0;for(let a=0;a<r;a++){let l=a<t?s[a]:F.EMPTY.source;i[n++]=l.source,i[n++]=l.style}let o=new ne(i);return pb[e]=o,o}var pb,th=p(()=>{ks();yt();pb={}});function lf(s,t,e){if(s)for(let r in s){let i=r.toLocaleLowerCase(),n=t[i];if(n){let o=s[r];r==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else O(`${r} placement hook does not exist in shader`)}}var mb=p(()=>{pt()});function hf(s){let t={};return(s.match(lB)?.map(r=>r.replace(/[{()}]/g,""))??[]).forEach(r=>{t[r]=[]}),t}var lB,gb=p(()=>{"use strict";lB=/\{\{(.*?)\}\}/g});function _b(s,t){let e,r=/@in\s+([^;]+);/g;for(;(e=r.exec(s))!==null;)t.push(e[1])}function uf(s,t,e=!1){let r=[];_b(t,r),s.forEach(a=>{a.header&&_b(a.header,r)});let i=r;e&&i.sort();let n=i.map((a,l)=>` @location(${l}) ${a},`).join(`
118
+ `),o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
119
+ ${n}
120
+ `),o}var xb=p(()=>{"use strict"});function yb(s,t){let e,r=/@out\s+([^;]+);/g;for(;(e=r.exec(s))!==null;)t.push(e[1])}function hB(s){let e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function uB(s){let t=/@.*?\s+/g;return s.replace(t,"")}function bb(s,t){let e=[];yb(t,e),s.forEach(l=>{l.header&&yb(l.header,e)});let r=0,i=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${r++}) ${l}`).join(`,
121
+ `),n=e.sort().map(l=>` var ${uB(l)};`).join(`
122
+ `),o=`return VSOutput(
123
+ ${e.sort().map(l=>` ${hB(l)}`).join(`,
124
+ `)});`,a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
125
+ ${i}
126
+ `),a=a.replace("{{start}}",`
127
+ ${n}
128
+ `),a=a.replace("{{return}}",`
129
+ ${o}
130
+ `),a}var vb=p(()=>{"use strict"});function cf(s,t){let e=s;for(let r in t){let i=t[r];i.join(`
131
+ `).length?e=e.replace(`{{${r}}}`,`//-----${r} START-----//
132
+ ${i.join(`
133
+ `)}
134
+ //----${r} FINISH----//`):e=e.replace(`{{${r}}}`,"")}return e}var Sb=p(()=>{"use strict"});function Tb({template:s,bits:t}){let e=Pb(s,t);if(es[e])return es[e];let{vertex:r,fragment:i}=dB(s,t);return es[e]=Mb(r,i,t),es[e]}function Cb({template:s,bits:t}){let e=Pb(s,t);return es[e]||(es[e]=Mb(s.vertex,s.fragment,t)),es[e]}function dB(s,t){let e=t.map(o=>o.vertex).filter(o=>!!o),r=t.map(o=>o.fragment).filter(o=>!!o),i=uf(e,s.vertex,!0);i=bb(e,i);let n=uf(r,s.fragment,!0);return{vertex:i,fragment:n}}function Pb(s,t){return t.map(e=>(df.has(e)||df.set(e,cB++),df.get(e))).sort((e,r)=>e-r).join("-")+s.vertex+s.fragment}function Mb(s,t,e){let r=hf(s),i=hf(t);return e.forEach(n=>{lf(n.vertex,r,n.name),lf(n.fragment,i,n.name)}),{vertex:cf(s,r),fragment:cf(t,i)}}var es,df,cB,wb=p(()=>{mb();gb();xb();vb();Sb();es=Object.create(null),df=new Map,cB=0});var Eb,Ab,Bb,Rb,Ib=p(()=>{"use strict";Eb=`
135
+ @in aPosition: vec2<f32>;
136
+ @in aUV: vec2<f32>;
137
+
138
+ @out @builtin(position) vPosition: vec4<f32>;
139
+ @out vUV : vec2<f32>;
140
+ @out vColor : vec4<f32>;
141
+
142
+ {{header}}
143
+
144
+ struct VSOutput {
145
+ {{struct}}
146
+ };
147
+
148
+ @vertex
149
+ fn main( {{in}} ) -> VSOutput {
150
+
151
+ var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
152
+ var modelMatrix = mat3x3<f32>(
153
+ 1.0, 0.0, 0.0,
154
+ 0.0, 1.0, 0.0,
155
+ 0.0, 0.0, 1.0
156
+ );
157
+ var position = aPosition;
158
+ var uv = aUV;
159
+
160
+ {{start}}
161
+
162
+ vColor = vec4<f32>(1., 1., 1., 1.);
163
+
164
+ {{main}}
165
+
166
+ vUV = uv;
167
+
168
+ var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
169
+
170
+ vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
171
+
172
+ vColor *= globalUniforms.uWorldColorAlpha;
173
+
174
+ {{end}}
175
+
176
+ {{return}}
177
+ };
178
+ `,Ab=`
179
+ @in vUV : vec2<f32>;
180
+ @in vColor : vec4<f32>;
181
+
182
+ {{header}}
183
+
184
+ @fragment
185
+ fn main(
186
+ {{in}}
187
+ ) -> @location(0) vec4<f32> {
188
+
189
+ {{start}}
190
+
191
+ var outColor:vec4<f32>;
192
+
193
+ {{main}}
194
+
195
+ var finalColor:vec4<f32> = outColor * vColor;
196
+
197
+ {{end}}
198
+
199
+ return finalColor;
200
+ };
201
+ `,Bb=`
202
+ in vec2 aPosition;
203
+ in vec2 aUV;
204
+
205
+ out vec4 vColor;
206
+ out vec2 vUV;
207
+
208
+ {{header}}
209
+
210
+ void main(void){
211
+
212
+ mat3 worldTransformMatrix = uWorldTransformMatrix;
213
+ mat3 modelMatrix = mat3(
214
+ 1.0, 0.0, 0.0,
215
+ 0.0, 1.0, 0.0,
216
+ 0.0, 0.0, 1.0
217
+ );
218
+ vec2 position = aPosition;
219
+ vec2 uv = aUV;
220
+
221
+ {{start}}
222
+
223
+ vColor = vec4(1.);
224
+
225
+ {{main}}
226
+
227
+ vUV = uv;
228
+
229
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
230
+
231
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
232
+
233
+ vColor *= uWorldColorAlpha;
234
+
235
+ {{end}}
236
+ }
237
+ `,Rb=`
238
+
239
+ in vec4 vColor;
240
+ in vec2 vUV;
241
+
242
+ out vec4 finalColor;
243
+
244
+ {{header}}
245
+
246
+ void main(void) {
247
+
248
+ {{start}}
249
+
250
+ vec4 outColor;
251
+
252
+ {{main}}
253
+
254
+ finalColor = outColor * vColor;
255
+
256
+ {{end}}
257
+ }
258
+ `});var Fb,kb,Lb=p(()=>{"use strict";Fb={name:"global-uniforms-bit",vertex:{header:`
259
+ struct GlobalUniforms {
260
+ uProjectionMatrix:mat3x3<f32>,
261
+ uWorldTransformMatrix:mat3x3<f32>,
262
+ uWorldColorAlpha: vec4<f32>,
263
+ uResolution: vec2<f32>,
264
+ }
265
+
266
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
267
+ `}},kb={name:"global-uniforms-bit",vertex:{header:`
268
+ uniform mat3 uProjectionMatrix;
269
+ uniform mat3 uWorldTransformMatrix;
270
+ uniform vec4 uWorldColorAlpha;
271
+ uniform vec2 uResolution;
272
+ `}}});function Li({bits:s,name:t}){let e=Tb({template:{fragment:Ab,vertex:Eb},bits:[Fb,...s]});return Oe.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Di({bits:s,name:t}){return new De({name:t,...Cb({template:{vertex:Bb,fragment:Rb},bits:[kb,...s]})})}var Oi=p(()=>{Fs();Ai();wb();Ib();Lb()});var eh,rh,sh=p(()=>{"use strict";eh={name:"color-bit",vertex:{header:`
273
+ @in aColor: vec4<f32>;
274
+ `,main:`
275
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
276
+ `}},rh={name:"color-bit",vertex:{header:`
277
+ in vec4 aColor;
278
+ `,main:`
279
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
280
+ `}}});function fB(s){let t=[];if(s===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 r=0;r<s;r++)t.push(`@group(1) @binding(${e++}) var textureSource${r+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${r+1}: sampler;`)}return t.join(`
281
+ `)}function pB(s){let t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<s;e++)e===s-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(`
282
+ `)}function ih(s){return ff[s]||(ff[s]={name:"texture-batch-bit",vertex:{header:`
283
+ @in aTextureIdAndRound: vec2<u32>;
284
+ @out @interpolate(flat) vTextureId : u32;
285
+ `,main:`
286
+ vTextureId = aTextureIdAndRound.y;
287
+ `,end:`
288
+ if(aTextureIdAndRound.x == 1)
289
+ {
290
+ vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
291
+ }
292
+ `},fragment:{header:`
293
+ @in @interpolate(flat) vTextureId: u32;
294
+
295
+ ${fB(s)}
296
+ `,main:`
297
+ var uvDx = dpdx(vUV);
298
+ var uvDy = dpdy(vUV);
299
+
300
+ ${pB(s)}
301
+ `}}),ff[s]}function mB(s){let t=[];for(let e=0;e<s;e++)e>0&&t.push("else"),e<s-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
302
+ `)}function nh(s){return pf[s]||(pf[s]={name:"texture-batch-bit",vertex:{header:`
303
+ in vec2 aTextureIdAndRound;
304
+ out float vTextureId;
305
+
306
+ `,main:`
307
+ vTextureId = aTextureIdAndRound.y;
308
+ `,end:`
309
+ if(aTextureIdAndRound.x == 1.)
310
+ {
311
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
312
+ }
313
+ `},fragment:{header:`
314
+ in float vTextureId;
315
+
316
+ uniform sampler2D uTextures[${s}];
317
+
318
+ `,main:`
319
+
320
+ ${mB(s)}
321
+ `}}),pf[s]}var ff,pf,oh=p(()=>{"use strict";ff={};pf={}});var xo,Db,ah,yo=p(()=>{"use strict";xo={name:"local-uniform-bit",vertex:{header:`
322
+
323
+ struct LocalUniforms {
324
+ uTransformMatrix:mat3x3<f32>,
325
+ uColor:vec4<f32>,
326
+ uRound:f32,
327
+ }
328
+
329
+ @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
330
+ `,main:`
331
+ vColor *= localUniforms.uColor;
332
+ modelMatrix *= localUniforms.uTransformMatrix;
333
+ `,end:`
334
+ if(localUniforms.uRound == 1)
335
+ {
336
+ vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
337
+ }
338
+ `}},Db={...xo,vertex:{...xo.vertex,header:xo.vertex.header.replace("group(1)","group(2)")}},ah={name:"local-uniform-bit",vertex:{header:`
339
+
340
+ uniform mat3 uTransformMatrix;
341
+ uniform vec4 uColor;
342
+ uniform float uRound;
343
+ `,main:`
344
+ vColor *= uColor;
345
+ modelMatrix = uTransformMatrix;
346
+ `,end:`
347
+ if(uRound == 1.)
348
+ {
349
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
350
+ }
351
+ `}}});var Gi,Ui,Vi=p(()=>{"use strict";Gi={name:"round-pixels-bit",vertex:{header:`
352
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
353
+ {
354
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
355
+ }
356
+ `}},Ui={name:"round-pixels-bit",vertex:{header:`
357
+ vec2 roundPixels(vec2 position, vec2 targetSize)
358
+ {
359
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
360
+ }
361
+ `}}});var bo,Ob=p(()=>{A();nt();th();Oi();sh();oh();yo();Vi();Qr();Qe();bo=class{constructor(){this._maxTextures=0}contextChange(t){let e=new Nt({uTransformMatrix:{value:new R,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;let r=Li({name:"graphics",bits:[eh,ih(this._maxTextures),Db,Gi]});this.shader=new oe({gpuProgram:r,resources:{localUniforms:e}})}execute(t,e){let r=e.context,i=r.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(r),h=n.encoder;h.setGeometry(a.geometry,i.gpuProgram);let u=n.globalUniforms.bindGroup;h.setBindGroup(0,u,i.gpuProgram);let c=n.renderPipes.uniformBatch.getUniformBindGroup(i.resources.localUniforms,!0);h.setBindGroup(2,c,i.gpuProgram);let f=l.instructions,d=null;for(let m=0;m<l.instructionSize;m++){let g=f[m];if(g.topology!==d&&(d=g.topology,h.setPipelineFromGeometryProgramAndState(a.geometry,i.gpuProgram,t.state,g.topology)),i.groups[1]=g.bindGroup,!g.gpuBindGroup){let _=g.textures;g.bindGroup=ki(_.textures,_.count,this._maxTextures),g.gpuBindGroup=n.bindGroup.getBindGroup(g.bindGroup,i.gpuProgram,1)}h.setBindGroup(1,g.bindGroup,i.gpuProgram),h.renderPassEncoder.drawIndexed(g.size,1,g.start)}}destroy(){this.shader.destroy(!0),this.shader=null}};bo.extension={type:[y.WebGPUPipesAdaptor],name:"graphics"}});var Gb,Ub,mf=p(()=>{"use strict";Gb={name:"texture-bit",vertex:{header:`
362
+
363
+ struct TextureUniforms {
364
+ uTextureMatrix:mat3x3<f32>,
365
+ }
366
+
367
+ @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
368
+ `,main:`
369
+ uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
370
+ `},fragment:{header:`
371
+ @group(2) @binding(0) var uTexture: texture_2d<f32>;
372
+ @group(2) @binding(1) var uSampler: sampler;
373
+
374
+
375
+ `,main:`
376
+ outColor = textureSample(uTexture, uSampler, vUV);
377
+ `}},Ub={name:"texture-bit",vertex:{header:`
378
+ uniform mat3 uTextureMatrix;
379
+ `,main:`
380
+ uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
381
+ `},fragment:{header:`
382
+ uniform sampler2D uTexture;
383
+
384
+
385
+ `,main:`
386
+ outColor = texture(uTexture, vUV);
387
+ `}}});var vo,Vb=p(()=>{A();nt();Oi();yo();Vi();mf();Qr();yt();pt();vo=class{init(){let t=Li({name:"mesh",bits:[xo,Gb,Gi]});this._shader=new oe({gpuProgram:t,resources:{uTexture:F.EMPTY._source,uSampler:F.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new R}}}})}execute(t,e){let r=t.renderer,i=e._shader;if(!i)i=this._shader,i.groups[2]=r.texture.getTextureBindGroup(e.texture);else if(!i.gpuProgram){O("Mesh shader has no gpuProgram",e.shader);return}let n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=r.globalUniforms.bindGroup),n.autoAssignLocalUniforms){let o=t.localUniforms;i.groups[1]=r.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}r.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}};vo.extension={type:[y.WebGPUPipesAdaptor],name:"mesh"}});var lh,So,Nb=p(()=>{A();hr();th();lh=Kt.for2d(),So=class{start(t,e,r){let i=t.renderer,n=i.encoder,o=r.gpuProgram;this._shader=r,this._geometry=e,n.setGeometry(e,o),lh.blendMode="normal",i.pipeline.getPipeline(e,o,lh);let a=i.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(t,e){let r=this._shader.gpuProgram,i=t.renderer,n=i.encoder;if(!e.bindGroup){let l=e.textures;e.bindGroup=ki(l.textures,l.count,i.limits.maxBatchableTextures)}lh.blendMode=e.blendMode;let o=i.bindGroup.getBindGroup(e.bindGroup,r,1),a=i.pipeline.getPipeline(this._geometry,r,lh,e.topology);e.bindGroup._touch(i.gc.now,i.tick),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}};So.extension={type:[y.WebGPUPipesAdaptor],name:"batch"}});var Gs,gf=p(()=>{A();Gs=class{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}};Gs.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"customRender"}});var Ni,_f=p(()=>{"use strict";Ni=class{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}});function To(s,t){let e=s.instructionSet,r=e.instructions;for(let i=0;i<e.instructionSize;i++){let n=r[i];t[n.renderPipeId].execute(n)}}var xf=p(()=>{"use strict"});var Us,yf=p(()=>{A();nt();Er();_f();xf();Us=class{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&&(Pt.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){let r=t._batchableRenderGroup??(t._batchableRenderGroup=Pt.get(Ni));r.renderable=t.root,r.transform=t.root.relativeGroupTransform,r.texture=t.texture,r.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(r,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;let e=new R().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}}),To(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}),To(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}};Us.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"renderGroup"}});function Co(s,t){t||(t=0);for(let e=t;e<s.length&&s[e];e++)s[e]=null}var bf=p(()=>{"use strict"});function vf(s,t=!1){_B(s);let e=s.childrenToUpdate,r=s.updateTick++;for(let i in e){let n=Number(i),o=e[i],a=o.list,l=o.index;for(let h=0;h<l;h++){let u=a[h];u.parentRenderGroup===s&&u.relativeRenderGroupDepth===n&&Wb(u,r,0)}Co(a,l),o.index=0}if(t)for(let i=0;i<s.renderGroupChildren.length;i++)vf(s.renderGroupChildren[i],t)}function _B(s){let t=s.root,e;if(s.renderGroupParent){let r=s.renderGroupParent;s.worldTransform.appendFrom(t.relativeGroupTransform,r.worldTransform),s.worldColor=di(t.groupColor,r.worldColor),e=t.groupAlpha*r.worldAlpha}else s.worldTransform.copyFrom(t.localTransform),s.worldColor=t.localColor,e=t.localAlpha;e=e<0?0:e>1?1:e,s.worldAlpha=e,s.worldColorAlpha=s.worldColor+((e*255|0)<<24)}function Wb(s,t,e){if(t===s.updateTick)return;s.updateTick=t,s.didChange=!1;let r=s.localTransform;s.updateLocalTransform();let i=s.parent;if(i&&!i.renderGroup?(e|=s._updateFlags,s.relativeGroupTransform.appendFrom(r,i.relativeGroupTransform),e&Hb&&zb(s,i,e)):(e=s._updateFlags,s.relativeGroupTransform.copyFrom(r),e&Hb&&zb(s,gB,e)),!s.renderGroup){let n=s.children,o=n.length;for(let h=0;h<o;h++)Wb(n[h],t,e);let a=s.parentRenderGroup,l=s;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function zb(s,t,e){if(e&xi){s.groupColor=di(s.localColor,t.groupColor);let r=s.localAlpha*t.groupAlpha;r=r<0?0:r>1?1:r,s.groupAlpha=r,s.groupColorAlpha=s.groupColor+((r*255|0)<<24)}e&Wn&&(s.groupBlendMode=s.localBlendMode==="inherit"?t.groupBlendMode:s.localBlendMode),e&Es&&(s.globalDisplayStatus=s.localDisplayStatus&t.globalDisplayStatus),s._updateFlags=0}var gB,Hb,Xb=p(()=>{Ke();bf();Yc();gB=new Mt,Hb=Es|xi|Wn});function jb(s,t){let{list:e}=s.childrenRenderablesToUpdate,r=!1;for(let i=0;i<s.childrenRenderablesToUpdate.index;i++){let n=e[i];if(r=t[n.renderPipeId].validateRenderable(n),r)break}return s.structureDidChange=r,r}var Yb=p(()=>{"use strict"});var xB,Po,$b=p(()=>{A();nt();_i();zn();ie();bf();xf();Xb();Yb();xB=new R,Po=class{constructor(t){this._renderer=t}render({container:t,transform:e}){let r=t.parent,i=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;let n=this._renderer,o=xB;e&&(o.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));let 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}),To(t.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(o),t.parent=r,t.renderGroup.renderGroupParent=i}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let r=t.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(t.renderGroupChildren[r],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){let r=t.root.getLocalBounds(),i=this._renderer,n=t.textureOptions.resolution||i.view.resolution,o=t.textureOptions.antialias??i.view.antialias,a=t.textureOptions.scaleMode??"linear",l=t.texture;r.ceil(),t.texture&&Vt.returnTexture(t.texture,!0);let h=Vt.getOptimalTexture(r.width,r.height,n,o);h._source.style=new Rr({scaleMode:a}),t.texture=h,t._textureBounds||(t._textureBounds=new ot),t._textureBounds.copyFrom(r),l!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(Vt.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){let e=this._renderer,r=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=r,t.structureDidChange?Co(t.childrenRenderablesToUpdate.list,0):jb(t,r),vf(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!(t.isCachedAsTexture&&!t.textureNeedsUpdate))for(let i=0;i<t.renderGroupChildren.length;i++)this._updateRenderGroups(t.renderGroupChildren[i])}_updateRenderables(t){let{list:e,index:r}=t.childrenRenderablesToUpdate;for(let i=0;i<r;i++){let n=e[i];n.didViewUpdate&&t.updateRenderable(n)}Co(e,r)}_buildInstructions(t,e){let r=t.root,i=t.instructionSet;i.reset();let n=e.renderPipes?e:e.batch.renderer,o=n.renderPipes;o.batch.buildStart(i),o.blendMode.buildStart(),o.colorMask.buildStart(),r.sortableChildren&&r.sortChildren(),r.collectRenderablesWithEffects(i,n,null),o.batch.buildEnd(i),o.blendMode.buildEnd(i)}};Po.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"renderGroup"}});var Vs,Sf=p(()=>{A();_f();Vs=class{constructor(t){this._renderer=t}addRenderable(t,e){let r=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,r),this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){let e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){let 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){let e=new Ni;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}};Vs.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"sprite"}});var Hi,Tf=p(()=>{Qt();Hi="8.19.0"});var Mo,wo,Cf=p(()=>{A();Tf();Mo=class{static init(){globalThis.__PIXI_APP_INIT__?.(this,Hi)}static destroy(){}};Mo.extension=y.Application;wo=class{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Hi)}destroy(){this._renderer=null}};wo.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"initHook",priority:-10}});var Eo,qb=p(()=>{"use strict";Eo=class{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`)}}}});function Ao(s,t,e,r){if(e??(e=0),r??(r=Math.min(s.byteLength-e,t.byteLength)),!(e&7)&&!(r&7)){let i=r/8;new Float64Array(t,0,i).set(new Float64Array(s,e,i))}else if(!(e&3)&&!(r&3)){let i=r/4;new Float32Array(t,0,i).set(new Float32Array(s,e,i))}else new Uint8Array(t).set(new Uint8Array(s,e,r))}var Pf=p(()=>{"use strict"});var Kb,Et,Ns=p(()=>{"use strict";Kb={normal:"normal-npm",add:"add-npm",screen:"screen-npm"},Et=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",s[s.NONE=5]="NONE",s))(Et||{})});function Mf(s,t){return t.alphaMode==="no-premultiply-alpha"&&Kb[s]||s}var Zb=p(()=>{Ns()});function bB(s){let t="";for(let e=0;e<s;++e)e>0&&(t+=`
388
+ else `),e<s-1&&(t+=`if(test == ${e}.0){}`);return t}function hh(s,t){if(s===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");let e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){let r=yB.replace(/%forloop%/gi,bB(s));if(t.shaderSource(e,r),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))s=s/2|0;else break}}finally{t.deleteShader(e)}return s}var yB,wf=p(()=>{"use strict";yB=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
389
+ `)});function Jb(){if(zi)return zi;let s=Vl();return zi=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),zi=hh(zi,s),s.getExtension("WEBGL_lose_context")?.loseContext(),zi}var zi,Qb=p(()=>{kd();wf();zi=null});var uh,tv=p(()=>{"use strict";uh=class{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){let e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}});function ev(){return ch>0?Ro[--ch]:new Ef}function rv(s){s.elements=null,Ro[ch++]=s}var Ef,Ro,ch,Bo,sv,nv,ov=p(()=>{Gt();qb();Rt();bs();Pf();Zb();Qb();tv();Ef=class{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new uh,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}},Ro=[],ch=0;Le.register({clear:()=>{if(Ro.length>0)for(let s of Ro)s&&s.destroy();Ro.length=0,ch=0}});Bo=0,sv=class iv{constructor(t){this.uid=$("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...iv.defaultOptions,...t},t.maxTextures||(N("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Jb());let{maxTextures:e,attributesInitialSize:r,indicesInitialSize:i}=t;this.attributeBuffer=new Eo(r*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)rv(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){let r=t._batch.textures.ids[e._source.uid];return!r&&r!==0?!1:(t._textureId=r,t.texture=e,!0)}updateElement(t){this.dirty=!0;let 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){let e=this._elements;if(!e[this.elementStart])return;let r=ev(),i=r.textures;i.clear();let n=e[this.elementStart],o=Mf(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);let l=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,u=this.indexBuffer,c=this._batchIndexSize,f=this._batchIndexStart,d="startBatch",m=[],g=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){let x=e[_];e[_]=null;let v=x.texture._source,b=Mf(x.blendMode,v),C=o!==b||a!==x.topology;if(v._batchTick===Bo&&!C){x._textureId=v._textureBindLocation,c+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,l,h,x._attributeStart,x._textureId),this.packQuadIndex(u,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,l,h,x._attributeStart,x._textureId),this.packIndex(x,u,x._indexStart,x._attributeStart/this.vertexSize)),x._batch=r,m.push(x);continue}v._batchTick=Bo,(i.count>=g||C)&&(this._finishBatch(r,f,c-f,i,o,a,t,d,m),d="renderBatch",f=c,o=b,a=x.topology,r=ev(),i=r.textures,i.clear(),m=[],++Bo),x._textureId=v._textureBindLocation=i.count,i.ids[v.uid]=i.count,i.textures[i.count++]=v,x._batch=r,m.push(x),c+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,l,h,x._attributeStart,x._textureId),this.packQuadIndex(u,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,l,h,x._attributeStart,x._textureId),this.packIndex(x,u,x._indexStart,x._attributeStart/this.vertexSize))}i.count>0&&(this._finishBatch(r,f,c-f,i,o,a,t,d,m),f=c,++Bo),this.elementStart=this.elementSize,this._batchIndexStart=f,this._batchIndexSize=c}_finishBatch(t,e,r,i,n,o,a,l,h){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=i,t.blendMode=n,t.topology=o,t.start=e,t.size=r,t.elements=h,++Bo,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){let e=Math.max(t,this.attributeBuffer.size*2),r=new Eo(e);Ao(this.attributeBuffer.rawBinaryData,r.rawBinaryData),this.attributeBuffer=r}_resizeIndexBuffer(t){let e=this.indexBuffer,r=Math.max(t,e.length*1.5);r+=r%2;let i=r>65535?new Uint32Array(r):new Uint16Array(r);if(i.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n<e.length;n++)i[n]=e[n];else Ao(e.buffer,i.buffer);this.indexBuffer=i}packQuadIndex(t,e,r){t[e]=r+0,t[e+1]=r+1,t[e+2]=r+2,t[e+3]=r+0,t[e+4]=r+2,t[e+5]=r+3}packIndex(t,e,r,i){let n=t.indices,o=t.indexSize,a=t.indexOffset,l=t.attributeOffset;for(let h=0;h<o;h++)e[r++]=i+n[h+a]-l}destroy(t={}){if(this.batches!==null){for(let e=0;e<this.batchIndex;e++)rv(this.batches[e]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&(this.shader?.destroy(),this.shader=null);for(let e=0;e<this._elements.length;e++)this._elements[e]&&(this._elements[e]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};sv.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};nv=sv});var vB,SB,dh,av=p(()=>{Bi();Ls();Xl();vB=new Float32Array(1),SB=new Uint32Array(1),dh=class extends ts{constructor(){let e=new pe({data:vB,label:"attribute-batch-buffer",usage:xt.VERTEX|xt.COPY_DST,shrinkToFit:!1}),r=new pe({data:SB,label:"index-batch-buffer",usage:xt.INDEX|xt.COPY_DST,shrinkToFit:!1}),i=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aUV:{buffer:e,format:"float32x2",stride:i,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:i,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:i,offset:20}},indexBuffer:r})}}});function fh(s){let t=lv[s];if(t)return t;let e=new Int32Array(s);for(let r=0;r<s;r++)e[r]=r;return t=lv[s]=new Nt({uTextures:{value:e,type:"i32",size:s}},{isStatic:!0}),t}var lv,Af=p(()=>{Qe();lv={}});var Io,hv=p(()=>{Oi();sh();oh();Vi();Af();Qr();Io=class extends oe{constructor(t){let e=Di({name:"batch",bits:[rh,nh(t),Ui]}),r=Li({name:"batch",bits:[eh,ih(t),Gi]});super({glProgram:e,gpuProgram:r,resources:{batchSamplers:fh(t)}}),this.maxTextures=t}}});var Fo,uv,ko,Bf=p(()=>{A();ov();av();hv();Fo=null,uv=class cv extends nv{constructor(t){super(t),this.geometry=new dh,this.name=cv.extension.name,this.vertexSize=6,Fo??(Fo=new Io(t.maxTextures)),this.shader=Fo}packAttributes(t,e,r,i,n){let o=n<<16|t.roundPixels&65535,a=t.transform,l=a.a,h=a.b,u=a.c,c=a.d,f=a.tx,d=a.ty,{positions:m,uvs:g}=t,_=t.color,x=t.attributeOffset,S=x+t.attributeSize;for(let v=x;v<S;v++){let b=v*2,C=m[b],T=m[b+1];e[i++]=l*C+u*T+f,e[i++]=c*T+h*C+d,e[i++]=g[b],e[i++]=g[b+1],r[i++]=_,r[i++]=o}}packQuadAttributes(t,e,r,i,n){let o=t.texture,a=t.transform,l=a.a,h=a.b,u=a.c,c=a.d,f=a.tx,d=a.ty,m=t.bounds,g=m.maxX,_=m.minX,x=m.maxY,S=m.minY,v=o.uvs,b=t.color,C=n<<16|t.roundPixels&65535;e[i+0]=l*_+u*S+f,e[i+1]=c*S+h*_+d,e[i+2]=v.x0,e[i+3]=v.y0,r[i+4]=b,r[i+5]=C,e[i+6]=l*g+u*S+f,e[i+7]=c*S+h*g+d,e[i+8]=v.x1,e[i+9]=v.y1,r[i+10]=b,r[i+11]=C,e[i+12]=l*g+u*x+f,e[i+13]=c*x+h*g+d,e[i+14]=v.x2,e[i+15]=v.y2,r[i+16]=b,r[i+17]=C,e[i+18]=l*_+u*x+f,e[i+19]=c*x+h*_+d,e[i+20]=v.x3,e[i+21]=v.y3,r[i+22]=b,r[i+23]=C}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Fo=new Io(t),this.shader=Fo)}destroy(){this.shader=null,super.destroy()}};uv.extension={type:[y.Batcher],name:"default"};ko=uv});var Rf,Lo,If=p(()=>{A();hr();Bf();Rf=class dv{constructor(t,e){this.state=Kt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init?.(this)}static getBatcher(t,e){return new this._availableBatchers[t]({maxTextures:e})}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new ko({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(let r in this._activeBatches)this._activeBatches[r].begin()}addToBatch(t,e){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(e);let r=this._activeBatches[t.batcherName];r||(r=this._activeBatches[t.batcherName]=dv.getBatcher(t.batcherName,this.renderer.limits.maxBatchableTextures),r.begin()),this._activeBatch=r}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);let e=this._activeBatches;for(let r in e){let i=e[r],n=i.geometry;n.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),n.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(t){let e=this._batchersByInstructionSet[t.uid];for(let r in e){let i=e[r],n=i.geometry;i.dirty&&(i.dirty=!1,n.buffers[0].update(i.attributeSize*4))}}execute(t){if(t.action==="startBatch"){let e=t.batcher,r=e.geometry,i=e.shader;this._adaptor.start(this,r,i)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(let t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};Rf.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"batch"};Rf._availableBatchers=Object.create(null);Lo=Rf;U.handleByMap(y.Batcher,Lo._availableBatchers);U.add(ko)});var fv,pv=p(()=>{fv=`in vec2 vMaskCoord;
390
+ in vec2 vTextureCoord;
391
+
392
+ uniform sampler2D uTexture;
393
+ uniform sampler2D uMaskTexture;
394
+
395
+ uniform float uAlpha;
396
+ uniform vec4 uMaskClamp;
397
+ uniform float uInverse;
398
+ uniform float uChannel;
399
+
400
+ out vec4 finalColor;
401
+
402
+ void main(void)
403
+ {
404
+ float clip = step(3.5,
405
+ step(uMaskClamp.x, vMaskCoord.x) +
406
+ step(uMaskClamp.y, vMaskCoord.y) +
407
+ step(vMaskCoord.x, uMaskClamp.z) +
408
+ step(vMaskCoord.y, uMaskClamp.w));
409
+
410
+ // TODO look into why this is needed
411
+ float npmAlpha = uAlpha;
412
+ vec4 original = texture(uTexture, vTextureCoord);
413
+ vec4 masky = texture(uMaskTexture, vMaskCoord);
414
+
415
+ float a;
416
+ if (uChannel == 1.0) {
417
+ a = masky.a * npmAlpha * clip;
418
+ } else {
419
+ float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
420
+ a = alphaMul * masky.r * npmAlpha * clip;
421
+ }
422
+
423
+ if (uInverse == 1.0) {
424
+ a = 1.0 - a;
425
+ }
426
+
427
+ finalColor = original * a;
428
+ }
429
+ `});var mv,gv=p(()=>{mv=`in vec2 aPosition;
430
+
431
+ out vec2 vTextureCoord;
432
+ out vec2 vMaskCoord;
433
+
434
+
435
+ uniform vec4 uInputSize;
436
+ uniform vec4 uOutputFrame;
437
+ uniform vec4 uOutputTexture;
438
+ uniform mat3 uFilterMatrix;
439
+
440
+ vec4 filterVertexPosition( vec2 aPosition )
441
+ {
442
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
443
+
444
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
445
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
446
+
447
+ return vec4(position, 0.0, 1.0);
448
+ }
449
+
450
+ vec2 filterTextureCoord( vec2 aPosition )
451
+ {
452
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
453
+ }
454
+
455
+ vec2 getFilterCoord( vec2 aPosition )
456
+ {
457
+ return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
458
+ }
459
+
460
+ void main(void)
461
+ {
462
+ gl_Position = filterVertexPosition(aPosition);
463
+ vTextureCoord = filterTextureCoord(aPosition);
464
+ vMaskCoord = getFilterCoord(aPosition);
465
+ }
466
+ `});var Ff,_v=p(()=>{Ff=`struct GlobalFilterUniforms {
467
+ uInputSize:vec4<f32>,
468
+ uInputPixel:vec4<f32>,
469
+ uInputClamp:vec4<f32>,
470
+ uOutputFrame:vec4<f32>,
471
+ uGlobalFrame:vec4<f32>,
472
+ uOutputTexture:vec4<f32>,
473
+ };
474
+
475
+ struct MaskUniforms {
476
+ uFilterMatrix:mat3x3<f32>,
477
+ uMaskClamp:vec4<f32>,
478
+ uAlpha:f32,
479
+ uInverse:f32,
480
+ uChannel:f32,
481
+ };
482
+
483
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
484
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
485
+ @group(0) @binding(2) var uSampler : sampler;
486
+
487
+ @group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
488
+ @group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
489
+
490
+ struct VSOutput {
491
+ @builtin(position) position: vec4<f32>,
492
+ @location(0) uv : vec2<f32>,
493
+ @location(1) filterUv : vec2<f32>,
494
+ };
495
+
496
+ fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
497
+ {
498
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
499
+
500
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
501
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
502
+
503
+ return vec4(position, 0.0, 1.0);
504
+ }
505
+
506
+ fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
507
+ {
508
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
509
+ }
510
+
511
+ fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
512
+ {
513
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
514
+ }
515
+
516
+ fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
517
+ {
518
+ return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
519
+ }
520
+
521
+ fn getSize() -> vec2<f32>
522
+ {
523
+ return gfu.uGlobalFrame.zw;
524
+ }
525
+
526
+ @vertex
527
+ fn mainVertex(
528
+ @location(0) aPosition : vec2<f32>,
529
+ ) -> VSOutput {
530
+ return VSOutput(
531
+ filterVertexPosition(aPosition),
532
+ filterTextureCoord(aPosition),
533
+ getFilterCoord(aPosition)
534
+ );
535
+ }
536
+
537
+ @fragment
538
+ fn mainFragment(
539
+ @location(0) uv: vec2<f32>,
540
+ @location(1) filterUv: vec2<f32>,
541
+ @builtin(position) position: vec4<f32>
542
+ ) -> @location(0) vec4<f32> {
543
+
544
+ var maskClamp = filterUniforms.uMaskClamp;
545
+ var uAlpha = filterUniforms.uAlpha;
546
+
547
+ var clip = step(3.5,
548
+ step(maskClamp.x, filterUv.x) +
549
+ step(maskClamp.y, filterUv.y) +
550
+ step(filterUv.x, maskClamp.z) +
551
+ step(filterUv.y, maskClamp.w));
552
+
553
+ var mask = textureSample(uMaskTexture, uSampler, filterUv);
554
+ var source = textureSample(uTexture, uSampler, uv);
555
+
556
+ var a: f32;
557
+ if (filterUniforms.uChannel == 1.0) {
558
+ a = mask.a * uAlpha * clip;
559
+ } else {
560
+ var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
561
+ a = alphaMul * mask.r * uAlpha * clip;
562
+ }
563
+
564
+ if (filterUniforms.uInverse == 1.0) {
565
+ a = 1.0 - a;
566
+ }
567
+
568
+ return source * a;
569
+ }
570
+ `});var ph,xv=p(()=>{nt();Fs();Ai();Qe();td();jd();pv();gv();_v();ph=class extends zl{constructor(t){let{sprite:e,...r}=t,i=new gi(e.texture),n=new Nt({uFilterMatrix:{value:new R,type:"mat3x3<f32>"},uMaskClamp:{value:i.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"},uChannel:{value:t.channel==="alpha"?1:0,type:"f32"}}),o=Oe.from({vertex:{source:Ff,entryPoint:"mainVertex"},fragment:{source:Ff,entryPoint:"mainFragment"}}),a=De.from({vertex:mv,fragment:fv,name:"mask-filter"});super({...r,gpuProgram:o,glProgram:a,clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=i}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(t){this.resources.filterUniforms.uniforms.uChannel=t==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(t,e,r,i){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,r,i)}}});var TB,kf,Hs,Lf=p(()=>{A();ll();xv();ie();Nn();bd();Er();yt();_i();Gr();TB=new ot,kf=class extends Ar{constructor(){super(),this.filters=[new ph({sprite:new Rs(F.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}get channel(){return this.filters[0].channel}set channel(t){this.filters[0].channel=t}},Hs=class{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,r){let i=this._renderer;if(i.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.channel=e._maskOptions.channel??"red",t.renderMaskToTexture){let n=t.mask;n.includeInBuild=!0,n.collectRenderables(r,i,null),n.includeInBuild=!1}i.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){let e=this._renderer,r=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){let i=Pt.get(kf);if(i.inverse=t.inverse,i.channel=t.mask.channel,r){t.mask.mask.measurable=!0;let n=ci(t.mask.mask,!0,TB);t.mask.mask.measurable=!1,n.ceil();let o=e.renderTarget.renderTarget.colorTexture.source,a=Vt.getOptimalTexture(n.width,n.height,o._resolution,o.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});let l=i.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:a})}else i.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){let i=this._activeMaskStage[this._activeMaskStage.length-1];r&&(e.type===qt.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();let i=this._activeMaskStage.pop();r&&Vt.returnTexture(i.filterTexture),Pt.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}};Hs.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"alphaMask"}});var Do,yv=p(()=>{A();Do=class{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,r){this._renderer.renderPipes.batch.break(r);let n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;let o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,r.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(t,e,r){this._renderer.renderPipes.batch.break(r);let n=this._colorStack;this._colorStackIndex--;let o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,r.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}};Do.extension={type:[y.WebGLPipes,y.WebGPUPipes],name:"colorMask"}});var Oo,bv=p(()=>{A();Ri();Ns();Oo=class{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,r){var i;let n=t,o=this._renderer;o.renderPipes.batch.break(r),o.renderPipes.blendMode.setBlendMode(n.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});let a=n.mask;a.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});let l=this._maskHash.get(n);l.instructionsStart=r.instructionSize,a.collectRenderables(r,o,null),a.includeInBuild=!1,o.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});let h=r.instructionSize-l.instructionsStart-1;l.instructionsLength=h;let u=o.renderTarget.renderTarget.uid;(i=this._maskStackHash)[u]??(i[u]=0)}pop(t,e,r){let i=t,n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(i.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});let o=this._maskHash.get(t);for(let a=0;a<o.instructionsLength;a++)r.instructions[r.instructionSize++]=r.instructions[o.instructionsStart++];r.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;let r=this._renderer,i=r,n=r.renderTarget.renderTarget.uid,o=(e=this._maskStackHash)[n]??(e[n]=0);t.action==="pushMaskBegin"?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(Et.RENDERING_MASK_ADD,o),o++,i.colorMask.setMask(0)):t.action==="pushMaskEnd"?(t.inverse?i.stencil.setStencilMode(Et.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(Et.MASK_ACTIVE,o),i.colorMask.setMask(15)):t.action==="popMaskBegin"?(i.colorMask.setMask(0),o!==0?i.stencil.setStencilMode(Et.RENDERING_MASK_REMOVE,o):(i.renderTarget.clear(null,Zt.STENCIL),i.stencil.setStencilMode(Et.DISABLED,o)),o--):t.action==="popMaskEnd"&&(t.inverse?i.stencil.setStencilMode(Et.INVERSE_MASK_ACTIVE,o):i.stencil.setStencilMode(Et.MASK_ACTIVE,o),i.colorMask.setMask(15)),this._maskStackHash[n]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}};Oo.extension={type:[y.WebGLPipes,y.WebGPUPipes],name:"stencilMask"}});var Df,Sv,Tv=p(()=>{se();A();pt();Df=class vv{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Z(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...vv.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){Z.shared.setValue(t).alpha<1&&this._backgroundColor.alpha===1&&O("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Df.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"background",priority:0};Df.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};Sv=Df});var Go,zs,Of=p(()=>{A();ll();rd();pt();Go={};U.handle(y.BlendMode,s=>{if(!s.name)throw new Error("BlendMode extension must have a name property");Go[s.name]=s.ref},s=>{delete Go[s.name]});zs=class{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,r){this._blendModeStack.push(e),this.setBlendMode(t,e,r)}popBlendMode(t){this._blendModeStack.pop();let e=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,e,t)}setBlendMode(t,e,r){let i=t instanceof ws;if(this._activeBlendMode===e){this._isAdvanced&&t&&!i&&this._renderableList?.push(t);return}this._isAdvanced&&this._endAdvancedBlendMode(r),this._activeBlendMode=e,t&&(this._isAdvanced=!!Go[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,r))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);let r=this._activeBlendMode;if(!Go[r]){O(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let i=this._ensureFilterEffect(r),n=t instanceof ws,o={renderPipeId:"filter",action:"pushFilter",filterEffect:i,renderables:n?null:[t],container:n?t.root:null,canBundle:!1};this._renderableList=o.renderables,e.add(o)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new Ar,e.filters=[new Go[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(let t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}};zs.extension={type:[y.WebGLPipes,y.WebGPUPipes,y.CanvasPipes],name:"blendMode"}});var Gf,Uf,Pv,Mv=p(()=>{ct();A();Ke();yt();Gf={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Uf=class Cv{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Mt||t instanceof F?{target:t,...e}:{...e,...t}}async image(t){let e=D.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,Cv.defaultImageOptions);let{format:e,quality:r}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((n,o)=>{i.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}let l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},Gf[e],r)});if(i.toDataURL!==void 0)return i.toDataURL(Gf[e],r);if(i.convertToBlob!==void 0){let n=await i.convertToBlob({type:Gf[e],quality:r});return new Promise((o,a)=>{let 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);let e=t.target,r=this._renderer;if(e instanceof F)return r.texture.generateCanvas(e);let i=r.textureGenerator.generateTexture(t),n=r.texture.generateCanvas(i);return i.destroy(!0),n}pixels(t){t=this._normalizeOptions(t);let e=t.target,r=this._renderer,i=e instanceof F?e:r.textureGenerator.generateTexture(t),n=r.texture.getPixels(i);return e instanceof Mt&&i.destroy(!0),n}texture(t){return t=this._normalizeOptions(t),t.target instanceof F?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);let e=this.canvas(t),r=document.createElement("a");r.download=t.filename??"image.png",r.href=e.toDataURL("image/png"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}log(t){let e=t.width??200;t=this._normalizeOptions(t);let r=this.canvas(t),i=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);let n=["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${i}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};Uf.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"extract"};Uf.defaultImageOptions={format:"png",quality:1};Pv=Uf});var mh,wv=p(()=>{ce();yt();mh=class s extends F{static create(t){let{dynamic:e,textureOptions:r,...i}=t;return new s({...r,source:new ut(i),dynamic:e??!1})}resize(t,e,r){return this.source.resize(t,e,r),this}}});var CB,PB,MB,Uo,Ev=p(()=>{se();A();nt();te();ie();fl();Ke();wv();CB=new rt,PB=new ot,MB=[0,0,0,0],Uo=class{constructor(t){this._renderer=t}generateTexture(t){t instanceof Mt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});let e=t.resolution||this._renderer.resolution,r=t.antialias||this._renderer.view.antialias,i=t.target,n=t.clearColor;n?n=Array.isArray(n)&&n.length===4?n:Z.shared.setValue(n).toArray():n=MB;let o=t.frame?.copyTo(CB)||fi(i,PB).rectangle,a=t.defaultAnchor&&{defaultAnchor:t.defaultAnchor};o.width=Math.max(o.width,1/e)|0,o.height=Math.max(o.height,1/e)|0;let l=mh.create({...t.textureSourceOptions,width:o.width,height:o.height,resolution:e,antialias:r,textureOptions:a}),h=R.shared.translate(-o.x,-o.y);return this._renderer.render({container:i,transform:h,target:l,clearColor:n}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}};Uo.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"textureGenerator"}});function Av(s){let t=!1;for(let r in s)if(s[r]==null){t=!0;break}if(!t)return s;let e=Object.create(null);for(let r in s){let i=s[r];i&&(e[r]=i)}return e}function Bv(s){let t=0;for(let e=0;e<s.length;e++)s[e]==null?t++:s[e-t]=s[e];return s.length-=t,s}var Rv=p(()=>{"use strict"});var Vf,Fv,kv=p(()=>{A();Rv();Vf=class Iv{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=t}init(t){t={...Iv.defaultOptions,...t},this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(let e of this._managedCollections){let{context:r,collection:i,type:n}=e;n==="hash"?r[i]=Av(r[i]):r[i]=Bv(r[i])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e,t.gcTick=e;for(let r of t.renderGroupChildren)this._updateInstructionGCTick(r,e)}addCollection(t,e,r){this._managedCollections.push({context:t,collection:e,type:r})}addResource(t,e){if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,t._onTouch?.(this.now);return}let r=this._managedResources.length;t._gcData={index:r,type:e},t._gcLastUsed=this.now,t._onTouch?.(this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){let e=t._gcData;if(!e)return;let r=e.index,i=this._managedResources.length-1;if(r!==i){let n=this._managedResources[i];this._managedResources[r]=n,n._gcData.index=r}this._managedResources.length--,t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,r,i=0){this._managedResourceHashes.push({context:t,hash:e,type:r,priority:i}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){let t=performance.now(),e=this._managedResourceHashes;for(let i of e)this.runOnHash(i,t);let r=0;for(let i=0;i<this._managedResources.length;i++){let n=this._managedResources[i];r=this.runOnResource(n,t,r)}this._managedResources.length=r}updateRenderableGCTick(t,e){let r=t.renderGroup??t.parentRenderGroup,i=r?.instructionSet?.gcTick??-1;(r?.gcTick??0)===i&&(t._gcLastUsed=e,t._onTouch?.(e))}runOnResource(t,e,r){let i=t._gcData;return i.type==="renderable"&&this.updateRenderableGCTick(t,e),e-t._gcLastUsed<this.maxUnusedTime||!t.autoGarbageCollect?(this._managedResources[r]=t,i.index=r,r++):(t.unload(),t._gcData=null,t._gcLastUsed=-1,t.off("unload",this.removeResource,this)),r}_createHashClone(t,e){let r=Object.create(null);for(let i in t){if(i===e)break;t[i]!==null&&(r[i]=t[i])}return r}runOnHash(t,e){let{context:r,hash:i,type:n}=t,o=r[i],a=null,l=0;for(let h in o){let u=o[h];if(u===null){l++,l===1e4&&!a&&(a=this._createHashClone(o,h));continue}if(u._gcLastUsed===-1){u._gcLastUsed=e,u._onTouch?.(e),a&&(a[h]=u);continue}if(n==="renderable"&&this.updateRenderableGCTick(u,e),!(e-u._gcLastUsed<this.maxUnusedTime)&&u.autoGarbageCollect){if(n==="renderable"){let f=u,d=f.renderGroup??f.parentRenderGroup;d&&(d.structureDidChange=!0)}u.unload(),u._gcData=null,u._gcLastUsed=-1,a||(l+1!==1e4?(o[h]=null,l++):a=this._createHashClone(o,h))}else a&&(a[h]=u)}a&&(r[i]=a)}destroy(){this.enabled=!1,this._managedResources.forEach(t=>{t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Vf.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"gc",priority:0};Vf.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};Fv=Vf});function gh(s,t,e){let r=(s>>24&255)/255;t[e++]=(s&255)/255*r,t[e++]=(s>>8&255)/255*r,t[e++]=(s>>16&255)/255*r,t[e++]=r}var Nf=p(()=>{"use strict"});var Vo,Lv=p(()=>{A();nt();ke();Nf();ks();Gr();Qe();Vo=class{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:r,worldColor:i,offset:n}){let o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new R,worldColor:4294967295,offset:new et},l={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:r||a.worldTransformMatrix,worldColor:i||a.worldColor,offset:n||a.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);let u=h.uniforms;u.uProjectionMatrix=l.projectionMatrix,u.uResolution=l.resolution,u.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),u.uWorldTransformMatrix.tx-=l.offset.x,u.uWorldTransformMatrix.ty-=l.offset.y,gh(l.worldColor,u.uWorldColorAlpha,0),h.update();let c;this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(c=this._bindGroupPool.pop()||new ne,this._activeBindGroups.push(c),c.setResource(h,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===qt.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 R,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new R,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}};Vo.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"globalUniforms"}});var wB,No,Dv=p(()=>{A();As();wB=1,No=class{constructor(){this._tasks=[],this._offset=0}init(){St.system.add(this._update,this)}repeat(t,e,r=!0){let i=wB++,n=0;return r&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:i}),i}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t){this._tasks.splice(e,1);return}}_update(){let t=performance.now();for(let e=0;e<this._tasks.length;e++){let r=this._tasks[e];if(t-r.offset-r.last>=r.duration){let i=t-r.start;r.func(i),r.last=t}}}destroy(){St.system.remove(this._update,this),this._tasks.length=0}};No.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"scheduler",priority:0}});function Gv(s){if(!Ov){if(D.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){let t=[`%c %c %c %c %c PixiJS %c v${Hi} (${s}) http://www.pixijs.com/
571
+
572
+ `,"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 ${Hi} - ${s} - http://www.pixijs.com/`);Ov=!0}}var Ov,Uv=p(()=>{ct();Tf();Ov=!1});var Wi,Vv=p(()=>{A();Uv();Gr();Wi=class{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===qt.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Gv(e)}}};Wi.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"hello",priority:-2};Wi.defaultOptions={hello:!1}});var Hf,Hv,zv=p(()=>{A();Rt();Hf=class Nv{constructor(t){this._renderer=t}init(t){t={...Nv.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return N("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(t){N("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=t}addManagedHash(t,e){N("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,e,"hash")}addManagedArray(t,e){N("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,e,"array")}addRenderable(t){N("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(t,"renderable")}run(){N("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Hf.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"renderableGC",priority:0};Hf.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};Hv=Hf});var zf,Wv,Xv=p(()=>{A();Rt();zf=class _h{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(t){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=t/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(t){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(t){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){t.textureGCActive!==_h.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==_h.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==_h.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};zf.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"textureGC"};zf.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};Wv=zf});var jv,Ho,Wf=p(()=>{Gt();ce();yt();jv=class Yv{constructor(t={}){if(this.uid=$("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...Yv.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 ut({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(r=>r.source)];let 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 F||t.depthStencilTexture instanceof ut?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){let 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 ut({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,r=this.resolution,i=!1){this.dirtyId++,this.colorTextures.forEach((n,o)=>{i&&o===0||n.source.resize(t,e,r)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,r)}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)}};jv.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};Ho=jv});function xh(s,t){if(!Xi.has(s)){let e=new F({source:new It({resource:s,...t})}),r=()=>{Xi.get(s)===e&&Xi.delete(s)};e.once("destroy",r),e.source.once("destroy",r),Xi.set(s,e)}return Xi.get(s)}var Xi,Xf=p(()=>{bs();Zr();yt();Xi=new Map;Le.register(Xi)});var jf,qv,Kv=p(()=>{ct();A();te();Rt();Wf();Xf();jf=class $v{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={...$v.defaultOptions,...t},t.view&&(N(J,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view),this.screen=new rt(0,0,t.width,t.height),this.canvas=t.canvas||D.get().createCanvas(),this.antialias=!!t.antialias,this.texture=xh(this.canvas,t),this.renderTarget=new Ho({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,r){this.texture.source.resize(t,e,r),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:!!t?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};jf.extension={type:[y.WebGLSystem,y.WebGPUSystem,y.CanvasSystem],name:"view",priority:0};jf.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};qv=jf});var ji,yh,bh=p(()=>{gf();yf();$b();Sf();Cf();If();Lf();yv();bv();Tv();Of();Mv();Ev();kv();Lv();Dv();Vv();zv();Xv();Kv();ji=[Sv,Vo,Wi,qv,Po,Fv,Wv,Uo,Pv,wo,Hv,No],yh=[zs,Lo,Vs,Us,Hs,Oo,Do,Gs]});var zo,Zv=p(()=>{A();zo=class{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,r){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,r)}_createBindGroup(t,e,r){let i=this._gpu.device,n=e.layout[r],o=[],a=this._renderer;for(let u in n){let c=t.resources[u]??t.resources[n[u]],f;if(c._resourceType==="uniformGroup"){let d=c;a.ubo.updateUniformGroup(d);let m=d.buffer;f={buffer:a.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(c._resourceType==="buffer"){let d=c;f={buffer:a.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(c._resourceType==="bufferResource"){let d=c;f={buffer:a.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(c._resourceType==="textureSampler"){let d=c;f=a.texture.getGpuSampler(d)}else if(c._resourceType==="textureSource"){let d=c;f=a.texture.getTextureView(d)}o.push({binding:n[u],resource:f})}let l=a.shader.getProgramData(e).bindGroups[r],h=i.createBindGroup({layout:l,entries:o});return this._hash[t._key]=h,h}destroy(){this._hash=null,this._renderer=null}};zo.extension={type:[y.WebGPUSystem],name:"bindGroup"}});var zt,cr=p(()=>{"use strict";zt=class{constructor(t){this.items=Object.create(null);let{renderer:e,type:r,onUnload:i,priority:n,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",r,n??0),this._onUnload=i,this.name=o}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){if(!this.items[t.uid])return;let r=t._gpuData[this._renderer.uid];r&&(this._onUnload?.(t,...e),r.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}});var Yf,Wo,Jv=p(()=>{A();cr();Gt();Pf();Yf=class{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}},Wo=class{constructor(t){this._renderer=t,this._managedBuffers=new zt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t}getGPUBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(t)}updateBuffer(t){let e=this.getGPUBuffer(t),r=t.data;return t._updateID&&r&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,r.buffer,0,(t._updateSize||r.byteLength)+3&-4)),e}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this)}createGPUBuffer(t){let e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t._resourceId=$("resource"),t.data&&(Ao(t.data.buffer,e.getMappedRange(),t.data.byteOffset,t.data.byteLength),e.unmap()),t._gpuData[this._renderer.uid]=new Yf(e),this._managedBuffers.add(t)&&(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this)),e}onBufferChange(t){this._managedBuffers.remove(t),t._updateID=0,this.createGPUBuffer(t)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}};Wo.extension={type:[y.WebGPUSystem],name:"buffer"}});var Xo,Qv=p(()=>{A();Xo=class{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}};Xo.extension={type:[y.WebGPUSystem],name:"colorMask"}});var Yi,t0=p(()=>{ct();A();Yi=class{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.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT=="number"},this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){let e=await D.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(n=>e.features.has(n)),i=await e.requestDevice({requiredFeatures:r});return{adapter:e,device:i}}destroy(){this.gpu=null,this.extensions=null,this._renderer=null}};Yi.extension={type:[y.WebGPUSystem],name:"device"};Yi.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1}});var jo,e0=p(()=>{A();jo=class{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,r,i){let n=this._renderer.pipeline.getPipeline(t,e,r,i);this.setPipeline(n)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;let 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,r){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.gc.now,this._renderer.tick);let i=this._renderer.bindGroup.getBindGroup(e,r,t);this.renderPassEncoder.setBindGroup(t,i)}setGeometry(t,e){let r=this._renderer.pipeline.getBufferNamesToBind(t,e);for(let i in r)this._setVertexBuffer(parseInt(i,10),t.attributes[r[i]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(let r in t.groups){let i=t.groups[r];e||this._syncBindGroup(i),this.setBindGroup(r,i,t.gpuProgram)}}_syncBindGroup(t){for(let e in t.resources){let r=t.resources[e];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(t){let{geometry:e,shader:r,state:i,topology:n,size:o,start:a,instanceCount:l,skipSync:h}=t;this.setPipelineFromGeometryProgramAndState(e,r.gpuProgram,i,n),this.setGeometry(e,r.gpuProgram),this._setShaderBindGroups(r,h),e.indexBuffer?this.renderPassEncoder.drawIndexed(o||e.indexBuffer.data.length,l??e.instanceCount,a||0):this.renderPassEncoder.draw(o||e.getSize(),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(){let t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);let e=this._boundPipeline,r={...this._boundVertexBuffer},i=this._boundIndexBuffer,n={...this._boundBindGroup};this._clearCache();let o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(e);for(let a in r)this._setVertexBuffer(a,r[a]);for(let a in n)this.setBindGroup(a,n[a],null);this._setIndexBuffer(i)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}};jo.extension={type:[y.WebGPUSystem],name:"encoder",priority:1}});var Yo,r0=p(()=>{A();Yo=class{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}};Yo.extension={type:[y.WebGPUSystem],name:"limits"}});var $o,s0=p(()=>{A();Ns();$o=class{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:Et.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){let r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=t,r.stencilReference=e;let i=this._renderer;i.pipeline.setStencilMode(t),i.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}};$o.extension={type:[y.WebGPUSystem],name:"stencil"}});var $i,$f=p(()=>{Jd();Bi();Ls();$i=class{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!jl())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){let e=this.getUniformGroupData(t);t.buffer||(t.buffer=new pe({data:new Float32Array(e.layout.size/4),usage:xt.UNIFORM|xt.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){let e=t._signature,r=this._syncFunctionHash[e];if(!r){let i=Object.keys(t.uniformStructures).map(a=>t.uniformStructures[a]),n=this._adaptor.createUboElements(i),o=this._generateUboSync(n.uboElements);r=this._syncFunctionHash[e]={layout:n,syncFunction:o}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,r){let i=this.getUniformGroupData(t);t.buffer||(t.buffer=new pe({data:new Float32Array(i.layout.size/4),usage:xt.UNIFORM|xt.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),r||(r=0),i.syncFunction(t.uniforms,e,n,r),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;let e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}});function i0(s){let t=s.map(r=>({data:r,offset:0,size:0})),e=0;for(let r=0;r<t.length;r++){let i=t[r],n=qo[i.data.type].size,o=qo[i.data.type].align;if(!qo[i.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${i.data.type}`);i.data.size>1&&(n=Math.max(n,o)*i.data.size),e=Math.ceil(e/o)*o,i.size=n,i.offset=e,e+=n}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}var qo,qf=p(()=>{"use strict";qo={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}}});var Ur,Kf=p(()=>{"use strict";Ur=[{type:"mat3x3<f32>",test:s=>s.value.a!==void 0,ubo:`
573
+ var matrix = uv[name].toArray(true);
574
+ data[offset] = matrix[0];
575
+ data[offset + 1] = matrix[1];
576
+ data[offset + 2] = matrix[2];
577
+ data[offset + 4] = matrix[3];
578
+ data[offset + 5] = matrix[4];
579
+ data[offset + 6] = matrix[5];
580
+ data[offset + 8] = matrix[6];
581
+ data[offset + 9] = matrix[7];
582
+ data[offset + 10] = matrix[8];
583
+ `,uniform:`
584
+ gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
585
+ `},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.width!==void 0,ubo:`
586
+ v = uv[name];
587
+ data[offset] = v.x;
588
+ data[offset + 1] = v.y;
589
+ data[offset + 2] = v.width;
590
+ data[offset + 3] = v.height;
591
+ `,uniform:`
592
+ cv = ud[name].value;
593
+ v = uv[name];
594
+ if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
595
+ cv[0] = v.x;
596
+ cv[1] = v.y;
597
+ cv[2] = v.width;
598
+ cv[3] = v.height;
599
+ gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
600
+ }
601
+ `},{type:"vec2<f32>",test:s=>s.type==="vec2<f32>"&&s.size===1&&s.value.x!==void 0,ubo:`
602
+ v = uv[name];
603
+ data[offset] = v.x;
604
+ data[offset + 1] = v.y;
605
+ `,uniform:`
606
+ cv = ud[name].value;
607
+ v = uv[name];
608
+ if (cv[0] !== v.x || cv[1] !== v.y) {
609
+ cv[0] = v.x;
610
+ cv[1] = v.y;
611
+ gl.uniform2f(ud[name].location, v.x, v.y);
612
+ }
613
+ `},{type:"vec4<f32>",test:s=>s.type==="vec4<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
614
+ v = uv[name];
615
+ data[offset] = v.red;
616
+ data[offset + 1] = v.green;
617
+ data[offset + 2] = v.blue;
618
+ data[offset + 3] = v.alpha;
619
+ `,uniform:`
620
+ cv = ud[name].value;
621
+ v = uv[name];
622
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
623
+ cv[0] = v.red;
624
+ cv[1] = v.green;
625
+ cv[2] = v.blue;
626
+ cv[3] = v.alpha;
627
+ gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
628
+ }
629
+ `},{type:"vec3<f32>",test:s=>s.type==="vec3<f32>"&&s.size===1&&s.value.red!==void 0,ubo:`
630
+ v = uv[name];
631
+ data[offset] = v.red;
632
+ data[offset + 1] = v.green;
633
+ data[offset + 2] = v.blue;
634
+ `,uniform:`
635
+ cv = ud[name].value;
636
+ v = uv[name];
637
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
638
+ cv[0] = v.red;
639
+ cv[1] = v.green;
640
+ cv[2] = v.blue;
641
+ gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
642
+ }
643
+ `}]});function vh(s,t,e,r){let i=[`
644
+ var v = null;
645
+ var v2 = null;
646
+ var t = 0;
647
+ var index = 0;
648
+ var name = null;
649
+ var arrayOffset = null;
650
+ `],n=0;for(let a=0;a<s.length;a++){let l=s[a],h=l.data.name,u=!1,c=0;for(let f=0;f<Ur.length;f++)if(Ur[f].test(l.data)){c=l.offset/4,i.push(`name = "${h}";`,`offset += ${c-n};`,Ur[f][t]||Ur[f].ubo),u=!0;break}if(!u)if(l.data.size>1)c=l.offset/4,i.push(e(l,c-n));else{let f=r[l.data.type];c=l.offset/4,i.push(`
651
+ v = uv.${h};
652
+ offset += ${c-n};
653
+ ${f};
654
+ `)}n=c}let o=i.join(`
655
+ `);return new Function("uv","data","dataInt32","offset",o)}var Zf=p(()=>{Kf()});function qi(s,t){return`
656
+ for (let i = 0; i < ${s*t}; i++) {
657
+ data[offset + (((i / ${s})|0) * 4) + (i % ${s})] = v[i];
658
+ }
659
+ `}var Jf,n0,Qf=p(()=>{"use strict";Jf={f32:`
660
+ data[offset] = v;`,i32:`
661
+ dataInt32[offset] = v;`,"vec2<f32>":`
662
+ data[offset] = v[0];
663
+ data[offset + 1] = v[1];`,"vec3<f32>":`
664
+ data[offset] = v[0];
665
+ data[offset + 1] = v[1];
666
+ data[offset + 2] = v[2];`,"vec4<f32>":`
667
+ data[offset] = v[0];
668
+ data[offset + 1] = v[1];
669
+ data[offset + 2] = v[2];
670
+ data[offset + 3] = v[3];`,"vec2<i32>":`
671
+ dataInt32[offset] = v[0];
672
+ dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
673
+ dataInt32[offset] = v[0];
674
+ dataInt32[offset + 1] = v[1];
675
+ dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
676
+ dataInt32[offset] = v[0];
677
+ dataInt32[offset + 1] = v[1];
678
+ dataInt32[offset + 2] = v[2];
679
+ dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
680
+ data[offset] = v[0];
681
+ data[offset + 1] = v[1];
682
+ data[offset + 4] = v[2];
683
+ data[offset + 5] = v[3];`,"mat3x3<f32>":`
684
+ data[offset] = v[0];
685
+ data[offset + 1] = v[1];
686
+ data[offset + 2] = v[2];
687
+ data[offset + 4] = v[3];
688
+ data[offset + 5] = v[4];
689
+ data[offset + 6] = v[5];
690
+ data[offset + 8] = v[6];
691
+ data[offset + 9] = v[7];
692
+ data[offset + 10] = v[8];`,"mat4x4<f32>":`
693
+ for (let i = 0; i < 16; i++) {
694
+ data[offset + i] = v[i];
695
+ }`,"mat3x2<f32>":qi(3,2),"mat4x2<f32>":qi(4,2),"mat2x3<f32>":qi(2,3),"mat4x3<f32>":qi(4,3),"mat2x4<f32>":qi(2,4),"mat3x4<f32>":qi(3,4)},n0={...Jf,"mat2x2<f32>":`
696
+ data[offset] = v[0];
697
+ data[offset + 1] = v[1];
698
+ data[offset + 2] = v[2];
699
+ data[offset + 3] = v[3];
700
+ `}});function o0(s,t){let{size:e,align:r}=qo[s.data.type],i=(r-e)/4,n=s.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
701
+ v = uv.${s.data.name};
702
+ ${t!==0?`offset += ${t};`:""}
703
+
704
+ arrayOffset = offset;
705
+
706
+ t = 0;
707
+
708
+ for(var i=0; i < ${s.data.size*(e/4)}; i++)
709
+ {
710
+ for(var j = 0; j < ${e/4}; j++)
711
+ {
712
+ ${n}[arrayOffset++] = v[t++];
713
+ }
714
+ ${i!==0?`arrayOffset += ${i};`:""}
715
+ }
716
+ `}var a0=p(()=>{qf()});function l0(s){return vh(s,"uboWgsl",o0,n0)}var h0=p(()=>{Zf();Qf();a0()});var Ko,u0=p(()=>{A();$f();qf();h0();Ko=class extends $i{constructor(){super({createUboElements:i0,generateUboSync:l0})}};Ko.extension={type:[y.WebGPUSystem],name:"ubo"}});var rs,Sh=p(()=>{Qt();Gt();rs=class extends q{constructor({buffer:t,offset:e,size:r}){super(),this.uid=$("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=$("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=r,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=$("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}});var Th,c0=p(()=>{"use strict";Th=class{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}`);let e=this.byteIndex,r=e+t*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,e}addGroup(t){let e=this.addEmptyGroup(t.length);for(let r=0;r<t.length;r++)this.data[e/4+r]=t[r];return e}destroy(){this.data=null}}});var ss,Zo,d0=p(()=>{A();Bi();Sh();Ls();c0();ks();ss=128,Zo=class{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new Th({minUniformOffsetAlignment:ss});let e=256/ss;for(let r=0;r<e;r++){let i=xt.UNIFORM|xt.COPY_DST;r===0&&(i|=xt.COPY_SRC),this._buffers.push(new pe({data:this._batchBuffer.data,usage:i}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);let r=t.buffer.data,i=this._batchBuffer.addEmptyGroup(r.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,i/4),this._bindGroupHash[t.uid]=this._getBindGroup(i/ss),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);let e=t.buffer.data,r=this._batchBuffer.addGroup(e);return this._getBufferResource(r/ss)}getArrayBindGroup(t){let e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/ss)}getArrayBufferResource(t){let r=this._batchBuffer.addGroup(t)/ss;return this._getBufferResource(r)}_getBufferResource(t){if(!this._bufferResources[t]){let e=this._buffers[t%2];this._bufferResources[t]=new rs({buffer:e,offset:(t/2|0)*256,size:ss})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){let e=new ne({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){let t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);let r=this._renderer.gpu.device.createCommandEncoder();for(let i=1;i<this._buffers.length;i++){let n=this._buffers[i];r.copyBufferToBuffer(t.getGPUBuffer(e),ss,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([r.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t]?.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}};Zo.extension={type:[y.WebGPUPipes],name:"uniformBatch"}});function Ch(s,t){for(let e in s.attributes){let r=s.attributes[e],i=t[e];i?(r.format??(r.format=i.format),r.offset??(r.offset=i.offset),r.instance??(r.instance=i.instance)):O(`Attribute ${e} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}EB(s)}function EB(s){let{buffers:t,attributes:e}=s,r={},i={};for(let n in t){let o=t[n];r[o.uid]=0,i[o.uid]=0}for(let n in e){let o=e[n];r[o.buffer.uid]+=Or(o.format).stride}for(let n in e){let o=e[n];o.stride??(o.stride=r[o.buffer.uid]),o.start??(o.start=i[o.buffer.uid]),i[o.buffer.uid]+=Or(o.format).stride}}var tp=p(()=>{pt();oo()});var dr,ep=p(()=>{Ns();dr=[];dr[Et.NONE]=void 0;dr[Et.DISABLED]={stencilWriteMask:0,stencilReadMask:0};dr[Et.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};dr[Et.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};dr[Et.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};dr[Et.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}}});function BB(s,t,e,r,i){return s<<24|t<<16|e<<10|r<<5|i}function RB(s,t,e,r,i){return e<<8|s<<5|r<<3|i<<1|t}var AB,Jo,f0=p(()=>{A();pt();tp();Ns();io();ep();AB={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};Jo=class{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(Et.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=t.colorTargetCount,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=dr[t],this._updatePipeHash())}setPipeline(t,e,r,i){let n=this.getPipeline(t,e,r);i.setPipeline(n)}getPipeline(t,e,r,i){t._layoutKey||(Ch(t,e.attributeData),this._generateBufferKey(t)),i||(i=t.topology);let n=BB(t._layoutKey,e._layoutKey,r.data,r._blendModeId,AB[i]);return this._pipeCache[n]?this._pipeCache[n]:(this._pipeCache[n]=this._createPipeline(t,e,r,i),this._pipeCache[n])}_createPipeline(t,e,r,i){let n=this._gpu.device,o=this._createVertexBufferLayouts(t,e),a=this._renderer.state.getColorTargets(r,this._colorTargetCount),l=this._stencilMode===Et.RENDERING_MASK_ADD?0:this._colorMask;for(let f=0;f<a.length;f++)a[f].writeMask=l;let h=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:i,cullMode:r.cullMode},layout:h,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(u.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:r.depthTest,depthCompare:r.depthTest?"less":"always"}),n.createRenderPipeline(u)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){let e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){let e=[],r=0,i=Object.keys(t.attributes).sort();for(let o=0;o<i.length;o++){let a=t.attributes[i[o]];e[r++]=a.offset,e[r++]=a.format,e[r++]=a.stride,e[r++]=a.instance}let n=e.join("|");return t._layoutKey=Dr(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){let e=[],r=0,i=Object.keys(t.attributeData).sort();for(let o=0;o<i.length;o++){let a=t.attributeData[i[o]];e[r++]=a.location}let n=e.join("|");return t._attributeLocationsKey=Dr(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){let r=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[r])return this._bindingNamesCache[r];let i=this._createVertexBufferLayouts(t,e),n=Object.create(null),o=e.attributeData;for(let a=0;a<i.length;a++){let h=Object.values(i[a].attributes)[0].shaderLocation;for(let u in o)if(o[u].location===h){n[a]=u;break}}return this._bindingNamesCache[r]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);let r=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[r])return this._bufferLayoutsCache[r];let i=[];return t.buffers.forEach(n=>{let o={arrayStride:0,stepMode:"vertex",attributes:[]},a=o.attributes;for(let l in e.attributeData){let h=t.attributes[l];(h.divisor??1)!==1&&O(`Attribute ${l} has an invalid divisor value of '${h.divisor}'. WebGPU only supports a divisor value of 1`),h.buffer===n&&(o.arrayStride=h.stride,o.stepMode=h.instance?"instance":"vertex",a.push({shaderLocation:e.attributeData[l].location,offset:h.offset,format:h.format}))}a.length&&i.push(o)}),this._bufferLayoutsCache[r]=i,i}_updatePipeHash(){let t=RB(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}};Jo.extension={type:[y.WebGPUSystem],name:"pipeline"}});function p0(s,t,e,r,i,n){let o=n?1:-1;return s.identity(),s.a=1/r*2,s.d=o*(1/i*2),s.tx=-1-t*s.a,s.ty=-o-e*s.d,s}var m0=p(()=>{"use strict"});function g0(s){let t=s.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var _0=p(()=>{"use strict"});var is,Ph=p(()=>{nt();te();Ri();m0();af();Zr();ce();yt();Xf();_0();Wf();is=class{constructor(t){this.rootViewPort=new rt,this.viewport=new rt,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Ii("onRenderTargetChange"),this.projectionMatrix=new R,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:r,frame:i,mipLevel:n,layer:o}){this._renderTargetStack.length=0,this.push(t,e,r,i,n??0,o??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=g0(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(t,e=!0,r,i,n=0,o=0){let a=this.getRenderTarget(t),l=this.renderTarget!==a;this.renderTarget=a,this.renderSurface=t;let h=this.getGpuRenderTarget(a);(a.pixelWidth!==h.width||a.pixelHeight!==h.height)&&(this.adaptor.resizeGpuRenderTarget(a),h.width=a.pixelWidth,h.height=a.pixelHeight);let u=a.colorTexture,c=this.viewport,f=u.arrayLayerCount||1;if((o|0)!==o&&(o|=0),o<0||o>=f)throw new Error(`[RenderTargetSystem] layer ${o} is out of bounds (arrayLayerCount=${f}).`);this.mipLevel=n|0,this.layer=o|0;let d=Math.max(u.pixelWidth>>n,1),m=Math.max(u.pixelHeight>>n,1);if(!i&&t instanceof F&&(i=t.frame),i){let g=u._resolution,_=1<<Math.max(n|0,0),x=i.x*g+.5|0,S=i.y*g+.5|0,v=i.width*g+.5|0,b=i.height*g+.5|0,C=Math.floor(x/_),T=Math.floor(S/_),P=Math.ceil(v/_),E=Math.ceil(b/_);C=Math.min(Math.max(C,0),d-1),T=Math.min(Math.max(T,0),m-1),P=Math.min(Math.max(P,1),d-C),E=Math.min(Math.max(E,1),m-T),c.x=C,c.y=T,c.width=P,c.height=E}else c.x=0,c.y=0,c.width=d,c.height=m;return p0(this.projectionMatrix,0,0,c.width/u.resolution,c.height/u.resolution,!a.isRoot),this.adaptor.startRenderPass(a,e,r,c,n,o),l&&this.onRenderTargetChange.emit(a),a}clear(t,e=Zt.ALL,r,i=this.mipLevel,n=this.layer){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,r,this.viewport,i,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=Zt.ALL,r,i,n=0,o=0){let a=this.bind(t,e,r,i,n,o);return this._renderTargetStack.push({renderTarget:a,frame:i,mipLevel:n,layer:o}),a}pop(){this._renderTargetStack.pop();let t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame,t.mipLevel,t.layer)}getRenderTarget(t){return t.isTexture&&(t=t.source),this._renderSurfaceToRenderTargetHash.get(t)??this._initRenderTarget(t)}copyToTexture(t,e,r,i,n){r.x<0&&(i.width+=r.x,n.x-=r.x,r.x=0),r.y<0&&(i.height+=r.y,n.y-=r.y,r.y=0);let{pixelWidth:o,pixelHeight:a}=t;return i.width=Math.min(i.width,o-r.x),i.height=Math.min(i.height,a-r.y),this.adaptor.copyToTexture(t,e,r,i,n)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}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 It.test(t)&&(t=xh(t).source),t instanceof Ho?e=t:t instanceof ut&&(e=new Ho({colorTextures:[t]}),t.source instanceof It&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);let r=this._gpuRenderTargetHash[e.uid];r&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(r))})),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}}});var Mh,x0=p(()=>{"use strict";Mh=class{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}});var wh,y0=p(()=>{Ri();Zr();ce();x0();wh=class{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,r,i,n){let o=this._renderer,a=this._getGpuColorTexture(t),l=o.texture.getGpuSource(e.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:r},{texture:l,origin:n},i),e}startRenderPass(t,e=!0,r,i,n=0,o=0){let l=this._renderTargetSystem.getGpuRenderTarget(t);if(o!==0&&l.msaaTextures?.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(n>0&&l.msaaTextures?.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");let h=this.getDescriptor(t,e,r,n,o);l.descriptor=h,this._renderer.pipeline.setRenderTarget(l),this._renderer.encoder.beginRenderPass(l),this._renderer.encoder.setViewport(i)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){let e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,r,i=0,n=0){typeof e=="boolean"&&(e=e?Zt.ALL:Zt.NONE);let o=this._renderTargetSystem,a=o.getGpuRenderTarget(t),l=t.colorTextures.map((c,f)=>{let d=a.contexts[f],m,g;if(d){if(n!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");m=d.getCurrentTexture().createView()}else m=this._renderer.texture.getGpuSource(c).createView({dimension:"2d",baseMipLevel:i,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1});let _=!1;a.msaaTextures[f]&&(g=m,m=this._renderer.texture.getTextureView(a.msaaTextures[f]),_=a.msaaTextures[f].transient);let x=e&Zt.COLOR?"clear":"load";return r??(r=o.defaultClearColor),{view:m,resolveTarget:g,clearValue:r,storeOp:_?"discard":"store",loadOp:x}}),h;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=a.msaa?4:1,t.depthStencilTexture.source.transient=!!a.msaaTextures[0]?.transient),t.depthStencilTexture){let c=e&Zt.STENCIL?"clear":"load",f=e&Zt.DEPTH?"clear":"load",d=t.depthStencilTexture.source.transient?"discard":"store";h={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:i,mipLevelCount:1,baseArrayLayer:n,arrayLayerCount:1}),stencilStoreOp:d,stencilLoadOp:c,depthClearValue:1,depthLoadOp:f,depthStoreOp:d}}return{colorAttachments:l,depthStencilAttachment:h}}clear(t,e=!0,r,i,n=0,o=0){if(!e)return;let{gpu:a,encoder:l}=this._renderer,h=a.device;if(l.commandEncoder===null){let c=h.createCommandEncoder(),f=this.getDescriptor(t,e,r,n,o),d=c.beginRenderPass(f);d.setViewport(i.x,i.y,i.width,i.height,0,1),d.end();let m=c.finish();h.queue.submit([m])}else this.startRenderPass(t,e,r,i,n,o)}initGpuRenderTarget(t){t.isRoot=!0;let e=new Mh;return e.colorTargetCount=t.colorTextures.length,t.colorTextures.forEach((r,i)=>{if(r instanceof It){let n=r.resource.getContext("webgpu"),o=r.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}e.contexts[i]=n}if(e.msaa=r.source.antialias,r.source.antialias){let n=new ut({width:0,height:0,sampleCount:4,transient:r.source.transient,arrayLayerCount:r.source.arrayLayerCount});e.msaaTextures[i]=n}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4,t.depthStencilTexture.source.transient=!!e.msaaTextures[0]?.transient)),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){let e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){let e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((r,i)=>{e.msaaTextures[i]?.resize(r.source.width,r.source.height,r.source._resolution)})}}});var Qo,b0=p(()=>{A();Ph();y0();Qo=class extends is{constructor(t){super(t),this.adaptor=new wh,this.adaptor.init(t,this)}};Qo.extension={type:[y.WebGPUSystem],name:"renderTarget"}});var ta,v0=p(()=>{A();ta=class{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){let e=this._gpu.device,r=t.gpuLayout.map(n=>e.createBindGroupLayout({entries:n})),i={bindGroupLayouts:r};return this._gpuProgramData[t._layoutKey]={bindGroups:r,pipeline:e.createPipelineLayout(i)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}};ta.extension={type:[y.WebGPUSystem],name:"shader"}});var me,S0=p(()=>{"use strict";me={};me.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};me.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}};me.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}};me.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};me.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}};me.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}};me["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}};me["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}};me["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}};me.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};me.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}};me.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}});var ea,T0=p(()=>{A();hr();S0();ea=class{constructor(){this.defaultState=new Kt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e){let r=me[t.blendMode]||me.normal,i=[],n={format:"bgra8unorm",writeMask:0,blend:r};for(let o=0;o<e;o++)i[o]=n;return i}destroy(){this.gpu=null}};ea.extension={type:[y.WebGPUSystem],name:"state"}});var C0,P0=p(()=>{"use strict";C0={type:"image",upload(s,t,e,r=0){let i=s.resource,n=(s.pixelWidth|0)*(s.pixelHeight|0),o=i.byteLength/n;e.device.queue.writeTexture({texture:t,origin:{x:0,y:0,z:r}},i,{offset:0,rowsPerImage:s.pixelHeight,bytesPerRow:s.pixelWidth*o},{width:s.pixelWidth,height:s.pixelHeight,depthOrArrayLayers:1})}}});var rp,IB,M0,w0=p(()=>{"use strict";rp={"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}},IB={blockBytes:4,blockWidth:1,blockHeight:1},M0={type:"compressed",upload(s,t,e,r=0){let i=s.pixelWidth,n=s.pixelHeight,o=rp[s.format]||IB;for(let a=0;a<s.resource.length;a++){let l=s.resource[a],h=Math.ceil(i/o.blockWidth)*o.blockBytes;e.device.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:r}},l,{offset:0,bytesPerRow:h},{width:Math.ceil(i/o.blockWidth)*o.blockWidth,height:Math.ceil(n/o.blockHeight)*o.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),n=Math.max(n>>1,1)}}}});function A0(s){return{type:"cube",upload(t,e,r){let i=t.faces;for(let n=0;n<E0.length;n++){let o=E0[n],a=i[o];(s[a.uploadMethodId]||s.image).upload(a,e,r,n)}}}}var E0,B0=p(()=>{"use strict";E0=["right","left","top","bottom","front","back"]});var Eh,sp=p(()=>{ct();pt();Eh={type:"image",upload(s,t,e,r=0){let i=s.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){let l=D.get().createCanvas(i.width,i.height);l.getContext("2d").drawImage(i,0,0,i.width,i.height),s.resource=l,O("ImageSource: Image element passed, converting to canvas and replacing resource.")}let n=Math.min(t.width,s.resourceWidth||s.pixelWidth),o=Math.min(t.height,s.resourceHeight||s.pixelHeight),a=s.alphaMode==="premultiply-alpha-on-upload";e.device.queue.copyExternalImageToTexture({source:i},{texture:t,origin:{x:0,y:0,z:r},premultipliedAlpha:a},{width:n,height:o})}}});var R0,I0=p(()=>{sp();R0={type:"video",upload(s,t,e,r){Eh.upload(s,t,e,r)}}});var Ah,F0=p(()=>{"use strict";Ah=class{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:`
717
+ var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
718
+ vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
719
+
720
+ struct VertexOutput {
721
+ @builtin(position) position : vec4<f32>,
722
+ @location(0) texCoord : vec2<f32>,
723
+ };
724
+
725
+ @vertex
726
+ fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
727
+ var output : VertexOutput;
728
+ output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
729
+ output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
730
+ return output;
731
+ }
732
+
733
+ @group(0) @binding(0) var imgSampler : sampler;
734
+ @group(0) @binding(1) var img : texture_2d<f32>;
735
+
736
+ @fragment
737
+ fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
738
+ return textureSample(img, imgSampler, texCoord);
739
+ }
740
+ `})),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){let 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 r=t,i=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){let l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};r=this.device.createTexture(l)}let o=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let l=0;l<i;++l){let h=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),u=n?1:0;for(let c=1;c<t.mipLevelCount;++c){let f=r.createView({baseMipLevel:u++,mipLevelCount:1,dimension:"2d",baseArrayLayer:l,arrayLayerCount:1}),d=o.beginRenderPass({colorAttachments:[{view:f,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:h}]});d.setPipeline(e),d.setBindGroup(0,m),d.draw(3,1,0,0),d.end(),h=f}}if(!n){let l={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i};for(let h=1;h<t.mipLevelCount;++h)o.copyTextureToTexture({texture:r,mipLevel:h-1},{texture:t,mipLevel:h},l),l.width=Math.ceil(l.width/2),l.height=Math.ceil(l.height/2)}return this.device.queue.submit([o.finish()]),n||r.destroy(),t}}});var ip,np,op,L0=p(()=>{ct();A();cr();Qe();Fl();ks();P0();w0();B0();sp();I0();F0();ip=class{constructor(t){this.textureView=null,this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}},np=class k0{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new zt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});let e={image:Eh,buffer:C0,video:R0,compressed:M0,...k0.uploadExtensions};this._uploads={...e,cube:A0(e)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t}initSource(t){return t._gpuData[this._renderer.uid]?.gpuTexture||this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){let h=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(h))+1}let e;t.sampleCount>1?(e=GPUTextureUsage.RENDER_ATTACHMENT,t.transient&&this._renderer.device.extensions.transientAttachment&&(e|=GPUTextureUsage.TRANSIENT_ATTACHMENT)):(e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC));let r=rp[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},i=Math.ceil(t.pixelWidth/r.blockWidth)*r.blockWidth,n=Math.ceil(t.pixelHeight/r.blockHeight)*r.blockHeight,o={label:t.label,size:{width:i,height:n,depthOrArrayLayers:t.arrayLayerCount},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpu.device.createTexture(o);return t._gpuData[this._renderer.uid]=new ip(a),this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),a}onSourceUpdate(t){let e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new Ah(this._gpu.device));let e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceUnload(t){t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(t){t._gcLastUsed=this._renderer.gc.now;let e=t._gpuData[this._renderer.uid],r=e?.gpuTexture;r?(r.width!==t.pixelWidth||r.height!==t.pixelHeight)&&(e.destroy(),this._bindGroupHash[t.uid]=null,t._gpuData[this._renderer.uid]=null,this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]?.gpuTexture||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]||this._createTextureBindGroup(t)}_createTextureBindGroup(t){let e=t.source;return this._bindGroupHash[t.uid]=new ne({0:e,1:e.style,2:new Nt({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){let e=t.source;e._gcLastUsed=this._renderer.gc.now;let r=e._gpuData[this._renderer.uid];return r||(this.initSource(e),r=e._gpuData[this._renderer.uid]),r.textureView||(r.textureView=r.gpuTexture.createView({dimension:e.viewDimension})),r.textureView}generateCanvas(t){let e=this._renderer,r=e.gpu.device.createCommandEncoder(),i=D.get().createCanvas();i.width=t.source.pixelWidth,i.height=t.source.pixelHeight;let n=i.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:D.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),r.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:i.width,height:i.height}),e.gpu.device.queue.submit([r.finish()]),i}getPixels(t){let e=this.generateCanvas(t),r=Lr.getOptimalCanvasAndContext(e.width,e.height),i=r.context;i.drawImage(e,0,0);let{width:n,height:o}=e,a=i.getImageData(0,0,n,o),l=new Uint8ClampedArray(a.data.buffer);return Lr.returnCanvasAndContext(r),{pixels:l,width:n,height:o}}destroy(){this._managedTextures.destroy();for(let t of Object.keys(this._bindGroupHash)){let e=Number(t);this._bindGroupHash[e]?.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}};np.extension={type:[y.WebGPUSystem],name:"texture"};np.uploadExtensions=Object.create(null);op=np;U.handleByMap(y.TextureUploaderWebGPU,op.uploadExtensions)});var U0={};Mr(U0,{WebGPURenderer:()=>ap});var FB,kB,LB,D0,O0,G0,ap,V0=p(()=>{A();Ob();Vb();Nb();Fi();bh();Gr();Zv();Jv();Qv();t0();e0();r0();s0();u0();d0();f0();b0();v0();T0();L0();FB=[...ji,Ko,jo,Yi,Yo,Wo,op,Qo,ta,ea,Jo,Xo,$o,zo],kB=[...yh,Zo],LB=[So,vo,bo],D0=[],O0=[],G0=[];U.handleByNamedList(y.WebGPUSystem,D0);U.handleByNamedList(y.WebGPUPipes,O0);U.handleByNamedList(y.WebGPUPipesAdaptor,G0);U.add(...FB,...kB,...LB);ap=class extends ur{constructor(){let t={name:"webgpu",type:qt.WEBGPU,systems:D0,renderPipes:O0,renderPipeAdaptors:G0};super(t)}}});var ra,N0=p(()=>{A();nt();Oi();sh();oh();yo();Vi();Af();Qr();Qe();ra=class{contextChange(t){let e=new Nt({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new R,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),r=t.limits.maxBatchableTextures,i=Di({name:"graphics",bits:[rh,nh(r),ah,Ui]});this.shader=new oe({glProgram:i,resources:{localUniforms:e,batchSamplers:fh(r)}})}execute(t,e){let r=e.context,i=r.customShader||this.shader,n=t.renderer,o=n.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(r);i.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(i),n.geometry.bind(a.geometry,i.glProgram);let h=l.instructions;for(let u=0;u<l.instructionSize;u++){let c=h[u];if(c.size){for(let f=0;f<c.textures.count;f++)n.texture.bind(c.textures.textures[f],f);n.geometry.draw(c.topology,c.size,c.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}};ra.extension={type:[y.WebGLPipesAdaptor],name:"graphics"}});var sa,H0=p(()=>{A();nt();Oi();yo();Vi();mf();Qr();yt();pt();sa=class{init(){let t=Di({name:"mesh",bits:[ah,Ub,Ui]});this._shader=new oe({glProgram:t,resources:{uTexture:F.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new R}}}})}execute(t,e){let r=t.renderer,i=e._shader;if(i){if(!i.glProgram){O("Mesh shader has no glProgram",e.shader);return}}else{i=this._shader;let n=e.texture,o=n.source;i.resources.uTexture=o,i.resources.uSampler=o.style,i.resources.textureUniforms.uniforms.uTextureMatrix=n.textureMatrix.mapCoord}i.groups[100]=r.globalUniforms.bindGroup,i.groups[101]=t.localUniformsBindGroup,r.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}};sa.extension={type:[y.WebGLPipesAdaptor],name:"mesh"}});var ia,z0=p(()=>{A();hr();ia=class{constructor(){this._tempState=Kt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,r){let i=t.renderer,n=this._didUploadHash[r.uid];i.shader.bind(r,n),n||(this._didUploadHash[r.uid]=!0),i.shader.updateUniformGroup(i.globalUniforms.uniformGroup),i.geometry.bind(e,r.glProgram)}execute(t,e){let r=t.renderer;this._tempState.blendMode=e.blendMode,r.state.set(this._tempState);let i=e.textures.textures;for(let n=0;n<e.textures.count;n++)r.texture.bind(i[n],n);r.geometry.draw(e.topology,e.size,e.start)}};ia.extension={type:[y.WebGLPipesAdaptor],name:"batch"}});var na,W0=p(()=>{"use strict";na=(s=>(s[s.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",s[s.ARRAY_BUFFER=34962]="ARRAY_BUFFER",s[s.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",s))(na||{})});var Bh,X0=p(()=>{"use strict";Bh=class{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}});var oa,j0=p(()=>{A();cr();Ls();W0();X0();oa=class{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new zt({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this.createGLBuffer(t)}bind(t){let{_gl:e}=this,r=this.getGlBuffer(t);e.bindBuffer(r.type,r.buffer)}bindBufferBase(t,e){let{_gl:r}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,r.bindBufferBase(r.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 r=0,i=this._nextBindBaseIndex;for(;r<2;){i>=this._maxBindings&&(i=this._minBaseLocation,r++);let n=this._boundBufferBases[i];if(n&&n._lastBindCallId===this._bindCallId){i++;continue}break}return e=i,this._nextBindBaseIndex=i+1,r>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){let e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,r,i){let{_gl:n}=this;r||(r=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,r*256,i||256)}updateBuffer(t){let{_gl:e}=this,r=this.getGlBuffer(t);if(t._updateID===r.updateID)return r;r.updateID=t._updateID,e.bindBuffer(r.type,r.buffer);let i=t.data,n=t.descriptor.usage&xt.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return i?r.byteLength>=i.byteLength?e.bufferSubData(r.type,0,i,0,t._updateSize/i.BYTES_PER_ELEMENT):(r.byteLength=i.byteLength,e.bufferData(r.type,i,n)):(r.byteLength=t.descriptor.size,e.bufferData(r.type,r.byteLength,n)),r}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){let r=t._gpuData[this._renderer.uid];r&&(e||this._gl.deleteBuffer(r.buffer))}createGLBuffer(t){let{_gl:e}=this,r=na.ARRAY_BUFFER;t.descriptor.usage&xt.INDEX?r=na.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&xt.UNIFORM&&(r=na.UNIFORM_BUFFER);let i=new Bh(e.createBuffer(),r);return t._gpuData[this._renderer.uid]=i,this._managedBuffers.add(t),i}resetState(){this._boundBufferBases=Object.create(null)}};oa.extension={type:[y.WebGLSystem],name:"buffer"}});var lp,$0,q0=p(()=>{ct();A();pt();lp=class Y0{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){t={...Y0.defaultOptions,...t};let e=this.multiView=t.multiView;if(t.context&&e&&(O("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),e=!1),e?this.canvas=D.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{let r=this._renderer.background.alpha<1,i=t.premultipliedAlpha??!0,n=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:r,premultipliedAlpha:i,antialias:n,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&O("multiView is disabled, but targetCanvas is not the main canvas");return}let{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 D.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);let e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let r,i=this.canvas;if(t===2&&(r=i.getContext("webgl2",e)),!r&&(r=i.getContext("webgl",e),!r))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=r,this.initFromContext(this.gl)}getExtensions(){let{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={...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={...e,colorBufferFloat:t.getExtension("EXT_color_buffer_float")};let r=t.getExtension("WEBGL_provoking_vertex");r&&r.provokingVertexWEBGL(r.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){let t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){let e=t.getContextAttributes();e&&!e.stencil&&O("Provided WebGL context does not have a stencil buffer, masks may not render correctly");let r=this.supports,i=this.webGLVersion===2,n=this.extensions;r.uint32Indices=i||!!n.uint32ElementIndex,r.uniformBufferObject=i,r.vertexArrayObject=i||!!n.vertexArrayObject,r.srgbTextures=i||!!n.srgb,r.nonPowOf2wrapping=i,r.nonPowOf2mipmaps=i,r.msaa=i,r.uint32Indices||O("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};lp.extension={type:[y.WebGLSystem],name:"context"};lp.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};$0=lp});var Rh,aa,lt,Ih=p(()=>{"use strict";Rh=(s=>(s[s.RGBA=6408]="RGBA",s[s.RGB=6407]="RGB",s[s.RG=33319]="RG",s[s.RED=6403]="RED",s[s.RGBA_INTEGER=36249]="RGBA_INTEGER",s[s.RGB_INTEGER=36248]="RGB_INTEGER",s[s.RG_INTEGER=33320]="RG_INTEGER",s[s.RED_INTEGER=36244]="RED_INTEGER",s[s.ALPHA=6406]="ALPHA",s[s.LUMINANCE=6409]="LUMINANCE",s[s.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",s[s.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",s[s.DEPTH_STENCIL=34041]="DEPTH_STENCIL",s))(Rh||{}),aa=(s=>(s[s.TEXTURE_2D=3553]="TEXTURE_2D",s[s.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",s[s.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",s[s.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",s[s.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",s[s.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",s[s.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",s[s.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",s))(aa||{}),lt=(s=>(s[s.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",s[s.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",s[s.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",s[s.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",s[s.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",s[s.UNSIGNED_INT=5125]="UNSIGNED_INT",s[s.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",s[s.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",s[s.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",s[s.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",s[s.BYTE=5120]="BYTE",s[s.SHORT=5122]="SHORT",s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",s[s.HALF_FLOAT=36193]="HALF_FLOAT",s))(lt||{})});function Z0(s){return K0[s]??K0.float32}var K0,J0=p(()=>{Ih();K0={uint8x2:lt.UNSIGNED_BYTE,uint8x4:lt.UNSIGNED_BYTE,sint8x2:lt.BYTE,sint8x4:lt.BYTE,unorm8x2:lt.UNSIGNED_BYTE,unorm8x4:lt.UNSIGNED_BYTE,snorm8x2:lt.BYTE,snorm8x4:lt.BYTE,uint16x2:lt.UNSIGNED_SHORT,uint16x4:lt.UNSIGNED_SHORT,sint16x2:lt.SHORT,sint16x4:lt.SHORT,unorm16x2:lt.UNSIGNED_SHORT,unorm16x4:lt.UNSIGNED_SHORT,snorm16x2:lt.SHORT,snorm16x4:lt.SHORT,float16x2:lt.HALF_FLOAT,float16x4:lt.HALF_FLOAT,float32:lt.FLOAT,float32x2:lt.FLOAT,float32x3:lt.FLOAT,float32x4:lt.FLOAT,uint32:lt.UNSIGNED_INT,uint32x2:lt.UNSIGNED_INT,uint32x3:lt.UNSIGNED_INT,uint32x4:lt.UNSIGNED_INT,sint32:lt.INT,sint32x2:lt.INT,sint32x3:lt.INT,sint32x4:lt.INT}});var DB,hp,la,Q0=p(()=>{A();cr();oo();tp();J0();DB={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5},hp=class{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}},la=class{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new zt({renderer:t,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){let t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);let e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=i=>e.bindVertexArrayOES(i),t.deleteVertexArray=i=>e.deleteVertexArrayOES(i));let r=this._renderer.context.extensions.vertexAttribDivisorANGLE;r&&(t.drawArraysInstanced=(i,n,o,a)=>{r.drawArraysInstancedANGLE(i,n,o,a)},t.drawElementsInstanced=(i,n,o,a,l)=>{r.drawElementsInstancedANGLE(i,n,o,a,l)},t.vertexAttribDivisor=(i,n)=>r.vertexAttribDivisorANGLE(i,n)),this._activeGeometry=null,this._activeVao=null}bind(t,e){let r=this.gl;this._activeGeometry=t;let i=this.getVao(t,e);this._activeVao!==i&&(this._activeVao=i,r.bindVertexArray(i)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){let t=this._activeGeometry,e=this._renderer.buffer;for(let r=0;r<t.buffers.length;r++){let i=t.buffers[r];e.updateBuffer(i)}t._gcLastUsed=this._renderer.gc.now}checkCompatibility(t,e){let r=t.attributes,i=e._attributeData;for(let n in i)if(!r[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){let r=t.attributes,i=e._attributeData,n=["g",t.uid];for(let o in r)i[o]&&n.push(o,i[o].location);return n.join("-")}getVao(t,e){return t._gpuData[this._renderer.uid]?.vaoCache[e._key]||this.initGeometryVao(t,e)}initGeometryVao(t,e,r=!0){let i=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);let o=this.getSignature(t,e),a=t._gpuData[this._renderer.uid];a||(a=new hp,t._gpuData[this._renderer.uid]=a,this._managedGeometries.add(t));let l=a.vaoCache,h=l[o];if(h)return l[e._key]=h,h;Ch(t,e._attributeData);let u=t.buffers;h=i.createVertexArray(),i.bindVertexArray(h);for(let c=0;c<u.length;c++){let f=u[c];n.bind(f)}return this.activateVao(t,e),l[e._key]=h,l[o]=h,i.bindVertexArray(null),h}onGeometryUnload(t,e=!1){let r=t._gpuData[this._renderer.uid];if(!r)return;let i=r.vaoCache;if(!e)for(let n in i)this._activeVao!==i[n]&&this.resetState(),this.gl.deleteVertexArray(i[n])}destroyAll(t=!1){this._managedGeometries.removeAll(t)}activateVao(t,e){let r=this._renderer.gl,i=this._renderer.buffer,n=t.attributes;t.indexBuffer&&i.bind(t.indexBuffer);let o=null;for(let a in n){let l=n[a],h=l.buffer,u=i.getGlBuffer(h),c=e._attributeData[a];if(c){o!==u&&(i.bind(h),o=u);let f=c.location;r.enableVertexAttribArray(f);let d=Or(l.format),m=Z0(l.format);if(c.format?.substring(1,4)==="int"?r.vertexAttribIPointer(f,d.size,m,l.stride,l.offset):r.vertexAttribPointer(f,d.size,m,d.normalised,l.stride,l.offset),l.instance)if(this.hasInstance){let g=l.divisor??1;r.vertexAttribDivisor(f,g)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,r,i){let{gl:n}=this._renderer,o=this._activeGeometry,a=DB[t||o.topology];if(i??(i=o.instanceCount),o.indexBuffer){let l=o.indexBuffer.data.BYTES_PER_ELEMENT,h=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;i!==1?n.drawElementsInstanced(a,e||o.indexBuffer.data.length,h,(r||0)*l,i):n.drawElements(a,e||o.indexBuffer.data.length,h,(r||0)*l)}else i!==1?n.drawArraysInstanced(a,r||0,e||o.getSize(),i):n.drawArrays(a,r||0,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}};la.extension={type:[y.WebGLSystem],name:"geometry"}});var OB,up,eS,rS=p(()=>{A();pt();Xl();Qr();hr();ce();yt();Fs();OB=new ts({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),up=class tS{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){let{useBackBuffer:e,antialias:r}={...tS.defaultOptions,...t};this.useBackBuffer=e,this._antialias=r,this._renderer.context.supports.msaa||(O("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Kt.for2d();let i=new De({vertex:`
741
+ attribute vec2 aPosition;
742
+ out vec2 vUv;
743
+
744
+ void main() {
745
+ gl_Position = vec4(aPosition, 0.0, 1.0);
746
+
747
+ vUv = (aPosition + 1.0) / 2.0;
748
+
749
+ // flip dem UVs
750
+ vUv.y = 1.0 - vUv.y;
751
+ }`,fragment:`
752
+ in vec2 vUv;
753
+ out vec4 finalColor;
754
+
755
+ uniform sampler2D uTexture;
756
+
757
+ void main() {
758
+ finalColor = texture(uTexture, vUv);
759
+ }`,name:"big-triangle"});this._bigTriangleShader=new oe({glProgram:i,resources:{uTexture:F.WHITE.source}})}renderStart(t){let e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){let r=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=r.colorTexture,t.target=this._getBackBufferTexture(r.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let 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:OB,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new F({source:new ut({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)}};up.extension={type:[y.WebGLSystem],name:"backBuffer",priority:1};up.defaultOptions={useBackBuffer:!1};eS=up});var ha,sS=p(()=>{A();ha=class{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)))}};ha.extension={type:[y.WebGLSystem],name:"colorMask"}});var ua,iS=p(()=>{A();ua=class{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){let e=this._renderer,{geometry:r,shader:i,state:n,skipSync:o,topology:a,size:l,start:h,instanceCount:u}=t;e.shader.bind(i,o),e.geometry.bind(r,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,l,h,u??r.instanceCount)}destroy(){this._renderer=null}};ua.extension={type:[y.WebGLSystem],name:"encoder"}});var ca,nS=p(()=>{A();wf();ca=class{constructor(t){this._renderer=t}contextChange(){let t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=hh(this.maxTextures,t);let e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}};ca.extension={type:[y.WebGLSystem],name:"limits"}});var da,oS=p(()=>{A();ep();Ns();da=class{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Et.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:Et.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Et.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){let r=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=dr[t],o=this._stencilCache;if(r.stencilMode=t,r.stencilReference=e,t===Et.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,i.disable(i.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,i.enable(i.STENCIL_TEST)),(t!==o.stencilMode||o.stencilReference!==e)&&(o.stencilMode=t,o.stencilReference=e,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}};da.extension={type:[y.WebGLSystem],name:"stencil"}});function aS(s){let t=s.map(n=>({data:n,offset:0,size:0})),e=16,r=0,i=0;for(let n=0;n<t.length;n++){let o=t[n];if(r=cp[o.data.type],!r)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(r=Math.max(r,e)*o.data.size);let a=r===12?16:r;o.size=r;let l=i%e;l>0&&e-l<a?i+=(e-l)%16:i+=(r-l%r)%r,o.offset=i,i+=r}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}var cp,dp=p(()=>{"use strict";cp={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 lS(s,t){let e=Math.max(cp[s.data.type]/16,1),r=s.data.value.length/s.data.size,i=(4-r%4)%4,n=s.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
760
+ v = uv.${s.data.name};
761
+ offset += ${t};
762
+
763
+ arrayOffset = offset;
764
+
765
+ t = 0;
766
+
767
+ for(var i=0; i < ${s.data.size*e}; i++)
768
+ {
769
+ for(var j = 0; j < ${r}; j++)
770
+ {
771
+ ${n}[arrayOffset++] = v[t++];
772
+ }
773
+ ${i!==0?`arrayOffset += ${i};`:""}
774
+ }
775
+ `}var hS=p(()=>{dp()});function uS(s){return vh(s,"uboStd40",lS,Jf)}var cS=p(()=>{Zf();Qf();hS()});var fa,dS=p(()=>{A();$f();dp();cS();fa=class extends $i{constructor(){super({createUboElements:aS,generateUboSync:uS})}};fa.extension={type:[y.WebGLSystem],name:"ubo"}});var Fh,fS=p(()=>{"use strict";Fh=class{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}});var kh,pS=p(()=>{te();pt();Zr();Ri();fS();kh=class{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new rt}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new rt;let t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(r,i)=>t.COLOR_ATTACHMENT0+i)}copyToTexture(t,e,r,i,n){let o=this._renderTargetSystem,a=this._renderer,l=o.getGpuRenderTarget(t),h=a.gl;return this.finishRenderPass(t),h.bindFramebuffer(h.FRAMEBUFFER,l.resolveTargetFramebuffer),a.texture.bind(e,0),h.copyTexSubImage2D(h.TEXTURE_2D,0,n.x,n.y,r.x,r.y,i.width,i.height),e}startRenderPass(t,e=!0,r,i,n=0,o=0){let a=this._renderTargetSystem,l=t.colorTexture,h=a.getGpuRenderTarget(t);if(o!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(n>0){if(h.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let u=i.y;t.isRoot&&(u=l.pixelHeight-i.height-i.y),t.colorTextures.forEach(d=>{this._renderer.texture.unbind(d)});let c=this._renderer.gl;c.bindFramebuffer(c.FRAMEBUFFER,h.framebuffer),!t.isRoot&&(h._attachedMipLevel!==n||h._attachedLayer!==o)&&(t.colorTextures.forEach((d,m)=>{let g=this._renderer.texture.getGlSource(d);if(g.target===c.TEXTURE_2D){if(o!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+m,c.TEXTURE_2D,g.texture,n)}else if(g.target===c.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");c.framebufferTextureLayer(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+m,g.texture,n,o)}else if(g.target===c.TEXTURE_CUBE_MAP){if(o<0||o>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0+m,c.TEXTURE_CUBE_MAP_POSITIVE_X+o,g.texture,n)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),h._attachedMipLevel=n,h._attachedLayer=o),t.colorTextures.length>1&&this._setDrawBuffers(t,c);let f=this._viewPortCache;(f.x!==i.x||f.y!==u||f.width!==i.width||f.height!==i.height)&&(f.x=i.x,f.y=u,f.width=i.width,f.height=i.height,c.viewport(i.x,u,i.width,i.height)),!h.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(h),this.clear(t,e,r)}finishRenderPass(t){let r=this._renderTargetSystem.getGpuRenderTarget(t);if(!r.msaa)return;let i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,r.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,r.framebuffer),i.blitFramebuffer(0,0,r.width,r.height,0,0,r.width,r.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,r.framebuffer)}initGpuRenderTarget(t){let r=this._renderer.gl,i=new Fh;return i._attachedMipLevel=0,i._attachedLayer=0,t.colorTexture instanceof It?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),r.bindFramebuffer(r.FRAMEBUFFER,null),i)}destroyGpuRenderTarget(t){let 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(r=>{e.deleteRenderbuffer(r)}),t.msaaRenderBuffer=null}clear(t,e,r,i,n=0,o=0){if(!e)return;if(o!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");let a=this._renderTargetSystem;typeof e=="boolean"&&(e=e?Zt.ALL:Zt.NONE);let l=this._renderer.gl;if(e&Zt.COLOR){r??(r=a.defaultClearColor);let h=this._clearColorCache,u=r;(h[0]!==u[0]||h[1]!==u[1]||h[2]!==u[2]||h[3]!==u[3])&&(h[0]=u[0],h[1]=u[1],h[2]=u[2],h[3]=u[3],l.clearColor(u[0],u[1],u[2],u[3]))}l.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;let r=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,r),(t.stencil||t.depth)&&this._resizeStencil(r)}_initColor(t,e){let r=this._renderer,i=r.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((a,l)=>{let h=a.source;h.antialias&&(r.context.supports.msaa?e.msaa=!0:O("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),r.texture.bindSource(h,0);let u=r.texture.getGlSource(h),c=u.texture;if(u.target===i.TEXTURE_2D)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,i.TEXTURE_2D,c,0);else if(u.target===i.TEXTURE_2D_ARRAY){if(r.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,c,0,0)}else if(u.target===i.TEXTURE_CUBE_MAP)i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,i.TEXTURE_CUBE_MAP_POSITIVE_X,c,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),e.msaa){let a=i.createFramebuffer();e.framebuffer=a,i.bindFramebuffer(i.FRAMEBUFFER,a),t.colorTextures.forEach((l,h)=>{let u=i.createRenderbuffer();e.msaaRenderBuffer[h]=u})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){let r=t.colorTexture.source;if(e.width=r.pixelWidth,e.height=r.pixelHeight,e._attachedMipLevel=0,e._attachedLayer=0,t.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(r.width,r.height,r._resolution)}),e.msaa){let i=this._renderer,n=i.gl,o=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,o),t.colorTextures.forEach((a,l)=>{let h=a.source;i.texture.bindSource(h,0);let c=i.texture.getGlSource(h).internalFormat,f=e.msaaRenderBuffer[l];n.bindRenderbuffer(n.RENDERBUFFER,f),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,c,h.pixelWidth,h.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+l,n.RENDERBUFFER,f)})}}_initStencil(t){if(t.framebuffer===null)return;let e=this._renderer.gl,r=e.createRenderbuffer();t.depthStencilRenderBuffer=r,e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,r),this._resizeStencil(t)}_resizeStencil(t){let 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){let e=t.colorTexture.resource;this._renderer.context.multiView&&It.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&It.test(t.colorTexture.resource)){let e=this._renderer.context.canvas,r=t.colorTexture;r.context2D.drawImage(e,0,r.pixelHeight-e.height)}}_setDrawBuffers(t,e){let r=t.colorTextures.length,i=this._drawBuffersCache[r];if(this._renderer.context.webGLVersion===1){let n=this._renderer.context.extensions.drawBuffers;n?n.drawBuffersWEBGL(i):O("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(i)}}});var pa,mS=p(()=>{A();Ph();pS();pa=class extends is{constructor(t){super(t),this.adaptor=new kh,this.adaptor.init(t,this)}};pa.extension={type:[y.WebGLSystem],name:"renderTarget"}});function gS(s,t){let e=[],r=[`
776
+ var g = s.groups;
777
+ var sS = r.shader;
778
+ var p = s.glProgram;
779
+ var ugS = r.uniformGroup;
780
+ var resources;
781
+ `],i=!1,n=0,o=t._getProgramData(s.glProgram);for(let l in s.groups){let h=s.groups[l];e.push(`
782
+ resources = g[${l}].resources;
783
+ `);for(let u in h.resources){let c=h.resources[u];if(c instanceof Nt)if(c.ubo){let f=s._uniformBindMap[l][Number(u)];e.push(`
784
+ sS.bindUniformBlock(
785
+ resources[${u}],
786
+ '${f}',
787
+ ${s.glProgram._uniformBlockData[f].index}
788
+ );
789
+ `)}else e.push(`
790
+ ugS.updateUniformGroup(resources[${u}], p, sD);
791
+ `);else if(c instanceof rs){let f=s._uniformBindMap[l][Number(u)];e.push(`
792
+ sS.bindUniformBlock(
793
+ resources[${u}],
794
+ '${f}',
795
+ ${s.glProgram._uniformBlockData[f].index}
796
+ );
797
+ `)}else if(c instanceof ut){let f=s._uniformBindMap[l][u],d=o.uniformData[f];d&&(i||(i=!0,r.push(`
798
+ var tS = r.texture;
799
+ `)),t._gl.uniform1i(d.location,n),e.push(`
800
+ tS.bind(resources[${u}], ${n});
801
+ `),n++)}}}let a=[...r,...e].join(`
802
+ `);return new Function("r","s","sD",a)}var _S=p(()=>{Sh();Qe();ce()});var Lh,xS=p(()=>{"use strict";Lh=class{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 fp(s,t,e){let r=s.createShader(t);return s.shaderSource(r,e),s.compileShader(r),r}var yS=p(()=>{"use strict"});function pp(s){let t=new Array(s);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Dh(s,t){switch(s){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 pp(2*t);case"bvec3":return pp(3*t);case"bvec4":return pp(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}var mp=p(()=>{"use strict"});function gp(s,t){if(!Oh){let e=Object.keys(bS);Oh={};for(let r=0;r<e.length;++r){let i=e[r];Oh[s[i]]=bS[i]}}return Oh[t]}function vS(s,t){let e=gp(s,t);return GB[e]||"float32"}var Oh,bS,GB,_p=p(()=>{"use strict";Oh=null,bS={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"},GB={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 SS(s,t,e=!1){let r={},i=t.getProgramParameter(s,t.ACTIVE_ATTRIBUTES);for(let o=0;o<i;o++){let a=t.getActiveAttrib(s,o);if(a.name.startsWith("gl_"))continue;let l=vS(t,a.type);r[a.name]={location:0,format:l,stride:Or(l).stride,offset:0,instance:!1,start:0}}let n=Object.keys(r);if(e){n.sort((o,a)=>o>a?1:-1);for(let o=0;o<n.length;o++)r[n[o]].location=o,t.bindAttribLocation(s,o,n[o]);t.linkProgram(s)}else for(let o=0;o<n.length;o++)r[n[o]].location=t.getAttribLocation(s,n[o]);return r}var TS=p(()=>{oo();_p()});function CS(s,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};let e={},r=t.getProgramParameter(s,t.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<r;i++){let n=t.getActiveUniformBlockName(s,i),o=t.getUniformBlockIndex(s,n),a=t.getActiveUniformBlockParameter(s,i,t.UNIFORM_BLOCK_DATA_SIZE);e[n]={name:n,index:o,size:a}}return e}var PS=p(()=>{"use strict"});function MS(s,t){let e={},r=t.getProgramParameter(s,t.ACTIVE_UNIFORMS);for(let i=0;i<r;i++){let n=t.getActiveUniform(s,i),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=gp(t,n.type);e[o]={name:o,index:i,type:l,size:n.size,isArray:a,value:Dh(l,n.size)}}return e}var wS=p(()=>{mp();_p()});function ES(s,t){let e=s.getShaderSource(t);if(e===null){console.error("PixiJS Error: Could not retrieve shader source (WebGL context may be lost).");return}let r=e.split(`
803
+ `).map((u,c)=>`${c}: ${u}`),i=s.getShaderInfoLog(t)??"",n=i.split(`
804
+ `),o={},a=n.map(u=>parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(u=>u&&!o[u]?(o[u]=!0,!0):!1),l=[""];a.forEach(u=>{r[u-1]=`%c${r[u-1]}%c`,l.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});let h=r.join(`
805
+ `);l[0]=h,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...l),console.groupEnd()}function AS(s,t,e,r){s.getProgramParameter(t,s.LINK_STATUS)||(s.getShaderParameter(e,s.COMPILE_STATUS)||ES(s,e),s.getShaderParameter(r,s.COMPILE_STATUS)||ES(s,r),console.error("PixiJS Error: Could not initialize shader."),s.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",s.getProgramInfoLog(t)))}var BS=p(()=>{"use strict"});function RS(s,t){let e=fp(s,s.VERTEX_SHADER,t.vertex),r=fp(s,s.FRAGMENT_SHADER,t.fragment),i=s.createProgram();s.attachShader(i,e),s.attachShader(i,r);let n=t.transformFeedbackVaryings;n&&(typeof s.transformFeedbackVaryings!="function"?O("TransformFeedback is not supported but TransformFeedbackVaryings are given."):s.transformFeedbackVaryings(i,n.names,n.bufferMode==="separate"?s.SEPARATE_ATTRIBS:s.INTERLEAVED_ATTRIBS)),s.linkProgram(i),s.getProgramParameter(i,s.LINK_STATUS)||AS(s,i,e,r),t._attributeData=SS(i,s,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=MS(i,s),t._uniformBlockData=CS(i,s),s.deleteShader(e),s.deleteShader(r);let o={};for(let l in t._uniformData){let h=t._uniformData[l];o[l]={location:s.getUniformLocation(i,l),value:Dh(h.type,h.size)}}return new Lh(i,o)}var IS=p(()=>{pt();xS();yS();mp();TS();PS();wS();BS()});var Gh,ma,FS=p(()=>{A();_S();IS();Gh={textureCount:0,blockIndex:0},ma=class{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;Gh.textureCount=0,Gh.blockIndex=0;let r=this._shaderSyncFunctions[t.glProgram._key];r||(r=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),r(this._renderer,t,Gh)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Gh)}bindUniformBlock(t,e,r=0){let i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),o=t._bufferResource;o||this._renderer.ubo.updateUniformGroup(t);let a=t.buffer,l=i.updateBuffer(a),h=i.freeLocationForBufferBase(l);if(o){let{offset:c,size:f}=t;c===0&&f===a.data.byteLength?i.bindBufferBase(l,h):i.bindBufferRange(l,h,c)}else i.getLastBindBaseLocation(l)!==h&&i.bindBufferBase(l,h);let u=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[r]!==h&&(n.uniformBlockBindings[r]=h,this._renderer.gl.uniformBlockBinding(n.program,u,h))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;let e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){let e=t._key;return this._programDataHash[e]=RS(this._gl,t),this._programDataHash[e]}destroy(){for(let t of Object.keys(this._programDataHash))this._programDataHash[t].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return gS(t,e)}resetState(){this._activeProgram=null}};ma.extension={type:[y.WebGLSystem],name:"shader"}});var kS,LS,DS=p(()=>{"use strict";kS={f32:`if (cv !== v) {
806
+ cu.value = v;
807
+ gl.uniform1f(location, v);
808
+ }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
809
+ cv[0] = v[0];
810
+ cv[1] = v[1];
811
+ gl.uniform2f(location, v[0], v[1]);
812
+ }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
813
+ cv[0] = v[0];
814
+ cv[1] = v[1];
815
+ cv[2] = v[2];
816
+ gl.uniform3f(location, v[0], v[1], v[2]);
817
+ }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
818
+ cv[0] = v[0];
819
+ cv[1] = v[1];
820
+ cv[2] = v[2];
821
+ cv[3] = v[3];
822
+ gl.uniform4f(location, v[0], v[1], v[2], v[3]);
823
+ }`,i32:`if (cv !== v) {
824
+ cu.value = v;
825
+ gl.uniform1i(location, v);
826
+ }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
827
+ cv[0] = v[0];
828
+ cv[1] = v[1];
829
+ gl.uniform2i(location, v[0], v[1]);
830
+ }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
831
+ cv[0] = v[0];
832
+ cv[1] = v[1];
833
+ cv[2] = v[2];
834
+ gl.uniform3i(location, v[0], v[1], v[2]);
835
+ }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
836
+ cv[0] = v[0];
837
+ cv[1] = v[1];
838
+ cv[2] = v[2];
839
+ cv[3] = v[3];
840
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
841
+ }`,u32:`if (cv !== v) {
842
+ cu.value = v;
843
+ gl.uniform1ui(location, v);
844
+ }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
845
+ cv[0] = v[0];
846
+ cv[1] = v[1];
847
+ gl.uniform2ui(location, v[0], v[1]);
848
+ }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
849
+ cv[0] = v[0];
850
+ cv[1] = v[1];
851
+ cv[2] = v[2];
852
+ gl.uniform3ui(location, v[0], v[1], v[2]);
853
+ }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
854
+ cv[0] = v[0];
855
+ cv[1] = v[1];
856
+ cv[2] = v[2];
857
+ cv[3] = v[3];
858
+ gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
859
+ }`,bool:`if (cv !== v) {
860
+ cu.value = v;
861
+ gl.uniform1i(location, v);
862
+ }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
863
+ cv[0] = v[0];
864
+ cv[1] = v[1];
865
+ gl.uniform2i(location, v[0], v[1]);
866
+ }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
867
+ cv[0] = v[0];
868
+ cv[1] = v[1];
869
+ cv[2] = v[2];
870
+ gl.uniform3i(location, v[0], v[1], v[2]);
871
+ }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
872
+ cv[0] = v[0];
873
+ cv[1] = v[1];
874
+ cv[2] = v[2];
875
+ cv[3] = v[3];
876
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
877
+ }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},LS={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 OS(s,t){let e=[`
878
+ var v = null;
879
+ var cv = null;
880
+ var cu = null;
881
+ var t = 0;
882
+ var gl = renderer.gl;
883
+ var name = null;
884
+ `];for(let r in s.uniforms){if(!t[r]){s.uniforms[r]instanceof Nt?s.uniforms[r].ubo?e.push(`
885
+ renderer.shader.bindUniformBlock(uv.${r}, "${r}");
886
+ `):e.push(`
887
+ renderer.shader.updateUniformGroup(uv.${r});
888
+ `):s.uniforms[r]instanceof rs&&e.push(`
889
+ renderer.shader.bindBufferResource(uv.${r}, "${r}");
890
+ `);continue}let i=s.uniformStructures[r],n=!1;for(let o=0;o<Ur.length;o++){let a=Ur[o];if(i.type===a.type&&a.test(i)){e.push(`name = "${r}";`,Ur[o].uniform),n=!0;break}}if(!n){let a=(i.size===1?kS:LS)[i.type].replace("location",`ud["${r}"].location`);e.push(`
891
+ cu = ud["${r}"];
892
+ cv = cu.value;
893
+ v = uv["${r}"];
894
+ ${a};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
895
+ `))}var GS=p(()=>{Sh();Qe();Kf();DS()});var ga,US=p(()=>{A();GS();ga=class{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,r){let i=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==i.uniformDirtyGroups[t.uid])&&(i.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(i.uniformData,t.uniforms,this._renderer,r))}_getUniformSyncFunction(t,e){return this._uniformGroupSyncHash[t._signature]?.[e._key]||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){let r=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),i=this._getSignature(t,e._uniformData,"u");return this._cache[i]||(this._cache[i]=this._generateUniformsSync(t,e._uniformData)),r[e._key]=this._cache[i],r[e._key]}_generateUniformsSync(t,e){return OS(t,e)}_getSignature(t,e,r){let i=t.uniforms,n=[`${r}-`];for(let o in i)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}};ga.extension={type:[y.WebGLSystem],name:"uniformGroup"}});function VS(s){let t={};if(t.normal=[s.ONE,s.ONE_MINUS_SRC_ALPHA],t.add=[s.ONE,s.ONE],t.multiply=[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.screen=[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],t["screen-npm"]=[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],t.erase=[s.ZERO,s.ONE_MINUS_SRC_ALPHA],!(s instanceof D.get().getWebGLRenderingContext()))t.min=[s.ONE,s.ONE,s.ONE,s.ONE,s.MIN,s.MIN],t.max=[s.ONE,s.ONE,s.ONE,s.ONE,s.MAX,s.MAX];else{let r=s.getExtension("EXT_blend_minmax");r&&(t.min=[s.ONE,s.ONE,s.ONE,s.ONE,r.MIN_EXT,r.MIN_EXT],t.max=[s.ONE,s.ONE,s.ONE,s.ONE,r.MAX_EXT,r.MAX_EXT])}return t}var NS=p(()=>{ct()});var UB,VB,NB,HB,zB,WB,HS,zS,WS=p(()=>{A();hr();NS();UB=0,VB=1,NB=2,HB=3,zB=4,WB=5,HS=class xp{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[UB]=this.setBlend,this.map[VB]=this.setOffset,this.map[NB]=this.setCullFace,this.map[HB]=this.setDepthTest,this.map[zB]=this.setFrontFace,this.map[WB]=this.setDepthMask,this.checks=[],this.defaultState=Kt.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=VS(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,r=0;for(;e;)e&1&&this.map[r].call(this,!!(t.data&1<<r)),e>>=1,r++;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(xp._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(xp._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;let 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;let e=this.blendModesMap[t],r=this.gl;e.length===2?r.blendFunc(e[0],e[1]):r.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,r.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.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){let r=this.checks.indexOf(t);e&&r===-1?this.checks.push(t):!e&&r!==-1&&this.checks.splice(r,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}};HS.extension={type:[y.WebGLSystem],name:"state"};zS=HS});var Uh,XS=p(()=>{Ih();Uh=class{constructor(t){this.target=aa.TEXTURE_2D,this._layerInitMask=0,this.texture=t,this.width=-1,this.height=-1,this.type=lt.UNSIGNED_BYTE,this.internalFormat=Rh.RGBA,this.format=Rh.RGBA,this.samplerType=0}destroy(){}}});var jS,YS=p(()=>{"use strict";jS={id:"buffer",upload(s,t,e,r,i,n=!1){let o=i||t.target;!n&&t.width===s.width&&t.height===s.height?e.texSubImage2D(o,0,0,0,s.width,s.height,t.format,t.type,s.resource):e.texImage2D(o,0,t.internalFormat,s.width,s.height,0,t.format,t.type,s.resource),t.width=s.width,t.height=s.height}}});var XB,$S,qS=p(()=>{"use strict";XB={"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},$S={id:"compressed",upload(s,t,e,r,i,n){let o=i??t.target;e.pixelStorei(e.UNPACK_ALIGNMENT,4);let a=s.pixelWidth,l=s.pixelHeight,h=!!XB[s.format];for(let u=0;u<s.resource.length;u++){let c=s.resource[u];h?e.compressedTexImage2D(o,u,t.internalFormat,a,l,0,c):e.texImage2D(o,u,t.internalFormat,a,l,0,t.format,t.type,c),a=Math.max(a>>1,1),l=Math.max(l>>1,1)}}}});function ZS(s){return{id:"cube",upload(t,e,r,i){let n=t.faces;for(let o=0;o<KS.length;o++){let a=KS[o],l=n[a];(s[l.uploadMethodId]||s.image).upload(l,e,r,i,aa.TEXTURE_CUBE_MAP_POSITIVE_X+o,(e._layerInitMask&1<<o)===0),e._layerInitMask|=1<<o}e.width=t.pixelWidth,e.height=t.pixelHeight}}}var KS,JS=p(()=>{Ih();KS=["right","left","top","bottom","front","back"]});function jB(s,t,e,r,i,n,o,a,l,h){if(!h){l&&s.texImage2D(t,0,e.internalFormat,r,i,0,e.format,e.type,null),s.texSubImage2D(t,0,0,0,n,o,e.format,e.type,a);return}if(!l){s.texSubImage2D(t,0,0,0,e.format,e.type,a);return}s.texImage2D(t,0,e.internalFormat,r,i,0,e.format,e.type,a)}function YB(s,t,e,r,i,n,o,a,l,h){if(!h){l&&s.texImage2D(t,0,e.internalFormat,r,i,0,e.format,e.type,null),s.texSubImage2D(t,0,0,0,e.format,e.type,a);return}if(!l){s.texSubImage2D(t,0,0,0,e.format,e.type,a);return}s.texImage2D(t,0,e.internalFormat,e.format,e.type,a)}var Vh,yp=p(()=>{"use strict";Vh={id:"image",upload(s,t,e,r,i,n=!1){let o=i||t.target,a=s.pixelWidth,l=s.pixelHeight,h=s.resourceWidth,u=s.resourceHeight,c=r===2,f=n||t.width!==a||t.height!==l,d=h>=a&&u>=l,m=s.resource;(c?jB:YB)(e,o,t,a,l,h,u,m,f,d),t.width=a,t.height=l}}});function QS(){let{userAgent:s}=D.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(s)}var tT=p(()=>{ct()});var $B,eT,rT=p(()=>{tT();yp();$B=QS(),eT={id:"video",upload(s,t,e,r,i,n=$B){if(!s.isValid){let o=i??t.target;e.texImage2D(o,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Vh.upload(s,t,e,r,i,n)}}});var bp,sT,Nh,iT,nT=p(()=>{"use strict";bp={linear:9729,nearest:9728},sT={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},Nh={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},iT={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519}});function vp(s,t,e,r,i,n,o,a){let l=n;if(!a||s.addressModeU!=="repeat"||s.addressModeV!=="repeat"||s.addressModeW!=="repeat"){let h=Nh[o?"clamp-to-edge":s.addressModeU],u=Nh[o?"clamp-to-edge":s.addressModeV],c=Nh[o?"clamp-to-edge":s.addressModeW];t[i](l,t.TEXTURE_WRAP_S,h),t[i](l,t.TEXTURE_WRAP_T,u),t.TEXTURE_WRAP_R&&t[i](l,t.TEXTURE_WRAP_R,c)}if((!a||s.magFilter!=="linear")&&t[i](l,t.TEXTURE_MAG_FILTER,bp[s.magFilter]),e){if(!a||s.mipmapFilter!=="linear"){let h=sT[s.minFilter][s.mipmapFilter];t[i](l,t.TEXTURE_MIN_FILTER,h)}}else t[i](l,t.TEXTURE_MIN_FILTER,bp[s.minFilter]);if(r&&s.maxAnisotropy>1){let h=Math.min(s.maxAnisotropy,t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](l,r.TEXTURE_MAX_ANISOTROPY_EXT,h)}s.compare&&t[i](l,t.TEXTURE_COMPARE_FUNC,iT[s.compare])}var oT=p(()=>{nT()});function aT(s){return{r8unorm:s.RED,r8snorm:s.RED,r8uint:s.RED,r8sint:s.RED,r16uint:s.RED,r16sint:s.RED,r16float:s.RED,rg8unorm:s.RG,rg8snorm:s.RG,rg8uint:s.RG,rg8sint:s.RG,r32uint:s.RED,r32sint:s.RED,r32float:s.RED,rg16uint:s.RG,rg16sint:s.RG,rg16float:s.RG,rgba8unorm:s.RGBA,"rgba8unorm-srgb":s.RGBA,rgba8snorm:s.RGBA,rgba8uint:s.RGBA,rgba8sint:s.RGBA,bgra8unorm:s.RGBA,"bgra8unorm-srgb":s.RGBA,rgb9e5ufloat:s.RGB,rgb10a2unorm:s.RGBA,rg11b10ufloat:s.RGB,rg32uint:s.RG,rg32sint:s.RG,rg32float:s.RG,rgba16uint:s.RGBA,rgba16sint:s.RGBA,rgba16float:s.RGBA,rgba32uint:s.RGBA,rgba32sint:s.RGBA,rgba32float:s.RGBA,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT,depth24plus:s.DEPTH_COMPONENT,"depth24plus-stencil8":s.DEPTH_STENCIL,depth32float:s.DEPTH_COMPONENT,"depth32float-stencil8":s.DEPTH_STENCIL}}var lT=p(()=>{"use strict"});function hT(s,t){let e={},r=s.RGBA;return s instanceof D.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":s.SRGB8_ALPHA8,"bgra8unorm-srgb":s.SRGB8_ALPHA8},r=s.RGBA8),{r8unorm:s.R8,r8snorm:s.R8_SNORM,r8uint:s.R8UI,r8sint:s.R8I,r16uint:s.R16UI,r16sint:s.R16I,r16float:s.R16F,rg8unorm:s.RG8,rg8snorm:s.RG8_SNORM,rg8uint:s.RG8UI,rg8sint:s.RG8I,r32uint:s.R32UI,r32sint:s.R32I,r32float:s.R32F,rg16uint:s.RG16UI,rg16sint:s.RG16I,rg16float:s.RG16F,rgba8unorm:s.RGBA,...e,rgba8snorm:s.RGBA8_SNORM,rgba8uint:s.RGBA8UI,rgba8sint:s.RGBA8I,bgra8unorm:r,rgb9e5ufloat:s.RGB9_E5,rgb10a2unorm:s.RGB10_A2,rg11b10ufloat:s.R11F_G11F_B10F,rg32uint:s.RG32UI,rg32sint:s.RG32I,rg32float:s.RG32F,rgba16uint:s.RGBA16UI,rgba16sint:s.RGBA16I,rgba16float:s.RGBA16F,rgba32uint:s.RGBA32UI,rgba32sint:s.RGBA32I,rgba32float:s.RGBA32F,stencil8:s.STENCIL_INDEX8,depth16unorm:s.DEPTH_COMPONENT16,depth24plus:s.DEPTH_COMPONENT24,"depth24plus-stencil8":s.DEPTH24_STENCIL8,depth32float:s.DEPTH_COMPONENT32F,"depth32float-stencil8":s.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}:{}}}var uT=p(()=>{ct()});function cT(s){return{r8unorm:s.UNSIGNED_BYTE,r8snorm:s.BYTE,r8uint:s.UNSIGNED_BYTE,r8sint:s.BYTE,r16uint:s.UNSIGNED_SHORT,r16sint:s.SHORT,r16float:s.HALF_FLOAT,rg8unorm:s.UNSIGNED_BYTE,rg8snorm:s.BYTE,rg8uint:s.UNSIGNED_BYTE,rg8sint:s.BYTE,r32uint:s.UNSIGNED_INT,r32sint:s.INT,r32float:s.FLOAT,rg16uint:s.UNSIGNED_SHORT,rg16sint:s.SHORT,rg16float:s.HALF_FLOAT,rgba8unorm:s.UNSIGNED_BYTE,"rgba8unorm-srgb":s.UNSIGNED_BYTE,rgba8snorm:s.BYTE,rgba8uint:s.UNSIGNED_BYTE,rgba8sint:s.BYTE,bgra8unorm:s.UNSIGNED_BYTE,"bgra8unorm-srgb":s.UNSIGNED_BYTE,rgb9e5ufloat:s.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:s.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:s.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:s.UNSIGNED_INT,rg32sint:s.INT,rg32float:s.FLOAT,rgba16uint:s.UNSIGNED_SHORT,rgba16sint:s.SHORT,rgba16float:s.HALF_FLOAT,rgba32uint:s.UNSIGNED_INT,rgba32sint:s.INT,rgba32float:s.FLOAT,stencil8:s.UNSIGNED_BYTE,depth16unorm:s.UNSIGNED_SHORT,depth24plus:s.UNSIGNED_INT,"depth24plus-stencil8":s.UNSIGNED_INT_24_8,depth32float:s.FLOAT,"depth32float-stencil8":s.FLOAT_32_UNSIGNED_INT_24_8_REV}}var dT=p(()=>{"use strict"});function fT(s){return{"2d":s.TEXTURE_2D,cube:s.TEXTURE_CUBE_MAP,"1d":null,"3d":s?.TEXTURE_3D||null,"2d-array":s?.TEXTURE_2D_ARRAY||null,"cube-array":s?.TEXTURE_CUBE_MAP_ARRAY||null}}var pT=p(()=>{"use strict"});var qB,Sp,Tp,gT=p(()=>{ct();A();cr();yt();XS();YS();qS();JS();yp();rT();oT();lT();uT();dT();pT();qB=4,Sp=class mT{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new zt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});let e={image:Vh,buffer:jS,video:eT,compressed:$S,...mT.uploadExtensions};this._uploads={...e,cube:ZS(e)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=hT(t,this._renderer.context.extensions),this._mapFormatToType=cT(t),this._mapFormatToFormat=aT(t),this._mapViewDimensionToGlTarget=fT(t)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(F.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){let r=t.source;t?(this.bindSource(r,e),this._useSeparateSamplers&&this._bindSampler(r.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){let r=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=F.EMPTY.source);let i=this.getGlSource(t);r.bindTexture(i.target,i.texture)}}_bindSampler(t,e=0){let r=this._gl;if(!t){this._boundSamplers[e]=null,r.bindSampler(e,null);return}let i=this._getGlSampler(t);this._boundSamplers[e]!==i&&(this._boundSamplers[e]=i,r.bindSampler(e,i))}unbind(t){let e=t.source,r=this._boundTextures,i=this._gl;for(let n=0;n<r.length;n++)if(r[n]===e){this._activateLocation(n);let o=this.getGlSource(e);i.bindTexture(o.target,null),r[n]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){let e=this._gl,r=new Uh(e.createTexture());if(r.type=this._mapFormatToType[t.format],r.internalFormat=this._mapFormatToInternalFormat[t.format],r.format=this._mapFormatToFormat[t.format],r.target=this._mapViewDimensionToGlTarget[t.viewDimension],r.target===null)throw new Error(`Unsupported view dimension: ${t.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(t.uploadMethodId==="cube"&&(r.target=e.TEXTURE_CUBE_MAP),t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){let n=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(n))+1}return t._gpuData[this._renderer.uid]=r,this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(t),this.updateStyle(t,!1),r}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){let r=this._gl,i=this.getGlSource(t);r.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=t,vp(t.style,r,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",i.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){let r=t._gpuData[this._renderer.uid];r&&(e||(this.unbind(t),this._gl.deleteTexture(r.texture)),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(t){let e=this._gl,r=this.getGlSource(t);e.bindTexture(r.target,r.texture),this._boundTextures[this._activeTextureLocation]=t;let i=t.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==i&&(this._premultiplyAlpha=i,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i)),this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,r,e,this._renderer.context.webGLVersion);else if(r.target===e.TEXTURE_2D)this._initEmptyTexture2D(r,t);else if(r.target===e.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(r,t);else if(r.target===e.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(r,t);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(r,t),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);let r=this.getGlSource(t);this._gl.generateMipmap(r.target)}_initEmptyTexture2D(t,e){let r=this._gl;r.texImage2D(r.TEXTURE_2D,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let i=Math.max(e.pixelWidth>>1,1),n=Math.max(e.pixelHeight>>1,1);for(let o=1;o<e.mipLevelCount;o++)r.texImage2D(r.TEXTURE_2D,o,t.internalFormat,i,n,0,t.format,t.type,null),i=Math.max(i>>1,1),n=Math.max(n>>1,1)}_initEmptyTexture2DArray(t,e){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");let r=this._gl,i=Math.max(e.arrayLayerCount|0,1);r.texImage3D(r.TEXTURE_2D_ARRAY,0,t.internalFormat,e.pixelWidth,e.pixelHeight,i,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a<e.mipLevelCount;a++)r.texImage3D(r.TEXTURE_2D_ARRAY,a,t.internalFormat,n,o,i,0,t.format,t.type,null),n=Math.max(n>>1,1),o=Math.max(o>>1,1)}_initEmptyTextureCube(t,e){let r=this._gl,i=6;for(let a=0;a<i;a++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),o=Math.max(e.pixelHeight>>1,1);for(let a=1;a<e.mipLevelCount;a++){for(let l=0;l<i;l++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,a,t.internalFormat,n,o,0,t.format,t.type,null);n=Math.max(n>>1,1),o=Math.max(o>>1,1)}}_applyMipRange(t,e){if(this._renderer.context.webGLVersion!==2||e.mipLevelCount<=1)return;let r=this._gl,i=Math.max((e.mipLevelCount|0)-1,0);r.texParameteri(t.target,r.TEXTURE_BASE_LEVEL,0),r.texParameteri(t.target,r.TEXTURE_MAX_LEVEL,i)}_initSampler(t){let e=this._gl,r=this._gl.createSampler();return this._glSamplers[t._resourceId]=r,vp(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",r,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){let{pixels:e,width:r,height:i}=this.getPixels(t),n=D.get().createCanvas();n.width=r,n.height=i;let o=n.getContext("2d");if(o){let a=o.createImageData(r,i);a.data.set(e),o.putImageData(a,0,0)}return n}getPixels(t){let e=t.source.resolution,r=t.frame,i=Math.max(Math.round(r.width*e),1),n=Math.max(Math.round(r.height*e),1),o=new Uint8Array(qB*i*n),a=this._renderer,l=a.renderTarget.getRenderTarget(t),h=a.renderTarget.getGpuRenderTarget(l),u=a.gl;return u.bindFramebuffer(u.FRAMEBUFFER,h.resolveTargetFramebuffer),u.readPixels(Math.round(r.x*e),Math.round(r.y*e),i,n,u.RGBA,u.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:i,height:n}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(F.EMPTY.source),this._boundSamplers=Object.create(null);let t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}};Sp.extension={type:[y.WebGLSystem],name:"texture"};Sp.uploadExtensions=Object.create(null);Tp=Sp;U.handleByMap(y.TextureUploaderWebGL,Tp.uploadExtensions)});var bT={};Mr(bT,{WebGLRenderer:()=>Ki});var KB,ZB,JB,_T,xT,yT,Ki,Cp=p(()=>{A();N0();H0();z0();Fi();bh();Gr();j0();q0();Q0();rS();sS();iS();nS();oS();dS();mS();FS();US();WS();gT();KB=[...ji,fa,eS,$0,ca,oa,Tp,pa,la,ga,ma,ua,zS,da,ha],ZB=[...yh],JB=[ia,sa,ra],_T=[],xT=[],yT=[];U.handleByNamedList(y.WebGLSystem,_T);U.handleByNamedList(y.WebGLPipes,xT);U.handleByNamedList(y.WebGLPipesAdaptor,yT);U.add(...KB,...ZB,...JB);Ki=class extends ur{constructor(){let t={name:"webgl",type:qt.WEBGL,systems:_T,renderPipes:xT,renderPipeAdaptors:yT};super(t)}}});function vT(s){let t=s.length;if(t<6)return 1;let e=0;for(let r=0,i=s[t-2],n=s[t-1];r<t;r+=2){let o=s[r],a=s[r+1];e+=(o-i)*(a+n),i=o,n=a}return e<0?-1:1}var ST=p(()=>{"use strict"});function TT(s,t,e,r,i,n,o,a){let l=s-e*i,h=t-r*i,u=s+e*n,c=t+r*n,f,d;o?(f=r,d=-e):(f=-r,d=e);let m=l+f,g=h+d,_=u+f,x=c+d;return a.push(m,g),a.push(_,x),2}function Ws(s,t,e,r,i,n,o,a){let l=e-s,h=r-t,u=Math.atan2(l,h),c=Math.atan2(i-s,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let f=u,d=c-u,m=Math.abs(d),g=Math.sqrt(l*l+h*h),_=(15*m*Math.sqrt(g)/Math.PI>>0)+1,x=d/_;if(f+=x,a){o.push(s,t),o.push(e,r);for(let S=1,v=f;S<_;S++,v+=x)o.push(s,t),o.push(s+Math.sin(v)*g,t+Math.cos(v)*g);o.push(s,t),o.push(i,n)}else{o.push(e,r),o.push(s,t);for(let S=1,v=f;S<_;S++,v+=x)o.push(s+Math.sin(v)*g,t+Math.cos(v)*g),o.push(s,t);o.push(i,n),o.push(s,t)}return _*2}function Zi(s,t,e,r,i,n){let o=1e-4;if(s.length===0)return;let a=t,l=a.alignment;if(t.alignment!==.5){let W=vT(s);e&&(W*=-1),l=(l-.5)*W+.5}let h=new et(s[0],s[1]),u=new et(s[s.length-2],s[s.length-1]),c=r,f=Math.abs(h.x-u.x)<o&&Math.abs(h.y-u.y)<o;if(c){s=s.slice(),f&&(s.pop(),s.pop(),u.set(s[s.length-2],s[s.length-1]));let W=(h.x+u.x)*.5,_t=(u.y+h.y)*.5;s.unshift(W,_t),s.push(W,_t)}let d=i,m=s.length/2,g=s.length,_=d.length/2,x=a.width/2,S=x*x,v=a.miterLimit*a.miterLimit,b=s[0],C=s[1],T=s[2],P=s[3],E=0,L=0,B=-(C-P),w=b-T,I=0,G=0,H=Math.sqrt(B*B+w*w);B/=H,w/=H,B*=x,w*=x;let gt=l,k=(1-gt)*2,V=gt*2;c||(a.cap==="round"?g+=Ws(b-B*(k-V)*.5,C-w*(k-V)*.5,b-B*k,C-w*k,b+B*V,C+w*V,d,!0)+2:a.cap==="square"&&(g+=TT(b,C,B,w,k,V,!0,d))),d.push(b-B*k,C-w*k),d.push(b+B*V,C+w*V);for(let W=1;W<m-1;++W){b=s[(W-1)*2],C=s[(W-1)*2+1],T=s[W*2],P=s[W*2+1],E=s[(W+1)*2],L=s[(W+1)*2+1],B=-(C-P),w=b-T,H=Math.sqrt(B*B+w*w),B/=H,w/=H,B*=x,w*=x,I=-(P-L),G=T-E,H=Math.sqrt(I*I+G*G),I/=H,G/=H,I*=x,G*=x;let _t=T-b,Ot=C-P,jt=T-E,kt=L-P,Lt=_t*jt+Ot*kt,it=Ot*jt-kt*_t,Tr=it<0;if(Math.abs(it)<.001*Math.abs(Lt)){d.push(T-B*k,P-w*k),d.push(T+B*V,P+w*V),Lt>=0&&(a.join==="round"?g+=Ws(T,P,T-B*k,P-w*k,T-I*k,P-G*k,d,!1)+4:g+=2,d.push(T-I*V,P-G*V),d.push(T+I*k,P+G*k));continue}let sl=(-B+b)*(-w+P)-(-B+T)*(-w+C),Fn=(-I+E)*(-G+P)-(-I+T)*(-G+L),kn=(_t*Fn-jt*sl)/it,Cr=(kt*sl-Ot*Fn)/it,ys=(kn-T)*(kn-T)+(Cr-P)*(Cr-P),Ye=T+(kn-T)*k,ve=P+(Cr-P)*k,Se=T-(kn-T)*V,$e=P-(Cr-P)*V,Yr=Math.min(_t*_t+Ot*Ot,jt*jt+kt*kt),Pr=Tr?k:V,Ln=Yr+Pr*Pr*S;ys<=Ln?a.join==="bevel"||ys/S>v?(Tr?(d.push(Ye,ve),d.push(T+B*V,P+w*V),d.push(Ye,ve),d.push(T+I*V,P+G*V)):(d.push(T-B*k,P-w*k),d.push(Se,$e),d.push(T-I*k,P-G*k),d.push(Se,$e)),g+=2):a.join==="round"?Tr?(d.push(Ye,ve),d.push(T+B*V,P+w*V),g+=Ws(T,P,T+B*V,P+w*V,T+I*V,P+G*V,d,!0)+4,d.push(Ye,ve),d.push(T+I*V,P+G*V)):(d.push(T-B*k,P-w*k),d.push(Se,$e),g+=Ws(T,P,T-B*k,P-w*k,T-I*k,P-G*k,d,!1)+4,d.push(T-I*k,P-G*k),d.push(Se,$e)):(d.push(Ye,ve),d.push(Se,$e)):(d.push(T-B*k,P-w*k),d.push(T+B*V,P+w*V),a.join==="round"?Tr?g+=Ws(T,P,T+B*V,P+w*V,T+I*V,P+G*V,d,!0)+2:g+=Ws(T,P,T-B*k,P-w*k,T-I*k,P-G*k,d,!1)+2:a.join==="miter"&&ys/S<=v&&(Tr?(d.push(Se,$e),d.push(Se,$e)):(d.push(Ye,ve),d.push(Ye,ve)),g+=2),d.push(T-I*k,P-G*k),d.push(T+I*V,P+G*V),g+=2)}b=s[(m-2)*2],C=s[(m-2)*2+1],T=s[(m-1)*2],P=s[(m-1)*2+1],B=-(C-P),w=b-T,H=Math.sqrt(B*B+w*w),B/=H,w/=H,B*=x,w*=x,d.push(T-B*k,P-w*k),d.push(T+B*V,P+w*V),c||(a.cap==="round"?g+=Ws(T-B*(k-V)*.5,P-w*(k-V)*.5,T-B*k,P-w*k,T+B*V,P+w*V,d,!1)+2:a.cap==="square"&&(g+=TT(T,P,B,w,k,V,!1,d)));let at=1e-4*1e-4;for(let W=_;W<g+_-2;++W)b=d[W*2],C=d[W*2+1],T=d[(W+1)*2],P=d[(W+1)*2+1],E=d[(W+2)*2],L=d[(W+2)*2+1],!(Math.abs(b*(P-L)+T*(L-C)+E*(C-P))<at)&&n.push(W,W+1,W+2)}var Hh=p(()=>{ke();ST()});function PT(s,t){for(let e=0;e<t.length;e++){let r=t[e];s.addColorStop(r.offset,r.color)}}function MT(s,t){let e=D.get().createCanvas(s,t),r=e.getContext("2d");return{canvas:e,context:r}}function e1(s){let t=s[0]??{};return(typeof t=="number"||s[1])&&(N("8.5.2","use options object instead"),t={type:"linear",start:{x:s[0],y:s[1]},end:{x:s[2],y:s[3]},textureSpace:s[4],textureSize:s[5]??ae.defaultLinearOptions.textureSize}),t}var CT,Mp,ae,Xs=p(()=>{se();ct();nt();Ci();yt();Gt();Rt();Kc();CT=[{offset:0,color:"white"},{offset:1,color:"black"}],Mp=class Pp{constructor(...t){this.uid=$("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=e1(t);e={...e.type==="radial"?Pp.defaultRadialOptions:Pp.defaultLinearOptions,...gl(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(i=>{this.addColorStop(i.offset,i.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Z.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:r,y:i}=this.end,n=r-t,o=i-e,a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){let _=t;t=r,r=_,n*=-1}if(o<0){let _=e;e=i,i=_,o*=-1}}let l=this.colorStops.length?this.colorStops:CT,h=this._textureSize,{canvas:u,context:c}=MT(h,1),f=a?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);PT(f,l),c.fillStyle=f,c.fillRect(0,0,h,1),this.texture=new F({source:new xe({resource:u,addressMode:this._wrapMode})});let d=Math.sqrt(n*n+o*o),m=Math.atan2(o,n),g=new R;g.scale(d/h,1),g.rotate(m),g.translate(t,e),this.textureSpace==="local"&&g.scale(h,h),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;let t=this.colorStops.length?this.colorStops:CT,e=this._textureSize,{canvas:r,context:i}=MT(e,e),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,h=this.innerRadius,u=this.outerRadius,c=a-u,f=l-u,d=e/(u*2),m=(n-c)*d,g=(o-f)*d,_=i.createRadialGradient(m,g,h*d,(a-c)*d,(l-f)*d,u*d);PT(_,t),i.fillStyle=t[t.length-1].color,i.fillRect(0,0,e,e),i.fillStyle=_,i.translate(m,g),i.rotate(this.rotation),i.scale(1,this.scale),i.translate(-m,-g),i.fillRect(0,0,e,e),this.texture=new F({source:new xe({resource:r,addressMode:this._wrapMode})});let x=new R;this.textureSpace==="local"?x.scale(2*u,2*u):x.scale(1/d,1/d),x.translate(c,f),this.transform=x}destroy(){this.texture?.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}`}};Mp.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Mp.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};ae=Mp});function r1(s){return s.texture!==void 0}var wT,tr,_a=p(()=>{nt();Gt();wT={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"}},tr=class{constructor(t,e){this.uid=$("fillPattern"),this._tick=0,this.transform=new R;let r=r1(t)?t:{texture:t,repetition:e};this.texture=r.texture,this.textureSpace=r.textureSpace??"global";let i=r.repetition;i&&(this.texture.source.style.addressModeU=wT[i].addressModeU,this.texture.source.style.addressModeV=wT[i].addressModeV)}setTransform(t){if(t){if(this.transform.equals(t))return;this.transform.copyFrom(t)}else{if(this.transform.isIdentity())return;this.transform.identity()}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}}});function ET(s,t,e,r,i,n,o,a=null){let l=0;e*=t,i*=n;let h=a.a,u=a.b,c=a.c,f=a.d,d=a.tx,m=a.ty;for(;l<o;){let g=s[e],_=s[e+1];r[i]=h*g+c*_+d,r[i+1]=u*g+f*_+m,i+=n,e+=t,l++}}function AT(s,t,e,r){let i=0;for(t*=e;i<r;)s[t]=0,s[t+1]=0,t+=e,i++}var BT=p(()=>{"use strict"});function wp(s,t,e,r,i){let n=t.a,o=t.b,a=t.c,l=t.d,h=t.tx,u=t.ty;e||(e=0),r||(r=2),i||(i=s.length/r-e);let c=e*r;for(let f=0;f<i;f++){let d=s[c],m=s[c+1];s[c]=n*d+a*m+h,s[c+1]=o*d+l*m+u,c+=r}}var RT=p(()=>{"use strict"});var s1,js,Ep=p(()=>{nt();Hn();s1=new R,js=class{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(){let t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,r=this.renderable;return r?or(e,r.groupColor)+(this.alpha*r.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||s1}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 Ji,IT,FT,kT=p(()=>{A();Ji={extension:{type:y.ShapeBuilder,name:"circle"},build(s,t){let e,r,i,n,o,a;if(s.type==="circle"){let b=s;if(o=a=b.radius,o<=0)return!1;e=b.x,r=b.y,i=n=0}else if(s.type==="ellipse"){let b=s;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,r=b.y,i=n=0}else{let b=s,C=b.width/2,T=b.height/2;e=b.x+C,r=b.y+T,o=a=Math.max(0,Math.min(b.radius,Math.min(C,T))),i=C-o,n=T-a}if(i<0||n<0)return!1;let l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(i?4:0)+(n?4:0);if(h===0)return!1;if(l===0)return t[0]=t[6]=e+i,t[1]=t[3]=r+n,t[2]=t[4]=e-i,t[5]=t[7]=r-n,!0;let u=0,c=l*4+(i?2:0)+2,f=c,d=h,m=i+o,g=n,_=e+m,x=e-m,S=r+g;if(t[u++]=_,t[u++]=S,t[--c]=S,t[--c]=x,n){let b=r-g;t[f++]=x,t[f++]=b,t[--d]=b,t[--d]=_}for(let b=1;b<l;b++){let C=Math.PI/2*(b/l),T=i+Math.cos(C)*o,P=n+Math.sin(C)*a,E=e+T,L=e-T,B=r+P,w=r-P;t[u++]=E,t[u++]=B,t[--c]=B,t[--c]=L,t[f++]=L,t[f++]=w,t[--d]=w,t[--d]=E}m=i,g=n+a,_=e+m,x=e-m,S=r+g;let v=r-g;return t[u++]=_,t[u++]=S,t[--d]=v,t[--d]=_,i&&(t[u++]=x,t[u++]=S,t[--d]=v,t[--d]=x),!0},triangulate(s,t,e,r,i,n){if(s.length===0)return;let o=0,a=0;for(let u=0;u<s.length;u+=2)o+=s[u],a+=s[u+1];o/=s.length/2,a/=s.length/2;let l=r;t[l*e]=o,t[l*e+1]=a;let h=l++;for(let u=0;u<s.length;u+=2)t[l*e]=s[u],t[l*e+1]=s[u+1],u>0&&(i[n++]=l,i[n++]=h,i[n++]=l-1),l++;i[n++]=h+1,i[n++]=h,i[n++]=l-1}},IT={...Ji,extension:{...Ji.extension,name:"ellipse"}},FT={...Ji,extension:{...Ji.extension,name:"roundedRectangle"}}});function LT(s,t,e,r){let i=1e-4;if(s.length===0)return;let n=s[0],o=s[1],a=s[s.length-2],l=s[s.length-1],h=t||Math.abs(n-a)<i&&Math.abs(o-l)<i,u=e,c=s.length/2,f=u.length/2;for(let d=0;d<c;d++)u.push(s[d*2]),u.push(s[d*2+1]);for(let d=0;d<c-1;d++)r.push(f+d,f+d+1);h&&r.push(f+c-1,f)}var DT=p(()=>{});function zh(s,t,e,r,i,n,o){let a=ob(s,t,2);if(!a)return;for(let h=0;h<a.length;h+=3)n[o++]=a[h]+i,n[o++]=a[h+1]+i,n[o++]=a[h+2]+i;let l=i*r;for(let h=0;h<s.length;h+=2)e[l]=s[h],e[l+1]=s[h+1],l+=r}var Ap=p(()=>{ab()});var i1,OT,GT=p(()=>{A();Ap();i1=[],OT={extension:{type:y.ShapeBuilder,name:"polygon"},build(s,t){for(let e=0;e<s.points.length;e++)t[e]=s.points[e];return!0},triangulate(s,t,e,r,i,n){zh(s,i1,t,e,r,i,n)}}});var UT,VT=p(()=>{A();UT={extension:{type:y.ShapeBuilder,name:"rectangle"},build(s,t){let e=s,r=e.x,i=e.y,n=e.width,o=e.height;return n>0&&o>0?(t[0]=r,t[1]=i,t[2]=r+n,t[3]=i,t[4]=r+n,t[5]=i+o,t[6]=r,t[7]=i+o,!0):!1},triangulate(s,t,e,r,i,n){let o=0;r*=e,t[r+o]=s[0],t[r+o+1]=s[1],o+=e,t[r+o]=s[2],t[r+o+1]=s[3],o+=e,t[r+o]=s[6],t[r+o+1]=s[7],o+=e,t[r+o]=s[4],t[r+o+1]=s[5],o+=e;let a=r/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}}});var NT,HT=p(()=>{A();NT={extension:{type:y.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,!0},triangulate(s,t,e,r,i,n){let o=0;r*=e,t[r+o]=s[0],t[r+o+1]=s[1],o+=e,t[r+o]=s[2],t[r+o+1]=s[3],o+=e,t[r+o]=s[4],t[r+o+1]=s[5];let a=r/e;i[n++]=a,i[n++]=a+1,i[n++]=a+2}}});function Wh(s,t,e,r){let i=t.matrix?s.copyFrom(t.matrix).invert():s.identity();if(t.textureSpace==="local"){let o=e.getBounds(o1);t.width&&o.pad(t.width);let{x:a,y:l}=o,h=1/o.width,u=1/o.height,c=-a*h,f=-l*u,d=i.a,m=i.b,g=i.c,_=i.d;i.a*=h,i.b*=h,i.c*=u,i.d*=u,i.tx=c*d+f*g+i.tx,i.ty=c*m+f*_+i.ty}else i.translate(t.texture.frame.x,t.texture.frame.y),i.scale(1/t.texture.source.width,1/t.texture.source.height);let n=t.texture.source.style;return!(t.fill instanceof ae)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),r&&i.append(n1.copyFrom(r).invert()),i}var n1,o1,Bp=p(()=>{nt();te();Xs();n1=new R,o1=new rt});function WT(s,t){let{geometryData:e,batches:r}=t;r.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let i=0;i<s.instructions.length;i++){let n=s.instructions[i];if(n.action==="texture")h1(n.data,r,e);else if(n.action==="fill"||n.action==="stroke"){let o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,h=n.data.hole;o&&h&&zT(h.shapePath,l,!0,r,e),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),zT(a,l,o,r,e)}}}function h1(s,t,e){let r=[],i=ns.rectangle,n=a1;n.x=s.dx,n.y=s.dy,n.width=s.dw,n.height=s.dh;let o=s.transform;if(!i.build(n,r))return;let{vertices:a,uvs:l,indices:h}=e,u=h.length,c=a.length/2;o&&wp(r,o),i.triangulate(r,a,2,c,h,u);let f=s.image,d=f.uvs;l.push(d.x0,d.y0,d.x1,d.y1,d.x3,d.y3,d.x2,d.y2);let m=Pt.get(js);m.indexOffset=u,m.indexSize=h.length-u,m.attributeOffset=c,m.attributeSize=a.length/2-c,m.baseColor=s.style,m.alpha=s.alpha,m.texture=f,m.geometryData=e,t.push(m)}function zT(s,t,e,r,i){let{vertices:n,uvs:o,indices:a}=i;s.shapePrimitives.forEach(({shape:l,transform:h,holes:u})=>{let c=[],f=ns[l.type];if(!f.build(l,c))return;let d=a.length,m=n.length/2,g="triangle-list";if(h&&wp(c,h),e){let v=l.closePath??!0,b=t;b.pixelLine?(LT(c,v,n,a),g="line-list"):Zi(c,b,!1,v,n,a)}else if(u){let v=[],b=c.slice();u1(u).forEach(T=>{v.push(b.length/2),b.push(...T)}),zh(b,v,n,2,m,a,d)}else f.triangulate(c,n,2,m,a,d);let _=o.length/2,x=t.texture;if(x!==F.WHITE){let v=Wh(l1,t,l,h);ET(n,2,m,o,_,2,n.length/2-m,v)}else AT(o,_,2,n.length/2-m);let S=Pt.get(js);S.indexOffset=d,S.indexSize=a.length-d,S.attributeOffset=m,S.attributeSize=n.length/2-m,S.baseColor=t.color,S.alpha=t.alpha,S.texture=x,S.geometryData=i,S.topology=g,r.push(S)})}function u1(s){let t=[];for(let e=0;e<s.length;e++){let r=s[e].shape,i=[];ns[r.type].build(r,i)&&t.push(i)}return t}var ns,a1,l1,Xh=p(()=>{A();nt();te();BT();RT();yt();Er();Ep();kT();Hh();DT();GT();VT();HT();Bp();Ap();ns={};U.handleByMap(y.ShapeBuilder,ns);U.add(UT,OT,NT,Ji,IT,FT);a1=new rt,l1=new R});function p1(s,t,e){s.beginPath();for(let r=0;r<e.length;r+=3){let i=e[r]*2,n=e[r+1]*2,o=e[r+2]*2;s.moveTo(t[i],t[i+1]),s.lineTo(t[n],t[n+1]),s.lineTo(t[o],t[o+1]),s.closePath()}s.fill()}function m1(s){return`#${(s&16777215).toString(16).padStart(6,"0")}`}function g1(s,t,e,r,i,n){n=Math.max(0,Math.min(n,Math.min(r,i)/2)),s.moveTo(t+n,e),s.lineTo(t+r-n,e),s.quadraticCurveTo(t+r,e,t+r,e+n),s.lineTo(t+r,e+i-n),s.quadraticCurveTo(t+r,e+i,t+r-n,e+i),s.lineTo(t+n,e+i),s.quadraticCurveTo(t,e+i,t,e+i-n),s.lineTo(t,e+n),s.quadraticCurveTo(t,e,t+n,e)}function Yh(s,t){switch(t.type){case"rectangle":{let e=t;s.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{let e=t;g1(s,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{let e=t;s.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{let e=t;s.ellipse?s.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2):(s.save(),s.translate(e.x,e.y),s.scale(e.halfWidth,e.halfHeight),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{let e=t;s.moveTo(e.x,e.y),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.closePath();break}case"polygon":default:{let e=t,r=e.points;if(!r?.length)break;s.moveTo(r[0],r[1]);for(let i=2;i<r.length;i+=2)s.lineTo(r[i],r[i+1]);e.closePath&&s.closePath();break}}}function _1(s,t){if(!t?.length)return!1;for(let e=0;e<t.length;e++){let r=t[e];if(!r?.shape)continue;let i=r.transform,n=i&&!i.isIdentity();n&&(s.save(),s.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),Yh(s,r.shape),n&&s.restore()}return!0}function x1(s,t,e,r){let i=s.fill;if(i instanceof ae){i.buildGradient();let o=i.texture;if(o){let a=K.getTintedPattern(o,t),l=e?Rp.copyFrom(e).scale(o.source.pixelWidth,o.source.pixelHeight):Rp.copyFrom(i.transform);return r&&!s.textureSpace&&l.append(r),K.applyPatternTransform(a,l),a}}if(i instanceof tr){let o=K.getTintedPattern(i.texture,t);return K.applyPatternTransform(o,i.transform,!1),o}let n=s.texture;if(n&&n!==F.WHITE){if(!n.source.resource)return c1;let o=K.getTintedPattern(n,t),a=e?Rp.copyFrom(e).scale(n.source.pixelWidth,n.source.pixelHeight):s.matrix;return K.applyPatternTransform(o,a),o}return m1(t)}var c1,jh,d1,f1,Rp,xa,XT=p(()=>{A();mi();nt();wi();yt();dl();Hn();Hh();Xs();_a();Xh();Bp();c1="#808080",jh=new R,d1=new R,f1=new R,Rp=new R;xa=class{constructor(){this.shader=null}contextChange(t){}execute(t,e){let r=t.renderer,i=r.canvasContext,n=i.activeContext,o=e.groupTransform,a=r.globalUniforms.globalUniformData?.worldColor??4294967295,l=e.groupColorAlpha,h=(a>>>24&255)/255,u=(l>>>24&255)/255,c=r.filter?.alphaMultiplier??1,f=h*u*c;if(f<=0)return;let d=a&16777215,m=l&16777215,g=Br(or(m,d)),_=r._roundPixels|e._roundPixels;n.save(),i.setContextTransform(o,_===1),i.setBlendMode(e.groupBlendMode);let x=e.context.instructions;for(let S=0;S<x.length;S++){let v=x[S];if(v.action==="texture"){let w=v.data,I=w.image,G=I?K.getCanvasSource(I):null;if(!G)continue;let H=w.alpha*f;if(H<=0)continue;let gt=or(w.style,g);n.globalAlpha=H;let k=G;gt!==16777215&&(k=K.getTintedCanvas({texture:I},gt));let V=I.frame,at=I.source._resolution??I.source.resolution??1,W=V.x*at,_t=V.y*at,Ot=V.width*at,jt=V.height*at;k!==G&&(W=0,_t=0);let kt=w.transform,Lt=kt&&!kt.isIdentity(),it=I.rotate;Lt||it?(jh.copyFrom(o),Lt&&jh.append(kt),it&&Q.matrixAppendRotationInv(jh,it,w.dx,w.dy,w.dw,w.dh),i.setContextTransform(jh,_===1)):i.setContextTransform(o,_===1),n.drawImage(k,W,_t,k===G?Ot:k.width,k===G?jt:k.height,it?0:w.dx,it?0:w.dy,w.dw,w.dh),(Lt||it)&&i.setContextTransform(o,_===1);continue}let b=v.data,C=b?.path?.shapePath;if(!C?.shapePrimitives?.length)continue;let T=b.style,P=or(T.color,g),E=T.alpha*f;if(E<=0)continue;let L=v.action==="stroke";if(n.globalAlpha=E,L){let w=T;n.lineWidth=w.width,n.lineCap=w.cap,n.lineJoin=w.join,n.miterLimit=w.miterLimit}let B=C.shapePrimitives;if(!L&&b.hole?.shapePath?.shapePrimitives?.length){let w=B[B.length-1];w.holes=b.hole.shapePath.shapePrimitives}for(let w=0;w<B.length;w++){let I=B[w];if(!I?.shape)continue;let G=I.transform,H=G&&!G.isIdentity(),gt=T.texture&&T.texture!==F.WHITE,k=T.textureSpace==="global"?G:null,V=gt?Wh(d1,T,I.shape,k):null,at=H?f1.copyFrom(o).append(G):o,W=x1(T,P,V,at);if(H&&(n.save(),n.transform(G.a,G.b,G.c,G.d,G.tx,G.ty)),L){let _t=T;if(_t.alignment!==.5&&!_t.pixelLine){let jt=[],kt=[],Lt=[];if(ns[I.shape.type]?.build(I.shape,jt)){let Tr=I.shape.closePath??!0;Zi(jt,_t,!1,Tr,kt,Lt),n.fillStyle=W,p1(n,kt,Lt)}else n.strokeStyle=W,n.beginPath(),Yh(n,I.shape),n.stroke()}else n.strokeStyle=W,n.beginPath(),Yh(n,I.shape),n.stroke()}else n.fillStyle=W,n.beginPath(),Yh(n,I.shape),_1(n,I.holes)?n.fill("evenodd"):n.fill();H&&n.restore()}}n.restore()}destroy(){this.shader=null}};xa.extension={type:[y.CanvasPipesAdaptor],name:"graphics"}});var Ip,jT,YT=p(()=>{A();mi();nt();dl();Hn();wi();Ip=class Ys{static _getPatternRepeat(t,e){let r=t&&t!=="clamp-to-edge",i=e&&e!=="clamp-to-edge";return r&&i?"repeat":r?"repeat-x":i?"repeat-y":"no-repeat"}start(t,e,r){}execute(t,e){let r=e.elements;if(!r||!r.length)return;let i=t.renderer,n=i.canvasContext,o=n.activeContext;for(let a=0;a<r.length;a++){let l=r[a];if(!l.packAsQuad)continue;let h=l,u=h.texture,c=u?K.getCanvasSource(u):null;if(!c)continue;let f=u.source.style,d=n.smoothProperty,m=f.scaleMode!=="nearest";o[d]!==m&&(o[d]=m),n.setBlendMode(e.blendMode);let g=i.globalUniforms.globalUniformData?.worldColor??4294967295,_=h.color,x=(g>>>24&255)/255,S=(_>>>24&255)/255,v=i.filter?.alphaMultiplier??1,b=x*S*v;if(b<=0)continue;o.globalAlpha=b;let C=g&16777215,T=_&16777215,P=Br(or(T,C)),E=u.frame,L=f.addressModeU??f.addressMode,B=f.addressModeV??f.addressMode,w=Ys._getPatternRepeat(L,B),I=u.source._resolution??u.source.resolution??1,G=h.renderable?.renderGroup?.isCachedAsTexture,H=E.x*I,gt=E.y*I,k=E.width*I,V=E.height*I,at=h.bounds,W=i.renderTarget.renderTarget.isRoot,_t=at.minX,Ot=at.minY,jt=at.maxX-at.minX,kt=at.maxY-at.minY,Lt=u.rotate,it=u.uvs,Tr=Math.min(it.x0,it.x1,it.x2,it.x3,it.y0,it.y1,it.y2,it.y3),sl=Math.max(it.x0,it.x1,it.x2,it.x3,it.y0,it.y1,it.y2,it.y3),Fn=w!=="no-repeat"&&(Tr<0||sl>1),Cr=Lt&&!(!Fn&&(P!==16777215||Lt));Cr?(Ys._tempPatternMatrix.copyFrom(h.transform),Q.matrixAppendRotationInv(Ys._tempPatternMatrix,Lt,_t,Ot,jt,kt),n.setContextTransform(Ys._tempPatternMatrix,h.roundPixels===1,void 0,G&&W)):n.setContextTransform(h.transform,h.roundPixels===1,void 0,G&&W);let ys=jt,Ye=kt,ve=Cr?0:_t,Se=Cr?0:Ot;if(!Cr&&h.roundPixels===1&&(ve|=0,Se|=0),Fn){let $e=c,Yr=P!==16777215&&!Lt,Pr=E.width<=u.source.width&&E.height<=u.source.height;Yr&&Pr&&($e=K.getTintedCanvas({texture:u},P));let Ln=o.createPattern($e,w);if(!Ln)continue;let Ac=ys,Pg=Ye;if(Ac===0||Pg===0)continue;let Mg=1/Ac,wg=1/Pg,Eg=(it.x1-it.x0)*Mg,Ag=(it.y1-it.y0)*Mg,Bg=(it.x3-it.x0)*wg,Rg=(it.y3-it.y0)*wg,UE=it.x0-Eg*ve-Bg*Se,VE=it.y0-Ag*ve-Rg*Se,Bc=u.source.pixelWidth,Rc=u.source.pixelHeight;Ys._tempPatternMatrix.set(Eg*Bc,Ag*Rc,Bg*Bc,Rg*Rc,UE*Bc,VE*Rc),K.applyPatternTransform(Ln,Ys._tempPatternMatrix),o.fillStyle=Ln,o.fillRect(ve,Se,ys,Ye)}else{let Yr=P!==16777215||Lt?K.getTintedCanvas({texture:u},P):c,Pr=Yr!==c;o.drawImage(Yr,Pr?0:H,Pr?0:gt,Pr?Yr.width:k,Pr?Yr.height:V,ve,Se,ys,Ye)}}}};Ip._tempPatternMatrix=new R;Ip.extension={type:[y.CanvasPipesAdaptor],name:"batch"};jT=Ip});var ya,$T=p(()=>{A();ya=class{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,r){this._renderer.renderPipes.batch.break(r);let i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;let n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,r.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,r){this._renderer.renderPipes.batch.break(r);let i=this._colorStack;this._colorStackIndex--;let n=i[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,r.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){}destroy(){this._renderer=null,this._colorStack=null}};ya.extension={type:[y.CanvasPipes],name:"colorMask"}});function qT(s){let t=[];return s.replace(y1,(e,r,i)=>{let n=r.toLowerCase(),o=r,a=v1(i);for(n==="m"&&a.length>2&&(t.push([o,...a.splice(0,2)]),n="l",o=o==="m"?"l":"L");;){if(a.length===Fp[n])return t.push([o,...a]),"";if(a.length<Fp[n])throw new Error("malformed path data");t.push([o,...a.splice(0,Fp[n])])}}),t}function v1(s){let t=s.match(b1);return t?t.map(Number):[]}var Fp,y1,b1,KT=p(()=>{Fp={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},y1=/([astvzqmhlc])([^astvzqmhlc]*)/gi,b1=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi});function ZT(s,t){let e=qT(s),r=[],i=null,n=0,o=0;for(let a=0;a<e.length;a++){let l=e[a],h=l[0],u=l;switch(h){case"M":n=u[1],o=u[2],t.moveTo(n,o);break;case"m":n+=u[1],o+=u[2],t.moveTo(n,o);break;case"H":n=u[1],t.lineTo(n,o);break;case"h":n+=u[1],t.lineTo(n,o);break;case"V":o=u[1],t.lineTo(n,o);break;case"v":o+=u[1],t.lineTo(n,o);break;case"L":n=u[1],o=u[2],t.lineTo(n,o);break;case"l":n+=u[1],o+=u[2],t.lineTo(n,o);break;case"C":n=u[5],o=u[6],t.bezierCurveTo(u[1],u[2],u[3],u[4],n,o);break;case"c":t.bezierCurveTo(n+u[1],o+u[2],n+u[3],o+u[4],n+u[5],o+u[6]),n+=u[5],o+=u[6];break;case"S":n=u[3],o=u[4],t.bezierCurveToShort(u[1],u[2],n,o);break;case"s":t.bezierCurveToShort(n+u[1],o+u[2],n+u[3],o+u[4]),n+=u[3],o+=u[4];break;case"Q":n=u[3],o=u[4],t.quadraticCurveTo(u[1],u[2],n,o);break;case"q":t.quadraticCurveTo(n+u[1],o+u[2],n+u[3],o+u[4]),n+=u[3],o+=u[4];break;case"T":n=u[1],o=u[2],t.quadraticCurveToShort(n,o);break;case"t":n+=u[1],o+=u[2],t.quadraticCurveToShort(n,o);break;case"A":n=u[6],o=u[7],t.arcToSvg(u[1],u[2],u[3],u[4],u[5],n,o);break;case"a":n+=u[6],o+=u[7],t.arcToSvg(u[1],u[2],u[3],u[4],u[5],n,o);break;case"Z":case"z":t.closePath(),r.length>0&&(i=r.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:O(`Unknown SVG path command: ${h}`)}h!=="Z"&&h!=="z"&&i===null&&(i={startX:n,startY:o},r.push(i))}return t}var JT=p(()=>{KT();pt()});var kp,Lp,Op,Qi,$h=p(()=>{A();th();Bf();pl();cr();Rt();Er();Xh();kp=class{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{Pt.return(t)}),this.graphicsData&&Pt.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}},Lp=class{constructor(){this.instructions=new $r}init(t){let e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new ko({maxTextures:e}),this.instructions.reset()}get geometry(){return N(e_,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}},Op=class Dp{constructor(t){this._renderer=t,this._managedContexts=new zt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Dp.defaultOptions.bezierSmoothness=t?.bezierSmoothness??Dp.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){let e=!!t._gpuData[this._renderer.uid],r=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&r.reset(),WT(t,r);let i=t.batchMode;t.customShader||i==="no-batch"?r.isBatchable=!1:i==="auto"?r.isBatchable=r.geometryData.vertices.length<400:r.isBatchable=!0,t.dirty=!1}return r}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){let e=Pt.get(Lp,{maxTextures:this._renderer.limits.maxBatchableTextures}),r=t._gpuData[this._renderer.uid],{batches:i,geometryData:n}=r;r.graphicsData=e;let o=n.vertices.length,a=n.indices.length;for(let c=0;c<i.length;c++)i[c].applyTransform=!1;let l=e.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let c=0;c<i.length;c++){let f=i[c];l.add(f)}l.finish(e.instructions);let h=l.geometry;h.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),h.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);let u=l.batches;for(let c=0;c<u.length;c++){let f=u[c];f.bindGroup=ki(f.textures.textures,f.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){let e=new kp;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Op.extension={type:[y.WebGLSystem,y.WebGPUSystem],name:"graphicsContext"};Op.defaultOptions={bezierSmoothness:.5};Qi=Op});function Kh(s,t,e,r,i,n,o,a,l,h){let c=Math.min(.99,Math.max(0,h??Qi.defaultOptions.bezierSmoothness)),f=(T1-c)/1;return f*=f,C1(t,e,r,i,n,o,a,l,s,f),s}function C1(s,t,e,r,i,n,o,a,l,h){Up(s,t,e,r,i,n,o,a,l,h,0),l.push(o,a)}function Up(s,t,e,r,i,n,o,a,l,h,u){if(u>S1)return;let c=Math.PI,f=(s+e)/2,d=(t+r)/2,m=(e+i)/2,g=(r+n)/2,_=(i+o)/2,x=(n+a)/2,S=(f+m)/2,v=(d+g)/2,b=(m+_)/2,C=(g+x)/2,T=(S+b)/2,P=(v+C)/2;if(u>0){let E=o-s,L=a-t,B=Math.abs((e-o)*L-(r-a)*E),w=Math.abs((i-o)*L-(n-a)*E),I,G;if(B>qh&&w>qh){if((B+w)*(B+w)<=h*(E*E+L*L)){if(tn<Gp){l.push(T,P);return}let H=Math.atan2(n-r,i-e);if(I=Math.abs(H-Math.atan2(r-t,e-s)),G=Math.abs(Math.atan2(a-n,o-i)-H),I>=c&&(I=2*c-I),G>=c&&(G=2*c-G),I+G<tn){l.push(T,P);return}if($s!==0){if(I>$s){l.push(e,r);return}if(G>$s){l.push(i,n);return}}}}else if(B>qh){if(B*B<=h*(E*E+L*L)){if(tn<Gp){l.push(T,P);return}if(I=Math.abs(Math.atan2(n-r,i-e)-Math.atan2(r-t,e-s)),I>=c&&(I=2*c-I),I<tn){l.push(e,r),l.push(i,n);return}if($s!==0&&I>$s){l.push(e,r);return}}}else if(w>qh){if(w*w<=h*(E*E+L*L)){if(tn<Gp){l.push(T,P);return}if(I=Math.abs(Math.atan2(a-n,o-i)-Math.atan2(n-r,i-e)),I>=c&&(I=2*c-I),I<tn){l.push(e,r),l.push(i,n);return}if($s!==0&&I>$s){l.push(i,n);return}}}else if(E=T-(s+o)/2,L=P-(t+a)/2,E*E+L*L<=h){l.push(T,P);return}}Up(s,t,f,d,S,v,T,P,l,h,u+1),Up(T,P,b,C,_,x,o,a,l,h,u+1)}var S1,qh,T1,Gp,tn,$s,Vp=p(()=>{$h();S1=8,qh=11920929e-14,T1=1,Gp=.01,tn=0,$s=0});function tC(s,t,e,r,i,n,o,a){let h=Math.min(.99,Math.max(0,a??Qi.defaultOptions.bezierSmoothness)),u=(w1-h)/1;return u*=u,A1(t,e,r,i,n,o,s,u),s}function A1(s,t,e,r,i,n,o,a){Np(o,s,t,e,r,i,n,a,0),o.push(i,n)}function Np(s,t,e,r,i,n,o,a,l){if(l>P1)return;let h=Math.PI,u=(t+r)/2,c=(e+i)/2,f=(r+n)/2,d=(i+o)/2,m=(u+f)/2,g=(c+d)/2,_=n-t,x=o-e,S=Math.abs((r-n)*x-(i-o)*_);if(S>M1){if(S*S<=a*(_*_+x*x)){if(QT<E1){s.push(m,g);return}let v=Math.abs(Math.atan2(o-i,n-r)-Math.atan2(i-e,r-t));if(v>=h&&(v=2*h-v),v<QT){s.push(m,g);return}}}else if(_=m-(t+n)/2,x=g-(e+o)/2,_*_+x*x<=a){s.push(m,g);return}Np(s,t,e,u,c,m,g,a,l+1),Np(s,m,g,f,d,n,o,a,l+1)}var P1,M1,w1,E1,QT,eC=p(()=>{$h();P1=8,M1=11920929e-14,w1=1,E1=.01,QT=0});function Zh(s,t,e,r,i,n,o,a){let l=Math.abs(i-n);(!o&&i>n||o&&n>i)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(r,1/3)*(l/Math.PI)))),a=Math.max(a,3);let h=l/a,u=i;h*=o?-1:1;for(let c=0;c<a+1;c++){let f=Math.cos(u),d=Math.sin(u),m=t+f*r,g=e+d*r;s.push(m,g),u+=h}}var Hp=p(()=>{"use strict"});function rC(s,t,e,r,i,n){let o=s[s.length-2],l=s[s.length-1]-e,h=o-t,u=i-e,c=r-t,f=Math.abs(l*c-h*u);if(f<1e-8||n===0){(s[s.length-2]!==t||s[s.length-1]!==e)&&s.push(t,e);return}let d=l*l+h*h,m=u*u+c*c,g=l*u+h*c,_=n*Math.sqrt(d)/f,x=n*Math.sqrt(m)/f,S=_*g/d,v=x*g/m,b=_*c+x*h,C=_*u+x*l,T=h*(x+S),P=l*(x+S),E=c*(_+v),L=u*(_+v),B=Math.atan2(P-C,T-b),w=Math.atan2(L-C,E-b);Zh(s,b+t,C+e,n,B,w,h*u>c*l)}var sC=p(()=>{Hp()});function B1(s,t){let e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=t===1.5707963267948966?.551915024494:e,i=Math.cos(s),n=Math.sin(s),o=Math.cos(s+t),a=Math.sin(s+t);return[{x:i-n*r,y:n+i*r},{x:o+a*r,y:a-o*r},{x:o,y:a}]}function nC(s,t,e,r,i,n,o,a=0,l=0,h=0){if(n===0||o===0)return;let u=Math.sin(a*ba/360),c=Math.cos(a*ba/360),f=c*(t-r)/2+u*(e-i)/2,d=-u*(t-r)/2+c*(e-i)/2;if(f===0&&d===0)return;n=Math.abs(n),o=Math.abs(o);let m=Math.pow(f,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),R1(t,e,r,i,n,o,l,h,u,c,f,d,zp);let{ang1:g,ang2:_}=zp,{centerX:x,centerY:S}=zp,v=Math.abs(_)/(ba/4);Math.abs(1-v)<1e-7&&(v=1);let b=Math.max(Math.ceil(v),1);_/=b;let C=s[s.length-2],T=s[s.length-1],P={x:0,y:0};for(let E=0;E<b;E++){let L=B1(g,_),{x:B,y:w}=Wp(L[0],n,o,c,u,x,S,P),{x:I,y:G}=Wp(L[1],n,o,c,u,x,S,P),{x:H,y:gt}=Wp(L[2],n,o,c,u,x,S,P);Kh(s,C,T,B,w,I,G,H,gt),C=H,T=gt,g+=_}}var ba,zp,Wp,iC,R1,oC=p(()=>{Vp();ba=Math.PI*2,zp={centerX:0,centerY:0,ang1:0,ang2:0},Wp=({x:s,y:t},e,r,i,n,o,a,l)=>{s*=e,t*=r;let h=i*s-n*t,u=n*s+i*t;return l.x=h+o,l.y=u+a,l};iC=(s,t,e,r)=>{let i=s*r-t*e<0?-1:1,n=s*e+t*r;return n>1&&(n=1),n<-1&&(n=-1),i*Math.acos(n)},R1=(s,t,e,r,i,n,o,a,l,h,u,c,f)=>{let d=Math.pow(i,2),m=Math.pow(n,2),g=Math.pow(u,2),_=Math.pow(c,2),x=d*m-d*_-m*g;x<0&&(x=0),x/=d*_+m*g,x=Math.sqrt(x)*(o===a?-1:1);let S=x*i/n*c,v=x*-n/i*u,b=h*S-l*v+(s+e)/2,C=l*S+h*v+(t+r)/2,T=(u-S)/i,P=(c-v)/n,E=(-u-S)/i,L=(-c-v)/n,B=iC(1,0,T,P),w=iC(T,P,E,L);a===0&&w>0&&(w-=ba),a===1&&w<0&&(w+=ba),f.centerX=b,f.centerY=C,f.ang1=B,f.ang2=w}});function aC(s,t,e){let r=(o,a)=>{let l=a.x-o.x,h=a.y-o.y,u=Math.sqrt(l*l+h*h),c=l/u,f=h/u;return{len:u,nx:c,ny:f}},i=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y)},n=t[t.length-1];for(let o=0;o<t.length;o++){let a=t[o%t.length],l=a.radius??e;if(l<=0){i(o,a),n=a;continue}let h=t[(o+1)%t.length],u=r(a,n),c=r(a,h);if(u.len<1e-4||c.len<1e-4){i(o,a),n=a;continue}let f=Math.asin(u.nx*c.ny-u.ny*c.nx),d=1,m=!1;u.nx*c.nx-u.ny*-c.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,d=-1,m=!0):f>0&&(d=-1,m=!0);let g=f/2,_,x=Math.abs(Math.cos(g)*l/Math.sin(g));x>Math.min(u.len/2,c.len/2)?(x=Math.min(u.len/2,c.len/2),_=Math.abs(x*Math.sin(g)/Math.cos(g))):_=l;let S=a.x+c.nx*x+-c.ny*_*d,v=a.y+c.ny*x+c.nx*_*d,b=Math.atan2(u.ny,u.nx)+Math.PI/2*d,C=Math.atan2(c.ny,c.nx)-Math.PI/2*d;o===0&&s.moveTo(S+Math.cos(b)*_,v+Math.sin(b)*_),s.arc(S,v,_,b,C,m),n=a}}function lC(s,t,e,r){let i=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),n=(a,l,h)=>({x:a.x+(l.x-a.x)*h,y:a.y+(l.y-a.y)*h}),o=t.length;for(let a=0;a<o;a++){let l=t[(a+1)%o],h=l.radius??e;if(h<=0){a===0?s.moveTo(l.x,l.y):s.lineTo(l.x,l.y);continue}let u=t[a],c=t[(a+2)%o],f=i(u,l),d;if(f<1e-4)d=l;else{let _=Math.min(f/2,h);d=n(l,u,_/f)}let m=i(c,l),g;if(m<1e-4)g=l;else{let _=Math.min(m/2,h);g=n(l,c,_/m)}a===0?s.moveTo(d.x,d.y):s.lineTo(d.x,d.y),s.quadraticCurveTo(l.x,l.y,g.x,g.y,r)}}var hC=p(()=>{"use strict"});var I1,Jh,uC=p(()=>{Hx();zx();Wx();te();Xx();ie();Vp();eC();Hp();sC();oC();hC();I1=new rt,Jh=class{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();let r=this._currentPoly.points,i=r[r.length-2],n=r[r.length-1];return(i!==t||n!==e)&&r.push(t,e),this}arc(t,e,r,i,n,o){this._ensurePoly(!1);let a=this._currentPoly.points;return Zh(a,t,e,r,i,n,o),this}arcTo(t,e,r,i,n){this._ensurePoly();let o=this._currentPoly.points;return rC(o,t,e,r,i,n),this}arcToSvg(t,e,r,i,n,o,a){let l=this._currentPoly.points;return nC(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,r,i,n),this}bezierCurveTo(t,e,r,i,n,o,a){this._ensurePoly();let l=this._currentPoly;return Kh(this._currentPoly.points,l.lastX,l.lastY,t,e,r,i,n,o,a),this}quadraticCurveTo(t,e,r,i,n){this._ensurePoly();let o=this._currentPoly;return tC(this._currentPoly.points,o.lastX,o.lastY,t,e,r,i,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));let r=this.shapePrimitives,i=r.length;for(let n=0;n<t.instructions.length;n++){let o=t.instructions[n];this[o.action](...o.data)}if(t.checkForHoles&&r.length-i>1){let n=null;for(let o=i;o<r.length;o++){let a=r[o];if(a.shape.type==="polygon"){let l=a.shape,h=n?.shape;h&&h.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),r.copyWithin(o,o+1),r.length--,o--):n=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,r,i,n){return this.drawShape(new rt(t,e,r,i),n),this}circle(t,e,r,i){return this.drawShape(new kl(t,e,r),i),this}poly(t,e,r){let i=new Ei(t);return i.closePath=e,this.drawShape(i,r),this}regularPoly(t,e,r,i,n=0,o){i=Math.max(i|0,3);let a=-1*Math.PI/2+n,l=Math.PI*2/i,h=[];for(let u=0;u<i;u++){let c=a-u*l;h.push(t+r*Math.cos(c),e+r*Math.sin(c))}return this.poly(h,!0,o),this}roundPoly(t,e,r,i,n,o=0,a){if(i=Math.max(i|0,3),n<=0)return this.regularPoly(t,e,r,i,o);let l=r*Math.sin(Math.PI/i)-.001;n=Math.min(n,l);let h=-1*Math.PI/2+o,u=Math.PI*2/i,c=(i-2)*Math.PI/i/2;for(let f=0;f<i;f++){let d=f*u+h,m=t+r*Math.cos(d),g=e+r*Math.sin(d),_=d+Math.PI+c,x=d-Math.PI-c,S=m+n*Math.cos(_),v=g+n*Math.sin(_),b=m+n*Math.cos(x),C=g+n*Math.sin(x);f===0?this.moveTo(S,v):this.lineTo(S,v),this.quadraticCurveTo(m,g,b,C,a)}return this.closePath()}roundShape(t,e,r=!1,i){return t.length<3?this:(r?lC(this,t,e,i):aC(this,t,e),this.closePath())}filletRect(t,e,r,i,n){if(n===0)return this.rect(t,e,r,i);let o=Math.min(r,i)/2,a=Math.min(o,Math.max(-o,n)),l=t+r,h=e+i,u=a<0?-a:0,c=Math.abs(a);return this.moveTo(t,e+c).arcTo(t+u,e+u,t+c,e,c).lineTo(l-c,e).arcTo(l-u,e+u,l,e+c,c).lineTo(l,h-c).arcTo(l-u,h-u,t+r-c,h,c).lineTo(t+c,h).arcTo(t+u,h-u,t,h-c,c).closePath()}chamferRect(t,e,r,i,n,o){if(n<=0)return this.rect(t,e,r,i);let a=Math.min(n,Math.min(r,i)/2),l=t+r,h=e+i,u=[t+a,e,l-a,e,l,e+a,l,h-a,l-a,h,t+a,h,t,h-a,t,e+a];for(let c=u.length-1;c>=2;c-=2)u[c]===u[c-2]&&u[c-1]===u[c-3]&&u.splice(c-1,2);return this.poly(u,!0,o)}ellipse(t,e,r,i,n){return this.drawShape(new Ll(t,e,r,i),n),this}roundRect(t,e,r,i,n,o){return this.drawShape(new Ol(t,e,r,i,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let r=this._currentPoly;return r&&this.endPoly(),r=new Ei,r.points.push(t,e),this._currentPoly=r,this}endPoly(t=!1){let 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 Ei,t)){let e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let r=e.shape.x,i=e.shape.y;if(e.transform&&!e.transform.isIdentity()){let n=e.transform,o=r;r=n.a*r+n.c*i+n.tx,i=n.b*o+n.d*i+n.ty}this._currentPoly.points.push(r,i)}else this._currentPoly.points.push(0,0)}}buildPath(){let t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){let r=t.instructions[e];this[r.action](...r.data)}this.finish()}get bounds(){let t=this._bounds;t.clear();let e=this.shapePrimitives;for(let r=0;r<e.length;r++){let i=e[r],n=i.shape.getBounds(I1);i.transform?t.addRect(n,i.transform):t.addRect(n)}return t}}});function en(s,t){return s?s.prepend(t):t.clone()}var Ue,Qh=p(()=>{ke();Gt();pt();JT();uC();Ue=class s{constructor(t,e=!1){this.instructions=[],this.uid=$("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?ZT(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new Jh(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,r,i,n){let o=this.instructions[this.instructions.length-1],a=this.getLastPoint(et.shared),l=0,h=0;if(!o||o.action!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.data[2],h=o.data[3];let u=a.x,c=a.y;l=u+(u-l),h=c+(c-h)}return this.instructions.push({action:"bezierCurveTo",data:[l,h,t,e,r,i,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,r){let i=this.instructions[this.instructions.length-1],n=this.getLastPoint(et.shared),o=0,a=0;if(!i||i.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=i.data[0],a=i.data[1];let l=n.x,h=n.y;o=l+(l-o),a=h+(h-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,r]}),this._dirty=!0,this}rect(t,e,r,i,n){return this.instructions.push({action:"rect",data:[t,e,r,i,n]}),this._dirty=!0,this}circle(t,e,r,i){return this.instructions.push({action:"circle",data:[t,e,r,i]}),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,r,i,n,o,a){n||(n=i/2);let l=-1*Math.PI/2+o,h=r*2,u=Math.PI*2/h,c=[];for(let f=0;f<h;f++){let d=f%2?n:i,m=f*u+l;c.push(t+d*Math.cos(m),e+d*Math.sin(m))}return this.poly(c,!0,a),this}clone(t=!1){let e=new s;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let r=0;r<this.instructions.length;r++){let i=this.instructions[r];e.instructions.push({action:i.action,data:i.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;let e=t.a,r=t.b,i=t.c,n=t.d,o=t.tx,a=t.ty,l=0,h=0,u=0,c=0,f=0,d=0,m=0,g=0;for(let _=0;_<this.instructions.length;_++){let x=this.instructions[_],S=x.data;switch(x.action){case"moveTo":case"lineTo":l=S[0],h=S[1],S[0]=e*l+i*h+o,S[1]=r*l+n*h+a;break;case"bezierCurveTo":u=S[0],c=S[1],f=S[2],d=S[3],l=S[4],h=S[5],S[0]=e*u+i*c+o,S[1]=r*u+n*c+a,S[2]=e*f+i*d+o,S[3]=r*f+n*d+a,S[4]=e*l+i*h+o,S[5]=r*l+n*h+a;break;case"quadraticCurveTo":u=S[0],c=S[1],l=S[2],h=S[3],S[0]=e*u+i*c+o,S[1]=r*u+n*c+a,S[2]=e*l+i*h+o,S[3]=r*l+n*h+a;break;case"arcToSvg":l=S[5],h=S[6],m=S[0],g=S[1],S[0]=e*m+i*g,S[1]=r*m+n*g,S[5]=e*l+i*h+o,S[6]=r*l+n*h+a;break;case"circle":S[4]=en(S[3],t);break;case"rect":S[4]=en(S[4],t);break;case"ellipse":S[8]=en(S[8],t);break;case"roundRect":S[5]=en(S[5],t);break;case"addPath":S[0].transform(t);break;case"poly":S[2]=en(S[2],t);break;case"regularPoly":case"chamferRect":S[5]=en(S[5],t);break;case"closePath":break;default:O("unknown transform action",x.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,r=this.instructions[e];if(!r)return t.x=0,t.y=0,t;for(;r.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;r=this.instructions[e]}switch(r.action){case"moveTo":case"lineTo":t.x=r.data[0],t.y=r.data[1];break;case"quadraticCurveTo":t.x=r.data[2],t.y=r.data[3];break;case"bezierCurveTo":t.x=r.data[4],t.y=r.data[5];break;case"arc":case"arcToSvg":t.x=r.data[5],t.y=r.data[6];break;case"addPath":r.data[0].getLastPoint(t);break}return t}}});function Bt(s,t,e){let r=s.getAttribute(t);return r?Number(r):e}var Xp=p(()=>{"use strict"});function cC(s,t){let e=s.querySelectorAll("defs");for(let r=0;r<e.length;r++){let i=e[r];for(let n=0;n<i.children.length;n++){let o=i.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=F1(o);break;case"radialgradient":t.defs[o.id]=k1(o);break;default:break}}}}function F1(s){let t=Bt(s,"x1",0),e=Bt(s,"y1",0),r=Bt(s,"x2",1),i=Bt(s,"y2",0),n=s.getAttribute("gradientUnits")||"objectBoundingBox",o=new ae(t,e,r,i,n==="objectBoundingBox"?"local":"global");for(let a=0;a<s.children.length;a++){let l=s.children[a],h=Bt(l,"offset",0),u=Z.shared.setValue(l.getAttribute("stop-color")).toNumber();o.addColorStop(h,u)}return o}function k1(s){return O("[SVG Parser] Radial gradients are not yet supported"),new ae(0,0,1,0)}var dC=p(()=>{se();pt();Xs();Xp()});function jp(s){let t=s.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}var fC=p(()=>{"use strict"});function Yp(s,t){let e=s.getAttribute("style"),r={},i={},n={strokeStyle:r,fillStyle:i,useFill:!1,useStroke:!1};for(let o in pC){let a=s.getAttribute(o);a&&mC(t,n,o,a.trim())}if(e){let o=e.split(";");for(let a=0;a<o.length;a++){let l=o[a].trim(),[h,u]=l.split(":");pC[h]&&mC(t,n,h,u.trim())}}return{strokeStyle:n.useStroke?r:null,fillStyle:n.useFill?i:null,useFill:n.useFill,useStroke:n.useStroke}}function mC(s,t,e,r){switch(e){case"stroke":if(r!=="none"){if(r.startsWith("url(")){let i=jp(r);t.strokeStyle.fill=s.defs[i]}else t.strokeStyle.color=Z.shared.setValue(r).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(r);break;case"fill":if(r!=="none"){if(r.startsWith("url(")){let i=jp(r);t.fillStyle.fill=s.defs[i]}else t.fillStyle.color=Z.shared.setValue(r).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(r);break;case"stroke-opacity":t.strokeStyle.alpha=Number(r);break;case"opacity":t.fillStyle.alpha=Number(r),t.strokeStyle.alpha=Number(r);break}}var pC,gC=p(()=>{se();fC();pC={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 _C(s){if(s.length<=2)return!0;let t=s.map(a=>a.area).sort((a,l)=>l-a),[e,r]=t,i=t[t.length-1],n=e/r,o=r/i;return!(n>3&&o<2)}var xC=p(()=>{"use strict"});function yC(s){return s.split(/(?=[Mm])/).filter(r=>r.trim().length>0)}function bC(s){let t=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;let e=t.map(Number),r=[],i=[];for(let u=0;u<e.length;u+=2)u+1<e.length&&(r.push(e[u]),i.push(e[u+1]));if(r.length===0||i.length===0)return 0;let n=Math.min(...r),o=Math.max(...r),a=Math.min(...i),l=Math.max(...i);return(o-n)*(l-a)}function $p(s,t){let e=new Ue(s,!1);for(let r of e.instructions)t.instructions.push(r)}var vC=p(()=>{Qh()});function SC(s,t){if(typeof s=="string"){let o=document.createElement("div");o.innerHTML=s.trim(),s=o.querySelector("svg")}let e={context:t,defs:{},path:new Ue};cC(s,e);let r=s.children,{fillStyle:i,strokeStyle:n}=Yp(s,e);for(let o=0;o<r.length;o++){let a=r[o];a.nodeName.toLowerCase()!=="defs"&&TC(a,e,i,n)}return t}function TC(s,t,e,r){let i=s.children,{fillStyle:n,strokeStyle:o}=Yp(s,t);n&&e?e={...e,...n}:n&&(e=n),o&&r?r={...r,...o}:o&&(r=o);let a=!e&&!r;a&&(e={color:0});let l,h,u,c,f,d,m,g,_,x,S,v,b,C,T,P,E;switch(s.nodeName.toLowerCase()){case"path":{C=s.getAttribute("d");let L=s.getAttribute("fill-rule"),B=yC(C),w=L==="evenodd",I=B.length>1;if(w&&I){let H=B.map(k=>({path:k,area:bC(k)}));if(H.sort((k,V)=>V.area-k.area),B.length>3||!_C(H))for(let k=0;k<H.length;k++){let V=H[k],at=k===0;t.context.beginPath();let W=new Ue(void 0,!0);$p(V.path,W),t.context.path(W),at?(e&&t.context.fill(e),r&&t.context.stroke(r)):t.context.cut()}else for(let k=0;k<H.length;k++){let V=H[k],at=k%2===1;t.context.beginPath();let W=new Ue(void 0,!0);$p(V.path,W),t.context.path(W),at?t.context.cut():(e&&t.context.fill(e),r&&t.context.stroke(r))}}else{let H=L?L==="evenodd":!0;T=new Ue(C,H),t.context.path(T),e&&t.context.fill(e),r&&t.context.stroke(r)}break}case"circle":m=Bt(s,"cx",0),g=Bt(s,"cy",0),_=Bt(s,"r",0),t.context.ellipse(m,g,_,_),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"rect":l=Bt(s,"x",0),h=Bt(s,"y",0),P=Bt(s,"width",0),E=Bt(s,"height",0),x=Bt(s,"rx",0),S=Bt(s,"ry",0),x||S?t.context.roundRect(l,h,P,E,x||S):t.context.rect(l,h,P,E),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"ellipse":m=Bt(s,"cx",0),g=Bt(s,"cy",0),x=Bt(s,"rx",0),S=Bt(s,"ry",0),t.context.beginPath(),t.context.ellipse(m,g,x,S),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"line":u=Bt(s,"x1",0),c=Bt(s,"y1",0),f=Bt(s,"x2",0),d=Bt(s,"y2",0),t.context.beginPath(),t.context.moveTo(u,c),t.context.lineTo(f,d),r&&t.context.stroke(r);break;case"polygon":b=s.getAttribute("points"),v=b.match(/-?\d+/g).map(L=>parseInt(L,10)),t.context.poly(v,!0),e&&t.context.fill(e),r&&t.context.stroke(r);break;case"polyline":b=s.getAttribute("points"),v=b.match(/-?\d+/g).map(L=>parseInt(L,10)),t.context.poly(v,!1),r&&t.context.stroke(r);break;case"g":case"svg":break;default:{O(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(e=null);for(let L=0;L<i.length;L++)TC(i[L],t,e,r)}var CC=p(()=>{pt();Qh();dC();Xp();gC();xC();vC()});function L1(s){return Z.isColorLike(s)}function PC(s){return s instanceof tr}function MC(s){return s instanceof ae}function D1(s){return s instanceof F}function O1(s,t,e){let r=Z.shared.setValue(t??0);return s.color=r.toNumber(),s.alpha=r.alpha===1?e.alpha:r.alpha,s.texture=F.WHITE,{...e,...s}}function G1(s,t,e){return s.texture=t,{...e,...s}}function wC(s,t,e){return s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,s.textureSpace=t.textureSpace,{...e,...s}}function EC(s,t,e){return t.buildGradient(),s.fill=t,s.color=16777215,s.texture=t.texture,s.matrix=t.transform,s.textureSpace=t.textureSpace,{...e,...s}}function U1(s,t){let e={...t,...s},r=Z.shared.setValue(e.color);return e.alpha*=r.alpha,e.color=r.toNumber(),e}function Vr(s,t){if(s==null)return null;let e={},r=s;return L1(s)?O1(e,s,t):D1(s)?G1(e,s,t):PC(s)?wC(e,s,t):MC(s)?EC(e,s,t):r.fill&&PC(r.fill)?wC(r,r.fill,t):r.fill&&MC(r.fill)?EC(r,r.fill,t):U1(r,t)}function rn(s,t){let{width:e,alignment:r,miterLimit:i,cap:n,join:o,pixelLine:a,...l}=t,h=Vr(s,l);return h?{width:e,alignment:r,miterLimit:i,cap:n,join:o,pixelLine:a,...h}:null}var qp=p(()=>{se();yt();Xs();_a()});function AC(s,t){let e=1,r=s.shapePath.shapePrimitives;for(let i=0;i<r.length;i++){let n=r[i].shape;if(n.type!=="polygon")continue;let o=n.points,a=o.length;if(a<6)continue;let l=n.closePath;for(let h=0;h<a;h+=2){if(!l&&(h===0||h===a-2))continue;let u=(h-2+a)%a,c=(h+2)%a,f=o[u],d=o[u+1],m=o[h],g=o[h+1],_=o[c],x=o[c+1],S=f-m,v=d-g,b=_-m,C=x-g,T=S*S+v*v,P=b*b+C*C;if(T<1e-12||P<1e-12)continue;let B=(S*b+v*C)/Math.sqrt(T*P);B<-1?B=-1:B>1&&(B=1);let w=Math.sqrt((1-B)*.5);if(w<1e-6)continue;let I=Math.min(1/w,t);I>e&&(e=I)}}return e}var BC=p(()=>{"use strict"});var V1,RC,Kp,ge,tu=p(()=>{Qt();se();nt();ke();yt();Gt();Rt();ie();Qh();CC();qp();BC();V1=new et,RC=new R,Kp=class fr extends q{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=$("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Ue,this._transform=new R,this._fillStyle={...fr.defaultFillStyle},this._strokeStyle={...fr.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new ot,this._boundsDirty=!0}clone(){let t=new fr;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...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=Vr(t,fr.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=rn(t,fr.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Vr(t,fr.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Vr(t,fr.defaultStrokeStyle),this}texture(t,e,r,i,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:r||0,dy:i||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?Z.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Ue,this}fill(t,e){let r,i=this.instructions[this.instructions.length-1];return this._tick===0&&i?.action==="stroke"?r=i.data.path:r=this._activePath.clone(),r?(t!=null&&(e!==void 0&&typeof t=="number"&&(N(J,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=Vr(t,fr.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){let{x:t,y:e}=this._activePath.getLastPoint(et.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e,r=this.instructions[this.instructions.length-1];return this._tick===0&&r?.action==="fill"?e=r.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=rn(t,fr.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++){let e=this.instructions[this.instructions.length-1-t],r=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(r);else{e.data.hole=r;break}}return this._initNextPathLocation(),this}arc(t,e,r,i,n,o){this._tick++;let a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,r,i,n,o),this}arcTo(t,e,r,i,n){this._tick++;let 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*r+o.c*i+o.tx,o.b*r+o.d*i+o.ty,n),this}arcToSvg(t,e,r,i,n,o,a){this._tick++;let l=this._transform;return this._activePath.arcToSvg(t,e,r,i,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,e,r,i,n,o,a){this._tick++;let 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*r+l.c*i+l.tx,l.b*r+l.d*i+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,r,i){return this._tick++,this._activePath.ellipse(t,e,r,i,this._transform.clone()),this}circle(t,e,r){return this._tick++,this._activePath.circle(t,e,r,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;let r=this._transform;return this._activePath.lineTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty),this}moveTo(t,e){this._tick++;let r=this._transform,i=this._activePath.instructions,n=r.a*t+r.c*e+r.tx,o=r.b*t+r.d*e+r.ty;return i.length===1&&i[0].action==="moveTo"?(i[0].data[0]=n,i[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(t,e,r,i,n){this._tick++;let 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*r+o.c*i+o.tx,o.b*r+o.d*i+o.ty,n),this}rect(t,e,r,i){return this._tick++,this._activePath.rect(t,e,r,i,this._transform.clone()),this}roundRect(t,e,r,i,n){return this._tick++,this._activePath.roundRect(t,e,r,i,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,r,i,n=0,o){return this._tick++,this._activePath.regularPoly(t,e,r,i,n,o),this}roundPoly(t,e,r,i,n,o){return this._tick++,this._activePath.roundPoly(t,e,r,i,n,o),this}roundShape(t,e,r,i){return this._tick++,this._activePath.roundShape(t,e,r,i),this}filletRect(t,e,r,i,n){return this._tick++,this._activePath.filletRect(t,e,r,i,n),this}chamferRect(t,e,r,i,n,o){return this._tick++,this._activePath.chamferRect(t,e,r,i,n,o),this}star(t,e,r,i,n=0,o=0){return this._tick++,this._activePath.star(t,e,r,i,n,o,this._transform.clone()),this}svg(t){return this._tick++,SC(t,this),this}restore(){let 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:{...this._fillStyle},strokeStyle:{...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,r,i,n,o){return t instanceof R?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,r,i,n,o),this)}transform(t,e,r,i,n,o){return t instanceof R?(this._transform.append(t),this):(RC.set(t,e,r,i,n,o),this._transform.append(RC),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;let t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){let r=this.instructions[e],i=r.action;if(i==="fill"){let n=r.data;t.addBounds(n.path.bounds)}else if(i==="texture"){let n=r.data;t.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(i==="stroke"){let n=r.data,o=n.style.alignment,a=n.style.width*(1-o);n.style.join==="miter"&&(a*=AC(n.path,n.style.miterLimit));let l=n.path.bounds;t.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;let e=this.instructions,r=!1;for(let i=0;i<e.length;i++){let n=e[i],o=n.data,a=o.path;if(!n.action||!a)continue;let l=o.style,h=a.shapePath.shapePrimitives;for(let u=0;u<h.length;u++){let c=h[u].shape;if(!l||!c)continue;let f=h[u].transform,d=f?f.applyInverse(t,V1):t;if(n.action==="fill")r=c.contains(d.x,d.y);else{let g=l;r=c.strokeContains(d.x,d.y,g.width,g.alignment)}let m=o.hole;if(m){let g=m.shapePath?.shapePrimitives;if(g)for(let _=0;_<g.length;_++)g[_].shape.contains(d.x,d.y)&&(r=!1)}if(r)return!0}}return r}unload(){this.emit("unload",this);for(let t in this._gpuData)this._gpuData[t]?.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){let r=typeof t=="boolean"?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(r)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(r))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Kp.defaultFillStyle={color:16777215,alpha:1,texture:F.WHITE,matrix:null,fill:null,textureSpace:"local"};Kp.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:F.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};ge=Kp});var Zp,Jp,tm,IC,FC=p(()=>{A();pl();cr();Zp=class{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}},Jp=class{constructor(){this.instructions=new $r}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}},tm=class Qp{constructor(t){this._renderer=t,this._managedContexts=new zt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Qp.defaultOptions.bezierSmoothness=t?.bezierSmoothness??Qp.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){let e=t._gpuData,r=!!e[this._renderer.uid],i=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!r)&&(r&&i.reset(),i.isBatchable=!1,t.dirty=!1),i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){let e=new Jp,r=this.getGpuContext(t);return r.graphicsData=e,e.init(),e}_initContext(t){let e=new Zp;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};tm.extension={type:[y.CanvasSystem],name:"graphicsContext"};tm.defaultOptions={bezierSmoothness:.5};IC=tm});var va,kC=p(()=>{A();hr();cr();va=class{constructor(t,e){this.state=Kt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new zt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){return!1}addRenderable(t,e){this._managedGraphics.add(t),this.renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){t.isRenderable&&this._adaptor.execute(this,t)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}};va.extension={type:[y.CanvasPipes],name:"graphics"}});var em,Sa,LC=p(()=>{A();hr();cr();Er();Nf();Ep();em=class{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Pt.return(t)}),this.batches.length=0}},Sa=class{constructor(t,e){this.state=Kt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new zt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){let e=t.context,r=!!t._gpuData,n=this.renderer.graphicsContext.updateGpuContext(e);return!!(n.isBatchable||r!==n.isBatchable)}addRenderable(t,e){let 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){let r=this._getGpuDataForRenderable(t).batches;for(let i=0;i<r.length;i++){let n=r[i];n._batcher.updateElement(n)}}execute(t){if(!t.isRenderable)return;let e=this.renderer,r=t.context;if(!e.graphicsContext.getGpuContext(r).batches.length)return;let n=r.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;let o=n.resources.localUniforms.uniforms;o.uTransformMatrix=t.groupTransform,o.uRound=e._roundPixels|t._roundPixels,gh(t.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){let e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){let r=this.renderer.renderPipes.batch,i=this._getGpuDataForRenderable(t).batches;for(let n=0;n<i.length;n++){let o=i[n];r.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){let e=new em;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){let r=t.context,n=this.renderer.graphicsContext.getGpuContext(r),o=this.renderer._roundPixels|t._roundPixels;e.batches=n.batches.map(a=>{let l=Pt.get(js);return a.copyTo(l),l.renderable=t,l.roundPixels=o,l})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}};Sa.extension={type:[y.WebGLPipes,y.WebGPUPipes],name:"graphics"}});var DC=p(()=>{A();FC();kC();$h();LC();U.add(va);U.add(Sa);U.add(IC);U.add(Qi)});var eu,OC=p(()=>{Rt();ud();tu();DC();eu=class s extends Si{constructor(t){t instanceof ge&&(t={context:t});let{context:e,roundPixels:r,...i}=t||{};super({label:"Graphics",...i}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new ge,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=r??!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||t?.context===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new s(this._context.clone()):(this._ownedContext=null,new s(this._context))}lineStyle(t,e,r){N(J,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");let i={};return t&&(i.width=t),e&&(i.color=e),r&&(i.alpha=r),this.context.strokeStyle=i,this}beginFill(t,e){N(J,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");let r={};return t!==void 0&&(r.color=t),e!==void 0&&(r.alpha=e),this.context.fillStyle=r,this}endFill(){N(J,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();let t=this.context.strokeStyle;return(t.width!==ge.defaultStrokeStyle.width||t.color!==ge.defaultStrokeStyle.color||t.alpha!==ge.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return N(J,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return N(J,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return N(J,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return N(J,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return N(J,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return N(J,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}});function N1(s,t,e,r,i,n){n=Math.max(0,Math.min(n,Math.min(r,i)/2)),s.moveTo(t+n,e),s.lineTo(t+r-n,e),s.quadraticCurveTo(t+r,e,t+r,e+n),s.lineTo(t+r,e+i-n),s.quadraticCurveTo(t+r,e+i,t+r-n,e+i),s.lineTo(t+n,e+i),s.quadraticCurveTo(t,e+i,t,e+i-n),s.lineTo(t,e+n),s.quadraticCurveTo(t,e,t+n,e)}function GC(s,t){switch(t.type){case"rectangle":{let e=t;s.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{let e=t;N1(s,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{let e=t;s.moveTo(e.x+e.radius,e.y),s.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{let e=t;s.ellipse?(s.moveTo(e.x+e.halfWidth,e.y),s.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2)):(s.save(),s.translate(e.x,e.y),s.scale(e.halfWidth,e.halfHeight),s.moveTo(1,0),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{let e=t;s.moveTo(e.x,e.y),s.lineTo(e.x2,e.y2),s.lineTo(e.x3,e.y3),s.closePath();break}case"polygon":default:{let e=t,r=e.points;if(!r?.length)break;s.moveTo(r[0],r[1]);for(let i=2;i<r.length;i+=2)s.lineTo(r[i],r[i+1]);e.closePath&&s.closePath();break}}}function H1(s,t,e){let r=[],i=[],n=[];if(!ns[t.type]?.build(t,r))return!1;let a=t.closePath??!0;Zi(r,e,!1,a,i,n);for(let l=0;l<n.length;l+=3){let h=n[l]*2,u=n[l+1]*2,c=n[l+2]*2;s.moveTo(i[h],i[h+1]),s.lineTo(i[u],i[u+1]),s.lineTo(i[c],i[c+1]),s.closePath()}return!0}function z1(s,t){if(!t?.length)return!1;for(let e=0;e<t.length;e++){let r=t[e];if(!r?.shape)continue;let i=r.transform,n=i&&!i.isIdentity();n&&(s.save(),s.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),GC(s,r.shape),n&&s.restore()}return!0}var Ta,UC=p(()=>{A();Hh();OC();Xh();pt();Ta=class{constructor(t){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=t}push(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){if(t.action!=="pushMaskBegin"&&t.action!=="popMaskEnd")return;let e=this._renderer,r=e.canvasContext,i=r?.activeContext;if(!i)return;if(t.action==="popMaskEnd"){this._canvasMaskStack.pop()&&i.restore();return}t.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");let n=t.mask.mask;if(!(n instanceof eu)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}let o=n,a=o.context?.instructions;if(!a?.length){this._canvasMaskStack.push(!1);return}i.save(),r.setContextTransform(o.groupTransform,(e._roundPixels|o._roundPixels)===1),i.beginPath();let l=!1,h=!1;for(let u=0;u<a.length;u++){let c=a[u],f=c.action;if(f!=="fill"&&f!=="stroke")continue;let d=c.data,m=d?.path?.shapePath;if(!m?.shapePrimitives?.length)continue;let g=f==="stroke",_=m.shapePrimitives;for(let x=0;x<_.length;x++){let S=_[x];if(!S?.shape)continue;let v=S.transform,b=v&&!v.isIdentity();b&&(i.save(),i.transform(v.a,v.b,v.c,v.d,v.tx,v.ty)),g&&d.style?l=H1(i,S.shape,d.style)||l:(GC(i,S.shape),h=z1(i,S.holes)||h,l=!0),b&&i.restore()}}if(!l){i.restore(),this._canvasMaskStack.push(!1);return}h?i.clip("evenodd"):i.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(t,e){this._warnedMaskTypes.has(t)||(this._warnedMaskTypes.add(t),O(e))}};Ta.extension={type:[y.CanvasPipes],name:"stencilMask"}});function VC(){let s=Il(),t=Object.create(null);return t.inherit=Tt,t.none=Tt,t.normal="source-over",t.add="lighter",t.multiply=s?"multiply":Tt,t.screen=s?"screen":Tt,t.overlay=s?"overlay":Tt,t.darken=s?"darken":Tt,t.lighten=s?"lighten":Tt,t["color-dodge"]=s?"color-dodge":Tt,t["color-burn"]=s?"color-burn":Tt,t["hard-light"]=s?"hard-light":Tt,t["soft-light"]=s?"soft-light":Tt,t.difference=s?"difference":Tt,t.exclusion=s?"exclusion":Tt,t.saturation=s?"saturation":Tt,t.color=s?"color":Tt,t.luminosity=s?"luminosity":Tt,t["linear-burn"]=s?"color-burn":Tt,t["linear-dodge"]=s?"color-dodge":Tt,t["linear-light"]=s?"hard-light":Tt,t["pin-light"]=s?"hard-light":Tt,t["vivid-light"]=s?"hard-light":Tt,t["hard-mix"]=Tt,t.negation=s?"difference":Tt,t["normal-npm"]=t.normal,t["add-npm"]=t.add,t["screen-npm"]=t.screen,t.erase="destination-out",t.subtract=Tt,t.divide=Tt,t.min=Tt,t.max=Tt,t}var Tt,NC=p(()=>{Ad();Tt="source-over"});var W1,Ca,HC=p(()=>{se();A();nt();NC();W1=new R,Ca=class{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=VC(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=t}resolutionChange(t){this.activeResolution=t}init(){let t=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){let e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,r,i){let n=i?R.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||R.IDENTITY,o=W1;o.copyFrom(n),o.append(t);let a=this._projTransform,l=this.activeResolution;if(r=r||l,a){let h=R.shared;h.copyFrom(o),h.prepend(a),o=h}e?this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*l|0,o.ty*l|0):this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*l,o.ty*l)}clear(t,e){let r=this.activeContext,i=this._renderer;if(r.clearRect(0,0,i.width,i.height),t){let n=Z.shared.setValue(t);r.globalAlpha=e??n.alpha,r.fillStyle=n.toHex(),r.fillRect(0,0,i.width,i.height),r.globalAlpha=1}}setBlendMode(t){if(this._activeBlendMode===t)return;this._activeBlendMode=t,this._outerBlend=!1;let e=this.blendModes[t];if(!e){this._warnedBlendModes.has(t)||(console.warn(`CanvasRenderer: blend mode "${t}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(t)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=e}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}};Ca.extension={type:[y.CanvasSystem],name:"canvasContext"}});var Pa,zC=p(()=>{A();Pa=class{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}};Pa.extension={type:[y.CanvasSystem],name:"limits"}});var ru,WC=p(()=>{se();ct();Zr();ru=class{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){let e=t.colorTexture,{canvas:r,context:i}=this._ensureCanvas(e);return{canvas:r,context:i,width:r.width,height:r.height}}resizeGpuRenderTarget(t){let e=t.colorTexture,{canvas:r}=this._ensureCanvas(e);r.width=t.pixelWidth,r.height=t.pixelHeight}startRenderPass(t,e,r,i){let n=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,r,i)}clear(t,e,r,i){let o=this._renderTargetSystem.getGpuRenderTarget(t).context,a=i||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(a.x,a.y,a.width,a.height),r){let l=Z.shared.setValue(r);l.alpha>0&&(o.globalAlpha=l.alpha,o.fillStyle=l.toHex(),o.fillRect(a.x,a.y,a.width,a.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,r,i,n){let a=this._renderTargetSystem.getGpuRenderTarget(t).canvas,l=e.source,{context:h}=this._ensureCanvas(l),u=n?.x??0,c=n?.y??0;return h.drawImage(a,r.x,r.y,i.width,i.height,u,c,i.width,i.height),l.update(),e}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!It.test(e))&&(e=D.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);let r=e.getContext("2d");return{canvas:e,context:r}}}});var Ma,XC=p(()=>{A();Ph();WC();Ma=class extends is{constructor(t){super(t),this.adaptor=new ru,this.adaptor.init(t,this)}};Ma.extension={type:[y.CanvasSystem],name:"renderTarget"}});var wa,jC=p(()=>{ct();A();wi();wa=class{constructor(t){}init(){}initSource(t){}generateCanvas(t){let e=D.get().createCanvas(),r=e.getContext("2d"),i=K.getCanvasSource(t);if(!i)return e;let n=t.frame,o=t.source._resolution??t.source.resolution??1,a=n.x*o,l=n.y*o,h=n.width*o,u=n.height*o;return e.width=Math.ceil(h),e.height=Math.ceil(u),r.drawImage(i,a,l,h,u,0,0,h,u),e}getPixels(t){let e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}};wa.extension={type:[y.CanvasSystem],name:"texture"}});var KC={};Mr(KC,{CanvasRenderer:()=>rm});var X1,j1,Y1,YC,$C,qC,rm,ZC=p(()=>{A();gf();yf();XT();Sf();YT();If();Lf();$T();UC();Of();Fi();bh();Gr();HC();zC();XC();jC();X1=[...ji,Ca,Pa,wa,Ma],j1=[zs,Lo,Vs,Us,Hs,Ta,ya,Gs],Y1=[jT,xa],YC=[],$C=[],qC=[];U.handleByNamedList(y.CanvasSystem,YC);U.handleByNamedList(y.CanvasPipes,$C);U.handleByNamedList(y.CanvasPipesAdaptor,qC);U.add(...X1,...j1,...Y1);rm=class extends ur{constructor(){let t={name:"canvas",type:qt.CANVAS,systems:YC,renderPipes:$C,renderPipeAdaptors:qC};super(t)}}});async function QC(s){let t=[];s.preference?Array.isArray(s.preference)?t=s.preference.slice():(t.push(s.preference),JC.forEach(n=>{n!==s.preference&&t.push(n)})):t=JC.slice();let e,r={};for(let n=0;n<t.length;n++){let o=t[n];if(o==="webgpu"&&await db()){let{WebGPURenderer:a}=await Promise.resolve().then(()=>(V0(),U0));e=a,r={...s,...s.webgpu};break}else if(o==="webgl"&&ub(s.failIfMajorPerformanceCaveat??ur.defaultOptions.failIfMajorPerformanceCaveat)){let{WebGLRenderer:a}=await Promise.resolve().then(()=>(Cp(),bT));e=a,r={...s,...s.webgl};break}else if(o==="canvas"){let{CanvasRenderer:a}=await Promise.resolve().then(()=>(ZC(),KC));e=a,r={...s,...s.canvasOptions};break}}if(delete r.webgpu,delete r.webgl,delete r.canvasOptions,!e)throw new Error("No available renderer for the current environment");let i=new e;return await i.init(r),i}var JC,tP=p(()=>{cb();fb();Fi();JC=["webgl","webgpu","canvas"]});var Ea,eP=p(()=>{A();Ea=class{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,r;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,r=globalThis.innerHeight;else{let{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,r=n}this.renderer.resize(e,r),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}};Ea.extension=y.Application});var Aa,rP=p(()=>{A();Xn();As();Aa=class{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,ar.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?St.shared:new St,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};Aa.extension=y.Application});var sP=p(()=>{A();eP();rP();U.add(Ea);U.add(Aa)});var iP,su,nP=p(()=>{A();tP();Ke();Cf();Rt();sP();iP=class sm{constructor(...t){this.stage=new Mt,t[0]!==void 0&&N(J,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new Mt),this.renderer=await QC(t),sm._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return N(J,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){return this.renderer.renderPipes.dom?._domElement}destroy(t=!1,e=!1){let r=sm._plugins.slice(0);r.reverse(),r.forEach(i=>{i.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};iP._plugins=[];su=iP;U.handleByList(y.Application,su._plugins);U.add(Mo)});var iu,oP=p(()=>{"use strict";iu={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){let t=s.match(/^[a-z]+\s+.+$/gm),e={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(let c in t){let f=t[c].match(/^[a-z]+/gm)[0],d=t[c].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),m={};for(let g in d){let _=d[g].split("="),x=_[0],S=_[1].replace(/"/gm,""),v=parseFloat(S),b=isNaN(v)?S:v;m[x]=b}e[f].push(m)}let r={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[i]=e.info,[n]=e.common,[o]=e.distanceField??[];o&&(r.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),r.fontSize=parseInt(i.size,10),r.fontFamily=i.face,r.lineHeight=parseInt(n.lineHeight,10);let a=e.page;for(let c=0;c<a.length;c++)r.pages.push({id:parseInt(a[c].id,10)||0,file:a[c].file});let l={};r.baseLineOffset=r.lineHeight-parseInt(n.base,10);let h=e.char;for(let c=0;c<h.length;c++){let f=h[c],d=parseInt(f.id,10),m=f.letter??f.char??String.fromCharCode(d);m==="space"&&(m=" "),l[d]=m,r.chars[m]={id:d,page:parseInt(f.page,10)||0,x:parseInt(f.x,10),y:parseInt(f.y,10),width:parseInt(f.width,10),height:parseInt(f.height,10),xOffset:parseInt(f.xoffset,10),yOffset:parseInt(f.yoffset,10),xAdvance:parseInt(f.xadvance,10),kerning:{}}}let u=e.kerning||[];for(let c=0;c<u.length;c++){let f=parseInt(u[c].first,10),d=parseInt(u[c].second,10),m=parseInt(u[c].amount,10);r.chars[l[d]]&&(r.chars[l[d]].kerning[l[f]]=m)}return r}}});var im,aP=p(()=>{"use strict";im={test(s){let t=s;return typeof t!="string"&&"getElementsByTagName"in t&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){let t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},e=s.getElementsByTagName("info")[0],r=s.getElementsByTagName("common")[0],i=s.getElementsByTagName("distanceField")[0];i&&(t.distanceField={type:i.getAttribute("fieldType"),range:parseInt(i.getAttribute("distanceRange"),10)});let n=s.getElementsByTagName("page"),o=s.getElementsByTagName("char"),a=s.getElementsByTagName("kerning");t.fontSize=parseInt(e.getAttribute("size"),10),t.fontFamily=e.getAttribute("face"),t.lineHeight=parseInt(r.getAttribute("lineHeight"),10);for(let h=0;h<n.length;h++)t.pages.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});let l={};t.baseLineOffset=t.lineHeight-parseInt(r.getAttribute("base"),10);for(let h=0;h<o.length;h++){let u=o[h],c=parseInt(u.getAttribute("id"),10),f=u.getAttribute("letter")??u.getAttribute("char")??String.fromCharCode(c);f==="space"&&(f=" "),l[c]=f,t.chars[f]={id:c,page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xOffset:parseInt(u.getAttribute("xoffset"),10),yOffset:parseInt(u.getAttribute("yoffset"),10),xAdvance:parseInt(u.getAttribute("xadvance"),10),kerning:{}}}for(let h=0;h<a.length;h++){let u=parseInt(a[h].getAttribute("first"),10),c=parseInt(a[h].getAttribute("second"),10),f=parseInt(a[h].getAttribute("amount"),10);t.chars[l[c]]&&(t.chars[l[c]].kerning[l[u]]=f)}return t}}});var nm,lP=p(()=>{ct();aP();nm={test(s){return typeof s=="string"&&s.match(/<font(\s|>)/)?im.test(D.get().parseXML(s)):!1},parse(s){return im.parse(D.get().parseXML(s))}}});var sn,om=p(()=>{Qt();Rt();sn=class extends q{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 N(J,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return N(J,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return N(J,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return N(J,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return N(J,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(let e in this.chars)this.chars[e].texture?.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}}});function nu(s=1e3,t=0,e=!1){if(isNaN(s)||s<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 am(s,t,e)}var am,lm=p(()=>{am=class{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,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)){let 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()){let e=new Array(t.length);for(let r=0;r<t.length;r++){let i=t[r];e[r]=[i,this.get(i)]}return e}evict(t=!1){if(t||this.size>0){let 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){let 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(){let t=new Array(this.size),e=this.first,r=0;for(;e!==null;)t[r++]=e.key,e=e.next;return t}setWithEvicted(t,e,r=this.resetTtl){let i=null;if(this.has(t))this.set(t,e,!0,r);else{this.max>0&&this.size===this.max&&(i={...this.first},this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return i}set(t,e,r=!1,i=this.resetTtl){let n=this.items[t];return r||n!==void 0?(n.value=e,r===!1&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){let e=new Array(t.length);for(let r=0;r<t.length;r++)e[r]=this.get(t[r]);return e}}});function hm(s){return!!s.tagStyles&&Object.keys(s.tagStyles).length>0}function um(s){return s.includes("<")}function $1(s,t){return s.clone().assign(t)}function hP(s,t){let e=[],r=t.tagStyles;if(!hm(t)||!um(s))return e.push({text:s,style:t}),e;let i=[t],n=[],o="",a=0;for(;a<s.length;){let l=s[a];if(l==="<"){let h=s.indexOf(">",a);if(h===-1){o+=l,a++;continue}let u=s.indexOf("<",a+1);if(u!==-1&&u<h){o+=l,a++;continue}let c=s.slice(a+1,h);if(c.startsWith("/")){let f=c.slice(1).trim();if(n.length>0&&n[n.length-1]===f){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o=""),i.pop(),n.pop(),a=h+1;continue}else{o+=s.slice(a,h+1),a=h+1;continue}}else{let f=c.trim();if(r[f]){o.length>0&&(e.push({text:o,style:i[i.length-1]}),o="");let d=i[i.length-1],m=$1(d,r[f]);i.push(m),n.push(f),a=h+1;continue}else{o+=s.slice(a,h+1),a=h+1;continue}}}else o+=l,a++}return o.length>0&&e.push({text:o,style:i[i.length-1]}),e}var cm=p(()=>{"use strict"});function nn(s){return typeof s!="string"?!1:K1.has(s.charCodeAt(0))}function ee(s,t){return typeof s!="string"?!1:J1.has(s.charCodeAt(0))}function dm(s){return typeof s!="string"?!1:tR.has(s.charCodeAt(0))}function fm(s){return typeof s!="string"?!1:rR.has(s.charCodeAt(0))}function on(s){return s==="normal"||s==="pre-line"}function an(s){return s==="normal"}function er(s){if(typeof s!="string")return"";let t=s.length-1;for(;t>=0&&ee(s[t]);)t--;return t<s.length-1?s.slice(0,t+1):s}function ou(s){let t=[],e=[];if(typeof s!="string")return t;for(let r=0;r<s.length;r++){let i=s[r],n=s[r+1];if(ee(i,n)||nn(i)){e.length>0&&(t.push(e.join("")),e.length=0),i==="\r"&&n===`
896
+ `?(t.push(`\r
897
+ `),r++):t.push(i);continue}e.push(i),fm(i)&&n&&!ee(n)&&!nn(n)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function au(s,t,e,r){let i=e(s),n=[];for(let o=0;o<i.length;o++){let a=i[o],l=a,h=1;for(;i[o+h];){let u=i[o+h];if(!r(l,u,s,o,t))a+=u,l=u,h++;else break}o+=h-1,n.push(a)}return n}var q1,K1,Z1,J1,Q1,tR,eR,rR,uP,cP,Ba=p(()=>{"use strict";q1=[10,13],K1=new Set(q1),Z1=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],J1=new Set(Z1),Q1=[9,32],tR=new Set(Q1),eR=[45,8208,8211,8212,173],rR=new Set(eR),uP=/(\r\n|\r|\n)/,cP=/(?:\r\n|\r|\n)/});function dP(s,t,e,r,i,n,o,a,l){let h=hP(s,t);if(an(t.whiteSpace))for(let H=0;H<h.length;H++){let gt=h[H];h[H]={text:gt.text.replace(sR," "),style:gt.style}}let c=[],f=[];for(let H of h){let gt=H.text.split(uP);for(let k=0;k<gt.length;k++){let V=gt[k];V===`\r
898
+ `||V==="\r"||V===`
899
+ `?(c.push(f),f=[]):V.length>0&&f.push({text:V,style:H.style})}}(f.length>0||c.length===0)&&c.push(f);let d=e?iR(c,t,r,n,a,l):c,m=[],g=[],_=[],x=[],S=[],v=0,b=t._fontString,C=o(b);C.fontSize===0&&(C.fontSize=t.fontSize,C.ascent=t.fontSize);let T="",P=!!t.dropShadow,E=t._stroke?.width||0;for(let H of d){let gt=0,k=C.ascent,V=C.descent,at="";for(let _t of H){let Ot=_t.style._fontString,jt=o(Ot);Ot!==T&&(r.font=Ot,T=Ot);let kt=i(_t.text,_t.style.letterSpacing,r);gt+=kt,k=Math.max(k,jt.ascent),V=Math.max(V,jt.descent),at+=_t.text;let Lt=_t.style._stroke?.width||0;Lt>E&&(E=Lt),!P&&_t.style.dropShadow&&(P=!0)}H.length===0&&(k=C.ascent,V=C.descent),m.push(gt),g.push(k),_.push(V),S.push(at);let W=t.lineHeight||k+V;x.push(W+t.leading),v=Math.max(v,gt)}let L=E,B=v+L+(t.dropShadow?t.dropShadow.distance:0),w=0;for(let H=0;H<x.length;H++)w+=x[H];w=Math.max(w,x[0]+L);let I=w+(t.dropShadow?t.dropShadow.distance:0),G=t.lineHeight||C.fontSize;return{width:B,height:I,lines:S,lineWidths:m,lineHeight:G+t.leading,maxLineWidth:v,fontProperties:C,runsByLine:d,lineAscents:g,lineDescents:_,lineHeights:x,hasDropShadow:P}}function iR(s,t,e,r,i,n){let{letterSpacing:o,whiteSpace:a,wordWrapWidth:l,breakWords:h}=t,u=on(a),c=l+o,f={},d="",m=(_,x)=>{let S=`${_}|${x.styleKey}`,v=f[S];if(v===void 0){let b=x._fontString;b!==d&&(e.font=b,d=b),v=r(_,x.letterSpacing,e)+x.letterSpacing,f[S]=v}return v},g=[];for(let _ of s){let x=nR(_),S=g.length,v=w=>{let I=0,G=w;do{let{token:H,style:gt}=x[G];I+=m(H,gt),G++}while(G<x.length&&x[G].continuesFromPrevious);return I},b=w=>{let I=[],G=w;do I.push({token:x[G].token,style:x[G].style}),G++;while(G<x.length&&x[G].continuesFromPrevious);return I},C=[],T=0,P=!u,E=null,L=()=>{E&&E.text.length>0&&C.push(E),E=null},B=()=>{if(L(),C.length>0){let w=C[C.length-1];w.text=er(w.text),w.text.length===0&&C.pop()}g.push(C),C=[],T=0,P=!1};for(let w=0;w<x.length;w++){let{token:I,style:G,continuesFromPrevious:H}=x[w],gt=m(I,G);if(u){let at=ee(I),W=E?.text[E.text.length-1]??C[C.length-1]?.text.slice(-1)??"",_t=W?ee(W):!1;if(at&&_t)continue}let k=!H,V=k?v(w):gt;if(V>c&&k)if(T>0&&B(),h){let at=b(w);for(let W=0;W<at.length;W++){let _t=at[W].token,Ot=at[W].style,jt=au(_t,h,n,i);for(let kt of jt){let Lt=m(kt,Ot);Lt+T>c&&B(),!E||E.style!==Ot?(L(),E={text:kt,style:Ot}):E.text+=kt,T+=Lt}}w+=at.length-1}else{let at=b(w);L(),g.push(at.map(W=>({text:W.token,style:W.style}))),P=!1,w+=at.length-1}else if(V+T>c&&k){if(ee(I)){P=!1;continue}B(),E={text:I,style:G},T=gt}else if(H&&!h)!E||E.style!==G?(L(),E={text:I,style:G}):E.text+=I,T+=gt;else{let at=ee(I);if(T===0&&at&&!P)continue;!E||E.style!==G?(L(),E={text:I,style:G}):E.text+=I,T+=gt}}if(L(),C.length>0){let w=C[C.length-1];w.text=er(w.text),w.text.length===0&&C.pop()}(C.length>0||g.length===S)&&g.push(C)}return g}function nR(s){let t=[],e=!1;for(let r of s){let i=ou(r.text),n=!0;for(let o of i){let a=ee(o)||nn(o),l=n&&e&&!a;t.push({token:o,style:r.style,continuesFromPrevious:l}),e=!a,n=!1}}return t}var sR,fP=p(()=>{cm();Ba();sR=/\r\n|\r|\n/g});function pP(s,t,e,r,i){let n=e[s];return typeof n!="number"&&(n=i(s,t,r)+t,e[s]=n),n}function mP(s,t,e,r,i,n,o){let a=e.getContext("2d",oR);a.font=t._fontString;let l=0,h="",u=[],c=Object.create(null),{letterSpacing:f,whiteSpace:d}=t,m=on(d),g=an(d),_=!m,x=t.wordWrapWidth+f,S=ou(s);for(let b=0;b<S.length;b++){let C=S[b];if(nn(C)){if(!g){u.push(er(h)),_=!m,h="",l=0;continue}C=" "}if(m){let P=ee(C),E=ee(h[h.length-1]);if(P&&E)continue}let T=pP(C,f,c,a,r);if(T>x)if(h!==""&&(u.push(er(h)),h="",l=0),i(C,t.breakWords)){let P=au(C,t.breakWords,o,n);for(let E of P){let L=pP(E,f,c,a,r);L+l>x&&(u.push(er(h)),_=!1,h="",l=0),h+=E,l+=L}}else h.length>0&&(u.push(er(h)),h="",l=0),u.push(er(C)),_=!1,h="",l=0;else T+l>x&&(_=!1,u.push(er(h)),h="",l=0),(h.length>0||!ee(C)||_)&&(h+=C,l+=T)}let v=er(h);return v.length>0&&u.push(v),u.join(`
900
+ `)}var oR,gP=p(()=>{Ba();oR={willReadFrequently:!0}});var _P,Nr,ln,pm=p(()=>{lm();ct();fP();cm();Ba();gP();_P={willReadFrequently:!0},Nr=class Y{static get experimentalLetterSpacingSupported(){let t=Y._experimentalLetterSpacingSupported;if(t===void 0){let e=D.get().getCanvasRenderingContext2D().prototype;t=Y._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,r,i,n,o,a,l,h,u){this.text=t,this.style=e,this.width=r,this.height=i,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h,u&&(this.runsByLine=u.runsByLine,this.lineAscents=u.lineAscents,this.lineDescents=u.lineDescents,this.lineHeights=u.lineHeights,this.hasDropShadow=u.hasDropShadow)}static measureText(t=" ",e,r=Y._canvas,i=e.wordWrap){let n=`${t}-${e.styleKey}-wordWrap-${i}`;if(Y._measurementCache.has(n))return Y._measurementCache.get(n);if(hm(e)&&um(t)){let b=dP(t,e,i,Y._context,Y._measureText,Y._measureTextAdvance,Y.measureFont,Y.canBreakChars,Y.wordWrapSplit),C=new Y(t,e,b.width,b.height,b.lines,b.lineWidths,b.lineHeight,b.maxLineWidth,b.fontProperties,{runsByLine:b.runsByLine,lineAscents:b.lineAscents,lineDescents:b.lineDescents,lineHeights:b.lineHeights,hasDropShadow:b.hasDropShadow});return Y._measurementCache.set(n,C),C}let a=e._fontString,l=Y.measureFont(a);l.fontSize===0&&(l.fontSize=e.fontSize,l.ascent=e.fontSize,l.descent=0);let h=Y._context;h.font=a;let c=(i?Y._wordWrap(t,e,r):t).split(cP),f=new Array(c.length),d=0;for(let b=0;b<c.length;b++){let C=Y._measureText(c[b],e.letterSpacing,h);f[b]=C,d=Math.max(d,C)}let m=e._stroke?.width??0,g=e.lineHeight||l.fontSize,_=Y._adjustWidthForStyle(d,e),x=Math.max(g,l.fontSize+m)+(c.length-1)*(g+e.leading),S=Y._adjustHeightForStyle(x,e),v=new Y(t,e,_,S,c,f,g+e.leading,d,l);return Y._measurementCache.set(n,v),v}static _adjustWidthForStyle(t,e){let r=e._stroke?.width||0,i=t+r;return e.dropShadow&&(i+=e.dropShadow.distance),i}static _adjustHeightForStyle(t,e){let r=t;return e.dropShadow&&(r+=e.dropShadow.distance),r}static _measureText(t,e,r){let{metricWidth:i,metrics:n,letterSpacingVal:o}=Y._measureTextCore(t,e,r),a=-(n.actualBoundingBoxLeft??0),h=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(h+=o),Math.max(i,h)}static _measureTextAdvance(t,e,r){return Y._measureTextCore(t,e,r).metricWidth}static _measureTextCore(t,e,r){let i=!1;Y.experimentalLetterSpacingSupported&&(Y.experimentalLetterSpacing?(r.letterSpacing=`${e}px`,r.textLetterSpacing=`${e}px`,i=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let n=r.measureText(t),o=n.width,a=0;return o>0&&(i?a=-e:a=(Y.graphemeSegmenter(t).length-1)*e,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(t,e,r=Y._canvas){return mP(t,e,r,Y._measureTextAdvance,Y.canBreakWords,Y.canBreakChars,Y.wordWrapSplit)}static isBreakingSpace(t,e){return ee(t,e)}static canBreakWords(t,e){return e}static canBreakChars(t,e,r,i,n){return!0}static wordWrapSplit(t){return Y.graphemeSegmenter(t)}static measureFont(t){if(Y._fonts[t])return Y._fonts[t];let e=Y._context;e.font=t;let r=e.measureText(Y.METRICS_STRING+Y.BASELINE_SYMBOL),i=r.actualBoundingBoxAscent??0,n=r.actualBoundingBoxDescent??0,o={ascent:i,descent:n,fontSize:i+n};return Y._fonts[t]=o,o}static clearMetrics(t=""){t?delete Y._fonts[t]:Y._fonts={}}static get _canvas(){if(!Y.__canvas){let t;try{let e=new OffscreenCanvas(0,0);if(e.getContext("2d",_P)?.measureText)return Y.__canvas=e,e;t=D.get().createCanvas()}catch{t=D.get().createCanvas()}t.width=t.height=10,Y.__canvas=t}return Y.__canvas}static get _context(){return Y.__context||(Y.__context=Y._canvas.getContext("2d",_P)),Y.__context}};Nr.METRICS_STRING="|\xC9q\xC5";Nr.BASELINE_SYMBOL="M";Nr.BASELINE_MULTIPLIER=1.4;Nr.HEIGHT_MULTIPLIER=2;Nr.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){let s=new Intl.Segmenter;return t=>{let e=s.segment(t),r=[],i=0;for(let n of e)r[i++]=n.segment;return r}}return s=>[...s]})();Nr.experimentalLetterSpacing=!1;Nr._fonts={};Nr._measurementCache=nu(1e3);ln=Nr});function Ra(s){let t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize,e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let r=e.length-1;r>=0;r--){let i=e[r].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!aR.includes(i)&&(i=`"${i}"`),e[r]=i}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}var aR,mm=p(()=>{"use strict";aR=["serif","sans-serif","monospace","cursive","fantasy","system-ui"]});function lR(s){let t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){let e=hn.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){N(J,"strokeThickness is now a part of stroke");let e=t.stroke,r={};if(Z.isColorLike(e))r.color=e;else if(e instanceof ae||e instanceof tr)r.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))r=e;else throw new Error("Invalid stroke value.");s.stroke={...r,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(N(J,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&O("The number of fill colors must match the number of fill gradient stops.");let e=new ae({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),r=t.fillGradientStops.slice(),i=t.fill.map(n=>Z.shared.setValue(n).toNumber());r.forEach((n,o)=>{e.addColorStop(n,i[o])}),s.fill={fill:e}}}var gm,hn,_m=p(()=>{Qt();se();Gt();Rt();pt();Xs();_a();tu();qp();mm();gm=class qs extends q{constructor(t={}){super(),this.uid=$("textStyle"),this._tick=0,this._cachedFontString=null,lR(t),t instanceof qs&&(t=t._toObject());let i={...qs.defaultTextStyle,...t};for(let n in i){let o=n;this[o]=i[n]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...qs.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...qs.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({...ge.defaultFillStyle,...t},()=>{this._fill=Vr({...this._originalFill},ge.defaultFillStyle)})),this._fill=Vr(t===0?"black":t,ge.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ge.defaultStrokeStyle,...t},()=>{this._stroke=rn({...this._originalStroke},ge.defaultStrokeStyle)})),this._stroke=rn(t,ge.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){let t=qs.defaultTextStyle;for(let e in t)this[e]=t[e]}assign(t){for(let e in t){let r=e;this[r]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Ra(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new qs(this._toObject())}_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){if(this.removeAllListeners(),typeof t=="boolean"?t:t?.texture){let r=typeof t=="boolean"?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(r),this._originalFill?.texture&&this._originalFill.texture.destroy(r),this._stroke?.texture&&this._stroke.texture.destroy(r),this._originalStroke?.texture&&this._originalStroke.texture.destroy(r)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(r,i,n)=>(r[i]===n||(r[i]=n,e?.(i,n),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Z.isColorLike(t)||t instanceof ae||t instanceof tr)}};gm.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};gm.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};hn=gm});function xm(s,t,e,r=0,i=0,n=0){if(s.texture===F.WHITE&&!s.fill)return Z.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof tr){let o=s.fill,a=t.createPattern(o.texture.source.resource,"repeat");return K.applyPatternTransform(a,o.transform,!1),a}else if(s.fill instanceof ae){let o=s.fill,a=o.type==="linear",l=o.textureSpace==="local",h=1,u=1;l&&e&&(h=e.width+r,u=e.height+r);let c,f=!1;if(a){let{start:d,end:m}=o;c=t.createLinearGradient(d.x*h+i,d.y*u+n,m.x*h+i,m.y*u+n),f=Math.abs(m.x-d.x)<Math.abs((m.y-d.y)*.1)}else{let{center:d,innerRadius:m,outerCenter:g,outerRadius:_}=o;c=t.createRadialGradient(d.x*h+i,d.y*u+n,m*h,g.x*h+i,g.y*u+n,_*h)}if(f&&l&&e){let d=e.lineHeight/u;for(let m=0;m<e.lines.length;m++){let g=(m*e.lineHeight+r/2)/u;o.colorStops.forEach(_=>{let x=g+_.offset*d;x=Math.max(0,Math.min(1,x)),c.addColorStop(Math.floor(x*xP)/xP,Z.shared.setValue(_.color).toHex())})}}else o.colorStops.forEach(d=>{c.addColorStop(d.offset,Z.shared.setValue(d.color).toHex())});return c}}else{let o=t.createPattern(s.texture.source.resource,"repeat"),a=s.matrix.copyTo(R.shared);return a.scale(s.texture.source.pixelWidth,s.texture.source.pixelHeight),o.setTransform(a),o}return O("FillStyle not recognised",s),"red"}var xP,yP=p(()=>{se();nt();wi();yt();pt();Xs();_a();xP=1e5});var bP,ym,SP=p(()=>{se();te();Fl();Ci();yt();zn();Rt();pm();mm();yP();_m();om();bP=class vP extends sn{constructor(t){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;let e={...vP.defaultOptions,...t};this._textureSize=e.textureSize,this._mipmap=e.mipmap;let r=e.style.clone();e.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=F.WHITE,r._fill.fill=null),this.applyFillAsTint=e.overrideFill;let i=r.fontSize;r.fontSize=this.baseMeasurementFontSize;let n=Ra(r);e.overrideSize?(r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/i),r.dropShadow&&(r.dropShadow.blur*=this.baseRenderedFontSize/i,r.dropShadow.distance*=this.baseRenderedFontSize/i)):r.fontSize=this.baseRenderedFontSize=i,this._style=r,this._skipKerning=e.skipKerning??!1,this.resolution=e.resolution??1,this._padding=e.padding??4,e.textureStyle&&(this._textureStyle=e.textureStyle instanceof Rr?e.textureStyle:new Rr(e.textureStyle)),this.fontMetrics=ln.measureFont(n),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(t){let e=ln.graphemeSegmenter(t).filter(x=>!this._currentChars.includes(x)).filter((x,S,v)=>v.indexOf(x)===S);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let r;this._currentPageIndex===-1?r=this._nextPage():r=this.pages[this._currentPageIndex];let{canvas:i,context:n}=r.canvasAndContext,o=r.texture.source,a=this._style,l=this._currentX,h=this._currentY,u=this._currentMaxCharHeight,c=this.baseRenderedFontSize/this.baseMeasurementFontSize,f=(a.dropShadow?.distance??0)+(a._stroke?.width??0),d=this._padding+f,m=!1,g=i.width/this.resolution,_=i.height/this.resolution;for(let x=0;x<e.length;x++){let S=e[x],v=ln.measureText(S,a,i,!1);v.lineHeight=v.height;let b=v.width*c,C=Math.ceil((a.fontStyle==="italic"?2:1)*b),T=v.height*c,P=C+d*2,E=T+d*2;if(m=!1,S!==`
901
+ `&&S!=="\r"&&S!==" "&&S!==" "&&(m=!0,u=Math.ceil(Math.max(E,u))),l+P>g&&(h+=u,u=E,l=0,h+u>_)){o.update();let B=this._nextPage();i=B.canvasAndContext.canvas,n=B.canvasAndContext.context,o=B.texture.source,l=0,h=0,u=0}let L=n.measureText(S).width/c;if(this.chars[S]={id:S.codePointAt(0),xOffset:-(d/c),yOffset:-(d/c),xAdvance:L,kerning:{}},m){this._drawGlyph(n,v,l+d,h+d,c,a);let B=o.width*c,w=o.height*c,I=new rt(l/B*o.width,h/w*o.height,P/B*o.width,E/w*o.height);this.chars[S].texture=new F({source:o,frame:I}),l+=Math.ceil(P)}}o.update(),this._currentX=l,this._currentY=h,this._currentMaxCharHeight=u,this._skipKerning||this._applyKerning(e,n,c)}get pageTextures(){return N(J,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e,r){let i=this._measureCache;for(let n=0;n<t.length;n++){let o=t[n];for(let a=0;a<this._currentChars.length;a++){let l=this._currentChars[a],h=i[o];h||(h=i[o]=e.measureText(o).width);let u=i[l];u||(u=i[l]=e.measureText(l).width);let c=e.measureText(o+l).width,f=c-(h+u);f&&this.chars[o]&&(this.chars[o].kerning[l]=f/r),c=e.measureText(o+l).width,f=c-(h+u),f&&this.chars[l]&&(this.chars[l].kerning[o]=f/r)}}}_nextPage(){this._currentPageIndex++;let t=this.resolution,e=Lr.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);let r=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),i=new F({source:new xe({resource:e.canvas,resolution:r,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(i.source.style=this._textureStyle);let n={canvasAndContext:e,texture:i};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,r){e.fontSize=this.baseRenderedFontSize,t.scale(r,r),t.font=Ra(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;let i=e._stroke,n=i?.width??0;if(i&&(t.lineWidth=n,t.lineJoin=i.join,t.miterLimit=i.miterLimit,t.strokeStyle=xm(i,t)),e._fill&&(t.fillStyle=xm(e._fill,t)),e.dropShadow){let o=e.dropShadow,a=Z.shared.setValue(o.color).toArray(),l=o.blur*r,h=o.distance*r;t.shadowColor=`rgba(${a[0]*255},${a[1]*255},${a[2]*255},${o.alpha})`,t.shadowBlur=l,t.shadowOffsetX=Math.cos(o.angle)*h,t.shadowOffsetY=Math.sin(o.angle)*h}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,r,i,n,o){let a=e.text,l=e.fontProperties,u=(o._stroke?.width??0)*n,c=r+u/2,f=i-u/2,d=l.descent*n,m=e.lineHeight*n,g=!1;o.stroke&&u&&(g=!0,t.strokeText(a,c,f+m-d));let{shadowBlur:_,shadowOffsetX:x,shadowOffsetY:S}=t;o._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(a,c,f+m-d)),g&&(t.shadowBlur=_,t.shadowOffsetX=x,t.shadowOffsetY=S)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){let{canvasAndContext:e,texture:r}=this.pages[t];Lr.returnCanvasAndContext(e),r.destroy(!0)}this.pages=null}};bP.defaultOptions={textureSize:512,style:new hn,mipmap:!0};ym=bP});function TP(s,t,e,r){let i={width:0,height:0,offsetY:0,scale:t.fontSize/e.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};i.offsetY=e.baseLineOffset;let n=i.lines[0],o=null,a=!0,l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=e.baseMeasurementFontSize/t.fontSize,u=t.letterSpacing*h,c=t.wordWrapWidth*h,f=t.lineHeight?t.lineHeight*h:e.lineHeight,d=t.wordWrap&&t.breakWords,m=on(t.whiteSpace),g=an(t.whiteSpace);if(m||g){let v=[],b=m;for(let C=0;C<s.length;C++){let T=s[C];if(T==="\r"||T===`
902
+ `)if(g)T==="\r"&&s[C+1]===`
903
+ `&&C++,T=" ";else{m&&(b=!0),v.push(T);continue}if(ee(T))if(m&&dm(T)){if(b)continue;b=!0,v.push(" ")}else b=!1,v.push(T);else b=!1,v.push(T)}s=v}let _=v=>{let b=n.width;for(let C=0;C<l.index;C++){let T=v.positions[C];n.chars.push(v.chars[C]),n.charPositions.push(T+b)}n.width+=v.width,(l.index>0||!m)&&(a=!1),l.width=0,l.index=0,l.chars.length=0},x=()=>{let v=n.chars.length-1;if(r){let b=n.chars[v];for(;dm(b);)n.width-=e.chars[b].xAdvance,n.spacesIndex.pop(),b=n.chars[--v]}i.width=Math.max(i.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(n),i.height+=f},S=v=>v-u>c;for(let v=0;v<s.length+1;v++){let b,C=v===s.length;C||(b=s[v]);let T=e.chars[b];if(/(?:\s)/.test(b)||b==="\r"||b===`
904
+ `||C){if(!a&&t.wordWrap&&S(n.width+l.width)?(x(),_(l),!C&&T&&n.charPositions.push(0)):(l.start=n.width,_(l),!C&&T&&n.charPositions.push(0)),b==="\r"||b===`
905
+ `)x();else if(!C&&T){let B=T.xAdvance+(T.kerning?.[o]||0)+u;n.width+=B,n.spaceWidth=B,n.spacesIndex.push(n.charPositions.length),n.chars.push(b)}}else if(T){let L=T.kerning?.[o]||0,B=T.xAdvance+L+u;d&&S(l.width+B)&&(a||x(),_(l),x()),l.positions[l.index++]=l.width+L,l.chars.push(b),l.width+=B,fm(b)&&(!a&&t.wordWrap&&S(n.width+l.width)&&x(),_(l))}o=b}return x(),t.align==="center"?hR(i):t.align==="right"?uR(i):t.align==="justify"&&cR(i),i}function hR(s){for(let t=0;t<s.lines.length;t++){let e=s.lines[t],r=s.width/2-e.width/2;for(let i=0;i<e.charPositions.length;i++)e.charPositions[i]+=r}}function uR(s){for(let t=0;t<s.lines.length;t++){let e=s.lines[t],r=s.width-e.width;for(let i=0;i<e.charPositions.length;i++)e.charPositions[i]+=r}}function cR(s){let t=s.width;for(let e=0;e<s.lines.length-2;e++){let r=s.lines[e],i=0,n=r.spacesIndex[i++],o=0,a=r.spacesIndex.length,h=(t-r.width)/a;for(let u=0;u<r.charPositions.length;u++)u===n&&(n=r.spacesIndex[i++],o+=h),r.charPositions[u]+=o}}var CP=p(()=>{Ba()});function PP(s){if(s==="")return[];typeof s=="string"&&(s=[s]);let t=[];for(let e=0,r=s.length;e<r;e++){let i=s[e];if(Array.isArray(i)){if(i.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${i.length}.`);if(i[0].length===0||i[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");let n=i[0].charCodeAt(0),o=i[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(i))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}var MP=p(()=>{"use strict"});var lu,bm,vm,wP=p(()=>{lm();Pi();Rt();pt();pm();_m();SP();CP();MP();lu=0,bm=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=nu(1e3)}getFont(t,e){let r=`${e.fontFamily}-bitmap`,i=!0;if(ft.has(r)){let o=ft.get(r);return o.ensureCharacters?.(t),o}if(e._fill.fill&&!e._stroke?(r+=e._fill.fill.styleKey,i=!1):(e._stroke||e.dropShadow)&&(r=`${e.styleKey}-bitmap`,i=!1),r+=`-${e.fontStyle}`,r+=`-${e.fontVariant}`,r+=`-${e.fontWeight}`,!ft.has(r)){let o=Object.create(e);o._lineHeight=0;let a=new ym({style:o,overrideFill:i,overrideSize:!0,...this.defaultOptions});lu++,lu>50&&O("BitmapText",`You have dynamically created ${lu} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),a.once("destroy",()=>{lu--,ft.remove(r)}),ft.set(r,a)}let n=ft.get(r);return n.ensureCharacters?.(t),n}getLayout(t,e,r=!0){let i=this.getFont(t,e),n=`${t}-${e.styleKey}-${r}`;if(this.measureCache.has(n))return this.measureCache.get(n);let o=ln.graphemeSegmenter(t),a=TP(o,e,i,r);return this.measureCache.set(n,a),a}measureText(t,e,r=!0){return this.getLayout(t,e,r)}install(...t){let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},N(J,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));let r=e?.name;if(!r)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};let i=e.style,n=i instanceof hn?i:new hn(i),o=e.dynamicFill??this._canUseTintForStyle(n),a=new ym({style:n,overrideFill:o,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),l=PP(e.chars);return a.ensureCharacters(l.join("")),ft.set(`${r}-bitmap`,a),a.once("destroy",()=>ft.remove(`${r}-bitmap`)),a}uninstall(t){let e=`${t}-bitmap`,r=ft.get(e);r&&r.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}},vm=new bm});var EP={};Mr(EP,{BitmapFont:()=>Sm});var Sm,AP=p(()=>{mi();te();yt();om();wP();Sm=class extends sn{constructor(t,e){super();let{textures:r,data:i}=t;Object.keys(i.pages).forEach(n=>{let o=i.pages[parseInt(n,10)],a=r[o.id];this.pages.push({texture:a})}),Object.keys(i.chars).forEach(n=>{let o=i.chars[n],{frame:a,source:l,rotate:h}=r[o.page],u=Q.transformRectCoords(o,a,h,new rt),c=new F({frame:u,orig:new rt(0,0,o.width,o.height),source:l,rotate:h});this.chars[n]={id:n.codePointAt(0),xOffset:o.xOffset,yOffset:o.yOffset,xAdvance:o.xAdvance,kerning:o.kerning??{},texture:c}}),this.baseRenderedFontSize=i.fontSize,this.baseMeasurementFontSize=i.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:i.fontSize},this.baseLineOffset=i.baseLineOffset,this.lineHeight=i.lineHeight,this.fontFamily=i.fontFamily,this.distanceField=i.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){let{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){vm.install(t)}static uninstall(t){vm.uninstall(t)}}});var dR,BP,RP,IP=p(()=>{kr();xd();ct();A();Kr();oP();lP();dR=[".xml",".fnt"],BP={extension:{type:y.CacheParser,name:"cacheBitmapFont"},test:s=>!!s?.pages&&!!s?.chars&&typeof s?.fontFamily=="string"&&s.fontFamily!=="",getCacheableAssets(s,t){let e={};return s.forEach(r=>{e[r]=t,e[`${r}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},RP={extension:{type:y.LoadParser,priority:$t.Normal},name:"loadBitmapFont",id:"bitmap-font",test(s){return dR.includes(wt.extname(s).toLowerCase())},async testParse(s){return iu.test(s)||nm.test(s)},async parse(s,t,e){let r=iu.test(s)?iu.parse(s):nm.parse(s),{src:i}=t,{pages:n}=r,o=[],a=r.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let f=0;f<n.length;++f){let d=n[f].file,m=wt.join(wt.dirname(i),d);m=Zn(m,i),o.push({src:m,data:a})}let[l,{BitmapFont:h}]=await Promise.all([e.load(o),Promise.resolve().then(()=>(AP(),EP))]),u=o.map(f=>l[f.src]);return new h({data:r,textures:u},i)},async load(s,t){return await(await D.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(r=>e.unload(r.texture.source._sourceOrigin))),s.destroy()}}});var hu,FP=p(()=>{"use strict";hu=class{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;let t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let r=0;r<e;r++)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())}}});var kP,LP=p(()=>{A();yt();kP={extension:{type:y.CacheParser,name:"cacheTextureArray"},test:s=>Array.isArray(s)&&s.every(t=>t instanceof F),getCacheableAssets:(s,t)=>{let e={};return s.forEach(r=>{t.forEach((i,n)=>{e[r+(n===0?"":n+1)]=i})}),e}}});async function uu(s){if("Image"in globalThis)return new Promise(t=>{let e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{let t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}var Tm=p(()=>{"use strict"});var DP,OP=p(()=>{A();Tm();DP={extension:{type:y.DetectionParser,priority:1},test:async()=>uu("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")}});var GP,UP,VP=p(()=>{A();GP=["png","jpg","jpeg"],UP={extension:{type:y.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...GP],remove:async s=>s.filter(t=>!GP.includes(t))}});function os(s){return fR?!1:document.createElement("video").canPlayType(s)!==""}var fR,Ia=p(()=>{"use strict";fR="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope});var NP,HP=p(()=>{A();Ia();NP={extension:{type:y.DetectionParser,priority:0},test:async()=>os("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")}});var zP,WP=p(()=>{A();Ia();zP={extension:{type:y.DetectionParser,priority:0},test:async()=>os("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")}});var XP,jP=p(()=>{A();Ia();XP={extension:{type:y.DetectionParser,priority:0},test:async()=>os("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")}});var YP,$P=p(()=>{A();Tm();YP={extension:{type:y.DetectionParser,priority:0},test:async()=>uu("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")}});var qP,KP,ZP=p(()=>{pt();Kr();Kn();Pl();qP=class cu{constructor(){this.loadOptions={...cu.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,r)=>(this._parsersValidated=!1,t[e]=r,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){let r={promise:null,parser:null};return r.promise=(async()=>{let i=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&O(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),n||O(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!n){for(let o=0;o<this.parsers.length;o++){let a=this.parsers[o];if(a.load&&a.test?.(t,e,this)){n=a;break}}if(!n)return O(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}i=await n.load(t,e,this),r.parser=n;for(let o=0;o<this.parsers.length;o++){let a=this.parsers[o];a.parse&&a.parse&&await a.testParse?.(i,e,this)&&(i=await a.parse(i,e,this)||i,r.parser=a)}return i})(),r}async load(t,e){this._parsersValidated||this._validateParsers();let r=typeof e=="function"?{...cu.defaultOptions,...this.loadOptions,onProgress:e}:{...cu.defaultOptions,...this.loadOptions,...e||{}},{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l}=r,h=0,u={},c=Bs(t),f=fe(t,g=>({alias:[g],src:g,data:{}})),d=f.reduce((g,_)=>g+(_.progressSize||1),0),m=f.map(async g=>{let _=wt.toAbsolute(g.src);u[g.src]||(await this._loadAssetWithRetry(_,g,{onProgress:i,onError:n,strategy:o,retryCount:a,retryDelay:l},u),h+=g.progressSize||1,i&&i(h/d))});return await Promise.all(m),c?u[f[0].src]:u}async unload(t){let r=fe(t,i=>({alias:[i],src:i})).map(async i=>{let n=wt.toAbsolute(i.src),o=this.promiseCache[n];if(o){let a=await o.promise;delete this.promiseCache[n],await o.parser?.unload?.(a,i,this)}});await Promise.all(r)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(!e.name&&!e.id?O("[Assets] parser should have an id"):(t[e.name]||t[e.id])&&O(`[Assets] parser id conflict "${e.id}"`),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,r,i){let n=0,{onError:o,strategy:a,retryCount:l,retryDelay:h}=r,u=c=>new Promise(f=>setTimeout(f,c));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),i[e.src]=await this.promiseCache[t].promise;return}catch(c){delete this.promiseCache[t],delete i[e.src],n++;let f=a!=="retry"||n>l;if(a==="retry"&&!f){o&&o(c,e),await u(h);continue}if(a==="skip"){o&&o(c,e);return}o&&o(c,e);let d=new Error(`[Loader.load] Failed to load ${t}.
906
+ ${c}`);throw c instanceof Error&&c.stack&&(d.stack=c.stack),d}}};qP.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};KP=qP});function Ve(s,t){if(Array.isArray(t)){for(let e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}var Ks=p(()=>{"use strict"});function Ne(s,t){let e=s.split("?")[0],r=wt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(r):r===t}var Zs=p(()=>{Kr()});var pR,mR,JP,QP=p(()=>{ct();A();Ks();Zs();kr();pR=".json",mR="application/json",JP={extension:{type:y.LoadParser,priority:$t.Low},name:"loadJson",id:"json",test(s){return Ve(s,mR)||Ne(s,pR)},async load(s){return await(await D.get().fetch(s)).json()}}});var gR,_R,tM,eM=p(()=>{ct();A();Ks();Zs();kr();gR=".txt",_R="text/plain",tM={name:"loadTxt",id:"text",extension:{type:y.LoadParser,priority:$t.Low,name:"loadTxt"},test(s){return Ve(s,_R)||Ne(s,gR)},async load(s){return await(await D.get().fetch(s)).text()}}});function SR(s){let t=wt.extname(s),i=wt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)),n=i.length>0;for(let a of i)if(!a.match(vR)){n=!1;break}let o=i.join(" ");return n||(o=`"${o.replace(/[\\"]/g,"\\$&")}"`),o}function CR(s){return TR.test(s)?s:encodeURI(s)}var xR,yR,bR,vR,TR,rM,sM=p(()=>{ct();A();pt();Kr();Pi();Ks();Zs();kr();xR=["normal","bold","100","200","300","400","500","600","700","800","900"],yR=[".ttf",".otf",".woff",".woff2"],bR=["font/ttf","font/otf","font/woff","font/woff2"],vR=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;TR=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;rM={extension:{type:y.LoadParser,priority:$t.Low},name:"loadWebFont",id:"web-font",test(s){return Ve(s,bR)||Ne(s,yR)},async load(s,t){let e=D.get().getFontFaceSet();if(e){let r=[],i=t.data?.family??SR(s),n=t.data?.weights?.filter(a=>xR.includes(a))??["normal"],o=t.data??{};for(let a=0;a<n.length;a++){let l=n[a],h=new FontFace(i,`url('${CR(s)}')`,{...o,weight:l});await h.load(),e.add(h),r.push(h)}return ft.has(`${i}-and-url`)?ft.get(`${i}-and-url`).entries.push({url:s,faces:r}):ft.set(`${i}-and-url`,{entries:[{url:s,faces:r}]}),r.length===1?r[0]:r}return O("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(s){let t=Array.isArray(s)?s:[s],e=t[0].family,r=ft.get(`${e}-and-url`),i=r.entries.find(n=>n.faces.some(o=>t.indexOf(o)!==-1));i.faces=i.faces.filter(n=>t.indexOf(n)===-1),i.faces.length===0&&(r.entries=r.entries.filter(n=>n!==i)),t.forEach(n=>{D.get().getFontFaceSet().delete(n)}),r.entries.length===0&&ft.remove(`${e}-and-url`)}}});function un(s,t=1){let e=Pe.RETINA_PREFIX?.exec(s);return e?parseFloat(e[1]):t}var du=p(()=>{Ti()});function cn(s,t,e){s.label=e,s._sourceOrigin=e;let r=new F({source:s,label:e}),i=()=>{delete t.promiseCache[e],ft.has(e)&&ft.remove(e)};return r.source.once("destroy",()=>{t.promiseCache[e]&&(O("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),i())}),r.once("destroy",()=>{s.destroyed||(O("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),i())}),r}var fu=p(()=>{yt();pt();Pi()});async function wR(s,t,e,r){let i=await D.get().fetch(s),n=D.get().createImage();n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await i.text())}`,n.crossOrigin=r,await n.decode();let o=t.data?.width??n.width,a=t.data?.height??n.height,l=t.data?.resolution||un(s),h=Math.ceil(o*l),u=Math.ceil(a*l),c=D.get().createCanvas(h,u),f=c.getContext("2d");f.imageSmoothingEnabled=!0,f.imageSmoothingQuality="high",f.drawImage(n,0,0,o*l,a*l);let{parseAsGraphicsContext:d,...m}=t.data??{},g=new xe({resource:c,alphaMode:"premultiply-alpha-on-upload",resolution:l,...m});return cn(g,e,s)}async function ER(s){let e=await(await D.get().fetch(s)).text(),r=new ge;return r.svg(e),r}var PR,MR,iM,nM=p(()=>{ct();A();Ci();tu();du();Ks();Zs();kr();fu();PR=".svg",MR="image/svg+xml",iM={extension:{type:y.LoadParser,priority:$t.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return Ve(s,MR)||Ne(s,PR)},async load(s,t,e){return t.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?ER(s):wR(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}}});var AR,dn,fn,oM=p(()=>{AR=`(function () {
907
+ 'use strict';
908
+
909
+ const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
910
+ async function checkImageBitmap() {
911
+ try {
912
+ if (typeof createImageBitmap !== "function") return false;
913
+ const response = await fetch(WHITE_PNG);
914
+ const imageBlob = await response.blob();
915
+ const imageBitmap = await createImageBitmap(imageBlob);
916
+ return imageBitmap.width === 1 && imageBitmap.height === 1;
917
+ } catch (_e) {
918
+ return false;
919
+ }
920
+ }
921
+ void checkImageBitmap().then((result) => {
922
+ self.postMessage(result);
923
+ });
924
+
925
+ })();
926
+ `,dn=null,fn=class{constructor(){dn||(dn=URL.createObjectURL(new Blob([AR],{type:"application/javascript"}))),this.worker=new Worker(dn)}};fn.revokeObjectURL=function(){dn&&(URL.revokeObjectURL(dn),dn=null)}});var BR,pn,Fa,aM=p(()=>{BR=`(function () {
927
+ 'use strict';
928
+
929
+ async function loadImageBitmap(url, alphaMode) {
930
+ const response = await fetch(url);
931
+ if (!response.ok) {
932
+ throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
933
+ }
934
+ const imageBlob = await response.blob();
935
+ return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
936
+ }
937
+ self.onmessage = async (event) => {
938
+ try {
939
+ const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
940
+ self.postMessage({
941
+ data: imageBitmap,
942
+ uuid: event.data.uuid,
943
+ id: event.data.id
944
+ }, [imageBitmap]);
945
+ } catch (e) {
946
+ self.postMessage({
947
+ error: e,
948
+ uuid: event.data.uuid,
949
+ id: event.data.id
950
+ });
951
+ }
952
+ };
953
+
954
+ })();
955
+ `,pn=null,Fa=class{constructor(){pn||(pn=URL.createObjectURL(new Blob([BR],{type:"application/javascript"}))),this.worker=new Worker(pn)}};Fa.revokeObjectURL=function(){pn&&(URL.revokeObjectURL(pn),pn=null)}});var lM,Cm,Pm,Mm,hM=p(()=>{oM();aM();lM=0,Pm=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=>{let{worker:e}=new fn;e.addEventListener("message",r=>{e.terminate(),fn.revokeObjectURL(),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Cm===void 0&&(Cm=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<Cm&&(this._createdWorkers++,t=new Fa().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();let r=new Promise((i,n)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:n})});return this._next(),r}_next(){if(!this._queue.length)return;let t=this._getWorker();if(!t)return;let e=this._queue.pop(),r=e.id;this._resolveHash[lM]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:lM++,id:r})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},Mm=new Pm});async function uM(s,t){let e=await D.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);let r=await e.blob();return t?.data?.alphaMode==="premultiplied-alpha"?createImageBitmap(r,{premultiplyAlpha:"none"}):createImageBitmap(r)}var RR,IR,Js,pu=p(()=>{ct();A();Ci();du();Ks();Zs();hM();kr();fu();RR=[".jpeg",".jpg",".png",".webp",".avif"],IR=["image/jpeg","image/png","image/webp","image/avif"];Js={name:"loadTextures",id:"texture",extension:{type:y.LoadParser,priority:$t.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return Ve(s,IR)||Ne(s,RR)},async load(s,t,e){let r=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Mm.isImageBitmapSupported()?r=await Mm.loadImageBitmap(s,t):r=await uM(s,t):r=await new Promise((n,o)=>{r=D.get().createImage(),r.crossOrigin=this.config.crossOrigin,r.src=s,r.complete?n(r):(r.onload=()=>{n(r)},r.onerror=o)});let i=new xe({resource:r,alphaMode:"premultiply-alpha-on-upload",resolution:t.data?.resolution||un(s),...t.data});return cn(i,e,s)},unload(s){s.destroy(!0)}}});function kR(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=DR(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function LR(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",r),s.addEventListener("error",i),s.load();function r(){n(),t()}function i(o){n(),e(o)}function n(){s.removeEventListener("canplaythrough",r),s.removeEventListener("error",i)}})}function DR(s,t=globalThis.location){if(s.startsWith("data:"))return"";t||(t=globalThis.location);let e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function OR(){let s=[],t=[];for(let e of FR){let r=Is.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;os(r)&&(s.push(e),t.includes(r)||t.push(r))}return{validVideoExtensions:s,validVideoMime:t}}var FR,wm,Em,cM,dM=p(()=>{A();Pd();Cd();du();Ia();Ks();Zs();fu();FR=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];cM={name:"loadVideo",id:"video",extension:{type:y.LoadParser,name:"loadVideo"},test(s){if(!wm||!Em){let{validVideoExtensions:r,validVideoMime:i}=OR();wm=r,Em=i}let t=Ve(s,Em),e=Ne(s,wm);return t||e},async load(s,t,e){let r={...Is.defaultOptions,resolution:t.data?.resolution||un(s),alphaMode:t.data?.alphaMode||await Al(),...t.data},i=document.createElement("video"),n={preload:r.autoLoad!==!1?"auto":void 0,"webkit-playsinline":r.playsinline!==!1?"":void 0,playsinline:r.playsinline!==!1?"":void 0,muted:r.muted===!0?"":void 0,loop:r.loop===!0?"":void 0,autoplay:r.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{let h=n[l];h!==void 0&&i.setAttribute(l,h)}),r.muted===!0&&(i.muted=!0),kR(i,s,r.crossorigin);let o=document.createElement("source"),a;if(r.mime)a=r.mime;else if(s.startsWith("data:"))a=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){let l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();a=Is.MIME_TYPES[l]||`video/${l}`}return o.src=s,a&&(o.type=a),new Promise((l,h)=>{r.preload&&!r.autoPlay&&i.load(),i.addEventListener("canplay",u),i.addEventListener("error",c),o.addEventListener("error",c),i.appendChild(o);async function u(){let d=new Is({...r,resource:i});f(),t.data.preload&&await LR(i),l(cn(d,e,s))}function c(d){f(),h(d)}function f(){i.removeEventListener("canplay",u),i.removeEventListener("error",c),o.removeEventListener("error",c)}})},unload(s){s.destroy(!0)}}});var mu,Am=p(()=>{A();pu();Ti();mu={extension:{type:y.ResolveParser,name:"resolveTexture"},test:Js.test,parse:s=>({resolution:parseFloat(Pe.RETINA_PREFIX.exec(s)?.[1]??"1"),format:s.split(".").pop(),src:s})}});var fM,pM=p(()=>{A();Ti();Am();fM={extension:{type:y.ResolveParser,priority:-2,name:"resolveJson"},test:s=>Pe.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:mu.parse}});var gu,Qs,mM,gM=p(()=>{A();IP();pt();FP();Pi();LP();OP();VP();HP();WP();jP();$P();ZP();QP();eM();sM();nM();pu();dM();pM();Am();Ti();Kn();Pl();gu=class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Pe,this.loader=new KP,this.cache=ft,this._backgroundLoader=new hu(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized){O("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");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 n=t.manifest;typeof n=="string"&&(n=await this.load(n)),this.resolver.addManifest(n)}let e=t.texturePreference?.resolution??1,r=typeof e=="number"?[e]:e,i=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:i,resolution:r}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...t.loadOptions})}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();let r=Bs(t),i=fe(t).map(a=>{if(typeof a!="string"){let l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(i),o=await this._mapLoadToResolve(n,e);return r?o[i[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let r=!1;typeof t=="string"&&(r=!0,t=[t]);let i=this.resolver.resolveBundle(t),n={},o=Object.keys(i),a=0,l=[],h=()=>{e?.(l.reduce((c,f)=>c+f,0)/a)},u=o.map((c,f)=>{let d=i[c],m=Object.values(d),_=[...new Set(m.flat())].reduce((x,S)=>x+(S.progressSize||1),0);return l.push(0),a+=_,this._mapLoadToResolve(d,x=>{l[f]=x*_,h()}).then(x=>{n[c]=x})});return await Promise.all(u),r?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);let e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);let e=this.resolver.resolveBundle(t);Object.values(e).forEach(r=>{this._backgroundLoader.add(Object.values(r))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return ft.get(t);let e={};for(let r=0;r<t.length;r++)e[r]=ft.get(t[r]);return e}async _mapLoadToResolve(t,e){let r=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;let i=await this.loader.load(r,e);this._backgroundLoader.active=!0;let n={};return r.forEach(o=>{let a=i[o.src],l=[o.src];o.alias&&l.push(...o.alias),l.forEach(h=>{n[h]=a}),ft.set(l,a)}),n}async unload(t){this._initialized||await this.init();let e=fe(t).map(i=>typeof i!="string"?i.src:i),r=this.resolver.resolve(e);await this._unloadFromResolved(r)}async unloadBundle(t){this._initialized||await this.init(),t=fe(t);let e=this.resolver.resolveBundle(t),r=Object.keys(e).map(i=>this._unloadFromResolved(e[i]));await Promise.all(r)}async _unloadFromResolved(t){let e=Object.values(t);e.forEach(r=>{ft.remove(r.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(let r of t.detections)t.skipDetections||await r.test()?e=await r.add(e):t.skipDetections||(e=await r.remove(e));return e=e.filter((r,i)=>e.indexOf(r)===i),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(r=>r in t).forEach(r=>{e.config[r]=t[r]})})}},Qs=new gu;U.handleByList(y.LoadParser,Qs.loader.parsers).handleByList(y.ResolveParser,Qs.resolver.parsers).handleByList(y.CacheParser,Qs.cache.parsers).handleByList(y.DetectionParser,Qs.detections);U.add(kP,UP,DP,YP,NP,zP,XP,JP,tM,rM,iM,Js,cM,RP,BP,mu,fM);mM={loader:y.LoadParser,resolver:y.ResolveParser,cache:y.CacheParser,detection:y.DetectionParser};U.handle(y.Asset,s=>{let t=s.ref;Object.entries(mM).filter(([e])=>!!t[e]).forEach(([e,r])=>U.add(Object.assign(t[e],{extension:t[e].extension??r})))},s=>{let t=s.ref;Object.keys(mM).filter(e=>!!t[e]).forEach(e=>U.remove(t[e]))})});var ka,_M=p(()=>{nt();Vn();ka=class{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t??new R,this.observer=e,this.position=new Ct(this,0,0),this.scale=new Ct(this,1,1),this.pivot=new Ct(this,0,0),this.skew=new Ct(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){let 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){this.dirty=!0,t===this.skew&&this.updateSkew(),this.observer?._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}toString(){return`[pixi.js/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`}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 He=p(()=>{Xy();$y();A();A();Rl();Ml();nP();gM();kr();pu();ct();nt();Vn();ke();Cp();Zr();yt();Ed();ie();Ke();As();Qt();_M();Kr();U.add(Wy,Yy)});function yM(s){return xM=s,s}function ht(){return xM}var xM,Me=p(()=>{});var Wt,pr=p(()=>{Wt=class{constructor(t,e){this.init(t,e)}init(t,e){this.destination=t,this.source=e||t}connect(t){this.source?.connect(t)}disconnect(){this.source?.disconnect()}destroy(){this.disconnect(),this.destination=null,this.source=null}}});var _u,bM=p(()=>{Me();pr();_u=class extends Wt{constructor(t=0){let e;if(!ht().useLegacy){let{audioContext:r}=ht().context;e=r.createWaveShaper()}super(e),this._distortion=e,this.amount=t}set amount(t){if(this._amount=t,ht().useLegacy)return;let e=t*1e3,r=44100,i=new Float32Array(r),n=Math.PI/180,o=0,a;for(;o<r;++o)a=o*2/r-1,i[o]=(3+e)*a*20*n/(Math.PI+e*Math.abs(a));this._distortion.curve=i,this._distortion.oversample="4x"}get amount(){return this._amount}destroy(){this._distortion=null,super.destroy()}}});var Dt,ti=p(()=>{Me();Dt=class{static setParamValue(t,e){if(t.setValueAtTime){let r=ht().context;t.setValueAtTime(e,r.audioContext.currentTime)}else t.value=e;return e}}});var mt,ze,vM=p(()=>{Me();ti();pr();mt=class extends Wt{constructor(s=0,t=0,e=0,r=0,i=0,n=0,o=0,a=0,l=0,h=0){let u=[],c=[{f:mt.F32,type:"lowshelf",gain:s},{f:mt.F64,type:"peaking",gain:t},{f:mt.F125,type:"peaking",gain:e},{f:mt.F250,type:"peaking",gain:r},{f:mt.F500,type:"peaking",gain:i},{f:mt.F1K,type:"peaking",gain:n},{f:mt.F2K,type:"peaking",gain:o},{f:mt.F4K,type:"peaking",gain:a},{f:mt.F8K,type:"peaking",gain:l},{f:mt.F16K,type:"highshelf",gain:h}];ht().useLegacy||(u=c.map(f=>{let d=ht().context.audioContext.createBiquadFilter();return d.type=f.type,Dt.setParamValue(d.Q,1),d.frequency.value=f.f,Dt.setParamValue(d.gain,f.gain),d})),super(u[0],u[u.length-1]),this.bands=u,this.bandsMap={};for(let f=0;f<this.bands.length;f++){let d=this.bands[f];f>0&&this.bands[f-1].connect(d),this.bandsMap[d.frequency.value]=d}}setGain(s,t=0){if(!this.bandsMap[s])throw new Error(`No band found for frequency ${s}`);Dt.setParamValue(this.bandsMap[s].gain,t)}getGain(s){if(!this.bandsMap[s])throw new Error(`No band found for frequency ${s}`);return this.bandsMap[s].gain.value}set f32(s){this.setGain(mt.F32,s)}get f32(){return this.getGain(mt.F32)}set f64(s){this.setGain(mt.F64,s)}get f64(){return this.getGain(mt.F64)}set f125(s){this.setGain(mt.F125,s)}get f125(){return this.getGain(mt.F125)}set f250(s){this.setGain(mt.F250,s)}get f250(){return this.getGain(mt.F250)}set f500(s){this.setGain(mt.F500,s)}get f500(){return this.getGain(mt.F500)}set f1k(s){this.setGain(mt.F1K,s)}get f1k(){return this.getGain(mt.F1K)}set f2k(s){this.setGain(mt.F2K,s)}get f2k(){return this.getGain(mt.F2K)}set f4k(s){this.setGain(mt.F4K,s)}get f4k(){return this.getGain(mt.F4K)}set f8k(s){this.setGain(mt.F8K,s)}get f8k(){return this.getGain(mt.F8K)}set f16k(s){this.setGain(mt.F16K,s)}get f16k(){return this.getGain(mt.F16K)}reset(){this.bands.forEach(s=>{Dt.setParamValue(s.gain,0)})}destroy(){this.bands.forEach(s=>{s.disconnect()}),this.bands=null,this.bandsMap=null}},ze=mt;ze.F32=32;ze.F64=64;ze.F125=125;ze.F250=250;ze.F500=500;ze.F1K=1e3;ze.F2K=2e3;ze.F4K=4e3;ze.F8K=8e3;ze.F16K=16e3});var xu,SM=p(()=>{Me();pr();xu=class extends Wt{constructor(){let t,e;if(!ht().useLegacy){let{audioContext:r}=ht().context;e=r.createChannelSplitter(),t=r.createChannelMerger(),t.connect(e)}super(t,e),this._merger=t}destroy(){this._merger?.disconnect(),this._merger=null,super.destroy()}}});var yu,TM=p(()=>{Me();pr();yu=class extends Wt{constructor(t=3,e=2,r=!1){super(null),this._seconds=this._clamp(t,1,50),this._decay=this._clamp(e,0,100),this._reverse=r,this._rebuild()}_clamp(t,e,r){return Math.min(r,Math.max(e,t))}get seconds(){return this._seconds}set seconds(t){this._seconds=this._clamp(t,1,50),this._rebuild()}get decay(){return this._decay}set decay(t){this._decay=this._clamp(t,0,100),this._rebuild()}get reverse(){return this._reverse}set reverse(t){this._reverse=t,this._rebuild()}_rebuild(){if(ht().useLegacy)return;let{audioContext:t}=ht().context,e=t.sampleRate,r=e*this._seconds,i=t.createBuffer(2,r,e),n=i.getChannelData(0),o=i.getChannelData(1),a;for(let h=0;h<r;h++)a=this._reverse?r-h:h,n[h]=(Math.random()*2-1)*Math.pow(1-a/r,this._decay),o[h]=(Math.random()*2-1)*Math.pow(1-a/r,this._decay);let l=t.createConvolver();l.buffer=i,this.init(l)}}});var bu,CM=p(()=>{Me();ti();pr();bu=class extends Wt{constructor(t=0){let e,r,i;if(!ht().useLegacy){let{audioContext:n}=ht().context;n.createStereoPanner?(e=n.createStereoPanner(),i=e):(r=n.createPanner(),r.panningModel="equalpower",i=r)}super(i),this._stereo=e,this._panner=r,this.pan=t}set pan(t){this._pan=t,this._stereo?Dt.setParamValue(this._stereo.pan,t):this._panner&&this._panner.setPosition(t,0,1-Math.abs(t))}get pan(){return this._pan}destroy(){super.destroy(),this._stereo=null,this._panner=null}}});var vu,PM=p(()=>{Me();pr();vu=class extends Wt{constructor(){let t,e;if(!ht().useLegacy){let{audioContext:r}=ht().context;t=r.createMediaStreamDestination(),e=r.createMediaStreamSource(t.stream)}super(t,e),this._stream=t?.stream}get stream(){return this._stream}destroy(){this._stream=null,super.destroy()}}});var Su,MM=p(()=>{Me();ti();pr();Su=class extends Wt{constructor(){let t,e;if(!ht().useLegacy){let{audioContext:r}=ht().context,i=r.createBiquadFilter(),n=r.createBiquadFilter(),o=r.createBiquadFilter(),a=r.createBiquadFilter();i.type="lowpass",Dt.setParamValue(i.frequency,2e3),n.type="lowpass",Dt.setParamValue(n.frequency,2e3),o.type="highpass",Dt.setParamValue(o.frequency,500),a.type="highpass",Dt.setParamValue(a.frequency,500),i.connect(n),n.connect(o),o.connect(a),t=i,e=a}super(t,e)}}});var Bm={};Mr(Bm,{DistortionFilter:()=>_u,EqualizerFilter:()=>ze,Filter:()=>Wt,MonoFilter:()=>xu,ReverbFilter:()=>yu,StereoFilter:()=>bu,StreamFilter:()=>vu,TelephoneFilter:()=>Su});var wM=p(()=>{bM();vM();pr();SM();TM();CM();PM();MM()});var mn,Rm=p(()=>{He();mn=class extends q{constructor(){super(...arguments),this.speed=1,this.muted=!1,this.volume=1,this.paused=!1}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(t){console.warn("HTML Audio does not support filters")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners()}}});var GR,Im,La,Fm=p(()=>{He();GR=0,Im=class extends q{constructor(s){super(),this.id=GR++,this.init(s)}set(s,t){if(this[s]===void 0)throw new Error(`Property with name ${s} does not exist.`);switch(s){case"speed":this.speed=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}get progress(){let{currentTime:s}=this._source;return s/this._duration}get paused(){return this._paused}set paused(s){this._paused=s,this.refreshPaused()}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(s){this._playing=!1,this._duration=s.source.duration;let t=this._source=s.source.cloneNode(!1);t.src=s.parent.url,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),s.context.on("refresh",this.refresh,this),s.context.on("refreshPaused",this.refreshPaused,this),this._media=s}_internalStop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._internalStop(),this._source&&this.emit("stop")}get speed(){return this._speed}set speed(s){this._speed=s,this.refresh()}get volume(){return this._volume}set volume(s){this._volume=s,this.refresh()}get loop(){return this._loop}set loop(s){this._loop=s,this.refresh()}get muted(){return this._muted}set muted(s){this._muted=s,this.refresh()}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(s){console.warn("HTML Audio does not support filters")}refresh(){let s=this._media.context,t=this._media.parent;this._source.loop=this._loop||t.loop;let e=s.volume*(s.muted?0:1),r=t.volume*(t.muted?0:1),i=this._volume*(this._muted?0:1);this._source.volume=i*e*r,this._source.playbackRate=this._speed*s.speed*t.speed}refreshPaused(){let s=this._media.context,t=this._media.parent,e=this._paused||t.paused||s.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,speed:this._speed,loop:this._loop})),this.emit("pause",e))}play(s){let{start:t,end:e,speed:r,loop:i,volume:n,muted:o}=s;e&&console.assert(e>t,"End time is before start time"),this._speed=r,this._volume=n,this._loop=!!i,this._muted=o,this.refresh(),this.loop&&e!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=e||this._duration,this._start=Math.max(0,this._start-Im.PADDING),this._end=Math.min(this._end+Im.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),St.shared.add(this._onUpdate,this))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate(){this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete()}_onComplete(){St.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){St.shared.remove(this._onUpdate,this),this.removeAllListeners();let s=this._source;s&&(s.onended=null,s.onplay=null,s.onpause=null,this._internalStop()),this._source=null,this._speed=1,this._volume=1,this._loop=!1,this._end=null,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._media&&(this._media.context.off("refresh",this.refresh,this),this._media.context.off("refreshPaused",this.refreshPaused,this),this._media=null)}toString(){return`[HTMLAudioInstance id=${this.id}]`}},La=Im;La.PADDING=.1});var gn,km=p(()=>{He();Fm();gn=class extends q{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url)}create(){return new La(this)}get isPlayable(){return!!this._source&&this._source.readyState===4}get duration(){return this._source.duration}get context(){return this.parent.context}get filters(){return null}set filters(t){console.warn("HTML Audio does not support filters")}destroy(){this.removeAllListeners(),this.parent=null,this._source&&(this._source.src="",this._source.load(),this._source=null)}get source(){return this._source}load(t){let e=this._source,r=this.parent;if(e.readyState===4){r.isLoaded=!0;let l=r.autoPlayStart();t&&setTimeout(()=>{t(null,r,l)},0);return}if(!r.url){t(new Error("sound.url or sound.source must be set"));return}e.src=r.url;let i=()=>{a(),r.isLoaded=!0;let l=r.autoPlayStart();t&&t(null,r,l)},n=()=>{a(),t&&t(new Error("Sound loading has been aborted"))},o=()=>{a();let l=`Failed to load audio element (code: ${e.error.code})`;t?t(new Error(l)):console.error(l)},a=()=>{e.removeEventListener("canplaythrough",i),e.removeEventListener("load",i),e.removeEventListener("abort",n),e.removeEventListener("error",o)};e.addEventListener("canplaythrough",i,!1),e.addEventListener("load",i,!1),e.addEventListener("abort",n,!1),e.addEventListener("error",o,!1),e.load()}}});var Lm={};Mr(Lm,{HTMLAudioContext:()=>mn,HTMLAudioInstance:()=>La,HTMLAudioMedia:()=>gn});var EM=p(()=>{Rm();Fm();km()});var _n,Dm=p(()=>{_n=class{constructor(t,e){this.parent=t,Object.assign(this,e),this.duration=this.end-this.start,console.assert(this.duration>0,"End time must be after start time")}play(t){return this.parent.play({complete:t,speed:this.speed||this.parent.speed,end:this.end,start:this.start,loop:this.loop})}destroy(){this.parent=null}}});function Om(s){let t={m4a:"audio/mp4",oga:"audio/ogg",opus:'audio/ogg; codecs="opus"',caf:'audio/x-caf; codecs="opus"',...s||{}},e=document.createElement("audio"),r={},i=/^no$/;as.forEach(n=>{let o=e.canPlayType(`audio/${n}`).replace(i,""),a=t[n]?e.canPlayType(t[n]).replace(i,""):"";r[n]=!!o||!!a}),Object.assign(ls,r)}var as,Tu,ls,Cu=p(()=>{as=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],Tu=["audio/mpeg","audio/ogg"],ls={};Om()});var UR,xn,Gm=p(()=>{He();ti();UR=0,xn=class extends q{constructor(t){super(),this.id=UR++,this._media=null,this._paused=!1,this._muted=!1,this._elapsed=0,this.init(t)}set(t,e){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case"speed":this.speed=e;break;case"volume":this.volume=e;break;case"muted":this.muted=e;break;case"loop":this.loop=e;break;case"paused":this.paused=e;break}return this}stop(){this._source&&(this._internalStop(),this.emit("stop"))}get speed(){return this._speed}set speed(t){this._speed=t,this.refresh(),this._update(!0)}get volume(){return this._volume}set volume(t){this._volume=t,this.refresh()}get muted(){return this._muted}set muted(t){this._muted=t,this.refresh()}get loop(){return this._loop}set loop(t){this._loop=t,this.refresh()}get filters(){return this._filters}set filters(t){this._filters&&(this._filters?.filter(e=>e).forEach(e=>e.disconnect()),this._filters=null,this._source.connect(this._gain)),this._filters=t?.length?t.slice(0):null,this.refresh()}refresh(){if(!this._source)return;let t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;let r=t.volume*(t.muted?0:1),i=e.volume*(e.muted?0:1),n=this._volume*(this._muted?0:1);Dt.setParamValue(this._gain.gain,n*i*r),Dt.setParamValue(this._source.playbackRate,this._speed*e.speed*t.speed),this.applyFilters()}applyFilters(){if(this._filters?.length){this._source.disconnect();let t=this._source;this._filters.forEach(e=>{t.connect(e.destination),t=e}),t.connect(this._gain)}}refreshPaused(){let t=this._media.context,e=this._media.parent,r=this._paused||e.paused||t.paused;r!==this._pausedReal&&(this._pausedReal=r,r?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,speed:this._speed,loop:this._loop,volume:this._volume})),this.emit("pause",r))}play(t){let{start:e,end:r,speed:i,loop:n,volume:o,muted:a,filters:l}=t;r&&console.assert(r>e,"End time is before start time"),this._paused=!1;let{source:h,gain:u}=this._media.nodes.cloneBufferSource();this._source=h,this._gain=u,this._speed=i,this._volume=o,this._loop=!!n,this._muted=a,this._filters=l,this.refresh();let c=this._source.buffer.duration;this._duration=c,this._end=r,this._lastUpdate=this._now(),this._elapsed=e,this._source.onended=this._onComplete.bind(this),this._loop?(this._source.loopEnd=r,this._source.loopStart=e,this._source.start(0,e)):r?this._source.start(0,e,r-e):this._source.start(0,e),this.emit("start"),this._update(!0),this.enableTicker(!0)}enableTicker(t){St.shared.remove(this._updateListener,this),t&&St.shared.add(this._updateListener,this)}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused=t,this.refreshPaused()}destroy(){this.removeAllListeners(),this._internalStop(),this._gain&&(this._gain.disconnect(),this._gain=null),this._media&&(this._media.context.events.off("refresh",this.refresh,this),this._media.context.events.off("refreshPaused",this.refreshPaused,this),this._media=null),this._filters?.forEach(t=>t.disconnect()),this._filters=null,this._end=null,this._speed=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}toString(){return`[WebAudioInstance id=${this.id}]`}_now(){return this._media.context.audioContext.currentTime}_updateListener(){this._update()}_update(t=!1){if(this._source){let e=this._now(),r=e-this._lastUpdate;if(r>0||t){let i=this._source.playbackRate.value;this._elapsed+=r*i,this._lastUpdate=e;let n=this._duration,o;if(this._source.loopStart){let a=this._source.loopEnd-this._source.loopStart;o=(this._source.loopStart+this._elapsed%a)/n}else o=this._elapsed%n/n;this._progress=o,this.emit("progress",this._progress,n)}}}init(t){this._media=t,t.context.events.on("refresh",this.refresh,this),t.context.events.on("refreshPaused",this.refreshPaused,this)}_internalStop(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.stop(0),this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null}}_onComplete(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}}this._source=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)}}});var hs,Pu=p(()=>{hs=class{constructor(t,e){this._output=e,this._input=t}get destination(){return this._input}get filters(){return this._filters}set filters(t){if(this._filters&&(this._filters.forEach(e=>{e&&e.disconnect()}),this._filters=null,this._input.connect(this._output)),t&&t.length){this._filters=t.slice(0),this._input.disconnect();let e=null;t.forEach(r=>{e===null?this._input.connect(r.destination):e.connect(r.destination),e=r}),e.connect(this._output)}}destroy(){this.filters=null,this._input=null,this._output=null}}});var AM,Da,Um=p(()=>{Pu();ti();AM=class extends hs{constructor(s){let t=s.audioContext,e=t.createBufferSource(),r=t.createGain(),i=t.createAnalyser();e.connect(i),i.connect(r),r.connect(s.destination),super(i,r),this.context=s,this.bufferSource=e,this.gain=r,this.analyser=i}get script(){return this._script||(this._script=this.context.audioContext.createScriptProcessor(AM.BUFFER_SIZE),this._script.connect(this.context.destination)),this._script}destroy(){super.destroy(),this.bufferSource.disconnect(),this._script&&this._script.disconnect(),this.gain.disconnect(),this.analyser.disconnect(),this.bufferSource=null,this._script=null,this.gain=null,this.analyser=null,this.context=null}cloneBufferSource(){let s=this.bufferSource,t=this.context.audioContext.createBufferSource();t.buffer=s.buffer,Dt.setParamValue(t.playbackRate,s.playbackRate.value),t.loop=s.loop;let e=this.context.audioContext.createGain();return t.connect(e),e.connect(this.destination),{source:t,gain:e}}get bufferSize(){return this.script.bufferSize}},Da=AM;Da.BUFFER_SIZE=0});var mr,Oa=p(()=>{He();Gm();Um();mr=class{init(t){this.parent=t,this._nodes=new Da(this.context),this._source=this._nodes.bufferSource,this.source=t.options.source}destroy(){this.parent=null,this._nodes.destroy(),this._nodes=null;try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null,this.source=null}create(){return new xn(this)}get context(){return this.parent.context}get isPlayable(){return!!this._source&&!!this._source.buffer}get filters(){return this._nodes.filters}set filters(t){this._nodes.filters=t}get duration(){return console.assert(this.isPlayable,"Sound not yet playable, no duration"),this._source.buffer.duration}get buffer(){return this._source.buffer}set buffer(t){this._source.buffer=t}get nodes(){return this._nodes}load(t){this.source?this._decode(this.source,t):this.parent.url?this._loadUrl(t):t?t(new Error("sound.url or sound.source must be set")):console.error("sound.url or sound.source must be set")}async _loadUrl(t){let e=this.parent.url,r=await D.get().fetch(e);this._decode(await r.arrayBuffer(),t)}_decode(t,e){let r=(i,n)=>{if(i)e&&e(i);else{this.parent.isLoaded=!0,this.buffer=n;let o=this.parent.autoPlayStart();e&&e(null,this.parent,o)}};t instanceof AudioBuffer?r(null,t):this.parent.context.decode(t,r)}}});var yn,gr,Ga=p(()=>{He();km();Me();Dm();Cu();Oa();yn=class{static from(s){let t={};typeof s=="string"?t.url=s:s instanceof ArrayBuffer||s instanceof AudioBuffer||s instanceof HTMLAudioElement?t.source=s:Array.isArray(s)?t.url=s:t=s,t={autoPlay:!1,singleInstance:!1,url:null,source:null,preload:!1,volume:1,speed:1,complete:null,loaded:null,loop:!1,...t},Object.freeze(t);let e=ht().useLegacy?new gn:new mr;return new yn(e,t)}constructor(s,t){this.media=s,this.options=t,this._instances=[],this._sprites={},this.media.init(this);let e=t.complete;this._autoPlayOptions=e?{complete:e}:null,this.isLoaded=!1,this._preloadQueue=null,this.isPlaying=!1,this.autoPlay=t.autoPlay,this.singleInstance=t.singleInstance,this.preload=t.preload||this.autoPlay,this.url=Array.isArray(t.url)?this.preferUrl(t.url):t.url,this.speed=t.speed,this.volume=t.volume,this.loop=t.loop,t.sprites&&this.addSprites(t.sprites),this.preload&&this._preload(t.loaded)}preferUrl(s){let[t]=s.map(e=>({url:e,ext:wt.extname(e).slice(1)})).filter(({ext:e})=>ls[e]).sort((e,r)=>as.indexOf(e.ext)-as.indexOf(r.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return ht().context}pause(){return this.isPlaying=!1,this.paused=!0,this}resume(){return this.isPlaying=this._instances.length>0,this.paused=!1,this}get paused(){return this._paused}set paused(s){this._paused=s,this.refreshPaused()}get speed(){return this._speed}set speed(s){this._speed=s,this.refresh()}get filters(){return this.media.filters}set filters(s){this.media.filters=s}addSprites(s,t){if(typeof s=="object"){let r={};for(let i in s)r[i]=this.addSprites(i,s[i]);return r}console.assert(!this._sprites[s],`Alias ${s} is already taken`);let e=new _n(this,t);return this._sprites[s]=e,e}destroy(){this._removeInstances(),this.removeSprites(),this.media.destroy(),this.media=null,this._sprites=null,this._instances=null}removeSprites(s){if(s){let t=this._sprites[s];t!==void 0&&(t.destroy(),delete this._sprites[s])}else for(let t in this._sprites)this.removeSprites(t);return this}get isPlayable(){return this.isLoaded&&this.media&&this.media.isPlayable}stop(){if(!this.isPlayable)return this.autoPlay=!1,this._autoPlayOptions=null,this;this.isPlaying=!1;for(let s=this._instances.length-1;s>=0;s--)this._instances[s].stop();return this}play(s,t){let e;if(typeof s=="string"?e={sprite:s,loop:this.loop,complete:t}:typeof s=="function"?(e={},e.complete=s):e=s,e={complete:null,loaded:null,sprite:null,end:null,start:0,volume:1,speed:1,muted:!1,loop:!1,...e||{}},e.sprite){let i=e.sprite;console.assert(!!this._sprites[i],`Alias ${i} is not available`);let n=this._sprites[i];e.start=n.start+(e.start||0),e.end=n.end,e.speed=n.speed||1,e.loop=n.loop||e.loop,delete e.sprite}if(e.offset&&(e.start=e.offset),!this.isLoaded)return this._preloadQueue?new Promise(i=>{this._preloadQueue.push(()=>{i(this.play(e))})}):(this._preloadQueue=[],this.autoPlay=!0,this._autoPlayOptions=e,new Promise((i,n)=>{this._preload((o,a,l)=>{this._preloadQueue.forEach(h=>h()),this._preloadQueue=null,o?n(o):(e.loaded&&e.loaded(o,a,l),i(l))})}));(this.singleInstance||e.singleInstance)&&this._removeInstances();let r=this._createInstance();return this._instances.push(r),this.isPlaying=!0,r.once("end",()=>{e.complete&&e.complete(this),this._onComplete(r)}),r.once("stop",()=>{this._onComplete(r)}),r.play(e),r}refresh(){let s=this._instances.length;for(let t=0;t<s;t++)this._instances[t].refresh()}refreshPaused(){let s=this._instances.length;for(let t=0;t<s;t++)this._instances[t].refreshPaused()}get volume(){return this._volume}set volume(s){this._volume=s,this.refresh()}get muted(){return this._muted}set muted(s){this._muted=s,this.refresh()}get loop(){return this._loop}set loop(s){this._loop=s,this.refresh()}_preload(s){this.media.load(s)}get instances(){return this._instances}get sprites(){return this._sprites}get duration(){return this.media.duration}autoPlayStart(){let s;return this.autoPlay&&(s=this.play(this._autoPlayOptions)),s}_removeInstances(){for(let s=this._instances.length-1;s>=0;s--)this._poolInstance(this._instances[s]);this._instances.length=0}_onComplete(s){if(this._instances){let t=this._instances.indexOf(s);t>-1&&this._instances.splice(t,1),this.isPlaying=this._instances.length>0}this._poolInstance(s)}_createInstance(){if(yn._pool.length>0){let s=yn._pool.pop();return s.init(this.media),s}return this.media.create()}_poolInstance(s){s.destroy(),yn._pool.indexOf(s)<0&&yn._pool.push(s)}},gr=yn;gr._pool=[]});var ei,Vm=p(()=>{He();Pu();ei=class s extends hs{constructor(){let t=window,e=new s.AudioContext,r=e.createDynamicsCompressor(),i=e.createAnalyser();i.connect(r),r.connect(e.destination),super(i,r),this.autoPause=!0,this._ctx=e,this._offlineCtx=new s.OfflineAudioContext(1,2,t.OfflineAudioContext?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),this.compressor=r,this.analyser=i,this.events=new q,this.volume=1,this.speed=1,this.muted=!1,this.paused=!1,this._locked=e.state==="suspended"&&("ontouchstart"in globalThis||"onclick"in globalThis),this._locked&&(this._unlock(),this._unlock=this._unlock.bind(this),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),globalThis.addEventListener("focus",this.onFocus),globalThis.addEventListener("blur",this.onBlur)}onFocus(){if(!this.autoPause)return;let t=this._ctx.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock(){this._locked&&(this.playEmptySound(),this._ctx.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))}playEmptySound(){let t=this._ctx.createBufferSource();t.buffer=this._ctx.createBuffer(1,1,22050),t.connect(this._ctx.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume()}static get AudioContext(){let t=window;return t.AudioContext||t.webkitAudioContext||null}static get OfflineAudioContext(){let t=window;return t.OfflineAudioContext||t.webkitOfflineAudioContext||null}destroy(){super.destroy();let t=this._ctx;typeof t.close<"u"&&t.close(),globalThis.removeEventListener("focus",this.onFocus),globalThis.removeEventListener("blur",this.onBlur),this.events.removeAllListeners(),this.analyser.disconnect(),this.compressor.disconnect(),this.analyser=null,this.compressor=null,this.events=null,this._offlineCtx=null,this._ctx=null}get audioContext(){return this._ctx}get offlineContext(){return this._offlineCtx}set paused(t){t&&this._ctx.state==="running"?this._ctx.suspend():!t&&this._ctx.state==="suspended"&&this._ctx.resume(),this._paused=t}get paused(){return this._paused}refresh(){this.events.emit("refresh")}refreshPaused(){this.events.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t,e){let r=n=>{e(new Error(n?.message||"Unable to decode file"))},i=this._offlineCtx.decodeAudioData(t,n=>{e(null,n)},r);i&&i.catch(r)}}});var Ua,BM=p(()=>{Rm();Ga();Vm();Ua=class{constructor(){this.init()}init(){return this.supported&&(this._webAudioContext=new ei),this._htmlAudioContext=new mn,this._sounds={},this.useLegacy=!this.supported,this}get context(){return this._context}get filtersAll(){return this.useLegacy?[]:this._context.filters}set filtersAll(t){this.useLegacy||(this._context.filters=t)}get supported(){return ei.AudioContext!==null}add(t,e){if(typeof t=="object"){let n={};for(let o in t){let a=this._getOptions(t[o],e);n[o]=this.add(o,a)}return n}if(console.assert(!this._sounds[t],`Sound with alias ${t} already exists.`),e instanceof gr)return this._sounds[t]=e,e;let r=this._getOptions(e),i=gr.from(r);return this._sounds[t]=i,i}_getOptions(t,e){let r;return typeof t=="string"?r={url:t}:Array.isArray(t)?r={url:t}:t instanceof ArrayBuffer||t instanceof AudioBuffer||t instanceof HTMLAudioElement?r={source:t}:r=t,r={...r,...e||{}},r}get useLegacy(){return this._useLegacy}set useLegacy(t){this._useLegacy=t,this._context=!t&&this.supported?this._webAudioContext:this._htmlAudioContext}get disableAutoPause(){return!this._webAudioContext.autoPause}set disableAutoPause(t){this._webAudioContext.autoPause=!t}remove(t){return this.exists(t,!0),this._sounds[t].destroy(),delete this._sounds[t],this}get volumeAll(){return this._context.volume}set volumeAll(t){this._context.volume=t,this._context.refresh()}get speedAll(){return this._context.speed}set speedAll(t){this._context.speed=t,this._context.refresh()}togglePauseAll(){return this._context.togglePause()}pauseAll(){return this._context.paused=!0,this._context.refreshPaused(),this}resumeAll(){return this._context.paused=!1,this._context.refreshPaused(),this}toggleMuteAll(){return this._context.toggleMute()}muteAll(){return this._context.muted=!0,this._context.refresh(),this}unmuteAll(){return this._context.muted=!1,this._context.refresh(),this}removeAll(){for(let t in this._sounds)this._sounds[t].destroy(),delete this._sounds[t];return this}stopAll(){for(let t in this._sounds)this._sounds[t].stop();return this}exists(t,e=!1){let r=!!this._sounds[t];return e&&console.assert(r,`No sound matching alias '${t}'.`),r}isPlaying(){for(let t in this._sounds)if(this._sounds[t].isPlaying)return!0;return!1}find(t){return this.exists(t,!0),this._sounds[t]}play(t,e){return this.find(t).play(e)}stop(t){return this.find(t).stop()}pause(t){return this.find(t).pause()}resume(t){return this.find(t).resume()}volume(t,e){let r=this.find(t);return e!==void 0&&(r.volume=e),r.volume}speed(t,e){let r=this.find(t);return e!==void 0&&(r.speed=e),r.speed}duration(t){return this.find(t).duration}close(){return this.removeAll(),this._sounds=null,this._webAudioContext&&(this._webAudioContext.destroy(),this._webAudioContext=null),this._htmlAudioContext&&(this._htmlAudioContext.destroy(),this._htmlAudioContext=null),this._context=null,this}}});function RM(s,t){let e=`alias${Nm++}`;return ht().add(e,{url:s,preload:!0,autoPlay:!0,loaded:r=>{r&&(console.error(r),ht().remove(e),t&&t(r))},complete:()=>{ht().remove(e),t&&t(null)}}),e}var Nm,IM=p(()=>{Me();Nm=0});function FM(s,t){let e=document.createElement("canvas");t={width:512,height:128,fill:"black",...t||{}},e.width=t.width,e.height=t.height;let r=new It({resource:e});if(!(s.media instanceof mr))return r;let i=s.media;console.assert(!!i.buffer,"No buffer found, load first");let n=e.getContext("2d");n.fillStyle=t.fill;let o=i.buffer.getChannelData(0),a=Math.ceil(o.length/t.width),l=t.height/2;for(let h=0;h<t.width;h++){let u=1,c=-1;for(let f=0;f<a;f++){let d=o[h*a+f];d<u&&(u=d),d>c&&(c=d)}n.fillRect(h,(1+u)*l,1,Math.max(1,(c-u)*l))}return r}var kM=p(()=>{He();Oa()});function LM(s=200,t=1){let e=gr.from({singleInstance:!0});if(!(e.media instanceof mr))return e;let r=e.media,i=e.context,n=1,o=48e3,a=2,l=i.audioContext.createBuffer(n,t*o,o),h=l.getChannelData(0);for(let u=0;u<h.length;u++){let c=u/l.sampleRate,f=s*c*2*Math.PI;h[u]=Math.sin(f)*a}return r.buffer=l,e.isLoaded=!0,e}var DM=p(()=>{Ga();Oa()});var Hm={};Mr(Hm,{PLAY_ID:()=>Nm,extensions:()=>as,mimes:()=>Tu,playOnce:()=>RM,render:()=>FM,sineTone:()=>LM,supported:()=>ls,validateFormats:()=>Om});var OM=p(()=>{IM();kM();DM();Cu()});var zm={};Mr(zm,{WebAudioContext:()=>ei,WebAudioInstance:()=>xn,WebAudioMedia:()=>mr,WebAudioNodes:()=>Da,WebAudioUtils:()=>Dt});var GM=p(()=>{Vm();Gm();Oa();Um();ti()});var UM,Wm,VM=p(()=>{He();Me();Ga();Cu();UM=s=>{let t=s.src,e=s?.alias?.[0];return(!e||s.src===e)&&(e=wt.basename(t,wt.extname(t))),e},Wm={extension:y.Asset,detection:{test:async()=>!0,add:async s=>[...s,...as.filter(t=>ls[t])],remove:async s=>s.filter(t=>s.includes(t))},loader:{name:"sound",extension:{type:[y.LoadParser],priority:$t.High},test(s){let t=wt.extname(s).slice(1);return!!ls[t]||Tu.some(e=>s.startsWith(`data:${e}`))},async load(s,t){let e=await new Promise((r,i)=>gr.from({...t.data,url:s,preload:!0,loaded(n,o){n?i(n):r(o),t.data?.loaded?.(n,o)}}));return ht().add(UM(t),e),e},async unload(s,t){ht().remove(UM(t))}}};U.add(Wm)});var NM={};Mr(NM,{Filter:()=>Wt,Filterable:()=>hs,Sound:()=>gr,SoundLibrary:()=>Ua,SoundSprite:()=>_n,filters:()=>Bm,htmlaudio:()=>Lm,sound:()=>VR,soundAsset:()=>Wm,utils:()=>Hm,webaudio:()=>zm});var VR,HM=p(()=>{wM();EM();Me();BM();OM();GM();Pu();pr();Ga();VM();Dm();VR=yM(new Ua)});He();He();var NR=Object.defineProperty,HR=Object.defineProperties,zR=Object.getOwnPropertyDescriptors,zM=Object.getOwnPropertySymbols,WR=Object.prototype.hasOwnProperty,XR=Object.prototype.propertyIsEnumerable,yr=Math.pow,tg=(s,t,e)=>t in s?NR(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Mc=(s,t)=>{for(var e in t||(t={}))WR.call(t,e)&&tg(s,e,t[e]);if(zM)for(var e of zM(t))XR.call(t,e)&&tg(s,e,t[e]);return s},jR=(s,t)=>HR(s,zR(t)),M=(s,t,e)=>tg(s,typeof t!="symbol"?t+"":t,e),vt=(s,t,e)=>new Promise((r,i)=>{var n=l=>{try{a(e.next(l))}catch(h){i(h)}},o=l=>{try{a(e.throw(l))}catch(h){i(h)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(n,o);a((e=e.apply(s,t)).next())}),nE=class eg{constructor(t=0){t<1?(this._ptr=[],this._capacity=0,this._size=0):(this._ptr=new Array(t),this._capacity=t,this._size=0)}at(t){return this._ptr[t]}set(t,e){this._ptr[t]=e}get(t=0){let e=new Array;for(let r=t;r<this._size;r++)e.push(this._ptr[r]);return e}pushBack(t){this._size>=this._capacity&&this.prepareCapacity(this._capacity==0?eg.DefaultSize:this._capacity*2),this._ptr[this._size++]=t}clear(){this._ptr.length=0,this._size=0}getSize(){return this._size}assign(t,e){this._size<t&&this.prepareCapacity(t);for(let i=0;i<t;i++)this._ptr[i]=e;this._size=t}resize(t,e=null){this.updateSize(t,e,!0)}updateSize(t,e=null,r=!0){if(this._size<t)if(this.prepareCapacity(t),r)for(let n=this._size;n<t;n++)typeof e=="function"?this._ptr[n]=JSON.parse(JSON.stringify(new e)):this._ptr[n]=e;else for(let n=this._size;n<t;n++)this._ptr[n]=e;else{let n=this._size-t;this._ptr.splice(this._size-n,n)}this._size=t}insert(t,e,r){let i=t._index,n=e._index,o=r._index,a=o-n;this.prepareCapacity(this._size+a);let l=this._size-i;if(l>0)for(let h=0;h<l;h++)this._ptr.splice(i+h,0,null);for(let h=n;h<o;h++,i++)this._ptr[i]=e._vector._ptr[h];this._size=this._size+a}remove(t){return t<0||this._size<=t?!1:(this._ptr.splice(t,1),--this._size,!0)}erase(t){let e=t._index;return e<0||this._size<=e?t:(this._ptr.splice(e,1),--this._size,new Du(this,e))}prepareCapacity(t){t>this._capacity&&(this._capacity==0?(this._ptr=new Array(t),this._capacity=t):(this._ptr.length=t,this._capacity=t))}begin(){return this._size==0?this.end():new Du(this,0)}end(){return new Du(this,this._size)}getOffset(t){let e=new eg;return e._ptr=this.get(t),e._size=this.get(t).length,e._capacity=this.get(t).length,e}};nE.DefaultSize=10;var X=nE,Du=class rg{constructor(t,e){this._vector=t??null,this._index=e??0}set(t){return this._index=t._index,this._vector=t._vector,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new rg(this._vector,this._index++)}decrement(){return new rg(this._vector,this._index--)}ptr(){return this._vector._ptr[this._index]}substitution(t){return this._index=t._index,this._vector=t._vector,this}notEqual(t){return this._index!=t._index||this._vector!=t._vector}},WM;(s=>{s.csmVector=X,s.iterator=Du})(WM||(WM={}));var Be=class{append(t,e){return this.s+=e!==void 0?t.substr(0,e):t,this}expansion(t,e){for(let r=0;r<t;r++)this.append(e);return this}getBytes(){return encodeURIComponent(this.s).replace(/%../g,"x").length}getLength(){return this.s.length}isLess(t){return this.s<t.s}isGreat(t){return this.s>t.s}isEqual(t){return this.s==t}isEmpty(){return this.s.length==0}constructor(t){this.s=t}},XM;(s=>{s.csmString=Be})(XM||(XM={}));var Vu=class s{static createIdInternal(t){return new s(t)}getString(){return this._id}isEqual(t){return typeof t=="string"?this._id.isEqual(t):t instanceof Be?this._id.isEqual(t.s):t instanceof s?this._id.isEqual(t._id.s):!1}isNotEqual(t){return typeof t=="string"?!this._id.isEqual(t):t instanceof Be?!this._id.isEqual(t.s):t instanceof s?!this._id.isEqual(t._id.s):!1}constructor(t){if(typeof t=="string"){this._id=new Be(t);return}this._id=t}},jM;(s=>{s.CubismId=Vu})(jM||(jM={}));var Nu=class{constructor(){this._ids=new X}release(){for(let t=0;t<this._ids.getSize();++t)this._ids.set(t,void 0);this._ids=null}registerIds(t){for(let e=0;e<t.length;e++)this.registerId(t[e])}registerId(t){let e=null;if(typeof t=="string"){if((e=this.findId(t))!=null)return e;e=Vu.createIdInternal(t),this._ids.pushBack(e)}else return this.registerId(t.s);return e}getId(t){return this.registerId(t)}isExist(t){return typeof t=="string"?this.findId(t)!=null:this.isExist(t.s)}findId(t){for(let e=0;e<this._ids.getSize();++e)if(this._ids.at(e).getString().isEqual(t))return this._ids.at(e);return null}},YM;(s=>{s.CubismIdManager=Nu})(YM||(YM={}));var vr=class s{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,r){let i=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),n=4;for(let o=0;o<n;++o)for(let a=0;a<n;++a)for(let l=0;l<n;++l)i[a+o*4]+=t[l+o*4]*e[a+l*4];for(let o=0;o<16;++o)r[o]=i[o]}loadIdentity(){let t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){let r=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);s.multiply(r,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){let r=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);s.multiply(r,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){s.multiply(t.getArray(),this._tr,this._tr)}clone(){let t=new s;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}},$M;(s=>{s.CubismMatrix44=vr})($M||($M={}));var wn=class{constructor(t,e,r,i){this.x=t,this.y=e,this.width=r,this.height=i}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,e){this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2}},qM;(s=>{s.csmRect=wn})(qM||(qM={}));var En=class{static create(){return null}static delete(t){}initialize(t){this._model=t}drawModel(){this.getModel()!=null&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,r,i){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),r<0?r=0:r>1&&(r=1),i<0?i=0:i>1&&(i=1),this._modelColor.r=t,this._modelColor.g=e,this._modelColor.b=r,this._modelColor.a=i}getModelColor(){return JSON.parse(JSON.stringify(this._modelColor))}getModelColorWithOpacity(t){let e=this.getModelColor();return e.a*=t,this.isPremultipliedAlpha()&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._model=null,this._modelColor=new le,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new vr,this._mvpMatrix4x4.loadIdentity()}},ms=(s=>(s[s.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",s[s.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",s[s.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",s))(ms||{}),le=class{constructor(t=1,e=1,r=1,i=1){this.r=t,this.g=e,this.b=r,this.a=i}},sg=class{constructor(t,e){this._clippingIdList=t,this._clippingIdCount=e,this._allClippedDrawRect=new wn,this._layoutBounds=new wn,this._clippedDrawableIndexList=[],this._matrixForMask=new vr,this._matrixForDraw=new vr,this._bufferIndex=0}release(){this._layoutBounds!=null&&(this._layoutBounds=null),this._allClippedDrawRect!=null&&(this._allClippedDrawRect=null),this._clippedDrawableIndexList!=null&&(this._clippedDrawableIndexList=null)}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}},KM;(s=>{s.CubismBlendMode=ms,s.CubismRenderer=En,s.CubismTextureColor=le})(KM||(KM={}));var oE=0,YR=1,$R=2,qR=3,KR=4,ZR=5,JR=oE,QR=Object.freeze(Object.defineProperty({__proto__:null,CSM_LOG_LEVEL:JR,CSM_LOG_LEVEL_DEBUG:YR,CSM_LOG_LEVEL_ERROR:KR,CSM_LOG_LEVEL_INFO:$R,CSM_LOG_LEVEL_OFF:ZR,CSM_LOG_LEVEL_VERBOSE:oE,CSM_LOG_LEVEL_WARNING:qR},Symbol.toStringTag,{value:"Module"})),tI=(s,t,e)=>{ja.print(s,"[CSM]"+t,e)},Mu=(s,t,e)=>{tI(s,t+`
956
+ `,e)},ye=s=>{console.assert(s)},Xa,ii,dt,be;Xa=(s,...t)=>{Mu(ni.LogLevel_Debug,"[D]"+s,t)},ii=(s,...t)=>{Mu(ni.LogLevel_Info,"[I]"+s,t)},dt=(s,...t)=>{Mu(ni.LogLevel_Warning,"[W]"+s,t)},be=(s,...t)=>{Mu(ni.LogLevel_Error,"[E]"+s,t)};var ja=class{static print(t,e,r){if(t<bt.getLoggingLevel())return;let i=bt.coreLogFunction;if(!i)return;let n=e.replace(/\{(\d+)\}/g,(o,a)=>r[a]);i(n)}static dumpBytes(t,e,r){for(let i=0;i<r;i++)i%16==0&&i>0?this.print(t,`
957
+ `):i%8==0&&i>0&&this.print(t," "),this.print(t,"{0} ",[e[i]&255]);this.print(t,`
958
+ `)}constructor(){}},ZM;(s=>{s.CubismDebug=ja})(ZM||(ZM={}));var Hu=class{constructor(t,e){this.first=t??null,this.second=e??null}},aE=class ig{constructor(t){t!=null?t<1?(this._keyValues=[],this._dummyValue=null,this._size=0):(this._keyValues=new Array(t),this._size=t):(this._keyValues=[],this._dummyValue=null,this._size=0)}release(){this.clear()}appendKey(t){let e=-1;for(let r=0;r<this._size;r++)if(this._keyValues[r].first==t){e=r;break}if(e!=-1){dt("The key `{0}` is already append.",t);return}this.prepareCapacity(this._size+1,!1),this._keyValues[this._size]=new Hu(t),this._size+=1}getValue(t){let e=-1;for(let r=0;r<this._size;r++)if(this._keyValues[r].first==t){e=r;break}return e>=0?this._keyValues[e].second:(this.appendKey(t),this._keyValues[this._size-1].second)}setValue(t,e){let r=-1;for(let i=0;i<this._size;i++)if(this._keyValues[i].first==t){r=i;break}r>=0?this._keyValues[r].second=e:(this.appendKey(t),this._keyValues[this._size-1].second=e)}isExist(t){for(let e=0;e<this._size;e++)if(this._keyValues[e].first==t)return!0;return!1}clear(){this._keyValues=void 0,this._keyValues=null,this._keyValues=[],this._size=0}getSize(){return this._size}prepareCapacity(t,e){t>this._keyValues.length&&(this._keyValues.length==0?(!e&&t<ig.DefaultSize&&(t=ig.DefaultSize),this._keyValues.length=t):(!e&&t<this._keyValues.length*2&&(t=this._keyValues.length*2),this._keyValues.length=t))}begin(){return new Cn(this,0)}end(){return new Cn(this,this._size)}erase(t){let e=t._index;return e<0||this._size<=e?t:(this._keyValues.splice(e,1),--this._size,new Cn(this,e))}dumpAsInt(){for(let t=0;t<this._size;t++)Xa("{0} ,",this._keyValues[t]),Xa(`
959
+ `)}};aE.DefaultSize=10;var Xr=aE,Cn=class s{constructor(t,e){this._map=t??new Xr,this._index=e??0}set(t){return this._index=t._index,this._map=t._map,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new s(this._map,this._index++)}decrement(){let t=new s(this._map,this._index);return this._map=t._map,this._index=t._index,this}ptr(){return this._map._keyValues[this._index]}notEqual(t){return this._index!=t._index||this._map!=t._map}},JM;(s=>{s.csmMap=Xr,s.csmPair=Hu,s.iterator=Cn})(JM||(JM={}));var ng=class s{static parseJsonObject(t,e){return Object.keys(t).forEach(r=>{if(typeof t[r]=="boolean"){let i=!!t[r];e.put(r,new Ee(i))}else if(typeof t[r]=="string"){let i=String(t[r]);e.put(r,new xs(i))}else if(typeof t[r]=="number"){let i=Number(t[r]);e.put(r,new An(i))}else t[r]instanceof Array?e.put(r,s.parseJsonArray(t[r])):t[r]instanceof Object?e.put(r,s.parseJsonObject(t[r],new _s)):t[r]==null?e.put(r,new gs):e.put(r,t[r])}),e}static parseJsonArray(t){let e=new Ya;return Object.keys(t).forEach(r=>{if(typeof Number(r)=="number")if(typeof t[r]=="boolean"){let n=!!t[r];e.add(new Ee(n))}else if(typeof t[r]=="string"){let n=String(t[r]);e.add(new xs(n))}else if(typeof t[r]=="number"){let n=Number(t[r]);e.add(new An(n))}else t[r]instanceof Array?e.add(this.parseJsonArray(t[r])):t[r]instanceof Object?e.add(this.parseJsonObject(t[r],new _s)):t[r]==null?e.add(new gs):e.add(t[r]);else if(t[r]instanceof Array)e.add(this.parseJsonArray(t[r]));else if(t[r]instanceof Object)e.add(this.parseJsonObject(t[r],new _s));else if(t[r]==null)e.add(new gs);else{let n=Array(t[r]);for(let o=0;o<n.length;o++)e.add(n[o])}}),e}},zu="Error: type mismatch",eI="Error: index out of bounds",he=class _r{constructor(){}getRawString(t,e){return this.getString(t,e)}toInt(t=0){return t}toFloat(t=0){return t}toBoolean(t=!1){return t}getSize(){return 0}getArray(t=null){return t}getVector(t=new X){return t}getMap(t){return t}getValueByIndex(t){return _r.errorValue.setErrorNotForClientCall(zu)}getValueByString(t){return _r.nullValue.setErrorNotForClientCall(zu)}getKeys(){return _r.dummyKeys}isError(){return!1}isNull(){return!1}isBool(){return!1}isFloat(){return!1}isString(){return!1}isArray(){return!1}isMap(){return!1}equals(t){return!1}isStatic(){return!1}setErrorNotForClientCall(t){return ai.errorValue}static staticInitializeNotForClientCall(){Ee.trueValue=new Ee(!0),Ee.falseValue=new Ee(!1),_r.errorValue=new ai("ERROR",!0),_r.nullValue=new gs,_r.dummyKeys=new X}static staticReleaseNotForClientCall(){Ee.trueValue=null,Ee.falseValue=null,_r.errorValue=null,_r.nullValue=null,_r.dummyKeys=null}},Ie=class s{constructor(t,e){this._parseCallback=ng.parseJsonObject,this._error=null,this._lineCount=0,this._root=null,t!=null&&this.parseBytes(t,e,this._parseCallback)}static create(t,e){let r=new s;return r.parseBytes(t,e,r._parseCallback)?r:(s.delete(r),null)}static delete(t){}getRoot(){return this._root}static arrayBufferToString(t){let e=new Uint8Array(t),r="";for(let i=0,n=e.length;i<n;++i)r+="%"+this.pad(e[i].toString(16));return r=decodeURIComponent(r),r}static pad(t){return t.length<2?"0"+t:t}parseBytes(t,e,r){let i=new Array(1),n=s.arrayBufferToString(t);if(r==null?this._root=this.parseValue(n,e,0,i):this._root=r(JSON.parse(n),new _s),this._error){let o="\0";return o="Json parse error : @line "+(this._lineCount+1)+`
960
+ `,this._root=new xs(o),ii("{0}",this._root.getRawString()),!1}else if(this._root==null)return this._root=new ai(new Be(this._error),!1),!1;return!0}getParseError(){return this._error}checkEndOfFile(){return this._root.getArray()[1].equals("EOF")}parseValue(t,e,r,i){if(this._error)return null;let n=null,o=r,a;for(;o<e;o++)switch(t[o]){case"-":case".":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{let h=new Array(1);return a=rI(t.slice(o),h),i[0]=t.indexOf(h[0]),new An(a)}case'"':return new xs(this.parseString(t,e,o+1,i));case"[":return n=this.parseArray(t,e,o+1,i),n;case"{":return n=this.parseObject(t,e,o+1,i),n;case"n":return o+3<e?(n=new gs,i[0]=o+4):this._error="parse null",n;case"t":return o+3<e?(n=Ee.trueValue,i[0]=o+4):this._error="parse true",n;case"f":return o+4<e?(n=Ee.falseValue,i[0]=o+5):this._error="illegal ',' position",n;case",":return this._error="illegal ',' position",null;case"]":return i[0]=o,null;case`
961
+ `:this._lineCount++}return this._error="illegal end of value",null}parseString(t,e,r,i){if(this._error)return null;if(!t)return this._error="string is null",null;let n=r,o,a,l=new Be(""),h=r;for(;n<e;n++)switch(o=t[n],o){case'"':return i[0]=n+1,l.append(t.slice(h),n-h),l.s;case"//":if(n++,n-1>h&&l.append(t.slice(h),n-h),h=n+1,n<e)switch(a=t[n],a){case"\\":l.expansion(1,"\\");break;case'"':l.expansion(1,'"');break;case"/":l.expansion(1,"/");break;case"b":l.expansion(1,"\b");break;case"f":l.expansion(1,"\f");break;case"n":l.expansion(1,`
962
+ `);break;case"r":l.expansion(1,"\r");break;case"t":l.expansion(1," ");break;case"u":this._error="parse string/unicord escape not supported";break}else this._error="parse string/escape error"}return this._error="parse string/illegal end",null}parseObject(t,e,r,i){if(this._error)return null;if(!t)return this._error="buffer is null",null;let n=new _s,o="",a=r,l="",h=Array(1),u=!1;for(;a<e;a++){t:for(;a<e;a++)switch(l=t[a],l){case'"':if(o=this.parseString(t,e,a+1,h),this._error)return null;a=h[0],u=!0;break t;case"}":return i[0]=a+1,n;case":":this._error="illegal ':' position";break;case`
963
+ `:this._lineCount++}if(!u)return this._error="key not found",null;u=!1;t:for(;a<e;a++)switch(l=t[a],l){case":":u=!0,a++;break t;case"}":this._error="illegal '}' position";break;case`
964
+ `:this._lineCount++}if(!u)return this._error="':' not found",null;let c=this.parseValue(t,e,a,h);if(this._error)return null;a=h[0],n.put(o,c);t:for(;a<e;a++)switch(l=t[a],l){case",":break t;case"}":return i[0]=a+1,n;case`
965
+ `:this._lineCount++}}return this._error="illegal end of perseObject",null}parseArray(t,e,r,i){if(this._error)return null;if(!t)return this._error="buffer is null",null;let n=new Ya,o=r,a,l=new Array(1);for(;o<e;o++){let h=this.parseValue(t,e,o,l);if(this._error)return null;o=l[0],h&&n.add(h);t:for(;o<e;o++)switch(a=t[o],a){case",":break t;case"]":return i[0]=o+1,n;case`
966
+ `:++this._lineCount}}return n=void 0,this._error="illegal end of parseObject",null}},An=class extends he{constructor(t){super(),this._value=t}isFloat(){return!0}getString(t,e){return this._value=parseFloat("\0"),this._stringBuffer="\0",this._stringBuffer}toInt(t=0){return parseInt(this._value.toString())}toFloat(t=0){return this._value}equals(t){return typeof t=="number"?Math.round(t)?!1:t==this._value:!1}},Ee=class extends he{isBool(){return!0}toBoolean(t=!1){return this._boolValue}getString(t,e){return this._stringBuffer=this._boolValue?"true":"false",this._stringBuffer}equals(t){return typeof t=="boolean"?t==this._boolValue:!1}isStatic(){return!0}constructor(t){super(),this._boolValue=t}},xs=class extends he{constructor(t){super(),typeof t=="string"&&(this._stringBuffer=t),t instanceof Be&&(this._stringBuffer=t.s)}isString(){return!0}getString(t,e){return this._stringBuffer}equals(t){return typeof t=="string"?this._stringBuffer==t:t instanceof Be?this._stringBuffer==t.s:!1}},ai=class extends xs{isStatic(){return this._isStatic}setErrorNotForClientCall(t){return this._stringBuffer=t,this}constructor(t,e){typeof t=="string"?super(t):super(t),this._isStatic=e}isError(){return!0}},gs=class extends he{isNull(){return!0}getString(t,e){return this._stringBuffer}isStatic(){return!0}setErrorNotForClientCall(t){return this._stringBuffer=t,ai.nullValue}constructor(){super(),this._stringBuffer="NullValue"}},Ya=class extends he{constructor(){super(),this._array=new X}release(){for(let t=this._array.begin();t.notEqual(this._array.end());t.preIncrement()){let e=t.ptr();e&&!e.isStatic()&&(e=void 0,e=null)}}isArray(){return!0}getValueByIndex(t){if(t<0||this._array.getSize()<=t)return he.errorValue.setErrorNotForClientCall(eI);let e=this._array.at(t);return e??he.nullValue}getValueByString(t){return he.errorValue.setErrorNotForClientCall(zu)}getString(t,e){let r=e+`[
967
+ `;for(let i=this._array.begin();i.notEqual(this._array.end());i.increment()){let n=i.ptr();this._stringBuffer+=e+""+n.getString(e+" ")+`
968
+ `}return this._stringBuffer=r+e+`]
969
+ `,this._stringBuffer}add(t){this._array.pushBack(t)}getVector(t=null){return this._array}getSize(){return this._array.getSize()}},_s=class extends he{constructor(){super(),this._map=new Xr}release(){let t=this._map.begin();for(;t.notEqual(this._map.end());){let e=t.ptr().second;e&&!e.isStatic()&&(e=void 0,e=null),t.preIncrement()}}isMap(){return!0}getValueByString(t){if(t instanceof Be){let e=this._map.getValue(t.s);return e??he.nullValue}for(let e=this._map.begin();e.notEqual(this._map.end());e.preIncrement())if(e.ptr().first==t)return e.ptr().second==null?he.nullValue:e.ptr().second;return he.nullValue}getValueByIndex(t){return he.errorValue.setErrorNotForClientCall(zu)}getString(t,e){this._stringBuffer=e+`{
970
+ `;let r=this._map.begin();for(;r.notEqual(this._map.end());){let i=r.ptr().first,n=r.ptr().second;this._stringBuffer+=e+" "+i+" : "+n.getString(e+" ")+`
971
+ `,r.preIncrement()}return this._stringBuffer+=e+`}
972
+ `,this._stringBuffer}getMap(t){return this._map}put(t,e){this._map.setValue(t,e)}getKeys(){if(!this._keys){this._keys=new X;let t=this._map.begin();for(;t.notEqual(this._map.end());){let e=t.ptr().first;this._keys.pushBack(e),t.preIncrement()}}return this._keys}getSize(){return this._keys.getSize()}},QM;(s=>{s.CubismJson=Ie,s.JsonArray=Ya,s.JsonBoolean=Ee,s.JsonError=ai,s.JsonFloat=An,s.JsonMap=_s,s.JsonNullvalue=gs,s.JsonString=xs,s.Value=he})(QM||(QM={}));function rI(s,t){let e=0;for(let i=1;;i++){let n=s.slice(i-1,i);if(n=="e"||n=="-"||n=="E")continue;let o=s.substring(0,i),a=Number(o);if(isNaN(a))break;e=i}let r=parseFloat(s);return isNaN(r)&&(r=NaN),t[0]=s.slice(e),r}var rr=!1,bn=!1,vn=null,Va=null,Ou=Object.freeze({vertexOffset:0,vertexStep:2});function lE(s){s&&(s=void 0)}var bt=class{static startUp(t=null){if(rr)return ii("CubismFramework.startUp() is already done."),rr;if(vn=t,vn!=null&&Live2DCubismCore.Logging.csmSetLogFunction(vn.logFunction),rr=!0,rr){let e=Live2DCubismCore.Version.csmGetVersion(),r=(e&4278190080)>>24,i=(e&16711680)>>16,n=e&65535,o=e;ii("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+r).slice(-2),("00"+i).slice(-2),("0000"+n).slice(-4),o)}return ii("CubismFramework.startUp() is complete."),rr}static cleanUp(){rr=!1,bn=!1,vn=null,Va=null}static initialize(t=0){if(ye(rr),!rr){dt("CubismFramework is not started.");return}if(bn){dt("CubismFramework.initialize() skipped, already initialized.");return}he.staticInitializeNotForClientCall(),Va=new Nu,Live2DCubismCore.Memory.initializeAmountOfMemory(t),bn=!0,ii("CubismFramework.initialize() is complete.")}static dispose(){if(ye(rr),!rr){dt("CubismFramework is not started.");return}if(!bn){dt("CubismFramework.dispose() skipped, not initialized.");return}he.staticReleaseNotForClientCall(),Va.release(),Va=null,En.staticRelease(),bn=!1,ii("CubismFramework.dispose() is complete.")}static isStarted(){return rr}static isInitialized(){return bn}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return vn!=null?vn.loggingLevel:5}static getIdManager(){return Va}constructor(){}};var ni=(s=>(s[s.LogLevel_Verbose=0]="LogLevel_Verbose",s[s.LogLevel_Debug=1]="LogLevel_Debug",s[s.LogLevel_Info=2]="LogLevel_Info",s[s.LogLevel_Warning=3]="LogLevel_Warning",s[s.LogLevel_Error=4]="LogLevel_Error",s[s.LogLevel_Off=5]="LogLevel_Off",s))(ni||{}),tw;(s=>{s.Constant=Ou,s.csmDelete=lE,s.CubismFramework=bt})(tw||(tw={}));var Xm=2,Sr=2,sI=0,ew=1,iI=2,nI=999,Ae={LOG_LEVEL_VERBOSE:sI,LOG_LEVEL_WARNING:ew,LOG_LEVEL_ERROR:iI,LOG_LEVEL_NONE:nI,logLevel:ew,sound:!0,fftSize:512,motionSync:!0,motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500,preserveExpressionOnMotion:!0,cubism:QR};var tt={log(s,...t){Ae.logLevel<=Ae.LOG_LEVEL_VERBOSE&&console.log(`[${s}]`,...t)},warn(s,...t){Ae.logLevel<=Ae.LOG_LEVEL_WARNING&&console.warn(`[${s}]`,...t)},error(s,...t){Ae.logLevel<=Ae.LOG_LEVEL_ERROR&&console.error(`[${s}]`,...t)}};function og(s,t,e){return s<t?t:s>e?e:s}function oI(s){return s*1024*1024}function Na(s,t,e,r,i){let n=t[r];n!==null&&typeof n===s&&(e[i]=n)}function Ha(s,t,e,r,i){let n=t[r];Array.isArray(n)&&(e[i]=n.filter(o=>o!==null&&typeof o===s))}function aI(s,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{r!=="constructor"&&Object.defineProperty(s.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r))})})}function rw(s){let t=s.lastIndexOf("/");return t!=-1&&(s=s.slice(0,t)),t=s.lastIndexOf("/"),t!==-1&&(s=s.slice(t+1)),s}function lI(s,t){let e=s.indexOf(t);e!==-1&&s.splice(e,1)}var jm=/^[a-zA-Z][a-zA-Z0-9+.-]*:/;function hE(s,t){if(!t)return s;if(jm.test(t))return t;if(t.startsWith("/"))return jm.test(s)?new URL(t,s).toString():t;if(jm.test(s))return new URL(t,s).toString();let e="http://example.com",r=s.startsWith("/")?e+s:`${e}/${s}`,i=new URL(t,r),n=i.pathname+i.search+i.hash;return!s.startsWith("/")&&n.startsWith("/")&&(n=n.slice(1)),n}var Wu=class extends q{constructor(t,e){super(),M(this,"expressionDataType","json"),M(this,"tag"),M(this,"settings"),M(this,"expressions",[]),M(this,"defaultExpression"),M(this,"currentExpression"),M(this,"reserveExpressionIndex",-1),M(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createDefaultExpression(),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}createDefaultExpression(){return this.createExpression({},void 0)}loadExpression(t){return vt(this,null,function*(){if(!this.definitions[t]){tt.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){tt.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}if(this.expressions[t])return this.expressions[t];let e=yield this._loadExpression(t);return this.expressions[t]=e,e})}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return vt(this,null,function*(){if(this.definitions.length){let t=[];for(let e=0;e<this.definitions.length;e++)this.expressions[e]!==null&&this.expressions[e]!==this.currentExpression&&e!==this.reserveExpressionIndex&&t.push(e);if(t.length){let e=Math.floor(Math.random()*t.length);return this.setExpression(e)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return vt(this,null,function*(){if(typeof t!="number"&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length)||t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;let e=yield this.loadExpression(t);return!e||this.reserveExpressionIndex!==t?!1:(this.reserveExpressionIndex=-1,this.currentExpression=e,this._setExpression(e),!0)})}update(t,e){return this.isFinished()?!1:this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy");let t=this;t.definitions=void 0,t.expressions=void 0}},sw=.01,hI=40/7.5,uI=1/(.15*1e3),ag=class{constructor(){M(this,"targetX",0),M(this,"targetY",0),M(this,"x",0),M(this,"y",0),M(this,"vx",0),M(this,"vy",0)}focus(t,e,r=!1){this.targetX=og(t,-1,1),this.targetY=og(e,-1,1),r&&(this.x=this.targetX,this.y=this.targetY)}update(t){let e=this.targetX-this.x,r=this.targetY-this.y;if(Math.abs(e)<sw&&Math.abs(r)<sw)return;let i=Math.sqrt(yr(e,2)+yr(r,2)),n=hI/(1e3/t),o=n*(e/i)-this.vx,a=n*(r/i)-this.vy,l=Math.sqrt(yr(o,2)+yr(a,2)),h=n*uI*t;l>h&&(o*=h/l,a*=h/l),this.vx+=o,this.vy+=a;let u=Math.sqrt(yr(this.vx,2)+yr(this.vy,2)),c=.5*(Math.sqrt(yr(h,2)+8*h*i)-h);u>c&&(this.vx*=c/u,this.vy*=c/u),this.x+=this.vx,this.y+=this.vy}},Bn=class{constructor(t){M(this,"json"),M(this,"name"),M(this,"url"),M(this,"pose"),M(this,"physics"),this.json=t,this.url=t.url,this.name=rw(this.url)}normalizeName(){(!this.name||this.name.toLowerCase()==="name")&&(this.name=rw(this.url))}setModelName(...t){for(let e of t){let r=typeof e=="string"?e.trim():"";if(r&&r.toLowerCase()!=="name"){this.name=r;return}}this.normalizeName()}getFileStem(t){if(!t)return;let e=t.split(/[/\\]/).filter(Boolean).pop();return e?.replace(/\.[^.]+$/,"")}resolveURL(t){return hE(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let e=0;e<this.textures.length;e++)this.textures[e]=t(this.textures[e],`textures[${e}]`)}getDefinedFiles(){let t=[];return this.replaceFiles(e=>(t.push(e),e)),t}validateFiles(t){let e=(n,o)=>{let a=this.resolveURL(n);if(!t.includes(a)){if(o)throw new Error(`File "${n}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(n=>e(n,!0)),this.getDefinedFiles().filter(n=>e(n,!1))}},ir=(s=>(s[s.NONE=0]="NONE",s[s.IDLE=1]="IDLE",s[s.NORMAL=2]="NORMAL",s[s.FORCE=3]="FORCE",s))(ir||{}),Xu=class{constructor(){M(this,"tag"),M(this,"debug",!1),M(this,"currentPriority",0),M(this,"reservePriority",0),M(this,"currentGroup"),M(this,"currentIndex"),M(this,"reservedGroup"),M(this,"reservedIndex"),M(this,"reservedIdleGroup"),M(this,"reservedIdleIndex")}reserve(t,e,r){if(r<=0)return tt.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return tt.log(this.tag,"Motion is already playing.",this.dump(t,e)),!1;if(t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex)return tt.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(r===1){if(this.currentPriority!==0)return tt.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return tt.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(r<3){if(r<=this.currentPriority)return tt.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(r<=this.reservePriority)return tt.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,e)),!1}this.setReserved(t,e,r)}return!0}start(t,e,r,i){if(i===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return tt.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,r)),!1}else{if(e!==this.reservedGroup||r!==this.reservedIndex)return tt.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,r)),!1;this.setReserved(void 0,void 0,0)}return t?(this.setCurrent(e,r,i),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,r){this.currentPriority=r,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,r){this.reservePriority=r,this.reservedGroup=t,this.reservedIndex=e}setReservedIdle(t,e){this.reservedIdleGroup=t,this.reservedIdleIndex=e}isActive(t,e){return t===this.currentGroup&&e===this.currentIndex||t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!Ae.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){let r=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
973
+ <Requested> group = "${t}", index = ${e}
974
+ `+r.map(i=>"["+i+"] "+this[i]).join(`
975
+ `)}return""}},fs="SoundManager",Pn=.5,cI="live2d-sound-",dI=0,wu,iw=new WeakSet;function nw(s){if(!iw.has(s)){try{s.disableAutoPause=!0}catch(t){tt.warn(fs,"Failed to disable @pixi/sound auto pause.",t)}iw.add(s)}return s}function fI(){return typeof PIXI<"u"?PIXI==null?void 0:PIXI.sound:void 0}function pI(){return vt(this,null,function*(){let s=fI();return s?nw(s):(wu??(wu=Promise.resolve().then(()=>(HM(),NM)).then(({sound:t})=>nw(t)).catch(t=>(tt.warn(fs,"@pixi/sound is not available. Load pixi-sound.js before using motion sounds, speak(), or lip sync.",t),null))),wu)})}function ow(s,t){try{s.remove(t)}catch(e){tt.warn(fs,`Failed to remove sound "${t}".`,e)}}function mI(s){try{s.destroy()}catch(t){tt.warn(fs,"Failed to destroy audio.",t)}}function aw(s){let e=s.media.buffer;return!e||typeof e!="object"?void 0:typeof e.getChannelData=="function"?e:void 0}var Jt=class{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(t,e){return vt(this,null,function*(){let r=null,i;try{if(r=yield pI(),!r)throw new Error("@pixi/sound is not available");i=`${cI}${dI++}`;let n=r,o=i,l=yield new Promise((h,u)=>{let c=n.add(o,{url:t,volume:this._volume,preload:!0,loaded:(f,d)=>{if(f){u(f);return}let m=d??c;if(!m){u(new Error(`Error: ${t} failed to load`));return}if(!aw(m)){u(new Error(`Error: ${t} is not WebAudioMedia`));return}h(m)}})});return this.aliases.set(l,{alias:o,library:n}),this.audios.push(l),l}catch(n){return r&&i&&ow(r,i),tt.warn(fs,`Error occurred on "${t}"`,n),e?.(n),null}})}static play(t,e){t.play({singleInstance:!0,complete:()=>{e?.(),this.dispose(t)}})}static addAnalyzer(t,e){let r=aw(t);if(!r){tt.warn(fs,"Cannot create audio analyzer because WebAudio media is unavailable.");return}let i=e.createBufferSource();i.buffer=r;let n=e.createAnalyser();return n.fftSize=Ae.fftSize,n.minDecibels=-90,n.maxDecibels=-10,n.smoothingTimeConstant=.85,i.connect(n),i.start(0),this.analysers.push(n),n}static analyze(t){if(!t)return parseFloat(Math.random().toFixed(1));let e=new Float32Array(t.fftSize);t.getFloatTimeDomainData(e);let r=0;for(let l=0;l<e.length;l++)r+=yr(e[l],2);let i=Math.sqrt(r/e.length),o=20*Math.log10(i||yr(10,-100/20)),a=Math.min(Math.max((o-t.minDecibels)/(t.maxDecibels-t.minDecibels),0),1);return parseFloat(a.toFixed(1))}static dispose(t){try{t.pause()}catch(r){tt.warn(fs,"Failed to pause audio.",r)}let e=this.aliases.get(t);e?(ow(e.library,e.alias),this.aliases.delete(t)):mI(t),lI(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--){let e=this.contexts[t];e?.close().catch(r=>{tt.warn(fs,"Failed to close AudioContext.",r)})}for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}};M(Jt,"audios",[]);M(Jt,"analysers",[]);M(Jt,"contexts",[]);M(Jt,"aliases",new WeakMap);M(Jt,"_volume",Pn);var ju=class extends q{constructor(t){super(),M(this,"tag"),M(this,"settings"),M(this,"motionGroups",{}),M(this,"state",new Xu),M(this,"currentAudio"),M(this,"currentAnalyzer"),M(this,"currentContext"),M(this,"playing",!1),M(this,"destroyed",!1),M(this,"parent"),this.settings=t.settings,this.tag=`MotionManager(${this.settings.name})`,this.state.tag=this.tag,this.parent=t}init(t){t?.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){if(!this.definitions){tt.warn(this.tag,"Motion definitions are not initialized.");return}for(let r of Object.keys(this.definitions))this.motionGroups[r]=[];let e;switch(t?.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;case"IDLE":default:e=[this.groups.idle];break}for(let r of e){let i=this.definitions[r];if(i)for(let n=0;n<i.length;n++)this.loadMotion(r,n)}}loadMotion(t,e){return vt(this,null,function*(){var r,i;if(this.destroyed||!this.getMotionDefinition(t,e))return;let o=(i=(r=this.motionGroups)[t])!=null?i:r[t]=[];if(o[e]===null){tt.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);return}if(o[e])return o[e];let a=yield this._loadMotion(t,e);if(!this.destroyed)return o[e]=a??null,a})}_loadMotion(t,e){throw new Error("Not implemented.")}initializeAudio(t,e){this.currentAudio=t,Jt.volume=e,this.currentContext=t.context.audioContext,this.currentAnalyzer=Jt.addAnalyzer(this.currentAudio,this.currentContext)}speak(t){return vt(this,arguments,function*(e,{volume:r=Pn,expression:i,resetExpression:n=!0,onFinish:o,onError:a}={}){if(!Ae.sound)return!1;let l;if(this.currentAudio&&this.currentAudio.isPlaying)return!1;let h,u=e&&e.startsWith("data:");if(e&&!u){let f=document.createElement("a");f.href=e,e=f.href,h=e}else h="data:audio/";let c=e;if(c)try{if(l=yield Jt.add(c,(f,d=this)=>{tt.error(this.tag,"Error during audio playback:",f),a?.(f),n&&i&&d.expressionManager&&d.expressionManager.resetExpression(),d.currentAudio=void 0}),!l)return!1;this.initializeAudio(l,r)}catch(f){return tt.warn(this.tag,"Failed to create audio",h,f),!1}if(l){let f=!0;try{Ae.motionSync&&Jt.play(l,()=>{o?.(),n&&i&&this.expressionManager&&this.expressionManager.resetExpression(),this.currentAudio=void 0})}catch(d){tt.warn(this.tag,"Failed to play audio",l.url,d),f=!1}if(!f)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),i&&this.expressionManager&&(yield this.expressionManager.setExpression(i)),this.playing=!0,!0})}startMotion(t,e){return vt(this,arguments,function*(r,i,n=ir.NORMAL,{sound:o=void 0,volume:a=Pn,expression:l=void 0,resetExpression:h=!0,onFinish:u,onError:c,ignoreParamIds:f=[],loop:d=void 0}={}){if(this.destroyed||!this.state.reserve(r,i,n)||this.currentAudio&&this.currentAudio.isPlaying&&n!=ir.FORCE)return!1;let m=this.getMotionDefinition(r,i);if(!m)return!1;this.currentAudio&&Jt.dispose(this.currentAudio);let g,_,x=o&&o.startsWith("data:");if(o&&!x){let b=document.createElement("a");b.href=o,o=b.href,_=o}else _=this.getSoundFile(m),_&&(_=this.settings.resolveURL(_));let S=_;if(S)try{g=yield Jt.add(S,(b,C=this)=>{tt.error(this.tag,"Error during audio playback:",b),c?.(b),h&&l&&C.expressionManager&&C.expressionManager.resetExpression(),C.currentAudio=void 0}),g&&this.initializeAudio(g,a)}catch(b){tt.warn(this.tag,"Failed to create audio",_,b)}let v=yield this.loadMotion(r,i);if(g&&Ae.motionSync)try{Jt.play(g,(b=this)=>{u?.(),h&&l&&b.expressionManager&&b.expressionManager.resetExpression(),b.currentAudio=void 0})}catch(b){tt.warn(this.tag,"Failed to play audio",g.url,b)}return this.state.start(v,r,i,n)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),tt.log(this.tag,"Start motion:",this.getMotionName(m)),this.emit("motionStart",r,i,g),l&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(l)),this.playing=!0,v&&this._startMotion(v,void 0,f,d),!0):(g&&(Jt.dispose(g),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return vt(this,arguments,function*(r,i,{sound:n,volume:o=Pn,expression:a,resetExpression:l=!0,onFinish:h,onError:u,loop:c=void 0}={}){var f,d;if(this.destroyed)return!1;let m=(f=this.definitions)==null?void 0:f[r];if(m?.length){let g=[],_=(d=this.motionGroups[r])!=null?d:[];for(let x=0;x<m.length;x++)_[x]!==null&&!this.state.isActive(r,x)&&g.push(x);if(g.length){let x=g[Math.floor(Math.random()*g.length)];return this.startMotion(r,x,i,{sound:n,volume:o,expression:a,resetExpression:l,onFinish:h,onError:u,loop:c})}}return!1})}stopSpeaking(){this.currentAudio&&(Jt.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,e){var r;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&((r=this.expressionManager)==null||r.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,ir.IDLE)),this.updateParameters(t,e)}mouthSync(){return this.currentAnalyzer?Jt.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),(t=this.expressionManager)==null||t.destroy();let e=this;e.definitions=void 0,e.motionGroups=void 0}getMotionAndApplyExpression(t,e,r){return vt(this,null,function*(){if(this.destroyed||!this.state.reserve(t,e,ir.FORCE))return null;let i=this.getMotionDefinition(t,e);if(!i)return null;this.currentAudio&&Jt.dispose(this.currentAudio);let n=yield this.loadMotion(t,e);return this.state.start(n,t,e,ir.FORCE)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),tt.log(this.tag,"Start motion:",this.getMotionName(i)),this.emit("motionStart",t,e,void 0),r&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(r)),n):null})}getMotionDefinition(t,e){var r,i;let n=(i=(r=this.definitions)==null?void 0:r[t])==null?void 0:i[e];return n||tt.warn(this.tag,`Undefined motion at "${t}"[${e}]`),n}};function gI(s,t){s.a=t,s.b=0,s.c=0,s.d=t}function _I(s){let t=[];for(let[e,r]of Object.entries(s))typeof r=="number"&&t.push([e,r]);return t}function xI(s,t,e,r){var i,n;let o=Mc({width:Xm,height:Sr},r),a=(i=o.width)!=null?i:Xm,l=(n=o.height)!=null?n:Sr;s.identity(),s.scale(a/Xm,l/Sr);let h=t*s.a,u=e*s.d,c=o.x!==void 0&&o.x-a/2||o.centerX!==void 0&&o.centerX||o.left!==void 0&&o.left-a/2||o.right!==void 0&&o.right+a/2||0,f=o.y!==void 0&&o.y-l/2||o.centerY!==void 0&&o.centerY||o.top!==void 0&&o.top-l/2||o.bottom!==void 0&&o.bottom+l/2||0;return s.translate(h*c,-u*f),{width:h,height:u}}function uE(s,t){return Sr*t*s.scale}function cE(s){return Sr*s.scale}function yI(s,t,e){s.scale=e/(Sr*t)}function bI(s,t){s.scale=t/Sr}function Yu(s,t){s.x=t}function $u(s,t){s.y=t}function vI(s,t,e){Yu(s,e-uE(s,t)/2)}function SI(s,t){$u(s,t-cE(s)/2)}function TI(s,t,e){Yu(s,e-uE(s,t))}function CI(s,t){$u(s,t-cE(s))}function PI(s,t,e,r){if(t<=0||e<=0)return s.identity(),{width:0,height:0};let i=_I(r),n=t/e,o={scale:1,x:0,y:0};for(let[u,c]of i)u==="width"?yI(o,n,c):u==="height"&&bI(o,c);for(let[u,c]of i)u==="x"?Yu(o,c):u==="y"?$u(o,c):u==="centerX"?vI(o,n,c):u==="centerY"?SI(o,c):u==="top"?$u(o,c):u==="bottom"?CI(o,c):u==="left"?Yu(o,c):u==="right"&&TI(o,n,c);let a=e/Sr,l=Sr*n/2,h=Sr/2;return s.identity(),gI(s,o.scale),s.tx=a*(o.x+l)-t*o.scale/2,s.ty=a*(h-o.y)-e*o.scale/2,{width:t*o.scale,height:e*o.scale}}function MI(s,t){if(!Array.isArray(s))return[];let e=[];for(let r of s){if(!r||typeof r!="object")continue;let i=r,n=typeof i.id=="string"?i.id:typeof i.Id=="string"?i.Id:void 0,o=typeof i.name=="string"?i.name:typeof i.Name=="string"?i.Name:void 0;!n||!o||e.push({id:n,name:o,index:t(n)})}return e}var wI={x:0,y:0,width:0,height:0},lg=class extends q{constructor(){super(...arguments),M(this,"focusController",new ag),M(this,"pose"),M(this,"physics"),M(this,"originalWidth",0),M(this,"originalHeight",0),M(this,"width",0),M(this,"height",0),M(this,"localTransform",new R),M(this,"drawingMatrix",new R),M(this,"hitAreas",{}),M(this,"textureFlipY",!1),M(this,"viewport",[0,0,0,0]),M(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){let t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];let r=xI(this.localTransform,this.originalWidth,this.originalHeight,this.getLayout());t.width=r.width,t.height=r.height}setupHitAreas(){let t=this.getHitAreaDefs();this.hitAreas={};for(let e of t)e.name&&(this.hitAreas[e.name]=e)}hitTest(t,e){return Object.keys(this.hitAreas).filter(r=>this.isHit(r,t,e))}isHit(t,e,r){let i=this.hitAreas[t];if(!i)return!1;let n=i.index;if(n<0){if(!i.id||(n=this.getDrawableIndex(i.id),n<0))return!1;i.index=n}let o=this.getDrawableBounds(n,wI);return o.x<=e&&e<=o.x+o.width&&o.y<=r&&r<=o.y+o.height}getDrawableBounds(t,e){let r=this.getDrawableVertices(t),i=r[0],n=r[0],o=r[1],a=r[1];for(let l=0;l<r.length;l+=2){let h=r[l],u=r[l+1];i=Math.min(h,i),n=Math.max(h,n),o=Math.min(u,o),a=Math.max(u,a)}return e??(e={}),e.x=i,e.y=o,e.width=n-i,e.height=a-o,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0,this.parallelMotionManager.forEach(t=>t.destroy()),this.parallelMotionManager=[]}updateMotions(t,e){this.emit("beforeMotionUpdate");let r=this.motionManager.update(t,e),i=this.parallelMotionManager.map(o=>o.update(t,e)),n=r||i.reduce((o,a)=>o||a,!1);return this.emit("afterMotionUpdate"),n}},EI="XHRLoader",qu=class extends Error{constructor(t,e,r,i=!1){super(t),this.url=e,this.status=r,this.aborted=i}},oi=class Xe{static createXHR(t,e,r,i,n){let o=new XMLHttpRequest;if(Xe.allXhrSet.add(o),t){let a=Xe.xhrMap.get(t);a?a.add(o):(a=new Set([o]),Xe.xhrMap.set(t,a))}return o.open("GET",e),o.responseType=r,o.onload=()=>{var a;(o.status===200||o.status===0)&&o.response?i(o.response):(a=o.onerror)==null||a.call(o,new ProgressEvent("error"))},o.onerror=()=>{tt.warn(EI,`Failed to load resource as ${o.responseType} (Status ${o.status}): ${e}`),n(new qu("Network error.",e,o.status))},o.onabort=()=>n(new qu("Aborted.",e,o.status,!0)),o.onloadend=()=>{var a;Xe.allXhrSet.delete(o),t&&((a=Xe.xhrMap.get(t))==null||a.delete(o))},o}static cancelXHRs(){var t;(t=Xe.xhrMap.get(this))==null||t.forEach(e=>{e.abort(),Xe.allXhrSet.delete(e)}),Xe.xhrMap.delete(this)}static release(){Xe.allXhrSet.forEach(t=>t.abort()),Xe.allXhrSet.clear(),Xe.xhrMap=new WeakMap}};M(oi,"xhrMap",new WeakMap);M(oi,"allXhrSet",new Set);M(oi,"loader",s=>new Promise((t,e)=>{let r=s.target,i=s.target&&typeof oi.cancelXHRs=="function"?oi.cancelXHRs.bind(s.target):void 0,n=oi.createXHR(s.target,s.settings?s.settings.resolveURL(s.url):s.url,s.type,o=>{s.result=o,t()},e);if(s.target&&i&&typeof r.listeners=="function"&&typeof r.once=="function"){let o=r.listeners("destroy");(!Array.isArray(o)||!o.includes(i))&&r.once("destroy",i)}n.send()}));var AI=oi;function dE(s,t){let e=-1;return r(0);function r(i,n){if(n)return Promise.reject(n);if(i<=e)return Promise.reject(new Error("next() called multiple times"));e=i;let o=s[i];if(!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,i+1)))}catch(a){let l=a instanceof Error?a:new Error(String(a));return Promise.reject(l)}}}var jr=class{static load(t){return vt(this,null,function*(){return yield dE(this.middlewares,t),t.result})}};M(jr,"middlewares",[AI.loader]);var Ku=class s extends Bn{constructor(t){if(super(t),M(this,"moc"),M(this,"textures"),M(this,"layout"),M(this,"hitAreas"),M(this,"initParams"),M(this,"initOpacities"),M(this,"expressions"),M(this,"motions",{}),!s.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,Ha("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){if(!t||typeof t!="object")return!1;let e=Array.isArray(t.textures)?t.textures.every(r=>typeof r=="string"):!1;return typeof t.model=="string"&&e}copy(t){Na("string",t,this,"name","name"),Na("string",t,this,"pose","pose"),Na("string",t,this,"physics","physics"),Na("object",t,this,"layout","layout"),Na("object",t,this,"motions","motions"),Ha("object",t,this,"hit_areas","hitAreas"),Ha("object",t,this,"expressions","expressions"),Ha("object",t,this,"init_params","initParams"),Ha("object",t,this,"init_opacities","initOpacities");let e=this.getFileStem(this.moc);this.setModelName(this.name,e)}replaceFiles(t){super.replaceFiles(t);for(let[e,r]of Object.entries(this.motions))for(let i=0;i<r.length;i++)r[i].file=t(r[i].file,`motions.${e}[${i}].file`),r[i].sound!==void 0&&(r[i].sound=t(r[i].sound,`motions.${e}[${i}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}},BI=.5,RI=4096;function II({lod:s,effectiveScale:t,textureWidth:e,textureHeight:r,lodScaleThreshold:i,lodTextureSizeThreshold:n,lodMaxLevel:o}){if(fE(s)!=="single-auto"||!Number.isFinite(t)||t<=0)return;let a=Math.floor(e),l=Math.floor(r);if(a<=1||l<=1)return;let h=lw(i,BI);if(t>=h)return;let u=lw(n,RI);if(Math.max(a,l)<u)return;let c=Math.round(Math.log2(1/t)),f=Math.max(1,Math.floor(Math.log2(Math.max(a,l)))),d=Math.min(f,kI(o,f)),m=LI(Math.max(1,c),1,d),g=yr(2,m);return{level:m,width:Math.max(1,Math.round(a/g)),height:Math.max(1,Math.round(l/g))}}function fE(s){return s===!1||s==="single-auto"?s:"full"}function FI(s){return s==="nearest"?"nearest":"linear"}function lw(s,t){return s!==void 0&&Number.isFinite(s)&&s>0?s:t}function kI(s,t){return s!==void 0&&Number.isFinite(s)&&s>=1?Math.floor(s):t}function LI(s,t,e){return Math.min(e,Math.max(t,s))}function DI(s,t={}){let e=Js.config,r=e?.crossOrigin,i=e?.preferCreateImageBitmap,n=e?.preferWorkers;return t.crossOrigin!==void 0&&e&&(e.crossOrigin=t.crossOrigin),t.preferCreateImageBitmap===!1&&e&&(e.preferCreateImageBitmap=!1,e.preferWorkers=!1),Qs.load({src:s,data:{autoGenerateMipmaps:fE(t.lod)==="full"}}).catch(o=>{throw o instanceof Error?o:new Error("Texture loading error",{cause:o})}).finally(()=>{e&&(e.crossOrigin=r??e.crossOrigin,t.preferCreateImageBitmap===!1&&(e.preferCreateImageBitmap=i??e.preferCreateImageBitmap,e.preferWorkers=n??e.preferWorkers))})}function OI(){}var hw="Live2DFactory",pE=(s,t)=>vt(null,null,function*(){if(typeof s.source=="string"){let e=yield jr.load({url:s.source,type:"json",target:s.live2dModel});e.url=typeof e.url=="string"?e.url:s.source,s.source=e,s.live2dModel.emit("settingsJSONLoaded",e)}return t()}),mE=(s,t)=>vt(null,null,function*(){if(s.source instanceof Bn)return s.settings=s.source,t();if(typeof s.source=="object"){let n=Re.findRuntime(s.source);if(n){let o=n.createModelSettings(s.source);return s.settings=o,s.live2dModel.emit("settingsLoaded",o),t()}}let e=s.source&&typeof s.source.url=="string"?s.source.url:void 0,r=Re.runtimes.map(n=>n.version).join(", ");if(Re.runtimes.length===0)throw new TypeError(["Unknown settings format: no Live2D runtimes registered.",'Import a published runtime entry before loading models (e.g. "<package>/cubism" for Cubism 3/4/5, "<package>/cubism-legacy" for Cubism 2).',e?`Settings URL: ${e}`:void 0].filter(Boolean).join(`
976
+ `));let i=(()=>{try{return!s.source||typeof s.source!="object"||Array.isArray(s.source)?void 0:Object.keys(s.source).slice(0,30).join(", ")}catch{return}})();throw new TypeError(["Unknown settings format: no matching runtime found for the loaded settings JSON.",r?`Registered runtimes (versions): ${r}`:void 0,i?`Settings JSON keys: ${i}`:void 0,e?`Settings URL: ${e}`:void 0].filter(Boolean).join(`
977
+ `))}),gE=(s,t)=>{if(s.settings){let e=Re.findRuntime(s.settings);if(e)return e.ready().then(()=>t())}return t()},_E=(s,t)=>vt(null,null,function*(){yield t();let e=s.internalModel;if(e){let r=s.settings,i=Re.findRuntime(r);if(i){let n=[],o=r instanceof Ku?"json":"arraybuffer";r.pose&&n.push(jr.load({settings:r,url:r.pose,type:o,target:e}).then(a=>{e.pose=i.createPose(e.coreModel,a),s.live2dModel.emit("poseLoaded",e.pose)}).catch(a=>{s.live2dModel.emit("poseLoadError",a),tt.warn(hw,"Failed to load pose.",a)})),r.physics&&n.push(jr.load({settings:r,url:r.physics,type:o,target:e}).then(a=>{e.physics=i.createPhysics(e.coreModel,a),s.live2dModel.emit("physicsLoaded",e.physics)}).catch(a=>{s.live2dModel.emit("physicsLoadError",a),tt.warn(hw,"Failed to load physics.",a)})),n.length&&(yield Promise.all(n))}}}),xE=(s,t)=>vt(null,null,function*(){if(s.settings){let e=s.live2dModel,r=Mc({crossOrigin:s.options.crossOrigin},s.options.textureOptions);s.settings instanceof Ku&&(r.preferCreateImageBitmap=!1);let i=Promise.all(s.settings.textures.map(n=>{let o=s.settings.resolveURL(n);return DI(o,r)}));if(i.catch(OI),yield t(),s.internalModel)e.internalModel=s.internalModel,e.emit("modelLoaded",s.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield i,e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),yE=(s,t)=>vt(null,null,function*(){let e=s.settings;if(e instanceof Bn){let r=Re.findRuntime(e);if(!r)throw new TypeError("Unknown model settings.");let i=yield jr.load({settings:e,url:e.moc,type:"arraybuffer",target:s.live2dModel});if(!r.isValidMoc(i))throw new Error("Invalid moc data");let n=r.createCoreModel(i);return s.internalModel=r.createInternalModel(n,e,s.options),t()}throw new TypeError("Missing settings.")}),br=class Gu{static resolveURL(t,e){var r;let i=(r=Gu.filesMap[t])==null?void 0:r[e];if(i===void 0)throw new Error("Cannot find this file from uploaded files: "+e);return i}static upload(t,e){let r={};for(let i of e.getDefinedFiles()){let n=decodeURI(hE(e.url,i)),o=t.find(a=>a.webkitRelativePath===n);o&&(r[i]=URL.createObjectURL(o))}Gu.filesMap[e._objectURL]=r}static createSettings(t){return vt(this,null,function*(){let e=t.find(a=>a.name.endsWith("model.json")||a.name.endsWith("model3.json"));if(!e)throw new TypeError("Settings file not found");let r=yield Gu.readText(e),i=JSON.parse(r);i.url=e.webkitRelativePath;let n=Re.findRuntime(i);if(!n)throw new Error("Unknown settings JSON");let o=n.createModelSettings(i);return o._objectURL=URL.createObjectURL(e),o})}static readText(t){return vt(this,null,function*(){return new Promise((e,r)=>{let i=new FileReader;i.onload=()=>e(i.result),i.onerror=r,i.readAsText(t,"utf8")})})}};M(br,"live2dFactory");M(br,"filesMap",{});M(br,"factory",(s,t)=>vt(null,null,function*(){if(Array.isArray(s.source)&&s.source[0]instanceof File){let e=s.source,r=e.settings;if(!r)r=yield br.createSettings(e);else if(!r._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings');r.validateFiles(e.map(i=>encodeURI(i.webkitRelativePath))),br.upload(e,r),r.resolveURL=function(i){return br.resolveURL(this._objectURL,i)},s.source=r,s.live2dModel.once("modelLoaded",i=>{i.once("destroy",function(){let n=this.settings._objectURL;if(URL.revokeObjectURL(n),br.filesMap[n])for(let o of Object.values(br.filesMap[n]))URL.revokeObjectURL(o);delete br.filesMap[n]})})}return t()}));var bE=br,nr=class _e{static registerRuntime(t){_e.runtimes.push(t),_e.runtimes.sort((e,r)=>r.version-e.version)}static findRuntime(t){for(let e of _e.runtimes)if(e.test(t))return e}static setupLive2DModel(t,e,r){return vt(this,null,function*(){let i=new Promise(a=>t.once("textureLoaded",a)),n=new Promise(a=>t.once("modelLoaded",a)),o=Promise.all([i,n]).then(()=>t.emit("ready"));yield dE(_e.live2DModelMiddlewares,{live2dModel:t,source:e,options:r||{}}),yield o,t.emit("load")})}static loadMotion(t,e,r){var i,n;let o=a=>t.emit("motionLoadError",e,r,a);try{let a=(i=t.definitions[e])==null?void 0:i[r];if(!a)return Promise.resolve(void 0);t.once("destroy",()=>_e.releaseMotionTasks(t));let l=_e.motionTasksMap.get(t);l||(l={},_e.motionTasksMap.set(t,l));let h=l[e];h||(h=[],l[e]=h);let u=t.getMotionFile(a);return(n=h[r])!=null||(h[r]=jr.load({url:u,settings:t.settings,type:t.motionDataType,target:t}).then(c=>{var f;let d=(f=_e.motionTasksMap.get(t))==null?void 0:f[e];d&&(d[r]=void 0);let m=c,g=t.createMotion(m,e,a);return t.emit("motionLoaded",e,r,g),g}).catch(c=>{tt.warn(t.tag,`Failed to load motion: ${u}
978
+ `,c),o(c)})),h[r]}catch(a){tt.warn(t.tag,`Failed to load motion at "${e}"[${r}]
979
+ `,a),o(a)}return Promise.resolve(void 0)}static loadExpression(t,e){var r,i;let n=o=>t.emit("expressionLoadError",e,o);try{let o=t.definitions[e];if(!o)return Promise.resolve(void 0);t.once("destroy",()=>_e.releaseExpressionTasks(t));let a=_e.expressionTasksMap.get(t);a||(a=[],_e.expressionTasksMap.set(t,a));let l=t.getExpressionFile(o),h=(r=t.expressionDataType)!=null?r:"json";return(i=a[e])!=null||(a[e]=jr.load({url:l,settings:t.settings,type:h,target:t}).then(u=>{let c=_e.expressionTasksMap.get(t);c&&(c[e]=void 0);let f=u,d=t.createExpression(f,o);return t.emit("expressionLoaded",e,d),d}).catch(u=>{tt.warn(t.tag,`Failed to load expression: ${l}
980
+ `,u),n(u)})),a[e]}catch(o){tt.warn(t.tag,`Failed to load expression at [${e}]
981
+ `,o),n(o)}return Promise.resolve(void 0)}static releaseMotionTasks(t){_e.motionTasksMap.delete(t)}static releaseExpressionTasks(t){_e.expressionTasksMap.delete(t)}};M(nr,"runtimes",[]);M(nr,"urlToJSON",pE);M(nr,"jsonToSettings",mE);M(nr,"waitUntilReady",gE);M(nr,"setupOptionals",_E);M(nr,"setupEssentials",xE);M(nr,"createInternalModel",yE);M(nr,"live2DModelMiddlewares",[bE.factory,pE,mE,gE,_E,xE,yE]);M(nr,"motionTasksMap",new WeakMap);M(nr,"expressionTasksMap",new WeakMap);var Re=nr;ju.prototype._loadMotion=function(s,t){return Re.loadMotion(this,s,t)};Wu.prototype._loadExpression=function(s){return Re.loadExpression(this,s)};bE.live2dFactory=Re;var vE=class SE{constructor(t,{autoUpdate:e=!0,autoHitTest:r=!0,autoFocus:i=!0,autoInteract:n,ticker:o}={}){M(this,"model"),M(this,"destroyed",!1),M(this,"_ticker"),M(this,"_autoUpdate",!1),M(this,"_autoHitTest",!1),M(this,"_autoFocus",!1);var a;o??(o=(a=SE.defaultTicker)!=null?a:typeof PIXI<"u"?PIXI.Ticker.shared:St.shared),n!==void 0&&(r=n,i=n,tt.warn(t.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=t,this.ticker=o,this.autoUpdate=e,this.autoHitTest=r,this.autoFocus=i,(r||i)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var e,r;this._ticker&&this._ticker.remove(Eu,this),this._ticker=t,this._autoUpdate&&((e=this._ticker)==null||e.add(Eu,this),(r=this._ticker)==null||r.start())}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;this.destroyed||(t?this._ticker?(this._ticker.add(Eu,this),this._autoUpdate=!0):tt.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):((e=this._ticker)==null||e.remove(Eu,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",cw,this):this.model.off("pointertap",cw,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?(this.model.on("globalpointermove",Au,this),this.model.on("pointermove",Au,this)):(this.model.off("globalpointermove",Au,this),this.model.off("pointermove",Au,this)),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){let t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};M(vE,"defaultTicker");var uw=vE;function Eu(){this.onTickerUpdate()}function cw(s){this.onTap(s)}function Au(s){this.onPointerMove(s)}var hg=class extends ka{},We=new et,GI=new R,UI=new R,VI={x:0,y:0,width:0,height:0},us=new ot,dw=!1,$a=class{constructor(t){this.renderer=t}addPrepare(t,e){var r,i;(i=(r=this.renderer.renderPipes.batch)==null?void 0:r.break)==null||i.call(r,e),e.add({renderPipeId:"live2d",action:"prepare",canBundle:!1,prepare:t})}addRenderable(t,e){var r,i;(i=(r=this.renderer.renderPipes.batch)==null?void 0:r.break)==null||i.call(r,e),e.add(t)}execute(t){if(!(t instanceof qa)){t.prepare();return}let e=t;!e.visible||e.alpha<=0||e.renderLive2D(this.renderer)}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}destroy(){}};M($a,"extension",{type:[y.WebGLPipes],name:"live2d"});var TE=$a;function NI(s){let t=s;t.renderPipes.live2d||(dw||(dw=!0,console.warn("[untitled-pixi-live2d-engine] Lazy Live2D render pipe registration is deprecated. Register Live2DPlugin explicitly with `extensions.add(Live2DPlugin)` before creating the Pixi renderer.")),t.renderPipes.live2d=new $a(s))}function HI(s){return Math.max(Math.hypot(s.a,s.b),Math.hypot(s.c,s.d))}function zI(s){if(!s||typeof s!="object")return!1;let{width:t,height:e}=s;return typeof t=="number"&&t>0&&typeof e=="number"&&e>0}function WI(s,t,e,r,i){var n,o;let a=s.source.resource;if(!zI(a))return;let l=D.get().createCanvas(e,r),h=l.getContext("2d");if(!h)return;try{h.clearRect(0,0,e,r),h.imageSmoothingEnabled=i!=="nearest","imageSmoothingQuality"in h&&i!=="nearest"&&(h.imageSmoothingQuality="high"),h.drawImage(a,0,0,s.source.pixelWidth,s.source.pixelHeight,0,0,e,r)}catch{return}let u=`${(o=(n=s.label)!=null?n:s.source.label)!=null?o:"Live2DTexture"} LOD ${t}`;return new F({label:u,source:new It({resource:l,width:e,height:r,resolution:1,scaleMode:FI(i),autoGenerateMipmaps:!1,label:u})})}var qa=class extends Mt{constructor(t){var e;super(),M(this,"renderPipeId","live2d"),M(this,"tag","Live2DModel(uninitialized)"),M(this,"internalModel"),M(this,"textures",[]),M(this,"textureOptions"),M(this,"anchorMode"),M(this,"textureLODStates",[]),M(this,"textureLODFailures",[]),M(this,"transform",new hg),M(this,"anchor"),M(this,"_bounds",new ot),M(this,"_boundsDirty",!0),M(this,"_boundsRetryAfterDraw",!1),M(this,"gl",null),M(this,"elapsedTime",0),M(this,"deltaTime",0),M(this,"automator"),M(this,"currentGlId",0),M(this,"renderLive2D",r=>{var i,n,o,a,l;if(!(r instanceof Ki))throw new Error("Renderer is not supported");r.geometry.resetState(),r.shader.resetState(),r.texture.resetState();let h=!1;this.gl!==r.gl&&(this.gl=r.gl,this.internalModel.updateWebGLContext(r.gl,this.generateUID()),h=!0);let{projectionMatrix:u,offset:c,worldTransformMatrix:f}=r.globalUniforms.globalUniformData,d=UI.copyFrom(f).append(this.groupTransform),m=HI(d)*r.resolution;for(let T=0;T<this.textures.length;T++){let P=this.textures[T],E=this.resolveTextureForRender(T,P,m);try{this.uploadTextureForRender(r,E,h)}catch{if(E===P)throw new Error("Failed to upload Live2D texture.");let B=this.textureLODStates[T];B?.texture===E&&(this.markTextureLODFailure(T,P,B.level),this.destroyTextureLODState(T)),E=P,this.uploadTextureForRender(r,E,h)}this.internalModel.bindTexture(T,r.texture.getGlSource(E.source).texture)}let g=r.renderTarget.viewport,_=r.renderTarget.renderTarget,x=g.y;_?.isRoot&&(x=_.colorTexture.source.pixelHeight-g.height-g.y),this.internalModel.viewport=[g.x,x,g.width,g.height];let S=this.deltaTime;this.deltaTime=0,S&&this.internalModel.update(S,this.elapsedTime),d.tx-=(i=c?.x)!=null?i:0,d.ty-=(n=c?.y)!=null?n:0;let v=GI.copyFrom(u).append(d);this.internalModel.updateTransform(v),this.internalModel.draw(r.gl),this._boundsRetryAfterDraw&&this.updateDrawableBounds(!0),r.state.resetState(),r.texture.resetState();let b=(o=r.renderTarget)==null?void 0:o.defaultClearColor,C=(l=(a=r.renderTarget)==null?void 0:a.adaptor)==null?void 0:l._clearColorCache;b&&(r.gl.clearColor(b[0],b[1],b[2],b[3]),C&&(C[0]=b[0],C[1]=b[1],C[2]=b[2],C[3]=b[3]))}),this.textureOptions=t?.textureOptions,this.anchorMode=(e=t?.anchorMode)!=null?e:"canvas",this.anchor=new Ct({_onUpdate:()=>this.onAnchorChange()},0,0),this.automator=new uw(this,t),this.once("modelLoaded",()=>this.initializeOnModelLoad(t))}get isRenderable(){return!0}get canBundle(){return!1}static from(t,e){return vt(this,null,function*(){let r=new this(e);return yield Re.setupLive2DModel(r,t,e),r})}static fromSync(t,e){let r=new this(e);return Re.setupLive2DModel(r,t,e).then(()=>{var i;return(i=e?.onLoad)==null?void 0:i.call(e)}).catch(i=>{var n;return(n=e?.onError)==null?void 0:n.call(e,i)}),r}static registerTicker(t){uw.defaultTicker=t.shared}get bounds(){return this.internalModel?(this._boundsDirty&&this.updateDrawableBounds(),this._bounds):(this._bounds.set(0,0,0,0),this._bounds)}updateDrawableBounds(t=!1){if(!this.internalModel){this._bounds.set(0,0,0,0),this._boundsDirty=!1;return}let e=this.internalModel.getDrawableIDs();us.clear();for(let r=0;r<e.length;r++){let i=e[r],n=this.internalModel.getDrawableIndex(i);if(n<0)continue;let o=this.internalModel.getDrawableBounds(n,VI);!Number.isFinite(o.x)||!Number.isFinite(o.y)||!Number.isFinite(o.width)||!Number.isFinite(o.height)||us.addFrame(o.x,o.y,o.x+o.width,o.y+o.height,R.IDENTITY)}if(this._bounds.clear(),us.isValid&&us.isPositive)this._bounds.addFrame(us.minX,us.minY,us.maxX,us.maxY,this.internalModel.localTransform),this._boundsRetryAfterDraw=!1;else{let r=this.internalModel.originalWidth||this.internalModel.width,i=this.internalModel.originalHeight||this.internalModel.height;this._bounds.addFrame(0,0,r,i,this.internalModel.localTransform),this._boundsRetryAfterDraw=!0}this._boundsDirty=!1,this._didViewChangeTick++,t&&this.anchorMode==="drawable"&&this.onAnchorChange()}prepareForRender(){if(!this.internalModel)return;let t=this.deltaTime;this.deltaTime=0,t&&this.internalModel.update(t,this.elapsedTime),this.updateDrawableBounds()}generateUID(){return++this.currentGlId}collectRenderables(t,e,r){var i,n,o,a;if(this.parentRenderLayer&&this.parentRenderLayer!==r||this.globalDisplayStatus<7||!this.includeInBuild)return;this.sortableChildren&&this.sortChildren(),NI(e);let l=e.renderPipes,h=()=>{l.live2d.addRenderable(this,t)},u=()=>{let f=this.children,d=f.length;for(let m=0;m<d;m++)f[m].collectRenderables(t,e,r)},c=this.effects;if(c){c.length&&l.live2d.addPrepare(()=>this.prepareForRender(),t);for(let f=0;f<c.length;f++){let d=c[f],m=d.filters;if(m)for(let g of m)g&&typeof g.resolution=="number"&&g.resolution===1&&(g.resolution="inherit");(n=(i=l[d.pipe])==null?void 0:i.push)==null||n.call(i,d,this,t)}h(),u();for(let f=c.length-1;f>=0;f--){let d=c[f];(a=(o=l[d.pipe])==null?void 0:o.pop)==null||a.call(o,d,this,t)}}else h(),u()}initializeOnModelLoad(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`,this.updateDrawableBounds(!0),this.anchorMode==="canvas"&&this.onAnchorChange()}onAnchorChange(){if(!(!this.internalModel||!this.pivot))if(this.anchorMode==="drawable"){let t=this.bounds;this.pivot.set(t.minX+this.anchor.x*t.width,t.minY+this.anchor.y*t.height)}else this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,r){return vt(this,arguments,function*(i,n,o,{sound:a=void 0,volume:l=Pn,expression:h=void 0,resetExpression:u=!0,onFinish:c,onError:f,loop:d=void 0}={}){return n===void 0?this.internalModel.motionManager.startRandomMotion(i,o,{sound:a,volume:l,expression:h,resetExpression:u,onFinish:c,onError:f,loop:d}):this.internalModel.motionManager.startMotion(i,n,o,{sound:a,volume:l,expression:h,resetExpression:u,onFinish:c,onError:f,loop:d})})}motionLastFrame(t,e){return vt(this,arguments,function*(r,i,{expression:n=void 0}={}){return this.internalModel.motionManager.motionLastFrame(r,i,{expression:n})})}parallelMotion(t){return vt(this,null,function*(){this.internalModel.extendParallelMotionManager(t.length);let e=t.map((i,n)=>this.internalModel.parallelMotionManager[n].startMotion(i.group,i.index,i.priority,{ignoreParamIds:i.ignoreParamIds,loop:i.loop})),r=[];for(let i of e)r.push(yield i);return r})}parallelLastFrame(t){return vt(this,null,function*(){this.internalModel.extendParallelMotionManager(t.length);let e=t.map((i,n)=>this.internalModel.parallelMotionManager[n].playMotionLastFrame(i.group,i.index)),r=[];for(let i of e)r.push(yield i);return r})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:e=Pn,expression:r,resetExpression:i=!0,onFinish:n,onError:o}={}){return this.internalModel.motionManager.speak(t,{volume:e,expression:r,resetExpression:i,onFinish:n,onError:o})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,r=!1){We.x=t,We.y=e,this.toModelPosition(We,We,!0);let i=We.x/this.internalModel.originalWidth*2-1,n=We.y/this.internalModel.originalHeight*2-1,o=Math.atan2(n,i);this.internalModel.focusController.focus(Math.cos(o),-Math.sin(o),r)}tap(t,e){let r=this.hitTest(t,e);r.length&&this.emit("hit",r)}hitTest(t,e){return We.x=t,We.y=e,this.toModelPosition(We,We),this.internalModel.hitTest(We.x,We.y)}toModelPosition(t,e=t.clone(),r){return r||this.updateLocalTransform(),this.toLocal(t,void 0,e,r),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.bounds.containsPoint(t.x,t.y)}_calculateBounds(){if(!this.internalModel){this.getBounds().set(0,0,0,0);return}let t=this.bounds;this.getBounds().addFrame(t.minX,t.minY,t.maxX,t.maxY,this.transform.matrix)}update(t){this.deltaTime+=t,this.elapsedTime+=t}resolveTextureForRender(t,e,r){var i;let n=II(jR(Mc({},this.textureOptions),{effectiveScale:r,textureWidth:e.source.pixelWidth,textureHeight:e.source.pixelHeight}));if(!n)return e;let o=this.textureLODFailures[t];if(o?.source===e&&o.levels.has(n.level))return e;let a=this.textureLODStates[t];if(a?.source===e&&a.level===n.level&&!a.texture.destroyed)return a.texture;this.destroyTextureLODState(t);let l=WI(e,n.level,n.width,n.height,(i=this.textureOptions)==null?void 0:i.lodFilter);return l?(this.textureLODStates[t]={source:e,level:n.level,texture:l},l):(this.markTextureLODFailure(t,e,n.level),e)}markTextureLODFailure(t,e,r){let i=this.textureLODFailures[t];i?.source!==e&&(i={source:e,levels:new Set},this.textureLODFailures[t]=i),i.levels.add(r)}destroyTextureLODState(t){let e=this.textureLODStates[t];e&&(e.texture.destroy(!0),this.textureLODStates[t]=void 0)}destroyTextureLODStates(){for(let t=0;t<this.textureLODStates.length;t++)this.destroyTextureLODState(t);this.textureLODFailures.length=0}uploadTextureForRender(t,e,r){let i=!!e.source._gpuData[t.uid];(r||!i)&&(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(e,0))}destroy(t){this.emit("destroy"),this.destroyTextureLODStates(),t?.texture&&this.textures.forEach(e=>e.destroy(t.baseTexture)),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}};if(typeof window>"u"||typeof window.Live2DCubismCore>"u")throw new Error("Could not find Cubism runtime. This plugin requires live2dcubismcore.js to be loaded.");var j=class s{constructor(t,e){this.x=t,this.y=e,this.x=t??0,this.y=e??0}add(t){let e=new s(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){let e=new s(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){let e=new s(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new s(t,t))}division(t){let e=new s(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new s(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){let t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}},fw;(s=>{s.CubismVector2=j})(fw||(fw={}));var CE=class Uu{static range(t,e,r){return t<e?t=e:t>r&&(t=r),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let e=t,r=e<0;r&&(e=-e);let i;return e===1/0?i=1/0:(i=Math.exp(Math.log(e)/3),i=(e/(i*i)+2*i)/3),r?-i:i}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,e){return t>e?t:e}static min(t,e){return t>e?e:t}static clamp(t,e,r){return t<e?e:r<t?r:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,e){let r=Math.atan2(e.y,e.x),i=Math.atan2(t.y,t.x),n=r-i;for(;n<-Math.PI;)n+=Math.PI*2;for(;n>Math.PI;)n-=Math.PI*2;return n}static directionToDegrees(t,e){let r=this.directionToRadian(t,e),i=this.radianToDegrees(r);return e.x-t.x>0&&(i=-i),i}static radianToDirection(t){let e=new j;return e.x=this.sin(t),e.y=this.cos(t),e}static quadraticEquation(t,e,r){return this.abs(t)<Uu.Epsilon?this.abs(e)<Uu.Epsilon?-r:-r/e:-(e+this.sqrt(e*e-4*t*r))/(2*t)}static cardanoAlgorithmForBezier(t,e,r,i){if(this.abs(t)<Uu.Epsilon)return this.range(this.quadraticEquation(e,r,i),0,1);let n=e/t,o=r/t,a=i/t,l=(3*o-n*n)/3,h=l/3,u=(2*n*n*n-9*n*o+27*a)/27,c=u/2,f=c*c+h*h*h,d=.5,m=d+.01;if(f<0){let v=-l/3,b=v*v*v,C=this.sqrt(b),T=-u/(2*C),P=this.range(T,-1,1),E=Math.acos(P),B=2*this.cbrt(C),w=B*this.cos(E/3)-n/3;if(this.abs(w-d)<m)return this.range(w,0,1);let I=B*this.cos((E+2*Math.PI)/3)-n/3;if(this.abs(I-d)<m)return this.range(I,0,1);let G=B*this.cos((E+4*Math.PI)/3)-n/3;return this.range(G,0,1)}if(f==0){let v;c<0?v=this.cbrt(-c):v=-this.cbrt(c);let b=2*v-n/3;if(this.abs(b-d)<m)return this.range(b,0,1);let C=-v-n/3;return this.range(C,0,1)}let g=this.sqrt(f),_=this.cbrt(g-c),x=this.cbrt(g+c),S=_-x-n/3;return this.range(S,0,1)}static mod(t,e){if(!isFinite(t)||e===0||isNaN(t)||isNaN(e))return console.warn(`divided: ${t}, divisor: ${e} mod() returns 'NaN'.`),NaN;let r=Math.abs(t),i=Math.abs(e),n=r-Math.floor(r/i)*i;return n*=Math.sign(t),n}constructor(){}};CE.Epsilon=1e-5;var st=CE,pw;(s=>{s.CubismMath=st})(pw||(pw={}));var Rn=class{constructor(){this.setBeganMotionHandler=t=>this._onBeganMotion=t,this.getBeganMotionHandler=()=>this._onBeganMotion,this.setFinishedMotionHandler=t=>this._onFinishedMotion=t,this.getFinishedMotionHandler=()=>this._onFinishedMotion,this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._isLoop=!1,this._isLoopFadeIn=!0,this._previousLoopState=this._isLoop,this._firedEventValues=new X}static delete(t){t.release(),t=null}release(){this._weight=0}updateParameters(t,e,r){if(!e.isAvailable()||e.isFinished())return;this.setupMotionQueueEntry(e,r);let i=this.updateFadeWeight(e,r);this.doUpdateParameters(t,r,i,e),e.getEndTime()>0&&e.getEndTime()<r&&e.setIsFinished(!0)}setupMotionQueueEntry(t,e){t==null||t.isStarted()||t.isAvailable()&&(t.setIsStarted(!0),t.setStartTime(e-this._offsetSeconds),t.setFadeInStartTime(e),t.getEndTime()<0&&this.adjustEndTime(t),t._motion._onBeganMotion&&t._motion._onBeganMotion(t._motion))}updateFadeWeight(t,e){t==null&&ja.print(ni.LogLevel_Error,"motionQueueEntry is null.");let r=this._weight,i=this._fadeInSeconds==0?1:st.getEasingSine((e-t.getFadeInStartTime())/this._fadeInSeconds),n=this._fadeOutSeconds==0||t.getEndTime()<0?1:st.getEasingSine((t.getEndTime()-e)/this._fadeOutSeconds);return r=r*i*n,t.setState(e,r),ye(0<=r&&r<=1),r}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}setLoop(t){this._isLoop=t}getLoop(){return this._isLoop}setLoopFadeIn(t){this._isLoopFadeIn=t}getLoopFadeIn(){return this._isLoopFadeIn}getFiredEvent(t,e){return this._firedEventValues}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){return null}getModelOpacityValue(){return 1}adjustEndTime(t){let e=this.getDuration(),r=e<=0?-1:t.getStartTime()+e;t.setEndTime(r)}},mw;(s=>{s.ACubismMotion=Rn})(mw||(mw={}));var XI="FadeInTime",jI="FadeOutTime",gw="Parameters",YI="Id",$I="Value",Bu="Blend",qI="Add",KI="Multiply",ZI="Overwrite",_w=1,Tg=class xr extends Rn{static create(t,e){let r=new xr;return r.parse(t,e),r}doUpdateParameters(t,e,r,i){for(let n=0;n<this._parameters.getSize();++n){let o=this._parameters.at(n);switch(o.blendType){case 0:{t.addParameterValueById(o.parameterId,o.value,r);break}case 1:{t.multiplyParameterValueById(o.parameterId,o.value,r);break}case 2:{t.setParameterValueById(o.parameterId,o.value,r);break}}}}calculateExpressionParameters(t,e,r,i,n,o){if(!(r==null||i==null)&&r.isAvailable()){this._fadeWeight=this.updateFadeWeight(r,e);for(let a=0;a<i.getSize();++a){let l=i.at(a);if(l.parameterId==null)continue;let h=l.overwriteValue=t.getParameterValueById(l.parameterId),u=this.getExpressionParameters(),c=-1;for(let _=0;_<u.getSize();++_)if(l.parameterId==u.at(_).parameterId){c=_;break}if(c<0){n==0?(l.additiveValue=xr.DefaultAdditiveValue,l.multiplyValue=xr.DefaultMultiplyValue,l.overwriteValue=h):(l.additiveValue=this.calculateValue(l.additiveValue,xr.DefaultAdditiveValue,o),l.multiplyValue=this.calculateValue(l.multiplyValue,xr.DefaultMultiplyValue,o),l.overwriteValue=this.calculateValue(l.overwriteValue,h,o));continue}let f=u.at(c).value,d,m,g;switch(u.at(c).blendType){case 0:d=f,m=xr.DefaultMultiplyValue,g=h;break;case 1:d=xr.DefaultAdditiveValue,m=f,g=h;break;case 2:d=xr.DefaultAdditiveValue,m=xr.DefaultMultiplyValue,g=f;break;default:return}n==0?(l.additiveValue=d,l.multiplyValue=m,l.overwriteValue=g):(l.additiveValue=l.additiveValue*(1-o)+d*o,l.multiplyValue=l.multiplyValue*(1-o)+m*o,l.overwriteValue=l.overwriteValue*(1-o)+g*o)}}}getExpressionParameters(){return this._parameters}getFadeWeight(){return this._fadeWeight}parse(t,e){let r=Ie.create(t,e);if(!r)return;let i=r.getRoot();this.setFadeInTime(i.getValueByString(XI).toFloat(_w)),this.setFadeOutTime(i.getValueByString(jI).toFloat(_w));let n=i.getValueByString(gw).getSize();this._parameters.prepareCapacity(n);for(let o=0;o<n;++o){let a=i.getValueByString(gw).getValueByIndex(o),l=bt.getIdManager().getId(a.getValueByString(YI).getRawString()),h=a.getValueByString($I).toFloat(),u;a.getValueByString(Bu).isNull()||a.getValueByString(Bu).getString()==qI?u=0:a.getValueByString(Bu).getString()==KI?u=1:a.getValueByString(Bu).getString()==ZI?u=2:u=0;let c=new Zu;c.parameterId=l,c.blendType=u,c.value=h,this._parameters.pushBack(c)}Ie.delete(r)}calculateValue(t,e,r){return t*(1-r)+e*r}constructor(){super(),this._parameters=new X,this._fadeWeight=0}};Tg.DefaultAdditiveValue=0;Tg.DefaultMultiplyValue=1;var ug=Tg,PE=(s=>(s[s.Additive=0]="Additive",s[s.Multiply=1]="Multiply",s[s.Overwrite=2]="Overwrite",s))(PE||{}),Zu=class{},xw;(s=>{s.CubismExpressionMotion=ug,s.ExpressionBlendType=PE,s.ExpressionParameter=Zu})(xw||(xw={}));var Ju=class{constructor(){this._autoDelete=!1,this._motion=null,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&Rn.delete(this._motion)}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,e){let r=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||r<this._endTimeSeconds)&&(this._endTimeSeconds=r)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,e){this._stateTimeSeconds=t,this._stateWeight=e}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}getCubismMotion(){return this._motion}},yw;(s=>{s.CubismMotionQueueEntry=Ju})(yw||(yw={}));var In=class{constructor(){this._userTimeSeconds=0,this._eventCallBack=null,this._eventCustomData=null,this._motions=new X}release(){for(let t=0;t<this._motions.getSize();++t)this._motions.at(t)&&(this._motions.at(t).release(),this._motions.set(t,null));this._motions=null}startMotion(t,e,r){if(t==null)return ME;let i=null;for(let n=0;n<this._motions.getSize();++n)i=this._motions.at(n),i?.setFadeOut(i._motion.getFadeOutTime());return i=new Ju,i._autoDelete=e,i._motion=t,this._motions.pushBack(i),i._motionQueueEntryHandle}isFinished(){for(let t=this._motions.begin();t.notEqual(this._motions.end());){let e=t.ptr();if(e==null){t=this._motions.erase(t);continue}if(e._motion==null){e.release(),e=null,t=this._motions.erase(t);continue}if(e.isFinished())t.preIncrement();else return!1}return!0}isFinishedByHandle(t){for(let e=this._motions.begin();e.notEqual(this._motions.end());e.increment()){let r=e.ptr();if(r!=null&&r._motionQueueEntryHandle==t&&!r.isFinished())return!1}return!0}stopAllMotions(){for(let t=this._motions.begin();t.notEqual(this._motions.end());){let e=t.ptr();if(e==null){t=this._motions.erase(t);continue}e.release(),e=null,t=this._motions.erase(t)}}getCubismMotionQueueEntries(){return this._motions}getCubismMotionQueueEntry(t){for(let e=this._motions.begin();e.notEqual(this._motions.end());e.preIncrement()){let r=e.ptr();if(r!=null&&r._motionQueueEntryHandle==t)return r}return null}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let r=!1;for(let i=this._motions.begin();i.notEqual(this._motions.end());){let n=i.ptr();if(n==null){i=this._motions.erase(i);continue}let o=n._motion;if(o==null){n.release(),n=null,i=this._motions.erase(i);continue}o.updateParameters(t,n,e),r=!0;let a=o.getFiredEvent(n.getLastCheckEventSeconds()-n.getStartTime(),e-n.getStartTime());for(let l=0;l<a.getSize();++l)this._eventCallBack(this,a.at(l),this._eventCustomData);n.setLastCheckEventSeconds(e),n.isFinished()?(n.release(),n=null,i=this._motions.erase(i)):(n.isTriggeredFadeOut()&&n.startFadeOut(n.getFadeOutSeconds(),e),i.preIncrement())}return r}},ME=-1,bw;(s=>{s.CubismMotionQueueManager=In,s.InvalidMotionQueueEntryHandleValue=ME})(bw||(bw={}));var cg=class extends Wu{constructor(t,e){var r,i;super(t,e),M(this,"expressionDataType","arraybuffer"),M(this,"queueManager",new In),M(this,"definitions"),this.definitions=(i=(r=t.expressions)==null?void 0:r.filter(n=>!!n&&typeof n.File=="string"))!=null?i:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex(e=>e.Name===t)}getExpressionFile(t){return t.File}createExpression(t,e){return ug.create(t,t.byteLength)}_setExpression(t){return this.queueManager.startMotion(t,!1)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}createDefaultExpression(){let t=new TextEncoder().encode(JSON.stringify({FadeInTime:0,FadeOutTime:0,Parameters:[]})).buffer;return ug.create(t,t.byteLength)}},sr=(s=>(s[s.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",s[s.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",s[s.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",s))(sr||{}),Xt=(s=>(s[s.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",s[s.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",s[s.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",s[s.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",s))(Xt||{}),li=class{constructor(){this.time=0,this.value=0}},Qu=class{constructor(){this.evaluate=null,this.basePointIndex=0,this.segmentType=0}},tc=class{constructor(){this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}},ec=class{constructor(){this.fireTime=0}},rc=class{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=new X,this.segments=new X,this.points=new X,this.events=new X}},vw;(s=>{s.CubismMotionCurve=tc,s.CubismMotionCurveTarget=sr,s.CubismMotionData=rc,s.CubismMotionEvent=ec,s.CubismMotionPoint=li,s.CubismMotionSegment=Qu,s.CubismMotionSegmentType=Xt})(vw||(vw={}));var we="Meta",JI="Duration",QI="Loop",tF="AreBeziersRestricted",eF="CurveCount",rF="Fps",sF="TotalSegmentCount",iF="TotalPointCount",Hr="Curves",nF="Target",oF="Id",Ru="FadeInTime",Iu="FadeOutTime",Sw="Segments",Tw="UserData",aF="UserDataCount",lF="TotalUserDataSize",hF="Time",uF="Value",Ka=class{constructor(t,e){this._json=Ie.create(t,e)}release(){Ie.delete(this._json)}getMotionDuration(){return this._json.getRoot().getValueByString(we).getValueByString(JI).toFloat()}isMotionLoop(){return this._json.getRoot().getValueByString(we).getValueByString(QI).toBoolean()}hasConsistency(){let t=!0;if(!this._json||!this._json.getRoot())return!1;let e=this._json.getRoot().getValueByString(Hr).getVector().getSize(),r=0,i=0;for(let n=0;n<e;++n)for(let o=0;o<this.getMotionCurveSegmentCount(n);){switch(o==0&&(i+=1,o+=2),this.getMotionCurveSegment(n,o)){case Xt.CubismMotionSegmentType_Linear:i+=1,o+=3;break;case Xt.CubismMotionSegmentType_Bezier:i+=3,o+=7;break;case Xt.CubismMotionSegmentType_Stepped:i+=1,o+=3;break;case Xt.CubismMotionSegmentType_InverseStepped:i+=1,o+=3;break;default:ye(0);break}++r}return e!=this.getMotionCurveCount()&&(dt("The number of curves does not match the metadata."),t=!1),r!=this.getMotionTotalSegmentCount()&&(dt("The number of segment does not match the metadata."),t=!1),i!=this.getMotionTotalPointCount()&&(dt("The number of point does not match the metadata."),t=!1),t}getEvaluationOptionFlag(t){return t==0?this._json.getRoot().getValueByString(we).getValueByString(tF).toBoolean():!1}getMotionCurveCount(){return this._json.getRoot().getValueByString(we).getValueByString(eF).toInt()}getMotionFps(){return this._json.getRoot().getValueByString(we).getValueByString(rF).toFloat()}getMotionTotalSegmentCount(){return this._json.getRoot().getValueByString(we).getValueByString(sF).toInt()}getMotionTotalPointCount(){return this._json.getRoot().getValueByString(we).getValueByString(iF).toInt()}isExistMotionFadeInTime(){return!this._json.getRoot().getValueByString(we).getValueByString(Ru).isNull()}isExistMotionFadeOutTime(){return!this._json.getRoot().getValueByString(we).getValueByString(Iu).isNull()}getMotionFadeInTime(){return this._json.getRoot().getValueByString(we).getValueByString(Ru).toFloat()}getMotionFadeOutTime(){return this._json.getRoot().getValueByString(we).getValueByString(Iu).toFloat()}getMotionCurveTarget(t){return this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(nF).getRawString()}getMotionCurveId(t){return bt.getIdManager().getId(this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(oF).getRawString())}isExistMotionCurveFadeInTime(t){return!this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(Ru).isNull()}isExistMotionCurveFadeOutTime(t){return!this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(Iu).isNull()}getMotionCurveFadeInTime(t){return this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(Ru).toFloat()}getMotionCurveFadeOutTime(t){return this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(Iu).toFloat()}getMotionCurveSegmentCount(t){return this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(Sw).getVector().getSize()}getMotionCurveSegment(t,e){return this._json.getRoot().getValueByString(Hr).getValueByIndex(t).getValueByString(Sw).getValueByIndex(e).toFloat()}getEventCount(){return this._json.getRoot().getValueByString(we).getValueByString(aF).toInt()}getTotalEventValueSize(){return this._json.getRoot().getValueByString(we).getValueByString(lF).toInt()}getEventTime(t){return this._json.getRoot().getValueByString(Tw).getValueByIndex(t).getValueByString(hF).toFloat()}getEventValue(t){return new Be(this._json.getRoot().getValueByString(Tw).getValueByIndex(t).getValueByString(uF).getRawString())}},wE=(s=>(s[s.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",s))(wE||{}),Cw;(s=>{s.CubismMotionJson=Ka})(Cw||(Cw={}));var cF="EyeBlink",dF="LipSync",fF="Model",pF="Parameter",mF="PartOpacity",Fu="Opacity",gF=!1;function je(s,t,e){let r=new li;return r.time=s.time+(t.time-s.time)*e,r.value=s.value+(t.value-s.value)*e,r}function EE(s,t){let e=(t-s[0].time)/(s[1].time-s[0].time);return e<0&&(e=0),s[0].value+(s[1].value-s[0].value)*e}function _F(s,t){let e=(t-s[0].time)/(s[3].time-s[0].time);e<0&&(e=0);let r=je(s[0],s[1],e),i=je(s[1],s[2],e),n=je(s[2],s[3],e),o=je(r,i,e),a=je(i,n,e);return je(o,a,e).value}function xF(s,t){let e=t,r=s[0].time,i=s[3].time,n=s[1].time,o=s[2].time,a=i-3*o+3*n-r,l=3*o-6*n+3*r,h=3*n-3*r,u=r-e,c=st.cardanoAlgorithmForBezier(a,l,h,u),f=je(s[0],s[1],c),d=je(s[1],s[2],c),m=je(s[2],s[3],c),g=je(f,d,c),_=je(d,m,c);return je(g,_,c).value}function AE(s,t){return s[0].value}function BE(s,t){return s[1].value}function Ym(s,t,e,r,i){let n=s.curves.at(t),o=-1,a=n.baseSegmentIndex+n.segmentCount,l=0;for(let u=n.baseSegmentIndex;u<a;++u)if(l=s.segments.at(u).basePointIndex+(s.segments.at(u).segmentType==Xt.CubismMotionSegmentType_Bezier?3:1),s.points.at(l).time>e){o=u;break}if(o==-1)return r&&e<i?yF(s,a-1,s.segments.at(n.baseSegmentIndex).basePointIndex,l,e,i):s.points.at(l).value;let h=s.segments.at(o);return h.evaluate(s.points.get(h.basePointIndex),e)}function yF(s,t,e,r,i,n){let o=[new li,new li];{let a=s.points.at(r);o[0].time=a.time,o[0].value=a.value}{let a=s.points.at(e);o[1].time=n,o[1].value=a.value}switch(s.segments.at(t).segmentType){case Xt.CubismMotionSegmentType_Linear:case Xt.CubismMotionSegmentType_Bezier:default:return EE(o,i);case Xt.CubismMotionSegmentType_Stepped:return AE(o);case Xt.CubismMotionSegmentType_InverseStepped:return BE(o)}}var sc=class s extends Rn{constructor(){super(),this._motionBehavior=1,this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._motionData=null,this._modelCurveIdEyeBlink=null,this._modelCurveIdLipSync=null,this._modelCurveIdOpacity=null,this._eyeBlinkParameterIds=null,this._lipSyncParameterIds=null,this._modelOpacity=1,this._debugMode=!1}static create(t,e,r,i,n=!1){let o=new s;if(o.parse(t,e,n),o._motionData)o._sourceFrameRate=o._motionData.fps,o._loopDurationSeconds=o._motionData.duration,o._onFinishedMotion=r,o._onBeganMotion=i;else return lE(o),null;return o}doUpdateParameters(t,e,r,i){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=bt.getIdManager().getId(cF)),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=bt.getIdManager().getId(dF)),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=bt.getIdManager().getId(Fu)),this._motionBehavior===1&&this._previousLoopState!==this._isLoop&&(this.adjustEndTime(i),this._previousLoopState=this._isLoop);let n=e-i.getStartTime();n<0&&(n=0);let o=Number.MAX_VALUE,a=Number.MAX_VALUE,l=64,h=0,u=0;this._eyeBlinkParameterIds.getSize()>l&&Xa("too many eye blink targets : {0}",this._eyeBlinkParameterIds.getSize()),this._lipSyncParameterIds.getSize()>l&&Xa("too many lip sync targets : {0}",this._lipSyncParameterIds.getSize());let c=this._fadeInSeconds<=0?1:st.getEasingSine((e-i.getFadeInStartTime())/this._fadeInSeconds),f=this._fadeOutSeconds<=0||i.getEndTime()<0?1:st.getEasingSine((i.getEndTime()-e)/this._fadeOutSeconds),d,m,g,_=n,x=this._motionData.duration,S=this._motionBehavior===1&&this._isLoop;if(this._isLoop)for(this._motionBehavior===1&&(x+=1/this._motionData.fps);_>x;)_-=x;let v=this._motionData.curves;for(m=0;m<this._motionData.curveCount&&v.at(m).type==sr.CubismMotionCurveTarget_Model;++m)d=Ym(this._motionData,m,_,S,x),v.at(m).id==this._modelCurveIdEyeBlink?a=d:v.at(m).id==this._modelCurveIdLipSync?o=d:v.at(m).id==this._modelCurveIdOpacity&&(this._modelOpacity=d,t.setModelOapcity(this.getModelOpacityValue()));for(;m<this._motionData.curveCount&&v.at(m).type==sr.CubismMotionCurveTarget_Parameter;++m){if(g=t.getParameterIndex(v.at(m).id),g==-1)continue;let b=t.getParameterValueByIndex(g);if(d=Ym(this._motionData,m,_,S,x),a!=Number.MAX_VALUE){for(let T=0;T<this._eyeBlinkParameterIds.getSize()&&T<l;++T)if(this._eyeBlinkParameterIds.at(T)==v.at(m).id){d*=a,u|=1<<T;break}}if(o!=Number.MAX_VALUE){for(let T=0;T<this._lipSyncParameterIds.getSize()&&T<l;++T)if(this._lipSyncParameterIds.at(T)==v.at(m).id){d+=o,h|=1<<T;break}}t.isRepeat(g)&&(d=t.getParameterRepeatValue(g,d));let C;if(v.at(m).fadeInTime<0&&v.at(m).fadeOutTime<0)C=b+(d-b)*r;else{let T,P;v.at(m).fadeInTime<0?T=c:T=v.at(m).fadeInTime==0?1:st.getEasingSine((e-i.getFadeInStartTime())/v.at(m).fadeInTime),v.at(m).fadeOutTime<0?P=f:P=v.at(m).fadeOutTime==0||i.getEndTime()<0?1:st.getEasingSine((i.getEndTime()-e)/v.at(m).fadeOutTime);let E=this._weight*T*P;C=b+(d-b)*E}t.setParameterValueByIndex(g,C,1)}{if(a!=Number.MAX_VALUE)for(let b=0;b<this._eyeBlinkParameterIds.getSize()&&b<l;++b){let C=t.getParameterValueById(this._eyeBlinkParameterIds.at(b));if(u>>b&1)continue;let T=C+(a-C)*r;t.setParameterValueById(this._eyeBlinkParameterIds.at(b),T)}if(o!=Number.MAX_VALUE)for(let b=0;b<this._lipSyncParameterIds.getSize()&&b<l;++b){let C=t.getParameterValueById(this._lipSyncParameterIds.at(b));if(h>>b&1)continue;let T=C+(o-C)*r;t.setParameterValueById(this._lipSyncParameterIds.at(b),T)}}for(;m<this._motionData.curveCount&&v.at(m).type==sr.CubismMotionCurveTarget_PartOpacity;++m)g=t.getParameterIndex(v.at(m).id),g!=-1&&(d=Ym(this._motionData,m,_,S,x),t.setParameterValueByIndex(g,d));n>=x&&(this._isLoop?this.updateForNextLoop(i,e,_):(this._onFinishedMotion&&this._onFinishedMotion(this),i.setIsFinished(!0))),this._lastWeight=r}setIsLoop(t){dt("setIsLoop() is a deprecated function. Please use setLoop()."),this._isLoop=t}isLoop(){return dt("isLoop() is a deprecated function. Please use getLoop()."),this._isLoop}setIsLoopFadeIn(t){dt("setIsLoopFadeIn() is a deprecated function. Please use setLoopFadeIn()."),this._isLoopFadeIn=t}isLoopFadeIn(){return dt("isLoopFadeIn() is a deprecated function. Please use getLoopFadeIn()."),this._isLoopFadeIn}setMotionBehavior(t){this._motionBehavior=t}getMotionBehavior(){return this._motionBehavior}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,e){let r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r.at(i).id){r.at(i).fadeInTime=e;return}}setParameterFadeOutTime(t,e){let r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r.at(i).id){r.at(i).fadeOutTime=e;return}}getParameterFadeInTime(t){let e=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==e.at(r).id)return e.at(r).fadeInTime;return-1}getParameterFadeOutTime(t){let e=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(t==e.at(r).id)return e.at(r).fadeOutTime;return-1}setEffectIds(t,e){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=e}release(){this._motionData=void 0,this._motionData=null}updateForNextLoop(t,e,r){switch(this._motionBehavior){case 1:default:t.setStartTime(e-r),this._isLoopFadeIn&&t.setFadeInStartTime(e-r),this._onFinishedMotion!=null&&this._onFinishedMotion(this);break;case 0:t.setStartTime(e),this._isLoopFadeIn&&t.setFadeInStartTime(e);break}}parse(t,e,r=!1){let i=new Ka(t,e);if(!i){i.release(),i=void 0;return}if(r&&!i.hasConsistency()){i.release(),be("Inconsistent motion3.json.");return}this._motionData=new rc,this._motionData.duration=i.getMotionDuration(),this._motionData.loop=i.isMotionLoop(),this._motionData.curveCount=i.getMotionCurveCount(),this._motionData.fps=i.getMotionFps(),this._motionData.eventCount=i.getEventCount();let n=i.getEvaluationOptionFlag(wE.EvaluationOptionFlag_AreBeziersRistricted);i.isExistMotionFadeInTime()?this._fadeInSeconds=i.getMotionFadeInTime()<0?1:i.getMotionFadeInTime():this._fadeInSeconds=1,i.isExistMotionFadeOutTime()?this._fadeOutSeconds=i.getMotionFadeOutTime()<0?1:i.getMotionFadeOutTime():this._fadeOutSeconds=1,this._motionData.curves.updateSize(this._motionData.curveCount,tc,!0),this._motionData.segments.updateSize(i.getMotionTotalSegmentCount(),Qu,!0),this._motionData.points.updateSize(i.getMotionTotalPointCount(),li,!0),this._motionData.events.updateSize(this._motionData.eventCount,ec,!0);let o=0,a=0;for(let l=0;l<this._motionData.curveCount;++l){i.getMotionCurveTarget(l)==fF?this._motionData.curves.at(l).type=sr.CubismMotionCurveTarget_Model:i.getMotionCurveTarget(l)==pF?this._motionData.curves.at(l).type=sr.CubismMotionCurveTarget_Parameter:i.getMotionCurveTarget(l)==mF?this._motionData.curves.at(l).type=sr.CubismMotionCurveTarget_PartOpacity:dt('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'),this._motionData.curves.at(l).id=i.getMotionCurveId(l),this._motionData.curves.at(l).baseSegmentIndex=a,this._motionData.curves.at(l).fadeInTime=i.isExistMotionCurveFadeInTime(l)?i.getMotionCurveFadeInTime(l):-1,this._motionData.curves.at(l).fadeOutTime=i.isExistMotionCurveFadeOutTime(l)?i.getMotionCurveFadeOutTime(l):-1;for(let h=0;h<i.getMotionCurveSegmentCount(l);){switch(h==0?(this._motionData.segments.at(a).basePointIndex=o,this._motionData.points.at(o).time=i.getMotionCurveSegment(l,h),this._motionData.points.at(o).value=i.getMotionCurveSegment(l,h+1),o+=1,h+=2):this._motionData.segments.at(a).basePointIndex=o-1,i.getMotionCurveSegment(l,h)){case Xt.CubismMotionSegmentType_Linear:{this._motionData.segments.at(a).segmentType=Xt.CubismMotionSegmentType_Linear,this._motionData.segments.at(a).evaluate=EE,this._motionData.points.at(o).time=i.getMotionCurveSegment(l,h+1),this._motionData.points.at(o).value=i.getMotionCurveSegment(l,h+2),o+=1,h+=3;break}case Xt.CubismMotionSegmentType_Bezier:{this._motionData.segments.at(a).segmentType=Xt.CubismMotionSegmentType_Bezier,n||gF?this._motionData.segments.at(a).evaluate=_F:this._motionData.segments.at(a).evaluate=xF,this._motionData.points.at(o).time=i.getMotionCurveSegment(l,h+1),this._motionData.points.at(o).value=i.getMotionCurveSegment(l,h+2),this._motionData.points.at(o+1).time=i.getMotionCurveSegment(l,h+3),this._motionData.points.at(o+1).value=i.getMotionCurveSegment(l,h+4),this._motionData.points.at(o+2).time=i.getMotionCurveSegment(l,h+5),this._motionData.points.at(o+2).value=i.getMotionCurveSegment(l,h+6),o+=3,h+=7;break}case Xt.CubismMotionSegmentType_Stepped:{this._motionData.segments.at(a).segmentType=Xt.CubismMotionSegmentType_Stepped,this._motionData.segments.at(a).evaluate=AE,this._motionData.points.at(o).time=i.getMotionCurveSegment(l,h+1),this._motionData.points.at(o).value=i.getMotionCurveSegment(l,h+2),o+=1,h+=3;break}case Xt.CubismMotionSegmentType_InverseStepped:{this._motionData.segments.at(a).segmentType=Xt.CubismMotionSegmentType_InverseStepped,this._motionData.segments.at(a).evaluate=BE,this._motionData.points.at(o).time=i.getMotionCurveSegment(l,h+1),this._motionData.points.at(o).value=i.getMotionCurveSegment(l,h+2),o+=1,h+=3;break}default:{ye(0);break}}++this._motionData.curves.at(l).segmentCount,++a}}for(let l=0;l<i.getEventCount();++l)this._motionData.events.at(l).fireTime=i.getEventTime(l),this._motionData.events.at(l).value=i.getEventValue(l);i.release(),i=void 0,i=null}getFiredEvent(t,e){this._firedEventValues.updateSize(0);for(let r=0;r<this._motionData.eventCount;++r)this._motionData.events.at(r).fireTime>t&&this._motionData.events.at(r).fireTime<=e&&this._firedEventValues.pushBack(new Be(this._motionData.events.at(r).value.s));return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){let e=this._motionData.curves.at(t);if(e.type==sr.CubismMotionCurveTarget_Model&&e.id.getString().s.localeCompare(Fu)==0)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){let e=this._motionData.curves.at(t);if(e.type==sr.CubismMotionCurveTarget_Model&&e.id.getString().s.localeCompare(Fu)==0)return t}return-1}getModelOpacityId(t){if(t!=-1){let e=this._motionData.curves.at(t);if(e.type==sr.CubismMotionCurveTarget_Model&&e.id.getString().s.localeCompare(Fu)==0)return bt.getIdManager().getId(e.id.getString().s)}return null}getModelOpacityValue(){return this._modelOpacity}setDebugMode(t){this._debugMode=t}},Pw;(s=>{s.CubismMotion=sc})(Pw||(Pw={}));function RE(s,t,e){let r=s.startMotion(e,!1),i=s.getCubismMotionQueueEntry(r);if(!i)return!1;i.setStartTime(0),i.setFadeInStartTime(0);let n=e.getDuration(),o=i.getStartTime()+n;return e.doUpdateParameters(t.coreModel,o,1,i),i.setIsFinished(!0),!0}var dg=class extends ju{constructor(t){var e;super(t),M(this,"definitions"),M(this,"groups",{idle:"Idle"}),M(this,"motionDataType","arraybuffer"),M(this,"queueManager",new In),M(this,"expressionManager"),M(this,"eyeBlinkIds"),M(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=(e=t.settings.motions)!=null?e:{},this.eyeBlinkIds=t.settings.getEyeBlinkParameters()||[];let r=t.settings.getLipSyncParameters();r?.length&&(this.lipSyncIds=r),this.init(t.options)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new cg(this.settings,t)),this.queueManager.setEventCallback((e,r)=>{let i=typeof r=="string"?r:typeof r=="number"?String(r):r&&typeof r=="object"?r.s:"undefined";this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e,r,i){if(t.setFinishedMotionHandler(e),t.setLoop(i??t._motionData.loop),r&&r.length>0){let n=t._motionData.curves,o=SF(n),a=Mw(n);for(let l=0;l<a;l++){let h=bF(n,l);if(!h)continue;let u=vF(h);(!u||!r.includes(u))&&TF(o,h)}t._motionData.curves=o,t._motionData.curveCount=Mw(o)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,e,r){let i=!!this.parent.options.checkMotionConsistency,n=sc.create(t,t.byteLength,void 0,void 0,i),o=new Ka(t,t.byteLength);n.setLoop(o.isMotionLoop());let a=(e===this.groups.idle?Ae.idleMotionFadingDuration:Ae.motionFadingDuration)/1e3;return o.getMotionFadeInTime()===void 0&&n.setFadeInTime(r.FadeInTime>0?r.FadeInTime:a),o.getMotionFadeOutTime()===void 0&&n.setFadeOutTime(r.FadeOutTime>0?r.FadeOutTime:a),n.setEffectIds(this.createIdVector(this.eyeBlinkIds),this.createIdVector(this.lipSyncIds)),n}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}motionLastFrame(t,e){return vt(this,arguments,function*(r,i,{expression:n=void 0}={}){let o=yield this.getMotionAndApplyExpression(r,i,n);return o?(this.playing=!0,RE(this.queueManager,this.parent,o),this.playing=!1,!0):!1})}createIdVector(t){let e=new X,r=bt.getIdManager();for(let i of t)e.pushBack(r.getId(i));return e}};function wc(s){return typeof s.pushBack=="function"}function Mw(s){return wc(s)?s.getSize():s.length}function bF(s,t){return wc(s)?s.at(t):s[t]}function vF(s){if(!s||typeof s!="object")return;let t=s.id;if(typeof t=="string")return t;if(t&&typeof t.getString=="function")return t.getString().s}function SF(s){return wc(s)?new X:[]}function TF(s,t){wc(s)?s.pushBack(t):s.push(t)}var fg=class extends q{constructor(t){super(),M(this,"tag"),M(this,"manager"),M(this,"settings"),M(this,"state",new Xu),M(this,"playing",!1),M(this,"destroyed",!1),M(this,"parent"),this.settings=t.settings,this.tag=`ParallelMotionManager(${this.settings.name})`,this.state.tag=this.tag,this.manager=t.motionManager,this.parent=t}startMotion(t,e){return vt(this,arguments,function*(r,i,n=ir.NORMAL,o={}){var a;let{ignoreParamIds:l=[],loop:h}=Array.isArray(o)?{ignoreParamIds:o,loop:void 0}:o;if(!this.state.reserve(r,i,n))return!1;let u=(a=this.manager.definitions[r])==null?void 0:a[i];if(!u)return!1;let c=yield this.manager.loadMotion(r,i);return this.state.start(c,r,i,n)?(tt.log(this.tag,"Start motion:",this.getMotionName(u)),this.emit("motionStart",r,i,void 0),this.playing=!0,this._startMotion(c,void 0,l,h),!0):!1})}startRandomMotion(t,e){return vt(this,arguments,function*(r,i,{loop:n=void 0}={}){var o;let a=this.manager.definitions[r];if(a?.length){let l=[],h=(o=this.manager.motionGroups[r])!=null?o:[];for(let u=0;u<a.length;u++)h[u]!==null&&!this.state.isActive(r,u)&&l.push(u);if(l.length){let u=l[Math.floor(Math.random()*l.length)];return this.startMotion(r,u,i,{loop:n})}}return!1})}stopAllMotions(){this._stopAllMotions(),this.state.reset()}update(t,e){return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.complete()),this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy"),this.stopAllMotions()}},pg=class extends fg{constructor(t){super(t),M(this,"queueManager",new In),this.init()}init(){this.queueManager.setEventCallback((t,e)=>{let r=typeof e=="string"?e:typeof e=="number"?String(e):e&&typeof e=="object"?e.s:"undefined";this.emit("motion:"+r)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e,r,i){if(t.setFinishedMotionHandler(e),t.setLoop(i??t._motionData.loop),r&&r.length>0){let n=t._motionData.curves,o=MF(n),a=ww(n);for(let l=0;l<a;l++){let h=CF(n,l);if(!h)continue;let u=PF(h);(!u||!r.includes(u))&&wF(o,h)}t._motionData.curves=o,t._motionData.curveCount=ww(o)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}getMotionName(t){return t.File}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}playMotionLastFrame(t,e){return vt(this,null,function*(){var r;if(!this.state.reserve(t,e,ir.FORCE))return!1;let i=(r=this.manager.definitions[t])==null?void 0:r[e];if(!i)return!1;let n=yield this.manager.loadMotion(t,e);return this.state.start(n,t,e,ir.FORCE)?(tt.log(this.tag,"Start motion:",this.getMotionName(i)),this.emit("motionStart",t,e,void 0),this.playing=!0,this.queueManager.stopAllMotions(),RE(this.queueManager,this.parent,n)?(this.playing=!1,!0):(this.playing=!1,!1)):!1})}};function Ec(s){return typeof s.pushBack=="function"}function ww(s){return Ec(s)?s.getSize():s.length}function CF(s,t){return Ec(s)?s.at(t):s[t]}function PF(s){if(!s||typeof s!="object")return;let t=s.id;if(typeof t=="string")return t;if(t&&typeof t.getString=="function")return t.getString().s}function MF(s){return Ec(s)?new X:[]}function wF(s,t){Ec(s)?s.pushBack(t):s.push(t)}var z=Object.freeze({HitAreaPrefix:"HitArea",HitAreaHead:"Head",HitAreaBody:"Body",PartsIdCore:"Parts01Core",PartsArmPrefix:"Parts01Arm_",PartsArmLPrefix:"Parts01ArmL_",PartsArmRPrefix:"Parts01ArmR_",ParamAngleX:"ParamAngleX",ParamAngleY:"ParamAngleY",ParamAngleZ:"ParamAngleZ",ParamEyeLOpen:"ParamEyeLOpen",ParamEyeLSmile:"ParamEyeLSmile",ParamEyeROpen:"ParamEyeROpen",ParamEyeRSmile:"ParamEyeRSmile",ParamEyeBallX:"ParamEyeBallX",ParamEyeBallY:"ParamEyeBallY",ParamEyeBallForm:"ParamEyeBallForm",ParamBrowLY:"ParamBrowLY",ParamBrowRY:"ParamBrowRY",ParamBrowLX:"ParamBrowLX",ParamBrowRX:"ParamBrowRX",ParamBrowLAngle:"ParamBrowLAngle",ParamBrowRAngle:"ParamBrowRAngle",ParamBrowLForm:"ParamBrowLForm",ParamBrowRForm:"ParamBrowRForm",ParamMouthForm:"ParamMouthForm",ParamMouthOpenY:"ParamMouthOpenY",ParamCheek:"ParamCheek",ParamBodyAngleX:"ParamBodyAngleX",ParamBodyAngleY:"ParamBodyAngleY",ParamBodyAngleZ:"ParamBodyAngleZ",ParamBreath:"ParamBreath",ParamArmLA:"ParamArmLA",ParamArmRA:"ParamArmRA",ParamArmLB:"ParamArmLB",ParamArmRB:"ParamArmRB",ParamHandL:"ParamHandL",ParamHandR:"ParamHandR",ParamHairFront:"ParamHairFront",ParamHairSide:"ParamHairSide",ParamHairBack:"ParamHairBack",ParamHairFluffy:"ParamHairFluffy",ParamShoulderY:"ParamShoulderY",ParamBustX:"ParamBustX",ParamBustY:"ParamBustY",ParamBaseX:"ParamBaseX",ParamBaseY:"ParamBaseY",ParamNONE:"NONE:"}),Ew;(s=>{s.HitAreaBody=z.HitAreaBody,s.HitAreaHead=z.HitAreaHead,s.HitAreaPrefix=z.HitAreaPrefix,s.ParamAngleX=z.ParamAngleX,s.ParamAngleY=z.ParamAngleY,s.ParamAngleZ=z.ParamAngleZ,s.ParamArmLA=z.ParamArmLA,s.ParamArmLB=z.ParamArmLB,s.ParamArmRA=z.ParamArmRA,s.ParamArmRB=z.ParamArmRB,s.ParamBaseX=z.ParamBaseX,s.ParamBaseY=z.ParamBaseY,s.ParamBodyAngleX=z.ParamBodyAngleX,s.ParamBodyAngleY=z.ParamBodyAngleY,s.ParamBodyAngleZ=z.ParamBodyAngleZ,s.ParamBreath=z.ParamBreath,s.ParamBrowLAngle=z.ParamBrowLAngle,s.ParamBrowLForm=z.ParamBrowLForm,s.ParamBrowLX=z.ParamBrowLX,s.ParamBrowLY=z.ParamBrowLY,s.ParamBrowRAngle=z.ParamBrowRAngle,s.ParamBrowRForm=z.ParamBrowRForm,s.ParamBrowRX=z.ParamBrowRX,s.ParamBrowRY=z.ParamBrowRY,s.ParamBustX=z.ParamBustX,s.ParamBustY=z.ParamBustY,s.ParamCheek=z.ParamCheek,s.ParamEyeBallForm=z.ParamEyeBallForm,s.ParamEyeBallX=z.ParamEyeBallX,s.ParamEyeBallY=z.ParamEyeBallY,s.ParamEyeLOpen=z.ParamEyeLOpen,s.ParamEyeLSmile=z.ParamEyeLSmile,s.ParamEyeROpen=z.ParamEyeROpen,s.ParamEyeRSmile=z.ParamEyeRSmile,s.ParamHairBack=z.ParamHairBack,s.ParamHairFluffy=z.ParamHairFluffy,s.ParamHairFront=z.ParamHairFront,s.ParamHairSide=z.ParamHairSide,s.ParamHandL=z.ParamHandL,s.ParamHandR=z.ParamHandR,s.ParamMouthForm=z.ParamMouthForm,s.ParamMouthOpenY=z.ParamMouthOpenY,s.ParamNONE=z.ParamNONE,s.ParamShoulderY=z.ParamShoulderY,s.PartsArmLPrefix=z.PartsArmLPrefix,s.PartsArmPrefix=z.PartsArmPrefix,s.PartsArmRPrefix=z.PartsArmRPrefix,s.PartsIdCore=z.PartsIdCore})(Ew||(Ew={}));var ic=class s{static create(){return new s}static delete(t){}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;let r=this._currentTime*2*Math.PI;for(let i=0;i<this._breathParameters.getSize();++i){let n=this._breathParameters.at(i);t.addParameterValueById(n.parameterId,n.offset+n.peak*Math.sin(r/n.cycle),n.weight)}}constructor(){this._currentTime=0}},ds=class{constructor(t,e,r,i,n){this.parameterId=t??null,this.offset=e??0,this.peak=r??0,this.cycle=i??0,this.weight=n??0}},Aw;(s=>{s.BreathParameterData=ds,s.CubismBreath=ic})(Aw||(Aw={}));var IE=class mg{static create(t=null){return new mg(t)}static delete(t){}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,e,r){this._closingSeconds=t,this._closedSeconds=e,this._openingSeconds=r}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,e){this._userTimeSeconds+=e;let r,i=0;switch(this._blinkingState){case 2:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,i>=1&&(i=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),r=1-i;break;case 3:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,i>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),r=0;break;case 4:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,i>=1&&(i=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),r=i;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),r=1;break;case 0:default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),r=1;break}mg.CloseIfZero||(r=-r);for(let o=0;o<this._parameterIds.getSize();++o)t.setParameterValueById(this._parameterIds.at(o),r)}constructor(t){if(this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new X,t!=null)for(let e=0;e<t.getEyeBlinkParameterCount();++e)this._parameterIds.pushBack(t.getEyeBlinkParameterId(e))}determinNextBlinkingTiming(){let t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};IE.CloseIfZero=!0;var FE=IE,kE=(s=>(s[s.EyeState_First=0]="EyeState_First",s[s.EyeState_Interval=1]="EyeState_Interval",s[s.EyeState_Closing=2]="EyeState_Closing",s[s.EyeState_Closed=3]="EyeState_Closed",s[s.EyeState_Opening=4]="EyeState_Opening",s))(kE||{}),Bw;(s=>{s.CubismEyeBlink=FE,s.EyeState=kE})(Bw||(Bw={}));var $m=4,EF=36,AF=32,gg=class{constructor(t){this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=new X,this._clippingContextListForDraw=new X,this._channelColors=new X,this._tmpBoundsOnModel=new wn,this._tmpMatrix=new vr,this._tmpMatrixForMask=new vr,this._tmpMatrixForDraw=new vr,this._clippingContexttConstructor=t;let e=new le;e.r=1,e.g=0,e.b=0,e.a=0,this._channelColors.pushBack(e),e=new le,e.r=0,e.g=1,e.b=0,e.a=0,this._channelColors.pushBack(e),e=new le,e.r=0,e.g=0,e.b=1,e.a=0,this._channelColors.pushBack(e),e=new le,e.r=0,e.g=0,e.b=0,e.a=1,this._channelColors.pushBack(e)}release(){for(let t=0;t<this._clippingContextListForMask.getSize();t++)this._clippingContextListForMask.at(t)&&(this._clippingContextListForMask.at(t).release(),this._clippingContextListForMask.set(t,void 0)),this._clippingContextListForMask.set(t,null);this._clippingContextListForMask=null;for(let t=0;t<this._clippingContextListForDraw.getSize();t++)this._clippingContextListForDraw.set(t,null);this._clippingContextListForDraw=null;for(let t=0;t<this._channelColors.getSize();t++)this._channelColors.set(t,null);this._channelColors=null,this._clearedFrameBufferFlags!=null&&this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=null}initialize(t,e){e%1!=0&&(dt("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),e=~~e),e<1&&dt("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=e<1?1:e,this._clearedFrameBufferFlags=new X(this._renderTextureCount);for(let r=0;r<t.getDrawableCount();r++){if(t.getDrawableMaskCounts()[r]<=0){this._clippingContextListForDraw.pushBack(null);continue}let i=this.findSameClip(t.getDrawableMasks()[r],t.getDrawableMaskCounts()[r]);i==null&&(i=new this._clippingContexttConstructor(this,t.getDrawableMasks()[r],t.getDrawableMaskCounts()[r]),this._clippingContextListForMask.pushBack(i)),i.addClippedDrawable(r),this._clippingContextListForDraw.pushBack(i)}}findSameClip(t,e){for(let r=0;r<this._clippingContextListForMask.getSize();r++){let i=this._clippingContextListForMask.at(r),n=i._clippingIdCount;if(n!=e)continue;let o=0;for(let a=0;a<n;a++){let l=i._clippingIdList[a];for(let h=0;h<n;h++)if(t[h]==l){o++;break}}if(o==n)return i}return null}setupMatrixForHighPrecision(t,e){let r=0;for(let i=0;i<this._clippingContextListForMask.getSize();i++){let n=this._clippingContextListForMask.at(i);this.calcClippedDrawTotalBounds(t,n),n._isUsing&&r++}if(r>0){if(this.setupLayoutBounds(0),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount){this._clearedFrameBufferFlags.clear();for(let i=0;i<this._renderTextureCount;i++)this._clearedFrameBufferFlags.pushBack(!1)}else for(let i=0;i<this._renderTextureCount;i++)this._clearedFrameBufferFlags.set(i,!1);for(let i=0;i<this._clippingContextListForMask.getSize();i++){let n=this._clippingContextListForMask.at(i),o=n._allClippedDrawRect,a=n._layoutBounds,l=.05,h=0,u=0,c=t.getPixelsPerUnit(),f=n.getClippingManager().getClippingMaskBufferSize(),d=a.width*f,m=a.height*f;this._tmpBoundsOnModel.setRect(o),this._tmpBoundsOnModel.width*c>d?(this._tmpBoundsOnModel.expand(o.width*l,0),h=a.width/this._tmpBoundsOnModel.width):h=c/d,this._tmpBoundsOnModel.height*c>m?(this._tmpBoundsOnModel.expand(0,o.height*l),u=a.height/this._tmpBoundsOnModel.height):u=c/m,this.createMatrixForMask(e,a,h,u),n._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),n._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray())}}}createMatrixForMask(t,e,r,i){this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(e.x,e.y),this._tmpMatrix.scaleRelative(r,i),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(e.x,e.y*(t?-1:1)),this._tmpMatrix.scaleRelative(r,i*(t?-1:1)),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray())}setupLayoutBounds(t){let e=this._renderTextureCount<=1?EF:AF*this._renderTextureCount;if(t<=0||t>e){t>e&&be(`not supported mask count : {0}
982
+ [Details] render texture count : {1}, mask count : {2}`,t-e,this._renderTextureCount,t);for(let h=0;h<this._clippingContextListForMask.getSize();h++){let u=this._clippingContextListForMask.at(h);u._layoutChannelIndex=0,u._layoutBounds.x=0,u._layoutBounds.y=0,u._layoutBounds.width=1,u._layoutBounds.height=1,u._bufferIndex=0}return}let r=this._renderTextureCount<=1?9:8,i=t/this._renderTextureCount,n=t%this._renderTextureCount;i=Math.ceil(i);let o=i/$m,a=i%$m;o=~~o;let l=0;for(let h=0;h<this._renderTextureCount;h++)for(let u=0;u<$m;u++){let c=o+(u<a?1:0),f=a+(o<1?-1:0);if(u==f&&n>0&&(c-=h<n?0:1),c!=0)if(c==1){let d=this._clippingContextListForMask.at(l++);d._layoutChannelIndex=u,d._layoutBounds.x=0,d._layoutBounds.y=0,d._layoutBounds.width=1,d._layoutBounds.height=1,d._bufferIndex=h}else if(c==2)for(let d=0;d<c;d++){let m=d%2;m=~~m;let g=this._clippingContextListForMask.at(l++);g._layoutChannelIndex=u,g._layoutBounds.x=m*.5,g._layoutBounds.y=0,g._layoutBounds.width=.5,g._layoutBounds.height=1,g._bufferIndex=h}else if(c<=4)for(let d=0;d<c;d++){let m=d%2,g=d/2;m=~~m,g=~~g;let _=this._clippingContextListForMask.at(l++);_._layoutChannelIndex=u,_._layoutBounds.x=m*.5,_._layoutBounds.y=g*.5,_._layoutBounds.width=.5,_._layoutBounds.height=.5,_._bufferIndex=h}else if(c<=r)for(let d=0;d<c;d++){let m=d%3,g=d/3;m=~~m,g=~~g;let _=this._clippingContextListForMask.at(l++);_._layoutChannelIndex=u,_._layoutBounds.x=m/3,_._layoutBounds.y=g/3,_._layoutBounds.width=1/3,_._layoutBounds.height=1/3,_._bufferIndex=h}else{be(`not supported mask count : {0}
983
+ [Details] render texture count : {1}, mask count : {2}`,t-e,this._renderTextureCount,t);for(let d=0;d<c;d++){let m=this._clippingContextListForMask.at(l++);m._layoutChannelIndex=0,m._layoutBounds.x=0,m._layoutBounds.y=0,m._layoutBounds.width=1,m._layoutBounds.height=1,m._bufferIndex=0}}}}calcClippedDrawTotalBounds(t,e){let r=Number.MAX_VALUE,i=Number.MAX_VALUE,n=Number.MIN_VALUE,o=Number.MIN_VALUE,a=e._clippedDrawableIndexList.length;for(let l=0;l<a;l++){let h=e._clippedDrawableIndexList[l],u=t.getDrawableVertexCount(h),c=t.getDrawableVertices(h),f=Number.MAX_VALUE,d=Number.MAX_VALUE,m=-Number.MAX_VALUE,g=-Number.MAX_VALUE,_=u*Ou.vertexStep;for(let x=Ou.vertexOffset;x<_;x+=Ou.vertexStep){let S=c[x],v=c[x+1];S<f&&(f=S),S>m&&(m=S),v<d&&(d=v),v>g&&(g=v)}if(f!=Number.MAX_VALUE)if(f<r&&(r=f),d<i&&(i=d),m>n&&(n=m),g>o&&(o=g),r==Number.MAX_VALUE)e._allClippedDrawRect.x=0,e._allClippedDrawRect.y=0,e._allClippedDrawRect.width=0,e._allClippedDrawRect.height=0,e._isUsing=!1;else{e._isUsing=!0;let x=n-r,S=o-i;e._allClippedDrawRect.x=r,e._allClippedDrawRect.y=i,e._allClippedDrawRect.width=x,e._allClippedDrawRect.height=S}}}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}getChannelFlagAsColor(t){return this._channelColors.at(t)}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}},Sn,BF=10,nc=class{constructor(){this._shaderSets=new X}release(){this.releaseShaderProgram()}setupShaderProgramForDraw(t,e,r){t.isPremultipliedAlpha()||be("NoPremultipliedAlpha is not allowed"),this._shaderSets.getSize()==0&&this.generateShaders();let i,n,o,a,l=t.getClippingContextBufferForDraw()!=null,h=e.getDrawableInvertedMaskBit(r),u=l?h?2:1:0,c;switch(e.getDrawableBlendMode(r)){case ms.CubismBlendMode_Normal:default:c=this._shaderSets.at(1+u),i=this.gl.ONE,n=this.gl.ONE_MINUS_SRC_ALPHA,o=this.gl.ONE,a=this.gl.ONE_MINUS_SRC_ALPHA;break;case ms.CubismBlendMode_Additive:c=this._shaderSets.at(4+u),i=this.gl.ONE,n=this.gl.ONE,o=this.gl.ZERO,a=this.gl.ONE;break;case ms.CubismBlendMode_Multiplicative:c=this._shaderSets.at(7+u),i=this.gl.DST_COLOR,n=this.gl.ONE_MINUS_SRC_ALPHA,o=this.gl.ZERO,a=this.gl.ONE;break}this.gl.useProgram(c.shaderProgram),t._bufferData.vertex==null&&(t._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.vertex);let f=e.getDrawableVertices(r);this.gl.bufferData(this.gl.ARRAY_BUFFER,f,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(c.attributePositionLocation),this.gl.vertexAttribPointer(c.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),t._bufferData.uv==null&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);let d=e.getDrawableVertexUvs(r);if(this.gl.bufferData(this.gl.ARRAY_BUFFER,d,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(c.attributeTexCoordLocation),this.gl.vertexAttribPointer(c.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),l){this.gl.activeTexture(this.gl.TEXTURE1);let C=t.getClippingContextBufferForDraw().getClippingManager().getColorBuffer().at(t.getClippingContextBufferForDraw()._bufferIndex);this.gl.bindTexture(this.gl.TEXTURE_2D,C),this.gl.uniform1i(c.samplerTexture1Location,1),this.gl.uniformMatrix4fv(c.uniformClipMatrixLocation,!1,t.getClippingContextBufferForDraw()._matrixForDraw.getArray());let T=t.getClippingContextBufferForDraw()._layoutChannelIndex,P=t.getClippingContextBufferForDraw().getClippingManager().getChannelFlagAsColor(T);this.gl.uniform4f(c.uniformChannelFlagLocation,P.r,P.g,P.b,P.a)}let m=e.getDrawableTextureIndex(r),g=t.getBindedTextures().getValue(m);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,g),this.gl.uniform1i(c.samplerTexture0Location,0);let _=t.getMvpMatrix();this.gl.uniformMatrix4fv(c.uniformMatrixLocation,!1,_.getArray());let x=t.getModelColorWithOpacity(e.getDrawableOpacity(r)),S=e.getMultiplyColor(r),v=e.getScreenColor(r);this.gl.uniform4f(c.uniformBaseColorLocation,x.r,x.g,x.b,x.a),this.gl.uniform4f(c.uniformMultiplyColorLocation,S.r,S.g,S.b,S.a),this.gl.uniform4f(c.uniformScreenColorLocation,v.r,v.g,v.b,v.a),t._bufferData.index==null&&(t._bufferData.index=this.gl.createBuffer());let b=e.getDrawableVertexIndices(r);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,b,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(i,n,o,a)}setupShaderProgramForMask(t,e,r){t.isPremultipliedAlpha()||be("NoPremultipliedAlpha is not allowed"),this._shaderSets.getSize()==0&&this.generateShaders();let i=this._shaderSets.at(0);this.gl.useProgram(i.shaderProgram),t._bufferData.vertex==null&&(t._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.vertex);let n=e.getDrawableVertices(r);this.gl.bufferData(this.gl.ARRAY_BUFFER,n,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(i.attributePositionLocation),this.gl.vertexAttribPointer(i.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),t._bufferData.uv==null&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);let o=e.getDrawableTextureIndex(r),a=t.getBindedTextures().getValue(o);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.uniform1i(i.samplerTexture0Location,0),t._bufferData.uv==null&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);let l=e.getDrawableVertexUvs(r);this.gl.bufferData(this.gl.ARRAY_BUFFER,l,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(i.attributeTexCoordLocation),this.gl.vertexAttribPointer(i.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),t.getClippingContextBufferForMask();let h=t.getClippingContextBufferForMask()._layoutChannelIndex,u=t.getClippingContextBufferForMask().getClippingManager().getChannelFlagAsColor(h);this.gl.uniform4f(i.uniformChannelFlagLocation,u.r,u.g,u.b,u.a),this.gl.uniformMatrix4fv(i.uniformClipMatrixLocation,!1,t.getClippingContextBufferForMask()._matrixForMask.getArray());let c=t.getClippingContextBufferForMask()._layoutBounds;this.gl.uniform4f(i.uniformBaseColorLocation,c.x*2-1,c.y*2-1,c.getRight()*2-1,c.getBottom()*2-1);let f=e.getMultiplyColor(r),d=e.getScreenColor(r);this.gl.uniform4f(i.uniformMultiplyColorLocation,f.r,f.g,f.b,f.a),this.gl.uniform4f(i.uniformScreenColorLocation,d.r,d.g,d.b,d.a);let m=this.gl.ZERO,g=this.gl.ONE_MINUS_SRC_COLOR,_=this.gl.ZERO,x=this.gl.ONE_MINUS_SRC_ALPHA;t._bufferData.index==null&&(t._bufferData.index=this.gl.createBuffer());let S=e.getDrawableVertexIndices(r);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,S,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(m,g,_,x)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.getSize();t++)this.gl.deleteProgram(this._shaderSets.at(t).shaderProgram),this._shaderSets.at(t).shaderProgram=0,this._shaderSets.set(t,void 0),this._shaderSets.set(t,null)}generateShaders(){for(let t=0;t<BF;t++)this._shaderSets.pushBack(new oc);this._shaderSets.at(0).shaderProgram=this.loadShaderProgram(RF,IF),this._shaderSets.at(1).shaderProgram=this.loadShaderProgram(FF,kF),this._shaderSets.at(2).shaderProgram=this.loadShaderProgram(Rw,LF),this._shaderSets.at(3).shaderProgram=this.loadShaderProgram(Rw,DF),this._shaderSets.at(4).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(5).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(6).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(7).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(8).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(9).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(0).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,"a_position"),this._shaderSets.at(0).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,"a_texCoord"),this._shaderSets.at(0).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"s_texture0"),this._shaderSets.at(0).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_clipMatrix"),this._shaderSets.at(0).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_channelFlag"),this._shaderSets.at(0).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_baseColor"),this._shaderSets.at(0).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_multiplyColor"),this._shaderSets.at(0).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_screenColor"),this._shaderSets.at(1).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,"a_position"),this._shaderSets.at(1).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,"a_texCoord"),this._shaderSets.at(1).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"s_texture0"),this._shaderSets.at(1).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_matrix"),this._shaderSets.at(1).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_baseColor"),this._shaderSets.at(1).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_multiplyColor"),this._shaderSets.at(1).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_screenColor"),this._shaderSets.at(2).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,"a_position"),this._shaderSets.at(2).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,"a_texCoord"),this._shaderSets.at(2).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"s_texture0"),this._shaderSets.at(2).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"s_texture1"),this._shaderSets.at(2).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_matrix"),this._shaderSets.at(2).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_clipMatrix"),this._shaderSets.at(2).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_channelFlag"),this._shaderSets.at(2).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_baseColor"),this._shaderSets.at(2).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_multiplyColor"),this._shaderSets.at(2).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_screenColor"),this._shaderSets.at(3).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,"a_position"),this._shaderSets.at(3).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,"a_texCoord"),this._shaderSets.at(3).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"s_texture0"),this._shaderSets.at(3).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"s_texture1"),this._shaderSets.at(3).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_matrix"),this._shaderSets.at(3).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_clipMatrix"),this._shaderSets.at(3).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_channelFlag"),this._shaderSets.at(3).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_baseColor"),this._shaderSets.at(3).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_multiplyColor"),this._shaderSets.at(3).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_screenColor"),this._shaderSets.at(4).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,"a_position"),this._shaderSets.at(4).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,"a_texCoord"),this._shaderSets.at(4).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"s_texture0"),this._shaderSets.at(4).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_matrix"),this._shaderSets.at(4).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_baseColor"),this._shaderSets.at(4).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_multiplyColor"),this._shaderSets.at(4).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_screenColor"),this._shaderSets.at(5).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,"a_position"),this._shaderSets.at(5).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,"a_texCoord"),this._shaderSets.at(5).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"s_texture0"),this._shaderSets.at(5).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"s_texture1"),this._shaderSets.at(5).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_matrix"),this._shaderSets.at(5).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_clipMatrix"),this._shaderSets.at(5).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_channelFlag"),this._shaderSets.at(5).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_baseColor"),this._shaderSets.at(5).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_multiplyColor"),this._shaderSets.at(5).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_screenColor"),this._shaderSets.at(6).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,"a_position"),this._shaderSets.at(6).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,"a_texCoord"),this._shaderSets.at(6).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"s_texture0"),this._shaderSets.at(6).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"s_texture1"),this._shaderSets.at(6).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_matrix"),this._shaderSets.at(6).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_clipMatrix"),this._shaderSets.at(6).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_channelFlag"),this._shaderSets.at(6).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_baseColor"),this._shaderSets.at(6).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_multiplyColor"),this._shaderSets.at(6).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_screenColor"),this._shaderSets.at(7).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,"a_position"),this._shaderSets.at(7).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,"a_texCoord"),this._shaderSets.at(7).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"s_texture0"),this._shaderSets.at(7).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_matrix"),this._shaderSets.at(7).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_baseColor"),this._shaderSets.at(7).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_multiplyColor"),this._shaderSets.at(7).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_screenColor"),this._shaderSets.at(8).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,"a_position"),this._shaderSets.at(8).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,"a_texCoord"),this._shaderSets.at(8).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"s_texture0"),this._shaderSets.at(8).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"s_texture1"),this._shaderSets.at(8).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_matrix"),this._shaderSets.at(8).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_clipMatrix"),this._shaderSets.at(8).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_channelFlag"),this._shaderSets.at(8).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_baseColor"),this._shaderSets.at(8).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_multiplyColor"),this._shaderSets.at(8).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_screenColor"),this._shaderSets.at(9).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,"a_position"),this._shaderSets.at(9).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,"a_texCoord"),this._shaderSets.at(9).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"s_texture0"),this._shaderSets.at(9).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"s_texture1"),this._shaderSets.at(9).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_matrix"),this._shaderSets.at(9).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_clipMatrix"),this._shaderSets.at(9).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_channelFlag"),this._shaderSets.at(9).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_baseColor"),this._shaderSets.at(9).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_multiplyColor"),this._shaderSets.at(9).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_screenColor")}loadShaderProgram(t,e){let r=this.gl.createProgram(),i=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!i)return be("Vertex shader compile error!"),0;let n=this.compileShaderSource(this.gl.FRAGMENT_SHADER,e);return n?(this.gl.attachShader(r,i),this.gl.attachShader(r,n),this.gl.linkProgram(r),this.gl.getProgramParameter(r,this.gl.LINK_STATUS)?(this.gl.deleteShader(i),this.gl.deleteShader(n),r):(be("Failed to link program: {0}",r),this.gl.deleteShader(i),i=0,this.gl.deleteShader(n),n=0,r&&(this.gl.deleteProgram(r),r=0),0)):(be("Vertex shader compile error!"),0)}compileShaderSource(t,e){let r=e,i=this.gl.createShader(t);if(this.gl.shaderSource(i,r),this.gl.compileShader(i),!i){let o=this.gl.getShaderInfoLog(i);be("Shader compile log: {0} ",o)}return this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS)?i:(this.gl.deleteShader(i),null)}setGl(t){this.gl=t}},ps=class s{static getInstance(){return Sn==null&&(Sn=new s),Sn}static deleteInstance(){Sn&&(Sn.release(),Sn=null)}constructor(){this._shaderMap=new Xr}release(){for(let t=this._shaderMap.begin();t.notEqual(this._shaderMap.end());t.preIncrement())t.ptr().second.release();this._shaderMap.clear()}getShader(t){return this._shaderMap.getValue(t)}setGlContext(t){if(!this._shaderMap.isExist(t)){let e=new nc;e.setGl(t),this._shaderMap.setValue(t,e)}}},oc=class{},LE=(s=>(s[s.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",s[s.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",s[s.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",s[s.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",s[s.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",s[s.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",s[s.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",s[s.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",s[s.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",s[s.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",s))(LE||{}),RF="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",IF="precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}",FF="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Rw="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",kF="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",LF="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}",DF="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}",Iw;(s=>{s.CubismShaderSet=oc,s.CubismShader_WebGL=nc,s.CubismShaderManager_WebGL=ps,s.ShaderNames=LE})(Iw||(Iw={}));var Wr,ac,Za=class extends gg{getMaskRenderTexture(){if(this._maskTexture&&this._maskTexture.textures!=null)this._maskTexture.frameNo=this._currentFrameNo;else{this._maskRenderTextures!=null&&this._maskRenderTextures.clear(),this._maskRenderTextures=new X,this._maskColorBuffers!=null&&this._maskColorBuffers.clear(),this._maskColorBuffers=new X;let t=this._clippingMaskBufferSize;for(let e=0;e<this._renderTextureCount;e++)this._maskColorBuffers.pushBack(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers.at(e)),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.pushBack(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures.at(e)),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers.at(e),0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,ac),this._maskTexture=new lc(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}constructor(){super(hc)}setupClippingContext(t,e){this._currentFrameNo++;let r=0;for(let i=0;i<this._clippingContextListForMask.getSize();i++){let n=this._clippingContextListForMask.at(i);this.calcClippedDrawTotalBounds(t,n),n._isUsing&&r++}if(r>0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture().at(0),e.preDraw(),this.setupLayoutBounds(r),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount&&(this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=new X(this._renderTextureCount));for(let i=0;i<this._clearedFrameBufferFlags.getSize();i++)this._clearedFrameBufferFlags.set(i,!1);for(let i=0;i<this._clippingContextListForMask.getSize();i++){let n=this._clippingContextListForMask.at(i),o=n._allClippedDrawRect,a=n._layoutBounds,l=.05,h=0,u=0,c=this.getMaskRenderTexture().at(n._bufferIndex);this._currentMaskRenderTexture!=c&&(this._currentMaskRenderTexture=c,e.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._tmpBoundsOnModel.setRect(o),this._tmpBoundsOnModel.expand(o.width*l,o.height*l),h=a.width/this._tmpBoundsOnModel.width,u=a.height/this._tmpBoundsOnModel.height,this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(h,u),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(h,u),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),n._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),n._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());let f=n._clippingIdCount;for(let d=0;d<f;d++){let m=n._clippingIdList[d];t.getDrawableDynamicFlagVertexPositionsDidChange(m)&&(e.setIsCulling(t.getDrawableCulling(m)!=!1),this._clearedFrameBufferFlags.at(n._bufferIndex)||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferFlags.set(n._bufferIndex,!0)),e.setClippingContextBufferForMask(n),e.drawMeshWebGL(t,m))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,ac),e.setClippingContextBufferForMask(null),this.gl.viewport(Wr[0],Wr[1],Wr[2],Wr[3])}}getColorBuffer(){return this._maskColorBuffers}getClippingMaskCount(){return this._clippingContextListForMask.getSize()}},lc=class{constructor(t,e){this.frameNo=t,this.textures=e}},hc=class extends sg{constructor(t,e,r){super(e,r),this._owner=t}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}},_g=class{setGlEnable(t,e){e?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,e){e?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){if(this.gl==null){be(`'gl' is null. WebGLRenderingContext is required.
984
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastElementArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)}restore(){if(this.gl==null){be(`'gl' is null. WebGLRenderingContext is required.
985
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}},Ja=class extends En{initialize(t,e=1){t.isUsingMasking()&&(this._clippingManager=new Za,this._clippingManager.initialize(t,e)),this._sortedDrawableIndexList.resize(t.getDrawableCount(),0),super.initialize(t)}bindTexture(t,e){this._textures.setValue(t,e)}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;let e=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=void 0,this._clippingManager=null,this._clippingManager=new Za,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),e)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new _g,this.firstDraw=!0,this._textures=new Xr,this._sortedDrawableIndexList=new X,this._bufferData={vertex:WebGLBuffer=null,uv:WebGLBuffer=null,index:WebGLBuffer=null},this._textures.prepareCapacity(32,!0)}release(){this._clippingManager&&(this._clippingManager.release(),this._clippingManager=void 0,this._clippingManager=null),this.gl!=null&&(this.gl.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,this.gl.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,this.gl.deleteBuffer(this._bufferData.index),this._bufferData.index=null,this._bufferData=null,this._textures=null)}doDrawModel(){if(this.gl==null){be(`'gl' is null. WebGLRenderingContext is required.
986
+ Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._clippingManager!=null&&(this.preDraw(),this.isUsingHighPrecisionMask()?this._clippingManager.setupMatrixForHighPrecision(this.getModel(),!1):this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();let t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let r=0;r<t;++r){let i=e[r];this._sortedDrawableIndexList.set(i,r)}for(let r=0;r<t;++r){let i=this._sortedDrawableIndexList.at(r);if(!this.getModel().getDrawableDynamicFlagIsVisible(i))continue;let n=this._clippingManager!=null?this._clippingManager.getClippingContextListForDraw().at(i):null;if(n!=null&&this.isUsingHighPrecisionMask()){n._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,n.getClippingManager().getMaskRenderTexture().at(n._bufferIndex)),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{let o=n._clippingIdCount;for(let a=0;a<o;a++){let l=n._clippingIdList[a];this._model.getDrawableDynamicFlagVertexPositionsDidChange(l)&&(this.setIsCulling(this._model.getDrawableCulling(l)!=!1),this.setClippingContextBufferForMask(n),this.drawMeshWebGL(this._model,l))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,ac),this.setClippingContextBufferForMask(null),this.gl.viewport(Wr[0],Wr[1],Wr[2],Wr[3]),this.preDraw()}this.setClippingContextBufferForDraw(n),this.setIsCulling(this.getModel().getDrawableCulling(i)),this.drawMeshWebGL(this._model,i)}}drawMeshWebGL(t,e){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),this.isGeneratingMask()?ps.getInstance().getShader(this.gl).setupShaderProgramForMask(this,t,e):ps.getInstance().getShader(this.gl).setupShaderProgramForDraw(this,t,e);{let r=t.getDrawableVertexIndexCount(e);this.gl.drawElements(this.gl.TRIANGLES,r,this.gl.UNSIGNED_SHORT,0)}this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){ps.deleteInstance()}setRenderState(t,e){ac=t,Wr=e}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(let t=0;t<this._textures.getSize();++t)this.gl.bindTexture(this.gl.TEXTURE_2D,this._textures.getValue(t)),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}isGeneratingMask(){return this.getClippingContextBufferForMask()!=null}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),ps.getInstance().setGlContext(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}};En.staticRelease=()=>{Ja.doStaticRelease()};var Fw;(s=>{s.CubismClippingContext=hc,s.CubismClippingManager_WebGL=Za,s.CubismRenderTextureResource=lc,s.CubismRenderer_WebGL=Ja})(Fw||(Fw={}));var kw=new vr,OF=36,GF=32,UF=16,VF=64,NF=3,HF=4096,zF=.5,WF=24,XF={CenterX:"centerX",centerX:"centerX",center_x:"centerX",CenterY:"centerY",centerY:"centerY",center_y:"centerY",X:"x",x:"x",Y:"y",y:"y",Width:"width",width:"width",Height:"height",height:"height",Top:"top",top:"top",Bottom:"bottom",bottom:"bottom",Left:"left",left:"left",Right:"right",right:"right"};function jF(s){var t;if(!s.isUsingMasking())return 1;let e=s.getDrawableMaskCounts(),r=s.getDrawableMasks(),i=new Set;for(let o=0;o<s.getDrawableCount();o++){let a=e[o];if(!a||a<=0)continue;let l=Array.from((t=r[o])!=null?t:[]).slice(0,a).sort((h,u)=>h-u).join(",");i.add(l)}let n=i.size;return n<=OF?1:Math.ceil(n/GF)}function YF(s){var t,e;let r=s.getDrawableMaskCounts(),i=s.getDrawableMasks(),n=new Set,o=s.getDrawableCount(),a=0,l=0,h=0,u=0;for(let c=0;c<o;c++){let f=s.getDrawableVertexCount(c),d=(t=r[c])!=null?t:0;if(u+=f,d<=0)continue;a++,h+=f,l=Math.max(l,d);let m=Array.from((e=i[c])!=null?e:[]).slice(0,d).sort((g,_)=>g-_).join(",");n.add(m)}return{maskedDrawableCount:a,uniqueMaskSetCount:n.size,maxMasksPerDrawable:l,maskedVertexCount:h,totalVertexCount:u}}function $F(s){if(!s.isUsingMasking())return!1;let t=YF(s),e=t.totalVertexCount>0?t.maskedVertexCount/t.totalVertexCount:0;return t.uniqueMaskSetCount>UF||t.maskedDrawableCount>VF||t.maxMasksPerDrawable>=NF||t.maskedVertexCount>HF||e>=zF&&t.maskedDrawableCount>WF}function qF(s,t){return typeof t=="boolean"?t:$F(s)}var xg=class extends lg{constructor(t,e,r){super(),M(this,"settings"),M(this,"options"),M(this,"coreModel"),M(this,"motionManager"),M(this,"parallelMotionManager"),M(this,"lipSync",!0),M(this,"breath",ic.create()),M(this,"eyeBlink"),M(this,"renderer",new Ja),M(this,"idManager"),M(this,"idParamAngleX"),M(this,"idParamAngleY"),M(this,"idParamAngleZ"),M(this,"idParamEyeBallX"),M(this,"idParamEyeBallY"),M(this,"idParamBodyAngleX"),M(this,"idParamBreath"),M(this,"idParamMouthForm"),M(this,"pixelsPerUnit",1),M(this,"modelTransform",new R),this.coreModel=t,this.settings=e,this.options=Object.assign({},{breathDepth:1,lipSyncGain:1.5,lipSyncWeight:.4},r),this.idManager=bt.getIdManager(),this.idParamAngleX=this.getIdSafe(z.ParamAngleX),this.idParamAngleY=this.getIdSafe(z.ParamAngleY),this.idParamAngleZ=this.getIdSafe(z.ParamAngleZ),this.idParamEyeBallX=this.getIdSafe(z.ParamEyeBallX),this.idParamEyeBallY=this.getIdSafe(z.ParamEyeBallY),this.idParamBodyAngleX=this.getIdSafe(z.ParamBodyAngleX),this.idParamBreath=this.getIdSafe(z.ParamBreath),this.idParamMouthForm=this.getIdSafe(z.ParamMouthForm),this.motionManager=new dg(this),this.parallelMotionManager=[],this.init()}init(){var t;super.init();let e=this.settings.getEyeBlinkParameters();if(this.options.eyeBlink!==!1&&e.length){let i=new X;for(let o of e)i.pushBack(this.idManager.getId(o));let n=FE.create();(t=n.setParameterIds)==null||t.call(n,i),this.eyeBlink=n}let r=new X;r.pushBack(new ds(this.idParamAngleX,0,15*this.options.breathDepth,6.5345,.5)),r.pushBack(new ds(this.idParamAngleY,0,8*this.options.breathDepth,3.5345,.5)),r.pushBack(new ds(this.idParamAngleZ,0,10*this.options.breathDepth,5.5345,.5)),r.pushBack(new ds(this.idParamBodyAngleX,0,4*this.options.breathDepth,15.5345,.5)),r.pushBack(new ds(this.idParamBreath,0,.5,3.2345,.5)),this.breath.setParameters(r),this.renderer.initialize(this.coreModel,jF(this.coreModel)),this.renderer.useHighPrecisionMask(qF(this.coreModel,this.options.useHighPrecisionMask)),this.renderer.setIsPremultipliedAlpha(!0)}getIdSafe(t){return this.idManager.getId(t??"")}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){let t={},e=this.settings.layout;if(e)for(let[r,i]of Object.entries(e)){let n=XF[r];n&&typeof i=="number"&&(t[n]=i)}return t}setupLayout(){let t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1],t.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit;let r=PI(this.localTransform,this.originalWidth,this.originalHeight,this.getLayout());t.width=r.width,t.height=r.height,this.modelTransform.identity().scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(t,e){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager&&(this.renderer._clippingManager._currentFrameNo=e),ps.getInstance().setGlContext(t)}bindTexture(t,e){this.renderer.bindTexture(t,e)}getHitAreaDefs(){var t,e,r;let i=this.settings.json,n=(r=(e=(t=this.settings.hitAreas)!=null?t:i.HitAreas)!=null?e:i.hitAreas)!=null?r:i.hit_areas;return MI(n,o=>this.coreModel.getDrawableIndex(this.idManager.getId(o)))}getDrawableIDs(){let t=this.coreModel.getDrawableCount(),e=[];for(let r=0;r<t;r++)e.push(this.coreModel.getDrawableId(r).getString().s);return e}getDrawableIndex(t){return this.coreModel.getDrawableIndex(this.idManager.getId(t))}getDrawableVertices(t){if(typeof t=="string"){let r=t;if(t=this.getDrawableIndex(r),t===-1)throw new TypeError("Unable to find drawable ID: "+r)}let e=this.coreModel.getDrawableVertices(t).slice();for(let r=0;r<e.length;r+=2)e[r]=e[r]*this.pixelsPerUnit+this.originalWidth/2,e[r+1]=-e[r+1]*this.pixelsPerUnit+this.originalHeight/2;return e}updateTransform(t){this.drawingMatrix.copyFrom(this.modelTransform).prepend(this.localTransform).prepend(t)}update(t,e){var r,i,n,o,a;super.update(t,e),t/=1e3,e/=1e3;let l=this.coreModel,h=this.updateMotions(l,e);if(l.saveParameters(),(r=this.motionManager.expressionManager)==null||r.update(l,e),h||(n=(i=this.eyeBlink)==null?void 0:i.updateParameters)==null||n.call(i,l,t),this.updateFocus(),this.updateNaturalMovements(t*1e3,e*1e3),this.lipSync&&this.motionManager.currentAudio){let u=this.motionManager.mouthSync()*this.options.lipSyncGain;u=Math.pow(u,1.15);let c=u>0?.1:0;u=og(u,c,1),this.motionManager.lipSyncIds.forEach(d=>{l.addParameterValueById(this.getIdSafe(d),u,this.options.lipSyncWeight)})}(o=this.physics)==null||o.evaluate(l,t),(a=this.pose)==null||a.updateParameters(l,t),this.emit("beforeModelUpdate"),l.update(),l.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,e){var r;(r=this.breath)==null||r.updateParameters(this.coreModel,t/1e3)}draw(t){let e=this.drawingMatrix,r=kw.getArray();r[0]=e.a,r[1]=e.b,r[4]=-e.c,r[5]=-e.d,r[12]=e.tx,r[13]=e.ty,this.renderer.setMvpMatrix(kw);let i=t.getParameter(t.FRAMEBUFFER_BINDING),n=t.getParameter(t.CULL_FACE_MODE),o=r[0]*r[5]-r[1]*r[4];t.cullFace(o<0?t.FRONT:t.BACK),this.renderer.setRenderState(i,this.viewport);try{this.renderer.drawModel()}finally{t.cullFace(n)}}extendParallelMotionManager(t){for(;this.parallelMotionManager.length<t;)this.parallelMotionManager.push(new pg(this))}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}},uc=class{},Lw;(s=>{s.ICubismModelSetting=uc})(Lw||(Lw={}));var DE=(s=>(s[s.FrequestNode_Groups=0]="FrequestNode_Groups",s[s.FrequestNode_Moc=1]="FrequestNode_Moc",s[s.FrequestNode_Motions=2]="FrequestNode_Motions",s[s.FrequestNode_Expressions=3]="FrequestNode_Expressions",s[s.FrequestNode_Textures=4]="FrequestNode_Textures",s[s.FrequestNode_Physics=5]="FrequestNode_Physics",s[s.FrequestNode_Pose=6]="FrequestNode_Pose",s[s.FrequestNode_HitAreas=7]="FrequestNode_HitAreas",s))(DE||{}),Qa=class extends uc{constructor(t,e){super(),this.version="Version",this.fileReferences="FileReferences",this.groups="Groups",this.layout="Layout",this.hitAreas="HitAreas",this.moc="Moc",this.textures="Textures",this.physics="Physics",this.pose="Pose",this.expressions="Expressions",this.motions="Motions",this.userData="UserData",this.name="Name",this.filePath="File",this.id="Id",this.ids="Ids",this.target="Target",this.idle="Idle",this.tapBody="TapBody",this.pinchIn="PinchIn",this.pinchOut="PinchOut",this.shake="Shake",this.flickHead="FlickHead",this.parameter="Parameter",this.soundPath="Sound",this.fadeInTime="FadeInTime",this.fadeOutTime="FadeOutTime",this.centerX="CenterX",this.centerY="CenterY",this.x="X",this.y="Y",this.width="Width",this.height="Height",this.lipSync="LipSync",this.eyeBlink="EyeBlink",this.initParameter="init_param",this.initPartsVisible="init_parts_visible",this.val="val",this._json=Ie.create(t,e),this.getJson()&&(this._jsonValue=new X,this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.groups)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.moc)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.motions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.expressions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.textures)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.physics)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.pose)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.hitAreas)))}release(){Ie.delete(this._json),this._jsonValue=null}getJson(){return this._json}getModelFileName(){return this.isExistModelFile()?this._jsonValue.at(1).getRawString():""}getTextureCount(){return this.isExistTextureFiles()?this._jsonValue.at(4).getSize():0}getTextureDirectory(){let e=this._jsonValue.at(4).getValueByIndex(0).getRawString().split("/"),r=e.length-1,i="";for(let n=0;n<r;n++)i+=e[n],n<r-1&&(i+="/");return i}getTextureFileName(t){return this._jsonValue.at(4).getValueByIndex(t).getRawString()}getHitAreasCount(){return this.isExistHitAreas()?this._jsonValue.at(7).getSize():0}getHitAreaId(t){return bt.getIdManager().getId(this._jsonValue.at(7).getValueByIndex(t).getValueByString(this.id).getRawString())}getHitAreaName(t){return this._jsonValue.at(7).getValueByIndex(t).getValueByString(this.name).getRawString()}getPhysicsFileName(){return this.isExistPhysicsFile()?this._jsonValue.at(5).getRawString():""}getPoseFileName(){return this.isExistPoseFile()?this._jsonValue.at(6).getRawString():""}getExpressionCount(){return this.isExistExpressionFile()?this._jsonValue.at(3).getSize():0}getExpressionName(t){return this._jsonValue.at(3).getValueByIndex(t).getValueByString(this.name).getRawString()}getExpressionFileName(t){return this._jsonValue.at(3).getValueByIndex(t).getValueByString(this.filePath).getRawString()}getMotionGroupCount(){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().getSize():0}getMotionGroupName(t){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().at(t):null}getMotionCount(t){return this.isExistMotionGroupName(t)?this._jsonValue.at(2).getValueByString(t).getSize():0}getMotionFileName(t,e){return this.isExistMotionGroupName(t)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.filePath).getRawString():""}getMotionSoundFileName(t,e){return this.isExistMotionSoundFile(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath).getRawString():""}getMotionFadeInTimeValue(t,e){return this.isExistMotionFadeIn(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime).toFloat():-1}getMotionFadeOutTimeValue(t,e){return this.isExistMotionFadeOut(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime).toFloat():-1}getUserDataFile(){return this.isExistUserDataFile()?this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData).getRawString():""}getLayoutMap(t){let e=this.getJson().getRoot().getValueByString(this.layout).getMap();if(e==null)return!1;let r=!1;for(let i=e.begin();i.notEqual(e.end());i.preIncrement())t.setValue(i.ptr().first,i.ptr().second.toFloat()),r=!0;return r}getEyeBlinkParameterCount(){if(!this.isExistEyeBlinkParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(0).getSize();e++){let r=this._jsonValue.at(0).getValueByIndex(e);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.eyeBlink){t=r.getValueByString(this.ids).getVector().getSize();break}}return t}getEyeBlinkParameterId(t){if(!this.isExistEyeBlinkParameters())return null;for(let e=0;e<this._jsonValue.at(0).getSize();e++){let r=this._jsonValue.at(0).getValueByIndex(e);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.eyeBlink)return bt.getIdManager().getId(r.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}getLipSyncParameterCount(){if(!this.isExistLipSyncParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(0).getSize();e++){let r=this._jsonValue.at(0).getValueByIndex(e);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.lipSync){t=r.getValueByString(this.ids).getVector().getSize();break}}return t}getLipSyncParameterId(t){if(!this.isExistLipSyncParameters())return null;for(let e=0;e<this._jsonValue.at(0).getSize();e++){let r=this._jsonValue.at(0).getValueByIndex(e);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.lipSync)return bt.getIdManager().getId(r.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}isExistModelFile(){let t=this._jsonValue.at(1);return!t.isNull()&&!t.isError()}isExistTextureFiles(){let t=this._jsonValue.at(4);return!t.isNull()&&!t.isError()}isExistHitAreas(){let t=this._jsonValue.at(7);return!t.isNull()&&!t.isError()}isExistPhysicsFile(){let t=this._jsonValue.at(5);return!t.isNull()&&!t.isError()}isExistPoseFile(){let t=this._jsonValue.at(6);return!t.isNull()&&!t.isError()}isExistExpressionFile(){let t=this._jsonValue.at(3);return!t.isNull()&&!t.isError()}isExistMotionGroups(){let t=this._jsonValue.at(2);return!t.isNull()&&!t.isError()}isExistMotionGroupName(t){let e=this._jsonValue.at(2).getValueByString(t);return!e.isNull()&&!e.isError()}isExistMotionSoundFile(t,e){let r=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath);return!r.isNull()&&!r.isError()}isExistMotionFadeIn(t,e){let r=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime);return!r.isNull()&&!r.isError()}isExistMotionFadeOut(t,e){let r=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime);return!r.isNull()&&!r.isError()}isExistUserDataFile(){let t=this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData);return!t.isNull()&&!t.isError()}isExistEyeBlinkParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let t=0;t<this._jsonValue.at(0).getSize();++t)if(this._jsonValue.at(0).getValueByIndex(t).getValueByString(this.name).getRawString()==this.eyeBlink)return!0;return!1}isExistLipSyncParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let t=0;t<this._jsonValue.at(0).getSize();++t)if(this._jsonValue.at(0).getValueByIndex(t).getValueByString(this.name).getRawString()==this.lipSync)return!0;return!1}},Dw;(s=>{s.CubismModelSettingJson=Qa,s.FrequestNode=DE})(Dw||(Dw={}));var KF=[z.ParamEyeLOpen,z.ParamEyeROpen],Mn=class s extends Bn{constructor(t){var e,r;if(super(t),M(this,"moc"),M(this,"textures"),M(this,"layout"),M(this,"hitAreas"),M(this,"expressions"),M(this,"motions"),!s.isValidJSON(t))throw new TypeError("Invalid JSON.");let i=new TextEncoder().encode(JSON.stringify(t)).buffer;Object.assign(this,new Qa(i,i.byteLength)),this.moc=t.FileReferences.Moc,this.textures=[...t.FileReferences.Textures],this.pose=t.FileReferences.Pose,this.physics=t.FileReferences.Physics,this.expressions=(e=t.FileReferences.Expressions)==null?void 0:e.filter(o=>!!o&&typeof o.File=="string"),this.motions=(r=t.FileReferences.Motions)!=null?r:t.Motions,this.layout=t.Layout,this.hitAreas=t.HitAreas;let n=this.getFileStem(this.moc);this.setModelName(n,this.name)}static isValidJSON(t){if(!t||typeof t!="object")return!1;let e=t.FileReferences;if(!e||typeof e!="object"||typeof e.Moc!="string")return!1;let r=e.Textures;if(!Array.isArray(r)||r.length===0||!r.every(l=>typeof l=="string"))return!1;let n=e.Expressions,o=l=>!!l&&typeof l.File=="string";return!(n!==void 0&&(!Array.isArray(n)||n.some(l=>!o(l))))}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(let[e,r]of Object.entries(this.motions))for(let i=0;i<r.length;i++){let n=r[i];n?.File&&(n.File=t(n.File,`motions.${e}[${i}].File`),n.Sound&&(n.Sound=t(n.Sound,`motions.${e}[${i}].Sound`)))}if(this.expressions)for(let e=0;e<this.expressions.length;e++){let r=this.expressions[e];r?.File&&(r.File=t(r.File,`expressions[${e}].File`))}}getEyeBlinkParameters(){var t,e,r;let i=[],n=(e=(t=this.getEyeBlinkParameterCount)==null?void 0:t.call(this))!=null?e:0;if(n>0)for(let o=0;o<n;o++){let a=(r=this.getEyeBlinkParameterId)==null?void 0:r.call(this,o);a?.getString&&i.push(a.getString().s)}else{let o=!1,a=this.json.Groups;if(Array.isArray(a)){for(let l of a)if(l?.Name==="EyeBlink"&&(o=!0,!!Array.isArray(l.Ids)))for(let h of l.Ids)typeof h=="string"?i.push(h):h?.Id&&i.push(h.Id)}if(o)return i}return i.length?i:[...KF]}getLipSyncParameters(){var t,e,r;let i=[],n=(e=(t=this.getLipSyncParameterCount)==null?void 0:t.call(this))!=null?e:0;if(n>0)for(let o=0;o<n;o++){let a=(r=this.getLipSyncParameterId)==null?void 0:r.call(this,o);a?.getString&&i.push(a.getString().s)}else if(Array.isArray(this.json.Groups)){let o=this.json.Groups;for(let a of o)if(!(a?.Name!=="LipSync"||!Array.isArray(a.Ids)))for(let l of a.Ids)typeof l=="string"?i.push(l):l?.Id&&i.push(l.Id)}return i}};aI(Mn,[Qa]);var ku,Ow=20,OE=16;function GE(s={}){s.memorySizeMB!=null&&(OE=s.memorySizeMB)}function ZF(){return bt.isStarted()?Promise.resolve():(ku??(ku=new Promise((s,t)=>{function e(){try{JF(),s()}catch(r){if(Ow--,Ow<0){t(new Error("Failed to start up Cubism framework.",{cause:r}));return}tt.log("Cubism","Startup failed, retrying 10ms later..."),setTimeout(e,10)}}e()})),ku)}function JF(s,t){let e=Mc({logFunction:console.log,loggingLevel:ni.LogLevel_Verbose},s),r=t??OE;bt.startUp(e),bt.initialize(oI(r))}var QF=.001,qm=.5,Gw="FadeInTime",Uw="Link",tk="Groups",ek="Id",cc=class s{static create(t,e){let r=Ie.create(t,e);if(!r)return null;let i=new s,n=r.getRoot();n.getValueByString(Gw).isNull()||(i._fadeTimeSeconds=n.getValueByString(Gw).toFloat(qm),i._fadeTimeSeconds<0&&(i._fadeTimeSeconds=qm));let o=n.getValueByString(tk),a=o.getSize();for(let l=0;l<a;++l){let h=o.getValueByIndex(l),u=h.getSize(),c=0;for(let f=0;f<u;++f){let d=h.getValueByIndex(f),m=new tl,g=bt.getIdManager().getId(d.getValueByString(ek).getRawString());if(m.partId=g,!d.getValueByString(Uw).isNull()){let _=d.getValueByString(Uw),x=_.getSize();for(let S=0;S<x;++S){let v=new tl,b=bt.getIdManager().getId(_.getValueByIndex(S).getString());v.partId=b,m.link.pushBack(v)}}i._partGroups.pushBack(m.clone()),++c}i._partGroupCounts.pushBack(c)}return Ie.delete(r),i}static delete(t){}updateParameters(t,e){t!=this._lastModel&&this.reset(t),this._lastModel=t,e<0&&(e=0);let r=0;for(let i=0;i<this._partGroupCounts.getSize();i++){let n=this._partGroupCounts.at(i);this.doFade(t,e,r,n),r+=n}this.copyPartOpacities(t)}reset(t){let e=0;for(let r=0;r<this._partGroupCounts.getSize();++r){let i=this._partGroupCounts.at(r);for(let n=e;n<e+i;++n){this._partGroups.at(n).initialize(t);let o=this._partGroups.at(n).partIndex,a=this._partGroups.at(n).parameterIndex;if(!(o<0)){t.setPartOpacityByIndex(o,n==e?1:0),t.setParameterValueByIndex(a,n==e?1:0);for(let l=0;l<this._partGroups.at(n).link.getSize();++l)this._partGroups.at(n).link.at(l).initialize(t)}}e+=i}}copyPartOpacities(t){for(let e=0;e<this._partGroups.getSize();++e){let r=this._partGroups.at(e);if(r.link.getSize()==0)continue;let i=this._partGroups.at(e).partIndex,n=t.getPartOpacityByIndex(i);for(let o=0;o<r.link.getSize();++o){let l=r.link.at(o).partIndex;l<0||t.setPartOpacityByIndex(l,n)}}}doFade(t,e,r,i){let n=-1,o=1,a=.5,l=.15;for(let h=r;h<r+i;++h){let u=this._partGroups.at(h).partIndex,c=this._partGroups.at(h).parameterIndex;if(t.getParameterValueByIndex(c)>QF){if(n>=0)break;if(n=h,this._fadeTimeSeconds==0){o=1;continue}o=t.getPartOpacityByIndex(u),o+=e/this._fadeTimeSeconds,o>1&&(o=1)}}n<0&&(n=0,o=1);for(let h=r;h<r+i;++h){let u=this._partGroups.at(h).partIndex;if(n==h)t.setPartOpacityByIndex(u,o);else{let c=t.getPartOpacityByIndex(u),f;o<a?f=o*(a-1)/a+1:f=(1-o)*a/(1-a),(1-f)*(1-o)>l&&(f=1-l/(1-o)),c>f&&(c=f),t.setPartOpacityByIndex(u,c)}}}constructor(){this._fadeTimeSeconds=qm,this._lastModel=null,this._partGroups=new X,this._partGroupCounts=new X}},tl=class s{constructor(t){if(this.parameterIndex=0,this.partIndex=0,this.link=new X,t!=null){this.partId=t.partId;for(let e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone())}}assignment(t){this.partId=t.partId;for(let e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone());return this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){let t=new s;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new X;for(let e=this.link.begin();e.notEqual(this.link.end());e.increment())t.link.pushBack(e.ptr().clone());return t}},Vw;(s=>{s.CubismPose=cc,s.PartData=tl})(Vw||(Vw={}));var yg=class{constructor(t=!1,e=!1){this.isOverridden=t,this.isParameterRepeated=e}},dc=class{constructor(t=!1,e=new le){this.isOverridden=t,this.color=e}get isOverwritten(){return this.isOverridden}},fc=class{constructor(t=!1,e=new le){this.isOverridden=t,this.color=e}get isOverwritten(){return this.isOverridden}},bg=class{constructor(t=!1,e=!1){this.isOverridden=t,this.isCulling=e}get isOverwritten(){return this.isOverridden}},pc=class{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){let t=this._model.parameters.count,e=this._savedParameters.getSize();for(let r=0;r<t;++r)r<e?this._savedParameters.set(r,this._parameterValues[r]):this._savedParameters.pushBack(this._parameterValues[r])}getMultiplyColor(t){return this.getOverrideFlagForModelMultiplyColors()||this.getOverrideFlagForDrawableMultiplyColors(t)?this._userMultiplyColors.at(t).color:this.getDrawableMultiplyColor(t)}getScreenColor(t){return this.getOverrideFlagForModelScreenColors()||this.getOverrideFlagForDrawableScreenColors(t)?this._userScreenColors.at(t).color:this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,e){this.setMultiplyColorByRGBA(t,e.r,e.g,e.b,e.a)}setMultiplyColorByRGBA(t,e,r,i,n=1){this._userMultiplyColors.at(t).color.r=e,this._userMultiplyColors.at(t).color.g=r,this._userMultiplyColors.at(t).color.b=i,this._userMultiplyColors.at(t).color.a=n}setScreenColorByTextureColor(t,e){this.setScreenColorByRGBA(t,e.r,e.g,e.b,e.a)}setScreenColorByRGBA(t,e,r,i,n=1){this._userScreenColors.at(t).color.r=e,this._userScreenColors.at(t).color.g=r,this._userScreenColors.at(t).color.b=i,this._userScreenColors.at(t).color.a=n}getPartMultiplyColor(t){return this._userPartMultiplyColors.at(t).color}getPartScreenColor(t){return this._userPartScreenColors.at(t).color}setPartColor(t,e,r,i,n,o,a){if(o.at(t).color.r=e,o.at(t).color.g=r,o.at(t).color.b=i,o.at(t).color.a=n,o.at(t).isOverridden)for(let l=0;l<this._partChildDrawables.at(t).getSize();++l){let h=this._partChildDrawables.at(t).at(l);a.at(h).color.r=e,a.at(h).color.g=r,a.at(h).color.b=i,a.at(h).color.a=n}}setPartMultiplyColorByTextureColor(t,e){this.setPartMultiplyColorByRGBA(t,e.r,e.g,e.b,e.a)}setPartMultiplyColorByRGBA(t,e,r,i,n){this.setPartColor(t,e,r,i,n,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,e){this.setPartScreenColorByRGBA(t,e.r,e.g,e.b,e.a)}setPartScreenColorByRGBA(t,e,r,i,n){this.setPartColor(t,e,r,i,n,this._userPartScreenColors,this._userScreenColors)}getOverrideFlagForModelParameterRepeat(){return this._isOverriddenParameterRepeat}setOverrideFlagForModelParameterRepeat(t){this._isOverriddenParameterRepeat=t}getOverrideFlagForParameterRepeat(t){return this._userParameterRepeatDataList.at(t).isOverridden}setOverrideFlagForParameterRepeat(t,e){this._userParameterRepeatDataList.at(t).isOverridden=e}getRepeatFlagForParameterRepeat(t){return this._userParameterRepeatDataList.at(t).isParameterRepeated}setRepeatFlagForParameterRepeat(t,e){this._userParameterRepeatDataList.at(t).isParameterRepeated=e}getOverwriteFlagForModelMultiplyColors(){return dt("getOverwriteFlagForModelMultiplyColors() is a deprecated function. Please use getOverrideFlagForModelMultiplyColors()."),this.getOverrideFlagForModelMultiplyColors()}getOverrideFlagForModelMultiplyColors(){return this._isOverriddenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return dt("getOverwriteFlagForModelScreenColors() is a deprecated function. Please use getOverrideFlagForModelScreenColors()."),this.getOverrideFlagForModelScreenColors()}getOverrideFlagForModelScreenColors(){return this._isOverriddenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){dt("setOverwriteFlagForModelMultiplyColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelMultiplyColors(value: boolean)."),this.setOverrideFlagForModelMultiplyColors(t)}setOverrideFlagForModelMultiplyColors(t){this._isOverriddenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){dt("setOverwriteFlagForModelScreenColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelScreenColors(value: boolean)."),this.setOverrideFlagForModelScreenColors(t)}setOverrideFlagForModelScreenColors(t){this._isOverriddenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return dt("getOverwriteFlagForDrawableMultiplyColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableMultiplyColors(drawableindex: number)."),this.getOverrideFlagForDrawableMultiplyColors(t)}getOverrideFlagForDrawableMultiplyColors(t){return this._userMultiplyColors.at(t).isOverridden}getOverwriteFlagForDrawableScreenColors(t){return dt("getOverwriteFlagForDrawableScreenColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableScreenColors(drawableindex: number)."),this.getOverrideFlagForDrawableScreenColors(t)}getOverrideFlagForDrawableScreenColors(t){return this._userScreenColors.at(t).isOverridden}setOverwriteFlagForDrawableMultiplyColors(t,e){dt("setOverwriteFlagForDrawableMultiplyColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableMultiplyColors(drawableindex: number, value: boolean)."),this.setOverrideFlagForDrawableMultiplyColors(t,e)}setOverrideFlagForDrawableMultiplyColors(t,e){this._userMultiplyColors.at(t).isOverridden=e}setOverwriteFlagForDrawableScreenColors(t,e){dt("setOverwriteFlagForDrawableScreenColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableScreenColors(drawableindex: number, value: boolean)."),this.setOverrideFlagForDrawableScreenColors(t,e)}setOverrideFlagForDrawableScreenColors(t,e){this._userScreenColors.at(t).isOverridden=e}getOverwriteColorForPartMultiplyColors(t){return dt("getOverwriteColorForPartMultiplyColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartMultiplyColors(partIndex: number)."),this.getOverrideColorForPartMultiplyColors(t)}getOverrideColorForPartMultiplyColors(t){return this._userPartMultiplyColors.at(t).isOverridden}getOverwriteColorForPartScreenColors(t){return dt("getOverwriteColorForPartScreenColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartScreenColors(partIndex: number)."),this.getOverrideColorForPartScreenColors(t)}getOverrideColorForPartScreenColors(t){return this._userPartScreenColors.at(t).isOverridden}setOverwriteColorForPartColors(t,e,r,i){dt("setOverwriteColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>) is a deprecated function. Please use setOverrideColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>)."),this.setOverrideColorForPartColors(t,e,r,i)}setOverrideColorForPartColors(t,e,r,i){r.at(t).isOverridden=e;for(let n=0;n<this._partChildDrawables.at(t).getSize();++n){let o=this._partChildDrawables.at(t).at(n);i.at(o).isOverridden=e,e&&(i.at(o).color.r=r.at(t).color.r,i.at(o).color.g=r.at(t).color.g,i.at(o).color.b=r.at(t).color.b,i.at(o).color.a=r.at(t).color.a)}}setOverwriteColorForPartMultiplyColors(t,e){dt("setOverwriteColorForPartMultiplyColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartMultiplyColors(partIndex: number, value: boolean)."),this.setOverrideColorForPartMultiplyColors(t,e)}setOverrideColorForPartMultiplyColors(t,e){this._userPartMultiplyColors.at(t).isOverridden=e,this.setOverrideColorForPartColors(t,e,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,e){dt("setOverwriteColorForPartScreenColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartScreenColors(partIndex: number, value: boolean)."),this.setOverrideColorForPartScreenColors(t,e)}setOverrideColorForPartScreenColors(t,e){this._userPartScreenColors.at(t).isOverridden=e,this.setOverrideColorForPartColors(t,e,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForDrawableCullings(t))return this._userCullings.at(t).isCulling;let e=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t])}setDrawableCulling(t,e){this._userCullings.at(t).isCulling=e}getOverwriteFlagForModelCullings(){return dt("getOverwriteFlagForModelCullings() is a deprecated function. Please use getOverrideFlagForModelCullings()."),this.getOverrideFlagForModelCullings()}getOverrideFlagForModelCullings(){return this._isOverriddenCullings}setOverwriteFlagForModelCullings(t){dt("setOverwriteFlagForModelCullings(isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForModelCullings(isOverriddenCullings: boolean)."),this.setOverrideFlagForModelCullings(t)}setOverrideFlagForModelCullings(t){this._isOverriddenCullings=t}getOverwriteFlagForDrawableCullings(t){return dt("getOverwriteFlagForDrawableCullings(drawableIndex: number) is a deprecated function. Please use getOverrideFlagForDrawableCullings(drawableIndex: number)."),this.getOverrideFlagForDrawableCullings(t)}getOverrideFlagForDrawableCullings(t){return this._userCullings.at(t).isOverridden}setOverwriteFlagForDrawableCullings(t,e){dt("setOverwriteFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean)."),this.setOverrideFlagForDrawableCullings(t,e)}setOverrideFlagForDrawableCullings(t,e){this._userCullings.at(t).isOverridden=e}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let e,r=this._model.parts.count;for(e=0;e<r;++e)if(t==this._partIds.at(e))return e;return this._notExistPartId.isExist(t)?this._notExistPartId.getValue(t):(e=r+this._notExistPartId.getSize(),this._notExistPartId.setValue(t,e),this._notExistPartOpacities.appendKey(e),e)}getPartId(t){let e=this._model.parts.ids[t];return bt.getIdManager().getId(e)}getPartCount(){return this._model.parts.count}getPartParentPartIndices(){return this._model.parts.parentIndices}setPartOpacityByIndex(t,e){if(this._notExistPartOpacities.isExist(t)){this._notExistPartOpacities.setValue(t,e);return}ye(0<=t&&t<this.getPartCount()),this._partOpacities[t]=e}setPartOpacityById(t,e){let r=this.getPartIndex(t);r<0||this.setPartOpacityByIndex(r,e)}getPartOpacityByIndex(t){return this._notExistPartOpacities.isExist(t)?this._notExistPartOpacities.getValue(t):(ye(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){let e=this.getPartIndex(t);return e<0?0:this.getPartOpacityByIndex(e)}getParameterIndex(t){let e,r=this._model.parameters.count;for(e=0;e<r;++e)if(t==this._parameterIds.at(e))return e;return this._notExistParameterId.isExist(t)?this._notExistParameterId.getValue(t):(e=this._model.parameters.count+this._notExistParameterId.getSize(),this._notExistParameterId.setValue(t,e),this._notExistParameterValues.appendKey(e),e)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterId(t){return bt.getIdManager().getId(this._model.parameters.ids[t])}getParameterValueByIndex(t){return this._notExistParameterValues.isExist(t)?this._notExistParameterValues.getValue(t):(ye(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){let e=this.getParameterIndex(t);return this.getParameterValueByIndex(e)}setParameterValueByIndex(t,e,r=1){if(this._notExistParameterValues.isExist(t)){this._notExistParameterValues.setValue(t,r==1?e:this._notExistParameterValues.getValue(t)*(1-r)+e*r);return}ye(0<=t&&t<this.getParameterCount()),this.isRepeat(t)?e=this.getParameterRepeatValue(t,e):e=this.getParameterClampValue(t,e),this._parameterValues[t]=r==1?e:this._parameterValues[t]=this._parameterValues[t]*(1-r)+e*r}setParameterValueById(t,e,r=1){let i=this.getParameterIndex(t);this.setParameterValueByIndex(i,e,r)}addParameterValueByIndex(t,e,r=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*r)}addParameterValueById(t,e,r=1){let i=this.getParameterIndex(t);this.addParameterValueByIndex(i,e,r)}isRepeat(t){if(this._notExistParameterValues.isExist(t))return!1;ye(0<=t&&t<this.getParameterCount());let e;return this._isOverriddenParameterRepeat||this._userParameterRepeatDataList.at(t).isOverridden?e=this._userParameterRepeatDataList.at(t).isParameterRepeated:e=this._model.parameters.repeats[t]!=0,e}getParameterRepeatValue(t,e){if(this._notExistParameterValues.isExist(t))return e;ye(0<=t&&t<this.getParameterCount());let r=this._model.parameters.maximumValues[t],i=this._model.parameters.minimumValues[t],n=r-i;if(r<e){let o=st.mod(e-r,n);Number.isNaN(o)?e=r:e=i+o}if(e<i){let o=st.mod(i-e,n);Number.isNaN(o)?e=i:e=r-o}return e}getParameterClampValue(t,e){if(this._notExistParameterValues.isExist(t))return e;ye(0<=t&&t<this.getParameterCount());let r=this._model.parameters.maximumValues[t],i=this._model.parameters.minimumValues[t];return st.clamp(e,i,r)}getParameterRepeats(t){return this._model.parameters.repeats[t]!=0}multiplyParameterValueById(t,e,r=1){let i=this.getParameterIndex(t);this.multiplyParameterValueByIndex(i,e,r)}multiplyParameterValueByIndex(t,e,r=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*r))}getDrawableIndex(t){let e=this._model.drawables.count;for(let r=0;r<e;++r)if(this._drawableIds.at(r)==t)return r;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){let e=this._model.drawables.ids;return bt.getIdManager().getId(e[t])}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){let e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){let e=this._model.drawables.multiplyColors,r=t*4,i=new le;return i.r=e[r],i.g=e[r+1],i.b=e[r+2],i.a=e[r+3],i}getDrawableScreenColor(t){let e=this._model.drawables.screenColors,r=t*4,i=new le;return i.r=e[r],i.g=e[r+1],i.b=e[r+2],i.a=e[r+3],i}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){let e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t])?ms.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t])?ms.CubismBlendMode_Multiplicative:ms.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){let e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){let e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(e[t])}getDrawableDynamicFlagVisibilityDidChange(t){let e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t])}getDrawableDynamicFlagOpacityDidChange(t){let e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t])}getDrawableDynamicFlagRenderOrderDidChange(t){let e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t])}getDrawableDynamicFlagBlendColorDidChange(t){let e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(e[t])}loadParameters(){let t=this._model.parameters.count,e=this._savedParameters.getSize();t>e&&(t=e);for(let r=0;r<t;++r)this._parameterValues[r]=this._savedParameters.at(r)}initialize(){ye(this._model),this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{let e=this._model.parameters.ids,r=this._model.parameters.count;this._parameterIds.prepareCapacity(r),this._userParameterRepeatDataList.prepareCapacity(r);for(let i=0;i<r;++i)this._parameterIds.pushBack(bt.getIdManager().getId(e[i])),this._userParameterRepeatDataList.pushBack(new yg(!1,!1))}let t=this._model.parts.count;{let e=this._model.parts.ids;this._partIds.prepareCapacity(t);for(let r=0;r<t;++r)this._partIds.pushBack(bt.getIdManager().getId(e[r]));this._userPartMultiplyColors.prepareCapacity(t),this._userPartScreenColors.prepareCapacity(t),this._partChildDrawables.prepareCapacity(t)}{let e=this._model.drawables.ids,r=this._model.drawables.count;this._userMultiplyColors.prepareCapacity(r),this._userScreenColors.prepareCapacity(r),this._userCullings.prepareCapacity(r);let i=new bg(!1,!1);for(let n=0;n<t;++n){let o=new le(1,1,1,1),a=new le(0,0,0,1),l=new fc(!1,o),h=new fc(!1,a);this._userPartMultiplyColors.pushBack(l),this._userPartScreenColors.pushBack(h),this._partChildDrawables.pushBack(new X),this._partChildDrawables.at(n).prepareCapacity(r)}for(let n=0;n<r;++n){let o=new le(1,1,1,1),a=new le(0,0,0,1),l=new dc(!1,o),h=new dc(!1,a);this._drawableIds.pushBack(bt.getIdManager().getId(e[n])),this._userMultiplyColors.pushBack(l),this._userScreenColors.pushBack(h),this._userCullings.pushBack(i);let u=this.getDrawableParentPartIndex(n);u>=0&&this._partChildDrawables.at(u).pushBack(n)}}}constructor(t){this._model=t,this._parameterValues=null,this._parameterMaximumValues=null,this._parameterMinimumValues=null,this._partOpacities=null,this._savedParameters=new X,this._parameterIds=new X,this._drawableIds=new X,this._partIds=new X,this._isOverriddenParameterRepeat=!0,this._isOverriddenModelMultiplyColors=!1,this._isOverriddenModelScreenColors=!1,this._isOverriddenCullings=!1,this._modelOpacity=1,this._userParameterRepeatDataList=new X,this._userMultiplyColors=new X,this._userScreenColors=new X,this._userCullings=new X,this._userPartMultiplyColors=new X,this._userPartScreenColors=new X,this._partChildDrawables=new X,this._notExistPartId=new Xr,this._notExistParameterId=new Xr,this._notExistParameterValues=new Xr,this._notExistPartOpacities=new Xr}release(){this._model.release(),this._model=null}},Nw;(s=>{s.CubismModel=pc})(Nw||(Nw={}));var mc=class s{static create(t,e){let r=null;if(e&&!this.hasMocConsistency(t))return be("Inconsistent MOC3."),r;let i=Live2DCubismCore.Moc.fromArrayBuffer(t);return i&&(r=new s(i),r._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(i,t)),r}static delete(t){t._moc._release(),t._moc=null,t=null}createModel(){let t=null,e=Live2DCubismCore.Model.fromMoc(this._moc);return e&&(t=new pc(e),t.initialize(),++this._modelCount),t}deleteModel(t){t!=null&&(t.release(),t=null,--this._modelCount)}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){ye(this._modelCount==0),this._moc._release(),this._moc=null}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}},Hw;(s=>{s.CubismMoc=mc})(Hw||(Hw={}));var gc=(s=>(s[s.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",s))(gc||{}),cs=(s=>(s[s.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",s[s.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",s[s.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",s))(cs||{}),vg=class{constructor(){this.gravity=new j(0,0),this.wind=new j(0,0)}},el=class{},rl=class{},_c=class{constructor(){this.initialPosition=new j(0,0),this.position=new j(0,0),this.lastPosition=new j(0,0),this.lastGravity=new j(0,0),this.force=new j(0,0),this.velocity=new j(0,0)}},xc=class{constructor(){this.normalizationPosition=new rl,this.normalizationAngle=new rl}},yc=class{constructor(){this.source=new el}},bc=class{constructor(){this.destination=new el,this.translationScale=new j(0,0)}},vc=class{constructor(){this.settings=new X,this.inputs=new X,this.outputs=new X,this.particles=new X,this.gravity=new j(0,0),this.wind=new j(0,0),this.fps=0}},zw;(s=>{s.CubismPhysicsInput=yc,s.CubismPhysicsNormalization=rl,s.CubismPhysicsOutput=bc,s.CubismPhysicsParameter=el,s.CubismPhysicsParticle=_c,s.CubismPhysicsRig=vc,s.CubismPhysicsSource=cs,s.CubismPhysicsSubRig=xc,s.CubismPhysicsTargetType=gc,s.PhysicsJsonEffectiveForces=vg})(zw||(zw={}));var za="Position",Km="X",Zm="Y",Jm="Angle",Ww="Type",Xw="Id",zr="Meta",Lu="EffectiveForces",rk="TotalInputCount",sk="TotalOutputCount",ik="PhysicsSettingCount",jw="Gravity",Yw="Wind",nk="VertexCount",ok="Fps",At="PhysicsSettings",Tn="Normalization",$w="Minimum",qw="Maximum",Kw="Default",Zw="Reflect",Jw="Weight",Wa="Input",ak="Source",ri="Output",lk="Scale",hk="VertexIndex",uk="Destination",si="Vertices",ck="Mobility",dk="Delay",fk="Radius",pk="Acceleration",Sc=class{constructor(t,e){this._json=Ie.create(t,e)}release(){Ie.delete(this._json)}getGravity(){let t=new j(0,0);return t.x=this._json.getRoot().getValueByString(zr).getValueByString(Lu).getValueByString(jw).getValueByString(Km).toFloat(),t.y=this._json.getRoot().getValueByString(zr).getValueByString(Lu).getValueByString(jw).getValueByString(Zm).toFloat(),t}getWind(){let t=new j(0,0);return t.x=this._json.getRoot().getValueByString(zr).getValueByString(Lu).getValueByString(Yw).getValueByString(Km).toFloat(),t.y=this._json.getRoot().getValueByString(zr).getValueByString(Lu).getValueByString(Yw).getValueByString(Zm).toFloat(),t}getFps(){return this._json.getRoot().getValueByString(zr).getValueByString(ok).toFloat(0)}getSubRigCount(){return this._json.getRoot().getValueByString(zr).getValueByString(ik).toInt()}getTotalInputCount(){return this._json.getRoot().getValueByString(zr).getValueByString(rk).toInt()}getTotalOutputCount(){return this._json.getRoot().getValueByString(zr).getValueByString(sk).toInt()}getVertexCount(){return this._json.getRoot().getValueByString(zr).getValueByString(nk).toInt()}getNormalizationPositionMinimumValue(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Tn).getValueByString(za).getValueByString($w).toFloat()}getNormalizationPositionMaximumValue(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Tn).getValueByString(za).getValueByString(qw).toFloat()}getNormalizationPositionDefaultValue(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Tn).getValueByString(za).getValueByString(Kw).toFloat()}getNormalizationAngleMinimumValue(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Tn).getValueByString(Jm).getValueByString($w).toFloat()}getNormalizationAngleMaximumValue(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Tn).getValueByString(Jm).getValueByString(qw).toFloat()}getNormalizationAngleDefaultValue(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Tn).getValueByString(Jm).getValueByString(Kw).toFloat()}getInputCount(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Wa).getVector().getSize()}getInputWeight(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Wa).getValueByIndex(e).getValueByString(Jw).toFloat()}getInputReflect(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Wa).getValueByIndex(e).getValueByString(Zw).toBoolean()}getInputType(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Wa).getValueByIndex(e).getValueByString(Ww).getRawString()}getInputSourceId(t,e){return bt.getIdManager().getId(this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(Wa).getValueByIndex(e).getValueByString(ak).getValueByString(Xw).getRawString())}getOutputCount(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(ri).getVector().getSize()}getOutputVertexIndex(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(ri).getValueByIndex(e).getValueByString(hk).toInt()}getOutputAngleScale(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(ri).getValueByIndex(e).getValueByString(lk).toFloat()}getOutputWeight(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(ri).getValueByIndex(e).getValueByString(Jw).toFloat()}getOutputDestinationId(t,e){return bt.getIdManager().getId(this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(ri).getValueByIndex(e).getValueByString(uk).getValueByString(Xw).getRawString())}getOutputType(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(ri).getValueByIndex(e).getValueByString(Ww).getRawString()}getOutputReflect(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(ri).getValueByIndex(e).getValueByString(Zw).toBoolean()}getParticleCount(t){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(si).getVector().getSize()}getParticleMobility(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(si).getValueByIndex(e).getValueByString(ck).toFloat()}getParticleDelay(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(si).getValueByIndex(e).getValueByString(dk).toFloat()}getParticleAcceleration(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(si).getValueByIndex(e).getValueByString(pk).toFloat()}getParticleRadius(t,e){return this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(si).getValueByIndex(e).getValueByString(fk).toFloat()}getParticlePosition(t,e){let r=new j(0,0);return r.x=this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(si).getValueByIndex(e).getValueByString(za).getValueByString(Km).toFloat(),r.y=this._json.getRoot().getValueByString(At).getValueByIndex(t).getValueByString(si).getValueByIndex(e).getValueByString(za).getValueByString(Zm).toFloat(),r}},Qw;(s=>{s.CubismPhysicsJson=Sc})(Qw||(Qw={}));var tE="X",eE="Y",rE="Angle",mk=5,Sg=100,sE=.001,gk=5,Tc=class s{static create(t,e){let r=new s;return r.parse(t,e),r._physicsRig.gravity.y=0,r}static delete(t){t!=null&&(t.release(),t=null)}parse(t,e){this._physicsRig=new vc;let r=new Sc(t,e);this._physicsRig.gravity=r.getGravity(),this._physicsRig.wind=r.getWind(),this._physicsRig.subRigCount=r.getSubRigCount(),this._physicsRig.fps=r.getFps(),this._physicsRig.settings.updateSize(this._physicsRig.subRigCount,xc,!0),this._physicsRig.inputs.updateSize(r.getTotalInputCount(),yc,!0),this._physicsRig.outputs.updateSize(r.getTotalOutputCount(),bc,!0),this._physicsRig.particles.updateSize(r.getVertexCount(),_c,!0),this._currentRigOutputs.clear(),this._previousRigOutputs.clear();let i=0,n=0,o=0;for(let a=0;a<this._physicsRig.settings.getSize();++a){this._physicsRig.settings.at(a).normalizationPosition.minimum=r.getNormalizationPositionMinimumValue(a),this._physicsRig.settings.at(a).normalizationPosition.maximum=r.getNormalizationPositionMaximumValue(a),this._physicsRig.settings.at(a).normalizationPosition.defalut=r.getNormalizationPositionDefaultValue(a),this._physicsRig.settings.at(a).normalizationAngle.minimum=r.getNormalizationAngleMinimumValue(a),this._physicsRig.settings.at(a).normalizationAngle.maximum=r.getNormalizationAngleMaximumValue(a),this._physicsRig.settings.at(a).normalizationAngle.defalut=r.getNormalizationAngleDefaultValue(a),this._physicsRig.settings.at(a).inputCount=r.getInputCount(a),this._physicsRig.settings.at(a).baseInputIndex=i;for(let u=0;u<this._physicsRig.settings.at(a).inputCount;++u)this._physicsRig.inputs.at(i+u).sourceParameterIndex=-1,this._physicsRig.inputs.at(i+u).weight=r.getInputWeight(a,u),this._physicsRig.inputs.at(i+u).reflect=r.getInputReflect(a,u),r.getInputType(a,u)==tE?(this._physicsRig.inputs.at(i+u).type=cs.CubismPhysicsSource_X,this._physicsRig.inputs.at(i+u).getNormalizedParameterValue=xk):r.getInputType(a,u)==eE?(this._physicsRig.inputs.at(i+u).type=cs.CubismPhysicsSource_Y,this._physicsRig.inputs.at(i+u).getNormalizedParameterValue=yk):r.getInputType(a,u)==rE&&(this._physicsRig.inputs.at(i+u).type=cs.CubismPhysicsSource_Angle,this._physicsRig.inputs.at(i+u).getNormalizedParameterValue=bk),this._physicsRig.inputs.at(i+u).source.targetType=gc.CubismPhysicsTargetType_Parameter,this._physicsRig.inputs.at(i+u).source.id=r.getInputSourceId(a,u);i+=this._physicsRig.settings.at(a).inputCount,this._physicsRig.settings.at(a).outputCount=r.getOutputCount(a),this._physicsRig.settings.at(a).baseOutputIndex=n;let l=new Pc;l.outputs.resize(this._physicsRig.settings.at(a).outputCount);let h=new Pc;h.outputs.resize(this._physicsRig.settings.at(a).outputCount);for(let u=0;u<this._physicsRig.settings.at(a).outputCount;++u)l.outputs.set(u,0),h.outputs.set(u,0),this._physicsRig.outputs.at(n+u).destinationParameterIndex=-1,this._physicsRig.outputs.at(n+u).vertexIndex=r.getOutputVertexIndex(a,u),this._physicsRig.outputs.at(n+u).angleScale=r.getOutputAngleScale(a,u),this._physicsRig.outputs.at(n+u).weight=r.getOutputWeight(a,u),this._physicsRig.outputs.at(n+u).destination.targetType=gc.CubismPhysicsTargetType_Parameter,this._physicsRig.outputs.at(n+u).destination.id=r.getOutputDestinationId(a,u),r.getOutputType(a,u)==tE?(this._physicsRig.outputs.at(n+u).type=cs.CubismPhysicsSource_X,this._physicsRig.outputs.at(n+u).getValue=vk,this._physicsRig.outputs.at(n+u).getScale=Mk):r.getOutputType(a,u)==eE?(this._physicsRig.outputs.at(n+u).type=cs.CubismPhysicsSource_Y,this._physicsRig.outputs.at(n+u).getValue=Sk,this._physicsRig.outputs.at(n+u).getScale=wk):r.getOutputType(a,u)==rE&&(this._physicsRig.outputs.at(n+u).type=cs.CubismPhysicsSource_Angle,this._physicsRig.outputs.at(n+u).getValue=Tk,this._physicsRig.outputs.at(n+u).getScale=Ek),this._physicsRig.outputs.at(n+u).reflect=r.getOutputReflect(a,u);this._currentRigOutputs.pushBack(l),this._previousRigOutputs.pushBack(h),n+=this._physicsRig.settings.at(a).outputCount,this._physicsRig.settings.at(a).particleCount=r.getParticleCount(a),this._physicsRig.settings.at(a).baseParticleIndex=o;for(let u=0;u<this._physicsRig.settings.at(a).particleCount;++u)this._physicsRig.particles.at(o+u).mobility=r.getParticleMobility(a,u),this._physicsRig.particles.at(o+u).delay=r.getParticleDelay(a,u),this._physicsRig.particles.at(o+u).acceleration=r.getParticleAcceleration(a,u),this._physicsRig.particles.at(o+u).radius=r.getParticleRadius(a,u),this._physicsRig.particles.at(o+u).position=r.getParticlePosition(a,u);o+=this._physicsRig.settings.at(a).particleCount}this.initialize(),r.release(),r=void 0,r=null}stabilization(t){var e,r,i,n;let o,a,l,h,u=new j,c,f,d,m,g=t.getModel().parameters.values,_=t.getModel().parameters.maximumValues,x=t.getModel().parameters.minimumValues,S=t.getModel().parameters.defaultValues;((r=(e=this._parameterCaches)==null?void 0:e.length)!=null?r:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((n=(i=this._parameterInputCaches)==null?void 0:i.length)!=null?n:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let v=0;v<t.getParameterCount();++v)this._parameterCaches[v]=g[v],this._parameterInputCaches[v]=g[v];for(let v=0;v<this._physicsRig.subRigCount;++v){o={angle:0},u.x=0,u.y=0,c=this._physicsRig.settings.at(v),f=this._physicsRig.inputs.get(c.baseInputIndex),d=this._physicsRig.outputs.get(c.baseOutputIndex),m=this._physicsRig.particles.get(c.baseParticleIndex);for(let b=0;b<c.inputCount;++b)a=f[b].weight/Sg,f[b].sourceParameterIndex==-1&&(f[b].sourceParameterIndex=t.getParameterIndex(f[b].source.id)),f[b].getNormalizedParameterValue(u,o,g[f[b].sourceParameterIndex],x[f[b].sourceParameterIndex],_[f[b].sourceParameterIndex],S[f[b].sourceParameterIndex],c.normalizationPosition,c.normalizationAngle,f[b].reflect,a),this._parameterCaches[f[b].sourceParameterIndex]=g[f[b].sourceParameterIndex];l=st.degreesToRadian(-o.angle),u.x=u.x*st.cos(l)-u.y*st.sin(l),u.y=u.x*st.sin(l)+u.y*st.cos(l),Bk(m,c.particleCount,u,o.angle,this._options.wind,sE*c.normalizationPosition.maximum);for(let b=0;b<c.outputCount;++b){let C=d[b].vertexIndex;if(d[b].destinationParameterIndex==-1&&(d[b].destinationParameterIndex=t.getParameterIndex(d[b].destination.id)),C<1||C>=c.particleCount)continue;let T=new j;T=m[C].position.substract(m[C-1].position),h=d[b].getValue(T,m,C,d[b].reflect,this._options.gravity),this._currentRigOutputs.at(v).outputs.set(b,h),this._previousRigOutputs.at(v).outputs.set(b,h);let P=d[b].destinationParameterIndex,E=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(g.subarray(P))):g.slice(P);Qm(E,x[P],_[P],h,d[b]);for(let L=P,B=0;L<this._parameterCaches.length;L++,B++)g[L]=this._parameterCaches[L]=E[B]}}}evaluate(t,e){var r,i,n,o;let a,l,h,u,c=new j,f,d,m,g;if(0>=e)return;let _=t.getModel().parameters.values,x=t.getModel().parameters.maximumValues,S=t.getModel().parameters.minimumValues,v=t.getModel().parameters.defaultValues,b;if(this._currentRemainTime+=e,this._currentRemainTime>gk&&(this._currentRemainTime=0),((i=(r=this._parameterCaches)==null?void 0:r.length)!=null?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),((o=(n=this._parameterInputCaches)==null?void 0:n.length)!=null?o:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let T=0;T<t.getParameterCount();++T)this._parameterInputCaches[T]=_[T]}for(this._physicsRig.fps>0?b=1/this._physicsRig.fps:b=e;this._currentRemainTime>=b;){for(let P=0;P<this._physicsRig.subRigCount;++P){f=this._physicsRig.settings.at(P),m=this._physicsRig.outputs.get(f.baseOutputIndex);for(let E=0;E<f.outputCount;++E)this._previousRigOutputs.at(P).outputs.set(E,this._currentRigOutputs.at(P).outputs.at(E))}let T=b/this._currentRemainTime;for(let P=0;P<t.getParameterCount();++P)this._parameterCaches[P]=this._parameterInputCaches[P]*(1-T)+_[P]*T,this._parameterInputCaches[P]=this._parameterCaches[P];for(let P=0;P<this._physicsRig.subRigCount;++P){a={angle:0},c.x=0,c.y=0,f=this._physicsRig.settings.at(P),d=this._physicsRig.inputs.get(f.baseInputIndex),m=this._physicsRig.outputs.get(f.baseOutputIndex),g=this._physicsRig.particles.get(f.baseParticleIndex);for(let E=0;E<f.inputCount;++E)l=d[E].weight/Sg,d[E].sourceParameterIndex==-1&&(d[E].sourceParameterIndex=t.getParameterIndex(d[E].source.id)),d[E].getNormalizedParameterValue(c,a,this._parameterCaches[d[E].sourceParameterIndex],S[d[E].sourceParameterIndex],x[d[E].sourceParameterIndex],v[d[E].sourceParameterIndex],f.normalizationPosition,f.normalizationAngle,d[E].reflect,l);h=st.degreesToRadian(-a.angle),c.x=c.x*st.cos(h)-c.y*st.sin(h),c.y=c.x*st.sin(h)+c.y*st.cos(h),Ak(g,f.particleCount,c,a.angle,this._options.wind,sE*f.normalizationPosition.maximum,b,mk);for(let E=0;E<f.outputCount;++E){let L=m[E].vertexIndex;if(m[E].destinationParameterIndex==-1&&(m[E].destinationParameterIndex=t.getParameterIndex(m[E].destination.id)),L<1||L>=f.particleCount)continue;let B=new j;B.x=g[L].position.x-g[L-1].position.x,B.y=g[L].position.y-g[L-1].position.y,u=m[E].getValue(B,g,L,m[E].reflect,this._options.gravity),this._currentRigOutputs.at(P).outputs.set(E,u);let w=m[E].destinationParameterIndex,I=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(w))):this._parameterCaches.slice(w);Qm(I,S[w],x[w],u,m[E]);for(let G=w,H=0;G<this._parameterCaches.length;G++,H++)this._parameterCaches[G]=I[H]}}this._currentRemainTime-=b}let C=this._currentRemainTime/b;this.interpolate(t,C)}interpolate(t,e){let r,i,n=t.getModel().parameters.values,o=t.getModel().parameters.maximumValues,a=t.getModel().parameters.minimumValues;for(let l=0;l<this._physicsRig.subRigCount;++l){i=this._physicsRig.settings.at(l),r=this._physicsRig.outputs.get(i.baseOutputIndex);for(let h=0;h<i.outputCount;++h){if(r[h].destinationParameterIndex==-1)continue;let u=r[h].destinationParameterIndex,c=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(n.subarray(u))):n.slice(u);Qm(c,a[u],o[u],this._previousRigOutputs.at(l).outputs.at(h)*(1-e)+this._currentRigOutputs.at(l).outputs.at(h)*e,r[h]);for(let f=u,d=0;f<n.length;f++,d++)n[f]=c[d]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._physicsRig=null,this._options=new Cc,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=new X,this._previousRigOutputs=new X,this._currentRemainTime=0,this._parameterCaches=null,this._parameterInputCaches=null}release(){this._physicsRig=void 0,this._physicsRig=null}initialize(){let t,e,r;for(let i=0;i<this._physicsRig.subRigCount;++i){e=this._physicsRig.settings.at(i),t=this._physicsRig.particles.get(e.baseParticleIndex),t[0].initialPosition=new j(0,0),t[0].lastPosition=new j(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new j(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new j(0,0),t[0].force=new j(0,0);for(let n=1;n<e.particleCount;++n)r=new j(0,0),r.y=t[n].radius,t[n].initialPosition=new j(t[n-1].initialPosition.x+r.x,t[n-1].initialPosition.y+r.y),t[n].position=new j(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastPosition=new j(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastGravity=new j(0,-1),t[n].lastGravity.y*=-1,t[n].velocity=new j(0,0),t[n].force=new j(0,0)}}},Cc=class{constructor(){this.gravity=new j(0,0),this.wind=new j(0,0)}},Pc=class{constructor(){this.outputs=new X(0)}};function _k(s){let t=0;return s>0?t=1:s<0&&(t=-1),t}function xk(s,t,e,r,i,n,o,a,l,h){s.x+=Cg(e,r,i,n,o.minimum,o.maximum,o.defalut,l)*h}function yk(s,t,e,r,i,n,o,a,l,h){s.y+=Cg(e,r,i,n,o.minimum,o.maximum,o.defalut,l)*h}function bk(s,t,e,r,i,n,o,a,l,h){t.angle+=Cg(e,r,i,n,a.minimum,a.maximum,a.defalut,l)*h}function vk(s,t,e,r,i){let n=s.x;return r&&(n*=-1),n}function Sk(s,t,e,r,i){let n=s.y;return r&&(n*=-1),n}function Tk(s,t,e,r,i){let n;return e>=2?i=t[e-1].position.substract(t[e-2].position):i=i.multiplyByScaler(-1),n=st.directionToRadian(i,s),r&&(n*=-1),n}function Ck(s,t){let e=st.max(s,t),r=st.min(s,t);return st.abs(e-r)}function Pk(s,t){return st.min(s,t)+Ck(s,t)/2}function Mk(s,t){return JSON.parse(JSON.stringify(s.x))}function wk(s,t){return JSON.parse(JSON.stringify(s.y))}function Ek(s,t){return JSON.parse(JSON.stringify(t))}function Ak(s,t,e,r,i,n,o,a){let l,h,u=new j(0,0),c=new j(0,0),f=new j(0,0),d=new j(0,0);s[0].position=new j(e.x,e.y);let m=st.degreesToRadian(r),g=st.radianToDirection(m);g.normalize();for(let _=1;_<t;++_)s[_].force=g.multiplyByScaler(s[_].acceleration).add(i),s[_].lastPosition=new j(s[_].position.x,s[_].position.y),l=s[_].delay*o*30,u=s[_].position.substract(s[_-1].position),h=st.directionToRadian(s[_].lastGravity,g)/a,u.x=st.cos(h)*u.x-u.y*st.sin(h),u.y=st.sin(h)*u.x+u.y*st.cos(h),s[_].position=s[_-1].position.add(u),c=s[_].velocity.multiplyByScaler(l),f=s[_].force.multiplyByScaler(l).multiplyByScaler(l),s[_].position=s[_].position.add(c).add(f),d=s[_].position.substract(s[_-1].position),d.normalize(),s[_].position=s[_-1].position.add(d.multiplyByScaler(s[_].radius)),st.abs(s[_].position.x)<n&&(s[_].position.x=0),l!=0&&(s[_].velocity=s[_].position.substract(s[_].lastPosition),s[_].velocity=s[_].velocity.divisionByScalar(l),s[_].velocity=s[_].velocity.multiplyByScaler(s[_].mobility)),s[_].force=new j(0,0),s[_].lastGravity=new j(g.x,g.y)}function Bk(s,t,e,r,i,n){let o=new j(0,0);s[0].position=new j(e.x,e.y);let a=st.degreesToRadian(r),l=st.radianToDirection(a);l.normalize();for(let h=1;h<t;++h)s[h].force=l.multiplyByScaler(s[h].acceleration).add(i),s[h].lastPosition=new j(s[h].position.x,s[h].position.y),s[h].velocity=new j(0,0),o=s[h].force,o.normalize(),o=o.multiplyByScaler(s[h].radius),s[h].position=s[h-1].position.add(o),st.abs(s[h].position.x)<n&&(s[h].position.x=0),s[h].force=new j(0,0),s[h].lastGravity=new j(l.x,l.y)}function Qm(s,t,e,r,i){let n,o=i.getScale(i.translationScale,i.angleScale);n=r*o,n<t?(n<i.valueBelowMinimum&&(i.valueBelowMinimum=n),n=t):n>e&&(n>i.valueExceededMaximum&&(i.valueExceededMaximum=n),n=e);let a=i.weight/Sg;a>=1||(n=s[0]*(1-a)+n*a),s[0]=n}function Cg(s,t,e,r,i,n,o,a){let l=0,h=st.max(e,t);h<s&&(s=h);let u=st.min(e,t);u>s&&(s=u);let c=st.min(i,n),f=st.max(i,n),d=o,m=Pk(u,h),g=s-m;switch(_k(g)){case 1:{let _=f-d,x=h-m;x!=0&&(l=g*(_/x),l+=d);break}case-1:{let _=c-d,x=u-m;x!=0&&(l=g*(_/x),l+=d);break}case 0:{l=d;break}}return a?l:l*-1}var iE;(s=>{s.CubismPhysics=Tc,s.Options=Cc})(iE||(iE={}));Re.registerRuntime({version:4,ready:ZF,test(s){return s instanceof Mn||Mn.isValidJSON(s)},isValidMoc(s){if(s.byteLength<4)return!1;let t=new Int8Array(s,0,4);return String.fromCharCode(...t)==="MOC3"},createModelSettings(s){return new Mn(s)},createCoreModel(s,t){let e=mc.create(s,!!t?.checkMocConsistency);try{let r=e.createModel();return r.__moc=e,r}catch(r){try{e.release()}catch(i){tt.warn("CubismFactory","Failed to release moc after core model creation failed.",i)}throw r}},createInternalModel(s,t,e){let r=new xg(s,t,e),i=s;return i.__moc&&(r.__moc=i.__moc,delete i.__moc,r.once("destroy",Rk)),r},createPhysics(s,t){if(!(t instanceof ArrayBuffer))throw new TypeError("Cubism physics data must be an ArrayBuffer.");return Tc.create(t,t.byteLength)},createPose(s,t){if(!(t instanceof ArrayBuffer))throw new TypeError("Cubism pose data must be an ArrayBuffer.");return cc.create(t,t.byteLength)}});function Rk(){var s;(s=this.__moc)==null||s.release()}var Ik=globalThis;Ik.__dshLive2dPetVendor={Application:su,Point:et,extensions:U,MotionPriority:ir,configureCubismSDK:GE,Live2DModel:qa,Live2DPlugin:TE};})();
987
+ /*! Bundled license information:
988
+
989
+ tiny-lru/dist/tiny-lru.js:
990
+ (**
991
+ * tiny-lru
992
+ *
993
+ * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
994
+ * @license BSD-3-Clause
995
+ * @version 11.4.7
996
+ *)
997
+ */