chatlab-cli 0.28.1 → 0.29.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 (111) hide show
  1. package/dist/{chat-command-ISJ2DC7R.mjs → chat-command-JKG3FY5B.mjs} +8 -5
  2. package/dist/{chat-command-ISJ2DC7R.mjs.map → chat-command-JKG3FY5B.mjs.map} +1 -1
  3. package/dist/chunk-2MZ6G4AC.mjs +1339 -0
  4. package/dist/chunk-2MZ6G4AC.mjs.map +1 -0
  5. package/dist/{chunk-NJB2NNB2.mjs → chunk-6FPEP2ZX.mjs} +2 -2
  6. package/dist/{chunk-YBS3YQB6.mjs → chunk-7RW4CQAO.mjs} +31 -57
  7. package/dist/chunk-7RW4CQAO.mjs.map +1 -0
  8. package/dist/{chunk-GHTGFM6O.mjs → chunk-ARZM6HBX.mjs} +14 -12
  9. package/dist/{chunk-GHTGFM6O.mjs.map → chunk-ARZM6HBX.mjs.map} +1 -1
  10. package/dist/{chunk-3QBVO4J7.mjs → chunk-CIB23U32.mjs} +2 -2
  11. package/dist/chunk-D4WTE7LV.mjs +526 -0
  12. package/dist/chunk-D4WTE7LV.mjs.map +1 -0
  13. package/dist/{chunk-T7IETWHN.mjs → chunk-I35WHWA6.mjs} +5 -3
  14. package/dist/{chunk-T7IETWHN.mjs.map → chunk-I35WHWA6.mjs.map} +1 -1
  15. package/dist/{chunk-AB6TAXTQ.mjs → chunk-KL2NGIMQ.mjs} +171 -47
  16. package/dist/chunk-KL2NGIMQ.mjs.map +1 -0
  17. package/dist/{chunk-ZVDOFWL7.mjs → chunk-QQK7MLCR.mjs} +3926 -10867
  18. package/dist/chunk-QQK7MLCR.mjs.map +1 -0
  19. package/dist/{chunk-ERAAWLEF.mjs → chunk-SKUG5XVD.mjs} +10 -8
  20. package/dist/{chunk-ERAAWLEF.mjs.map → chunk-SKUG5XVD.mjs.map} +1 -1
  21. package/dist/chunk-WPI6YSAR.mjs +8813 -0
  22. package/dist/chunk-WPI6YSAR.mjs.map +1 -0
  23. package/dist/cli.mjs +7 -4
  24. package/dist/contacts-worker.mjs +48 -0
  25. package/dist/contacts-worker.mjs.map +1 -0
  26. package/dist/{http-MBILV37U.mjs → http-5E7ARYFW.mjs} +11 -8
  27. package/dist/{import-EYV3GXHE.mjs → import-3KG6VK6O.mjs} +7 -4
  28. package/dist/index.mjs +11 -8
  29. package/dist/{mcp-H55AEXU5.mjs → mcp-JBI4CUQT.mjs} +8 -5
  30. package/dist/{mcp-H55AEXU5.mjs.map → mcp-JBI4CUQT.mjs.map} +1 -1
  31. package/dist/people-relationships-worker.mjs +48 -0
  32. package/dist/people-relationships-worker.mjs.map +1 -0
  33. package/dist/semantic-index-worker.mjs +1 -1
  34. package/dist/{src-36ZIR65K.mjs → src-UTBQAOJ3.mjs} +62 -44
  35. package/dist/{stream-import-YZMZ56B5.mjs → stream-import-7HZ4IRYJ.mjs} +7 -4
  36. package/dist/{worker-runtime-YDYS2C6T.mjs → worker-runtime-ALS4MR2A.mjs} +7 -3
  37. package/dist/{worker-runtime-YDYS2C6T.mjs.map → worker-runtime-ALS4MR2A.mjs.map} +1 -1
  38. package/dist-web/assets/BufferResource-MsqP5sq3.js +185 -0
  39. package/dist-web/assets/CanvasRenderer-BKCvcc2p.js +1 -0
  40. package/dist-web/assets/DebugToolsPanel-D_lFIW6j.css +1 -0
  41. package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-HGJb0Et1.js +110 -0
  42. package/dist-web/assets/{EChartWordcloud-B_YisOW5.js → EChartWordcloud-Clg60FMo.js} +1 -1
  43. package/dist-web/assets/Filter-wRJtdXx9.js +1 -0
  44. package/dist-web/assets/MessageExportModal-BCrMf5Kw.js +1 -0
  45. package/dist-web/assets/PageHeader-Bbn87QZS.css +1 -0
  46. package/dist-web/assets/PageHeader-C_yw54le.js +1 -0
  47. package/dist-web/assets/RelationshipGalaxyCanvas-DTzJq7q7.js +244 -0
  48. package/dist-web/assets/RelationshipGalaxyThreeCanvas-BluPHjCR.css +1 -0
  49. package/dist-web/assets/RelationshipGalaxyThreeCanvas-DIE-0_iM.js +4108 -0
  50. package/dist-web/assets/RenderTargetSystem-BSAQFamI.js +184 -0
  51. package/dist-web/assets/WebGLRenderer-lfzmCZNT.js +156 -0
  52. package/dist-web/assets/WebGPURenderer-BnEdfdr_.js +41 -0
  53. package/dist-web/assets/browserAll-gRNfDyPu.js +14 -0
  54. package/dist-web/assets/{electron-DWDCqx_d.js → electron-BHaEaaZP.js} +1 -1
  55. package/dist-web/assets/{fetch-29ZBtGV0.js → fetch-BW3aO7PS.js} +1 -1
  56. package/dist-web/assets/fetch-BwF5hNuF.js +1 -0
  57. package/dist-web/assets/{fetch-Bh1fo3Df.js → fetch-C1fI_KOX.js} +1 -1
  58. package/dist-web/assets/{fetch-DyD8wDhb.js → fetch-CBZbgZqk.js} +1 -1
  59. package/dist-web/assets/{fetch-C3yhWO2S.js → fetch-CFRoSIAn.js} +1 -1
  60. package/dist-web/assets/fetch-CN91TIwV.js +1 -0
  61. package/dist-web/assets/{fetch-BcxrU2mr.js → fetch-CQt-gb-f.js} +1 -1
  62. package/dist-web/assets/{fetch-TCeykOkO.js → fetch-DPCJ-1l-.js} +1 -1
  63. package/dist-web/assets/{fetch-tIIVdXSv.js → fetch-gMB4wuBd.js} +1 -1
  64. package/dist-web/assets/{fetch-BYczbT4C.js → fetch-mFlEBZyB.js} +1 -1
  65. package/dist-web/assets/index---rXG1hZ.css +1 -0
  66. package/dist-web/assets/index--6C0sK6a.css +1 -0
  67. package/dist-web/assets/index-B6wEGata.js +173 -0
  68. package/dist-web/assets/index-Bg4GGPXv.js +1 -0
  69. package/dist-web/assets/index-BgVbj5qX.js +12 -0
  70. package/dist-web/assets/index-BkoXaBV_.js +64 -0
  71. package/dist-web/assets/index-C56IuV5U.css +1 -0
  72. package/dist-web/assets/index-CLRaKwpT.js +2 -0
  73. package/dist-web/assets/index-Dj1BSD7O.js +1 -0
  74. package/dist-web/assets/index-DosG7LmJ.css +1 -0
  75. package/dist-web/assets/index-DveHdPfK.js +1 -0
  76. package/dist-web/assets/{index-BX3tqfLz.css → index-MBRD3wPd.css} +1 -1
  77. package/dist-web/assets/index-RoDgJcHU.js +2 -0
  78. package/dist-web/assets/{index-fbWrQpgH.js → index-ZdCB7xcf.js} +4 -4
  79. package/dist-web/assets/index-aljYO5ms.js +1 -0
  80. package/dist-web/assets/people-page-header-Mupn-U_b.js +1 -0
  81. package/dist-web/assets/relationship-galaxy-viewport-Cwfa51ER.js +1 -0
  82. package/dist-web/assets/{vendor-echarts-CITQeskI.js → vendor-echarts-hJVnODyU.js} +2 -2
  83. package/dist-web/assets/{vendor-echarts-wordcloud-B1kQMklB.js → vendor-echarts-wordcloud-k5ih2Jl4.js} +1 -1
  84. package/dist-web/assets/{vendor-nuxt-ui-Zy8txNdC.js → vendor-nuxt-ui-Dr2T8_OZ.js} +2 -2
  85. package/dist-web/assets/{vendor-reka-ui-mMvma1EP.js → vendor-reka-ui-CzM4kDQ7.js} +1 -1
  86. package/dist-web/assets/{vendor-zrender-DFl4U2Oe.js → vendor-zrender-5DcYjSZk.js} +1 -1
  87. package/dist-web/assets/{web-H3XLx159.js → web-BakeV58u.js} +1 -1
  88. package/dist-web/assets/webworkerAll-D_6PgURS.js +83 -0
  89. package/dist-web/index.html +4 -4
  90. package/package.json +1 -1
  91. package/dist/chunk-AB6TAXTQ.mjs.map +0 -1
  92. package/dist/chunk-YBS3YQB6.mjs.map +0 -1
  93. package/dist/chunk-ZVDOFWL7.mjs.map +0 -1
  94. package/dist-web/assets/DebugToolsPanel-DFw6_G5V.css +0 -1
  95. package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-Do3x4aL3.js +0 -110
  96. package/dist-web/assets/MessageExportModal-rijqUusq.js +0 -1
  97. package/dist-web/assets/fetch-BAxKmbKF.js +0 -1
  98. package/dist-web/assets/fetch-Da_TBxrX.js +0 -1
  99. package/dist-web/assets/index-BzjLqlW_.js +0 -173
  100. package/dist-web/assets/index-C74qEDFh.js +0 -64
  101. package/dist-web/assets/index-CM6xNPFp.css +0 -1
  102. package/dist-web/assets/index-CgK2LLIF.js +0 -12
  103. package/dist-web/assets/index-CjkOvM3N.js +0 -2
  104. package/dist-web/assets/index-Dno7CADA.js +0 -1
  105. package/dist-web/assets/index-I3SWZjnW.css +0 -1
  106. /package/dist/{chunk-NJB2NNB2.mjs.map → chunk-6FPEP2ZX.mjs.map} +0 -0
  107. /package/dist/{chunk-3QBVO4J7.mjs.map → chunk-CIB23U32.mjs.map} +0 -0
  108. /package/dist/{http-MBILV37U.mjs.map → http-5E7ARYFW.mjs.map} +0 -0
  109. /package/dist/{import-EYV3GXHE.mjs.map → import-3KG6VK6O.mjs.map} +0 -0
  110. /package/dist/{src-36ZIR65K.mjs.map → src-UTBQAOJ3.mjs.map} +0 -0
  111. /package/dist/{stream-import-YZMZ56B5.mjs.map → stream-import-7HZ4IRYJ.mjs.map} +0 -0
@@ -0,0 +1,244 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-gRNfDyPu.js","assets/webworkerAll-D_6PgURS.js","assets/Filter-wRJtdXx9.js","assets/vendor-snapdom-XnBoh1gd.js","assets/index-BgVbj5qX.js","assets/vendor-reka-ui-CzM4kDQ7.js","assets/vendor-nuxt-ui-Dr2T8_OZ.js","assets/index-C56IuV5U.css","assets/index-CLRaKwpT.js","assets/index-aljYO5ms.js","assets/people-page-header-Mupn-U_b.js","assets/relationship-galaxy-viewport-Cwfa51ER.js","assets/WebGPURenderer-BnEdfdr_.js","assets/BufferResource-MsqP5sq3.js","assets/RenderTargetSystem-BSAQFamI.js","assets/WebGLRenderer-lfzmCZNT.js","assets/CanvasRenderer-BKCvcc2p.js"])))=>i.map(i=>d[i]);
2
+ import{_ as Xe}from"./vendor-snapdom-XnBoh1gd.js";import{a0 as Qo}from"./index-BgVbj5qX.js";import{b as Qi,a as Jo,m as ta}from"./index-CLRaKwpT.js";import{b as Ji,a as ea}from"./relationship-galaxy-viewport-Cwfa51ER.js";import{p as sa,d as ia,n as na,w as tn,z as ra,G as oa,P as aa,b as en}from"./vendor-reka-ui-CzM4kDQ7.js";var H=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.TextureUploaderWebGL="texture-uploader-webgl",i.TextureUploaderWebGPU="texture-uploader-webgpu",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(H||{});const fi=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},cs=(i,t)=>fi(i).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(fi).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...i){return i.map(fi).forEach(t=>{t.type.forEach(e=>{const s=this._addHandlers,n=this._queue;s[e]?s[e]?.(t):(n[e]=n[e]||[],n[e]?.push(t))})}),this},handle(i,t,e){const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const r=this._queue;return r[i]&&(r[i]?.forEach(o=>t(o)),delete r[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,o)=>cs(o.value,e)-cs(r.value,e)))},s=>{const n=t.findIndex(r=>r.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,r)=>cs(r,e)-cs(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})},mixin(i,...t){for(const e of t)Object.defineProperties(i.prototype,Object.getOwnPropertyDescriptors(e))}},ha={extension:{type:H.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Xe(()=>import("./browserAll-gRNfDyPu.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))}},la={extension:{type:H.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Xe(()=>import("./webworkerAll-D_6PgURS.js"),__vite__mapDeps([1,2,3,4,5,6,7,8,9,10,11]))}};class mt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new mt(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))}}var zs={exports:{}},sn;function ca(){return sn||(sn=1,(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,u,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new n(c,u||h,f),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],d]:h._events[p].push(d):(h._events[p]=d,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var f=0,d=u.length,p=new Array(d);f<d;f++)p[f]=u[f].fn;return p},a.prototype.listenerCount=function(l){var c=e?e+l:l,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,c,u,f,d,p){var x=e?e+l:l;if(!this._events[x])return!1;var g=this._events[x],m=arguments.length,_,y;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),m){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,f),!0;case 5:return g.fn.call(g.context,c,u,f,d),!0;case 6:return g.fn.call(g.context,c,u,f,d,p),!0}for(y=1,_=new Array(m-1);y<m;y++)_[y-1]=arguments[y];g.fn.apply(g.context,_)}else{var b=g.length,w;for(y=0;y<b;y++)switch(g[y].once&&this.removeListener(l,g[y].fn,void 0,!0),m){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,c);break;case 3:g[y].fn.call(g[y].context,c,u);break;case 4:g[y].fn.call(g[y].context,c,u,f);break;default:if(!_)for(w=1,_=new Array(m-1);w<m;w++)_[w-1]=arguments[w];g[y].fn.apply(g[y].context,_)}}return!0},a.prototype.on=function(l,c,u){return r(this,l,c,u,!1)},a.prototype.once=function(l,c,u){return r(this,l,c,u,!0)},a.prototype.removeListener=function(l,c,u,f){var d=e?e+l:l;if(!this._events[d])return this;if(!c)return o(this,d),this;var p=this._events[d];if(p.fn)p.fn===c&&(!f||p.once)&&(!u||p.context===u)&&o(this,d);else{for(var x=0,g=[],m=p.length;x<m;x++)(p[x].fn!==c||f&&!p[x].once||u&&p[x].context!==u)&&g.push(p[x]);g.length?this._events[d]=g.length===1?g[0]:g:o(this,d)}return this},a.prototype.removeAllListeners=function(l){var c;return l?(c=e?e+l:l,this._events[c]&&o(this,c)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,i.exports=a})(zs)),zs.exports}var ua=ca();const Yt=Qo(ua),da=Math.PI*2,fa=180/Math.PI,pa=Math.PI/180;class X{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new X(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 Hs.x=0,Hs.y=0,Hs}}const Hs=new X;class N{constructor(t=1,e=0,s=0,n=1,r=0,o=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=n,this.tx=r,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,n,r,o){return this.a=t,this.b=e,this.c=s,this.d=n,this.tx=r,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new X;const s=t.x,n=t.y;return e.x=this.a*s+this.c*n+this.tx,e.y=this.b*s+this.d*n+this.ty,e}applyInverse(t,e){e=e||new X;const s=this.a,n=this.b,r=this.c,o=this.d,a=this.tx,h=this.ty,l=1/(s*o+r*-n),c=t.x,u=t.y;return e.x=o*l*c+-r*l*u+(h*r-a*o)*l,e.y=s*l*u+-n*l*c+(-h*s+a*n)*l,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),n=this.a,r=this.c,o=this.tx;return this.a=n*e-this.b*s,this.b=n*s+this.b*e,this.c=r*e-this.d*s,this.d=r*s+this.d*e,this.tx=o*e-this.ty*s,this.ty=o*s+this.ty*e,this}append(t){const e=this.a,s=this.b,n=this.c,r=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*s+t.b*r,this.c=t.c*e+t.d*n,this.d=t.c*s+t.d*r,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*s+t.ty*r+this.ty,this}appendFrom(t,e){const s=t.a,n=t.b,r=t.c,o=t.d,a=t.tx,h=t.ty,l=e.a,c=e.b,u=e.c,f=e.d;return this.a=s*l+n*u,this.b=s*c+n*f,this.c=r*l+o*u,this.d=r*c+o*f,this.tx=a*l+h*u+e.tx,this.ty=a*c+h*f+e.ty,this}setTransform(t,e,s,n,r,o,a,h,l){return this.a=Math.cos(a+l)*r,this.b=Math.sin(a+l)*r,this.c=-Math.sin(a-h)*o,this.d=Math.cos(a-h)*o,this.tx=t-(s*this.a+n*this.c),this.ty=e-(s*this.b+n*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,n=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,n=this.c,r=this.d,o=t.pivot,a=-Math.atan2(-n,r),h=Math.atan2(s,e),l=Math.abs(a+h);return l<1e-5||Math.abs(da-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=h),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(n*n+r*r),t.position.x=this.tx+(o.x*e+o.y*n),t.position.y=this.ty+(o.x*s+o.y*r),t}invert(){const t=this.a,e=this.b,s=this.c,n=this.d,r=this.tx,o=t*n-e*s;return this.a=n/o,this.b=-e/o,this.c=-s/o,this.d=t/o,this.tx=(s*this.ty-n*r)/o,this.ty=-(t*this.ty-e*r)/o,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new N;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 ma.identity()}static get shared(){return ga.identity()}}const ga=new N,ma=new N,le=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ce=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ue=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],de=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],pi=[],xr=[],us=Math.sign;function xa(){for(let i=0;i<16;i++){const t=[];pi.push(t);for(let e=0;e<16;e++){const s=us(le[i]*le[e]+ue[i]*ce[e]),n=us(ce[i]*le[e]+de[i]*ce[e]),r=us(le[i]*ue[e]+ue[i]*de[e]),o=us(ce[i]*ue[e]+de[i]*de[e]);for(let a=0;a<16;a++)if(le[a]===s&&ce[a]===n&&ue[a]===r&&de[a]===o){t.push(a);break}}}for(let i=0;i<16;i++){const t=new N;t.set(le[i],ce[i],ue[i],de[i],0,0),xr.push(t)}}xa();const Y={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:i=>le[i],uY:i=>ce[i],vX:i=>ue[i],vY:i=>de[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>pi[i][t],sub:(i,t)=>pi[i][Y.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?Y.S:Y.N:Math.abs(t)*2<=Math.abs(i)?i>0?Y.E:Y.W:t>0?i>0?Y.SE:Y.SW:i>0?Y.NE:Y.NW,matrixAppendRotationInv:(i,t,e=0,s=0,n=0,r=0)=>{const o=xr[Y.inv(t)],a=o.a,h=o.b,l=o.c,c=o.d,u=e-Math.min(0,a*n,l*r,a*n+l*r),f=s-Math.min(0,h*n,c*r,h*n+c*r),d=i.a,p=i.b,x=i.c,g=i.d;i.a=a*d+h*x,i.b=a*p+h*g,i.c=l*d+c*x,i.d=l*p+c*g,i.tx=u*d+f*x+i.tx,i.ty=u*p+f*g+i.ty},transformRectCoords:(i,t,e,s)=>{const{x:n,y:r,width:o,height:a}=i,{x:h,y:l,width:c,height:u}=t;return e===Y.E?(s.set(n+h,r+l,o,a),s):e===Y.S?s.set(c-r-a+h,n+l,a,o):e===Y.W?s.set(c-n-o+h,u-r-a+l,o,a):e===Y.N?s.set(r+h,u-n-o+l,a,o):s.set(n+h,r+l,o,a)}},ds=[new X,new X,new X,new X];class Q{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}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 Q(0,0,0,0)}clone(){return new Q(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,s,n=.5){const{width:r,height:o}=this;if(r<=0||o<=0)return!1;const a=this.x,h=this.y,l=s*(1-n),c=s-l,u=a-l,f=a+r+l,d=h-l,p=h+o+l,x=a+c,g=a+r-c,m=h+c,_=h+o-c;return t>=u&&t<=f&&e>=d&&e<=p&&!(t>x&&t<g&&e>m&&e<_)}intersects(t,e){if(!e){const I=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=I)return!1;const M=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>M}const s=this.left,n=this.right,r=this.top,o=this.bottom;if(n<=s||o<=r)return!1;const a=ds[0].set(t.left,t.top),h=ds[1].set(t.left,t.bottom),l=ds[2].set(t.right,t.top),c=ds[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=s||Math.min(a.x,h.x,l.x,c.x)>=n||Math.max(a.y,h.y,l.y,c.y)<=r||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const f=u*(h.y-a.y),d=u*(a.x-h.x),p=f*s+d*r,x=f*n+d*r,g=f*s+d*o,m=f*n+d*o;if(Math.max(p,x,g,m)<=f*a.x+d*a.y||Math.min(p,x,g,m)>=f*c.x+d*c.y)return!1;const _=u*(a.y-l.y),y=u*(l.x-a.x),b=_*s+y*r,w=_*n+y*r,v=_*s+y*o,S=_*n+y*o;return!(Math.max(b,w,v,S)<=_*a.x+y*a.y||Math.min(b,w,v,S)>=_*c.x+y*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=n-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=r-n,this}getBounds(t){return t||(t=new Q),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,n=t.x+t.width,r=t.y+t.height;return e>=this.x&&e<this.x+this.width&&s>=this.y&&s<this.y+this.height&&n>=this.x&&n<this.x+this.width&&r>=this.y&&r<this.y+this.height}set(t,e,s,n){return this.x=t,this.y=e,this.width=s,this.height=n,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Os={default:-1};function at(i="default"){return Os[i]===void 0&&(Os[i]=-1),++Os[i]}const nn=new Set,ot="8.0.0",ya="8.3.4",Me={quiet:!1,noColor:!1},$=((i,t,e=3)=>{if(Me.quiet||nn.has(t))return;let s=new Error().stack;const n=`${t}
3
+ Deprecated since v${i}`,r=typeof console.groupCollapsed=="function"&&!Me.noColor;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",n):(s=s.split(`
4
+ `).splice(e).join(`
5
+ `),r?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(s))),nn.add(t)});Object.defineProperties($,{quiet:{get:()=>Me.quiet,set:i=>{Me.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>Me.noColor,set:i=>{Me.noColor=i},enumerable:!0,configurable:!1}});const yr=()=>{};function Ae(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function rn(i){return!(i&i-1)&&!!i}function _r(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const on=Object.create(null);function _a(i){const t=on[i];return t===void 0&&(on[i]=at("resource")),t}const br=class wr extends Yt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...wr.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){$(ot,"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(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=_a(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};br.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Pe=br;const vr=class Sr extends Yt{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=at("textureSource"),this._resourceType="textureSource",this._resourceId=at("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={...Sr.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 Pe(_r(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){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=at("resource"),this.emit("change",this),this.emit("unload",this);for(const t in this._gpuData)this._gpuData[t]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*s),r=Math.round(e*s);return this.width=n/s,this.height=r/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=at("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=rn(this.pixelWidth)&&rn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};vr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Rt=vr;class Bi extends Rt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Bi.extension=H.TextureSource;const an=new N;class ba{constructor(t,e){this.mapCoord=new N,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);const s=this.mapCoord;for(let n=0;n<t.length;n+=2){const r=t[n],o=t[n+1];e[n]=r*s.a+o*s.c+s.tx,e[n+1]=r*s.b+o*s.d+s.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const s=t.orig,n=t.trim;n&&(an.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(an));const r=t.source,o=this.uClampFrame,a=this.clampMargin/r._resolution,h=this.clampOffset/r._resolution;return o[0]=(t.frame.x+a+h)/r.width,o[1]=(t.frame.y+a+h)/r.height,o[2]=(t.frame.x+t.frame.width-a+h)/r.width,o[3]=(t.frame.y+t.frame.height-a+h)/r.height,this.uClampOffset[0]=this.clampOffset/r.pixelWidth,this.uClampOffset[1]=this.clampOffset/r.pixelHeight,this.isSimple=t.frame.width===r.width&&t.frame.height===r.height&&t.rotate===0,!0}}class K extends Yt{constructor({source:t,label:e,frame:s,orig:n,trim:r,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=at("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Q,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=t?.source??new Rt,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:c,height:u}=this._source;this.frame.width=c,this.frame.height=u}this.orig=n||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!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 ba(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:s,height:n}=this._source,r=e.x/s,o=e.y/n,a=e.width/s,h=e.height/n;let l=this.rotate;if(l){const c=a/2,u=h/2,f=r+c,d=o+u;l=Y.add(l,Y.NW),t.x0=f+c*Y.uX(l),t.y0=d+u*Y.uY(l),l=Y.add(l,2),t.x1=f+c*Y.uX(l),t.y1=d+u*Y.uY(l),l=Y.add(l,2),t.x2=f+c*Y.uX(l),t.y2=d+u*Y.uY(l),l=Y.add(l,2),t.x3=f+c*Y.uX(l),t.y3=d+u*Y.uY(l)}else t.x0=r,t.y0=o,t.x1=r+a,t.y1=o,t.x2=r+a,t.y2=o+h,t.x3=r,t.y3=o+h}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 $(ot,"Texture.baseTexture is now Texture.source"),this._source}}K.EMPTY=new K({label:"EMPTY",source:new Rt({label:"EMPTY"})});K.EMPTY.destroy=yr;K.WHITE=new K({source:new Bi({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});K.WHITE.destroy=yr;function Cr(i,t,e){const{width:s,height:n}=e.orig,r=e.trim;if(r){const o=r.width,a=r.height;i.minX=r.x-t._x*s,i.maxX=i.minX+o,i.minY=r.y-t._y*n,i.maxY=i.minY+a}else i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}const hn=new N;class It{constructor(t=1/0,e=1/0,s=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=hn,this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Q);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=hn,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,r){r||(r=this.matrix);const o=r.a,a=r.b,h=r.c,l=r.d,c=r.tx,u=r.ty;let f=this.minX,d=this.minY,p=this.maxX,x=this.maxY,g=o*t+h*e+c,m=a*t+l*e+u;g<f&&(f=g),m<d&&(d=m),g>p&&(p=g),m>x&&(x=m),g=o*s+h*e+c,m=a*s+l*e+u,g<f&&(f=g),m<d&&(d=m),g>p&&(p=g),m>x&&(x=m),g=o*t+h*n+c,m=a*t+l*n+u,g<f&&(f=g),m<d&&(d=m),g>p&&(p=g),m>x&&(x=m),g=o*s+h*n+c,m=a*s+l*n+u,g<f&&(f=g),m<d&&(d=m),g>p&&(p=g),m>x&&(x=m),this.minX=f,this.minY=d,this.maxX=p,this.maxY=x}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,s=this.minY,n=this.maxX,r=this.maxY,{a:o,b:a,c:h,d:l,tx:c,ty:u}=t;let f=o*e+h*s+c,d=a*e+l*s+u;this.minX=f,this.minY=d,this.maxX=f,this.maxY=d,f=o*n+h*s+c,d=a*n+l*s+u,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+h*r+c,d=a*e+l*r+u,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*n+h*r+c,d=a*n+l*r+u,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,s,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>n&&(this.maxY=n),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 It(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,n){let r=this.minX,o=this.minY,a=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,u=n.c,f=n.d,d=n.tx,p=n.ty;for(let x=e;x<s;x+=2){const g=t[x],m=t[x+1],_=l*g+u*m+d,y=c*g+f*m+p;r=_<r?_:r,o=y<o?y:o,a=_>a?_:a,h=y>h?y:h}this.minX=r,this.minY=o,this.maxX=a,this.maxY=h}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 wa={grad:.9,turn:360,rad:360/(2*Math.PI)},$t=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},ft=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},At=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},Mr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},ln=function(i){return{r:At(i.r,0,255),g:At(i.g,0,255),b:At(i.b,0,255),a:At(i.a)}},Us=function(i){return{r:ft(i.r),g:ft(i.g),b:ft(i.b),a:ft(i.a,3)}},va=/^#([0-9a-f]{3,8})$/i,fs=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},Tr=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=Math.max(t,e,s),o=r-Math.min(t,e,s),a=o?r===t?(e-s)/o:r===e?2+(s-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:n}},Ar=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var r=Math.floor(t),o=s*(1-e),a=s*(1-(t-r)*e),h=s*(1-(1-t+r)*e),l=r%6;return{r:255*[s,a,o,o,h,s][l],g:255*[h,s,s,a,o,o][l],b:255*[o,o,h,s,s,a][l],a:n}},cn=function(i){return{h:Mr(i.h),s:At(i.s,0,100),l:At(i.l,0,100),a:At(i.a)}},un=function(i){return{h:ft(i.h),s:ft(i.s),l:ft(i.l),a:ft(i.a,3)}},dn=function(i){return Ar((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Ve=function(i){return{h:(t=Tr(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},Sa=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ca=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ma=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ta=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gi={string:[[function(i){var t=va.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?ft(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?ft(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=Ma.exec(i)||Ta.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:ln({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(i){var t=Sa.exec(i)||Ca.exec(i);if(!t)return null;var e,s,n=cn({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(wa[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return dn(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=n===void 0?1:n;return $t(t)&&$t(e)&&$t(s)?ln({r:Number(t),g:Number(e),b:Number(s),a:Number(r)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,r=n===void 0?1:n;if(!$t(t)||!$t(e)||!$t(s))return null;var o=cn({h:Number(t),s:Number(e),l:Number(s),a:Number(r)});return dn(o)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,r=n===void 0?1:n;if(!$t(t)||!$t(e)||!$t(s))return null;var o=(function(a){return{h:Mr(a.h),s:At(a.s,0,100),v:At(a.v,0,100),a:At(a.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(r)});return Ar(o)},"hsv"]]},fn=function(i,t){for(var e=0;e<t.length;e++){var s=t[e][0](i);if(s)return[s,t[e][1]]}return[null,void 0]},Aa=function(i){return typeof i=="string"?fn(i.trim(),gi.string):typeof i=="object"&&i!==null?fn(i,gi.object):[null,void 0]},Ys=function(i,t){var e=Ve(i);return{h:e.h,s:At(e.s+100*t,0,100),l:e.l,a:e.a}},Ns=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},pn=function(i,t){var e=Ve(i);return{h:e.h,s:e.s,l:At(e.l+100*t,0,100),a:e.a}},mi=(function(){function i(t){this.parsed=Aa(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return ft(Ns(this.rgba),2)},i.prototype.isDark=function(){return Ns(this.rgba)<.5},i.prototype.isLight=function(){return Ns(this.rgba)>=.5},i.prototype.toHex=function(){return t=Us(this.rgba),e=t.r,s=t.g,n=t.b,o=(r=t.a)<1?fs(ft(255*r)):"","#"+fs(e)+fs(s)+fs(n)+o;var t,e,s,n,r,o},i.prototype.toRgb=function(){return Us(this.rgba)},i.prototype.toRgbString=function(){return t=Us(this.rgba),e=t.r,s=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+n+", "+r+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,r},i.prototype.toHsl=function(){return un(Ve(this.rgba))},i.prototype.toHslString=function(){return t=un(Ve(this.rgba)),e=t.h,s=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+r+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,r},i.prototype.toHsv=function(){return t=Tr(this.rgba),{h:ft(t.h),s:ft(t.s),v:ft(t.v),a:ft(t.a,3)};var t},i.prototype.invert=function(){return Ht({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),Ht(Ys(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Ht(Ys(this.rgba,-t))},i.prototype.grayscale=function(){return Ht(Ys(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Ht(pn(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Ht(pn(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?Ht({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ft(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Ve(this.rgba);return typeof t=="number"?Ht({h:t,s:e.s,l:e.l,a:e.a}):ft(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Ht(t).toHex()},i})(),Ht=function(i){return i instanceof mi?i:new mi(i)},gn=[],Pa=function(i){i.forEach(function(t){gn.indexOf(t)<0&&(t(mi,gi),gn.push(t))})};function ka(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var n in e)s[e[n]]=n;var r={};i.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=s[this.toHex()];if(l)return l;if(o?.closest){var c=this.toRgb(),u=1/0,f="black";if(!r.length)for(var d in e)r[d]=new i(e[d]).toRgb();for(var p in e){var x=(a=c,h=r[p],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));x<u&&(u=x,f=p)}return f}},t.string.push([function(o){var a=o.toLowerCase(),h=a==="transparent"?"#0000":e[a];return h?new i(h).toRgb():null},"name"])}Pa([ka]);const ke=class Ue{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 Ue)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){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,o)=>r===e[o]);if(t!==null&&e!==null){const r=Object.keys(t),o=Object.keys(e);return r.length!==o.length?!1:r.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,n,r]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,n,r]=Ue._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const 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,s,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,s=(o>>8&255)/255,n=(o&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,r=255]=t,e/=255,s/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Ue.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=Ht(t);o.isValid()&&({r:e,g:s,b:n,a:r}=o.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Ue||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};ke.shared=new ke;ke._temp=new ke;ke.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let nt=ke;const Ia={cullArea:null,cullable:!1,cullableChildren:!0};let Xs=0;const mn=500;function bt(...i){Xs!==mn&&(Xs++,Xs===mn?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const is={_registeredResources:new Set,register(i){this._registeredResources.add(i)},unregister(i){this._registeredResources.delete(i)},release(){this._registeredResources.forEach(i=>i.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(i){return this._registeredResources.has(i)},reset(){this._registeredResources.clear()}};class Ra{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}}class Ea{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 Ra(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const vt=new Ea;is.register(vt);const Ba={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(i){typeof i=="boolean"&&i===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(i===!0?{}:i))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(i){$("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function Wa(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const r=s-e;for(n=t;n<r;++n)i[n]=i[n+e];i.length=r}const Ga={allowChildren:!0,removeChildren(i=0,t){const e=t??this.children.length,s=e-i,n=[];if(s>0&&s<=e){for(let o=e-1;o>=i;o--){const a=this.children[o];a&&(n.push(a),a.parent=null)}Wa(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let o=0;o<n.length;++o){const a=n[o];a.parentRenderLayer?.detach(a),this.emit("childRemoved",a,this,o),n[o].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(s===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const t=this.getChildAt(i);return this.removeChild(t)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||$(ot,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const s=i.parent===this;if(i.parent){const r=i.parent.children.indexOf(i);if(s){if(r===t)return i;i.parent.children.splice(r,1)}else i.removeFromParent()}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(i),this.sortableChildren&&(this.sortDirty=!0),s||(this.emit("childAdded",i,this,t),i.emit("added",this)),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i},replaceChild(i,t){i.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(i)),t.setFromMatrix(i.localTransform),t.updateLocalTransform(),this.removeChild(i)}},Fa={collectRenderables(i,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(i,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,i):this.collectRenderablesWithEffects(i,t,e))},collectRenderablesSimple(i,t,e){const s=this.children,n=s.length;for(let r=0;r<n;r++)s[r].collectRenderables(i,t,e)},collectRenderablesWithEffects(i,t,e){const{renderPipes:s}=t;for(let n=0;n<this.effects.length;n++){const r=this.effects[n];s[r.pipe].push(r,this,i)}this.collectRenderablesSimple(i,t,e);for(let n=this.effects.length-1;n>=0;n--){const r=this.effects[n];s[r.pipe].pop(r,this,i)}}};class xn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class Da{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const s=this._tests[e];if(s.test(t))return vt.get(s.maskClass,t)}return t}returnMaskEffect(t){vt.return(t)}}const xi=new Da;ht.handleByList(H.MaskEffect,xi._effectClasses);const La={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0)},addEffect(i){this.effects.indexOf(i)===-1&&(this.effects.push(i),this.effects.sort((e,s)=>e.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(i){const t=this._maskEffect;t?.mask!==i&&(t&&(this.removeEffect(t),xi.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=xi.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(i){this._maskOptions={...this._maskOptions,...i},i.mask&&(this.mask=i.mask),this._markStructureAsChanged()},set filters(i){!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new xn);i=i;const e=i?.length>0,s=t.filters?.length>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){return this._filterEffect?.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new xn),this._filterEffect.filterArea=i},get filterArea(){return this._filterEffect?.filterArea}},za={label:null,get name(){return $(ot,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){$(ot,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const n=e[s];if(n.label===i||i instanceof RegExp&&i.test(n.label))return n}if(t)for(let s=0;s<e.length;s++){const r=e[s].getChildByLabel(i,!0);if(r)return r}return null},getChildrenByLabel(i,t=!1,e=[]){const s=this.children;for(let n=0;n<s.length;n++){const r=s[n];(r.label===i||i instanceof RegExp&&i.test(r.label))&&e.push(r)}if(t)for(let n=0;n<s.length;n++)s[n].getChildrenByLabel(i,!0,e);return e}},_t=vt.getPool(N),Kt=vt.getPool(It),Ha=new N,Oa={getFastGlobalBounds(i,t){t||(t=new It),t.clear(),this._getGlobalBoundsRecursive(!!i,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(i,t,e){let s=t;if(i&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(s=Kt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const r=this.children;for(let o=0;o<r.length;o++)r[o]._getGlobalBoundsRecursive(i,s,e)}if(n){let r=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(r||(r=!0,s.applyMatrix(o.worldTransform)),this.effects[a].addBounds(s,!0));r&&s.applyMatrix(o.worldTransform.copyTo(Ha).invert()),t.addBounds(s),Kt.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),Kt.return(s))}};function Pr(i,t,e){e.clear();let s,n;return i.parent?t?s=i.parent.worldTransform:(n=_t.get().identity(),s=Wi(i,n)):s=N.IDENTITY,kr(i,e,s,t),n&&_t.return(n),e.isValid||e.set(0,0,0,0),e}function kr(i,t,e,s){if(!i.visible||!i.measurable)return;let n;s?n=i.worldTransform:(i.updateLocalTransform(),n=_t.get(),n.appendFrom(i.localTransform,e));const r=t,o=!!i.effects.length;if(o&&(t=Kt.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{const a=i.bounds;a&&!a.isEmpty()&&(t.matrix=n,t.addBounds(a));for(let h=0;h<i.children.length;h++)kr(i.children[h],t,n,s)}if(o){for(let a=0;a<i.effects.length;a++)i.effects[a].addBounds?.(t);r.addBounds(t,N.IDENTITY),Kt.return(t)}s||_t.return(n)}function Wi(i,t){const e=i.parent;return e&&(Wi(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Ir(i,t){if(i===16777215||!t)return t;if(t===16777215||!i)return i;const e=i>>16&255,s=i>>8&255,n=i&255,r=t>>16&255,o=t>>8&255,a=t&255,h=e*r/255|0,l=s*o/255|0,c=n*a/255|0;return(h<<16)+(l<<8)+c}const yn=16777215;function _n(i,t){return i===yn?t:t===yn?i:Ir(i,t)}function Ms(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const Ua={getGlobalAlpha(i){if(i)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(i=new N,t){if(t)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Wi(this,_t.get().identity());return i.appendFrom(this.localTransform,e),_t.return(e),i},getGlobalTint(i){if(i)return this.renderGroup?Ms(this.renderGroup.worldColor):this.parentRenderGroup?Ms(_n(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=_n(t,e.localColor),e=e.parent;return Ms(t)}};function Rr(i,t,e){return t.clear(),e||(e=N.IDENTITY),Er(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function Er(i,t,e,s,n){let r;if(n)r=_t.get(),r=e.copyTo(r);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const h=i.localTransform;r=_t.get(),r.appendFrom(h,e)}const o=t,a=!!i.effects.length;if(a&&(t=Kt.get().clear()),i.boundsArea)t.addRect(i.boundsArea,r);else{i.renderPipeId&&(t.matrix=r,t.addBounds(i.bounds));const h=i.children;for(let l=0;l<h.length;l++)Er(h[l],t,r,s,!1)}if(a){for(let h=0;h<i.effects.length;h++)i.effects[h].addLocalBounds?.(t,s);o.addBounds(t,N.IDENTITY),Kt.return(t)}_t.return(r)}function Br(i,t){const e=i.children;for(let s=0;s<e.length;s++){const n=e[s],r=n.uid,o=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,a=t.index;(t.data[a]!==r||t.data[a+1]!==o)&&(t.data[t.index]=r,t.data[t.index+1]=o,t.didChange=!0),t.index=a+2,n.children.length&&Br(n,t)}return t.didChange}const Ya=new N,Na={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=i/t*e:this.scale.x=e},_setHeight(i,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=i/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new It});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),Br(this,i),i.didChange&&Rr(this,i.localBounds,Ya),i.localBounds},getBounds(i,t){return Pr(this,i,t||new It)}},Xa={_onRender:null,set onRender(i){const t=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},Va={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,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($a))}};function $a(i,t){return i._zIndex-t._zIndex}const ja={getGlobalPosition(i=new X,t=!1){return this.parent?this.parent.toGlobal(this._position,i,t):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,t,e=!1){const s=this.getGlobalTransform(_t.get(),e);return t=s.apply(i,t),_t.return(s),t},toLocal(i,t,e,s){t&&(i=t.toGlobal(i,e,s));const n=this.getGlobalTransform(_t.get(),s);return e=n.applyInverse(i,e),_t.return(n),e}};class Gi{constructor(){this.uid=at("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"])}}let qa=0;class Ka{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Pe(this.textureOptions)}createTexture(t,e,s,n){const r=new Rt({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:n});return new K({source:r,label:`texturePool_${qa++}`})}getOptimalTexture(t,e,s=1,n,r=!1){let o=Math.ceil(t*s-1e-6),a=Math.ceil(e*s-1e-6);o=Ae(o),a=Ae(a);const h=n?1:0,l=r?1:0,c=(o<<17)+(a<<2)+(l<<1)+h;this._texturePool[c]||(this._texturePool[c]=[]);let u=this._texturePool[c].pop();return u||(u=this.createTexture(o,a,n,r)),u.source._resolution=s,u.source.width=o/s,u.source.height=a/s,u.source.pixelWidth=o,u.source.pixelHeight=a,u.frame.x=0,u.frame.y=0,u.frame.width=t,u.frame.height=e,u.updateUvs(),this._poolKeyHash[u.uid]=c,u}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t,e=!1){const s=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[s].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let n=0;n<s.length;n++)s[n].destroy(!0)}this._texturePool={}}}const Bs=new Ka;is.register(Bs);class Za{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new N,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 Gi,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s<e.length;s++){const n=e[s];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Bs.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let s=0;s<e.length;s++)this.removeChild(e[s])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let s=0;s<e.length;s++)this._getChildren(e[s],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const s=t.children;for(let n=0;n<s.length;n++)this._getChildren(s[n],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new N),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new N),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;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new N),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 Qa(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const Vs=new mt(null),ps=new mt(null),$s=new mt(null,1,1),gs=new mt(null),bn=1,Ja=2,js=4;class kt extends Yt{constructor(t={}){super(),this.uid=at("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 N,this.relativeGroupTransform=new N,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new mt(this,0,0),this._scale=$s,this._pivot=ps,this._origin=gs,this._skew=Vs,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=[],Qa(this,t,{children:!0,parent:!0,effects:!0}),t.children?.forEach(e=>this.addChild(e)),t.parent?.addChild(this)}static mixin(t){$("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),ht.mixin(kt,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||$(ot,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n<t.length;n++)this.addChild(t[n]);return t[0]}const e=t[0],s=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),s&&(s.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,s&&s.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 n=0;n<t.length;n++)this.removeChild(t[n]);return t[0]}const e=t[0],s=this.children.indexOf(e);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=vt.get(Za,this),this.groupTransform=N.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),vt.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 N),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*fa}set angle(t){this.rotation=t*pa}get pivot(){return this._pivot===ps&&(this._pivot=new mt(this,0,0)),this._pivot}set pivot(t){this._pivot===ps&&(this._pivot=new mt(this,0,0),this._origin!==gs&&bt("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===Vs&&(this._skew=new mt(this,0,0)),this._skew}set skew(t){this._skew===Vs&&(this._skew=new mt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===$s&&(this._scale=new mt(this,1,1)),this._scale}set scale(t){this._scale===$s&&(this._scale=new mt(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===gs&&(this._origin=new mt(this,0,0)),this._origin}set origin(t){this._origin===gs&&(this._origin=new mt(this,0,0),this._pivot!==ps&&bt("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){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX:this.scale.x,typeof t.scaleY=="number"?t.scaleY:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,r=this._origin,o=this._position,a=s._x,h=s._y,l=n._x,c=n._y,u=-r._x,f=-r._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(u*e.a+f*e.c)-u,e.ty=o._y-(l*e.b+c*e.d)+(u*e.b+f*e.d)-f}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=bn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=nt.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=bn,this._onUpdate())}get tint(){return Ms(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ja,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=js,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=js,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=js,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 n=0;n<e.length;++n)e[n].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}ht.mixin(kt,Ga,Oa,ja,Xa,Na,La,za,Va,Ia,Ba,Ua,Fa);class Fi extends kt{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 It(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){const e=this.bounds,{x:s,y:n}=t;return s>=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(const 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,s){const{renderPipes:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const o=n[this.renderPipeId];o?.addRenderable&&o.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,h=a.length;for(let l=0;l<h;l++)a[l].collectRenderables(t,e,s);n.blendMode.popBlendMode(t)}}class Ke extends Fi{constructor(t=K.EMPTY){t instanceof K&&(t={texture:t});const{texture:e=K.EMPTY,anchor:s,roundPixels:n,width:r,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 mt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof K?new Ke(t):new Ke(K.from(t,e))}set texture(t){t||(t=K.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return Cr(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return $("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:n,height:r}=e.orig;s.minX=-t._x*n,s.maxX=s.minX+n,s.minY=-t._y*r,s.maxY=s.minY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t?.texture){const s=typeof t=="boolean"?t:t?.textureSource;this._texture.destroy(s)}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)}}const th=new It;function Wr(i,t,e){const s=th;i.measurable=!0,Pr(i,e,s),t.addBoundsMask(s),i.measurable=!1}function Gr(i,t,e){const s=Kt.get();i.measurable=!0;const n=_t.get().identity(),r=Fr(i,e,n);Rr(i,s,r),i.measurable=!1,t.addBoundsMask(s),_t.return(n),Kt.return(s)}function Fr(i,t,e){return i?(i!==t&&(Fr(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(bt("Mask bounds, renderable is not inside the root container"),e)}class Dr{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 Ke),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||Wr(this.mask,t,e)}addLocalBounds(t,e){Gr(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Ke}}Dr.extension=H.MaskEffect;class Lr{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"}}Lr.extension=H.MaskEffect;class zr{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){Wr(this.mask,t,e)}addLocalBounds(t,e){Gr(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof kt}}zr.extension=H.MaskEffect;const eh={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let wn=eh;const ct={get(){return wn},set(i){wn=i}};class Hr extends Rt{constructor(t){t.resource||(t.resource=ct.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}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"))}}Hr.extension=H.TextureSource;class As extends Rt{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}}As.extension=H.TextureSource;var Ps=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(Ps||{});class qs{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Or=class Ct{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new qs(null,null,1/0),this.deltaMS=1/Ct.targetFPMS,this.elapsedMS=1/Ct.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=Ps.NORMAL){return this._addListener(new qs(t,e,s))}addOnce(t,e,s=Ps.NORMAL){return this._addListener(new qs(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const r=t-this._lastFrame|0;if(r<this._minElapsedMS)return;this._lastFrame=t-r%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Ct.targetFPMS;const s=this._head;let n=s.next;for(;n;)n=n.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(Math.max(0,t)/1e3,Ct.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(!Ct._shared){const t=Ct._shared=new Ct;t.autoStart=!0,t._protected=!0}return Ct._shared}static get system(){if(!Ct._system){const t=Ct._system=new Ct;t.autoStart=!0,t._protected=!0}return Ct._system}};Or.targetFPMS=.06;let ge=Or,Ks;async function sh(){return Ks??(Ks=(async()=>{const t=ct.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(s),t.getExtension("WEBGL_lose_context")?.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Ks}const Ws=class Ur extends Rt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Ur.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){const t=ge.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await sh(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ge.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||(ge.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ge.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ws.extension=H.TextureSource;Ws.defaultOptions={...Rt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ws.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ih=Ws;const Se=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class nh{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){const e=this._cache.get(t);return e||bt(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=Se(t);let n;for(let h=0;h<this.parsers.length;h++){const l=this.parsers[h];if(l.test(e)){n=l.getCacheableAssets(s,e);break}}const r=new Map(Object.entries(n||{}));n||s.forEach(h=>{r.set(h,e)});const o=[...r.keys()],a={cacheKeys:o,keys:s};s.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&bt("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){bt(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const Ce=new nh,yi=[];ht.handleByList(H.TextureSource,yi);function Yr(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n<yi.length;n++){const r=yi[n];if(r.test(e))return new r(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function rh(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,n=e?i:{resource:i};if(!t&&Ce.has(s))return Ce.get(s);const r=new K({source:Yr(n)});return r.on("destroy",()=>{Ce.has(s)&&Ce.remove(s)}),t||Ce.set(s,r),r}function oh(i,t=!1){return typeof i=="string"?Ce.get(i):i instanceof Rt?new K({source:i}):rh(i,t)}K.from=oh;Rt.from=Yr;ht.add(Dr,Lr,zr,ih,As,Hr,Bi);var Nr=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Nr||{});function Ft(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Ge(i){return i.split("?")[0].split("#")[0]}function ah(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hh(i,t,e){return i.replace(new RegExp(ah(t),"g"),e)}function lh(i,t){let e="",s=0,n=-1,r=0,o=-1;for(let a=0;a<=i.length;++a){if(a<i.length)o=i.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(n===a-1||r===1))if(n!==a-1&&r===2){if(e.length<2||s!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),n=a,r=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=a,r=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,a)}`:e=i.slice(n+1,a),s=a-n-1;n=a,r=0}else o===46&&r!==-1?++r:r=-1}return e}const Ze={toPosix(i){return hh(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){Ft(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(Ft(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Ge(this.toPosix(t??ct.get().getBaseUrl())),n=Ge(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?Ze.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(Ft(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=lh(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return Ft(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e<i.length;++e){const s=i[e];if(Ft(s),s.length>0)if(t===void 0)t=s;else{const n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(Ft(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const r=this.getProtocol(i),o=i;i=i.slice(r.length);for(let a=i.length-1;a>=1;--a)if(t=i.charCodeAt(a),t===47){if(!n){s=a;break}}else n=!1;return s===-1?e?"/":this.isUrl(o)?r+i:r:e&&s===1?"//":r+i.slice(0,s)},rootname(i){Ft(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){Ft(i),t&&Ft(t),i=Ge(this.toPosix(i));let e=0,s=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let o=t.length-1,a=-1;for(r=i.length-1;r>=0;--r){const h=i.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else a===-1&&(n=!1,a=r+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(s=r):(o=-1,s=a))}return e===s?s=a:s===-1&&(s=i.length),i.slice(e,s)}for(r=i.length-1;r>=0;--r)if(i.charCodeAt(r)===47){if(!n){e=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":i.slice(e,s)},extname(i){Ft(i),i=Ge(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,r=0;for(let o=i.length-1;o>=0;--o){const a=i.charCodeAt(o);if(a===47){if(!n){e=o+1;break}continue}s===-1&&(n=!1,s=o+1),a===46?t===-1?t=o:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){Ft(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Ge(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let r=-1,o=0,a=-1,h=!0,l=i.length-1,c=0;for(;l>=n;--l){if(e=i.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||a===-1||c===0||c===1&&r===a-1&&r===o+1?a!==-1&&(o===0&&s?t.base=t.name=i.slice(1,a):t.base=t.name=i.slice(o,a)):(o===0&&s?(t.name=i.slice(1,r),t.base=i.slice(1,a)):(t.name=i.slice(o,r),t.base=i.slice(o,a)),t.ext=i.slice(r,a)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Xr(i,t,e,s,n){const r=t[e];for(let o=0;o<r.length;o++){const a=r[o];e<t.length-1?Xr(i.replace(s[e],a),t,e+1,s,n):n.push(i.replace(s[e],a))}}function ch(i){const t=/\{(.*?)\}/g,e=i.match(t),s=[];if(e){const n=[];e.forEach(r=>{const o=r.substring(1,r.length-1).split(",");n.push(o)}),Xr(i,n,0,e,s)}else s.push(i);return s}const vn=i=>!Array.isArray(i);class Vr{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{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return Se(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(o=>o?.src??o):r?.src?r.src:r,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&bt("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,o])=>typeof o=="string"||Array.isArray(o)?{alias:r,src:o}:{alias:r,...o})),n.forEach(r=>{const o=r.src,a=r.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);s.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));s.push(...l),h=[...a,...l]}this.add({...r,alias:h,src:o})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&bt(`[Resolver] already has key: ${r} overwriting`)},Se(e).forEach(r=>{const{src:o}=r;let{data:a,format:h,loadParser:l,parser:c}=r;const u=Se(o).map(x=>typeof x=="string"?ch(x):Array.isArray(x)?x:[x]),f=this.getAlias(r);Array.isArray(f)?f.forEach(s):s(f);const d=[],p=x=>{const g=this._parsers.find(m=>m.test(x));return{src:x,...g?.parse(x)}};u.forEach(x=>{x.forEach(g=>{let m={};if(typeof g!="object"?m=p(g):(a=g.data??a,h=g.format??h,(g.loadParser||g.parser)&&(l=g.loadParser??l,c=g.parser??c),m={...p(g.src),...g}),!f)throw new Error(`[Resolver] alias is undefined for this asset: ${m.src}`);m=this._buildResolvedAsset(m,{aliases:f,data:a,format:h,loadParser:l,parser:c,progressSize:r.progressSize}),d.push(m)})}),f.forEach(x=>{this._assetMap[x]=d})})}resolveBundle(t){const e=vn(t);t=Se(t);const s={};return t.forEach(n=>{const r=this._bundles[n];if(r){const o=this.resolve(r),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(n,h)]=l}s[n]=a}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=vn(t);t=Se(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const o=this._getPreferredOrder(r);o?.priority.forEach(a=>{o.params[a].forEach(h=>{const l=r.filter(c=>c[a]?c[a]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[e],n=this._preferredOrder.find(r=>r.params.format.includes(s.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:s,data:n,loadParser:r,parser:o,format:a,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=Ze.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??uh(t.src),h!==void 0&&(t.progressSize=h),t}}Vr.RETINA_PREFIX=/@([0-9\.]+)x/;function uh(i){return i.split(".").pop().split("?").shift().split("#").shift()}const Sn=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},$r=class Ye{constructor(t,e){this.linkedSheets=[];let s=t;t?.source instanceof Rt&&(s={texture:t,data:e});const{texture:n,data:r,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=n instanceof K?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=r;const a=parseFloat(r.meta.scale);a?(this.resolution=a,n.source.resolution=this.resolution):this.resolution=n.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<=Ye.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let s=t;const n=e?1/0:Ye.BATCH_SIZE;for(;s-t<n&&s<this._frameKeys.length;){const r=this._frameKeys[s],o=this._frames[r],a=o.frame;if(a){let h=null,l=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,u=new Q(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?h=new Q(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):h=new Q(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&&(l=new Q(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[r]=new K({source:this.textureSource,frame:h,orig:u,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:r.toString()})}s++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const n=t[e][s];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Ye.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Ye.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const 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=[]}};$r.BATCH_SIZE=1e3;let Cn=$r;const dh=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function jr(i,t,e){const s={};if(i.forEach(n=>{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=Ze.dirname(i[0]);t.linkedSheets.forEach((r,o)=>{const a=jr([`${n}/${t.data.meta.related_multi_packs[o]}`],r,!0);Object.assign(s,a)})}return s}const fh={extension:H.Asset,cache:{test:i=>i instanceof Cn,getCacheableAssets:(i,t)=>jr(i,t,!1)},resolver:{extension:{type:H.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&dh.includes(n)},parse:i=>{const t=i.split(".");return{resolution:parseFloat(Vr.RETINA_PREFIX.exec(i)?.[1]??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:H.LoadParser,priority:Nr.Normal,name:"spritesheetLoader"},async testParse(i,t){return Ze.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){const{texture:s,imageFilename:n,textureOptions:r,cachePrefix:o}=t?.data??{};let a=Ze.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(s instanceof K)h=s;else{const u=Sn(a+(n??i.meta.image),t.src);h=(await e.load([{src:u,data:r}]))[u]}const l=new Cn({texture:h.source,data:i,cachePrefix:o});await l.parse();const c=i?.meta?.related_multi_packs;if(Array.isArray(c)){const u=[];for(const d of c){if(typeof d!="string")continue;let p=a+d;t.data?.ignoreMultiPack||(p=Sn(p,t.src),u.push(e.load({src:p,data:{textureOptions:r,ignoreMultiPack:!0}})))}const f=await Promise.all(u);l.linkedSheets=f,f.forEach(d=>{d.linkedSheets=[l].concat(l.linkedSheets.filter(p=>p!==d))})}return l},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};ht.add(fh);const Zs=Object.create(null),Mn=Object.create(null);function Di(i,t){let e=Mn[i];return e===void 0&&(Zs[t]===void 0&&(Zs[t]=1),Mn[i]=e=Zs[t]++),e}let ms;function qr(){return(!ms||ms?.isContextLost())&&(ms=ct.get().createCanvas().getContext("webgl",{})),ms}let xs;function ph(){if(!xs){xs="mediump";const i=qr();i&&i.getShaderPrecisionFormat&&(xs=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return xs}function gh(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),`
6
+
7
+ #ifdef GL_ES // This checks if it is WebGL1
8
+ #define in varying
9
+ #define finalColor gl_FragColor
10
+ #define texture texture2D
11
+ #endif
12
+ ${i}
13
+ `):`
14
+
15
+ #ifdef GL_ES // This checks if it is WebGL1
16
+ #define in attribute
17
+ #define out varying
18
+ #endif
19
+ ${i}
20
+ `}function mh(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&s!=="highp"&&(n="mediump"),`precision ${n} float;
21
+ ${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function xh(i,t){return t?`#version 300 es
22
+ ${i}`:i}const yh={},_h={};function bh(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?yh:_h;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`}
23
+ ${i}`}function wh(i,t){return t?i.replace("#version 300 es",""):i}const Qs={stripVersion:wh,ensurePrecision:mh,addProgramDefines:gh,setProgramName:bh,insertVersion:xh},Fe=Object.create(null),Kr=class _i{constructor(t){t={..._i.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ph()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Qs).forEach(o=>{const a=s[o];n=Qs[o](n,a,!0),r=Qs[o](r,a,!1)}),this.fragment=n,this.vertex=r,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Di(`${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,Fe[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Fe[e]||(Fe[e]=new _i(t),Fe[e]._cacheKey=e),Fe[e]}};Kr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Zr=Kr;const Tn={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 vh(i){return Tn[i]??Tn.float32}const Sh={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"},An=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Pn(i,t){let e;for(;(e=An.exec(i))!==null;){const s=Sh[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:s,stride:vh(s).stride,offset:0,instance:!1,start:0}}An.lastIndex=0}function Ch(i){return i.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Mh({source:i,entryPoint:t}){const e={},s=Ch(i),n=s.indexOf(`fn ${t}(`);if(n===-1)return e;const r=s.indexOf("->",n);if(r===-1)return e;const o=s.substring(n,r);if(Pn(o,e),Object.keys(e).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const h=a[1],l=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=s.match(l);c&&Pn(c[1],e)}}return e}function Js(i){const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=i.match(t)?.map(u=>({group:parseInt(u.match(e)[1],10),binding:parseInt(u.match(s)[1],10),name:u.match(n)[2],isUniform:u.match(n)[1]==="<uniform>",type:u.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=i.match(o)?.map(u=>{const f=u.match(h)[1],d=u.match(a).reduce((p,x)=>{const[g,m]=x.split(":");return p[g.trim()]=m.trim(),p},{});return d?{name:f,members:d}:null}).filter(({name:u})=>l.some(f=>f.type===u||f.type.includes(`<${u}>`)))??[];return{groups:l,structs:c}}var fe=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(fe||{});function Th({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:fe.VERTEX|fe.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:fe.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:fe.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):s.type==="texture_2d_array"||s.type.startsWith("texture_2d_array<")?t[s.group].push({binding:s.binding,visibility:fe.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(s.type==="texture_cube"||s.type.startsWith("texture_cube<"))&&t[s.group].push({binding:s.binding,visibility:fe.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function Ah({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function Ph(i,t){const e=new Set,s=new Set,n=[...i.structs,...t.structs].filter(o=>e.has(o.name)?!1:(e.add(o.name),!0)),r=[...i.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return s.has(a)?!1:(s.add(a),!0)});return{structs:n,groups:r}}const De=Object.create(null);class Gs{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:r,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=s,e.source===s.source){const a=Js(e.source);this.structsAndGroups=a}else{const a=Js(s.source),h=Js(e.source);this.structsAndGroups=Ph(a,h)}this.layout=n??Ah(this.structsAndGroups),this.gpuLayout=r??Th(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Di(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Mh(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,De[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return De[e]||(De[e]=new Gs(t),De[e]._cacheKey=e),De[e]}}const Qr=["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>"],kh=Qr.reduce((i,t)=>(i[t]=!0,i),{});function Ih(i,t){switch(i){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}const Jr=class to{constructor(t,e){this._touched=0,this.uid=at("uniform"),this._resourceType="uniformGroup",this._resourceId=at("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...to.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!kh[r.type]){const o=r.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${r.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Qr.join(", ")}`)}r.value??(r.value=Ih(r.type,r.size)),s[n]=r.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Di(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Jr.defaultOptions={ubo:!1,isStatic:!1};let eo=Jr;class Ts{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){const s=this.resources[e];t!==s&&(s?.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){const s=this.resources;for(const n in s)s[n]._gcLastUsed=t,s[n]._touched=e}destroy(){const t=this.resources;for(const 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 bi=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.CANVAS=4]="CANVAS",i[i.BOTH=3]="BOTH",i))(bi||{});class Li extends Yt{constructor(t){super(),this.uid=at("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:n,resources:r,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=s,o===void 0&&(o=0,e&&(o|=bi.WEBGPU),s&&(o|=bi.WEBGL)),this.compatibleRenderers=o;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&a)for(const l in a)for(const c in a[l]){const u=a[l][c];h[u]={group:l,binding:c,name:u}}else if(e&&n&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(r){n={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let l=0;for(const c in r)h[c]||(n[99]||(n[99]=new Ts,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in r){const u=c;let f=r[c];!f.source&&!f._resourceType&&(f=new eo(f));const d=h[u];d&&(n[d.group]||(n[d.group]=new Ts,this._ownedBindGroups.push(n[d.group])),n[d.group].setResource(f,d.binding))}}this.groups=n,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[s]||(r[s]=t),this.groups[e]||(this.groups[e]=new Ts,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const r=e[n];Object.defineProperty(s,r.name,{get(){return t[r.group].getResource(r.binding)},set(o){t[r.group].setResource(o,r.binding)}})}return s}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){const{gpu:e,gl:s,...n}=t;let r,o;return e&&(r=Gs.from(e)),s&&(o=Zr.from(s)),new Li({gpuProgram:r,glProgram:o,...n})}}const Rh={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},ti=0,ei=1,si=2,ii=3,ni=4,ri=5,wi=class so{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<ti)}set blend(t){!!(this.data&1<<ti)!==t&&(this.data^=1<<ti)}get offsets(){return!!(this.data&1<<ei)}set offsets(t){!!(this.data&1<<ei)!==t&&(this.data^=1<<ei)}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<<si)}set culling(t){!!(this.data&1<<si)!==t&&(this.data^=1<<si)}get depthTest(){return!!(this.data&1<<ii)}set depthTest(t){!!(this.data&1<<ii)!==t&&(this.data^=1<<ii)}get depthMask(){return!!(this.data&1<<ri)}set depthMask(t){!!(this.data&1<<ri)!==t&&(this.data^=1<<ri)}get clockwiseFrontFace(){return!!(this.data&1<<ni)}set clockwiseFrontFace(t){!!(this.data&1<<ni)!==t&&(this.data^=1<<ni)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=Rh[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(){const t=new so;return t.depthTest=!1,t.blend=!0,t}};wi.default2d=wi.for2d();let io=wi;const vi=[];ht.handleByNamedList(H.Environment,vi);async function Eh(i){if(!i)for(let t=0;t<vi.length;t++){const e=vi[t];if(e.value.test()){await e.value.load();return}}}let Le;function Bh(){if(typeof Le=="boolean")return Le;try{Le=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Le=!1}return Le}function kn(i,t,e=2){const s=t&&t.length,n=s?t[0]*e:i.length;let r=no(i,0,n,e,!0);const o=[];if(!r||r.next===r.prev)return o;let a,h,l;if(s&&(r=Lh(i,t,r,e)),i.length>80*e){a=i[0],h=i[1];let c=a,u=h;for(let f=e;f<n;f+=e){const d=i[f],p=i[f+1];d<a&&(a=d),p<h&&(h=p),d>c&&(c=d),p>u&&(u=p)}l=Math.max(c-a,u-h),l=l!==0?32767/l:0}return Qe(r,o,e,a,h,l,0),o}function no(i,t,e,s,n){let r;if(n===qh(i,t,e,s)>0)for(let o=t;o<e;o+=s)r=In(o/s|0,i[o],i[o+1],r);else for(let o=e-s;o>=t;o-=s)r=In(o/s|0,i[o],i[o+1],r);return r&&Ie(r,r.next)&&(ts(r),r=r.next),r}function xe(i,t){if(!i)return i;t||(t=i);let e=i,s;do if(s=!1,!e.steiner&&(Ie(e,e.next)||it(e.prev,e,e.next)===0)){if(ts(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Qe(i,t,e,s,n,r,o){if(!i)return;!o&&r&&Yh(i,s,n,r);let a=i;for(;i.prev!==i.next;){const h=i.prev,l=i.next;if(r?Gh(i,s,n,r):Wh(i)){t.push(h.i,i.i,l.i),ts(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=Fh(xe(i),t),Qe(i,t,e,s,n,r,2)):o===2&&Dh(i,t,e,s,n,r):Qe(xe(i),t,e,s,n,r,1);break}}}function Wh(i){const t=i.prev,e=i,s=i.next;if(it(t,e,s)>=0)return!1;const n=t.x,r=e.x,o=s.x,a=t.y,h=e.y,l=s.y,c=Math.min(n,r,o),u=Math.min(a,h,l),f=Math.max(n,r,o),d=Math.max(a,h,l);let p=s.next;for(;p!==t;){if(p.x>=c&&p.x<=f&&p.y>=u&&p.y<=d&&Ne(n,a,r,h,o,l,p.x,p.y)&&it(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Gh(i,t,e,s){const n=i.prev,r=i,o=i.next;if(it(n,r,o)>=0)return!1;const a=n.x,h=r.x,l=o.x,c=n.y,u=r.y,f=o.y,d=Math.min(a,h,l),p=Math.min(c,u,f),x=Math.max(a,h,l),g=Math.max(c,u,f),m=Si(d,p,t,e,s),_=Si(x,g,t,e,s);let y=i.prevZ,b=i.nextZ;for(;y&&y.z>=m&&b&&b.z<=_;){if(y.x>=d&&y.x<=x&&y.y>=p&&y.y<=g&&y!==n&&y!==o&&Ne(a,c,h,u,l,f,y.x,y.y)&&it(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=d&&b.x<=x&&b.y>=p&&b.y<=g&&b!==n&&b!==o&&Ne(a,c,h,u,l,f,b.x,b.y)&&it(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=m;){if(y.x>=d&&y.x<=x&&y.y>=p&&y.y<=g&&y!==n&&y!==o&&Ne(a,c,h,u,l,f,y.x,y.y)&&it(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=_;){if(b.x>=d&&b.x<=x&&b.y>=p&&b.y<=g&&b!==n&&b!==o&&Ne(a,c,h,u,l,f,b.x,b.y)&&it(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Fh(i,t){let e=i;do{const s=e.prev,n=e.next.next;!Ie(s,n)&&oo(s,e,e.next,n)&&Je(s,n)&&Je(n,s)&&(t.push(s.i,e.i,n.i),ts(e),ts(e.next),e=i=n),e=e.next}while(e!==i);return xe(e)}function Dh(i,t,e,s,n,r){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Vh(o,a)){let h=ao(o,a);o=xe(o,o.next),h=xe(h,h.next),Qe(o,t,e,s,n,r,0),Qe(h,t,e,s,n,r,0);return}a=a.next}o=o.next}while(o!==i)}function Lh(i,t,e,s){const n=[];for(let r=0,o=t.length;r<o;r++){const a=t[r]*s,h=r<o-1?t[r+1]*s:i.length,l=no(i,a,h,s,!1);l===l.next&&(l.steiner=!0),n.push(Xh(l))}n.sort(zh);for(let r=0;r<n.length;r++)e=Hh(n[r],e);return e}function zh(i,t){let e=i.x-t.x;if(e===0&&(e=i.y-t.y,e===0)){const s=(i.next.y-i.y)/(i.next.x-i.x),n=(t.next.y-t.y)/(t.next.x-t.x);e=s-n}return e}function Hh(i,t){const e=Oh(i,t);if(!e)return t;const s=ao(e,i);return xe(s,s.next),xe(e,e.next)}function Oh(i,t){let e=t;const s=i.x,n=i.y;let r=-1/0,o;if(Ie(i,e))return e;do{if(Ie(i,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const u=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=s&&u>r&&(r=u,o=e.x<e.next.x?e:e.next,u===s))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,h=o.x,l=o.y;let c=1/0;e=o;do{if(s>=e.x&&e.x>=h&&s!==e.x&&ro(n<l?s:r,n,h,l,n<l?r:s,n,e.x,e.y)){const u=Math.abs(n-e.y)/(s-e.x);Je(e,i)&&(u<c||u===c&&(e.x>o.x||e.x===o.x&&Uh(o,e)))&&(o=e,c=u)}e=e.next}while(e!==a);return o}function Uh(i,t){return it(i.prev,i,t.prev)<0&&it(t.next,i,i.next)<0}function Yh(i,t,e,s){let n=i;do n.z===0&&(n.z=Si(n.x,n.y,t,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,Nh(n)}function Nh(i){let t,e=1;do{let s=i,n;i=null;let r=null;for(t=0;s;){t++;let o=s,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let h=e;for(;a>0||h>0&&o;)a!==0&&(h===0||!o||s.z<=o.z)?(n=s,s=s.nextZ,a--):(n=o,o=o.nextZ,h--),r?r.nextZ=n:i=n,n.prevZ=r,r=n;s=o}r.nextZ=null,e*=2}while(t>1);return i}function Si(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Xh(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function ro(i,t,e,s,n,r,o,a){return(n-o)*(t-a)>=(i-o)*(r-a)&&(i-o)*(s-a)>=(e-o)*(t-a)&&(e-o)*(r-a)>=(n-o)*(s-a)}function Ne(i,t,e,s,n,r,o,a){return!(i===o&&t===a)&&ro(i,t,e,s,n,r,o,a)}function Vh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!$h(i,t)&&(Je(i,t)&&Je(t,i)&&jh(i,t)&&(it(i.prev,i,t.prev)||it(i,t.prev,t))||Ie(i,t)&&it(i.prev,i,i.next)>0&&it(t.prev,t,t.next)>0)}function it(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Ie(i,t){return i.x===t.x&&i.y===t.y}function oo(i,t,e,s){const n=_s(it(i,t,e)),r=_s(it(i,t,s)),o=_s(it(e,s,i)),a=_s(it(e,s,t));return!!(n!==r&&o!==a||n===0&&ys(i,e,t)||r===0&&ys(i,s,t)||o===0&&ys(e,i,s)||a===0&&ys(e,t,s))}function ys(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function _s(i){return i>0?1:i<0?-1:0}function $h(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&oo(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Je(i,t){return it(i.prev,i,i.next)<0?it(i,t,i.next)>=0&&it(i,i.prev,t)>=0:it(i,t,i.prev)<0||it(i,i.next,t)<0}function jh(i,t){let e=i,s=!1;const n=(i.x+t.x)/2,r=(i.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function ao(i,t){const e=Ci(i.i,i.x,i.y),s=Ci(t.i,t.x,t.y),n=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function In(i,t,e,s){const n=Ci(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function ts(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ci(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qh(i,t,e,s){let n=0;for(let r=t,o=e-s;r<e;r+=s)n+=(i[o]-i[r])*(i[r+1]+i[o+1]),o=r;return n}const Kh=kn.default||kn;var ho=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))(ho||{});class Zh{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,r,o,a,h){const{name:l,items:c}=this;for(let u=0,f=c.length;u<f;u++)c[u][l](t,e,s,n,r,o,a,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const Qh=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],lo=class co extends Yt{constructor(t){super(),this.tick=0,this.uid=at("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Qh,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Eh(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...co.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(t);this._initOptions=t}render(t,e){this.tick++;let s=t;if(s instanceof kt&&(s={container:s},e&&($(ot,"passing a second argument is deprecated, please use render options instead"),s.target=e.renderTexture)),s.target||(s.target=this.view.renderTarget),s.target===this.view.renderTarget&&(this._lastObjectRendered=s.container,s.clearColor??(s.clearColor=this.background.colorRgba),s.clear??(s.clear=this.background.clearBeforeRender)),s.clearColor){const n=Array.isArray(s.clearColor)&&s.clearColor.length===4;s.clearColor=n?s.clearColor:nt.shared.setValue(s.clearColor).toArray()}s.transform||(s.container.updateLocalTransform(),s.transform=s.container.localTransform),s.container.visible&&(s.container.enableRenderGroup(),this.runners.prerender.emit(s),this.runners.renderStart.emit(s),this.runners.render.emit(s),this.runners.renderEnd.emit(s),this.runners.postrender.emit(s))}resize(t,e,s){const n=this.view.resolution;this.view.resize(t,e,s),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),s!==void 0&&s!==n&&this.runners.resolutionChange.emit(s)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=ho.ALL);const{clear:s,clearColor:n,target:r,mipLevel:o,layer:a}=t;nt.shared.setValue(n??this.background.colorRgba),e.renderTarget.clear(r,s,nt.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 Zh(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const n in this.runners)this.runners[n].add(s);return this}_addPipes(t,e){const s=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,o=n.name,a=s[o];this.renderPipes[o]=new r(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)&&is.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(!Bh())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()}};lo.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let uo=lo,bs;function Jh(i){return bs!==void 0||(bs=(()=>{const t={stencil:!0,failIfMajorPerformanceCaveat:i??uo.defaultOptions.failIfMajorPerformanceCaveat};try{if(!ct.get().getWebGLRenderingContext())return!1;let s=ct.get().createCanvas().getContext("webgl",t);const n=!!s?.getContextAttributes()?.stencil;if(s){const r=s.getExtension("WEBGL_lose_context");r&&r.loseContext()}return s=null,n}catch{return!1}})()),bs}let ws;async function tl(i={}){return ws!==void 0||(ws=await(async()=>{const t=ct.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),ws}const Rn=["webgl","webgpu","canvas"];async function el(i){let t=[];i.preference?Array.isArray(i.preference)?t=i.preference.slice():(t.push(i.preference),Rn.forEach(r=>{r!==i.preference&&t.push(r)})):t=Rn.slice();let e,s={};for(let r=0;r<t.length;r++){const o=t[r];if(o==="webgpu"&&await tl()){const{WebGPURenderer:a}=await Xe(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-BnEdfdr_.js");return{WebGPURenderer:h}},__vite__mapDeps([12,13,14,2,3,4,5,6,7,8,9,10,11]));e=a,s={...i,...i.webgpu};break}else if(o==="webgl"&&Jh(i.failIfMajorPerformanceCaveat??uo.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await Xe(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-lfzmCZNT.js");return{WebGLRenderer:h}},__vite__mapDeps([15,13,14,2,3,4,5,6,7,8,9,10,11]));e=a,s={...i,...i.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await Xe(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer-BKCvcc2p.js");return{CanvasRenderer:h}},__vite__mapDeps([16,14,2,3,4,5,6,7,8,9,10,11]));e=a,s={...i,...i.canvasOptions};break}}if(delete s.webgpu,delete s.webgl,delete s.canvasOptions,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}const fo="8.19.0";class po{static init(){globalThis.__PIXI_APP_INIT__?.(this,fo)}static destroy(){}}po.extension=H.Application;class sl{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,fo)}destroy(){this._renderer=null}}sl.extension={type:[H.WebGLSystem,H.WebGPUSystem],name:"initHook",priority:-10};class go{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,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:r}=this._resizeTo;e=n,s=r}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}go.extension=H.Application;class mo{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,Ps.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ge.shared:new ge,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}mo.extension=H.Application;ht.add(go);ht.add(mo);const xo=class Mi{constructor(...t){this.stage=new kt,t[0]!==void 0&&$(ot,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new kt),this.renderer=await el(t),Mi._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return $(ot,"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){const s=Mi._plugins.slice(0);s.reverse(),s.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};xo._plugins=[];let yo=xo;ht.handleByList(H.Application,yo._plugins);ht.add(po);const oi={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},il=/([astvzqmhlc])([^astvzqmhlc]*)/gi,nl=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function rl(i){const t=[];return i.replace(il,(e,s,n)=>{let r=s.toLowerCase(),o=s;const a=ol(n);for(r==="m"&&a.length>2&&(t.push([o,...a.splice(0,2)]),r="l",o=o==="m"?"l":"L");;){if(a.length===oi[r])return t.push([o,...a]),"";if(a.length<oi[r])throw new Error("malformed path data");t.push([o,...a.splice(0,oi[r])])}}),t}function ol(i){const t=i.match(nl);return t?t.map(Number):[]}function al(i,t){const e=rl(i),s=[];let n=null,r=0,o=0;for(let a=0;a<e.length;a++){const h=e[a],l=h[0],c=h;switch(l){case"M":r=c[1],o=c[2],t.moveTo(r,o);break;case"m":r+=c[1],o+=c[2],t.moveTo(r,o);break;case"H":r=c[1],t.lineTo(r,o);break;case"h":r+=c[1],t.lineTo(r,o);break;case"V":o=c[1],t.lineTo(r,o);break;case"v":o+=c[1],t.lineTo(r,o);break;case"L":r=c[1],o=c[2],t.lineTo(r,o);break;case"l":r+=c[1],o+=c[2],t.lineTo(r,o);break;case"C":r=c[5],o=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],r,o);break;case"c":t.bezierCurveTo(r+c[1],o+c[2],r+c[3],o+c[4],r+c[5],o+c[6]),r+=c[5],o+=c[6];break;case"S":r=c[3],o=c[4],t.bezierCurveToShort(c[1],c[2],r,o);break;case"s":t.bezierCurveToShort(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"Q":r=c[3],o=c[4],t.quadraticCurveTo(c[1],c[2],r,o);break;case"q":t.quadraticCurveTo(r+c[1],o+c[2],r+c[3],o+c[4]),r+=c[3],o+=c[4];break;case"T":r=c[1],o=c[2],t.quadraticCurveToShort(r,o);break;case"t":r+=c[1],o+=c[2],t.quadraticCurveToShort(r,o);break;case"A":r=c[6],o=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"a":r+=c[6],o+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,o);break;case"Z":case"z":t.closePath(),s.length>0&&(n=s.pop(),n?(r=n.startX,o=n.startY):(r=0,o=0)),n=null;break;default:bt(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:o},s.push(n))}return t}class zi{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new zi(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=s}strokeContains(t,e,s,n=.5){if(this.radius===0)return!1;const r=this.x-t,o=this.y-e,a=this.radius,h=(1-n)*s,l=Math.sqrt(r*r+o*o);return l<=a+h&&l>a-(s-h)}getBounds(t){return t||(t=new Q),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}]`}}class Hi{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new Hi(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s,n=.5){const{halfWidth:r,halfHeight:o}=this;if(r<=0||o<=0)return!1;const a=s*(1-n),h=s-a,l=r-h,c=o-h,u=r+a,f=o+a,d=t-this.x,p=e-this.y,x=d*d/(l*l)+p*p/(c*c),g=d*d/(u*u)+p*p/(f*f);return x>1&&g<=1}getBounds(t){return t||(t=new Q),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}]`}}function hl(i,t,e,s,n,r){const o=i-e,a=t-s,h=n-e,l=r-s,c=o*h+a*l,u=h*h+l*l;let f=-1;u!==0&&(f=c/u);let d,p;f<0?(d=e,p=s):f>1?(d=n,p=r):(d=e+f*h,p=s+f*l);const x=i-d,g=t-p;return x*x+g*g}let ll,cl;class $e{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,r=e.length;n<r;n++)s.push(e[n].x,e[n].y);e=s}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,s=e.length;for(let n=0;n<s;n+=2){const r=e[n],o=e[n+1],a=e[(n+2)%s],h=e[(n+3)%s];t+=(a-r)*(h+o)}return t<0}containsPolygon(t){const e=this.getBounds(ll),s=t.getBounds(cl);if(!e.containsRect(s))return!1;const n=t.points;for(let r=0;r<n.length;r+=2){const o=n[r],a=n[r+1];if(!this.contains(o,a))return!1}return!0}clone(){const t=this.points.slice(),e=new $e(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const n=this.points.length/2;for(let r=0,o=n-1;r<n;o=r++){const a=this.points[r*2],h=this.points[r*2+1],l=this.points[o*2],c=this.points[o*2+1];h>e!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(s=!s)}return s}strokeContains(t,e,s,n=.5){const r=s*s,o=r*(1-n),a=r-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;c<l;c+=2){const u=h[c],f=h[c+1],d=h[(c+2)%h.length],p=h[(c+3)%h.length],x=hl(t,e,u,f,d,p),g=Math.sign((d-u)*(e-f)-(p-f)*(t-u));if(x<=(g<0?a:o))return!0}return!1}getBounds(t){t||(t=new Q);const e=this.points;let s=1/0,n=-1/0,r=1/0,o=-1/0;for(let a=0,h=e.length;a<h;a+=2){const l=e[a],c=e[a+1];s=l<s?l:s,n=l>n?l:n,r=c<r?c:r,o=c>o?c:o}return t.x=s,t.width=n-s,t.y=r,t.height=o-r,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 $("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return $("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]}}const vs=(i,t,e,s,n,r,o)=>{const a=i-e,h=t-s,l=Math.sqrt(a*a+h*h);return l>=n-r&&l<=n+o};class Oi{constructor(t=0,e=0,s=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=r}getBounds(t){return t||(t=new Q),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Oi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let n=t-(this.x+s),r=e-(this.y+s);const o=s*s;if(n*n+r*r<=o||(n=t-(this.x+this.width-s),n*n+r*r<=o)||(r=e-(this.y+this.height-s),n*n+r*r<=o)||(n=t-(this.x+s),n*n+r*r<=o))return!0}return!1}strokeContains(t,e,s,n=.5){const{x:r,y:o,width:a,height:h,radius:l}=this,c=s*(1-n),u=s-c,f=r+l,d=o+l,p=a-l*2,x=h-l*2,g=r+a,m=o+h;return(t>=r-c&&t<=r+u||t>=g-u&&t<=g+c)&&e>=d&&e<=d+x||(e>=o-c&&e<=o+u||e>=m-u&&e<=m+c)&&t>=f&&t<=f+p?!0:t<f&&e<d&&vs(t,e,f,d,l,u,c)||t>g-l&&e<d&&vs(t,e,g-l,d,l,u,c)||t>g-l&&e>m-l&&vs(t,e,g-l,m-l,l,u,c)||t<f&&e>m-l&&vs(t,e,f,m-l,l,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const _o={};function ul(i,t,e){let s=2166136261;for(let n=0;n<t;n++)s^=i[n].uid,s=Math.imul(s,16777619),s>>>=0;return _o[s]||dl(i,t,s,e)}function dl(i,t,e,s){const n={};let r=0;for(let a=0;a<s;a++){const h=a<t?i[a]:K.EMPTY.source;n[r++]=h.source,n[r++]=h.style}const o=new Ts(n);return _o[e]=o,o}class En{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 Bn(i,t,e,s){if(e??(e=0),s??(s=Math.min(i.byteLength-e,t.byteLength)),!(e&7)&&!(s&7)){const n=s/8;new Float64Array(t,0,n).set(new Float64Array(i,e,n))}else if(!(e&3)&&!(s&3)){const n=s/4;new Float32Array(t,0,n).set(new Float32Array(i,e,n))}else new Uint8Array(t).set(new Uint8Array(i,e,s))}const fl={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var pl=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",i[i.NONE=5]="NONE",i))(pl||{});function Wn(i,t){return t.alphaMode==="no-premultiply-alpha"&&fl[i]||i}const gl=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
24
+ `);function ml(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
25
+ else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function xl(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=gl.replace(/%forloop%/gi,ml(i));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}}finally{t.deleteShader(e)}return i}let _e=null;function yl(){if(_e)return _e;const i=qr();return _e=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_e=xl(_e,i),i.getExtension("WEBGL_lose_context")?.loseContext(),_e}class _l{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class bl{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new _l,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const je=[];let ks=0;is.register({clear:()=>{if(je.length>0)for(const i of je)i&&i.destroy();je.length=0,ks=0}});function Gn(){return ks>0?je[--ks]:new bl}function Fn(i){i.elements=null,je[ks++]=i}let ze=0;const bo=class wo{constructor(t){this.uid=at("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...wo.defaultOptions,...t},t.maxTextures||($("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=yl());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new En(s*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)Fn(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const s=t._batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t._textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let s=Gn(),n=s.textures;n.clear();const r=e[this.elementStart];let o=Wn(r.blendMode,r.texture._source),a=r.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,f=this._batchIndexStart,d="startBatch",p=[];const x=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const m=e[g];e[g]=null;const y=m.texture._source,b=Wn(m.blendMode,y),w=o!==b||a!==m.topology;if(y._batchTick===ze&&!w){m._textureId=y._textureBindLocation,u+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,h,l,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,h,l,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize)),m._batch=s,p.push(m);continue}y._batchTick=ze,(n.count>=x||w)&&(this._finishBatch(s,f,u-f,n,o,a,t,d,p),d="renderBatch",f=u,o=b,a=m.topology,s=Gn(),n=s.textures,n.clear(),p=[],++ze),m._textureId=y._textureBindLocation=n.count,n.ids[y.uid]=n.count,n.textures[n.count++]=y,m._batch=s,p.push(m),u+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,h,l,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,h,l,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,f,u-f,n,o,a,t,d,p),f=u,++ze),this.elementStart=this.elementSize,this._batchIndexStart=f,this._batchIndexSize=u}_finishBatch(t,e,s,n,r,o,a,h,l){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=n,t.blendMode=r,t.topology=o,t.start=e,t.size=s,t.elements=l,++ze,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new En(e);Bn(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r<e.length;r++)n[r]=e[r];else Bn(e.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}packIndex(t,e,s,n){const r=t.indices,o=t.indexSize,a=t.indexOffset,h=t.attributeOffset;for(let l=0;l<o;l++)e[s++]=n+r[l+a]-h}destroy(t={}){if(this.batches!==null){for(let e=0;e<this.batchIndex;e++)Fn(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}}};bo.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let wl=bo;var wt=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(wt||{});class es extends Yt{constructor(t){let{data:e,size:s}=t;const{usage:n,label:r,shrinkToFit:o}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=at("buffer"),this._resourceType="buffer",this._resourceId=at("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,s??(s=e?.byteLength);const a=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:a,label:r},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&wt.STATIC)}set static(t){t?this.descriptor.usage|=wt.STATIC:this.descriptor.usage&=~wt.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const n=this._data;if(this._data=t,this._dataInt32=null,!n||n.length!==t.length){!this.shrinkToFit&&n&&t.byteLength<n.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=at("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}unload(){this.emit("unload",this);for(const 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 vo(i,t){if(!(i instanceof es)){let e=t?wt.INDEX:wt.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=wt.INDEX|wt.COPY_DST):(i=new Float32Array(i),e=wt.VERTEX|wt.COPY_DST)),i=new es({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function vl(i,t,e){const s=i.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const n=s.buffer.data;let r=1/0,o=1/0,a=-1/0,h=-1/0;const l=n.BYTES_PER_ELEMENT,c=(s.offset||0)/l,u=(s.stride||8)/l;for(let f=c;f<n.length;f+=u){const d=n[f],p=n[f+1];d>a&&(a=d),p>h&&(h=p),d<r&&(r=d),p<o&&(o=p)}return e.minX=r,e.minY=o,e.maxX=a,e.maxY=h,e}function Sl(i){return(i instanceof es||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=vo(i.buffer,!1),i}class Cl extends Yt{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=at("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new It,this._boundsDirty=!0;const{attributes:e,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},e)for(const r in e)this.addAttribute(r,e[r]);this.instanceCount=t.instanceCount??1,s&&this.addIndex(s),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const s=Sl(e);this.buffers.indexOf(s.buffer)===-1&&(this.buffers.push(s.buffer),s.buffer.on("update",this.onBufferUpdate,this),s.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=s}addIndex(t){this.indexBuffer=vo(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,vl(this,"aPosition",this._bounds)):this._bounds}unload(){this.emit("unload",this);for(const 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}}const Ml=new Float32Array(1),Tl=new Uint32Array(1);class Al extends Cl{constructor(){const e=new es({data:Ml,label:"attribute-batch-buffer",usage:wt.VERTEX|wt.COPY_DST,shrinkToFit:!1}),s=new es({data:Tl,label:"index-batch-buffer",usage:wt.INDEX|wt.COPY_DST,shrinkToFit:!1}),n=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:20}},indexBuffer:s})}}function Dn(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),r=t[n];if(r){let o=i[s];s==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(o)}else bt(`${s} placement hook does not exist in shader`)}}const Pl=/\{\{(.*?)\}\}/g;function Ln(i){const t={};return(i.match(Pl)?.map(s=>s.replace(/[{()}]/g,""))??[]).forEach(s=>{t[s]=[]}),t}function zn(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Hn(i,t,e=!1){const s=[];zn(t,s),i.forEach(a=>{a.header&&zn(a.header,s)});const n=s;e&&n.sort();const r=n.map((a,h)=>` @location(${h}) ${a},`).join(`
26
+ `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
27
+ ${r}
28
+ `),o}function On(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function kl(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function Il(i){const t=/@.*?\s+/g;return i.replace(t,"")}function Rl(i,t){const e=[];On(t,e),i.forEach(h=>{h.header&&On(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
29
+ `),r=e.sort().map(h=>` var ${Il(h)};`).join(`
30
+ `),o=`return VSOutput(
31
+ ${e.sort().map(h=>` ${kl(h)}`).join(`,
32
+ `)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
33
+ ${n}
34
+ `),a=a.replace("{{start}}",`
35
+ ${r}
36
+ `),a=a.replace("{{return}}",`
37
+ ${o}
38
+ `),a}function Un(i,t){let e=i;for(const s in t){const n=t[s];n.join(`
39
+ `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
40
+ ${n.join(`
41
+ `)}
42
+ //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const ie=Object.create(null),ai=new Map;let El=0;function Bl({template:i,bits:t}){const e=So(i,t);if(ie[e])return ie[e];const{vertex:s,fragment:n}=Gl(i,t);return ie[e]=Co(s,n,t),ie[e]}function Wl({template:i,bits:t}){const e=So(i,t);return ie[e]||(ie[e]=Co(i.vertex,i.fragment,t)),ie[e]}function Gl(i,t){const e=t.map(o=>o.vertex).filter(o=>!!o),s=t.map(o=>o.fragment).filter(o=>!!o);let n=Hn(e,i.vertex,!0);n=Rl(e,n);const r=Hn(s,i.fragment,!0);return{vertex:n,fragment:r}}function So(i,t){return t.map(e=>(ai.has(e)||ai.set(e,El++),ai.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function Co(i,t,e){const s=Ln(i),n=Ln(t);return e.forEach(r=>{Dn(r.vertex,s,r.name),Dn(r.fragment,n,r.name)}),{vertex:Un(i,s),fragment:Un(t,n)}}const Fl=`
43
+ @in aPosition: vec2<f32>;
44
+ @in aUV: vec2<f32>;
45
+
46
+ @out @builtin(position) vPosition: vec4<f32>;
47
+ @out vUV : vec2<f32>;
48
+ @out vColor : vec4<f32>;
49
+
50
+ {{header}}
51
+
52
+ struct VSOutput {
53
+ {{struct}}
54
+ };
55
+
56
+ @vertex
57
+ fn main( {{in}} ) -> VSOutput {
58
+
59
+ var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
60
+ var modelMatrix = mat3x3<f32>(
61
+ 1.0, 0.0, 0.0,
62
+ 0.0, 1.0, 0.0,
63
+ 0.0, 0.0, 1.0
64
+ );
65
+ var position = aPosition;
66
+ var uv = aUV;
67
+
68
+ {{start}}
69
+
70
+ vColor = vec4<f32>(1., 1., 1., 1.);
71
+
72
+ {{main}}
73
+
74
+ vUV = uv;
75
+
76
+ var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
77
+
78
+ vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
79
+
80
+ vColor *= globalUniforms.uWorldColorAlpha;
81
+
82
+ {{end}}
83
+
84
+ {{return}}
85
+ };
86
+ `,Dl=`
87
+ @in vUV : vec2<f32>;
88
+ @in vColor : vec4<f32>;
89
+
90
+ {{header}}
91
+
92
+ @fragment
93
+ fn main(
94
+ {{in}}
95
+ ) -> @location(0) vec4<f32> {
96
+
97
+ {{start}}
98
+
99
+ var outColor:vec4<f32>;
100
+
101
+ {{main}}
102
+
103
+ var finalColor:vec4<f32> = outColor * vColor;
104
+
105
+ {{end}}
106
+
107
+ return finalColor;
108
+ };
109
+ `,Ll=`
110
+ in vec2 aPosition;
111
+ in vec2 aUV;
112
+
113
+ out vec4 vColor;
114
+ out vec2 vUV;
115
+
116
+ {{header}}
117
+
118
+ void main(void){
119
+
120
+ mat3 worldTransformMatrix = uWorldTransformMatrix;
121
+ mat3 modelMatrix = mat3(
122
+ 1.0, 0.0, 0.0,
123
+ 0.0, 1.0, 0.0,
124
+ 0.0, 0.0, 1.0
125
+ );
126
+ vec2 position = aPosition;
127
+ vec2 uv = aUV;
128
+
129
+ {{start}}
130
+
131
+ vColor = vec4(1.);
132
+
133
+ {{main}}
134
+
135
+ vUV = uv;
136
+
137
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
138
+
139
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
140
+
141
+ vColor *= uWorldColorAlpha;
142
+
143
+ {{end}}
144
+ }
145
+ `,zl=`
146
+
147
+ in vec4 vColor;
148
+ in vec2 vUV;
149
+
150
+ out vec4 finalColor;
151
+
152
+ {{header}}
153
+
154
+ void main(void) {
155
+
156
+ {{start}}
157
+
158
+ vec4 outColor;
159
+
160
+ {{main}}
161
+
162
+ finalColor = outColor * vColor;
163
+
164
+ {{end}}
165
+ }
166
+ `,Hl={name:"global-uniforms-bit",vertex:{header:`
167
+ struct GlobalUniforms {
168
+ uProjectionMatrix:mat3x3<f32>,
169
+ uWorldTransformMatrix:mat3x3<f32>,
170
+ uWorldColorAlpha: vec4<f32>,
171
+ uResolution: vec2<f32>,
172
+ }
173
+
174
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
175
+ `}},Ol={name:"global-uniforms-bit",vertex:{header:`
176
+ uniform mat3 uProjectionMatrix;
177
+ uniform mat3 uWorldTransformMatrix;
178
+ uniform vec4 uWorldColorAlpha;
179
+ uniform vec2 uResolution;
180
+ `}};function Ul({bits:i,name:t}){const e=Bl({template:{fragment:Dl,vertex:Fl},bits:[Hl,...i]});return Gs.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Yl({bits:i,name:t}){return new Zr({name:t,...Wl({template:{vertex:Ll,fragment:zl},bits:[Ol,...i]})})}const Nl={name:"color-bit",vertex:{header:`
181
+ @in aColor: vec4<f32>;
182
+ `,main:`
183
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
184
+ `}},Xl={name:"color-bit",vertex:{header:`
185
+ in vec4 aColor;
186
+ `,main:`
187
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
188
+ `}},hi={};function Vl(i){const t=[];if(i===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 s=0;s<i;s++)t.push(`@group(1) @binding(${e++}) var textureSource${s+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
189
+ `)}function $l(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<i;e++)e===i-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(`
190
+ `)}function jl(i){return hi[i]||(hi[i]={name:"texture-batch-bit",vertex:{header:`
191
+ @in aTextureIdAndRound: vec2<u32>;
192
+ @out @interpolate(flat) vTextureId : u32;
193
+ `,main:`
194
+ vTextureId = aTextureIdAndRound.y;
195
+ `,end:`
196
+ if(aTextureIdAndRound.x == 1)
197
+ {
198
+ vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
199
+ }
200
+ `},fragment:{header:`
201
+ @in @interpolate(flat) vTextureId: u32;
202
+
203
+ ${Vl(i)}
204
+ `,main:`
205
+ var uvDx = dpdx(vUV);
206
+ var uvDy = dpdy(vUV);
207
+
208
+ ${$l(i)}
209
+ `}}),hi[i]}const li={};function ql(i){const t=[];for(let e=0;e<i;e++)e>0&&t.push("else"),e<i-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
210
+ `)}function Kl(i){return li[i]||(li[i]={name:"texture-batch-bit",vertex:{header:`
211
+ in vec2 aTextureIdAndRound;
212
+ out float vTextureId;
213
+
214
+ `,main:`
215
+ vTextureId = aTextureIdAndRound.y;
216
+ `,end:`
217
+ if(aTextureIdAndRound.x == 1.)
218
+ {
219
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
220
+ }
221
+ `},fragment:{header:`
222
+ in float vTextureId;
223
+
224
+ uniform sampler2D uTextures[${i}];
225
+
226
+ `,main:`
227
+
228
+ ${ql(i)}
229
+ `}}),li[i]}const Zl={name:"round-pixels-bit",vertex:{header:`
230
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
231
+ {
232
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
233
+ }
234
+ `}},Ql={name:"round-pixels-bit",vertex:{header:`
235
+ vec2 roundPixels(vec2 position, vec2 targetSize)
236
+ {
237
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
238
+ }
239
+ `}},Yn={};function Jl(i){let t=Yn[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=Yn[i]=new eo({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class Nn extends Li{constructor(t){const e=Yl({name:"batch",bits:[Xl,Kl(t),Ql]}),s=Ul({name:"batch",bits:[Nl,jl(t),Zl]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Jl(t)}}),this.maxTextures=t}}let He=null;const Mo=class To extends wl{constructor(t){super(t),this.geometry=new Al,this.name=To.extension.name,this.vertexSize=6,He??(He=new Nn(t.maxTextures)),this.shader=He}packAttributes(t,e,s,n,r){const o=r<<16|t.roundPixels&65535,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,f=a.tx,d=a.ty,{positions:p,uvs:x}=t,g=t.color,m=t.attributeOffset,_=m+t.attributeSize;for(let y=m;y<_;y++){const b=y*2,w=p[b],v=p[b+1];e[n++]=h*w+c*v+f,e[n++]=u*v+l*w+d,e[n++]=x[b],e[n++]=x[b+1],s[n++]=g,s[n++]=o}}packQuadAttributes(t,e,s,n,r){const o=t.texture,a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,f=a.tx,d=a.ty,p=t.bounds,x=p.maxX,g=p.minX,m=p.maxY,_=p.minY,y=o.uvs,b=t.color,w=r<<16|t.roundPixels&65535;e[n+0]=h*g+c*_+f,e[n+1]=u*_+l*g+d,e[n+2]=y.x0,e[n+3]=y.y0,s[n+4]=b,s[n+5]=w,e[n+6]=h*x+c*_+f,e[n+7]=u*_+l*x+d,e[n+8]=y.x1,e[n+9]=y.y1,s[n+10]=b,s[n+11]=w,e[n+12]=h*x+c*m+f,e[n+13]=u*m+l*x+d,e[n+14]=y.x2,e[n+15]=y.y2,s[n+16]=b,s[n+17]=w,e[n+18]=h*g+c*m+f,e[n+19]=u*m+l*g+d,e[n+20]=y.x3,e[n+21]=y.y3,s[n+22]=b,s[n+23]=w}_updateMaxTextures(t){this.shader.maxTextures!==t&&(He=new Nn(t),this.shader=He)}destroy(){this.shader=null,super.destroy()}};Mo.extension={type:[H.Batcher],name:"default"};let tc=Mo;class ns{constructor(t){this.items=Object.create(null);const{renderer:e,type:s,onUnload:n,priority:r,name:o}=t;this._renderer=e,e.gc.addResourceHash(this,"items",s,r??0),this._onUnload=n,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;const s=t._gpuData[this._renderer.uid];s&&(this._onUnload?.(t,...e),s.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function ec(i,t,e,s,n,r,o,a=null){let h=0;e*=t,n*=r;const l=a.a,c=a.b,u=a.c,f=a.d,d=a.tx,p=a.ty;for(;h<o;){const x=i[e],g=i[e+1];s[n]=l*x+u*g+d,s[n+1]=c*x+f*g+p,n+=r,e+=t,h++}}function sc(i,t,e,s){let n=0;for(t*=e;n<s;)i[t]=0,i[t+1]=0,t+=e,n++}function Ao(i,t,e,s,n){const r=t.a,o=t.b,a=t.c,h=t.d,l=t.tx,c=t.ty;e||(e=0),s||(s=2),n||(n=i.length/s-e);let u=e*s;for(let f=0;f<n;f++){const d=i[u],p=i[u+1];i[u]=r*d+a*p+l,i[u+1]=o*d+h*p+c,u+=s}}const ic=new N;class Ui{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?Ir(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||ic}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}}const ss={extension:{type:H.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,r,o,a;if(i.type==="circle"){const b=i;if(o=a=b.radius,o<=0)return!1;e=b.x,s=b.y,n=r=0}else if(i.type==="ellipse"){const b=i;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,s=b.y,n=r=0}else{const b=i,w=b.width/2,v=b.height/2;e=b.x+w,s=b.y+v,o=a=Math.max(0,Math.min(b.radius,Math.min(w,v))),n=w-o,r=v-a}if(n<0||r<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return!1;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+r,t[2]=t[4]=e-n,t[5]=t[7]=s-r,!0;let c=0,u=h*4+(n?2:0)+2,f=u,d=l,p=n+o,x=r,g=e+p,m=e-p,_=s+x;if(t[c++]=g,t[c++]=_,t[--u]=_,t[--u]=m,r){const b=s-x;t[f++]=m,t[f++]=b,t[--d]=b,t[--d]=g}for(let b=1;b<h;b++){const w=Math.PI/2*(b/h),v=n+Math.cos(w)*o,S=r+Math.sin(w)*a,I=e+v,R=e-v,M=s+S,C=s-S;t[c++]=I,t[c++]=M,t[--u]=M,t[--u]=R,t[f++]=R,t[f++]=C,t[--d]=C,t[--d]=I}p=n,x=r+a,g=e+p,m=e-p,_=s+x;const y=s-x;return t[c++]=g,t[c++]=_,t[--d]=y,t[--d]=g,n&&(t[c++]=m,t[c++]=_,t[--d]=y,t[--d]=m),!0},triangulate(i,t,e,s,n,r){if(i.length===0)return;let o=0,a=0;for(let c=0;c<i.length;c+=2)o+=i[c],a+=i[c+1];o/=i.length/2,a/=i.length/2;let h=s;t[h*e]=o,t[h*e+1]=a;const l=h++;for(let c=0;c<i.length;c+=2)t[h*e]=i[c],t[h*e+1]=i[c+1],c>0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},nc={...ss,extension:{...ss.extension,name:"ellipse"}},rc={...ss,extension:{...ss.extension,name:"roundedRectangle"}},Po=1e-4,Xn=1e-4;function oc(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],r=i[t-1];s<t;s+=2){const o=i[s],a=i[s+1];e+=(o-n)*(a+r),n=o,r=a}return e<0?-1:1}function Vn(i,t,e,s,n,r,o,a){const h=i-e*n,l=t-s*n,c=i+e*r,u=t+s*r;let f,d;o?(f=s,d=-e):(f=-s,d=e);const p=h+f,x=l+d,g=c+f,m=u+d;return a.push(p,x),a.push(g,m),2}function ae(i,t,e,s,n,r,o,a){const h=e-i,l=s-t;let c=Math.atan2(h,l),u=Math.atan2(n-i,r-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let f=c;const d=u-c,p=Math.abs(d),x=Math.sqrt(h*h+l*l),g=(15*p*Math.sqrt(x)/Math.PI>>0)+1,m=d/g;if(f+=m,a){o.push(i,t),o.push(e,s);for(let _=1,y=f;_<g;_++,y+=m)o.push(i,t),o.push(i+Math.sin(y)*x,t+Math.cos(y)*x);o.push(i,t),o.push(n,r)}else{o.push(e,s),o.push(i,t);for(let _=1,y=f;_<g;_++,y+=m)o.push(i+Math.sin(y)*x,t+Math.cos(y)*x),o.push(i,t);o.push(n,r),o.push(i,t)}return g*2}function ac(i,t,e,s,n,r){const o=Po;if(i.length===0)return;const a=t;let h=a.alignment;if(t.alignment!==.5){let B=oc(i);h=(h-.5)*B+.5}const l=new X(i[0],i[1]),c=new X(i[i.length-2],i[i.length-1]),u=s,f=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(u){i=i.slice(),f&&(i.pop(),i.pop(),c.set(i[i.length-2],i[i.length-1]));const B=(l.x+c.x)*.5,q=(c.y+l.y)*.5;i.unshift(B,q),i.push(B,q)}const d=n,p=i.length/2;let x=i.length;const g=d.length/2,m=a.width/2,_=m*m,y=a.miterLimit*a.miterLimit;let b=i[0],w=i[1],v=i[2],S=i[3],I=0,R=0,M=-(w-S),C=b-v,W=0,D=0,G=Math.sqrt(M*M+C*C);M/=G,C/=G,M*=m,C*=m;const V=h,k=(1-V)*2,E=V*2;u||(a.cap==="round"?x+=ae(b-M*(k-E)*.5,w-C*(k-E)*.5,b-M*k,w-C*k,b+M*E,w+C*E,d,!0)+2:a.cap==="square"&&(x+=Vn(b,w,M,C,k,E,!0,d))),d.push(b-M*k,w-C*k),d.push(b+M*E,w+C*E);for(let B=1;B<p-1;++B){b=i[(B-1)*2],w=i[(B-1)*2+1],v=i[B*2],S=i[B*2+1],I=i[(B+1)*2],R=i[(B+1)*2+1],M=-(w-S),C=b-v,G=Math.sqrt(M*M+C*C),M/=G,C/=G,M*=m,C*=m,W=-(S-R),D=v-I,G=Math.sqrt(W*W+D*D),W/=G,D/=G,W*=m,D*=m;const q=v-b,et=w-S,xt=v-I,st=R-S,pt=q*xt+et*st,Bt=et*xt-st*q,Nt=Bt<0;if(Math.abs(Bt)<.001*Math.abs(pt)){d.push(v-M*k,S-C*k),d.push(v+M*E,S+C*E),pt>=0&&(a.join==="round"?x+=ae(v,S,v-M*k,S-C*k,v-W*k,S-D*k,d,!1)+4:x+=2,d.push(v-W*E,S-D*E),d.push(v+W*k,S+D*k));continue}const Re=(-M+b)*(-C+S)-(-M+v)*(-C+w),P=(-W+I)*(-D+S)-(-W+v)*(-D+R),T=(q*P-xt*Re)/Bt,A=(st*Re-et*P)/Bt,U=(T-v)*(T-v)+(A-S)*(A-S),L=v+(T-v)*k,j=S+(A-S)*k,ut=v-(T-v)*E,dt=S-(A-S)*E,Lt=Math.min(q*q+et*et,xt*xt+st*st),zt=Nt?k:E,lt=Lt+zt*zt*_;U<=lt?a.join==="bevel"||U/_>y?(Nt?(d.push(L,j),d.push(v+M*E,S+C*E),d.push(L,j),d.push(v+W*E,S+D*E)):(d.push(v-M*k,S-C*k),d.push(ut,dt),d.push(v-W*k,S-D*k),d.push(ut,dt)),x+=2):a.join==="round"?Nt?(d.push(L,j),d.push(v+M*E,S+C*E),x+=ae(v,S,v+M*E,S+C*E,v+W*E,S+D*E,d,!0)+4,d.push(L,j),d.push(v+W*E,S+D*E)):(d.push(v-M*k,S-C*k),d.push(ut,dt),x+=ae(v,S,v-M*k,S-C*k,v-W*k,S-D*k,d,!1)+4,d.push(v-W*k,S-D*k),d.push(ut,dt)):(d.push(L,j),d.push(ut,dt)):(d.push(v-M*k,S-C*k),d.push(v+M*E,S+C*E),a.join==="round"?Nt?x+=ae(v,S,v+M*E,S+C*E,v+W*E,S+D*E,d,!0)+2:x+=ae(v,S,v-M*k,S-C*k,v-W*k,S-D*k,d,!1)+2:a.join==="miter"&&U/_<=y&&(Nt?(d.push(ut,dt),d.push(ut,dt)):(d.push(L,j),d.push(L,j)),x+=2),d.push(v-W*k,S-D*k),d.push(v+W*E,S+D*E),x+=2)}b=i[(p-2)*2],w=i[(p-2)*2+1],v=i[(p-1)*2],S=i[(p-1)*2+1],M=-(w-S),C=b-v,G=Math.sqrt(M*M+C*C),M/=G,C/=G,M*=m,C*=m,d.push(v-M*k,S-C*k),d.push(v+M*E,S+C*E),u||(a.cap==="round"?x+=ae(v-M*(k-E)*.5,S-C*(k-E)*.5,v-M*k,S-C*k,v+M*E,S+C*E,d,!1)+2:a.cap==="square"&&(x+=Vn(v,S,M,C,k,E,!1,d)));const O=Xn*Xn;for(let B=g;B<x+g-2;++B)b=d[B*2],w=d[B*2+1],v=d[(B+1)*2],S=d[(B+1)*2+1],I=d[(B+2)*2],R=d[(B+2)*2+1],!(Math.abs(b*(S-R)+v*(R-w)+I*(w-S))<O)&&r.push(B,B+1,B+2)}function hc(i,t,e,s){const n=Po;if(i.length===0)return;const r=i[0],o=i[1],a=i[i.length-2],h=i[i.length-1],l=t||Math.abs(r-a)<n&&Math.abs(o-h)<n,c=e,u=i.length/2,f=c.length/2;for(let d=0;d<u;d++)c.push(i[d*2]),c.push(i[d*2+1]);for(let d=0;d<u-1;d++)s.push(f+d,f+d+1);l&&s.push(f+u-1,f)}function ko(i,t,e,s,n,r,o){const a=Kh(i,t,2);if(!a)return;for(let l=0;l<a.length;l+=3)r[o++]=a[l]+n,r[o++]=a[l+1]+n,r[o++]=a[l+2]+n;let h=n*s;for(let l=0;l<i.length;l+=2)e[h]=i[l],e[h+1]=i[l+1],h+=s}const lc=[],cc={extension:{type:H.ShapeBuilder,name:"polygon"},build(i,t){for(let e=0;e<i.points.length;e++)t[e]=i.points[e];return!0},triangulate(i,t,e,s,n,r){ko(i,lc,t,e,s,n,r)}},uc={extension:{type:H.ShapeBuilder,name:"rectangle"},build(i,t){const e=i,s=e.x,n=e.y,r=e.width,o=e.height;return r>0&&o>0?(t[0]=s,t[1]=n,t[2]=s+r,t[3]=n,t[4]=s+r,t[5]=n+o,t[6]=s,t[7]=n+o,!0):!1},triangulate(i,t,e,s,n,r){let o=0;s*=e,t[s+o]=i[0],t[s+o+1]=i[1],o+=e,t[s+o]=i[2],t[s+o+1]=i[3],o+=e,t[s+o]=i[6],t[s+o+1]=i[7],o+=e,t[s+o]=i[4],t[s+o+1]=i[5],o+=e;const a=s/e;n[r++]=a,n[r++]=a+1,n[r++]=a+2,n[r++]=a+1,n[r++]=a+3,n[r++]=a+2}},dc={extension:{type:H.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,!0},triangulate(i,t,e,s,n,r){let o=0;s*=e,t[s+o]=i[0],t[s+o+1]=i[1],o+=e,t[s+o]=i[2],t[s+o+1]=i[3],o+=e,t[s+o]=i[4],t[s+o+1]=i[5];const a=s/e;n[r++]=a,n[r++]=a+1,n[r++]=a+2}},$n=[{offset:0,color:"white"},{offset:1,color:"black"}],Yi=class Ti{constructor(...t){this.uid=at("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=fc(t);e={...e.type==="radial"?Ti.defaultRadialOptions:Ti.defaultLinearOptions,..._r(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(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:nt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:n}=this.end,r=s-t,o=n-e;const a=r<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(r<0){const g=t;t=s,s=g,r*=-1}if(o<0){const g=e;e=n,n=g,o*=-1}}const h=this.colorStops.length?this.colorStops:$n,l=this._textureSize,{canvas:c,context:u}=qn(l,1),f=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);jn(f,h),u.fillStyle=f,u.fillRect(0,0,l,1),this.texture=new K({source:new As({resource:c,addressMode:this._wrapMode})});const d=Math.sqrt(r*r+o*o),p=Math.atan2(o,r),x=new N;x.scale(d/l,1),x.rotate(p),x.translate(t,e),this.textureSpace==="local"&&x.scale(l,l),this.transform=x}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:$n,e=this._textureSize,{canvas:s,context:n}=qn(e,e),{x:r,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,u=a-c,f=h-c,d=e/(c*2),p=(r-u)*d,x=(o-f)*d,g=n.createRadialGradient(p,x,l*d,(a-u)*d,(h-f)*d,c*d);jn(g,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=g,n.translate(p,x),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-p,-x),n.fillRect(0,0,e,e),this.texture=new K({source:new As({resource:s,addressMode:this._wrapMode})});const m=new N;this.textureSpace==="local"?m.scale(2*c,2*c):m.scale(1/d,1/d),m.translate(u,f),this.transform=m}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}`}};Yi.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Yi.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Qt=Yi;function jn(i,t){for(let e=0;e<t.length;e++){const s=t[e];i.addColorStop(s.offset,s.color)}}function qn(i,t){const e=ct.get().createCanvas(i,t),s=e.getContext("2d");return{canvas:e,context:s}}function fc(i){let t=i[0]??{};return(typeof t=="number"||i[1])&&($("8.5.2","use options object instead"),t={type:"linear",start:{x:i[0],y:i[1]},end:{x:i[2],y:i[3]},textureSpace:i[4],textureSize:i[5]??Qt.defaultLinearOptions.textureSize}),t}const pc=new N,gc=new Q;function mc(i,t,e,s){const n=t.matrix?i.copyFrom(t.matrix).invert():i.identity();if(t.textureSpace==="local"){const o=e.getBounds(gc);t.width&&o.pad(t.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,u=-a*l,f=-h*c,d=n.a,p=n.b,x=n.c,g=n.d;n.a*=l,n.b*=l,n.c*=c,n.d*=c,n.tx=u*d+f*x+n.tx,n.ty=u*p+f*g+n.ty}else n.translate(t.texture.frame.x,t.texture.frame.y),n.scale(1/t.texture.source.width,1/t.texture.source.height);const r=t.texture.source.style;return!(t.fill instanceof Qt)&&r.addressMode==="clamp-to-edge"&&(r.addressMode="repeat",r.update()),s&&n.append(pc.copyFrom(s).invert()),n}const Fs={};ht.handleByMap(H.ShapeBuilder,Fs);ht.add(uc,cc,dc,ss,nc,rc);const xc=new Q,yc=new N;function _c(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n<i.instructions.length;n++){const r=i.instructions[n];if(r.action==="texture")bc(r.data,s,e);else if(r.action==="fill"||r.action==="stroke"){const o=r.action==="stroke",a=r.data.path.shapePath,h=r.data.style,l=r.data.hole;o&&l&&Kn(l.shapePath,h,!0,s,e),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),Kn(a,h,o,s,e)}}}function bc(i,t,e){const s=[],n=Fs.rectangle,r=xc;r.x=i.dx,r.y=i.dy,r.width=i.dw,r.height=i.dh;const o=i.transform;if(!n.build(r,s))return;const{vertices:a,uvs:h,indices:l}=e,c=l.length,u=a.length/2;o&&Ao(s,o),n.triangulate(s,a,2,u,l,c);const f=i.image,d=f.uvs;h.push(d.x0,d.y0,d.x1,d.y1,d.x3,d.y3,d.x2,d.y2);const p=vt.get(Ui);p.indexOffset=c,p.indexSize=l.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=i.style,p.alpha=i.alpha,p.texture=f,p.geometryData=e,t.push(p)}function Kn(i,t,e,s,n){const{vertices:r,uvs:o,indices:a}=n;i.shapePrimitives.forEach(({shape:h,transform:l,holes:c})=>{const u=[],f=Fs[h.type];if(!f.build(h,u))return;const d=a.length,p=r.length/2;let x="triangle-list";if(l&&Ao(u,l),e){const y=h.closePath??!0,b=t;b.pixelLine?(hc(u,y,r,a),x="line-list"):ac(u,b,!1,y,r,a)}else if(c){const y=[],b=u.slice();wc(c).forEach(v=>{y.push(b.length/2),b.push(...v)}),ko(b,y,r,2,p,a,d)}else f.triangulate(u,r,2,p,a,d);const g=o.length/2,m=t.texture;if(m!==K.WHITE){const y=mc(yc,t,h,l);ec(r,2,p,o,g,2,r.length/2-p,y)}else sc(o,g,2,r.length/2-p);const _=vt.get(Ui);_.indexOffset=d,_.indexSize=a.length-d,_.attributeOffset=p,_.attributeSize=r.length/2-p,_.baseColor=t.color,_.alpha=t.alpha,_.texture=m,_.geometryData=n,_.topology=x,s.push(_)})}function wc(i){const t=[];for(let e=0;e<i.length;e++){const s=i[e].shape,n=[];Fs[s.type].build(s,n)&&t.push(n)}return t}class vc{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{vt.return(t)}),this.graphicsData&&vt.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Sc{constructor(){this.instructions=new Gi}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new tc({maxTextures:e}),this.instructions.reset()}get geometry(){return $(ya,"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}}const Ni=class Ai{constructor(t){this._renderer=t,this._managedContexts=new ns({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Ai.defaultOptions.bezierSmoothness=t?.bezierSmoothness??Ai.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],s=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&s.reset(),_c(t,s);const n=t.batchMode;t.customShader||n==="no-batch"?s.isBatchable=!1:n==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,t.dirty=!1}return s}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=vt.get(Sc,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:n,geometryData:r}=s;s.graphicsData=e;const o=r.vertices.length,a=r.indices.length;for(let u=0;u<n.length;u++)n[u].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(o),h.ensureIndexBuffer(a),h.begin();for(let u=0;u<n.length;u++){const f=n[u];h.add(f)}h.finish(e.instructions);const l=h.geometry;l.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,!0),l.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,!0);const c=h.batches;for(let u=0;u<c.length;u++){const f=c[u];f.bindGroup=ul(f.textures.textures,f.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new vc;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Ni.extension={type:[H.WebGLSystem,H.WebGPUSystem],name:"graphicsContext"};Ni.defaultOptions={bezierSmoothness:.5};let Xi=Ni;const Cc=8,Ss=11920929e-14,Mc=1;function Io(i,t,e,s,n,r,o,a,h,l){const u=Math.min(.99,Math.max(0,l??Xi.defaultOptions.bezierSmoothness));let f=(Mc-u)/1;return f*=f,Tc(t,e,s,n,r,o,a,h,i,f),i}function Tc(i,t,e,s,n,r,o,a,h,l){Pi(i,t,e,s,n,r,o,a,h,l,0),h.push(o,a)}function Pi(i,t,e,s,n,r,o,a,h,l,c){if(c>Cc)return;const u=(i+e)/2,f=(t+s)/2,d=(e+n)/2,p=(s+r)/2,x=(n+o)/2,g=(r+a)/2,m=(u+d)/2,_=(f+p)/2,y=(d+x)/2,b=(p+g)/2,w=(m+y)/2,v=(_+b)/2;if(c>0){let S=o-i,I=a-t;const R=Math.abs((e-o)*I-(s-a)*S),M=Math.abs((n-o)*I-(r-a)*S);if(R>Ss&&M>Ss){if((R+M)*(R+M)<=l*(S*S+I*I)){h.push(w,v);return}}else if(R>Ss){if(R*R<=l*(S*S+I*I)){h.push(w,v);return}}else if(M>Ss){if(M*M<=l*(S*S+I*I)){h.push(w,v);return}}else if(S=w-(i+o)/2,I=v-(t+a)/2,S*S+I*I<=l){h.push(w,v);return}}Pi(i,t,u,f,m,_,w,v,h,l,c+1),Pi(w,v,y,b,x,g,o,a,h,l,c+1)}const Ac=8,Pc=11920929e-14,kc=1;function Ic(i,t,e,s,n,r,o,a){const l=Math.min(.99,Math.max(0,a??Xi.defaultOptions.bezierSmoothness));let c=(kc-l)/1;return c*=c,Rc(t,e,s,n,r,o,i,c),i}function Rc(i,t,e,s,n,r,o,a){ki(o,i,t,e,s,n,r,a,0),o.push(n,r)}function ki(i,t,e,s,n,r,o,a,h){if(h>Ac)return;const l=(t+s)/2,c=(e+n)/2,u=(s+r)/2,f=(n+o)/2,d=(l+u)/2,p=(c+f)/2;let x=r-t,g=o-e;const m=Math.abs((s-r)*g-(n-o)*x);if(m>Pc){if(m*m<=a*(x*x+g*g)){i.push(d,p);return}}else if(x=d-(t+r)/2,g=p-(e+o)/2,x*x+g*g<=a){i.push(d,p);return}ki(i,t,e,l,c,d,p,a,h+1),ki(i,d,p,u,f,r,o,a,h+1)}function Ro(i,t,e,s,n,r,o,a){let h=Math.abs(n-r);(!o&&n>r||o&&r>n)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI)))),a=Math.max(a,3);let l=h/a,c=n;l*=o?-1:1;for(let u=0;u<a+1;u++){const f=Math.cos(c),d=Math.sin(c),p=t+f*s,x=e+d*s;i.push(p,x),c+=l}}function Ec(i,t,e,s,n,r){const o=i[i.length-2],h=i[i.length-1]-e,l=o-t,c=n-e,u=s-t,f=Math.abs(h*u-l*c);if(f<1e-8||r===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const d=h*h+l*l,p=c*c+u*u,x=h*c+l*u,g=r*Math.sqrt(d)/f,m=r*Math.sqrt(p)/f,_=g*x/d,y=m*x/p,b=g*u+m*l,w=g*c+m*h,v=l*(m+_),S=h*(m+_),I=u*(g+y),R=c*(g+y),M=Math.atan2(S-w,v-b),C=Math.atan2(R-w,I-b);Ro(i,b+t,w+e,r,M,C,l*c>u*h)}const qe=Math.PI*2,ci={centerX:0,centerY:0,ang1:0,ang2:0},ui=({x:i,y:t},e,s,n,r,o,a,h)=>{i*=e,t*=s;const l=n*i-r*t,c=r*i+n*t;return h.x=l+o,h.y=c+a,h};function Bc(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),r=Math.sin(i),o=Math.cos(i+t),a=Math.sin(i+t);return[{x:n-r*s,y:r+n*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const Zn=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let r=i*e+t*s;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},Wc=(i,t,e,s,n,r,o,a,h,l,c,u,f)=>{const d=Math.pow(n,2),p=Math.pow(r,2),x=Math.pow(c,2),g=Math.pow(u,2);let m=d*p-d*g-p*x;m<0&&(m=0),m/=d*g+p*x,m=Math.sqrt(m)*(o===a?-1:1);const _=m*n/r*u,y=m*-r/n*c,b=l*_-h*y+(i+e)/2,w=h*_+l*y+(t+s)/2,v=(c-_)/n,S=(u-y)/r,I=(-c-_)/n,R=(-u-y)/r,M=Zn(1,0,v,S);let C=Zn(v,S,I,R);a===0&&C>0&&(C-=qe),a===1&&C<0&&(C+=qe),f.centerX=b,f.centerY=w,f.ang1=M,f.ang2=C};function Gc(i,t,e,s,n,r,o,a=0,h=0,l=0){if(r===0||o===0)return;const c=Math.sin(a*qe/360),u=Math.cos(a*qe/360),f=u*(t-s)/2+c*(e-n)/2,d=-c*(t-s)/2+u*(e-n)/2;if(f===0&&d===0)return;r=Math.abs(r),o=Math.abs(o);const p=Math.pow(f,2)/Math.pow(r,2)+Math.pow(d,2)/Math.pow(o,2);p>1&&(r*=Math.sqrt(p),o*=Math.sqrt(p)),Wc(t,e,s,n,r,o,h,l,c,u,f,d,ci);let{ang1:x,ang2:g}=ci;const{centerX:m,centerY:_}=ci;let y=Math.abs(g)/(qe/4);Math.abs(1-y)<1e-7&&(y=1);const b=Math.max(Math.ceil(y),1);g/=b;let w=i[i.length-2],v=i[i.length-1];const S={x:0,y:0};for(let I=0;I<b;I++){const R=Bc(x,g),{x:M,y:C}=ui(R[0],r,o,u,c,m,_,S),{x:W,y:D}=ui(R[1],r,o,u,c,m,_,S),{x:G,y:V}=ui(R[2],r,o,u,c,m,_,S);Io(i,w,v,M,C,W,D,G,V),w=G,v=V,x+=g}}function Fc(i,t,e){const s=(o,a)=>{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),u=h/c,f=l/c;return{len:c,nx:u,ny:f}},n=(o,a)=>{o===0?i.moveTo(a.x,a.y):i.lineTo(a.x,a.y)};let r=t[t.length-1];for(let o=0;o<t.length;o++){const a=t[o%t.length],h=a.radius??e;if(h<=0){n(o,a),r=a;continue}const l=t[(o+1)%t.length],c=s(a,r),u=s(a,l);if(c.len<1e-4||u.len<1e-4){n(o,a),r=a;continue}let f=Math.asin(c.nx*u.ny-c.ny*u.nx),d=1,p=!1;c.nx*u.nx-c.ny*-u.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,d=-1,p=!0):f>0&&(d=-1,p=!0);const x=f/2;let g,m=Math.abs(Math.cos(x)*h/Math.sin(x));m>Math.min(c.len/2,u.len/2)?(m=Math.min(c.len/2,u.len/2),g=Math.abs(m*Math.sin(x)/Math.cos(x))):g=h;const _=a.x+u.nx*m+-u.ny*g*d,y=a.y+u.ny*m+u.nx*g*d,b=Math.atan2(c.ny,c.nx)+Math.PI/2*d,w=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&i.moveTo(_+Math.cos(b)*g,y+Math.sin(b)*g),i.arc(_,y,g,b,w,p),r=a}}function Dc(i,t,e,s){const n=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),r=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=t.length;for(let a=0;a<o;a++){const h=t[(a+1)%o],l=h.radius??e;if(l<=0){a===0?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y);continue}const c=t[a],u=t[(a+2)%o],f=n(c,h);let d;if(f<1e-4)d=h;else{const g=Math.min(f/2,l);d=r(h,c,g/f)}const p=n(u,h);let x;if(p<1e-4)x=h;else{const g=Math.min(p/2,l);x=r(h,u,g/p)}a===0?i.moveTo(d.x,d.y):i.lineTo(d.x,d.y),i.quadraticCurveTo(h.x,h.y,x.x,x.y,s)}}const Lc=new Q;class zc{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new It,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const s=this._currentPoly.points,n=s[s.length-2],r=s[s.length-1];return(n!==t||r!==e)&&s.push(t,e),this}arc(t,e,s,n,r,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Ro(a,t,e,s,n,r,o),this}arcTo(t,e,s,n,r){this._ensurePoly();const o=this._currentPoly.points;return Ec(o,t,e,s,n,r),this}arcToSvg(t,e,s,n,r,o,a){const h=this._currentPoly.points;return Gc(h,this._currentPoly.lastX,this._currentPoly.lastY,o,a,t,e,s,n,r),this}bezierCurveTo(t,e,s,n,r,o,a){this._ensurePoly();const h=this._currentPoly;return Io(this._currentPoly.points,h.lastX,h.lastY,t,e,s,n,r,o,a),this}quadraticCurveTo(t,e,s,n,r){this._ensurePoly();const o=this._currentPoly;return Ic(this._currentPoly.points,o.lastX,o.lastY,t,e,s,n,r),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const s=this.shapePrimitives,n=s.length;for(let r=0;r<t.instructions.length;r++){const o=t.instructions[r];this[o.action](...o.data)}if(t.checkForHoles&&s.length-n>1){let r=null;for(let o=n;o<s.length;o++){const a=s[o];if(a.shape.type==="polygon"){const h=a.shape,l=r?.shape;l&&l.containsPolygon(h)?(r.holes||(r.holes=[]),r.holes.push(a),s.copyWithin(o,o+1),s.length--,o--):r=a}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,n,r){return this.drawShape(new Q(t,e,s,n),r),this}circle(t,e,s,n){return this.drawShape(new zi(t,e,s),n),this}poly(t,e,s){const n=new $e(t);return n.closePath=e,this.drawShape(n,s),this}regularPoly(t,e,s,n,r=0,o){n=Math.max(n|0,3);const a=-1*Math.PI/2+r,h=Math.PI*2/n,l=[];for(let c=0;c<n;c++){const u=a-c*h;l.push(t+s*Math.cos(u),e+s*Math.sin(u))}return this.poly(l,!0,o),this}roundPoly(t,e,s,n,r,o=0,a){if(n=Math.max(n|0,3),r<=0)return this.regularPoly(t,e,s,n,o);const h=s*Math.sin(Math.PI/n)-.001;r=Math.min(r,h);const l=-1*Math.PI/2+o,c=Math.PI*2/n,u=(n-2)*Math.PI/n/2;for(let f=0;f<n;f++){const d=f*c+l,p=t+s*Math.cos(d),x=e+s*Math.sin(d),g=d+Math.PI+u,m=d-Math.PI-u,_=p+r*Math.cos(g),y=x+r*Math.sin(g),b=p+r*Math.cos(m),w=x+r*Math.sin(m);f===0?this.moveTo(_,y):this.lineTo(_,y),this.quadraticCurveTo(p,x,b,w,a)}return this.closePath()}roundShape(t,e,s=!1,n){return t.length<3?this:(s?Dc(this,t,e,n):Fc(this,t,e),this.closePath())}filletRect(t,e,s,n,r){if(r===0)return this.rect(t,e,s,n);const o=Math.min(s,n)/2,a=Math.min(o,Math.max(-o,r)),h=t+s,l=e+n,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(t,e+u).arcTo(t+c,e+c,t+u,e,u).lineTo(h-u,e).arcTo(h-c,e+c,h,e+u,u).lineTo(h,l-u).arcTo(h-c,l-c,t+s-u,l,u).lineTo(t+u,l).arcTo(t+c,l-c,t,l-u,u).closePath()}chamferRect(t,e,s,n,r,o){if(r<=0)return this.rect(t,e,s,n);const a=Math.min(r,Math.min(s,n)/2),h=t+s,l=e+n,c=[t+a,e,h-a,e,h,e+a,h,l-a,h-a,l,t+a,l,t,l-a,t,e+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(t,e,s,n,r){return this.drawShape(new Hi(t,e,s,n),r),this}roundRect(t,e,s,n,r,o){return this.drawShape(new Oi(t,e,s,n,r),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new $e,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new $e,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,o=s;s=r.a*s+r.c*n+r.tx,n=r.b*o+r.d*n+r.ty}this._currentPoly.points.push(s,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const s=t.instructions[e];this[s.action](...s.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let s=0;s<e.length;s++){const n=e[s],r=n.shape.getBounds(Lc);n.transform?t.addRect(r,n.transform):t.addRect(r)}return t}}class Zt{constructor(t,e=!1){this.instructions=[],this.uid=at("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?al(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new zc(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,s,n,r){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(X.shared);let h=0,l=0;if(!o||o.action!=="bezierCurveTo")h=a.x,l=a.y;else{h=o.data[2],l=o.data[3];const c=a.x,u=a.y;h=c+(c-h),l=u+(u-l)}return this.instructions.push({action:"bezierCurveTo",data:[h,l,t,e,s,n,r]}),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,s){const n=this.instructions[this.instructions.length-1],r=this.getLastPoint(X.shared);let o=0,a=0;if(!n||n.action!=="quadraticCurveTo")o=r.x,a=r.y;else{o=n.data[0],a=n.data[1];const h=r.x,l=r.y;o=h+(h-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,t,e,s]}),this._dirty=!0,this}rect(t,e,s,n,r){return this.instructions.push({action:"rect",data:[t,e,s,n,r]}),this._dirty=!0,this}circle(t,e,s,n){return this.instructions.push({action:"circle",data:[t,e,s,n]}),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,s,n,r,o,a){r||(r=n/2);const h=-1*Math.PI/2+o,l=s*2,c=Math.PI*2/l,u=[];for(let f=0;f<l;f++){const d=f%2?r:n,p=f*c+h;u.push(t+d*Math.cos(p),e+d*Math.sin(p))}return this.poly(u,!0,a),this}clone(t=!1){const e=new Zt;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const n=this.instructions[s];e.instructions.push({action:n.action,data:n.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,s=t.b,n=t.c,r=t.d,o=t.tx,a=t.ty;let h=0,l=0,c=0,u=0,f=0,d=0,p=0,x=0;for(let g=0;g<this.instructions.length;g++){const m=this.instructions[g],_=m.data;switch(m.action){case"moveTo":case"lineTo":h=_[0],l=_[1],_[0]=e*h+n*l+o,_[1]=s*h+r*l+a;break;case"bezierCurveTo":c=_[0],u=_[1],f=_[2],d=_[3],h=_[4],l=_[5],_[0]=e*c+n*u+o,_[1]=s*c+r*u+a,_[2]=e*f+n*d+o,_[3]=s*f+r*d+a,_[4]=e*h+n*l+o,_[5]=s*h+r*l+a;break;case"quadraticCurveTo":c=_[0],u=_[1],h=_[2],l=_[3],_[0]=e*c+n*u+o,_[1]=s*c+r*u+a,_[2]=e*h+n*l+o,_[3]=s*h+r*l+a;break;case"arcToSvg":h=_[5],l=_[6],p=_[0],x=_[1],_[0]=e*p+n*x,_[1]=s*p+r*x,_[5]=e*h+n*l+o,_[6]=s*h+r*l+a;break;case"circle":_[4]=be(_[3],t);break;case"rect":_[4]=be(_[4],t);break;case"ellipse":_[8]=be(_[8],t);break;case"roundRect":_[5]=be(_[5],t);break;case"addPath":_[0].transform(t);break;case"poly":_[2]=be(_[2],t);break;case"regularPoly":case"chamferRect":_[5]=be(_[5],t);break;case"closePath":break;default:bt("unknown transform action",m.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,s=this.instructions[e];if(!s)return t.x=0,t.y=0,t;for(;s.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;s=this.instructions[e]}switch(s.action){case"moveTo":case"lineTo":t.x=s.data[0],t.y=s.data[1];break;case"quadraticCurveTo":t.x=s.data[2],t.y=s.data[3];break;case"bezierCurveTo":t.x=s.data[4],t.y=s.data[5];break;case"arc":case"arcToSvg":t.x=s.data[5],t.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(t);break}return t}}function be(i,t){return i?i.prepend(t):t.clone()}function rt(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function Hc(i,t){const e=i.querySelectorAll("defs");for(let s=0;s<e.length;s++){const n=e[s];for(let r=0;r<n.children.length;r++){const o=n.children[r];switch(o.nodeName.toLowerCase()){case"lineargradient":t.defs[o.id]=Oc(o);break;case"radialgradient":t.defs[o.id]=Uc();break}}}}function Oc(i){const t=rt(i,"x1",0),e=rt(i,"y1",0),s=rt(i,"x2",1),n=rt(i,"y2",0),r=i.getAttribute("gradientUnits")||"objectBoundingBox",o=new Qt(t,e,s,n,r==="objectBoundingBox"?"local":"global");for(let a=0;a<i.children.length;a++){const h=i.children[a],l=rt(h,"offset",0),c=nt.shared.setValue(h.getAttribute("stop-color")).toNumber();o.addColorStop(l,c)}return o}function Uc(i){return bt("[SVG Parser] Radial gradients are not yet supported"),new Qt(0,0,1,0)}function Qn(i){const t=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const Jn={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 Eo(i,t){const e=i.getAttribute("style"),s={},n={},r={strokeStyle:s,fillStyle:n,useFill:!1,useStroke:!1};for(const o in Jn){const a=i.getAttribute(o);a&&tr(t,r,o,a.trim())}if(e){const o=e.split(";");for(let a=0;a<o.length;a++){const h=o[a].trim(),[l,c]=h.split(":");Jn[l]&&tr(t,r,l,c.trim())}}return{strokeStyle:r.useStroke?s:null,fillStyle:r.useFill?n:null,useFill:r.useFill,useStroke:r.useStroke}}function tr(i,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const n=Qn(s);t.strokeStyle.fill=i.defs[n]}else t.strokeStyle.color=nt.shared.setValue(s).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(s);break;case"fill":if(s!=="none"){if(s.startsWith("url(")){const n=Qn(s);t.fillStyle.fill=i.defs[n]}else t.fillStyle.color=nt.shared.setValue(s).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(s);break;case"stroke-opacity":t.strokeStyle.alpha=Number(s);break;case"opacity":t.fillStyle.alpha=Number(s),t.strokeStyle.alpha=Number(s);break}}function Yc(i){if(i.length<=2)return!0;const t=i.map(a=>a.area).sort((a,h)=>h-a),[e,s]=t,n=t[t.length-1],r=e/s,o=s/n;return!(r>3&&o<2)}function Nc(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function Xc(i){const t=i.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],n=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(s.push(e[c]),n.push(e[c+1]));if(s.length===0||n.length===0)return 0;const r=Math.min(...s),o=Math.max(...s),a=Math.min(...n),h=Math.max(...n);return(o-r)*(h-a)}function er(i,t){const e=new Zt(i,!1);for(const s of e.instructions)t.instructions.push(s)}function Vc(i,t){if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=i.trim(),i=o.querySelector("svg")}const e={context:t,defs:{},path:new Zt};Hc(i,e);const s=i.children,{fillStyle:n,strokeStyle:r}=Eo(i,e);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&Bo(a,e,n,r)}return t}function Bo(i,t,e,s){const n=i.children,{fillStyle:r,strokeStyle:o}=Eo(i,t);r&&e?e={...e,...r}:r&&(e=r),o&&s?s={...s,...o}:o&&(s=o);const a=!e&&!s;a&&(e={color:0});let h,l,c,u,f,d,p,x,g,m,_,y,b,w,v,S,I;switch(i.nodeName.toLowerCase()){case"path":{w=i.getAttribute("d");const R=i.getAttribute("fill-rule"),M=Nc(w),C=R==="evenodd",W=M.length>1;if(C&&W){const G=M.map(k=>({path:k,area:Xc(k)}));if(G.sort((k,E)=>E.area-k.area),M.length>3||!Yc(G))for(let k=0;k<G.length;k++){const E=G[k],O=k===0;t.context.beginPath();const B=new Zt(void 0,!0);er(E.path,B),t.context.path(B),O?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let k=0;k<G.length;k++){const E=G[k],O=k%2===1;t.context.beginPath();const B=new Zt(void 0,!0);er(E.path,B),t.context.path(B),O?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const G=R?R==="evenodd":!0;v=new Zt(w,G),t.context.path(v),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":p=rt(i,"cx",0),x=rt(i,"cy",0),g=rt(i,"r",0),t.context.ellipse(p,x,g,g),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":h=rt(i,"x",0),l=rt(i,"y",0),S=rt(i,"width",0),I=rt(i,"height",0),m=rt(i,"rx",0),_=rt(i,"ry",0),m||_?t.context.roundRect(h,l,S,I,m||_):t.context.rect(h,l,S,I),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":p=rt(i,"cx",0),x=rt(i,"cy",0),m=rt(i,"rx",0),_=rt(i,"ry",0),t.context.beginPath(),t.context.ellipse(p,x,m,_),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"line":c=rt(i,"x1",0),u=rt(i,"y1",0),f=rt(i,"x2",0),d=rt(i,"y2",0),t.context.beginPath(),t.context.moveTo(c,u),t.context.lineTo(f,d),s&&t.context.stroke(s);break;case"polygon":b=i.getAttribute("points"),y=b.match(/-?\d+/g).map(R=>parseInt(R,10)),t.context.poly(y,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":b=i.getAttribute("points"),y=b.match(/-?\d+/g).map(R=>parseInt(R,10)),t.context.poly(y,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{bt(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}a&&(e=null);for(let R=0;R<n.length;R++)Bo(n[R],t,e,s)}function $c(i){return i.texture!==void 0}const sr={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Ds{constructor(t,e){this.uid=at("fillPattern"),this._tick=0,this.transform=new N;const s=$c(t)?t:{texture:t,repetition:e};this.texture=s.texture,this.textureSpace=s.textureSpace??"global";const n=s.repetition;n&&(this.texture.source.style.addressModeU=sr[n].addressModeU,this.texture.source.style.addressModeV=sr[n].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 jc(i){return nt.isColorLike(i)}function ir(i){return i instanceof Ds}function nr(i){return i instanceof Qt}function qc(i){return i instanceof K}function Kc(i,t,e){const s=nt.shared.setValue(t??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=K.WHITE,{...e,...i}}function Zc(i,t,e){return i.texture=t,{...e,...i}}function rr(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,i.textureSpace=t.textureSpace,{...e,...i}}function or(i,t,e){return t.buildGradient(),i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,i.textureSpace=t.textureSpace,{...e,...i}}function Qc(i,t){const e={...t,...i},s=nt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function me(i,t){if(i==null)return null;const e={},s=i;return jc(i)?Kc(e,i,t):qc(i)?Zc(e,i,t):ir(i)?rr(e,i,t):nr(i)?or(e,i,t):s.fill&&ir(s.fill)?rr(s,s.fill,t):s.fill&&nr(s.fill)?or(s,s.fill,t):Qc(s,t)}function Is(i,t){const{width:e,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...h}=t,l=me(i,h);return l?{width:e,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...l}:null}function Jc(i,t){let e=1;const s=i.shapePath.shapePrimitives;for(let n=0;n<s.length;n++){const r=s[n].shape;if(r.type!=="polygon")continue;const o=r.points,a=o.length;if(a<6)continue;const h=r.closePath;for(let l=0;l<a;l+=2){if(!h&&(l===0||l===a-2))continue;const c=(l-2+a)%a,u=(l+2)%a,f=o[c],d=o[c+1],p=o[l],x=o[l+1],g=o[u],m=o[u+1],_=f-p,y=d-x,b=g-p,w=m-x,v=_*_+y*y,S=b*b+w*w;if(v<1e-12||S<1e-12)continue;let M=(_*b+y*w)/Math.sqrt(v*S);M<-1?M=-1:M>1&&(M=1);const C=Math.sqrt((1-M)*.5);if(C<1e-6)continue;const W=Math.min(1/C,t);W>e&&(e=W)}}return e}const tu=new X,ar=new N,Vi=class Ot extends Yt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=at("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Zt,this._transform=new N,this._fillStyle={...Ot.defaultFillStyle},this._strokeStyle={...Ot.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new It,this._boundsDirty=!0}clone(){const t=new Ot;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=me(t,Ot.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Is(t,Ot.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=me(t,Ot.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=me(t,Ot.defaultStrokeStyle),this}texture(t,e,s,n,r,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:n||0,dw:r||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?nt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Zt,this}fill(t,e){let s;const n=this.instructions[this.instructions.length-1];return this._tick===0&&n?.action==="stroke"?s=n.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&($(ot,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=me(t,Ot.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(X.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s?.action==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Is(t,Ot.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,n,r,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,s,n,r,o),this}arcTo(t,e,s,n,r){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*n+o.tx,o.b*s+o.d*n+o.ty,r),this}arcToSvg(t,e,s,n,r,o,a){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,n,r,h.a*o+h.c*a+h.tx,h.b*o+h.d*a+h.ty),this}bezierCurveTo(t,e,s,n,r,o,a){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*s+h.c*n+h.tx,h.b*s+h.d*n+h.ty,h.a*r+h.c*o+h.tx,h.b*r+h.d*o+h.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,s,n){return this._tick++,this._activePath.ellipse(t,e,s,n,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,n=this._activePath.instructions,r=s.a*t+s.c*e+s.tx,o=s.b*t+s.d*e+s.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=r,n[0].data[1]=o,this):(this._activePath.moveTo(r,o),this)}quadraticCurveTo(t,e,s,n,r){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,o.a*s+o.c*n+o.tx,o.b*s+o.d*n+o.ty,r),this}rect(t,e,s,n){return this._tick++,this._activePath.rect(t,e,s,n,this._transform.clone()),this}roundRect(t,e,s,n,r){return this._tick++,this._activePath.roundRect(t,e,s,n,r,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,n,r=0,o){return this._tick++,this._activePath.regularPoly(t,e,s,n,r,o),this}roundPoly(t,e,s,n,r,o){return this._tick++,this._activePath.roundPoly(t,e,s,n,r,o),this}roundShape(t,e,s,n){return this._tick++,this._activePath.roundShape(t,e,s,n),this}filletRect(t,e,s,n,r){return this._tick++,this._activePath.filletRect(t,e,s,n,r),this}chamferRect(t,e,s,n,r,o){return this._tick++,this._activePath.chamferRect(t,e,s,n,r,o),this}star(t,e,s,n,r=0,o=0){return this._tick++,this._activePath.star(t,e,s,n,r,o,this._transform.clone()),this}svg(t){return this._tick++,Vc(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...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,s,n,r,o){return t instanceof N?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,n,r,o),this)}transform(t,e,s,n,r,o){return t instanceof N?(this._transform.append(t),this):(ar.set(t,e,s,n,r,o),this._transform.append(ar),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const s=this.instructions[e],n=s.action;if(n==="fill"){const r=s.data;t.addBounds(r.path.bounds)}else if(n==="texture"){const r=s.data;t.addFrame(r.dx,r.dy,r.dx+r.dw,r.dy+r.dh,r.transform)}if(n==="stroke"){const r=s.data,o=r.style.alignment;let a=r.style.width*(1-o);r.style.join==="miter"&&(a*=Jc(r.path,r.style.miterLimit));const h=r.path.bounds;t.addFrame(h.minX-a,h.minY-a,h.maxX+a,h.maxY+a)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let s=!1;for(let n=0;n<e.length;n++){const r=e[n],o=r.data,a=o.path;if(!r.action||!a)continue;const h=o.style,l=a.shapePath.shapePrimitives;for(let c=0;c<l.length;c++){const u=l[c].shape;if(!h||!u)continue;const f=l[c].transform,d=f?f.applyInverse(t,tu):t;if(r.action==="fill")s=u.contains(d.x,d.y);else{const x=h;s=u.strokeContains(d.x,d.y,x.width,x.alignment)}const p=o.hole;if(p){const x=p.shapePath?.shapePrimitives;if(x)for(let g=0;g<x.length;g++)x[g].shape.contains(d.x,d.y)&&(s=!1)}if(s)return!0}}return s}unload(){this.emit("unload",this);for(const 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){const s=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(s)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(s))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Vi.defaultFillStyle={color:16777215,alpha:1,texture:K.WHITE,matrix:null,fill:null,textureSpace:"local"};Vi.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:K.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Dt=Vi,we;function hr(i){const t=ct.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=i,e.fillRect(0,0,6,1),t}function eu(){if(we!==void 0)return we;try{const i=hr("#ff00ff"),t=hr("#ffff00"),s=ct.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(i,0,0),s.drawImage(t,2,0);const n=s.getImageData(2,0,1,1);if(!n)we=!1;else{const r=n.data;we=r[0]===255&&r[1]===0&&r[2]===0}}catch{we=!1}return we}const tt={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:eu(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:i=>{const t=i.source,e=t?.resource;if(!e)return null;const s=t.alphaMode==="premultiplied-alpha",n=t.resourceWidth??t.pixelWidth,r=t.resourceHeight??t.pixelHeight,o=n!==t.pixelWidth||r!==t.pixelHeight;if(s){if((e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)&&!o)return e;const a=tt._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){const a=tt._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;const h=ct.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d"),c=l.createImageData(t.pixelWidth,t.pixelHeight),u=c.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<u.length&&d+3<f.length;d+=4)u[d]=f[d+2],u[d+1]=f[d+1],u[d+2]=f[d],u[d+3]=f[d+3];else u.set(f.subarray(0,u.length));return l.putImageData(c,0,0),tt._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}if(s){const a=ct.get().createCanvas(t.pixelWidth,t.pixelHeight),h=a.getContext("2d",{willReadFrequently:!0});a.width=t.pixelWidth,a.height=t.pixelHeight,h.drawImage(e,0,0);const l=h.getImageData(0,0,a.width,a.height),c=l.data;for(let u=0;u<c.length;u+=4){const f=c[u+3];if(f>0){const d=255/f;c[u]=Math.min(255,c[u]*d+.5),c[u+1]=Math.min(255,c[u+1]*d+.5),c[u+2]=Math.min(255,c[u+2]*d+.5)}}return h.putImageData(l,0,0),tt._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){const a=tt._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;const h=ct.get().createCanvas(t.pixelWidth,t.pixelHeight),l=h.getContext("2d");return h.width=t.pixelWidth,h.height=t.pixelHeight,l.drawImage(e,0,0),tt._canvasSourceCache.set(t,{canvas:h,resourceId:t._resourceId}),h}return e},getTintedCanvas:(i,t)=>{const e=i.texture,s=nt.shared.setValue(t).toHex(),n=e.tintCache||(e.tintCache={}),r=n[s],o=e.source._resourceId;if(r?.tintId===o)return r;const a=r&&"getContext"in r?r:ct.get().createCanvas();return tt.tintMethod(e,t,a),a.tintId=o,n[s]=a,n[s]},getTintedPattern:(i,t)=>{const e=nt.shared.setValue(t).toHex(),s=i.patternCache||(i.patternCache={}),n=i.source._resourceId;let r=s[e];return r?.tintId===n||(tt.canvas||(tt.canvas=ct.get().createCanvas()),tt.tintMethod(i,t,tt.canvas),r=tt.canvas.getContext("2d").createPattern(tt.canvas,"repeat"),r.tintId=n,s[e]=r),r},applyPatternTransform:(i,t,e=!0)=>{if(!t)return;const s=i;if(!s.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const r=new n([t.a,t.b,t.c,t.d,t.tx,t.ty]);s.setTransform(e?r.inverse():r)},tintWithMultiply:(i,t,e)=>{const s=e.getContext("2d"),n=i.frame.clone(),r=i.source._resolution??i.source.resolution??1,o=i.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=Y.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.fillStyle=nt.shared.setValue(t).toHex(),s.fillRect(0,0,h,l),s.globalCompositeOperation="multiply";const c=tt.getCanvasSource(i);if(!c){s.restore();return}o&&tt._applyInverseRotation(s,o,n.width,n.height),s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.globalCompositeOperation="destination-atop",s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.restore()},tintWithOverlay:(i,t,e)=>{const s=e.getContext("2d"),n=i.frame.clone(),r=i.source._resolution??i.source.resolution??1,o=i.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=Y.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.globalCompositeOperation="copy",s.fillStyle=nt.shared.setValue(t).toHex(),s.fillRect(0,0,h,l),s.globalCompositeOperation="destination-atop";const c=tt.getCanvasSource(i);if(!c){s.restore();return}o&&tt._applyInverseRotation(s,o,n.width,n.height),s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.restore()},tintWithPerPixel:(i,t,e)=>{const s=e.getContext("2d"),n=i.frame.clone(),r=i.source._resolution??i.source.resolution??1,o=i.rotate;n.x*=r,n.y*=r,n.width*=r,n.height*=r;const a=Y.isVertical(o),h=a?n.height:n.width,l=a?n.width:n.height;e.width=Math.ceil(h),e.height=Math.ceil(l),s.save(),s.globalCompositeOperation="copy";const c=tt.getCanvasSource(i);if(!c){s.restore();return}o&&tt._applyInverseRotation(s,o,n.width,n.height),s.drawImage(c,n.x,n.y,n.width,n.height,0,0,n.width,n.height),s.restore();const u=t>>16&255,f=t>>8&255,d=t&255,p=s.getImageData(0,0,h,l),x=p.data;for(let g=0;g<x.length;g+=4)x[g]=x[g]*u/255,x[g+1]=x[g+1]*f/255,x[g+2]=x[g+2]*d/255;s.putImageData(p,0,0)},_applyInverseRotation:(i,t,e,s)=>{const n=Y.inv(t),r=Y.uX(n),o=Y.uY(n),a=Y.vX(n),h=Y.vY(n),l=-Math.min(0,r*e,a*s,r*e+a*s),c=-Math.min(0,o*e,h*s,o*e+h*s);i.transform(r,o,a,h,l,c)}};tt.tintMethod=tt.canUseMultiply?tt.tintWithMultiply:tt.tintWithPerPixel;class su{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=ct.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=Ae(t),e=Ae(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,r=(s<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,n),this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const Ii=new su;is.register(Ii);const iu=new It;function nu(i,t,e,s,n=!1){const r=iu;r.minX=0,r.minY=0,r.maxX=i.width/s|0,r.maxY=i.height/s|0;const o=Bs.getOptimalTexture(r.width,r.height,s,!1,n);return o.source.uploadMethodId="image",o.source.resource=i,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=t/s,o.frame.height=e/s,o.source.emit("update",o.source),o.updateUvs(),o}class ru{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class ou{constructor(){this.instructions=new Gi}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const $i=class Ri{constructor(t){this._renderer=t,this._managedContexts=new ns({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Ri.defaultOptions.bezierSmoothness=t?.bezierSmoothness??Ri.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,s=!!e[this._renderer.uid],n=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!s)&&(s&&n.reset(),n.isBatchable=!1,t.dirty=!1),n}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new ou,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new ru;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};$i.extension={type:[H.CanvasSystem],name:"graphicsContext"};$i.defaultOptions={bezierSmoothness:.5};let au=$i;class Wo{constructor(t,e){this.state=io.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ns({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}}Wo.extension={type:[H.CanvasPipes],name:"graphics"};function hu(i,t,e){const s=(i>>24&255)/255;t[e++]=(i&255)/255*s,t[e++]=(i>>8&255)/255*s,t[e++]=(i>>16&255)/255*s,t[e++]=s}class lu{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{vt.return(t)}),this.batches.length=0}}class Go{constructor(t,e){this.state=io.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new ns({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,r=this.renderer.graphicsContext.updateGpuContext(e);return!!(r.isBatchable||s!==r.isBatchable)}addRenderable(t,e){const n=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),n.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const s=this._getGpuDataForRenderable(t).batches;for(let n=0;n<s.length;n++){const r=s[n];r._batcher.updateElement(r)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const r=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const o=r.resources.localUniforms.uniforms;o.uTransformMatrix=t.groupTransform,o.uRound=e._roundPixels|t._roundPixels,hu(t.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),n=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),n.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const s=this.renderer.renderPipes.batch,n=this._getGpuDataForRenderable(t).batches;for(let r=0;r<n.length;r++){const o=n[r];s.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new lu;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const s=t.context,r=this.renderer.graphicsContext.getGpuContext(s),o=this.renderer._roundPixels|t._roundPixels;e.batches=r.batches.map(a=>{const h=vt.get(Ui);return a.copyTo(h),h.renderable=t,h.roundPixels=o,h})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Go.extension={type:[H.WebGLPipes,H.WebGPUPipes],name:"graphics"};ht.add(Wo);ht.add(Go);ht.add(au);ht.add(Xi);class Ut extends Fi{constructor(t){t instanceof Dt&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new Dt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||t?.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 Ut(this._context.clone()):(this._ownedContext=null,new Ut(this._context))}lineStyle(t,e,s){$(ot,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){$(ot,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){$(ot,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==Dt.defaultStrokeStyle.width||t.color!==Dt.defaultStrokeStyle.color||t.alpha!==Dt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return $(ot,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return $(ot,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return $(ot,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return $(ot,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return $(ot,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return $(ot,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class cu extends Fi{constructor(t,e){const{text:s,resolution:n,style:r,anchor:o,width:a,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new mt({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=l??!1,a!==void 0&&(this.width=a),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){t||(t={}),this._style?.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-s*this.anchor.y,t.y>=r&&t.y<=r+s)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function uu(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&($(ot,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}let he=null,qt=null;function du(i,t){he||(he=ct.get().createCanvas(256,128),qt=he.getContext("2d",{willReadFrequently:!0}),qt.globalCompositeOperation="copy",qt.globalAlpha=1),(he.width<i||he.height<t)&&(he.width=Ae(i),he.height=Ae(t))}function lr(i,t,e){for(let s=0,n=4*e*t;s<t;++s,n+=4)if(i[n+3]!==0)return!1;return!0}function cr(i,t,e,s,n){const r=4*t;for(let o=s,a=s*r+4*e;o<=n;++o,a+=r)if(i[a+3]!==0)return!1;return!0}function fu(...i){let t=i[0];t.canvas||(t={canvas:i[0],resolution:i[1]});const{canvas:e}=t,s=Math.min(t.resolution??1,1),n=t.width??e.width,r=t.height??e.height;let o=t.output;if(du(n,r),!qt)throw new TypeError("Failed to get canvas 2D context");qt.drawImage(e,0,0,n,r,0,0,n*s,r*s);const h=qt.getImageData(0,0,n,r).data;let l=0,c=0,u=n-1,f=r-1;for(;c<r&&lr(h,n,c);)++c;if(c===r)return Q.EMPTY;for(;lr(h,n,f);)--f;for(;cr(h,n,l,c,f);)++l;for(;cr(h,n,u,c,f);)--u;return++u,++f,qt.globalCompositeOperation="source-over",qt.strokeRect(l,c,u-l,f-c),qt.globalCompositeOperation="copy",o??(o=new Q),o.set(l/s,c/s,(u-l)/s,(f-c)/s),o}class pu{constructor(t=0,e=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=s,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++){const n=t[s];e[s]=[n,this.get(n)]}return e}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,s=0;for(;e!==null;)t[s++]=e.key,e=e.next;return t}setWithEvicted(t,e,s=this.resetTtl){let n=null;if(this.has(t))this.set(t,e,!0,s);else{this.max>0&&this.size===this.max&&(n={...this.first},this.evict(!0));let r=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=r:this.last.next=r,this.last=r}return n}set(t,e,s=!1,n=this.resetTtl){let r=this.items[t];return s||r!==void 0?(r.value=e,s===!1&&n&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(r)):(this.max>0&&this.size===this.max&&this.evict(!0),r=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=r:this.last.next=r,this.last=r),this}values(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=this.get(t[s]);return e}}function gu(i=1e3,t=0,e=!1){if(isNaN(i)||i<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 pu(i,t,e)}function Fo(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function Do(i){return i.includes("<")}function mu(i,t){return i.clone().assign(t)}function xu(i,t){const e=[],s=t.tagStyles;if(!Fo(t)||!Do(i))return e.push({text:i,style:t}),e;const n=[t],r=[];let o="",a=0;for(;a<i.length;){const h=i[a];if(h==="<"){const l=i.indexOf(">",a);if(l===-1){o+=h,a++;continue}const c=i.indexOf("<",a+1);if(c!==-1&&c<l){o+=h,a++;continue}const u=i.slice(a+1,l);if(u.startsWith("/")){const f=u.slice(1).trim();if(r.length>0&&r[r.length-1]===f){o.length>0&&(e.push({text:o,style:n[n.length-1]}),o=""),n.pop(),r.pop(),a=l+1;continue}else{o+=i.slice(a,l+1),a=l+1;continue}}else{const f=u.trim();if(s[f]){o.length>0&&(e.push({text:o,style:n[n.length-1]}),o="");const d=n[n.length-1],p=mu(d,s[f]);n.push(p),r.push(f),a=l+1;continue}else{o+=i.slice(a,l+1),a=l+1;continue}}}else o+=h,a++}return o.length>0&&e.push({text:o,style:n[n.length-1]}),e}const yu=[10,13],_u=new Set(yu),bu=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],wu=new Set(bu),vu=[9,32];new Set(vu);const Su=[45,8208,8211,8212,173],Cu=new Set(Su),Mu=/(\r\n|\r|\n)/,Tu=/(?:\r\n|\r|\n)/;function Rs(i){return typeof i!="string"?!1:_u.has(i.charCodeAt(0))}function Pt(i,t){return typeof i!="string"?!1:wu.has(i.charCodeAt(0))}function Au(i){return typeof i!="string"?!1:Cu.has(i.charCodeAt(0))}function Lo(i){return i==="normal"||i==="pre-line"}function zo(i){return i==="normal"}function jt(i){if(typeof i!="string")return"";let t=i.length-1;for(;t>=0&&Pt(i[t]);)t--;return t<i.length-1?i.slice(0,t+1):i}function Ho(i){const t=[],e=[];if(typeof i!="string")return t;for(let s=0;s<i.length;s++){const n=i[s],r=i[s+1];if(Pt(n)||Rs(n)){e.length>0&&(t.push(e.join("")),e.length=0),n==="\r"&&r===`
240
+ `?(t.push(`\r
241
+ `),s++):t.push(n);continue}e.push(n),Au(n)&&r&&!Pt(r)&&!Rs(r)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function Oo(i,t,e,s){const n=e(i),r=[];for(let o=0;o<n.length;o++){let a=n[o],h=a,l=1;for(;n[o+l];){const c=n[o+l];if(!s(h,c,i,o,t))a+=c,h=c,l++;else break}o+=l-1,r.push(a)}return r}const Pu=/\r\n|\r|\n/g;function ku(i,t,e,s,n,r,o,a,h){const l=xu(i,t);if(zo(t.whiteSpace))for(let G=0;G<l.length;G++){const V=l[G];l[G]={text:V.text.replace(Pu," "),style:V.style}}const u=[];let f=[];for(const G of l){const V=G.text.split(Mu);for(let k=0;k<V.length;k++){const E=V[k];E===`\r
242
+ `||E==="\r"||E===`
243
+ `?(u.push(f),f=[]):E.length>0&&f.push({text:E,style:G.style})}}(f.length>0||u.length===0)&&u.push(f);const d=e?Iu(u,t,s,r,a,h):u,p=[],x=[],g=[],m=[],_=[];let y=0;const b=t._fontString,w=o(b);w.fontSize===0&&(w.fontSize=t.fontSize,w.ascent=t.fontSize);let v="",S=!!t.dropShadow,I=t._stroke?.width||0;for(const G of d){let V=0,k=w.ascent,E=w.descent,O="";for(const q of G){const et=q.style._fontString,xt=o(et);et!==v&&(s.font=et,v=et);const st=n(q.text,q.style.letterSpacing,s);V+=st,k=Math.max(k,xt.ascent),E=Math.max(E,xt.descent),O+=q.text;const pt=q.style._stroke?.width||0;pt>I&&(I=pt),!S&&q.style.dropShadow&&(S=!0)}G.length===0&&(k=w.ascent,E=w.descent),p.push(V),x.push(k),g.push(E),_.push(O);const B=t.lineHeight||k+E;m.push(B+t.leading),y=Math.max(y,V)}const R=I,M=y+R+(t.dropShadow?t.dropShadow.distance:0);let C=0;for(let G=0;G<m.length;G++)C+=m[G];C=Math.max(C,m[0]+R);const W=C+(t.dropShadow?t.dropShadow.distance:0),D=t.lineHeight||w.fontSize;return{width:M,height:W,lines:_,lineWidths:p,lineHeight:D+t.leading,maxLineWidth:y,fontProperties:w,runsByLine:d,lineAscents:x,lineDescents:g,lineHeights:m,hasDropShadow:S}}function Iu(i,t,e,s,n,r){const{letterSpacing:o,whiteSpace:a,wordWrapWidth:h,breakWords:l}=t,c=Lo(a),u=h+o,f={};let d="";const p=(g,m)=>{const _=`${g}|${m.styleKey}`;let y=f[_];if(y===void 0){const b=m._fontString;b!==d&&(e.font=b,d=b),y=s(g,m.letterSpacing,e)+m.letterSpacing,f[_]=y}return y},x=[];for(const g of i){const m=Ru(g),_=x.length,y=C=>{let W=0,D=C;do{const{token:G,style:V}=m[D];W+=p(G,V),D++}while(D<m.length&&m[D].continuesFromPrevious);return W},b=C=>{const W=[];let D=C;do W.push({token:m[D].token,style:m[D].style}),D++;while(D<m.length&&m[D].continuesFromPrevious);return W};let w=[],v=0,S=!c,I=null;const R=()=>{I&&I.text.length>0&&w.push(I),I=null},M=()=>{if(R(),w.length>0){const C=w[w.length-1];C.text=jt(C.text),C.text.length===0&&w.pop()}x.push(w),w=[],v=0,S=!1};for(let C=0;C<m.length;C++){const{token:W,style:D,continuesFromPrevious:G}=m[C],V=p(W,D);if(c){const O=Pt(W),B=I?.text[I.text.length-1]??w[w.length-1]?.text.slice(-1)??"",q=B?Pt(B):!1;if(O&&q)continue}const k=!G,E=k?y(C):V;if(E>u&&k)if(v>0&&M(),l){const O=b(C);for(let B=0;B<O.length;B++){const q=O[B].token,et=O[B].style,xt=Oo(q,l,r,n);for(const st of xt){const pt=p(st,et);pt+v>u&&M(),!I||I.style!==et?(R(),I={text:st,style:et}):I.text+=st,v+=pt}}C+=O.length-1}else{const O=b(C);R(),x.push(O.map(B=>({text:B.token,style:B.style}))),S=!1,C+=O.length-1}else if(E+v>u&&k){if(Pt(W)){S=!1;continue}M(),I={text:W,style:D},v=V}else if(G&&!l)!I||I.style!==D?(R(),I={text:W,style:D}):I.text+=W,v+=V;else{const O=Pt(W);if(v===0&&O&&!S)continue;!I||I.style!==D?(R(),I={text:W,style:D}):I.text+=W,v+=V}}if(R(),w.length>0){const C=w[w.length-1];C.text=jt(C.text),C.text.length===0&&w.pop()}(w.length>0||x.length===_)&&x.push(w)}return x}function Ru(i){const t=[];let e=!1;for(const s of i){const n=Ho(s.text);let r=!0;for(const o of n){const a=Pt(o)||Rs(o),h=r&&e&&!a;t.push({token:o,style:s.style,continuesFromPrevious:h}),e=!a,r=!1}}return t}const Eu={willReadFrequently:!0};function ur(i,t,e,s,n){let r=e[i];return typeof r!="number"&&(r=n(i,t,s)+t,e[i]=r),r}function Bu(i,t,e,s,n,r,o){const a=e.getContext("2d",Eu);a.font=t._fontString;let h=0,l="";const c=[],u=Object.create(null),{letterSpacing:f,whiteSpace:d}=t,p=Lo(d),x=zo(d);let g=!p;const m=t.wordWrapWidth+f,_=Ho(i);for(let b=0;b<_.length;b++){let w=_[b];if(Rs(w)){if(!x){c.push(jt(l)),g=!p,l="",h=0;continue}w=" "}if(p){const S=Pt(w),I=Pt(l[l.length-1]);if(S&&I)continue}const v=ur(w,f,u,a,s);if(v>m)if(l!==""&&(c.push(jt(l)),l="",h=0),n(w,t.breakWords)){const S=Oo(w,t.breakWords,o,r);for(const I of S){const R=ur(I,f,u,a,s);R+h>m&&(c.push(jt(l)),g=!1,l="",h=0),l+=I,h+=R}}else l.length>0&&(c.push(jt(l)),l="",h=0),c.push(jt(w)),g=!1,l="",h=0;else v+h>m&&(g=!1,c.push(jt(l)),l="",h=0),(l.length>0||!Pt(w)||g)&&(l+=w,h+=v)}const y=jt(l);return y.length>0&&c.push(y),c.join(`
244
+ `)}const dr={willReadFrequently:!0},Jt=class F{static get experimentalLetterSpacingSupported(){let t=F._experimentalLetterSpacingSupported;if(t===void 0){const e=ct.get().getCanvasRenderingContext2D().prototype;t=F._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,r,o,a,h,l,c){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=r,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,s=F._canvas,n=e.wordWrap){const r=`${t}-${e.styleKey}-wordWrap-${n}`;if(F._measurementCache.has(r))return F._measurementCache.get(r);if(Fo(e)&&Do(t)){const b=ku(t,e,n,F._context,F._measureText,F._measureTextAdvance,F.measureFont,F.canBreakChars,F.wordWrapSplit),w=new F(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 F._measurementCache.set(r,w),w}const a=e._fontString,h=F.measureFont(a);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const l=F._context;l.font=a;const u=(n?F._wordWrap(t,e,s):t).split(Tu),f=new Array(u.length);let d=0;for(let b=0;b<u.length;b++){const w=F._measureText(u[b],e.letterSpacing,l);f[b]=w,d=Math.max(d,w)}const p=e._stroke?.width??0,x=e.lineHeight||h.fontSize,g=F._adjustWidthForStyle(d,e),m=Math.max(x,h.fontSize+p)+(u.length-1)*(x+e.leading),_=F._adjustHeightForStyle(m,e),y=new F(t,e,g,_,u,f,x+e.leading,d,h);return F._measurementCache.set(r,y),y}static _adjustWidthForStyle(t,e){const s=e._stroke?.width||0;let n=t+s;return e.dropShadow&&(n+=e.dropShadow.distance),n}static _adjustHeightForStyle(t,e){let s=t;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _measureText(t,e,s){const{metricWidth:n,metrics:r,letterSpacingVal:o}=F._measureTextCore(t,e,s),a=-(r.actualBoundingBoxLeft??0);let l=(r.actualBoundingBoxRight??0)-a;return r.width>0&&(l+=o),Math.max(n,l)}static _measureTextAdvance(t,e,s){return F._measureTextCore(t,e,s).metricWidth}static _measureTextCore(t,e,s){let n=!1;F.experimentalLetterSpacingSupported&&(F.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,n=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const r=s.measureText(t);let o=r.width,a=0;return o>0&&(n?a=-e:a=(F.graphemeSegmenter(t).length-1)*e,o+=a),{metricWidth:o,metrics:r,letterSpacingVal:a}}static _wordWrap(t,e,s=F._canvas){return Bu(t,e,s,F._measureTextAdvance,F.canBreakWords,F.canBreakChars,F.wordWrapSplit)}static isBreakingSpace(t,e){return Pt(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,n,r){return!0}static wordWrapSplit(t){return F.graphemeSegmenter(t)}static measureFont(t){if(F._fonts[t])return F._fonts[t];const e=F._context;e.font=t;const s=e.measureText(F.METRICS_STRING+F.BASELINE_SYMBOL),n=s.actualBoundingBoxAscent??0,r=s.actualBoundingBoxDescent??0,o={ascent:n,descent:r,fontSize:n+r};return F._fonts[t]=o,o}static clearMetrics(t=""){t?delete F._fonts[t]:F._fonts={}}static get _canvas(){if(!F.__canvas){let t;try{const e=new OffscreenCanvas(0,0);if(e.getContext("2d",dr)?.measureText)return F.__canvas=e,e;t=ct.get().createCanvas()}catch{t=ct.get().createCanvas()}t.width=t.height=10,F.__canvas=t}return F.__canvas}static get _context(){return F.__context||(F.__context=F._canvas.getContext("2d",dr)),F.__context}};Jt.METRICS_STRING="|ÉqÅ";Jt.BASELINE_SYMBOL="M";Jt.BASELINE_MULTIPLIER=1.4;Jt.HEIGHT_MULTIPLIER=2;Jt.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const i=new Intl.Segmenter;return t=>{const e=i.segment(t),s=[];let n=0;for(const r of e)s[n++]=r.segment;return s}}return i=>[...i]})();Jt.experimentalLetterSpacing=!1;Jt._fonts={};Jt._measurementCache=gu(1e3);let se=Jt;const Wu=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Ei(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!Wu.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const fr=1e5;function Cs(i,t,e,s=0,n=0,r=0){if(i.texture===K.WHITE&&!i.fill)return nt.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Ds){const o=i.fill,a=t.createPattern(o.texture.source.resource,"repeat");return tt.applyPatternTransform(a,o.transform,!1),a}else if(i.fill instanceof Qt){const o=i.fill,a=o.type==="linear",h=o.textureSpace==="local";let l=1,c=1;h&&e&&(l=e.width+s,c=e.height+s);let u,f=!1;if(a){const{start:d,end:p}=o;u=t.createLinearGradient(d.x*l+n,d.y*c+r,p.x*l+n,p.y*c+r),f=Math.abs(p.x-d.x)<Math.abs((p.y-d.y)*.1)}else{const{center:d,innerRadius:p,outerCenter:x,outerRadius:g}=o;u=t.createRadialGradient(d.x*l+n,d.y*c+r,p*l,x.x*l+n,x.y*c+r,g*l)}if(f&&h&&e){const d=e.lineHeight/c;for(let p=0;p<e.lines.length;p++){const x=(p*e.lineHeight+s/2)/c;o.colorStops.forEach(g=>{let m=x+g.offset*d;m=Math.max(0,Math.min(1,m)),u.addColorStop(Math.floor(m*fr)/fr,nt.shared.setValue(g.color).toHex())})}}else o.colorStops.forEach(d=>{u.addColorStop(d.offset,nt.shared.setValue(d.color).toHex())});return u}}else{const o=t.createPattern(i.texture.source.resource,"repeat"),a=i.matrix.copyTo(N.shared);return a.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),o.setTransform(a),o}return bt("FillStyle not recognised",i),"red"}const pr=new Q;function ve(i){let t=0;for(let e=0;e<i.length;e++)i.charCodeAt(e)===32&&t++;return t}class Gu{getCanvasAndContext(t){const{text:e,style:s,resolution:n=1}=t,r=s._getFinalPadding(),o=se.measureText(e||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+r*2)*n),h=Math.ceil(Math.ceil(Math.max(1,o.height)+r*2)*n),l=Ii.getOptimalCanvasAndContext(a,h);this._renderTextToCanvas(s,r,n,l,o);const c=s.trim?fu({canvas:l.canvas,width:a,height:h,resolution:1,output:pr}):pr.set(0,0,a,h);return{canvasAndContext:l,frame:c}}returnCanvasAndContext(t){Ii.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,n,r){if(r.runsByLine&&r.runsByLine.length>0){this._renderTaggedTextToCanvas(r,t,e,s,n);return}const{canvas:o,context:a}=n,h=Ei(t),l=r.lines,c=r.lineHeight,u=r.lineWidths,f=r.maxLineWidth,d=r.fontProperties,p=o.height;if(a.resetTransform(),a.scale(s,s),a.textBaseline=t.textBaseline,t._stroke?.width){const w=t._stroke;a.lineWidth=w.width,a.miterLimit=w.miterLimit,a.lineJoin=w.join,a.lineCap=w.cap}a.font=h;let x,g;const m=t.dropShadow?2:1,y=(t._stroke?.width??0)/2;let b=(c-d.fontSize)/2;c-d.fontSize<0&&(b=0);for(let w=0;w<m;++w){const v=t.dropShadow&&w===0,S=v?Math.ceil(Math.max(1,p)+e*2):0,I=S*s;if(v)this._setupDropShadow(a,t,s,I);else{const R=t._gradientBounds,M=t._gradientOffset;if(R){const C={width:R.width,height:R.height,lineHeight:R.height,lines:r.lines};this._setFillAndStrokeStyles(a,t,C,e,y,M?.x??0,M?.y??0)}else M?this._setFillAndStrokeStyles(a,t,r,e,y,M.x,M.y):this._setFillAndStrokeStyles(a,t,r,e,y);a.shadowColor="rgba(0,0,0,0)"}for(let R=0;R<l.length;R++){x=y,g=y+R*c+d.ascent+b,x+=this._getAlignmentOffset(u[R],f,t.align);let M=0;if(t.align==="justify"&&t.wordWrap&&R<l.length-1){const C=ve(l[R]);C>0&&(M=(f-u[R])/C)}t._stroke?.width&&this._drawLetterSpacing(l[R],t,n,x+e,g+e-S,!0,M),t._fill!==void 0&&this._drawLetterSpacing(l[R],t,n,x+e,g+e-S,!1,M)}}}_renderTaggedTextToCanvas(t,e,s,n,r){const{canvas:o,context:a}=r,{runsByLine:h,lineWidths:l,maxLineWidth:c,lineAscents:u,lineHeights:f,hasDropShadow:d}=t,p=o.height;a.resetTransform(),a.scale(n,n),a.textBaseline=e.textBaseline;const x=d?2:1;let g=e._stroke?.width??0;for(const y of h)for(const b of y){const w=b.style._stroke?.width??0;w>g&&(g=w)}const m=g/2,_=[];for(let y=0;y<h.length;y++){const b=h[y],w=[];for(const v of b){const S=Ei(v.style);a.font=S,w.push({width:se._measureText(v.text,v.style.letterSpacing,a),font:S})}_.push(w)}for(let y=0;y<x;++y){const b=d&&y===0,w=b?Math.ceil(Math.max(1,p)+s*2):0,v=w*n;b||(a.shadowColor="rgba(0,0,0,0)");let S=m;for(let I=0;I<h.length;I++){const R=h[I],M=l[I],C=u[I],W=f[I],D=_[I];let G=m;G+=this._getAlignmentOffset(M,c,e.align);let V=0;if(e.align==="justify"&&e.wordWrap&&I<h.length-1){let O=0;for(const B of R)O+=ve(B.text);O>0&&(V=(c-M)/O)}const k=S+C;let E=G+s;for(let O=0;O<R.length;O++){const B=R[O],{width:q,font:et}=D[O];if(a.font=et,a.textBaseline=B.style.textBaseline,B.style._stroke?.width){const st=B.style._stroke;if(a.lineWidth=st.width,a.miterLimit=st.miterLimit,a.lineJoin=st.join,a.lineCap=st.cap,b)if(B.style.dropShadow)this._setupDropShadow(a,B.style,n,v);else{const pt=ve(B.text);E+=q+pt*V;continue}else{const pt=se.measureFont(et),Bt=B.style.lineHeight||pt.fontSize,Nt={width:q,height:Bt,lineHeight:Bt,lines:[B.text]};a.strokeStyle=Cs(st,a,Nt,s*2,E-s,S)}this._drawLetterSpacing(B.text,B.style,r,E,k+s-w,!0,V)}const xt=ve(B.text);E+=q+xt*V}E=G+s;for(let O=0;O<R.length;O++){const B=R[O],{width:q,font:et}=D[O];if(a.font=et,a.textBaseline=B.style.textBaseline,B.style._fill!==void 0){if(b)if(B.style.dropShadow)this._setupDropShadow(a,B.style,n,v);else{const st=ve(B.text);E+=q+st*V;continue}else{const st=se.measureFont(et),pt=B.style.lineHeight||st.fontSize,Bt={width:q,height:pt,lineHeight:pt,lines:[B.text]};a.fillStyle=Cs(B.style._fill,a,Bt,s*2,E-s,S)}this._drawLetterSpacing(B.text,B.style,r,E,k+s-w,!1,V)}const xt=ve(B.text);E+=q+xt*V}S+=W}}}_setFillAndStrokeStyles(t,e,s,n,r,o=0,a=0){if(t.fillStyle=e._fill?Cs(e._fill,t,s,n*2,o,a):null,e._stroke?.width){const h=r+n*2;t.strokeStyle=Cs(e._stroke,t,s,h,o,a)}}_setupDropShadow(t,e,s,n){t.fillStyle="black",t.strokeStyle="black";const r=e.dropShadow,o=r.color,a=r.alpha;t.shadowColor=nt.shared.setValue(o).setAlpha(a).toRgbaString();const h=r.blur*s,l=r.distance*s;t.shadowBlur=h,t.shadowOffsetX=Math.cos(r.angle)*l,t.shadowOffsetY=Math.sin(r.angle)*l+n}_getAlignmentOffset(t,e,s){return s==="right"?e-t:s==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,s,n,r,o=!1,a=0){const{context:h}=s,l=e.letterSpacing;let c=!1;if(se.experimentalLetterSpacingSupported&&(se.experimentalLetterSpacing?(h.letterSpacing=`${l}px`,h.textLetterSpacing=`${l}px`,c=!0):(h.letterSpacing="0px",h.textLetterSpacing="0px")),(l===0||c)&&a===0){o?h.strokeText(t,n,r):h.fillText(t,n,r);return}if(a!==0&&(l===0||c)){const x=t.split(" ");let g=n;const m=h.measureText(" ").width;for(let _=0;_<x.length;_++)o?h.strokeText(x[_],g,r):h.fillText(x[_],g,r),g+=h.measureText(x[_]).width+m+a;return}let u=n;const f=se.graphemeSegmenter(t);let d=h.measureText(t).width,p=0;for(let x=0;x<f.length;++x){const g=f[x];o?h.strokeText(g,u,r):h.fillText(g,u,r);let m="";for(let _=x+1;_<f.length;++_)m+=f[_];p=h.measureText(m).width,u+=d-p+l,g===" "&&(u+=a),d=p}}}const Te=new Gu,ji=class pe extends Yt{constructor(t={}){super(),this.uid=at("textStyle"),this._tick=0,this._cachedFontString=null,Fu(t),t instanceof pe&&(t=t._toObject());const n={...pe.defaultTextStyle,...t};for(const r in n){const o=r;this[o]=n[r]}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({...pe.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...pe.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({...Dt.defaultFillStyle,...t},()=>{this._fill=me({...this._originalFill},Dt.defaultFillStyle)})),this._fill=me(t===0?"black":t,Dt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...Dt.defaultStrokeStyle,...t},()=>{this._stroke=Is({...this._originalStroke},Dt.defaultStrokeStyle)})),this._stroke=Is(t,Dt.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(){const t=pe.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const s=e;this[s]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Ei(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 pe(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){const s=typeof t=="boolean"?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(s),this._originalFill?.texture&&this._originalFill.texture.destroy(s),this._stroke?.texture&&this._stroke.texture.destroy(s),this._originalStroke?.texture&&this._originalStroke.texture.destroy(s)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,n,r)=>(s[n]===r||(s[n]=r,e?.(n,r),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(nt.isColorLike(t)||t instanceof Qt||t instanceof Ds)}};ji.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};ji.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Es=ji;function Fu(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=Es.defaultDropShadow;i.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){$(ot,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(nt.isColorLike(e))s.color=e;else if(e instanceof Qt||e instanceof Ds)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if($(ot,"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&&bt("The number of fill colors must match the number of fill gradient stops.");const e=new Qt({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=t.fillGradientStops.slice(),n=t.fill.map(r=>nt.shared.setValue(r).toNumber());s.forEach((r,o)=>{e.addColorStop(r,n[o])}),i.fill={fill:e}}}function Du(i,t){const{texture:e,bounds:s}=i,n=t._style._getFinalPadding();Cr(s,t._anchor,e);const r=t._anchor._x*n*2,o=t._anchor._y*n*2;s.minX-=n-r,s.minY-=n-o,s.maxX-=n-r,s.maxY-=n-o}class Lu{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class zu extends Lu{}class Uo{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new ns({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e?._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s?!0:t._didTextUpdate}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t._resolution!==n)&&this._updateGpuText(t),t._didTextUpdate=!1,Du(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new zu;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:s}=this._renderer;s.getReferenceCount(e.currentKey)>0?s.decreaseReferenceCount(e.currentKey):e.texture&&s.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Uo.extension={type:[H.WebGLPipes,H.WebGPUPipes,H.CanvasPipes],name:"text"};class Yo{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,n){typeof t=="string"&&($("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof Es||(t.style=new Es(t.style)),t.textureStyle instanceof Pe||(t.textureStyle=new Pe(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:r,style:o,textureStyle:a,autoGenerateMipmaps:h}=t,l=t.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=Te.getCanvasAndContext({text:r,style:o,resolution:l}),f=nu(u.canvas,c.width,c.height,l,h);if(a&&(f.source.style=a),o.trim&&(c.pad(o.padding),f.frame.copyFrom(c),f.frame.scale(1/l),f.updateUvs()),o.filters){const d=this._applyFilters(f,o.filters);return this.returnTexture(f),Te.returnCanvasAndContext(u),d}return this._renderer.texture.initSource(f._source),this._retainCanvasContext||Te.returnCanvasAndContext(u),f}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&s?.getContext){const n=s.getContext("2d");n&&Te.returnCanvasAndContext({canvas:s,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Bs.returnTexture(t,!0)}renderTextToCanvas(){$("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const s=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:s,usageCount:1},s}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){return this._activeTextures[t]?.usageCount??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const s=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(s,!1),n}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class No extends Yo{constructor(t){super(t,!0)}}No.extension={type:[H.CanvasSystem],name:"canvasText"};class Xo extends Yo{constructor(t){super(t,!1)}}Xo.extension={type:[H.WebGLSystem,H.WebGPUSystem],name:"canvasText"};ht.add(No);ht.add(Xo);ht.add(Uo);class Hu extends cu{constructor(...t){const e=uu(t,"Text");super(e,Es),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Pe?e.textureStyle:new Pe(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??Rt.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,n=0;if(this._style.trim){const{frame:r,canvasAndContext:o}=Te.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Te.returnCanvasAndContext(o),s=r.width,n=r.height}else{const r=se.measureText(this._text,this._style);s=r.width,n=r.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}}ht.add(ha,la);var Ou=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Uu(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Vo={exports:{}};(function(i,t){(function(){var e,s;s=function(n){return i.exports=n},e={linear:function(n,r,o,a){return o*n/a+r},easeInQuad:function(n,r,o,a){return o*(n/=a)*n+r},easeOutQuad:function(n,r,o,a){return-o*(n/=a)*(n-2)+r},easeInOutQuad:function(n,r,o,a){return(n/=a/2)<1?o/2*n*n+r:-o/2*(--n*(n-2)-1)+r},easeInCubic:function(n,r,o,a){return o*(n/=a)*n*n+r},easeOutCubic:function(n,r,o,a){return o*((n=n/a-1)*n*n+1)+r},easeInOutCubic:function(n,r,o,a){return(n/=a/2)<1?o/2*n*n*n+r:o/2*((n-=2)*n*n+2)+r},easeInQuart:function(n,r,o,a){return o*(n/=a)*n*n*n+r},easeOutQuart:function(n,r,o,a){return-o*((n=n/a-1)*n*n*n-1)+r},easeInOutQuart:function(n,r,o,a){return(n/=a/2)<1?o/2*n*n*n*n+r:-o/2*((n-=2)*n*n*n-2)+r},easeInQuint:function(n,r,o,a){return o*(n/=a)*n*n*n*n+r},easeOutQuint:function(n,r,o,a){return o*((n=n/a-1)*n*n*n*n+1)+r},easeInOutQuint:function(n,r,o,a){return(n/=a/2)<1?o/2*n*n*n*n*n+r:o/2*((n-=2)*n*n*n*n+2)+r},easeInSine:function(n,r,o,a){return-o*Math.cos(n/a*(Math.PI/2))+o+r},easeOutSine:function(n,r,o,a){return o*Math.sin(n/a*(Math.PI/2))+r},easeInOutSine:function(n,r,o,a){return-o/2*(Math.cos(Math.PI*n/a)-1)+r},easeInExpo:function(n,r,o,a){return n===0?r:o*Math.pow(2,10*(n/a-1))+r},easeOutExpo:function(n,r,o,a){return n===a?r+o:o*(-Math.pow(2,-10*n/a)+1)+r},easeInOutExpo:function(n,r,o,a){return(n/=a/2)<1?o/2*Math.pow(2,10*(n-1))+r:o/2*(-Math.pow(2,-10*--n)+2)+r},easeInCirc:function(n,r,o,a){return-o*(Math.sqrt(1-(n/=a)*n)-1)+r},easeOutCirc:function(n,r,o,a){return o*Math.sqrt(1-(n=n/a-1)*n)+r},easeInOutCirc:function(n,r,o,a){return(n/=a/2)<1?-o/2*(Math.sqrt(1-n*n)-1)+r:o/2*(Math.sqrt(1-(n-=2)*n)+1)+r},easeInElastic:function(n,r,o,a){var h,l,c;return c=1.70158,l=0,h=o,n===0||(n/=a),l||(l=a*.3),h<Math.abs(o)?(h=o,c=l/4):c=l/(2*Math.PI)*Math.asin(o/h),-(h*Math.pow(2,10*(n-=1))*Math.sin((n*a-c)*(2*Math.PI)/l))+r},easeOutElastic:function(n,r,o,a){var h,l,c;return c=1.70158,l=0,h=o,n===0||(n/=a),l||(l=a*.3),h<Math.abs(o)?(h=o,c=l/4):c=l/(2*Math.PI)*Math.asin(o/h),h*Math.pow(2,-10*n)*Math.sin((n*a-c)*(2*Math.PI)/l)+o+r},easeInOutElastic:function(n,r,o,a){var h,l,c;return c=1.70158,l=0,h=o,n===0||(n/=a/2),l||(l=a*(.3*1.5)),h<Math.abs(o)?(h=o,c=l/4):c=l/(2*Math.PI)*Math.asin(o/h),n<1?-.5*(h*Math.pow(2,10*(n-=1))*Math.sin((n*a-c)*(2*Math.PI)/l))+r:h*Math.pow(2,-10*(n-=1))*Math.sin((n*a-c)*(2*Math.PI)/l)*.5+o+r},easeInBack:function(n,r,o,a,h){return h===void 0&&(h=1.70158),o*(n/=a)*n*((h+1)*n-h)+r},easeOutBack:function(n,r,o,a,h){return h===void 0&&(h=1.70158),o*((n=n/a-1)*n*((h+1)*n+h)+1)+r},easeInOutBack:function(n,r,o,a,h){return h===void 0&&(h=1.70158),(n/=a/2)<1?o/2*(n*n*(((h*=1.525)+1)*n-h))+r:o/2*((n-=2)*n*(((h*=1.525)+1)*n+h)+2)+r},easeInBounce:function(n,r,o,a){var h;return h=e.easeOutBounce(a-n,0,o,a),o-h+r},easeOutBounce:function(n,r,o,a){return(n/=a)<1/2.75?o*(7.5625*n*n)+r:n<2/2.75?o*(7.5625*(n-=1.5/2.75)*n+.75)+r:n<2.5/2.75?o*(7.5625*(n-=2.25/2.75)*n+.9375)+r:o*(7.5625*(n-=2.625/2.75)*n+.984375)+r},easeInOutBounce:function(n,r,o,a){var h;return n<a/2?(h=e.easeInBounce(n*2,0,o,a),h*.5+r):(h=e.easeOutBounce(n*2-a,0,o,a),h*.5+o*.5+r)}},s(e)}).call(Ou)})(Vo);var Yu=Vo.exports;const gr=Uu(Yu);function Ls(i,t){if(i){if(typeof i=="function")return i;if(typeof i=="string")return gr[i]}else return gr[t]}class Nu{constructor(t){this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.eventMode="static",this.viewport.forceHitArea||(this.viewport.hitArea=new Q(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.options.allowPreserveDragOutside?this.viewport.on("globalpointermove",this.move,this):this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.options.allowPreserveDragOutside||this.viewport.on("pointerleave",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.events.domElement.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){var t;(t=this.viewport.options.events.domElement)==null||t.removeEventListener("wheel",this.wheelFunction)}down(t){if(!(this.viewport.pause||!this.viewport.visible)){if(t.pointerType==="mouse"?this.isMouseDown=!0:this.get(t.pointerId)||this.touches.push({id:t.pointerId,last:null}),this.count()===1){this.last=t.global.clone();const e=this.viewport.plugins.get("decelerate",!0),s=this.viewport.plugins.get("bounce",!0);(!e||!e.isActive())&&(!s||!s.isActive())?this.clickedAvailable=!0:this.clickedAvailable=!1}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.visible)return;const e=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const s=t.global.x-this.last.x,n=t.global.y-this.last.y;(this.checkThreshold(s)||this.checkThreshold(n))&&(this.clickedAvailable=!1)}e&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.visible)return;t.pointerType==="mouse"&&(this.isMouseDown=!1),t.pointerType!=="mouse"&&this.remove(t.pointerId);const e=this.viewport.plugins.up(t);this.clickedAvailable&&this.count()===0&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this.viewport}),this.clickedAvailable=!1),e&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const e=new X;return this.viewport.options.events.mapPositionToPoint(e,t.clientX,t.clientY),e}handleWheel(t){if(this.viewport.pause||!this.viewport.visible)return;const e=this.viewport.toLocal(this.getPointerPosition(t));this.viewport.left<=e.x&&e.x<=this.viewport.right&&this.viewport.top<=e.y&&e.y<=this.viewport.bottom&&this.viewport.plugins.wheel(t)&&!this.viewport.options.passiveWheel&&t.preventDefault()}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(const e of this.touches)if(e.id===t)return e;return null}remove(t){for(let e=0;e<this.touches.length;e++)if(this.touches[e].id===t){this.touches.splice(e,1);return}}count(){return(this.isMouseDown?1:0)+this.touches.length}}const Oe=["drag","pinch","wheel","follow","mouse-edges","decelerate","animate","bounce","snap-zoom","clamp-zoom","snap","clamp"];class Xu{constructor(t){this.viewport=t,this.list=[],this.plugins={}}add(t,e,s=Oe.length){const n=this.plugins[t];n&&n.destroy(),this.plugins[t]=e;const r=Oe.indexOf(t);r!==-1&&Oe.splice(r,1),Oe.splice(s,0,t),this.sort()}get(t,e){var s;return e&&(s=this.plugins[t])!=null&&s.paused?null:this.plugins[t]}update(t){for(const e of this.list)e.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.list.forEach(t=>{t.destroy()}),this.plugins={},this.sort()}remove(t){var e;this.plugins[t]&&((e=this.plugins[t])==null||e.destroy(),delete this.plugins[t],this.viewport.emit("plugin-remove",t),this.sort())}pause(t){var e;(e=this.plugins[t])==null||e.pause()}resume(t){var e;(e=this.plugins[t])==null||e.resume()}sort(){this.list=[];for(const t of Oe)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let e=!1;for(const s of this.list)s.down(t)&&(e=!0);return e}move(t){let e=!1;for(const s of this.viewport.plugins.list)s.move(t)&&(e=!0);return e}up(t){let e=!1;for(const s of this.list)s.up(t)&&(e=!0);return e}wheel(t){let e=!1;for(const s of this.list)s.wheel(t)&&(e=!0);return e}}class Et{constructor(t){this.parent=t,this.paused=!1}destroy(){}down(t){return!1}move(t){return!1}up(t){return!1}wheel(t){return!1}update(t){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}const Vu={removeOnInterrupt:!1,ease:"linear",time:1e3};class $u extends Et{constructor(t,e={}){super(t),this.startWidth=null,this.startHeight=null,this.deltaWidth=null,this.deltaHeight=null,this.width=null,this.height=null,this.time=0,this.options=Object.assign({},Vu,e),this.options.ease=Ls(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){typeof this.options.position<"u"?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,typeof this.options.scale<"u"?this.width=this.parent.screenWidth/this.options.scale:typeof this.options.scaleX<"u"||typeof this.options.scaleY<"u"?(typeof this.options.scaleX<"u"&&(this.width=this.parent.screenWidth/this.options.scaleX),typeof this.options.scaleY<"u"&&(this.height=this.parent.screenHeight/this.options.scaleY)):(typeof this.options.width<"u"&&(this.width=this.options.width),typeof this.options.height<"u"&&(this.height=this.options.height)),this.width!==null&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),this.height!==null&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),this.width!==null&&this.parent.fitWidth(this.width,this.keepCenter,this.height===null),this.height!==null&&this.parent.fitHeight(this.height,this.keepCenter,this.width===null),!this.keepCenter&&this.options.position&&this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(t){if(this.paused)return;this.time+=t;const e=new X(this.parent.scale.x,this.parent.scale.y);if(this.time>=this.options.time){const s=this.parent.width,n=this.parent.height;this.complete(),(s!==this.parent.width||n!==this.parent.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}else{const s=this.options.ease(this.time,0,1,this.options.time);if(this.width!==null){const n=this.startWidth,r=this.deltaWidth;this.parent.fitWidth(n+r*s,this.keepCenter,this.height===null)}if(this.height!==null){const n=this.startHeight,r=this.deltaHeight;this.parent.fitHeight(n+r*s,this.keepCenter,this.width===null)}if(this.width===null?this.parent.scale.x=this.parent.scale.y:this.height===null&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const n=this.startX,r=this.startY,o=this.deltaX,a=this.deltaY,h=new X(this.parent.x,this.parent.y);this.parent.moveCenter(n+o*s,r+a*s),this.parent.emit("moved",{viewport:this.parent,original:h,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:e,type:"animate"})}}}const ju={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class qu extends Et{constructor(t,e={}){super(t),this.options=Object.assign({},ju,e),this.ease=Ls(this.options.ease,"easeInOutSine"),this.options.sides?this.options.sides==="all"?this.top=this.bottom=this.left=this.right=!0:this.options.sides==="horizontal"?(this.right=this.left=!0,this.top=this.bottom=!1):this.options.sides==="vertical"?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=this.options.sides.indexOf("top")!==-1,this.bottom=this.options.sides.indexOf("bottom")!==-1,this.left=this.options.sides.indexOf("left")!==-1,this.right=this.options.sides.indexOf("right")!==-1):this.left=this.top=this.right=this.bottom=!1;const s=this.options.underflow.toLowerCase();s==="center"?(this.underflowX=0,this.underflowY=0):(this.underflowX=s.indexOf("left")!==-1?-1:s.indexOf("right")!==-1?1:0,this.underflowY=s.indexOf("top")!==-1?-1:s.indexOf("bottom")!==-1?1:0),this.reset()}isActive(){return this.toX!==null||this.toY!==null}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const e=this.toX;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),e.time>=this.options.time?(this.parent.x=e.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(e.time,e.start,e.delta,this.options.time)}if(this.toY){const e=this.toY;e.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),e.time>=this.options.time?(this.parent.y=e.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(e.time,e.start,e.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}oob(){const t=this.options.bounceBox;if(t){const e=typeof t.x>"u"?0:t.x,s=typeof t.y>"u"?0:t.y,n=typeof t.width>"u"?this.parent.worldWidth:t.width,r=typeof t.height>"u"?this.parent.worldHeight:t.height;return{left:this.parent.left<e,right:this.parent.right>n,top:this.parent.top<s,bottom:this.parent.bottom>r,topLeft:new X(e*this.parent.scale.x,s*this.parent.scale.y),bottomRight:new X(n*this.parent.scale.x-this.parent.screenWidth,r*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new X(0,0),bottomRight:new X(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){var t,e;if(this.paused)return;let s,n=this.parent.plugins.get("decelerate",!0);n&&(n.x||n.y)&&(n.x&&n.percentChangeX===((t=n.options)==null?void 0:t.friction)||n.y&&n.percentChangeY===((e=n.options)==null?void 0:e.friction))&&(s=this.oob(),(s.left&&this.left||s.right&&this.right)&&(n.percentChangeX=this.options.friction),(s.top&&this.top||s.bottom&&this.bottom)&&(n.percentChangeY=this.options.friction));const r=this.parent.plugins.get("drag",!0)||{},o=this.parent.plugins.get("pinch",!0)||{};if(n=n||{},!(r!=null&&r.active)&&!(o!=null&&o.active)&&(!this.toX||!this.toY)&&(!n.x||!n.y)){s=s||this.oob();const a=s.topLeft,h=s.bottomRight;if(!this.toX&&!n.x){let l=null;s.left&&this.left?l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-a.x:s.right&&this.right&&(l=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-h.x),l!==null&&this.parent.x!==l&&(this.toX={time:0,start:this.parent.x,delta:l-this.parent.x,end:l},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!n.y){let l=null;s.top&&this.top?l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-a.y:s.bottom&&this.bottom&&(l=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-h.y),l!==null&&this.parent.y!==l&&(this.toY={time:0,start:this.parent.y,delta:l-this.parent.y,end:l},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const Ku={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class Zu extends Et{constructor(t,e={}){super(t),this.options=Object.assign({},Ku,e),this.options.direction&&(this.options.left=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.right=this.options.direction==="x"||this.options.direction==="all"?!0:null,this.options.top=this.options.direction==="y"||this.options.direction==="all"?!0:null,this.options.bottom=this.options.direction==="y"||this.options.direction==="all"?!0:null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="none"?this.noUnderflow=!0:t==="center"?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=t.indexOf("left")!==-1?-1:t.indexOf("right")!==-1?1:0,this.underflowY=t.indexOf("top")!==-1?-1:t.indexOf("bottom")!==-1?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused||this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const t=new X(this.parent.x,this.parent.y),e=this.parent.plugins.decelerate||{};if(this.options.left!==null||this.options.right!==null){let s=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x!==0&&(this.parent.x=0,s=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,s=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,s=!0)}else this.options.left!==null&&this.parent.left<(this.options.left===!0?0:this.options.left)&&(this.parent.x=-(this.options.left===!0?0:this.options.left)*this.parent.scale.x,e.x=0,s=!0),this.options.right!==null&&this.parent.right>(this.options.right===!0?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(this.options.right===!0?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,e.x=0,s=!0);s&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(this.options.top!==null||this.options.bottom!==null){let s=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y!==0&&(this.parent.y=0,s=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,s=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,s=!0)}else this.options.top!==null&&this.parent.top<(this.options.top===!0?0:this.options.top)&&(this.parent.y=-(this.options.top===!0?0:this.options.top)*this.parent.scale.y,e.y=0,s=!0),this.options.bottom!==null&&this.parent.bottom>(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(this.options.bottom===!0?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,e.y=0,s=!0);s&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const Qu={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class Ju extends Et{constructor(t,e={}){super(t),this.options=Object.assign({},Qu,e),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused){if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight;if(this.options.minWidth!==null&&t<this.options.minWidth){const s=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/s,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxWidth!==null&&t>this.options.maxWidth){const s=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/s,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.minHeight!==null&&e<this.options.minHeight){const s=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/s,t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(this.options.maxHeight!==null&&e>this.options.maxHeight){const s=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/s,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},e={x:null,y:null};if(typeof this.options.minScale=="number")t.x=this.options.minScale,t.y=this.options.minScale;else if(this.options.minScale!==null){const r=this.options.minScale;t.x=typeof r.x>"u"?null:r.x,t.y=typeof r.y>"u"?null:r.y}if(typeof this.options.maxScale=="number")e.x=this.options.maxScale,e.y=this.options.maxScale;else if(this.options.maxScale!==null){const r=this.options.maxScale;e.x=typeof r.x>"u"?null:r.x,e.y=typeof r.y>"u"?null:r.y}let s=this.parent.scale.x,n=this.parent.scale.y;t.x!==null&&s<t.x&&(s=t.x),e.x!==null&&s>e.x&&(s=e.x),t.y!==null&&n<t.y&&(n=t.y),e.y!==null&&n>e.y&&(n=e.y),(s!==this.parent.scale.x||n!==this.parent.scale.y)&&(this.parent.scale.set(s,n),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}}reset(){this.clamp()}}const td={friction:.98,bounce:.8,minSpeed:.01},ee=16;class ed extends Et{constructor(t,e={}){super(t),this.options=Object.assign({},td,e),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",s=>this.handleMoved(s))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!!(this.x||this.y)}move(){if(this.paused)return!1;const t=this.parent.input.count();return(t===1||t>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}handleMoved(t){if(this.saved.length){const e=this.saved[this.saved.length-1];t.type==="clamp-x"&&t.original?e.x===t.original.x&&(e.x=this.parent.x):t.type==="clamp-y"&&t.original&&e.y===t.original.y&&(e.y=this.parent.y)}}up(){if(this.parent.input.count()===0&&this.saved.length){const t=performance.now();for(const e of this.saved)if(e.time>=t-100){const s=t-e.time;this.x=(this.parent.x-e.x)/s,this.y=(this.parent.y-e.y)/s,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){t=t||{},typeof t.x<"u"&&(this.x=t.x,this.percentChangeX=this.options.friction),typeof t.y<"u"&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;const e=this.x||this.y,s=this.timeSinceRelease,n=this.timeSinceRelease+t;if(this.x){const r=this.percentChangeX,o=Math.log(r);this.parent.x+=this.x*ee/o*(Math.pow(r,n/ee)-Math.pow(r,s/ee)),this.x*=Math.pow(this.percentChangeX,t/ee)}if(this.y){const r=this.percentChangeY,o=Math.log(r);this.parent.y+=this.y*ee/o*(Math.pow(r,n/ee)-Math.pow(r,s/ee)),this.y*=Math.pow(this.percentChangeY,t/ee)}this.timeSinceRelease+=t,this.x&&this.y?Math.abs(this.x)<this.options.minSpeed&&Math.abs(this.y)<this.options.minSpeed&&(this.x=0,this.y=0):(Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0)),e&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const sd={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20,wheelSwapAxes:!1};class id extends Et{constructor(t,e={}){super(t),this.windowEventHandlers=[],this.options=Object.assign({},sd,e),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="x",this.yDirection=!this.options.direction||this.options.direction==="all"||this.options.direction==="y",this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){const e=n=>{t.includes(n.code)&&(this.keyIsPressed=!0)},s=n=>{t.includes(n.code)&&(this.keyIsPressed=!1)};this.addWindowEventHandler("keyup",s),this.addWindowEventHandler("keydown",e)}addWindowEventHandler(t,e){typeof window>"u"||(window.addEventListener(t,e),this.windowEventHandlers.push({event:t,handler:e}))}destroy(){typeof window>"u"||this.windowEventHandlers.forEach(({event:t,handler:e})=>{window.removeEventListener(t,e)})}mouseButtons(t){!t||t==="all"?this.mouse=[!0,!0,!0]:this.mouse=[t.indexOf("left")!==-1,t.indexOf("middle")!==-1,t.indexOf("right")!==-1]}parseUnderflow(){const t=this.options.underflow.toLowerCase();t==="center"?(this.underflowX=0,this.underflowY=0):(t.includes("left")?this.underflowX=-1:t.includes("right")?this.underflowX=1:this.underflowX=0,t.includes("top")?this.underflowY=-1:t.includes("bottom")?this.underflowY=1:this.underflowY=0)}checkButtons(t){const e=t.pointerType==="mouse",s=this.parent.input.count();return!!((s===1||s>1&&!this.parent.plugins.get("pinch",!0))&&(!e||this.mouse[t.button]))}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&t.data.pointerType==="touch"}down(t){return this.paused||!this.options.pressDrag?!1:this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.global.x,y:t.global.y},(this.parent.parent||this.parent).toLocal(this.last,void 0,this.last),this.current=t.pointerId,!0):(this.last=null,!1)}get active(){return this.moved}move(t){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===t.data.pointerId){const e=t.global.x,s=t.global.y,n=this.parent.input.count();if(n===1||n>1&&!this.parent.plugins.get("pinch",!0)){const r={x:e,y:s};(this.parent.parent||this.parent).toLocal(r,void 0,r);const o=r.x-this.last.x,a=r.y-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(o)||this.yDirection&&this.parent.input.checkThreshold(a))return this.xDirection&&(this.parent.x+=(r.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(r.y-this.last.y)*this.options.factor),this.last=r,this.moved||this.parent.emit("drag-start",{event:t,screen:new X(this.last.x,this.last.y),world:this.parent.toWorld(new X(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}else this.moved=!1}return!1}up(t){if(this.paused)return!1;const e=this.parent.input.touches;if(e.length===1){const s=e[0];return s.last&&(this.last={x:s.last.x,y:s.last.y},this.current=s.id),this.moved=!1,!0}else if(this.last&&this.moved){const s=new X(this.last.x,this.last.y);return(this.parent.parent||this.parent).toGlobal(s,s,!0),this.parent.emit("drag-end",{event:t,screen:s,world:this.parent.toWorld(s),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){const e=this.parent.plugins.get("wheel",!0);if(!e||!e.options.wheelZoom&&!t.ctrlKey){const s=t.deltaMode?this.options.lineHeight:1,n=[t.deltaX,t.deltaY],[r,o]=this.options.wheelSwapAxes?n.reverse():n;return this.xDirection&&(this.parent.x+=r*s*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=o*s*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||t.preventDefault(),this.parent.options.stopPropagation&&t.stopPropagation(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate",!0)||{};if(this.options.clampWheel!=="y")if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,t.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if(this.options.clampWheel!=="x")if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,t.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const nd={speed:0,acceleration:null,radius:null};class rd extends Et{constructor(t,e,s={}){super(t),this.target=e,this.options=Object.assign({},nd,s),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const e=this.parent.center;let s=this.target.x,n=this.target.y;if(this.options.radius)if(Math.sqrt(Math.pow(this.target.y-e.y,2)+Math.pow(this.target.x-e.x,2))>this.options.radius){const a=Math.atan2(this.target.y-e.y,this.target.x-e.x);s=this.target.x-Math.cos(a)*this.options.radius,n=this.target.y-Math.sin(a)*this.options.radius}else return;const r=s-e.x,o=n-e.y;if(r||o)if(this.options.speed)if(this.options.acceleration){const a=Math.atan2(n-e.y,s-e.x),h=Math.sqrt(Math.pow(r,2)+Math.pow(o,2));if(h){const l=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);h>l?this.velocity={x:Math.min(this.velocity.x+(this.options.acceleration*t,this.options.speed)),y:Math.min(this.velocity.y+(this.options.acceleration*t,this.options.speed))}:this.velocity={x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const c=Math.cos(a)*this.velocity.x,u=Math.sin(a)*this.velocity.y,f=Math.abs(c)>Math.abs(r)?s:e.x+c,d=Math.abs(u)>Math.abs(o)?n:e.y+u;this.parent.moveCenter(f,d),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const a=Math.atan2(n-e.y,s-e.x),h=Math.cos(a)*this.options.speed,l=Math.sin(a)*this.options.speed,c=Math.abs(h)>Math.abs(r)?s:e.x+h,u=Math.abs(l)>Math.abs(o)?n:e.y+l;this.parent.moveCenter(c,u),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(s,n),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const od={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class ad extends Et{constructor(t,e={}){super(t),this.options=Object.assign({},od,e),this.reverse=this.options.reverse?1:-1,this.radiusSquared=typeof this.options.radius=="number"?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;t!==null?(this.left=t,this.top=t,this.right=this.parent.screenWidth-t,this.bottom=this.parent.screenHeight-t):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=this.options.right===null?null:this.parent.screenWidth-this.options.right,this.bottom=this.options.bottom===null?null:this.parent.screenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(t){if(this.paused||t.pointerType!=="mouse"&&t.pointerId!==1||!this.options.allowButtons&&t.buttons!==0)return!1;const e=t.global.x,s=t.global.y;if(this.radiusSquared){const n=this.parent.toScreen(this.parent.center);if(Math.pow(n.x-e,2)+Math.pow(n.y-s,2)>=this.radiusSquared){const r=Math.atan2(n.y-s,n.x-e);this.options.linear?(this.horizontal=Math.round(Math.cos(r))*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.round(Math.sin(r))*this.options.speed*this.reverse*(60/1e3)):(this.horizontal=Math.cos(r)*this.options.speed*this.reverse*(60/1e3),this.vertical=Math.sin(r)*this.options.speed*this.reverse*(60/1e3))}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else this.left!==null&&e<this.left?this.horizontal=Number(this.reverse)*this.options.speed*(60/1e3):this.right!==null&&e>this.right?this.horizontal=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateHorizontal(),this.horizontal=0),this.top!==null&&s<this.top?this.vertical=Number(this.reverse)*this.options.speed*(60/1e3):this.bottom!==null&&s>this.bottom?this.vertical=-1*this.reverse*this.options.speed*(60/1e3):(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate",!0);this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate",!0);this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const hd={noDrag:!1,percent:1,center:null,factor:1,axis:"all"},ld=new X;class cd extends Et{constructor(t,e={}){super(t),this.active=!1,this.pinching=!1,this.moved=!1,this.options=Object.assign({},hd,e)}down(){return this.parent.input.count()>=2?(this.active=!0,!0):!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(t){if(this.paused||!this.active)return!1;const{x:e,y:s}=(this.parent.parent||this.parent).toLocal(t.global,void 0,ld),n=this.parent.input.touches;if(n.length>=2){const r=n[0],o=n[1],a=r.last&&o.last?Math.sqrt(Math.pow(o.last.x-r.last.x,2)+Math.pow(o.last.y-r.last.y,2)):null;if(r.id===t.pointerId?r.last={x:e,y:s,data:t}:o.id===t.pointerId&&(o.last={x:e,y:s,data:t}),a){let h;const l=new X(r.last.x+(o.last.x-r.last.x)/2,r.last.y+(o.last.y-r.last.y)/2);this.options.center||(h=this.parent.toLocal(l,this.parent.parent||this.parent));let c=Math.sqrt(Math.pow(o.last.x-r.last.x,2)+Math.pow(o.last.y-r.last.y,2));c=c===0?c=1e-10:c;const u=(1-a/c)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=u),this.isAxisY()&&(this.parent.scale.y+=u),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:l});const f=this.parent.plugins.get("clamp-zoom",!0);if(f&&f.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const d=(this.parent.parent||this.parent).toLocal(h,this.parent);this.parent.x+=(l.x-d.x)*this.options.factor,this.parent.y+=(l.y-d.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(l.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(l.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=l,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return this.pinching&&this.parent.input.touches.length<=1?(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0):!1}}const ud={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class dd extends Et{constructor(t,e,s,n={}){super(t),this.options=Object.assign({},ud,n),this.ease=Ls(n.ease,"easeInOutSine"),this.x=e,this.y=s,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const t=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-t.x,this.deltaY=this.y-t.y,this.startX=t.x,this.startY=t.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(this.parent.input.count()===0){const t=this.parent.plugins.get("decelerate",!0);t&&(t.x||t.y)&&(t.percentChangeX=t.percentChangeY=this.options.friction)}return!1}update(t){if(!this.paused&&!(this.options.interrupt&&this.parent.input.count()!==0))if(this.snapping){const e=this.snapping;e.time+=t;let s,n,r;const o=this.startX,a=this.startY,h=this.deltaX,l=this.deltaY;if(e.time>this.options.time)s=!0,n=o+h,r=a+l;else{const c=this.ease(e.time,0,1,this.options.time);n=o+h*c,r=a+l*c}this.options.topLeft?this.parent.moveCorner(n,r):this.parent.moveCenter(n,r),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),s&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const e=this.options.topLeft?this.parent.corner:this.parent.center;(e.x!==this.x||e.y!==this.y)&&this.snapStart()}}}const fd={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class pd extends Et{constructor(t,e={}){super(t),this.options=Object.assign({},fd,e),this.ease=Ls(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=t.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,this.options.time===0?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):e.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,e=this.parent.worldScreenHeight,s=this.parent.screenWidth/this.xScale,n=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:e,deltaX:s-t,deltaY:n-e},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(t){if(this.paused||this.options.interrupt&&this.parent.input.count()!==0)return;let e;if(!this.options.center&&!this.options.noMove&&(e=this.parent.center),!this.snapping)(this.parent.scale.x!==this.xScale||this.parent.scale.y!==this.yScale)&&this.createSnapping();else if(this.snapping){const s=this.snapping;if(s.time+=t,s.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const r=this.snapping,o=this.ease(r.time,r.startX,r.deltaX,this.options.time),a=this.ease(r.time,r.startY,r.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/o,this.parent.scale.y=this.parent.screenHeight/a}const n=this.parent.plugins.get("clamp-zoom",!0);n&&n.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(e))}}resume(){this.snapping=null,super.resume()}}const gd={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all",keyToPress:null,trackpadPinch:!1,wheelZoom:!0};class md extends Et{constructor(t,e={}){super(t),this.options=Object.assign({},gd,e),this.keyIsPressed=!1,this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){typeof window>"u"||(window.addEventListener("keydown",e=>{t.includes(e.code)&&(this.keyIsPressed=!0)}),window.addEventListener("keyup",e=>{t.includes(e.code)&&(this.keyIsPressed=!1)}))}checkKeyPress(){return!this.options.keyToPress||this.keyIsPressed}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const t=this.smoothingCenter,e=this.smoothing;let s;this.options.center||(s=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=e.x),this.isAxisY()&&(this.parent.scale.y+=e.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const n=this.parent.plugins.get("clamp-zoom",!0);if(n&&n.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const r=this.parent.parent||this.parent;r.toLocal(s,this.parent,s);const o=r.toLocal(t);this.parent.x+=o.x-s.x,this.parent.y+=o.y-s.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,typeof this.options.smooth=="number"&&this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}pinch(t){if(this.paused)return;const e=this.parent.input.getPointerPosition(t),s=-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/200,n=Math.pow(2,(1+this.options.percent)*s);let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=n),this.isAxisY()&&(this.parent.scale.y*=n),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.parent||this.parent;a.toLocal(r,this.parent,r);const h=a.toLocal(e);this.parent.x+=h.x-r.x,this.parent.y+=h.y-r.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}wheel(t){if(this.paused||!this.checkKeyPress())return!1;if(t.ctrlKey&&this.options.trackpadPinch)this.pinch(t);else if(this.options.wheelZoom){const e=this.parent.input.getPointerPosition(t),s=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,n=Math.pow(2,(1+this.options.percent)*s);if(this.options.smooth){const r={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+r.x)*n-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+r.y)*n-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=e}else{let r;this.options.center||(r=this.parent.toLocal(e)),this.isAxisX()&&(this.parent.scale.x*=n),this.isAxisY()&&(this.parent.scale.y*=n),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const o=this.parent.plugins.get("clamp-zoom",!0);if(o&&o.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const a=this.parent.parent||this.parent;a.toLocal(r,this.parent,r);const h=a.toLocal(e);this.parent.x+=h.x-r.x,this.parent.y+=h.y-r.y}}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel-start",{event:t,viewport:this.parent})}return!this.parent.options.passiveWheel}}const xd={screenWidth:typeof window>"u"?0:window.innerWidth,screenHeight:typeof window>"u"?0:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,disableOnContextMenu:!1,ticker:ge.shared,allowPreserveDragOutside:!1};class yd extends kt{constructor(t){super(),this._disableOnContextMenu=e=>e.preventDefault(),this.options={...xd,...t},this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.disableOnContextMenu&&this.options.events.domElement.addEventListener("contextmenu",this._disableOnContextMenu),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new Nu(this),this.plugins=new Xu(this)}destroy(t){var e;!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.options.disableOnContextMenu&&((e=this.options.events.domElement)==null||e.removeEventListener("contextmenu",this._disableOnContextMenu)),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new Q(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=typeof window>"u"?0:window.innerWidth,e=typeof window>"u"?0:window.innerHeight,s,n){this.screenWidth=t,this.screenHeight=e,typeof s<"u"&&(this._worldWidth=s),typeof n<"u"&&(this._worldHeight=n),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new Q(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,e){return arguments.length===2?this.toLocal(new X(t,e)):this.toLocal(t)}toScreen(t,e){return arguments.length===2?this.toGlobal(new X(t,e)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new X(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(...t){let e,s;typeof t[0]=="number"?(e=t[0],s=t[1]):(e=t[0].x,s=t[0].y);const n=(this.worldScreenWidth/2-e)*this.scale.x,r=(this.worldScreenHeight/2-s)*this.scale.y;return(this.x!==n||this.y!==r)&&(this.position.set(n,r),this.plugins.reset(),this.dirty=!0),this}get corner(){return new X(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let e,s;return t.length===1?(e=-t[0].x*this.scale.x,s=-t[0].y*this.scale.y):(e=-t[0]*this.scale.x,s=-t[1]*this.scale.y),(e!==this.x||s!==this.y)&&(this.position.set(e,s),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(t){return this.screenWidth/t}findFitHeight(t){return this.screenHeight/t}findFit(t,e){const s=this.screenWidth/t,n=this.screenHeight/e;return Math.min(s,n)}findCover(t,e){const s=this.screenWidth/t,n=this.screenHeight/e;return Math.max(s,n)}fitWidth(t=this.worldWidth,e,s=!0,n){let r;e&&(r=this.center),this.scale.x=this.screenWidth/t,s&&(this.scale.y=this.scale.x);const o=this.plugins.get("clamp-zoom",!0);return!n&&o&&o.clamp(),e&&r&&this.moveCenter(r),this}fitHeight(t=this.worldHeight,e,s=!0,n){let r;e&&(r=this.center),this.scale.y=this.screenHeight/t,s&&(this.scale.x=this.scale.y);const o=this.plugins.get("clamp-zoom",!0);return!n&&o&&o.clamp(),e&&r&&this.moveCenter(r),this}fitWorld(t){let e;t&&(e=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const s=this.plugins.get("clamp-zoom",!0);return s&&s.clamp(),t&&e&&this.moveCenter(e),this}fit(t,e=this.worldWidth,s=this.worldHeight){let n;t&&(n=this.center),this.scale.x=this.screenWidth/e,this.scale.y=this.screenHeight/s,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const r=this.plugins.get("clamp-zoom",!0);return r&&r.clamp(),t&&n&&this.moveCenter(n),this}setZoom(t,e){let s;e&&(s=this.center),this.scale.set(t);const n=this.plugins.get("clamp-zoom",!0);return n&&n.clamp(),e&&s&&this.moveCenter(s),this}zoomPercent(t,e){return this.setZoom(this.scale.x+this.scale.x*t,e)}zoom(t,e){return this.fitWidth(t+this.worldScreenWidth,e),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new pd(this,t)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new X(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new Q(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new id(this,t)),this}clamp(t){return this.plugins.add("clamp",new Zu(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new ed(this,t)),this}bounce(t){return this.plugins.add("bounce",new qu(this,t)),this}pinch(t){return this.plugins.add("pinch",new cd(this,t)),this}snap(t,e,s){return this.plugins.add("snap",new dd(this,t,e,s)),this}follow(t,e){return this.plugins.add("follow",new rd(this,t,e)),this}wheel(t){return this.plugins.add("wheel",new md(this,t)),this}animate(t){return this.plugins.add("animate",new $u(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new Ju(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new ad(this,t)),this}get pause(){return!!this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,e,s,n,r){r&&(s>this.worldScreenWidth||n>this.worldScreenHeight)&&(this.fit(!0,s,n),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let o=!1;t<this.left?(this.left=t,o=!0):t+s>this.right&&(this.right=t+s,o=!0),e<this.top?(this.top=e,o=!0):e+n>this.bottom&&(this.bottom=e+n,o=!0),o&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}function mr(i,t,e){return Math.min(e,Math.max(t,i))}function di(i,t,e){return Math.sin((i/e+t)*Math.PI*2)}function _d(i){let t=2166136261;for(let e=0;e<i.length;e+=1)t^=i.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function bd(i){const t=di(i.elapsedMs,i.seed,i.selected?3600:5200),e=di(i.elapsedMs,i.seed+.37,6e3),s=i.selected?.6:1;return{scale:mr(1+t*(i.selected?.02:.01),.97,1.03),offsetX:e*s,offsetY:di(i.elapsedMs,i.seed+.71,7e3)*s,haloAlpha:mr((i.selected?.35:.08)+t*(i.selected?.06:.02),.05,.45)}}function wd(i){for(const t of i.removeChildren())t.destroy({children:!0})}const vd=["aria-label"],Sd=sa({__name:"RelationshipGalaxyCanvas",props:{graph:{},selectedKey:{default:null},privacyMode:{type:Boolean,default:!1},safeInsetRight:{default:0},label:{},ownerLabel:{}},emits:["select-node"],setup(i,{expose:t,emit:e}){const s=i,n=e,r=en(null);let o=null,a=null,h=null,l=null,c=null,u=!1,f=0,d=null;const p=new Map,x=[],g=en(null),m=new Map,_=[];let y=0,b=null,w=null;function v(P,T){if(!P)return T;const A=P.startsWith("#")?P.slice(1):P,U=Number.parseInt(A,16);return Number.isFinite(U)?U:T}function S(P){if(P.kind==="owner")return s.ownerLabel;const T=P.displayName||P.platformId||P.key;return s.privacyMode?ta(T):T}function I(P){return P.pool==="friend"?v(P.color,3718648):v(P.color,16096779)}function R(){const P=r.value?.getBoundingClientRect();return{width:Math.max(1,Math.floor(P?.width??1)),height:Math.max(1,Math.floor(P?.height??1))}}function M(P){if(P.length===0)return{minX:-500,minY:-500,maxX:500,maxY:500,width:1e3,height:1e3};let T=Number.POSITIVE_INFINITY,A=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,L=Number.NEGATIVE_INFINITY;for(const j of P)T=Math.min(T,j.x),A=Math.min(A,j.y),U=Math.max(U,j.x),L=Math.max(L,j.y);return{minX:T,minY:A,maxX:U,maxY:L,width:Math.max(800,U-T),height:Math.max(800,L-A)}}function C(){if(!h||!l)return;const{width:P,height:T}=R();h.clear(),l.clear(),h.rect(0,0,P,T).fill({color:263691,alpha:1});const A=[661041,1313320,400424];for(let L=0;L<8;L++){const j=L/8,ut=P*(.2+j*.6)+Math.sin(j*Math.PI)*P*.1,dt=T*(.3+(1-j)*.4)+Math.cos(j*Math.PI)*T*.08,Lt=Math.max(P,T)*(.2+L%3*.04),zt=A[L%A.length],lt=4;for(let St=0;St<lt;St++){const Xt=Lt*(1-St/lt),Mt=.012*(St+1)/lt*.5;h.circle(ut,dt,Xt).fill({color:zt,alpha:Mt})}}const U=Math.min(80,Math.max(30,Math.floor(P*T/18e3)));for(let L=0;L<U;L++){const j=(L*253.117+83)%P,ut=(L*123.643+47)%T,dt=L%8===0?1:.65,Lt=L%5===0?.35:L%2===0?.18:.1;l.circle(j,ut,dt).fill({color:14412542,alpha:Lt})}}function W(P,T,A,U){return A.active?!!U?.has(P.key):P.labelVisibility===2?!0:P.labelVisibility===1&&T<=500}function D(P,T,A){const U=new Hu({text:S(P),style:{fontFamily:"Inter, ui-sans-serif, system-ui, sans-serif",fontSize:A.selected?13:A.neighbor?11.5:11,fontWeight:A.selected?"700":"600",fill:A.selected?16777215:A.neighbor?16244660:14148337,align:"center",dropShadow:{color:0,alpha:.8,blur:4,distance:1}}});return U.anchor.set(.5,0),U.position.set(0,T+5),U.resolution=2,U}function G(P){return 1-Math.pow(1-P,3)}function V(P,T,A,U){if(!a)return;const L=new Ut;a.addChild(L),_.push({graphic:L,x:P,y:T,radius:4,maxRadius:Math.max(28,A*3.5),color:U,alpha:.7})}function k(){if(!w||!a)return;w.clear();const P=Qi(s.graph,s.selectedKey),T=P.nodes,A=new Map(T.map(lt=>[lt.key,lt])),U=g.value&&A.has(g.value)?g.value:null,L=s.selectedKey&&A.has(s.selectedKey)?s.selectedKey:null,j=U||L;if(!j){b&&(b.alpha=1);return}b&&(b.alpha=U?.12:L?.2:1);const ut=M(T),dt=260,Lt=-ut.minX+dt,zt=-ut.minY+dt;for(const lt of P.edges){if(lt.sourceKey!==j&&lt.targetKey!==j)continue;const St=A.get(lt.sourceKey),Xt=A.get(lt.targetKey);if(!St||!Xt)continue;const Mt=St.x+Lt,Vt=St.y+zt,rs=Xt.x+Lt,os=Xt.y+zt,ne=I(St);w.moveTo(Mt,Vt).lineTo(rs,os).stroke({color:ne,width:3,alpha:.16}),w.moveTo(Mt,Vt).lineTo(rs,os).stroke({color:16777215,width:1.3,alpha:.65})}}function E(P=!1){if(!a)return;wd(a),_.length=0,p.clear(),x.length=0,m.clear(),g.value=null,y=0;const T=Qi(s.graph,s.selectedKey),A=T.nodes,U=new Map(A.map(z=>[z.key,z])),L=M(A),j=260,ut=-L.minX+j,dt=-L.minY+j,Lt=L.width+j*2,zt=L.height+j*2,lt=R();a.resize(lt.width,lt.height,Lt,zt),b=new Ut,w=new Ut;const St=new kt,Xt=new kt;for(const z of T.edges){m.has(z.sourceKey)||m.set(z.sourceKey,new Set),m.has(z.targetKey)||m.set(z.targetKey,new Set),m.get(z.sourceKey).add(z.targetKey),m.get(z.targetKey).add(z.sourceKey);const gt=U.get(z.sourceKey),Tt=U.get(z.targetKey);if(!gt||!Tt)continue;const J=gt.x+ut,te=gt.y+dt,Wt=Tt.x+ut,Gt=Tt.y+dt,ye=z.visibility===2?.22:.07,hs=Math.min(1.4,Math.max(.4,Math.log10(z.weight+1)*.75)),Ee=I(gt);b.moveTo(J,te).lineTo(Wt,Gt).stroke({color:Ee,width:hs,alpha:ye})}const Mt=s.selectedKey,Vt=!!(Mt&&U.has(Mt)),rs=Mt&&Vt?m.get(Mt):null,os=Mt&&Vt?Jo(T,Mt):null,ne=new Map,as=new Map;for(const z of A){const gt=z.communityId||"default";ne.has(gt)||(ne.set(gt,{x:0,y:0}),as.set(gt,0));const Tt=ne.get(gt);Tt.x+=z.x+ut,Tt.y+=z.y+dt,as.set(gt,as.get(gt)+1)}for(const[z,gt]of ne.entries()){const Tt=as.get(z)||1;gt.x/=Tt,gt.y/=Tt}for(const z of A){const gt=z.x+ut,Tt=z.y+dt,J=Math.max(3.6,z.size),te=I(z),Wt=Vt&&z.key===Mt,Gt=!!(Vt&&rs?.has(z.key)),ye=Vt&&!Wt&&!Gt,hs={active:Vt,selected:Wt,neighbor:Gt},Ee=z.kind==="owner",Z=new Ut;p.set(z.key,{x:gt,y:Tt});const $o=z.communityId||"default",qi=ne.get($o)||{x:lt.width/2,y:lt.height/2},Be=qi.x,re=qi.y;if(Wt){Z.circle(0,0,J+11).fill({color:te,alpha:.12}),Z.circle(0,0,J+6).fill({color:16777215,alpha:.18}),Z.circle(0,0,J+5).stroke({color:16777215,width:1.8,alpha:.95});const yt=J+8,oe=3.5;Z.moveTo(0,-yt).lineTo(0,-yt-oe).stroke({color:16777215,width:1.2,alpha:.85}),Z.moveTo(0,yt).lineTo(0,yt+oe).stroke({color:16777215,width:1.2,alpha:.85}),Z.moveTo(-yt,0).lineTo(-yt-oe,0).stroke({color:16777215,width:1.2,alpha:.85}),Z.moveTo(yt,0).lineTo(yt+oe,0).stroke({color:16777215,width:1.2,alpha:.85})}else Ee?(Z.circle(0,0,J+8).fill({color:16096779,alpha:.14}),Z.circle(0,0,J+4).stroke({color:16096779,width:1.2,alpha:.45})):Gt?Z.circle(0,0,J+5).stroke({color:16244660,width:1.2,alpha:.42}):z.pool==="friend"&&Z.circle(0,0,J+4).fill({color:te,alpha:.08}),J>7&&Z.circle(0,0,J+6).fill({color:te,alpha:.06});const jo=Ee?16096779:te,qo=ye?.36:Wt?.98:Gt?.88:.82;Z.circle(0,0,J).fill({color:jo,alpha:qo}),Wt||Z.circle(0,0,J).stroke({color:Gt?16244660:16777215,width:.8,alpha:Gt?.35:.22}),Z.circle(-J*.28,-J*.32,Math.max(1.2,J*.34)).fill({color:16777215,alpha:ye?.1:Wt?.55:Gt?.34:.28}),Z.position.set(Be,re),Z.eventMode="static",Z.cursor="pointer",Z.on("pointertap",()=>{V(Z.x,Z.y,J,te),n("select-node",z)}),Z.on("pointerover",()=>{g.value=z.key}),Z.on("pointerout",()=>{g.value=null}),St.addChild(Z);const ls={graphic:Z,baseX:Be,baseY:re,labelBaseY:re+J+4,seed:_d(z.key),selected:Wt,startX:Be,startY:re,targetX:gt,targetY:Tt,key:z.key,radius:J,color:te,pool:z.pool,isOwner:Ee,selectedNeighbor:Gt,dimmedBySelection:ye,currentAlpha:ye?.16:Wt?.98:Gt?.88:.82,currentScale:1};if(x.push(ls),W(z,A.length,hs,os)){const yt=D(z,J,hs);if(Wt){const oe=new Ut,Ko=6,Ki=3,Zi=yt.width+Ko*2,Zo=yt.height+Ki*2;oe.roundRect(-Zi/2,-Ki,Zi,Zo,5).fill({color:790813,alpha:.8}).stroke({color:16777215,width:1,alpha:.18});const We=new kt;We.position.set(Be,re+J+4),yt.position.set(0,0),We.addChild(oe),We.addChild(yt),Xt.addChild(We),ls.label=We,ls.labelBaseY=re+J+4}else yt.position.set(Be,re+J+4),Xt.addChild(yt),ls.label=yt}}if(a.addChild(b),a.addChild(w),a.addChild(St),a.addChild(Xt),k(),P||!u){a.fitWorld(!0),a.scaled>1.18&&a.setZoom(1.18,!0);const z=ea(a.scaled,{viewportWidth:lt.width,safeInsetRight:s.safeInsetRight});z<a.scaled&&a.setZoom(z,!0),a.moveCenter(Ji(a.center,{viewportWidth:lt.width,safeInsetRight:s.safeInsetRight,scale:a.scaled}))}q()}function O(){if(!o)return;const P=performance.now()-f;if(l&&l.position.set(Math.sin(P/16e3)*8,Math.cos(P/19e3)*5),y<1){y=Math.min(1,y+.035);const T=G(y);for(const A of x)A.baseX=A.startX+(A.targetX-A.startX)*T,A.baseY=A.startY+(A.targetY-A.startY)*T,A.labelBaseY=A.baseY+A.radius+4}for(let T=_.length-1;T>=0;T--){const A=_[T];A.radius+=(A.maxRadius-A.radius)*.15,A.alpha-=.035,A.graphic.clear(),A.graphic.circle(A.x,A.y,A.radius).stroke({color:A.color,width:1.2,alpha:A.alpha}),A.alpha>.15&&A.graphic.circle(A.x,A.y,A.radius*1.25).stroke({color:A.color,width:.8,alpha:A.alpha*.4}),(A.alpha<=0||A.radius>=A.maxRadius-1)&&(a?.removeChild(A.graphic),A.graphic.destroy(),_.splice(T,1))}for(const T of x){const A=bd({elapsedMs:P,seed:T.seed,selected:T.selected});let U=T.dimmedBySelection?.14:T.selected?.98:T.selectedNeighbor?.9:.82,L=A.scale*(T.dimmedBySelection?.9:T.selectedNeighbor?1.03:1);if(g.value&&(T.key===g.value?(U=1,L=A.scale*1.18):m.get(g.value)?.has(T.key)?(U=.9,L=A.scale*1.05):(U=.12,L=A.scale*.82)),T.currentAlpha+=(U-T.currentAlpha)*.16,T.currentScale+=(L-T.currentScale)*.16,T.graphic.position.set(T.baseX+A.offsetX,T.baseY+A.offsetY),T.graphic.scale.set(T.currentScale),T.graphic.alpha=Math.min(1,T.currentAlpha+A.haloAlpha*(T.dimmedBySelection?.04:.12)),T.label){T.label.position.set(T.baseX+A.offsetX,T.labelBaseY+A.offsetY);const j=T.selected?1:T.selectedNeighbor?.9:.82;T.label.alpha=Math.min(1,j+A.haloAlpha*.35)}}}async function B(){const P=r.value;if(!P||o)return;const T=new yo;if(await T.init({resizeTo:P,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:Math.min(window.devicePixelRatio||1,2),preference:"webgl"}),!r.value||o){T.destroy({removeView:!0},!0);return}o=T,P.appendChild(T.canvas),T.canvas.className="h-full w-full",h=new Ut,l=new Ut,T.stage.addChild(h),T.stage.addChild(l);const A=R();a=new yd({screenWidth:A.width,screenHeight:A.height,worldWidth:1e3,worldHeight:1e3,events:T.renderer.events,ticker:T.ticker}),a.drag().pinch().wheel().decelerate().clampZoom({minScale:.04,maxScale:2.8}),a.on("moved",()=>{u=!0}),a.on("zoomed",()=>{u=!0}),T.stage.addChild(a),C(),E(!0),f=performance.now(),T.ticker.add(O),c=new ResizeObserver(()=>{C(),E(!u)}),c.observe(P)}function q(){if(!d)return;const P=d;if(!p.has(P)){d=null;return}et(P)}function et(P){const T=p.get(P);if(!T||!a)return d=P,!1;d=null,u=!0;const A=Math.min(Math.max(a.scaled,.45),1.55),U=R(),L=Ji(T,{viewportWidth:U.width,safeInsetRight:s.safeInsetRight,scale:A});return a.animate({position:L,scale:A,time:420,ease:"easeInOutSine"}),!0}function xt(){return a?{kind:"2d",center:{x:a.center.x,y:a.center.y},scale:a.scaled,hasUserMovedViewport:u}:null}function st(P){return!Bt(P)||!a?!1:(d=null,u=P.hasUserMovedViewport,a.animate({position:P.center,scale:P.scale,time:420,ease:"easeInOutSine"}),!0)}function pt(){a&&(u=!1,E(!0))}function Bt(P){return Re(P)?P.kind==="2d"&&Nt(P.center)&&typeof P.scale=="number"&&Number.isFinite(P.scale)&&typeof P.hasUserMovedViewport=="boolean":!1}function Nt(P){return Re(P)?typeof P.x=="number"&&Number.isFinite(P.x)&&typeof P.y=="number"&&Number.isFinite(P.y):!1}function Re(P){return typeof P=="object"&&P!==null}return ia(async()=>{await na(),await B()}),tn(()=>[s.graph.nodes,s.graph.edges,s.selectedKey,s.privacyMode,s.safeInsetRight],()=>{E(!1)},{flush:"post"}),tn(()=>g.value,()=>{k()}),ra(()=>{c?.disconnect(),c=null,o?.ticker.remove(O);for(const P of _)P.graphic.destroy();_.length=0,a?.destroy({children:!0}),a=null,o?.destroy({removeView:!0},!0),o=null,h=null,l=null}),t({focusNode:et,fitView:pt,captureView:xt,restoreView:st}),(P,T)=>(oa(),aa("div",{ref_key:"canvasRoot",ref:r,class:"h-full w-full overflow-hidden",role:"img","aria-label":i.label},null,8,vd))}}),kd=Object.freeze(Object.defineProperty({__proto__:null,default:Sd},Symbol.toStringTag,{value:"Module"}));export{Pr as $,uo as A,es as B,nt as C,ct as D,Yt as E,Qt as F,Gs as G,Bn as H,Ts as I,Di as J,ho as K,Rt as L,N as M,eo as N,Ii as O,X as P,Ul as Q,bi as R,Li as S,K as T,Ps as U,Nl as V,Zl as W,jl as X,ba as Y,tc as Z,vt as _,io as a,It as a0,Bs as a1,xn as a2,Ke as a3,Lu as a4,Za as a5,_n as a6,js as a7,bn as a8,Ja as a9,Pe as aa,Q as ab,Rr as ac,hu as ad,fo as ae,$ as af,is as ag,ot as ah,sl as ai,Zh as aj,Cl as ak,xl as al,Yl as am,Xl as an,Ql as ao,Kl as ap,Jl as aq,nu as ar,kd as as,Zr as b,pl as c,wt as d,at as e,tt as f,vh as g,Y as h,Ms as i,H as j,Ut as k,ac as l,Ir as m,eu as n,mc as o,Ds as p,Hr as q,ht as r,Fs as s,ge as t,Bh as u,Wa as v,bt as w,kt as x,ul as y,ns as z};