@foothill/agent-move 1.0.6

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 (163) hide show
  1. package/.github/screenshot.png +0 -0
  2. package/README.md +266 -0
  3. package/bin/cli.js +229 -0
  4. package/package.json +53 -0
  5. package/packages/client/dist/assets/BufferResource-Ddjob236.js +185 -0
  6. package/packages/client/dist/assets/CanvasRenderer-B0w6SYyW.js +1 -0
  7. package/packages/client/dist/assets/Filter-NcMGuiK-.js +1 -0
  8. package/packages/client/dist/assets/RenderTargetSystem-DgAzY5_U.js +172 -0
  9. package/packages/client/dist/assets/WebGLRenderer-DUWXDPIX.js +156 -0
  10. package/packages/client/dist/assets/WebGPURenderer-C1HbrllR.js +41 -0
  11. package/packages/client/dist/assets/browserAll-CaF1Fl0O.js +14 -0
  12. package/packages/client/dist/assets/index-CMmR_RuS.css +1 -0
  13. package/packages/client/dist/assets/index-Dh8yWoLP.js +711 -0
  14. package/packages/client/dist/assets/webworkerAll-BJ6UhC7r.js +83 -0
  15. package/packages/client/dist/favicon.svg +27 -0
  16. package/packages/client/dist/index.html +167 -0
  17. package/packages/client/package.json +19 -0
  18. package/packages/server/dist/config.d.ts +12 -0
  19. package/packages/server/dist/config.d.ts.map +1 -0
  20. package/packages/server/dist/config.js +19 -0
  21. package/packages/server/dist/config.js.map +1 -0
  22. package/packages/server/dist/hooks/hook-event-manager.d.ts +39 -0
  23. package/packages/server/dist/hooks/hook-event-manager.d.ts.map +1 -0
  24. package/packages/server/dist/hooks/hook-event-manager.js +161 -0
  25. package/packages/server/dist/hooks/hook-event-manager.js.map +1 -0
  26. package/packages/server/dist/hooks/hook-installer.d.ts +14 -0
  27. package/packages/server/dist/hooks/hook-installer.d.ts.map +1 -0
  28. package/packages/server/dist/hooks/hook-installer.js +179 -0
  29. package/packages/server/dist/hooks/hook-installer.js.map +1 -0
  30. package/packages/server/dist/index.d.ts +4 -0
  31. package/packages/server/dist/index.d.ts.map +1 -0
  32. package/packages/server/dist/index.js +3544 -0
  33. package/packages/server/dist/index.js.map +1 -0
  34. package/packages/server/dist/routes/api.d.ts +4 -0
  35. package/packages/server/dist/routes/api.d.ts.map +1 -0
  36. package/packages/server/dist/routes/api.js +27 -0
  37. package/packages/server/dist/routes/api.js.map +1 -0
  38. package/packages/server/dist/state/activity-processor.d.ts +31 -0
  39. package/packages/server/dist/state/activity-processor.d.ts.map +1 -0
  40. package/packages/server/dist/state/activity-processor.js +417 -0
  41. package/packages/server/dist/state/activity-processor.js.map +1 -0
  42. package/packages/server/dist/state/agent-state-manager.d.ts +107 -0
  43. package/packages/server/dist/state/agent-state-manager.d.ts.map +1 -0
  44. package/packages/server/dist/state/agent-state-manager.js +1622 -0
  45. package/packages/server/dist/state/agent-state-manager.js.map +1 -0
  46. package/packages/server/dist/state/anomaly-detector.d.ts +23 -0
  47. package/packages/server/dist/state/anomaly-detector.d.ts.map +1 -0
  48. package/packages/server/dist/state/anomaly-detector.js +272 -0
  49. package/packages/server/dist/state/anomaly-detector.js.map +1 -0
  50. package/packages/server/dist/state/identity-manager.d.ts +31 -0
  51. package/packages/server/dist/state/identity-manager.d.ts.map +1 -0
  52. package/packages/server/dist/state/identity-manager.js +63 -0
  53. package/packages/server/dist/state/identity-manager.js.map +1 -0
  54. package/packages/server/dist/state/role-resolver.d.ts +23 -0
  55. package/packages/server/dist/state/role-resolver.d.ts.map +1 -0
  56. package/packages/server/dist/state/role-resolver.js +43 -0
  57. package/packages/server/dist/state/role-resolver.js.map +1 -0
  58. package/packages/server/dist/state/task-graph-manager.d.ts +31 -0
  59. package/packages/server/dist/state/task-graph-manager.d.ts.map +1 -0
  60. package/packages/server/dist/state/task-graph-manager.js +191 -0
  61. package/packages/server/dist/state/task-graph-manager.js.map +1 -0
  62. package/packages/server/dist/state/tool-chain-tracker.d.ts +23 -0
  63. package/packages/server/dist/state/tool-chain-tracker.d.ts.map +1 -0
  64. package/packages/server/dist/state/tool-chain-tracker.js +113 -0
  65. package/packages/server/dist/state/tool-chain-tracker.js.map +1 -0
  66. package/packages/server/dist/watcher/agent-watcher.d.ts +16 -0
  67. package/packages/server/dist/watcher/agent-watcher.d.ts.map +1 -0
  68. package/packages/server/dist/watcher/agent-watcher.js +0 -0
  69. package/packages/server/dist/watcher/agent-watcher.js.map +1 -0
  70. package/packages/server/dist/watcher/claude-paths.d.ts +32 -0
  71. package/packages/server/dist/watcher/claude-paths.d.ts.map +1 -0
  72. package/packages/server/dist/watcher/claude-paths.js +104 -0
  73. package/packages/server/dist/watcher/claude-paths.js.map +1 -0
  74. package/packages/server/dist/watcher/file-watcher.d.ts +17 -0
  75. package/packages/server/dist/watcher/file-watcher.d.ts.map +1 -0
  76. package/packages/server/dist/watcher/file-watcher.js +347 -0
  77. package/packages/server/dist/watcher/file-watcher.js.map +1 -0
  78. package/packages/server/dist/watcher/git-info.d.ts +3 -0
  79. package/packages/server/dist/watcher/git-info.d.ts.map +1 -0
  80. package/packages/server/dist/watcher/git-info.js +35 -0
  81. package/packages/server/dist/watcher/git-info.js.map +1 -0
  82. package/packages/server/dist/watcher/jsonl-parser.d.ts +21 -0
  83. package/packages/server/dist/watcher/jsonl-parser.d.ts.map +1 -0
  84. package/packages/server/dist/watcher/jsonl-parser.js +95 -0
  85. package/packages/server/dist/watcher/jsonl-parser.js.map +1 -0
  86. package/packages/server/dist/watcher/opencode/opencode-parser.d.ts +58 -0
  87. package/packages/server/dist/watcher/opencode/opencode-parser.d.ts.map +1 -0
  88. package/packages/server/dist/watcher/opencode/opencode-parser.js +256 -0
  89. package/packages/server/dist/watcher/opencode/opencode-parser.js.map +1 -0
  90. package/packages/server/dist/watcher/opencode/opencode-paths.d.ts +20 -0
  91. package/packages/server/dist/watcher/opencode/opencode-paths.d.ts.map +1 -0
  92. package/packages/server/dist/watcher/opencode/opencode-paths.js +35 -0
  93. package/packages/server/dist/watcher/opencode/opencode-paths.js.map +1 -0
  94. package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts +49 -0
  95. package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts.map +1 -0
  96. package/packages/server/dist/watcher/opencode/opencode-watcher.js +1292 -0
  97. package/packages/server/dist/watcher/opencode/opencode-watcher.js.map +1 -0
  98. package/packages/server/dist/watcher/session-scanner.d.ts +7 -0
  99. package/packages/server/dist/watcher/session-scanner.d.ts.map +1 -0
  100. package/packages/server/dist/watcher/session-scanner.js +69 -0
  101. package/packages/server/dist/watcher/session-scanner.js.map +1 -0
  102. package/packages/server/dist/ws/broadcaster.d.ts +18 -0
  103. package/packages/server/dist/ws/broadcaster.d.ts.map +1 -0
  104. package/packages/server/dist/ws/broadcaster.js +152 -0
  105. package/packages/server/dist/ws/broadcaster.js.map +1 -0
  106. package/packages/server/dist/ws/ws-handler.d.ts +6 -0
  107. package/packages/server/dist/ws/ws-handler.d.ts.map +1 -0
  108. package/packages/server/dist/ws/ws-handler.js +55 -0
  109. package/packages/server/dist/ws/ws-handler.js.map +1 -0
  110. package/packages/server/package.json +25 -0
  111. package/packages/shared/dist/constants/colors.d.ts +46 -0
  112. package/packages/shared/dist/constants/colors.d.ts.map +1 -0
  113. package/packages/shared/dist/constants/colors.js +178 -0
  114. package/packages/shared/dist/constants/colors.js.map +1 -0
  115. package/packages/shared/dist/constants/names.d.ts +6 -0
  116. package/packages/shared/dist/constants/names.d.ts.map +1 -0
  117. package/packages/shared/dist/constants/names.js +28 -0
  118. package/packages/shared/dist/constants/names.js.map +1 -0
  119. package/packages/shared/dist/constants/tools.d.ts +15 -0
  120. package/packages/shared/dist/constants/tools.d.ts.map +1 -0
  121. package/packages/shared/dist/constants/tools.js +120 -0
  122. package/packages/shared/dist/constants/tools.js.map +1 -0
  123. package/packages/shared/dist/constants/zones.d.ts +37 -0
  124. package/packages/shared/dist/constants/zones.d.ts.map +1 -0
  125. package/packages/shared/dist/constants/zones.js +128 -0
  126. package/packages/shared/dist/constants/zones.js.map +1 -0
  127. package/packages/shared/dist/index.d.ts +15 -0
  128. package/packages/shared/dist/index.d.ts.map +1 -0
  129. package/packages/shared/dist/index.js +7 -0
  130. package/packages/shared/dist/index.js.map +1 -0
  131. package/packages/shared/dist/types/agent.d.ts +85 -0
  132. package/packages/shared/dist/types/agent.d.ts.map +1 -0
  133. package/packages/shared/dist/types/agent.js +2 -0
  134. package/packages/shared/dist/types/agent.js.map +1 -0
  135. package/packages/shared/dist/types/anomaly.d.ts +18 -0
  136. package/packages/shared/dist/types/anomaly.d.ts.map +1 -0
  137. package/packages/shared/dist/types/anomaly.js +6 -0
  138. package/packages/shared/dist/types/anomaly.js.map +1 -0
  139. package/packages/shared/dist/types/hooks.d.ts +51 -0
  140. package/packages/shared/dist/types/hooks.d.ts.map +1 -0
  141. package/packages/shared/dist/types/hooks.js +2 -0
  142. package/packages/shared/dist/types/hooks.js.map +1 -0
  143. package/packages/shared/dist/types/jsonl.d.ts +62 -0
  144. package/packages/shared/dist/types/jsonl.d.ts.map +1 -0
  145. package/packages/shared/dist/types/jsonl.js +3 -0
  146. package/packages/shared/dist/types/jsonl.js.map +1 -0
  147. package/packages/shared/dist/types/task-graph.d.ts +20 -0
  148. package/packages/shared/dist/types/task-graph.d.ts.map +1 -0
  149. package/packages/shared/dist/types/task-graph.js +2 -0
  150. package/packages/shared/dist/types/task-graph.js.map +1 -0
  151. package/packages/shared/dist/types/tool-chain.d.ts +17 -0
  152. package/packages/shared/dist/types/tool-chain.d.ts.map +1 -0
  153. package/packages/shared/dist/types/tool-chain.js +2 -0
  154. package/packages/shared/dist/types/tool-chain.js.map +1 -0
  155. package/packages/shared/dist/types/websocket.d.ts +132 -0
  156. package/packages/shared/dist/types/websocket.d.ts.map +1 -0
  157. package/packages/shared/dist/types/websocket.js +2 -0
  158. package/packages/shared/dist/types/websocket.js.map +1 -0
  159. package/packages/shared/dist/types/zone.d.ts +21 -0
  160. package/packages/shared/dist/types/zone.d.ts.map +1 -0
  161. package/packages/shared/dist/types/zone.js +2 -0
  162. package/packages/shared/dist/types/zone.js.map +1 -0
  163. package/packages/shared/package.json +15 -0
@@ -0,0 +1,711 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-CaF1Fl0O.js","assets/webworkerAll-BJ6UhC7r.js","assets/Filter-NcMGuiK-.js","assets/WebGPURenderer-C1HbrllR.js","assets/BufferResource-Ddjob236.js","assets/RenderTargetSystem-DgAzY5_U.js","assets/WebGLRenderer-DUWXDPIX.js","assets/CanvasRenderer-B0w6SYyW.js"])))=>i.map(i=>d[i]);
2
+ var Pu=Object.defineProperty;var Iu=(i,t,e)=>t in i?Pu(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var b=(i,t,e)=>Iu(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const o of n)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function e(n){const o={};return n.integrity&&(o.integrity=n.integrity),n.referrerPolicy&&(o.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?o.credentials="include":n.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(n){if(n.ep)return;n.ep=!0;const o=e(n);fetch(n.href,o)}})();const Lu="modulepreload",Bu=function(i){return"/"+i},Cl={},Hn=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){let r=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));n=r(e.map(u=>{if(u=Bu(u),u in Cl)return;Cl[u]=!0;const d=u.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${p}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":Lu,d||(m.as="script"),m.crossOrigin="",m.href=u,h&&m.setAttribute("nonce",h),document.head.appendChild(m),d)return new Promise((g,y)=>{m.addEventListener("load",g),m.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(r){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=r,window.dispatchEvent(l),!l.defaultPrevented)throw r}return n.then(r=>{for(const l of r||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};var mt=(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.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(mt||{});const _a=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},ro=(i,t)=>_a(i).priority??t,Ut={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(_a).forEach(t=>{t.type.forEach(e=>{var s,n;return(n=(s=this._removeHandlers)[e])==null?void 0:n.call(s,t)})}),this},add(...i){return i.map(_a).forEach(t=>{t.type.forEach(e=>{var o,r;const s=this._addHandlers,n=this._queue;s[e]?(r=s[e])==null||r.call(s,t):(n[e]=n[e]||[],(o=n[e])==null||o.push(t))})}),this},handle(i,t,e){var r;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 o=this._queue;return o[i]&&((r=o[i])==null||r.forEach(l=>t(l)),delete o[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(o=>o.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((o,r)=>ro(r.value,e)-ro(o.value,e)))},s=>{const n=t.findIndex(o=>o.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,o)=>ro(o,e)-ro(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))}},Ru={extension:{type:mt.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Hn(()=>import("./browserAll-CaF1Fl0O.js"),__vite__mapDeps([0,1,2]))}},Du={extension:{type:mt.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Hn(()=>import("./webworkerAll-BJ6UhC7r.js"),__vite__mapDeps([1,2]))}};class Kt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new Kt(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function Wh(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var dr={exports:{}},Al;function $u(){return Al||(Al=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,u,d){this.fn=h,this.context=u,this.once=d||!1}function o(h,u,d,p,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var g=new n(d,p||h,m),y=e?e+u:u;return h._events[y]?h._events[y].fn?h._events[y]=[h._events[y],g]:h._events[y].push(g):(h._events[y]=g,h._eventsCount++),h}function r(h,u){--h._eventsCount===0?h._events=new s:delete h._events[u]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,p;if(this._eventsCount===0)return u;for(p in d=this._events)t.call(d,p)&&u.push(e?p.slice(1):p);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=e?e+u:u,p=this._events[d];if(!p)return[];if(p.fn)return[p.fn];for(var m=0,g=p.length,y=new Array(g);m<g;m++)y[m]=p[m].fn;return y},l.prototype.listenerCount=function(u){var d=e?e+u:u,p=this._events[d];return p?p.fn?1:p.length:0},l.prototype.emit=function(u,d,p,m,g,y){var x=e?e+u:u;if(!this._events[x])return!1;var w=this._events[x],S=arguments.length,A,L;if(w.fn){switch(w.once&&this.removeListener(u,w.fn,void 0,!0),S){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,d),!0;case 3:return w.fn.call(w.context,d,p),!0;case 4:return w.fn.call(w.context,d,p,m),!0;case 5:return w.fn.call(w.context,d,p,m,g),!0;case 6:return w.fn.call(w.context,d,p,m,g,y),!0}for(L=1,A=new Array(S-1);L<S;L++)A[L-1]=arguments[L];w.fn.apply(w.context,A)}else{var I=w.length,O;for(L=0;L<I;L++)switch(w[L].once&&this.removeListener(u,w[L].fn,void 0,!0),S){case 1:w[L].fn.call(w[L].context);break;case 2:w[L].fn.call(w[L].context,d);break;case 3:w[L].fn.call(w[L].context,d,p);break;case 4:w[L].fn.call(w[L].context,d,p,m);break;default:if(!A)for(O=1,A=new Array(S-1);O<S;O++)A[O-1]=arguments[O];w[L].fn.apply(w[L].context,A)}}return!0},l.prototype.on=function(u,d,p){return o(this,u,d,p,!1)},l.prototype.once=function(u,d,p){return o(this,u,d,p,!0)},l.prototype.removeListener=function(u,d,p,m){var g=e?e+u:u;if(!this._events[g])return this;if(!d)return r(this,g),this;var y=this._events[g];if(y.fn)y.fn===d&&(!m||y.once)&&(!p||y.context===p)&&r(this,g);else{for(var x=0,w=[],S=y.length;x<S;x++)(y[x].fn!==d||m&&!y[x].once||p&&y[x].context!==p)&&w.push(y[x]);w.length?this._events[g]=w.length===1?w[0]:w:r(this,g)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=e?e+u:u,this._events[d]&&r(this,d)):(this._events=new s,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=e,l.EventEmitter=l,i.exports=l})(dr)),dr.exports}var zu=$u();const Ze=Wh(zu),Fu=Math.PI*2,Nu=180/Math.PI,Wu=Math.PI/180;class ae{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ae(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 ur.x=0,ur.y=0,ur}}const ur=new ae;class _t{constructor(t=1,e=0,s=0,n=1,o=0,r=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=n,this.tx=o,this.ty=r}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,o,r){return this.a=t,this.b=e,this.c=s,this.d=n,this.tx=o,this.ty=r,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 ae;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 ae;const s=this.a,n=this.b,o=this.c,r=this.d,l=this.tx,h=this.ty,u=1/(s*r+o*-n),d=t.x,p=t.y;return e.x=r*u*d+-o*u*p+(h*o-l*r)*u,e.y=s*u*p+-n*u*d+(-h*s+l*n)*u,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),n=this.a,o=this.c,r=this.tx;return this.a=n*e-this.b*s,this.b=n*s+this.b*e,this.c=o*e-this.d*s,this.d=o*s+this.d*e,this.tx=r*e-this.ty*s,this.ty=r*s+this.ty*e,this}append(t){const e=this.a,s=this.b,n=this.c,o=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*s+t.b*o,this.c=t.c*e+t.d*n,this.d=t.c*s+t.d*o,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*s+t.ty*o+this.ty,this}appendFrom(t,e){const s=t.a,n=t.b,o=t.c,r=t.d,l=t.tx,h=t.ty,u=e.a,d=e.b,p=e.c,m=e.d;return this.a=s*u+n*p,this.b=s*d+n*m,this.c=o*u+r*p,this.d=o*d+r*m,this.tx=l*u+h*p+e.tx,this.ty=l*d+h*m+e.ty,this}setTransform(t,e,s,n,o,r,l,h,u){return this.a=Math.cos(l+u)*o,this.b=Math.sin(l+u)*o,this.c=-Math.sin(l-h)*r,this.d=Math.cos(l-h)*r,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,o=this.d,r=t.pivot,l=-Math.atan2(-n,o),h=Math.atan2(s,e),u=Math.abs(l+h);return u<1e-5||Math.abs(Fu-u)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=l,t.skew.y=h),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(n*n+o*o),t.position.x=this.tx+(r.x*e+r.y*n),t.position.y=this.ty+(r.x*s+r.y*o),t}invert(){const t=this.a,e=this.b,s=this.c,n=this.d,o=this.tx,r=t*n-e*s;return this.a=n/r,this.b=-e/r,this.c=-s/r,this.d=t/r,this.tx=(s*this.ty-n*o)/r,this.ty=-(t*this.ty-e*o)/r,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 _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}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 Ou.identity()}static get shared(){return Gu.identity()}}const Gu=new _t,Ou=new _t,Ai=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Mi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ei=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Pi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],xa=[],Gh=[],ao=Math.sign;function Hu(){for(let i=0;i<16;i++){const t=[];xa.push(t);for(let e=0;e<16;e++){const s=ao(Ai[i]*Ai[e]+Ei[i]*Mi[e]),n=ao(Mi[i]*Ai[e]+Pi[i]*Mi[e]),o=ao(Ai[i]*Ei[e]+Ei[i]*Pi[e]),r=ao(Mi[i]*Ei[e]+Pi[i]*Pi[e]);for(let l=0;l<16;l++)if(Ai[l]===s&&Mi[l]===n&&Ei[l]===o&&Pi[l]===r){t.push(l);break}}}for(let i=0;i<16;i++){const t=new _t;t.set(Ai[i],Mi[i],Ei[i],Pi[i],0,0),Gh.push(t)}}Hu();const Lt={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=>Ai[i],uY:i=>Mi[i],vX:i=>Ei[i],vY:i=>Pi[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>xa[i][t],sub:(i,t)=>xa[i][Lt.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?Lt.S:Lt.N:Math.abs(t)*2<=Math.abs(i)?i>0?Lt.E:Lt.W:t>0?i>0?Lt.SE:Lt.SW:i>0?Lt.NE:Lt.NW,matrixAppendRotationInv:(i,t,e=0,s=0,n=0,o=0)=>{const r=Gh[Lt.inv(t)],l=r.a,h=r.b,u=r.c,d=r.d,p=e-Math.min(0,l*n,u*o,l*n+u*o),m=s-Math.min(0,h*n,d*o,h*n+d*o),g=i.a,y=i.b,x=i.c,w=i.d;i.a=l*g+h*x,i.b=l*y+h*w,i.c=u*g+d*x,i.d=u*y+d*w,i.tx=p*g+m*x+i.tx,i.ty=p*y+m*w+i.ty},transformRectCoords:(i,t,e,s)=>{const{x:n,y:o,width:r,height:l}=i,{x:h,y:u,width:d,height:p}=t;return e===Lt.E?(s.set(n+h,o+u,r,l),s):e===Lt.S?s.set(d-o-l+h,n+u,l,r):e===Lt.W?s.set(d-n-r+h,p-o-l+u,r,l):e===Lt.N?s.set(o+h,p-n-r+u,l,r):s.set(n+h,o+u,r,l)}},lo=[new ae,new ae,new ae,new ae];class Ht{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 Ht(0,0,0,0)}clone(){return new Ht(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:o,height:r}=this;if(o<=0||r<=0)return!1;const l=this.x,h=this.y,u=s*(1-n),d=s-u,p=l-u,m=l+o+u,g=h-u,y=h+r+u,x=l+d,w=l+o-d,S=h+d,A=h+r-d;return t>=p&&t<=m&&e>=g&&e<=y&&!(t>x&&t<w&&e>S&&e<A)}intersects(t,e){if(!e){const Q=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=Q)return!1;const j=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>j}const s=this.left,n=this.right,o=this.top,r=this.bottom;if(n<=s||r<=o)return!1;const l=lo[0].set(t.left,t.top),h=lo[1].set(t.left,t.bottom),u=lo[2].set(t.right,t.top),d=lo[3].set(t.right,t.bottom);if(u.x<=l.x||h.y<=l.y)return!1;const p=Math.sign(e.a*e.d-e.b*e.c);if(p===0||(e.apply(l,l),e.apply(h,h),e.apply(u,u),e.apply(d,d),Math.max(l.x,h.x,u.x,d.x)<=s||Math.min(l.x,h.x,u.x,d.x)>=n||Math.max(l.y,h.y,u.y,d.y)<=o||Math.min(l.y,h.y,u.y,d.y)>=r))return!1;const m=p*(h.y-l.y),g=p*(l.x-h.x),y=m*s+g*o,x=m*n+g*o,w=m*s+g*r,S=m*n+g*r;if(Math.max(y,x,w,S)<=m*l.x+g*l.y||Math.min(y,x,w,S)>=m*d.x+g*d.y)return!1;const A=p*(l.y-u.y),L=p*(u.x-l.x),I=A*s+L*o,O=A*n+L*o,R=A*s+L*r,z=A*n+L*r;return!(Math.max(I,O,R,z)<=A*l.x+L*l.y||Math.min(I,O,R,z)>=A*d.x+L*d.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),o=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(o-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),o=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=o-n,this}getBounds(t){return t||(t=new Ht),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,o=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&&o>=this.y&&o<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 fr={default:-1};function Gt(i="default"){return fr[i]===void 0&&(fr[i]=-1),++fr[i]}const Ml=new Set,Wt="8.0.0",Uu="8.3.4",Qi={quiet:!1,noColor:!1},wt=((i,t,e=3)=>{if(Qi.quiet||Ml.has(t))return;let s=new Error().stack;const n=`${t}
3
+ Deprecated since v${i}`,o=typeof console.groupCollapsed=="function"&&!Qi.noColor;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",n):(s=s.split(`
4
+ `).splice(e).join(`
5
+ `),o?(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))),Ml.add(t)});Object.defineProperties(wt,{quiet:{get:()=>Qi.quiet,set:i=>{Qi.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>Qi.noColor,set:i=>{Qi.noColor=i},enumerable:!0,configurable:!1}});const Oh=()=>{};function an(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 El(i){return!(i&i-1)&&!!i}function Hh(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const Pl=Object.create(null);function qu(i){const t=Pl[i];return t===void 0&&(Pl[i]=Gt("resource")),t}const Uh=class qh extends Ze{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...qh.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){wt(Wt,"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=qu(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Uh.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ln=Uh;const Vh=class Yh extends Ze{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=Gt("textureSource"),this._resourceType="textureSource",this._resourceId=Gt("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._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...Yh.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.alphaMode=t.alphaMode,this.style=new ln(Hh(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}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(){var t,e;this._resourceId=Gt("resource"),this.emit("change",this),this.emit("unload",this);for(const s in this._gpuData)(e=(t=this._gpuData[s])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*s),o=Math.round(e*s);return this.width=n/s,this.height=o/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===o?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=o,this.emit("resize",this),this._resourceId=Gt("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=El(this.pixelWidth)&&El(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Vh.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 Ie=Vh;class il extends Ie{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}}il.extension=mt.TextureSource;const Il=new _t;class Vu{constructor(t,e){this.mapCoord=new _t,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,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){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let n=0;n<t.length;n+=2){const o=t[n],r=t[n+1];e[n]=o*s.a+r*s.c+s.tx,e[n+1]=o*s.b+r*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&&(Il.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Il));const o=t.source,r=this.uClampFrame,l=this.clampMargin/o._resolution,h=this.clampOffset/o._resolution;return r[0]=(t.frame.x+l+h)/o.width,r[1]=(t.frame.y+l+h)/o.height,r[2]=(t.frame.x+t.frame.width-l+h)/o.width,r[3]=(t.frame.y+t.frame.height-l+h)/o.height,this.uClampOffset[0]=this.clampOffset/o.pixelWidth,this.uClampOffset[1]=this.clampOffset/o.pixelHeight,this.isSimple=t.frame.width===o.width&&t.frame.height===o.height&&t.rotate===0,!0}}class It extends Ze{constructor({source:t,label:e,frame:s,orig:n,trim:o,defaultAnchor:r,defaultBorders:l,rotate:h,dynamic:u}={}){if(super(),this.uid=Gt("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Ht,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new Ie,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:d,height:p}=this._source;this.frame.width=d,this.frame.height=p}this.orig=n||this.frame,this.trim=o,this.rotate=h??0,this.defaultAnchor=r,this.defaultBorders=l,this.destroyed=!1,this.dynamic=u||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Vu(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,o=e.x/s,r=e.y/n,l=e.width/s,h=e.height/n;let u=this.rotate;if(u){const d=l/2,p=h/2,m=o+d,g=r+p;u=Lt.add(u,Lt.NW),t.x0=m+d*Lt.uX(u),t.y0=g+p*Lt.uY(u),u=Lt.add(u,2),t.x1=m+d*Lt.uX(u),t.y1=g+p*Lt.uY(u),u=Lt.add(u,2),t.x2=m+d*Lt.uX(u),t.y2=g+p*Lt.uY(u),u=Lt.add(u,2),t.x3=m+d*Lt.uX(u),t.y3=g+p*Lt.uY(u)}else t.x0=o,t.y0=r,t.x1=o+l,t.y1=r,t.x2=o+l,t.y2=r+h,t.x3=o,t.y3=r+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 wt(Wt,"Texture.baseTexture is now Texture.source"),this._source}}It.EMPTY=new It({label:"EMPTY",source:new Ie({label:"EMPTY"})});It.EMPTY.destroy=Oh;It.WHITE=new It({source:new il({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});It.WHITE.destroy=Oh;function jh(i,t,e){const{width:s,height:n}=e.orig,o=e.trim;if(o){const r=o.width,l=o.height;i.minX=o.x-t._x*s,i.maxX=i.minX+r,i.minY=o.y-t._y*n,i.maxY=i.minY+l}else i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}const Ll=new _t;class Pe{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=Ll,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 Ht);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=Ll,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,o){o||(o=this.matrix);const r=o.a,l=o.b,h=o.c,u=o.d,d=o.tx,p=o.ty;let m=this.minX,g=this.minY,y=this.maxX,x=this.maxY,w=r*t+h*e+d,S=l*t+u*e+p;w<m&&(m=w),S<g&&(g=S),w>y&&(y=w),S>x&&(x=S),w=r*s+h*e+d,S=l*s+u*e+p,w<m&&(m=w),S<g&&(g=S),w>y&&(y=w),S>x&&(x=S),w=r*t+h*n+d,S=l*t+u*n+p,w<m&&(m=w),S<g&&(g=S),w>y&&(y=w),S>x&&(x=S),w=r*s+h*n+d,S=l*s+u*n+p,w<m&&(m=w),S<g&&(g=S),w>y&&(y=w),S>x&&(x=S),this.minX=m,this.minY=g,this.maxX=y,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,o=this.maxY,{a:r,b:l,c:h,d:u,tx:d,ty:p}=t;let m=r*e+h*s+d,g=l*e+u*s+p;this.minX=m,this.minY=g,this.maxX=m,this.maxY=g,m=r*n+h*s+d,g=l*n+u*s+p,this.minX=m<this.minX?m:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=m>this.maxX?m:this.maxX,this.maxY=g>this.maxY?g:this.maxY,m=r*e+h*o+d,g=l*e+u*o+p,this.minX=m<this.minX?m:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=m>this.maxX?m:this.maxX,this.maxY=g>this.maxY?g:this.maxY,m=r*n+h*o+d,g=l*n+u*o+p,this.minX=m<this.minX?m:this.minX,this.minY=g<this.minY?g:this.minY,this.maxX=m>this.maxX?m:this.maxX,this.maxY=g>this.maxY?g: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 Pe(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 o=this.minX,r=this.minY,l=this.maxX,h=this.maxY;n||(n=this.matrix);const u=n.a,d=n.b,p=n.c,m=n.d,g=n.tx,y=n.ty;for(let x=e;x<s;x+=2){const w=t[x],S=t[x+1],A=u*w+p*S+g,L=d*w+m*S+y;o=A<o?A:o,r=L<r?L:r,l=A>l?A:l,h=L>h?L:h}this.minX=o,this.minY=r,this.maxX=l,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 Yu={grad:.9,turn:360,rad:360/(2*Math.PI)},Ke=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},jt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},Ae=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},Xh=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Bl=function(i){return{r:Ae(i.r,0,255),g:Ae(i.g,0,255),b:Ae(i.b,0,255),a:Ae(i.a)}},pr=function(i){return{r:jt(i.r),g:jt(i.g),b:jt(i.b),a:jt(i.a,3)}},ju=/^#([0-9a-f]{3,8})$/i,co=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},Zh=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,o=Math.max(t,e,s),r=o-Math.min(t,e,s),l=r?o===t?(e-s)/r:o===e?2+(s-t)/r:4+(t-e)/r:0;return{h:60*(l<0?l+6:l),s:o?r/o*100:0,v:o/255*100,a:n}},Kh=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var o=Math.floor(t),r=s*(1-e),l=s*(1-(t-o)*e),h=s*(1-(1-t+o)*e),u=o%6;return{r:255*[s,l,r,r,h,s][u],g:255*[h,s,s,l,r,r][u],b:255*[r,r,h,s,s,l][u],a:n}},Rl=function(i){return{h:Xh(i.h),s:Ae(i.s,0,100),l:Ae(i.l,0,100),a:Ae(i.a)}},Dl=function(i){return{h:jt(i.h),s:jt(i.s),l:jt(i.l),a:jt(i.a,3)}},$l=function(i){return Kh((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},Un=function(i){return{h:(t=Zh(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},Xu=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zu=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ku=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qu=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,va={string:[[function(i){var t=ju.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?jt(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?jt(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=Ku.exec(i)||Qu.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:Bl({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=Xu.exec(i)||Zu.exec(i);if(!t)return null;var e,s,n=Rl({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(Yu[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return $l(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,o=n===void 0?1:n;return Ke(t)&&Ke(e)&&Ke(s)?Bl({r:Number(t),g:Number(e),b:Number(s),a:Number(o)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,o=n===void 0?1:n;if(!Ke(t)||!Ke(e)||!Ke(s))return null;var r=Rl({h:Number(t),s:Number(e),l:Number(s),a:Number(o)});return $l(r)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,o=n===void 0?1:n;if(!Ke(t)||!Ke(e)||!Ke(s))return null;var r=(function(l){return{h:Xh(l.h),s:Ae(l.s,0,100),v:Ae(l.v,0,100),a:Ae(l.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(o)});return Kh(r)},"hsv"]]},zl=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]},Ju=function(i){return typeof i=="string"?zl(i.trim(),va.string):typeof i=="object"&&i!==null?zl(i,va.object):[null,void 0]},mr=function(i,t){var e=Un(i);return{h:e.h,s:Ae(e.s+100*t,0,100),l:e.l,a:e.a}},gr=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},Fl=function(i,t){var e=Un(i);return{h:e.h,s:e.s,l:Ae(e.l+100*t,0,100),a:e.a}},wa=(function(){function i(t){this.parsed=Ju(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 jt(gr(this.rgba),2)},i.prototype.isDark=function(){return gr(this.rgba)<.5},i.prototype.isLight=function(){return gr(this.rgba)>=.5},i.prototype.toHex=function(){return t=pr(this.rgba),e=t.r,s=t.g,n=t.b,r=(o=t.a)<1?co(jt(255*o)):"","#"+co(e)+co(s)+co(n)+r;var t,e,s,n,o,r},i.prototype.toRgb=function(){return pr(this.rgba)},i.prototype.toRgbString=function(){return t=pr(this.rgba),e=t.r,s=t.g,n=t.b,(o=t.a)<1?"rgba("+e+", "+s+", "+n+", "+o+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,o},i.prototype.toHsl=function(){return Dl(Un(this.rgba))},i.prototype.toHslString=function(){return t=Dl(Un(this.rgba)),e=t.h,s=t.s,n=t.l,(o=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+o+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,o},i.prototype.toHsv=function(){return t=Zh(this.rgba),{h:jt(t.h),s:jt(t.s),v:jt(t.v),a:jt(t.a,3)};var t},i.prototype.invert=function(){return Oe({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),Oe(mr(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Oe(mr(this.rgba,-t))},i.prototype.grayscale=function(){return Oe(mr(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Oe(Fl(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Oe(Fl(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"?Oe({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):jt(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Un(this.rgba);return typeof t=="number"?Oe({h:t,s:e.s,l:e.l,a:e.a}):jt(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Oe(t).toHex()},i})(),Oe=function(i){return i instanceof wa?i:new wa(i)},Nl=[],tf=function(i){i.forEach(function(t){Nl.indexOf(t)<0&&(t(wa,va),Nl.push(t))})};function ef(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 o={};i.prototype.toName=function(r){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var l,h,u=s[this.toHex()];if(u)return u;if(r!=null&&r.closest){var d=this.toRgb(),p=1/0,m="black";if(!o.length)for(var g in e)o[g]=new i(e[g]).toRgb();for(var y in e){var x=(l=d,h=o[y],Math.pow(l.r-h.r,2)+Math.pow(l.g-h.g,2)+Math.pow(l.b-h.b,2));x<p&&(p=x,m=y)}return m}},t.string.push([function(r){var l=r.toLowerCase(),h=l==="transparent"?"#0000":e[l];return h?new i(h).toRgb():null},"name"])}tf([ef]);const cn=class Nn{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 Nn)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((o,r)=>o===e[r]);if(t!==null&&e!==null){const o=Object.keys(t),r=Object.keys(e);return o.length!==r.length?!1:o.every(l=>t[l]===e[l])}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,o]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=o,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,o]=Nn._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=o,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,o=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,o=o*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+o}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,o;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const r=t;e=(r>>16&255)/255,s=(r>>8&255)/255,n=(r&255)/255,o=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,o=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,o=255]=t,e/=255,s/=255,n/=255,o/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const l=Nn.HEX_PATTERN.exec(t);l&&(t=`#${l[2]}`)}const r=Oe(t);r.isValid()&&({r:e,g:s,b:n,a:o}=r.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]=o,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,o)=>{t[o]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof Nn||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}};cn.shared=new cn;cn._temp=new cn;cn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Yt=cn;const sf={cullArea:null,cullable:!1,cullableChildren:!0};let yr=0;const Wl=500;function fe(...i){yr!==Wl&&(yr++,yr===Wl?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const io={_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 nf{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var s;let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class of{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 nf(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 ye=new of;io.register(ye);const rf={get isCachedAsTexture(){var i;return!!((i=this.renderGroup)!=null&&i.isCachedAsTexture)},cacheAsTexture(i){typeof i=="boolean"&&i===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(i===!0?{}:i))},updateCacheTexture(){var i;(i=this.renderGroup)==null||i.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(i){wt("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function af(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const o=s-e;for(n=t;n<o;++n)i[n]=i[n+e];i.length=o}const lf={allowChildren:!0,removeChildren(i=0,t){var o;const e=t??this.children.length,s=e-i,n=[];if(s>0&&s<=e){for(let l=e-1;l>=i;l--){const h=this.children[l];h&&(n.push(h),h.parent=null)}af(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let l=0;l<n.length;++l){const h=n[l];(o=h.parentRenderLayer)==null||o.detach(h),this.emit("childRemoved",h,this,l),n[l].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||wt(Wt,"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 o=i.parent.children.indexOf(i);if(s){if(o===t)return i;i.parent.children.splice(o,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(){var i;(i=this.parent)==null||i.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)}},cf={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 o=0;o<n;o++)s[o].collectRenderables(i,t,e)},collectRenderablesWithEffects(i,t,e){const{renderPipes:s}=t;for(let n=0;n<this.effects.length;n++){const o=this.effects[n];s[o.pipe].push(o,this,i)}this.collectRenderablesSimple(i,t,e);for(let n=this.effects.length-1;n>=0;n--){const o=this.effects[n];s[o.pipe].pop(o,this,i)}}};class Gl{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 hf{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 ye.get(s.maskClass,t)}return t}returnMaskEffect(t){ye.return(t)}}const Sa=new hf;Ut.handleByList(mt.MaskEffect,Sa._effectClasses);const df={_maskEffect:null,_maskOptions:{inverse:!1},_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==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),Sa.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=Sa.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},setMask(i){this._maskOptions={...this._maskOptions,...i},i.mask&&(this.mask=i.mask),this._markStructureAsChanged()},set filters(i){var o;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new Gl);i=i;const e=(i==null?void 0:i.length)>0,s=((o=t.filters)==null?void 0:o.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(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new Gl),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},uf={label:null,get name(){return wt(Wt,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){wt(Wt,"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 o=e[s].getChildByLabel(i,!0);if(o)return o}return null},getChildrenByLabel(i,t=!1,e=[]){const s=this.children;for(let n=0;n<s.length;n++){const o=s[n];(o.label===i||i instanceof RegExp&&i.test(o.label))&&e.push(o)}if(t)for(let n=0;n<s.length;n++)s[n].getChildrenByLabel(i,!0,e);return e}},ue=ye.getPool(_t),rs=ye.getPool(Pe),ff=new _t,pf={getFastGlobalBounds(i,t){t||(t=new Pe),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=rs.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const r=this.bounds;s.addFrame(r.minX,r.minY,r.maxX,r.maxY,this.groupTransform)}const o=this.children;for(let r=0;r<o.length;r++)o[r]._getGlobalBoundsRecursive(i,s,e)}if(n){let o=!1;const r=this.renderGroup||this.parentRenderGroup;for(let l=0;l<this.effects.length;l++)this.effects[l].addBounds&&(o||(o=!0,s.applyMatrix(r.worldTransform)),this.effects[l].addBounds(s,!0));o&&s.applyMatrix(r.worldTransform.copyTo(ff).invert()),t.addBounds(s),rs.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),rs.return(s))}};function Qh(i,t,e){e.clear();let s,n;return i.parent?t?s=i.parent.worldTransform:(n=ue.get().identity(),s=nl(i,n)):s=_t.IDENTITY,Jh(i,e,s,t),n&&ue.return(n),e.isValid||e.set(0,0,0,0),e}function Jh(i,t,e,s){var l,h;if(!i.visible||!i.measurable)return;let n;s?n=i.worldTransform:(i.updateLocalTransform(),n=ue.get(),n.appendFrom(i.localTransform,e));const o=t,r=!!i.effects.length;if(r&&(t=rs.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{const u=i.bounds;u&&!u.isEmpty()&&(t.matrix=n,t.addBounds(u));for(let d=0;d<i.children.length;d++)Jh(i.children[d],t,n,s)}if(r){for(let u=0;u<i.effects.length;u++)(h=(l=i.effects[u]).addBounds)==null||h.call(l,t);o.addBounds(t,_t.IDENTITY),rs.return(t)}s||ue.return(n)}function nl(i,t){const e=i.parent;return e&&(nl(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function td(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,o=t>>16&255,r=t>>8&255,l=t&255,h=e*o/255|0,u=s*r/255|0,d=n*l/255|0;return(h<<16)+(u<<8)+d}const Ol=16777215;function Hl(i,t){return i===Ol?t:t===Ol?i:td(i,t)}function zo(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const mf={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 _t,t){if(t)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const e=nl(this,ue.get().identity());return i.appendFrom(this.localTransform,e),ue.return(e),i},getGlobalTint(i){if(i)return this.renderGroup?zo(this.renderGroup.worldColor):this.parentRenderGroup?zo(Hl(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Hl(t,e.localColor),e=e.parent;return zo(t)}};function ed(i,t,e){return t.clear(),e||(e=_t.IDENTITY),sd(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function sd(i,t,e,s,n){var h,u;let o;if(n)o=ue.get(),o=e.copyTo(o);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const d=i.localTransform;o=ue.get(),o.appendFrom(d,e)}const r=t,l=!!i.effects.length;if(l&&(t=rs.get().clear()),i.boundsArea)t.addRect(i.boundsArea,o);else{i.renderPipeId&&(t.matrix=o,t.addBounds(i.bounds));const d=i.children;for(let p=0;p<d.length;p++)sd(d[p],t,o,s,!1)}if(l){for(let d=0;d<i.effects.length;d++)(u=(h=i.effects[d]).addLocalBounds)==null||u.call(h,t,s);r.addBounds(t,_t.IDENTITY),rs.return(t)}ue.return(o)}function id(i,t){const e=i.children;for(let s=0;s<e.length;s++){const n=e[s],o=n.uid,r=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,l=t.index;(t.data[l]!==o||t.data[l+1]!==r)&&(t.data[t.index]=o,t.data[t.index+1]=r,t.didChange=!0),t.index=l+2,n.children.length&&id(n,t)}return t.didChange}const gf=new _t,yf={_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 Pe});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),id(this,i),i.didChange&&ed(this,i.localBounds,gf),i.localBounds},getBounds(i,t){return Qh(this,i,t||new Pe)}},bf={_onRender:null,set onRender(i){const t=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},_f={_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(xf))}};function xf(i,t){return i._zIndex-t._zIndex}const vf={getGlobalPosition(i=new ae,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(ue.get(),e);return t=s.apply(i,t),ue.return(s),t},toLocal(i,t,e,s){t&&(i=t.toGlobal(i,e,s));const n=this.getGlobalTransform(ue.get(),s);return e=n.applyInverse(i,e),ue.return(n),e}};class ol{constructor(){this.uid=Gt("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 wf=0;class Sf{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new ln(this.textureOptions)}createTexture(t,e,s,n){const o=new Ie({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:n});return new It({source:o,label:`texturePool_${wf++}`})}getOptimalTexture(t,e,s=1,n,o=!1){let r=Math.ceil(t*s-1e-6),l=Math.ceil(e*s-1e-6);r=an(r),l=an(l);const h=n?1:0,u=o?1:0,d=(r<<17)+(l<<2)+(u<<1)+h;this._texturePool[d]||(this._texturePool[d]=[]);let p=this._texturePool[d].pop();return p||(p=this.createTexture(r,l,n,o)),p.source._resolution=s,p.source.width=r/s,p.source.height=l/s,p.source.pixelWidth=r,p.source.pixelHeight=l,p.frame.x=0,p.frame.y=0,p.frame.width=t,p.frame.height=e,p.updateUvs(),this._poolKeyHash[p.uid]=d,p}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 or=new Sf;io.register(or);class kf{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new _t,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 ol,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&&(or.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 _t),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new _t),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 _t),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 Tf(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const br=new Kt(null),ho=new Kt(null),_r=new Kt(null,1,1),uo=new Kt(null),Ul=1,Cf=2,xr=4;class Rt extends Ze{constructor(t={}){var e,s;super(),this.uid=Gt("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 _t,this.relativeGroupTransform=new _t,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Kt(this,0,0),this._scale=_r,this._pivot=ho,this._origin=uo,this._skew=br,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=[],Tf(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(n=>this.addChild(n)),(s=t.parent)==null||s.addChild(this)}static mixin(t){wt("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),Ut.mixin(Rt,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||wt(Wt,"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==null||t.removeChild(this),this.renderGroup=ye.get(kf,this),this.groupTransform=_t.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),ye.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new _t),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*Nu}set angle(t){this.rotation=t*Wu}get pivot(){return this._pivot===ho&&(this._pivot=new Kt(this,0,0)),this._pivot}set pivot(t){this._pivot===ho&&(this._pivot=new Kt(this,0,0),this._origin!==uo&&fe("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===br&&(this._skew=new Kt(this,0,0)),this._skew}set skew(t){this._skew===br&&(this._skew=new Kt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===_r&&(this._scale=new Kt(this,1,1)),this._scale}set scale(t){this._scale===_r&&(this._scale=new Kt(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===uo&&(this._origin=new Kt(this,0,0)),this._origin}set origin(t){this._origin===uo&&(this._origin=new Kt(this,0,0),this._pivot!==ho&&fe("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||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,o=this._origin,r=this._position,l=s._x,h=s._y,u=n._x,d=n._y,p=-o._x,m=-o._y;e.a=this._cx*l,e.b=this._sx*l,e.c=this._cy*h,e.d=this._sy*h,e.tx=r._x-(u*e.a+d*e.c)+(p*e.a+m*e.c)-p,e.ty=r._y-(u*e.b+d*e.d)+(p*e.b+m*e.d)-m}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Ul,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Yt.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=Ul,this._onUpdate())}get tint(){return zo(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Cf,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|=xr,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|=xr,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|=xr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;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==null?void 0:t.children)&&e)for(let o=0;o<e.length;++o)e[o].destroy(t);(n=this.renderGroup)==null||n.destroy(),this.renderGroup=null}}Ut.mixin(Rt,lf,pf,vf,bf,yf,df,uf,_f,sf,rf,mf,cf);class rl extends Rt{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 Pe(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(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,s){const{renderPipes:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const r=n[this.renderPipeId];r!=null&&r.addRenderable&&r.addRenderable(this,t),this.didViewUpdate=!1;const l=this.children,h=l.length;for(let u=0;u<h;u++)l[u].collectRenderables(t,e,s);n.blendMode.popBlendMode(t)}}class Di extends rl{constructor(t=It.EMPTY){t instanceof It&&(t={texture:t});const{texture:e=It.EMPTY,anchor:s,roundPixels:n,width:o,height:r,...l}=t;super({label:"Sprite",...l}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Kt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,o!==void 0&&(this.width=o),r!==void 0&&(this.height=r)}static from(t,e=!1){return t instanceof It?new Di(t):new Di(It.from(t,e))}set texture(t){t||(t=It.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 jh(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return wt("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:o}=e.orig;s.minX=-t._x*n,s.maxX=s.minX+n,s.minY=-t._y*o,s.maxY=s.minY+o}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0: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 Af=new Pe;function nd(i,t,e){const s=Af;i.measurable=!0,Qh(i,e,s),t.addBoundsMask(s),i.measurable=!1}function od(i,t,e){const s=rs.get();i.measurable=!0;const n=ue.get().identity(),o=rd(i,e,n);ed(i,s,o),i.measurable=!1,t.addBoundsMask(s),ue.return(n),rs.return(s)}function rd(i,t,e){return i?(i!==t&&(rd(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(fe("Mask bounds, renderable is not inside the root container"),e)}class ad{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Di),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||nd(this.mask,t,e)}addLocalBounds(t,e){od(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Di}}ad.extension=mt.MaskEffect;class ld{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}ld.extension=mt.MaskEffect;class cd{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){nd(this.mask,t,e)}addLocalBounds(t,e){od(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Rt}}cd.extension=mt.MaskEffect;const Mf={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 ql=Mf;const Se={get(){return ql},set(i){ql=i}};class hd extends Ie{constructor(t){t.resource||(t.resource=Se.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"))}}hd.extension=mt.TextureSource;class jo extends Ie{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}}jo.extension=mt.TextureSource;var Xo=(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))(Xo||{});class vr{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 dd=class we{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 vr(null,null,1/0),this.deltaMS=1/we.targetFPMS,this.elapsedMS=1/we.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=Xo.NORMAL){return this._addListener(new vr(t,e,s))}addOnce(t,e,s=Xo.NORMAL){return this._addListener(new vr(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 o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*we.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,we.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(!we._shared){const t=we._shared=new we;t.autoStart=!0,t._protected=!0}return we._shared}static get system(){if(!we._system){const t=we._system=new we;t.autoStart=!0,t._protected=!0}return we._system}};dd.targetFPMS=.06;let Ji=dd,wr;async function Ef(){return wr??(wr=(async()=>{var r;const t=Se.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(l=>{const h=document.createElement("video");h.onloadeddata=()=>l(h),h.onerror=()=>l(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.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 o=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,o),t.deleteFramebuffer(n),t.deleteTexture(s),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),o[0]<=o[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),wr}const rr=class ud extends Ie{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...ud.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),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Ji.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Ef(),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.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ji.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||(Ji.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ji.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};rr.extension=mt.TextureSource;rr.defaultOptions={...Ie.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};rr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Pf=rr;const Xi=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class If{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||fe(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=Xi(t);let n;for(let h=0;h<this.parsers.length;h++){const u=this.parsers[h];if(u.test(e)){n=u.getCacheableAssets(s,e);break}}const o=new Map(Object.entries(n||{}));n||s.forEach(h=>{o.set(h,e)});const r=[...o.keys()],l={cacheKeys:r,keys:s};s.forEach(h=>{this._cacheMap.set(h,l)}),r.forEach(h=>{const u=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==u&&fe("[Cache] already has key:",h),this._cache.set(h,o.get(h))})}remove(t){if(!this._cacheMap.has(t)){fe(`[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 Zi=new If,ka=[];Ut.handleByList(mt.TextureSource,ka);function fd(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n<ka.length;n++){const o=ka[n];if(o.test(e))return new o(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function Lf(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,n=e?i:{resource:i};if(!t&&Zi.has(s))return Zi.get(s);const o=new It({source:fd(n)});return o.on("destroy",()=>{Zi.has(s)&&Zi.remove(s)}),t||Zi.set(s,o),o}function Bf(i,t=!1){return typeof i=="string"?Zi.get(i):i instanceof Ie?new It({source:i}):Lf(i,t)}It.from=Bf;Ie.from=fd;Ut.add(ad,ld,cd,Pf,jo,hd,il);var pd=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(pd||{});function Re(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function mn(i){return i.split("?")[0].split("#")[0]}function Rf(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Df(i,t,e){return i.replace(new RegExp(Rf(t),"g"),e)}function $f(i,t){let e="",s=0,n=-1,o=0,r=-1;for(let l=0;l<=i.length;++l){if(l<i.length)r=i.charCodeAt(l);else{if(r===47)break;r=47}if(r===47){if(!(n===l-1||o===1))if(n!==l-1&&o===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=l,o=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=l,o=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,l)}`:e=i.slice(n+1,l),s=l-n-1;n=l,o=0}else r===46&&o!==-1?++o:o=-1}return e}const Xn={toPosix(i){return Df(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){Re(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(Re(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=mn(this.toPosix(t??Se.get().getBaseUrl())),n=mn(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?Xn.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(Re(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=$f(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return Re(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(Re(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(Re(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const o=this.getProtocol(i),r=i;i=i.slice(o.length);for(let l=i.length-1;l>=1;--l)if(t=i.charCodeAt(l),t===47){if(!n){s=l;break}}else n=!1;return s===-1?e?"/":this.isUrl(r)?o+i:o:e&&s===1?"//":o+i.slice(0,s)},rootname(i){Re(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){Re(i),t&&Re(t),i=mn(this.toPosix(i));let e=0,s=-1,n=!0,o;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let r=t.length-1,l=-1;for(o=i.length-1;o>=0;--o){const h=i.charCodeAt(o);if(h===47){if(!n){e=o+1;break}}else l===-1&&(n=!1,l=o+1),r>=0&&(h===t.charCodeAt(r)?--r===-1&&(s=o):(r=-1,s=l))}return e===s?s=l:s===-1&&(s=i.length),i.slice(e,s)}for(o=i.length-1;o>=0;--o)if(i.charCodeAt(o)===47){if(!n){e=o+1;break}}else s===-1&&(n=!1,s=o+1);return s===-1?"":i.slice(e,s)},extname(i){Re(i),i=mn(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,o=0;for(let r=i.length-1;r>=0;--r){const l=i.charCodeAt(r);if(l===47){if(!n){e=r+1;break}continue}s===-1&&(n=!1,s=r+1),l===46?t===-1?t=r:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||s===-1||o===0||o===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){Re(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=mn(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 o=-1,r=0,l=-1,h=!0,u=i.length-1,d=0;for(;u>=n;--u){if(e=i.charCodeAt(u),e===47){if(!h){r=u+1;break}continue}l===-1&&(h=!1,l=u+1),e===46?o===-1?o=u:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||l===-1||d===0||d===1&&o===l-1&&o===r+1?l!==-1&&(r===0&&s?t.base=t.name=i.slice(1,l):t.base=t.name=i.slice(r,l)):(r===0&&s?(t.name=i.slice(1,o),t.base=i.slice(1,l)):(t.name=i.slice(r,o),t.base=i.slice(r,l)),t.ext=i.slice(o,l)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function md(i,t,e,s,n){const o=t[e];for(let r=0;r<o.length;r++){const l=o[r];e<t.length-1?md(i.replace(s[e],l),t,e+1,s,n):n.push(i.replace(s[e],l))}}function zf(i){const t=/\{(.*?)\}/g,e=i.match(t),s=[];if(e){const n=[];e.forEach(o=>{const r=o.substring(1,o.length-1).split(",");n.push(r)}),md(i,n,0,e,s)}else s.push(i);return s}const Vl=i=>!Array.isArray(i);class gd{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 Xi(e||s,o=>typeof o=="string"?o:Array.isArray(o)?o.map(r=>(r==null?void 0:r.src)??r):o!=null&&o.src?o.src:o,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&fe("[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(([o,r])=>typeof r=="string"||Array.isArray(r)?{alias:o,src:r}:{alias:o,...r})),n.forEach(o=>{const r=o.src,l=o.alias;let h;if(typeof l=="string"){const u=this._createBundleAssetId(t,l);s.push(u),h=[l,u]}else{const u=l.map(d=>this._createBundleAssetId(t,d));s.push(...u),h=[...l,...u]}this.add({...o,alias:h,src:r})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=o=>{this.hasKey(o)&&fe(`[Resolver] already has key: ${o} overwriting`)},Xi(e).forEach(o=>{const{src:r}=o;let{data:l,format:h,loadParser:u,parser:d}=o;const p=Xi(r).map(x=>typeof x=="string"?zf(x):Array.isArray(x)?x:[x]),m=this.getAlias(o);Array.isArray(m)?m.forEach(s):s(m);const g=[],y=x=>{const w=this._parsers.find(S=>S.test(x));return{src:x,...w==null?void 0:w.parse(x)}};p.forEach(x=>{x.forEach(w=>{let S={};if(typeof w!="object"?S=y(w):(l=w.data??l,h=w.format??h,(w.loadParser||w.parser)&&(u=w.loadParser??u,d=w.parser??d),S={...y(w.src),...w}),!m)throw new Error(`[Resolver] alias is undefined for this asset: ${S.src}`);S=this._buildResolvedAsset(S,{aliases:m,data:l,format:h,loadParser:u,parser:d,progressSize:o.progressSize}),g.push(S)})}),m.forEach(x=>{this._assetMap[x]=g})})}resolveBundle(t){const e=Vl(t);t=Xi(t);const s={};return t.forEach(n=>{const o=this._bundles[n];if(o){const r=this.resolve(o),l={};for(const h in r){const u=r[h];l[this._extractAssetIdFromBundle(n,h)]=u}s[n]=l}}),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=Vl(t);t=Xi(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let o=this._assetMap[n];const r=this._getPreferredOrder(o);r==null||r.priority.forEach(l=>{r.params[l].forEach(h=>{const u=o.filter(d=>d[l]?d[l]===h:!1);u.length&&(o=u)})}),this._resolverHash[n]=o[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(o=>o.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:o,parser:r,format:l,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=Xn.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=o??t.loadParser,t.parser=r??t.parser,t.format=l??t.format??Ff(t.src),h!==void 0&&(t.progressSize=h),t}}gd.RETINA_PREFIX=/@([0-9\.]+)x/;function Ff(i){return i.split(".").pop().split("?").shift().split("#").shift()}const Yl=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},yd=class Wn{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof Ie&&(s={texture:t,data:e});const{texture:n,data:o,cachePrefix:r=""}=s;this.cachePrefix=r,this._texture=n instanceof It?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=o;const l=parseFloat(o.meta.scale);l?(this.resolution=l,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<=Wn.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:Wn.BATCH_SIZE;for(;s-t<n&&s<this._frameKeys.length;){const o=this._frameKeys[s],r=this._frames[o],l=r.frame;if(l){let h=null,u=null;const d=r.trimmed!==!1&&r.sourceSize?r.sourceSize:r.frame,p=new Ht(0,0,Math.floor(d.w)/this.resolution,Math.floor(d.h)/this.resolution);r.rotated?h=new Ht(Math.floor(l.x)/this.resolution,Math.floor(l.y)/this.resolution,Math.floor(l.h)/this.resolution,Math.floor(l.w)/this.resolution):h=new Ht(Math.floor(l.x)/this.resolution,Math.floor(l.y)/this.resolution,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution),r.trimmed!==!1&&r.spriteSourceSize&&(u=new Ht(Math.floor(r.spriteSourceSize.x)/this.resolution,Math.floor(r.spriteSourceSize.y)/this.resolution,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution)),this.textures[o]=new It({source:this.textureSource,frame:h,orig:p,trim:u,rotate:r.rotated?2:0,defaultAnchor:r.anchor,defaultBorders:r.borders,label:o.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*Wn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Wn.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};yd.BATCH_SIZE=1e3;let jl=yd;const Nf=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function bd(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=Xn.dirname(i[0]);t.linkedSheets.forEach((o,r)=>{const l=bd([`${n}/${t.data.meta.related_multi_packs[r]}`],o,!0);Object.assign(s,l)})}return s}const Wf={extension:mt.Asset,cache:{test:i=>i instanceof jl,getCacheableAssets:(i,t)=>bd(i,t,!1)},resolver:{extension:{type:mt.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&Nf.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=gd.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:mt.LoadParser,priority:pd.Normal,name:"spritesheetLoader"},async testParse(i,t){return Xn.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var p,m;const{texture:s,imageFilename:n,textureOptions:o,cachePrefix:r}=(t==null?void 0:t.data)??{};let l=Xn.dirname(t.src);l&&l.lastIndexOf("/")!==l.length-1&&(l+="/");let h;if(s instanceof It)h=s;else{const g=Yl(l+(n??i.meta.image),t.src);h=(await e.load([{src:g,data:o}]))[g]}const u=new jl({texture:h.source,data:i,cachePrefix:r});await u.parse();const d=(p=i==null?void 0:i.meta)==null?void 0:p.related_multi_packs;if(Array.isArray(d)){const g=[];for(const x of d){if(typeof x!="string")continue;let w=l+x;(m=t.data)!=null&&m.ignoreMultiPack||(w=Yl(w,t.src),g.push(e.load({src:w,data:{textureOptions:o,ignoreMultiPack:!0}})))}const y=await Promise.all(g);u.linkedSheets=y,y.forEach(x=>{x.linkedSheets=[u].concat(u.linkedSheets.filter(w=>w!==x))})}return u},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};Ut.add(Wf);const Sr=Object.create(null),Xl=Object.create(null);function al(i,t){let e=Xl[i];return e===void 0&&(Sr[t]===void 0&&(Sr[t]=1),Xl[i]=e=Sr[t]++),e}let Ni;function _d(){return(!Ni||Ni!=null&&Ni.isContextLost())&&(Ni=Se.get().createCanvas().getContext("webgl",{})),Ni}let fo;function Gf(){if(!fo){fo="mediump";const i=_d();i&&i.getShaderPrecisionFormat&&(fo=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return fo}function Of(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 Hf(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 Uf(i,t){return t?`#version 300 es
22
+ ${i}`:i}const qf={},Vf={};function Yf(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?qf:Vf;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 jf(i,t){return t?i.replace("#version 300 es",""):i}const kr={stripVersion:jf,ensurePrecision:Hf,addProgramDefines:Of,setProgramName:Yf,insertVersion:Uf},gn=Object.create(null),xd=class Ta{constructor(t){t={...Ta.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Gf()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,o=t.vertex;Object.keys(kr).forEach(r=>{const l=s[r];n=kr[r](n,l,!0),o=kr[r](o,l,!1)}),this.fragment=n,this.vertex=o,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=al(`${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,gn[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return gn[e]||(gn[e]=new Ta(t),gn[e]._cacheKey=e),gn[e]}};xd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let vd=xd;const Zl={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 Xf(i){return Zl[i]??Zl.float32}const Zf={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"},Kl=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Ql(i,t){let e;for(;(e=Kl.exec(i))!==null;){const s=Zf[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:s,stride:Xf(s).stride,offset:0,instance:!1,start:0}}Kl.lastIndex=0}function Kf(i){return i.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Qf({source:i,entryPoint:t}){const e={},s=Kf(i),n=s.indexOf(`fn ${t}(`);if(n===-1)return e;const o=s.indexOf("->",n);if(o===-1)return e;const r=s.substring(n,o);if(Ql(r,e),Object.keys(e).length===0){const l=r.match(/\(\s*\w+\s*:\s*(\w+)/);if(l){const h=l[1],u=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),d=s.match(u);d&&Ql(d[1],e)}}return e}function Tr(i){var p,m;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,o=/:\s*([\w<>]+)/,r=/struct\s+(\w+)\s*{([^}]+)}/g,l=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,u=(p=i.match(t))==null?void 0:p.map(g=>({group:parseInt(g.match(e)[1],10),binding:parseInt(g.match(s)[1],10),name:g.match(n)[2],isUniform:g.match(n)[1]==="<uniform>",type:g.match(o)[1]}));if(!u)return{groups:[],structs:[]};const d=((m=i.match(r))==null?void 0:m.map(g=>{const y=g.match(h)[1],x=g.match(l).reduce((w,S)=>{const[A,L]=S.split(":");return w[A.trim()]=L.trim(),w},{});return x?{name:y,members:x}:null}).filter(({name:g})=>u.some(y=>y.type===g||y.type.includes(`<${g}>`))))??[];return{groups:u,structs:d}}var Ii=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Ii||{});function Jf({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:Ii.VERTEX|Ii.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Ii.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:Ii.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:Ii.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:Ii.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function tp({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 ep(i,t){const e=new Set,s=new Set,n=[...i.structs,...t.structs].filter(r=>e.has(r.name)?!1:(e.add(r.name),!0)),o=[...i.groups,...t.groups].filter(r=>{const l=`${r.name}-${r.binding}`;return s.has(l)?!1:(s.add(l),!0)});return{structs:n,groups:o}}const yn=Object.create(null);class ar{constructor(t){var l,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:o,name:r}=t;if(this.name=r,this.fragment=e,this.vertex=s,e.source===s.source){const u=Tr(e.source);this.structsAndGroups=u}else{const u=Tr(s.source),d=Tr(e.source);this.structsAndGroups=ep(u,d)}this.layout=n??tp(this.structsAndGroups),this.gpuLayout=o??Jf(this.structsAndGroups),this.autoAssignGlobalUniforms=((l=this.layout[0])==null?void 0:l.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=al(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Qf(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,yn[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return yn[e]||(yn[e]=new ar(t),yn[e]._cacheKey=e),yn[e]}}const wd=["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>"],sp=wd.reduce((i,t)=>(i[t]=!0,i),{});function ip(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 Sd=class kd{constructor(t,e){this._touched=0,this.uid=Gt("uniform"),this._resourceType="uniformGroup",this._resourceId=Gt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...kd.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const o=t[n];if(o.name=n,o.size=o.size??1,!sp[o.type]){const r=o.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(r){const[,l,h]=r;throw new Error(`Uniform type ${o.type} is not supported. Use type: '${l}', size: ${h} instead.`)}throw new Error(`Uniform type ${o.type} is not supported. Supported uniform types are: ${wd.join(", ")}`)}o.value??(o.value=ip(o.type,o.size)),s[n]=o.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=al(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Sd.defaultOptions={ubo:!1,isStatic:!1};let Td=Sd;class Fo{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){var n,o;const s=this.resources[e];t!==s&&((n=s==null?void 0:s.off)==null||n.call(s,"change",this.onResourceChange,this),(o=t.on)==null||o.call(t,"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(){var e;const t=this.resources;for(const s in t){const n=t[s];(e=n==null?void 0:n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var Ca=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.CANVAS=4]="CANVAS",i[i.BOTH=3]="BOTH",i))(Ca||{});class ll extends Ze{constructor(t){super(),this.uid=Gt("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:n,resources:o,compatibleRenderers:r,groupMap:l}=t;this.gpuProgram=e,this.glProgram=s,r===void 0&&(r=0,e&&(r|=Ca.WEBGPU),s&&(r|=Ca.WEBGL)),this.compatibleRenderers=r;const h={};if(!o&&!n&&(o={}),o&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!l)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&l)for(const u in l)for(const d in l[u]){const p=l[u][d];h[p]={group:u,binding:d,name:p}}else if(e&&n&&!l){const u=e.structsAndGroups.groups;l={},u.forEach(d=>{l[d.group]=l[d.group]||{},l[d.group][d.binding]=d.name,h[d.name]=d})}else if(o){n={},l={},e&&e.structsAndGroups.groups.forEach(p=>{l[p.group]=l[p.group]||{},l[p.group][p.binding]=p.name,h[p.name]=p});let u=0;for(const d in o)h[d]||(n[99]||(n[99]=new Fo,this._ownedBindGroups.push(n[99])),h[d]={group:99,binding:u,name:d},l[99]=l[99]||{},l[99][u]=d,u++);for(const d in o){const p=d;let m=o[d];!m.source&&!m._resourceType&&(m=new Td(m));const g=h[p];g&&(n[g.group]||(n[g.group]=new Fo,this._ownedBindGroups.push(n[g.group])),n[g.group].setResource(m,g.binding))}}this.groups=n,this._uniformBindMap=l,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,o;(n=this._uniformBindMap)[e]||(n[e]={}),(o=this._uniformBindMap[e])[s]||(o[s]=t),this.groups[e]||(this.groups[e]=new Fo,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const o=e[n];Object.defineProperty(s,o.name,{get(){return t[o.group].getResource(o.binding)},set(r){t[o.group].setResource(r,o.binding)}})}return s}destroy(t=!1){var e,s;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:s,...n}=t;let o,r;return e&&(o=ar.from(e)),s&&(r=vd.from(s)),new ll({gpuProgram:o,glProgram:r,...n})}}const np={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},Cr=0,Ar=1,Mr=2,Er=3,Pr=4,Ir=5,Aa=class Cd{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Cr)}set blend(t){!!(this.data&1<<Cr)!==t&&(this.data^=1<<Cr)}get offsets(){return!!(this.data&1<<Ar)}set offsets(t){!!(this.data&1<<Ar)!==t&&(this.data^=1<<Ar)}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<<Mr)}set culling(t){!!(this.data&1<<Mr)!==t&&(this.data^=1<<Mr)}get depthTest(){return!!(this.data&1<<Er)}set depthTest(t){!!(this.data&1<<Er)!==t&&(this.data^=1<<Er)}get depthMask(){return!!(this.data&1<<Ir)}set depthMask(t){!!(this.data&1<<Ir)!==t&&(this.data^=1<<Ir)}get clockwiseFrontFace(){return!!(this.data&1<<Pr)}set clockwiseFrontFace(t){!!(this.data&1<<Pr)!==t&&(this.data^=1<<Pr)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=np[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 Cd;return t.depthTest=!1,t.blend=!0,t}};Aa.default2d=Aa.for2d();let Ad=Aa;const Ma=[];Ut.handleByNamedList(mt.Environment,Ma);async function op(i){if(!i)for(let t=0;t<Ma.length;t++){const e=Ma[t];if(e.value.test()){await e.value.load();return}}}let bn;function rp(){if(typeof bn=="boolean")return bn;try{bn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{bn=!1}return bn}function Jl(i,t,e=2){const s=t&&t.length,n=s?t[0]*e:i.length;let o=Md(i,0,n,e,!0);const r=[];if(!o||o.next===o.prev)return r;let l,h,u;if(s&&(o=dp(i,t,o,e)),i.length>80*e){l=i[0],h=i[1];let d=l,p=h;for(let m=e;m<n;m+=e){const g=i[m],y=i[m+1];g<l&&(l=g),y<h&&(h=y),g>d&&(d=g),y>p&&(p=y)}u=Math.max(d-l,p-h),u=u!==0?32767/u:0}return Zn(o,r,e,l,h,u,0),r}function Md(i,t,e,s,n){let o;if(n===wp(i,t,e,s)>0)for(let r=t;r<e;r+=s)o=tc(r/s|0,i[r],i[r+1],o);else for(let r=e-s;r>=t;r-=s)o=tc(r/s|0,i[r],i[r+1],o);return o&&hn(o,o.next)&&(Qn(o),o=o.next),o}function $i(i,t){if(!i)return i;t||(t=i);let e=i,s;do if(s=!1,!e.steiner&&(hn(e,e.next)||zt(e.prev,e,e.next)===0)){if(Qn(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function Zn(i,t,e,s,n,o,r){if(!i)return;!r&&o&&gp(i,s,n,o);let l=i;for(;i.prev!==i.next;){const h=i.prev,u=i.next;if(o?lp(i,s,n,o):ap(i)){t.push(h.i,i.i,u.i),Qn(i),i=u.next,l=u.next;continue}if(i=u,i===l){r?r===1?(i=cp($i(i),t),Zn(i,t,e,s,n,o,2)):r===2&&hp(i,t,e,s,n,o):Zn($i(i),t,e,s,n,o,1);break}}}function ap(i){const t=i.prev,e=i,s=i.next;if(zt(t,e,s)>=0)return!1;const n=t.x,o=e.x,r=s.x,l=t.y,h=e.y,u=s.y,d=Math.min(n,o,r),p=Math.min(l,h,u),m=Math.max(n,o,r),g=Math.max(l,h,u);let y=s.next;for(;y!==t;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=g&&Gn(n,l,o,h,r,u,y.x,y.y)&&zt(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function lp(i,t,e,s){const n=i.prev,o=i,r=i.next;if(zt(n,o,r)>=0)return!1;const l=n.x,h=o.x,u=r.x,d=n.y,p=o.y,m=r.y,g=Math.min(l,h,u),y=Math.min(d,p,m),x=Math.max(l,h,u),w=Math.max(d,p,m),S=Ea(g,y,t,e,s),A=Ea(x,w,t,e,s);let L=i.prevZ,I=i.nextZ;for(;L&&L.z>=S&&I&&I.z<=A;){if(L.x>=g&&L.x<=x&&L.y>=y&&L.y<=w&&L!==n&&L!==r&&Gn(l,d,h,p,u,m,L.x,L.y)&&zt(L.prev,L,L.next)>=0||(L=L.prevZ,I.x>=g&&I.x<=x&&I.y>=y&&I.y<=w&&I!==n&&I!==r&&Gn(l,d,h,p,u,m,I.x,I.y)&&zt(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;L&&L.z>=S;){if(L.x>=g&&L.x<=x&&L.y>=y&&L.y<=w&&L!==n&&L!==r&&Gn(l,d,h,p,u,m,L.x,L.y)&&zt(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;I&&I.z<=A;){if(I.x>=g&&I.x<=x&&I.y>=y&&I.y<=w&&I!==n&&I!==r&&Gn(l,d,h,p,u,m,I.x,I.y)&&zt(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cp(i,t){let e=i;do{const s=e.prev,n=e.next.next;!hn(s,n)&&Pd(s,e,e.next,n)&&Kn(s,n)&&Kn(n,s)&&(t.push(s.i,e.i,n.i),Qn(e),Qn(e.next),e=i=n),e=e.next}while(e!==i);return $i(e)}function hp(i,t,e,s,n,o){let r=i;do{let l=r.next.next;for(;l!==r.prev;){if(r.i!==l.i&&_p(r,l)){let h=Id(r,l);r=$i(r,r.next),h=$i(h,h.next),Zn(r,t,e,s,n,o,0),Zn(h,t,e,s,n,o,0);return}l=l.next}r=r.next}while(r!==i)}function dp(i,t,e,s){const n=[];for(let o=0,r=t.length;o<r;o++){const l=t[o]*s,h=o<r-1?t[o+1]*s:i.length,u=Md(i,l,h,s,!1);u===u.next&&(u.steiner=!0),n.push(bp(u))}n.sort(up);for(let o=0;o<n.length;o++)e=fp(n[o],e);return e}function up(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 fp(i,t){const e=pp(i,t);if(!e)return t;const s=Id(e,i);return $i(s,s.next),$i(e,e.next)}function pp(i,t){let e=t;const s=i.x,n=i.y;let o=-1/0,r;if(hn(i,e))return e;do{if(hn(i,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const p=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(p<=s&&p>o&&(o=p,r=e.x<e.next.x?e:e.next,p===s))return r}e=e.next}while(e!==t);if(!r)return null;const l=r,h=r.x,u=r.y;let d=1/0;e=r;do{if(s>=e.x&&e.x>=h&&s!==e.x&&Ed(n<u?s:o,n,h,u,n<u?o:s,n,e.x,e.y)){const p=Math.abs(n-e.y)/(s-e.x);Kn(e,i)&&(p<d||p===d&&(e.x>r.x||e.x===r.x&&mp(r,e)))&&(r=e,d=p)}e=e.next}while(e!==l);return r}function mp(i,t){return zt(i.prev,i,t.prev)<0&&zt(t.next,i,i.next)<0}function gp(i,t,e,s){let n=i;do n.z===0&&(n.z=Ea(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,yp(n)}function yp(i){let t,e=1;do{let s=i,n;i=null;let o=null;for(t=0;s;){t++;let r=s,l=0;for(let u=0;u<e&&(l++,r=r.nextZ,!!r);u++);let h=e;for(;l>0||h>0&&r;)l!==0&&(h===0||!r||s.z<=r.z)?(n=s,s=s.nextZ,l--):(n=r,r=r.nextZ,h--),o?o.nextZ=n:i=n,n.prevZ=o,o=n;s=r}o.nextZ=null,e*=2}while(t>1);return i}function Ea(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 bp(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 Ed(i,t,e,s,n,o,r,l){return(n-r)*(t-l)>=(i-r)*(o-l)&&(i-r)*(s-l)>=(e-r)*(t-l)&&(e-r)*(o-l)>=(n-r)*(s-l)}function Gn(i,t,e,s,n,o,r,l){return!(i===r&&t===l)&&Ed(i,t,e,s,n,o,r,l)}function _p(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!xp(i,t)&&(Kn(i,t)&&Kn(t,i)&&vp(i,t)&&(zt(i.prev,i,t.prev)||zt(i,t.prev,t))||hn(i,t)&&zt(i.prev,i,i.next)>0&&zt(t.prev,t,t.next)>0)}function zt(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function hn(i,t){return i.x===t.x&&i.y===t.y}function Pd(i,t,e,s){const n=mo(zt(i,t,e)),o=mo(zt(i,t,s)),r=mo(zt(e,s,i)),l=mo(zt(e,s,t));return!!(n!==o&&r!==l||n===0&&po(i,e,t)||o===0&&po(i,s,t)||r===0&&po(e,i,s)||l===0&&po(e,t,s))}function po(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 mo(i){return i>0?1:i<0?-1:0}function xp(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&&Pd(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Kn(i,t){return zt(i.prev,i,i.next)<0?zt(i,t,i.next)>=0&&zt(i,i.prev,t)>=0:zt(i,t,i.prev)<0||zt(i,i.next,t)<0}function vp(i,t){let e=i,s=!1;const n=(i.x+t.x)/2,o=(i.y+t.y)/2;do e.y>o!=e.next.y>o&&e.next.y!==e.y&&n<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Id(i,t){const e=Pa(i.i,i.x,i.y),s=Pa(t.i,t.x,t.y),n=i.next,o=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,o.next=s,s.prev=o,s}function tc(i,t,e,s){const n=Pa(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 Qn(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 Pa(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function wp(i,t,e,s){let n=0;for(let o=t,r=e-s;o<e;o+=s)n+=(i[r]-i[o])*(i[o+1]+i[r+1]),r=o;return n}const Sp=Jl.default||Jl;var Ld=(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))(Ld||{});class kp{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,o,r,l,h){const{name:u,items:d}=this;for(let p=0,m=d.length;p<m;p++)d[p][u](t,e,s,n,o,r,l,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 Tp=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Bd=class Rd extends Ze{constructor(t){super(),this.tick=0,this.uid=Gt("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=[...Tp,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await op(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={...Rd.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 Rt&&(s={container:s},e&&(wt(Wt,"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:Yt.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=Ld.ALL);const{clear:s,clearColor:n,target:o,mipLevel:r,layer:l}=t;Yt.shared.setValue(n??this.background.colorRgba),e.renderTarget.clear(o,s,Yt.shared.toArray(),r??0,l??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 kp(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,o)=>(n[o.name]=o.value,n),{});t.forEach(n=>{const o=n.value,r=n.name,l=s[r];this.renderPipes[r]=new o(this,l?new l:null),this.runners.destroy.add(this.renderPipes[r])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&io.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(!rp())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()}};Bd.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Dd=Bd,go;function Cp(i){return go!==void 0||(go=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Dd.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Se.get().getWebGLRenderingContext())return!1;let n=Se.get().createCanvas().getContext("webgl",t);const o=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const r=n.getExtension("WEBGL_lose_context");r&&r.loseContext()}return n=null,o}catch{return!1}})()),go}let yo;async function Ap(i={}){return yo!==void 0||(yo=await(async()=>{const t=Se.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),yo}const ec=["webgl","webgpu","canvas"];async function Mp(i){let t=[];i.preference?(t.push(i.preference),ec.forEach(o=>{o!==i.preference&&t.push(o)})):t=ec.slice();let e,s={};for(let o=0;o<t.length;o++){const r=t[o];if(r==="webgpu"&&await Ap()){const{WebGPURenderer:l}=await Hn(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-C1HbrllR.js");return{WebGPURenderer:h}},__vite__mapDeps([3,4,5,2]));e=l,s={...i,...i.webgpu};break}else if(r==="webgl"&&Cp(i.failIfMajorPerformanceCaveat??Dd.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await Hn(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-DUWXDPIX.js");return{WebGLRenderer:h}},__vite__mapDeps([6,4,5,2]));e=l,s={...i,...i.webgl};break}else if(r==="canvas"){const{CanvasRenderer:l}=await Hn(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer-B0w6SYyW.js");return{CanvasRenderer:h}},__vite__mapDeps([7,5,2]));e=l,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 $d="8.17.0";class zd{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,$d)}static destroy(){}}zd.extension=mt.Application;class Ep{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,$d)}destroy(){this._renderer=null}}Ep.extension={type:[mt.WebGLSystem,mt.WebGPUSystem],name:"initHook",priority:-10};class Fd{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:o}=this._resizeTo;e=n,s=o}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}}Fd.extension=mt.Application;class Nd{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,Xo.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Ji.shared:new Ji,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Nd.extension=mt.Application;Ut.add(Fd);Ut.add(Nd);const Wd=class Ia{constructor(...t){this.stage=new Rt,t[0]!==void 0&&wt(Wt,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new Rt),this.renderer=await Mp(t),Ia._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return wt(Wt,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=Ia._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}};Wd._plugins=[];let Gd=Wd;Ut.handleByList(mt.Application,Gd._plugins);Ut.add(zd);var Lr,sc;function Pp(){if(sc)return Lr;sc=1,Lr=e;var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(o){var r=[];return o.replace(t,function(l,h,u){var d=h.toLowerCase();for(u=n(u),d=="m"&&u.length>2&&(r.push([h].concat(u.splice(0,2))),d="l",h=h=="m"?"l":"L");;){if(u.length==i[d])return u.unshift(h),r.push(u);if(u.length<i[d])throw new Error("malformed path data");r.push([h].concat(u.splice(0,i[d])))}}),r}var s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function n(o){var r=o.match(s);return r?r.map(Number):[]}return Lr}var Ip=Pp();const Lp=Wh(Ip);function Bp(i,t){const e=Lp(i),s=[];let n=null,o=0,r=0;for(let l=0;l<e.length;l++){const h=e[l],u=h[0],d=h;switch(u){case"M":o=d[1],r=d[2],t.moveTo(o,r);break;case"m":o+=d[1],r+=d[2],t.moveTo(o,r);break;case"H":o=d[1],t.lineTo(o,r);break;case"h":o+=d[1],t.lineTo(o,r);break;case"V":r=d[1],t.lineTo(o,r);break;case"v":r+=d[1],t.lineTo(o,r);break;case"L":o=d[1],r=d[2],t.lineTo(o,r);break;case"l":o+=d[1],r+=d[2],t.lineTo(o,r);break;case"C":o=d[5],r=d[6],t.bezierCurveTo(d[1],d[2],d[3],d[4],o,r);break;case"c":t.bezierCurveTo(o+d[1],r+d[2],o+d[3],r+d[4],o+d[5],r+d[6]),o+=d[5],r+=d[6];break;case"S":o=d[3],r=d[4],t.bezierCurveToShort(d[1],d[2],o,r);break;case"s":t.bezierCurveToShort(o+d[1],r+d[2],o+d[3],r+d[4]),o+=d[3],r+=d[4];break;case"Q":o=d[3],r=d[4],t.quadraticCurveTo(d[1],d[2],o,r);break;case"q":t.quadraticCurveTo(o+d[1],r+d[2],o+d[3],r+d[4]),o+=d[3],r+=d[4];break;case"T":o=d[1],r=d[2],t.quadraticCurveToShort(o,r);break;case"t":o+=d[1],r+=d[2],t.quadraticCurveToShort(o,r);break;case"A":o=d[6],r=d[7],t.arcToSvg(d[1],d[2],d[3],d[4],d[5],o,r);break;case"a":o+=d[6],r+=d[7],t.arcToSvg(d[1],d[2],d[3],d[4],d[5],o,r);break;case"Z":case"z":t.closePath(),s.length>0&&(n=s.pop(),n?(o=n.startX,r=n.startY):(o=0,r=0)),n=null;break;default:fe(`Unknown SVG path command: ${u}`)}u!=="Z"&&u!=="z"&&n===null&&(n={startX:o,startY:r},s.push(n))}return t}class cl{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new cl(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,o=this.y-e;return n*=n,o*=o,n+o<=s}strokeContains(t,e,s,n=.5){if(this.radius===0)return!1;const o=this.x-t,r=this.y-e,l=this.radius,h=(1-n)*s,u=Math.sqrt(o*o+r*r);return u<=l+h&&u>l-(s-h)}getBounds(t){return t||(t=new Ht),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 hl{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 hl(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:o,halfHeight:r}=this;if(o<=0||r<=0)return!1;const l=s*(1-n),h=s-l,u=o-h,d=r-h,p=o+l,m=r+l,g=t-this.x,y=e-this.y,x=g*g/(u*u)+y*y/(d*d),w=g*g/(p*p)+y*y/(m*m);return x>1&&w<=1}getBounds(t){return t||(t=new Ht),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 Rp(i,t,e,s,n,o){const r=i-e,l=t-s,h=n-e,u=o-s,d=r*h+l*u,p=h*h+u*u;let m=-1;p!==0&&(m=d/p);let g,y;m<0?(g=e,y=s):m>1?(g=n,y=o):(g=e+m*h,y=s+m*u);const x=i-g,w=t-y;return x*x+w*w}let Dp,$p;class qn{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,o=e.length;n<o;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 o=e[n],r=e[n+1],l=e[(n+2)%s],h=e[(n+3)%s];t+=(l-o)*(h+r)}return t<0}containsPolygon(t){const e=this.getBounds(Dp),s=t.getBounds($p);if(!e.containsRect(s))return!1;const n=t.points;for(let o=0;o<n.length;o+=2){const r=n[o],l=n[o+1];if(!this.contains(r,l))return!1}return!0}clone(){const t=this.points.slice(),e=new qn(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const n=this.points.length/2;for(let o=0,r=n-1;o<n;r=o++){const l=this.points[o*2],h=this.points[o*2+1],u=this.points[r*2],d=this.points[r*2+1];h>e!=d>e&&t<(u-l)*((e-h)/(d-h))+l&&(s=!s)}return s}strokeContains(t,e,s,n=.5){const o=s*s,r=o*(1-n),l=o-r,{points:h}=this,u=h.length-(this.closePath?0:2);for(let d=0;d<u;d+=2){const p=h[d],m=h[d+1],g=h[(d+2)%h.length],y=h[(d+3)%h.length],x=Rp(t,e,p,m,g,y),w=Math.sign((g-p)*(e-m)-(y-m)*(t-p));if(x<=(w<0?l:r))return!0}return!1}getBounds(t){t||(t=new Ht);const e=this.points;let s=1/0,n=-1/0,o=1/0,r=-1/0;for(let l=0,h=e.length;l<h;l+=2){const u=e[l],d=e[l+1];s=u<s?u:s,n=u>n?u:n,o=d<o?d:o,r=d>r?d:r}return t.x=s,t.width=n-s,t.y=o,t.height=r-o,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 wt("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return wt("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 bo=(i,t,e,s,n,o,r)=>{const l=i-e,h=t-s,u=Math.sqrt(l*l+h*h);return u>=n-o&&u<=n+r};class dl{constructor(t=0,e=0,s=0,n=0,o=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=o}getBounds(t){return t||(t=new Ht),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new dl(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),o=e-(this.y+s);const r=s*s;if(n*n+o*o<=r||(n=t-(this.x+this.width-s),n*n+o*o<=r)||(o=e-(this.y+this.height-s),n*n+o*o<=r)||(n=t-(this.x+s),n*n+o*o<=r))return!0}return!1}strokeContains(t,e,s,n=.5){const{x:o,y:r,width:l,height:h,radius:u}=this,d=s*(1-n),p=s-d,m=o+u,g=r+u,y=l-u*2,x=h-u*2,w=o+l,S=r+h;return(t>=o-d&&t<=o+p||t>=w-p&&t<=w+d)&&e>=g&&e<=g+x||(e>=r-d&&e<=r+p||e>=S-p&&e<=S+d)&&t>=m&&t<=m+y?!0:t<m&&e<g&&bo(t,e,m,g,u,p,d)||t>w-u&&e<g&&bo(t,e,w-u,g,u,p,d)||t>w-u&&e>S-u&&bo(t,e,w-u,S-u,u,p,d)||t<m&&e>S-u&&bo(t,e,m,S-u,u,p,d)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Od={};function zp(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 Od[s]||Fp(i,t,s,e)}function Fp(i,t,e,s){const n={};let o=0;for(let l=0;l<s;l++){const h=l<t?i[l]:It.EMPTY.source;n[o++]=h.source,n[o++]=h.style}const r=new Fo(n);return Od[e]=r,r}class ic{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 nc(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 Np={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var Wp=(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))(Wp||{});function oc(i,t){return t.alphaMode==="no-premultiply-alpha"&&Np[i]||i}const Gp=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
24
+ `);function Op(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 Hp(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=Gp.replace(/%forloop%/gi,Op(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 Wi=null;function Up(){var t;if(Wi)return Wi;const i=_d();return Wi=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),Wi=Hp(Wi,i),(t=i.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Wi}class qp{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 Vp{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new qp,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 Vn=[];let Zo=0;io.register({clear:()=>{if(Vn.length>0)for(const i of Vn)i&&i.destroy();Vn.length=0,Zo=0}});function rc(){return Zo>0?Vn[--Zo]:new Vp}function ac(i){i.elements=null,Vn[Zo++]=i}let _n=0;const Hd=class Ud{constructor(t){this.uid=Gt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...Ud.defaultOptions,...t},t.maxTextures||(wt("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Up());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new ic(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++)ac(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=rc(),n=s.textures;n.clear();const o=e[this.elementStart];let r=oc(o.blendMode,o.texture._source),l=o.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,u=this.attributeBuffer.uint32View,d=this.indexBuffer;let p=this._batchIndexSize,m=this._batchIndexStart,g="startBatch",y=[];const x=this.maxTextures;for(let w=this.elementStart;w<this.elementSize;++w){const S=e[w];e[w]=null;const L=S.texture._source,I=oc(S.blendMode,L),O=r!==I||l!==S.topology;if(L._batchTick===_n&&!O){S._textureId=L._textureBindLocation,p+=S.indexSize,S.packAsQuad?(this.packQuadAttributes(S,h,u,S._attributeStart,S._textureId),this.packQuadIndex(d,S._indexStart,S._attributeStart/this.vertexSize)):(this.packAttributes(S,h,u,S._attributeStart,S._textureId),this.packIndex(S,d,S._indexStart,S._attributeStart/this.vertexSize)),S._batch=s,y.push(S);continue}L._batchTick=_n,(n.count>=x||O)&&(this._finishBatch(s,m,p-m,n,r,l,t,g,y),g="renderBatch",m=p,r=I,l=S.topology,s=rc(),n=s.textures,n.clear(),y=[],++_n),S._textureId=L._textureBindLocation=n.count,n.ids[L.uid]=n.count,n.textures[n.count++]=L,S._batch=s,y.push(S),p+=S.indexSize,S.packAsQuad?(this.packQuadAttributes(S,h,u,S._attributeStart,S._textureId),this.packQuadIndex(d,S._indexStart,S._attributeStart/this.vertexSize)):(this.packAttributes(S,h,u,S._attributeStart,S._textureId),this.packIndex(S,d,S._indexStart,S._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,m,p-m,n,r,l,t,g,y),m=p,++_n),this.elementStart=this.elementSize,this._batchIndexStart=m,this._batchIndexSize=p}_finishBatch(t,e,s,n,o,r,l,h,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=n,t.blendMode=o,t.topology=r,t.start=e,t.size=s,t.elements=u,++_n,this.batches[this.batchIndex++]=t,l.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 ic(e);nc(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 o=0;o<e.length;o++)n[o]=e[o];else nc(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 o=t.indices,r=t.indexSize,l=t.indexOffset,h=t.attributeOffset;for(let u=0;u<r;u++)e[s++]=n+o[u+l]-h}destroy(t={}){var e;if(this.batches!==null){for(let s=0;s<this.batchIndex;s++)ac(this.batches[s]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let s=0;s<this._elements.length;s++)this._elements[s]&&(this._elements[s]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};Hd.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Yp=Hd;var me=(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))(me||{});class Jn extends Ze{constructor(t){let{data:e,size:s}=t;const{usage:n,label:o,shrinkToFit:r}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=Gt("buffer"),this._resourceType="buffer",this._resourceId=Gt("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==null?void 0:e.byteLength);const l=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:l,label:o},this.shrinkToFit=r??!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&me.STATIC)}set static(t){t?this.descriptor.usage|=me.STATIC:this.descriptor.usage&=~me.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=Gt("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(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||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 qd(i,t){if(!(i instanceof Jn)){let e=t?me.INDEX:me.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=me.INDEX|me.COPY_DST):(i=new Float32Array(i),e=me.VERTEX|me.COPY_DST)),i=new Jn({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function jp(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 o=1/0,r=1/0,l=-1/0,h=-1/0;const u=n.BYTES_PER_ELEMENT,d=(s.offset||0)/u,p=(s.stride||8)/u;for(let m=d;m<n.length;m+=p){const g=n[m],y=n[m+1];g>l&&(l=g),y>h&&(h=y),g<o&&(o=g),y<r&&(r=y)}return e.minX=o,e.minY=r,e.maxX=l,e.maxY=h,e}function Xp(i){return(i instanceof Jn||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=qd(i.buffer,!1),i}class Zp extends Ze{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Gt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Pe,this._boundsDirty=!0;const{attributes:e,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},e)for(const o in e)this.addAttribute(o,e[o]);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=Xp(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=qd(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,jp(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(s=>s.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Kp=new Float32Array(1),Qp=new Uint32Array(1);class Jp extends Zp{constructor(){const e=new Jn({data:Kp,label:"attribute-batch-buffer",usage:me.VERTEX|me.COPY_DST,shrinkToFit:!1}),s=new Jn({data:Qp,label:"index-batch-buffer",usage:me.INDEX|me.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 lc(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),o=t[n];if(o){let r=i[s];s==="header"&&(r=r.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&o.push(`//----${e}----//`),o.push(r)}else fe(`${s} placement hook does not exist in shader`)}}const tm=/\{\{(.*?)\}\}/g;function cc(i){var s;const t={};return(((s=i.match(tm))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function hc(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function dc(i,t,e=!1){const s=[];hc(t,s),i.forEach(l=>{l.header&&hc(l.header,s)});const n=s;e&&n.sort();const o=n.map((l,h)=>` @location(${h}) ${l},`).join(`
26
+ `);let r=t.replace(/@in\s+[^;]+;\s*/g,"");return r=r.replace("{{in}}",`
27
+ ${o}
28
+ `),r}function uc(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function em(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function sm(i){const t=/@.*?\s+/g;return i.replace(t,"")}function im(i,t){const e=[];uc(t,e),i.forEach(h=>{h.header&&uc(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
29
+ `),o=e.sort().map(h=>` var ${sm(h)};`).join(`
30
+ `),r=`return VSOutput(
31
+ ${e.sort().map(h=>` ${em(h)}`).join(`,
32
+ `)});`;let l=t.replace(/@out\s+[^;]+;\s*/g,"");return l=l.replace("{{struct}}",`
33
+ ${n}
34
+ `),l=l.replace("{{start}}",`
35
+ ${o}
36
+ `),l=l.replace("{{return}}",`
37
+ ${r}
38
+ `),l}function fc(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 mi=Object.create(null),Br=new Map;let nm=0;function om({template:i,bits:t}){const e=Vd(i,t);if(mi[e])return mi[e];const{vertex:s,fragment:n}=am(i,t);return mi[e]=Yd(s,n,t),mi[e]}function rm({template:i,bits:t}){const e=Vd(i,t);return mi[e]||(mi[e]=Yd(i.vertex,i.fragment,t)),mi[e]}function am(i,t){const e=t.map(r=>r.vertex).filter(r=>!!r),s=t.map(r=>r.fragment).filter(r=>!!r);let n=dc(e,i.vertex,!0);n=im(e,n);const o=dc(s,i.fragment,!0);return{vertex:n,fragment:o}}function Vd(i,t){return t.map(e=>(Br.has(e)||Br.set(e,nm++),Br.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function Yd(i,t,e){const s=cc(i),n=cc(t);return e.forEach(o=>{lc(o.vertex,s,o.name),lc(o.fragment,n,o.name)}),{vertex:fc(i,s),fragment:fc(t,n)}}const lm=`
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
+ `,cm=`
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
+ `,hm=`
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
+ `,dm=`
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
+ `,um={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
+ `}},fm={name:"global-uniforms-bit",vertex:{header:`
176
+ uniform mat3 uProjectionMatrix;
177
+ uniform mat3 uWorldTransformMatrix;
178
+ uniform vec4 uWorldColorAlpha;
179
+ uniform vec2 uResolution;
180
+ `}};function pm({bits:i,name:t}){const e=om({template:{fragment:cm,vertex:lm},bits:[um,...i]});return ar.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function mm({bits:i,name:t}){return new vd({name:t,...rm({template:{vertex:hm,fragment:dm},bits:[fm,...i]})})}const gm={name:"color-bit",vertex:{header:`
181
+ @in aColor: vec4<f32>;
182
+ `,main:`
183
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
184
+ `}},ym={name:"color-bit",vertex:{header:`
185
+ in vec4 aColor;
186
+ `,main:`
187
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
188
+ `}},Rr={};function bm(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 _m(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 xm(i){return Rr[i]||(Rr[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
+ ${bm(i)}
204
+ `,main:`
205
+ var uvDx = dpdx(vUV);
206
+ var uvDy = dpdy(vUV);
207
+
208
+ ${_m(i)}
209
+ `}}),Rr[i]}const Dr={};function vm(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 wm(i){return Dr[i]||(Dr[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
+ ${vm(i)}
229
+ `}}),Dr[i]}const Sm={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
+ `}},km={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
+ `}},pc={};function Tm(i){let t=pc[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=pc[i]=new Td({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class mc extends ll{constructor(t){const e=mm({name:"batch",bits:[ym,wm(t),km]}),s=pm({name:"batch",bits:[gm,xm(t),Sm]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Tm(t)}}),this.maxTextures=t}}let xn=null;const jd=class Xd extends Yp{constructor(t){super(t),this.geometry=new Jp,this.name=Xd.extension.name,this.vertexSize=6,xn??(xn=new mc(t.maxTextures)),this.shader=xn}packAttributes(t,e,s,n,o){const r=o<<16|t.roundPixels&65535,l=t.transform,h=l.a,u=l.b,d=l.c,p=l.d,m=l.tx,g=l.ty,{positions:y,uvs:x}=t,w=t.color,S=t.attributeOffset,A=S+t.attributeSize;for(let L=S;L<A;L++){const I=L*2,O=y[I],R=y[I+1];e[n++]=h*O+d*R+m,e[n++]=p*R+u*O+g,e[n++]=x[I],e[n++]=x[I+1],s[n++]=w,s[n++]=r}}packQuadAttributes(t,e,s,n,o){const r=t.texture,l=t.transform,h=l.a,u=l.b,d=l.c,p=l.d,m=l.tx,g=l.ty,y=t.bounds,x=y.maxX,w=y.minX,S=y.maxY,A=y.minY,L=r.uvs,I=t.color,O=o<<16|t.roundPixels&65535;e[n+0]=h*w+d*A+m,e[n+1]=p*A+u*w+g,e[n+2]=L.x0,e[n+3]=L.y0,s[n+4]=I,s[n+5]=O,e[n+6]=h*x+d*A+m,e[n+7]=p*A+u*x+g,e[n+8]=L.x1,e[n+9]=L.y1,s[n+10]=I,s[n+11]=O,e[n+12]=h*x+d*S+m,e[n+13]=p*S+u*x+g,e[n+14]=L.x2,e[n+15]=L.y2,s[n+16]=I,s[n+17]=O,e[n+18]=h*w+d*S+m,e[n+19]=p*S+u*w+g,e[n+20]=L.x3,e[n+21]=L.y3,s[n+22]=I,s[n+23]=O}_updateMaxTextures(t){this.shader.maxTextures!==t&&(xn=new mc(t),this.shader=xn)}destroy(){this.shader=null,super.destroy()}};jd.extension={type:[mt.Batcher],name:"default"};let Cm=jd;class no{constructor(t){this.items=Object.create(null);const{renderer:e,type:s,onUnload:n,priority:o,name:r}=t;this._renderer=e,e.gc.addResourceHash(this,"items",s,o??0),this._onUnload=n,this.name=r}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){var n;if(!this.items[t.uid])return;const s=t._gpuData[this._renderer.uid];s&&((n=this._onUnload)==null||n.call(this,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 Am(i,t,e,s,n,o,r,l=null){let h=0;e*=t,n*=o;const u=l.a,d=l.b,p=l.c,m=l.d,g=l.tx,y=l.ty;for(;h<r;){const x=i[e],w=i[e+1];s[n]=u*x+p*w+g,s[n+1]=d*x+m*w+y,n+=o,e+=t,h++}}function Mm(i,t,e,s){let n=0;for(t*=e;n<s;)i[t]=0,i[t+1]=0,t+=e,n++}function Zd(i,t,e,s,n){const o=t.a,r=t.b,l=t.c,h=t.d,u=t.tx,d=t.ty;e||(e=0),s||(s=2),n||(n=i.length/s-e);let p=e*s;for(let m=0;m<n;m++){const g=i[p],y=i[p+1];i[p]=o*g+l*y+u,i[p+1]=r*g+h*y+d,p+=s}}const Em=new _t;class ul{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?td(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||Em}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 to={extension:{type:mt.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,o,r,l;if(i.type==="circle"){const I=i;if(r=l=I.radius,r<=0)return!1;e=I.x,s=I.y,n=o=0}else if(i.type==="ellipse"){const I=i;if(r=I.halfWidth,l=I.halfHeight,r<=0||l<=0)return!1;e=I.x,s=I.y,n=o=0}else{const I=i,O=I.width/2,R=I.height/2;e=I.x+O,s=I.y+R,r=l=Math.max(0,Math.min(I.radius,Math.min(O,R))),n=O-r,o=R-l}if(n<0||o<0)return!1;const h=Math.ceil(2.3*Math.sqrt(r+l)),u=h*8+(n?4:0)+(o?4:0);if(u===0)return!1;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+o,t[2]=t[4]=e-n,t[5]=t[7]=s-o,!0;let d=0,p=h*4+(n?2:0)+2,m=p,g=u,y=n+r,x=o,w=e+y,S=e-y,A=s+x;if(t[d++]=w,t[d++]=A,t[--p]=A,t[--p]=S,o){const I=s-x;t[m++]=S,t[m++]=I,t[--g]=I,t[--g]=w}for(let I=1;I<h;I++){const O=Math.PI/2*(I/h),R=n+Math.cos(O)*r,z=o+Math.sin(O)*l,Q=e+R,X=e-R,j=s+z,Z=s-z;t[d++]=Q,t[d++]=j,t[--p]=j,t[--p]=X,t[m++]=X,t[m++]=Z,t[--g]=Z,t[--g]=Q}y=n,x=o+l,w=e+y,S=e-y,A=s+x;const L=s-x;return t[d++]=w,t[d++]=A,t[--g]=L,t[--g]=w,n&&(t[d++]=S,t[d++]=A,t[--g]=L,t[--g]=S),!0},triangulate(i,t,e,s,n,o){if(i.length===0)return;let r=0,l=0;for(let d=0;d<i.length;d+=2)r+=i[d],l+=i[d+1];r/=i.length/2,l/=i.length/2;let h=s;t[h*e]=r,t[h*e+1]=l;const u=h++;for(let d=0;d<i.length;d+=2)t[h*e]=i[d],t[h*e+1]=i[d+1],d>0&&(n[o++]=h,n[o++]=u,n[o++]=h-1),h++;n[o++]=u+1,n[o++]=u,n[o++]=h-1}},Pm={...to,extension:{...to.extension,name:"ellipse"}},Im={...to,extension:{...to.extension,name:"roundedRectangle"}},Kd=1e-4,gc=1e-4;function Lm(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],o=i[t-1];s<t;s+=2){const r=i[s],l=i[s+1];e+=(r-n)*(l+o),n=r,o=l}return e<0?-1:1}function yc(i,t,e,s,n,o,r,l){const h=i-e*n,u=t-s*n,d=i+e*o,p=t+s*o;let m,g;r?(m=s,g=-e):(m=-s,g=e);const y=h+m,x=u+g,w=d+m,S=p+g;return l.push(y,x),l.push(w,S),2}function vi(i,t,e,s,n,o,r,l){const h=e-i,u=s-t;let d=Math.atan2(h,u),p=Math.atan2(n-i,o-t);l&&d<p?d+=Math.PI*2:!l&&d>p&&(p+=Math.PI*2);let m=d;const g=p-d,y=Math.abs(g),x=Math.sqrt(h*h+u*u),w=(15*y*Math.sqrt(x)/Math.PI>>0)+1,S=g/w;if(m+=S,l){r.push(i,t),r.push(e,s);for(let A=1,L=m;A<w;A++,L+=S)r.push(i,t),r.push(i+Math.sin(L)*x,t+Math.cos(L)*x);r.push(i,t),r.push(n,o)}else{r.push(e,s),r.push(i,t);for(let A=1,L=m;A<w;A++,L+=S)r.push(i+Math.sin(L)*x,t+Math.cos(L)*x),r.push(i,t);r.push(n,o),r.push(i,t)}return w*2}function Bm(i,t,e,s,n,o){const r=Kd;if(i.length===0)return;const l=t;let h=l.alignment;if(t.alignment!==.5){let nt=Lm(i);h=(h-.5)*nt+.5}const u=new ae(i[0],i[1]),d=new ae(i[i.length-2],i[i.length-1]),p=s,m=Math.abs(u.x-d.x)<r&&Math.abs(u.y-d.y)<r;if(p){i=i.slice(),m&&(i.pop(),i.pop(),d.set(i[i.length-2],i[i.length-1]));const nt=(u.x+d.x)*.5,gt=(d.y+u.y)*.5;i.unshift(nt,gt),i.push(nt,gt)}const g=n,y=i.length/2;let x=i.length;const w=g.length/2,S=l.width/2,A=S*S,L=l.miterLimit*l.miterLimit;let I=i[0],O=i[1],R=i[2],z=i[3],Q=0,X=0,j=-(O-z),Z=I-R,it=0,ot=0,rt=Math.sqrt(j*j+Z*Z);j/=rt,Z/=rt,j*=S,Z*=S;const Et=h,J=(1-Et)*2,et=Et*2;p||(l.cap==="round"?x+=vi(I-j*(J-et)*.5,O-Z*(J-et)*.5,I-j*J,O-Z*J,I+j*et,O+Z*et,g,!0)+2:l.cap==="square"&&(x+=yc(I,O,j,Z,J,et,!0,g))),g.push(I-j*J,O-Z*J),g.push(I+j*et,O+Z*et);for(let nt=1;nt<y-1;++nt){I=i[(nt-1)*2],O=i[(nt-1)*2+1],R=i[nt*2],z=i[nt*2+1],Q=i[(nt+1)*2],X=i[(nt+1)*2+1],j=-(O-z),Z=I-R,rt=Math.sqrt(j*j+Z*Z),j/=rt,Z/=rt,j*=S,Z*=S,it=-(z-X),ot=R-Q,rt=Math.sqrt(it*it+ot*ot),it/=rt,ot/=rt,it*=S,ot*=S;const gt=R-I,St=O-z,At=R-Q,ht=X-z,$t=gt*At+St*ht,qt=St*At-ht*gt,be=qt<0;if(Math.abs(qt)<.001*Math.abs($t)){g.push(R-j*J,z-Z*J),g.push(R+j*et,z+Z*et),$t>=0&&(l.join==="round"?x+=vi(R,z,R-j*J,z-Z*J,R-it*J,z-ot*J,g,!1)+4:x+=2,g.push(R-it*et,z-ot*et),g.push(R+it*J,z+ot*J));continue}const Ot=(-j+I)*(-Z+z)-(-j+R)*(-Z+O),ke=(-it+Q)*(-ot+z)-(-it+R)*(-ot+X),Le=(gt*ke-At*Ot)/qt,pe=(ht*Ot-St*ke)/qt,Fi=(Le-R)*(Le-R)+(pe-z)*(pe-z),Fe=R+(Le-R)*J,Ne=z+(pe-z)*J,Be=R-(Le-R)*et,We=z-(pe-z)*et,fn=Math.min(gt*gt+St*St,At*At+ht*ht),pn=be?J:et,hr=fn+pn*pn*A;Fi<=hr?l.join==="bevel"||Fi/A>L?(be?(g.push(Fe,Ne),g.push(R+j*et,z+Z*et),g.push(Fe,Ne),g.push(R+it*et,z+ot*et)):(g.push(R-j*J,z-Z*J),g.push(Be,We),g.push(R-it*J,z-ot*J),g.push(Be,We)),x+=2):l.join==="round"?be?(g.push(Fe,Ne),g.push(R+j*et,z+Z*et),x+=vi(R,z,R+j*et,z+Z*et,R+it*et,z+ot*et,g,!0)+4,g.push(Fe,Ne),g.push(R+it*et,z+ot*et)):(g.push(R-j*J,z-Z*J),g.push(Be,We),x+=vi(R,z,R-j*J,z-Z*J,R-it*J,z-ot*J,g,!1)+4,g.push(R-it*J,z-ot*J),g.push(Be,We)):(g.push(Fe,Ne),g.push(Be,We)):(g.push(R-j*J,z-Z*J),g.push(R+j*et,z+Z*et),l.join==="round"?be?x+=vi(R,z,R+j*et,z+Z*et,R+it*et,z+ot*et,g,!0)+2:x+=vi(R,z,R-j*J,z-Z*J,R-it*J,z-ot*J,g,!1)+2:l.join==="miter"&&Fi/A<=L&&(be?(g.push(Be,We),g.push(Be,We)):(g.push(Fe,Ne),g.push(Fe,Ne)),x+=2),g.push(R-it*J,z-ot*J),g.push(R+it*et,z+ot*et),x+=2)}I=i[(y-2)*2],O=i[(y-2)*2+1],R=i[(y-1)*2],z=i[(y-1)*2+1],j=-(O-z),Z=I-R,rt=Math.sqrt(j*j+Z*Z),j/=rt,Z/=rt,j*=S,Z*=S,g.push(R-j*J,z-Z*J),g.push(R+j*et,z+Z*et),p||(l.cap==="round"?x+=vi(R-j*(J-et)*.5,z-Z*(J-et)*.5,R-j*J,z-Z*J,R+j*et,z+Z*et,g,!1)+2:l.cap==="square"&&(x+=yc(R,z,j,Z,J,et,!1,g)));const bt=gc*gc;for(let nt=w;nt<x+w-2;++nt)I=g[nt*2],O=g[nt*2+1],R=g[(nt+1)*2],z=g[(nt+1)*2+1],Q=g[(nt+2)*2],X=g[(nt+2)*2+1],!(Math.abs(I*(z-X)+R*(X-O)+Q*(O-z))<bt)&&o.push(nt,nt+1,nt+2)}function Rm(i,t,e,s){const n=Kd;if(i.length===0)return;const o=i[0],r=i[1],l=i[i.length-2],h=i[i.length-1],u=t||Math.abs(o-l)<n&&Math.abs(r-h)<n,d=e,p=i.length/2,m=d.length/2;for(let g=0;g<p;g++)d.push(i[g*2]),d.push(i[g*2+1]);for(let g=0;g<p-1;g++)s.push(m+g,m+g+1);u&&s.push(m+p-1,m)}function Qd(i,t,e,s,n,o,r){const l=Sp(i,t,2);if(!l)return;for(let u=0;u<l.length;u+=3)o[r++]=l[u]+n,o[r++]=l[u+1]+n,o[r++]=l[u+2]+n;let h=n*s;for(let u=0;u<i.length;u+=2)e[h]=i[u],e[h+1]=i[u+1],h+=s}const Dm=[],$m={extension:{type:mt.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,o){Qd(i,Dm,t,e,s,n,o)}},zm={extension:{type:mt.ShapeBuilder,name:"rectangle"},build(i,t){const e=i,s=e.x,n=e.y,o=e.width,r=e.height;return o>0&&r>0?(t[0]=s,t[1]=n,t[2]=s+o,t[3]=n,t[4]=s+o,t[5]=n+r,t[6]=s,t[7]=n+r,!0):!1},triangulate(i,t,e,s,n,o){let r=0;s*=e,t[s+r]=i[0],t[s+r+1]=i[1],r+=e,t[s+r]=i[2],t[s+r+1]=i[3],r+=e,t[s+r]=i[6],t[s+r+1]=i[7],r+=e,t[s+r]=i[4],t[s+r+1]=i[5],r+=e;const l=s/e;n[o++]=l,n[o++]=l+1,n[o++]=l+2,n[o++]=l+1,n[o++]=l+3,n[o++]=l+2}},Fm={extension:{type:mt.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,o){let r=0;s*=e,t[s+r]=i[0],t[s+r+1]=i[1],r+=e,t[s+r]=i[2],t[s+r+1]=i[3],r+=e,t[s+r]=i[4],t[s+r+1]=i[5];const l=s/e;n[o++]=l,n[o++]=l+1,n[o++]=l+2}},bc=[{offset:0,color:"white"},{offset:1,color:"black"}],fl=class La{constructor(...t){this.uid=Gt("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Nm(t);e={...e.type==="radial"?La.defaultRadialOptions:La.defaultLinearOptions,...Hh(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:Yt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:n}=this.end,o=s-t,r=n-e;const l=o<0||r<0;if(this._wrapMode==="clamp-to-edge"){if(o<0){const w=t;t=s,s=w,o*=-1}if(r<0){const w=e;e=n,n=w,r*=-1}}const h=this.colorStops.length?this.colorStops:bc,u=this._textureSize,{canvas:d,context:p}=xc(u,1),m=l?p.createLinearGradient(this._textureSize,0,0,0):p.createLinearGradient(0,0,this._textureSize,0);_c(m,h),p.fillStyle=m,p.fillRect(0,0,u,1),this.texture=new It({source:new jo({resource:d,addressMode:this._wrapMode})});const g=Math.sqrt(o*o+r*r),y=Math.atan2(r,o),x=new _t;x.scale(g/u,1),x.rotate(y),x.translate(t,e),this.textureSpace==="local"&&x.scale(u,u),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:bc,e=this._textureSize,{canvas:s,context:n}=xc(e,e),{x:o,y:r}=this.center,{x:l,y:h}=this.outerCenter,u=this.innerRadius,d=this.outerRadius,p=l-d,m=h-d,g=e/(d*2),y=(o-p)*g,x=(r-m)*g,w=n.createRadialGradient(y,x,u*g,(l-p)*g,(h-m)*g,d*g);_c(w,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=w,n.translate(y,x),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-y,-x),n.fillRect(0,0,e,e),this.texture=new It({source:new jo({resource:s,addressMode:this._wrapMode})});const S=new _t;S.scale(1/g,1/g),S.translate(p,m),this.textureSpace==="local"&&S.scale(e,e),this.transform=S}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};fl.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};fl.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let ls=fl;function _c(i,t){for(let e=0;e<t.length;e++){const s=t[e];i.addColorStop(s.offset,s.color)}}function xc(i,t){const e=Se.get().createCanvas(i,t),s=e.getContext("2d");return{canvas:e,context:s}}function Nm(i){let t=i[0]??{};return(typeof t=="number"||i[1])&&(wt("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]??ls.defaultLinearOptions.textureSize}),t}const Wm=new _t,Gm=new Ht;function Om(i,t,e,s){const n=t.matrix?i.copyFrom(t.matrix).invert():i.identity();if(t.textureSpace==="local"){const r=e.getBounds(Gm);t.width&&r.pad(t.width);const{x:l,y:h}=r,u=1/r.width,d=1/r.height,p=-l*u,m=-h*d,g=n.a,y=n.b,x=n.c,w=n.d;n.a*=u,n.b*=u,n.c*=d,n.d*=d,n.tx=p*g+m*x+n.tx,n.ty=p*y+m*w+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 o=t.texture.source.style;return!(t.fill instanceof ls)&&o.addressMode==="clamp-to-edge"&&(o.addressMode="repeat",o.update()),s&&n.append(Wm.copyFrom(s).invert()),n}const lr={};Ut.handleByMap(mt.ShapeBuilder,lr);Ut.add(zm,$m,Fm,to,Pm,Im);const Hm=new Ht,Um=new _t;function qm(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 o=i.instructions[n];if(o.action==="texture")Vm(o.data,s,e);else if(o.action==="fill"||o.action==="stroke"){const r=o.action==="stroke",l=o.data.path.shapePath,h=o.data.style,u=o.data.hole;r&&u&&vc(u.shapePath,h,!0,s,e),u&&(l.shapePrimitives[l.shapePrimitives.length-1].holes=u.shapePath.shapePrimitives),vc(l,h,r,s,e)}}}function Vm(i,t,e){const s=[],n=lr.rectangle,o=Hm;o.x=i.dx,o.y=i.dy,o.width=i.dw,o.height=i.dh;const r=i.transform;if(!n.build(o,s))return;const{vertices:l,uvs:h,indices:u}=e,d=u.length,p=l.length/2;r&&Zd(s,r),n.triangulate(s,l,2,p,u,d);const m=i.image,g=m.uvs;h.push(g.x0,g.y0,g.x1,g.y1,g.x3,g.y3,g.x2,g.y2);const y=ye.get(ul);y.indexOffset=d,y.indexSize=u.length-d,y.attributeOffset=p,y.attributeSize=l.length/2-p,y.baseColor=i.style,y.alpha=i.alpha,y.texture=m,y.geometryData=e,t.push(y)}function vc(i,t,e,s,n){const{vertices:o,uvs:r,indices:l}=n;i.shapePrimitives.forEach(({shape:h,transform:u,holes:d})=>{const p=[],m=lr[h.type];if(!m.build(h,p))return;const g=l.length,y=o.length/2;let x="triangle-list";if(u&&Zd(p,u),e){const L=h.closePath??!0,I=t;I.pixelLine?(Rm(p,L,o,l),x="line-list"):Bm(p,I,!1,L,o,l)}else if(d){const L=[],I=p.slice();Ym(d).forEach(R=>{L.push(I.length/2),I.push(...R)}),Qd(I,L,o,2,y,l,g)}else m.triangulate(p,o,2,y,l,g);const w=r.length/2,S=t.texture;if(S!==It.WHITE){const L=Om(Um,t,h,u);Am(o,2,y,r,w,2,o.length/2-y,L)}else Mm(r,w,2,o.length/2-y);const A=ye.get(ul);A.indexOffset=g,A.indexSize=l.length-g,A.attributeOffset=y,A.attributeSize=o.length/2-y,A.baseColor=t.color,A.alpha=t.alpha,A.texture=S,A.geometryData=n,A.topology=x,s.push(A)})}function Ym(i){const t=[];for(let e=0;e<i.length;e++){const s=i[e].shape,n=[];lr[s.type].build(s,n)&&t.push(n)}return t}class jm{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{ye.return(t)}),this.graphicsData&&ye.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 Xm{constructor(){this.instructions=new ol}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Cm({maxTextures:e}),this.instructions.reset()}get geometry(){return wt(Uu,"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 pl=class Ba{constructor(t){this._renderer=t,this._managedContexts=new no({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Ba.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??Ba.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(),qm(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=ye.get(Xm,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:n,geometryData:o}=s;s.graphicsData=e;const r=o.vertices.length,l=o.indices.length;for(let p=0;p<n.length;p++)n[p].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(r),h.ensureIndexBuffer(l),h.begin();for(let p=0;p<n.length;p++){const m=n[p];h.add(m)}h.finish(e.instructions);const u=h.geometry;u.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,!0),u.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,!0);const d=h.batches;for(let p=0;p<d.length;p++){const m=d[p];m.bindGroup=zp(m.textures.textures,m.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new jm;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};pl.extension={type:[mt.WebGLSystem,mt.WebGPUSystem],name:"graphicsContext"};pl.defaultOptions={bezierSmoothness:.5};let ml=pl;const Zm=8,_o=11920929e-14,Km=1;function Jd(i,t,e,s,n,o,r,l,h,u){const p=Math.min(.99,Math.max(0,u??ml.defaultOptions.bezierSmoothness));let m=(Km-p)/1;return m*=m,Qm(t,e,s,n,o,r,l,h,i,m),i}function Qm(i,t,e,s,n,o,r,l,h,u){Ra(i,t,e,s,n,o,r,l,h,u,0),h.push(r,l)}function Ra(i,t,e,s,n,o,r,l,h,u,d){if(d>Zm)return;const p=(i+e)/2,m=(t+s)/2,g=(e+n)/2,y=(s+o)/2,x=(n+r)/2,w=(o+l)/2,S=(p+g)/2,A=(m+y)/2,L=(g+x)/2,I=(y+w)/2,O=(S+L)/2,R=(A+I)/2;if(d>0){let z=r-i,Q=l-t;const X=Math.abs((e-r)*Q-(s-l)*z),j=Math.abs((n-r)*Q-(o-l)*z);if(X>_o&&j>_o){if((X+j)*(X+j)<=u*(z*z+Q*Q)){h.push(O,R);return}}else if(X>_o){if(X*X<=u*(z*z+Q*Q)){h.push(O,R);return}}else if(j>_o){if(j*j<=u*(z*z+Q*Q)){h.push(O,R);return}}else if(z=O-(i+r)/2,Q=R-(t+l)/2,z*z+Q*Q<=u){h.push(O,R);return}}Ra(i,t,p,m,S,A,O,R,h,u,d+1),Ra(O,R,L,I,x,w,r,l,h,u,d+1)}const Jm=8,tg=11920929e-14,eg=1;function sg(i,t,e,s,n,o,r,l){const u=Math.min(.99,Math.max(0,l??ml.defaultOptions.bezierSmoothness));let d=(eg-u)/1;return d*=d,ig(t,e,s,n,o,r,i,d),i}function ig(i,t,e,s,n,o,r,l){Da(r,i,t,e,s,n,o,l,0),r.push(n,o)}function Da(i,t,e,s,n,o,r,l,h){if(h>Jm)return;const u=(t+s)/2,d=(e+n)/2,p=(s+o)/2,m=(n+r)/2,g=(u+p)/2,y=(d+m)/2;let x=o-t,w=r-e;const S=Math.abs((s-o)*w-(n-r)*x);if(S>tg){if(S*S<=l*(x*x+w*w)){i.push(g,y);return}}else if(x=g-(t+o)/2,w=y-(e+r)/2,x*x+w*w<=l){i.push(g,y);return}Da(i,t,e,u,d,g,y,l,h+1),Da(i,g,y,p,m,o,r,l,h+1)}function tu(i,t,e,s,n,o,r,l){let h=Math.abs(n-o);(!r&&n>o||r&&o>n)&&(h=2*Math.PI-h),l||(l=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI)))),l=Math.max(l,3);let u=h/l,d=n;u*=r?-1:1;for(let p=0;p<l+1;p++){const m=Math.cos(d),g=Math.sin(d),y=t+m*s,x=e+g*s;i.push(y,x),d+=u}}function ng(i,t,e,s,n,o){const r=i[i.length-2],h=i[i.length-1]-e,u=r-t,d=n-e,p=s-t,m=Math.abs(h*p-u*d);if(m<1e-8||o===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const g=h*h+u*u,y=d*d+p*p,x=h*d+u*p,w=o*Math.sqrt(g)/m,S=o*Math.sqrt(y)/m,A=w*x/g,L=S*x/y,I=w*p+S*u,O=w*d+S*h,R=u*(S+A),z=h*(S+A),Q=p*(w+L),X=d*(w+L),j=Math.atan2(z-O,R-I),Z=Math.atan2(X-O,Q-I);tu(i,I+t,O+e,o,j,Z,u*d>p*h)}const Yn=Math.PI*2,$r={centerX:0,centerY:0,ang1:0,ang2:0},zr=({x:i,y:t},e,s,n,o,r,l,h)=>{i*=e,t*=s;const u=n*i-o*t,d=o*i+n*t;return h.x=u+r,h.y=d+l,h};function og(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),o=Math.sin(i),r=Math.cos(i+t),l=Math.sin(i+t);return[{x:n-o*s,y:o+n*s},{x:r+l*s,y:l-r*s},{x:r,y:l}]}const wc=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let o=i*e+t*s;return o>1&&(o=1),o<-1&&(o=-1),n*Math.acos(o)},rg=(i,t,e,s,n,o,r,l,h,u,d,p,m)=>{const g=Math.pow(n,2),y=Math.pow(o,2),x=Math.pow(d,2),w=Math.pow(p,2);let S=g*y-g*w-y*x;S<0&&(S=0),S/=g*w+y*x,S=Math.sqrt(S)*(r===l?-1:1);const A=S*n/o*p,L=S*-o/n*d,I=u*A-h*L+(i+e)/2,O=h*A+u*L+(t+s)/2,R=(d-A)/n,z=(p-L)/o,Q=(-d-A)/n,X=(-p-L)/o,j=wc(1,0,R,z);let Z=wc(R,z,Q,X);l===0&&Z>0&&(Z-=Yn),l===1&&Z<0&&(Z+=Yn),m.centerX=I,m.centerY=O,m.ang1=j,m.ang2=Z};function ag(i,t,e,s,n,o,r,l=0,h=0,u=0){if(o===0||r===0)return;const d=Math.sin(l*Yn/360),p=Math.cos(l*Yn/360),m=p*(t-s)/2+d*(e-n)/2,g=-d*(t-s)/2+p*(e-n)/2;if(m===0&&g===0)return;o=Math.abs(o),r=Math.abs(r);const y=Math.pow(m,2)/Math.pow(o,2)+Math.pow(g,2)/Math.pow(r,2);y>1&&(o*=Math.sqrt(y),r*=Math.sqrt(y)),rg(t,e,s,n,o,r,h,u,d,p,m,g,$r);let{ang1:x,ang2:w}=$r;const{centerX:S,centerY:A}=$r;let L=Math.abs(w)/(Yn/4);Math.abs(1-L)<1e-7&&(L=1);const I=Math.max(Math.ceil(L),1);w/=I;let O=i[i.length-2],R=i[i.length-1];const z={x:0,y:0};for(let Q=0;Q<I;Q++){const X=og(x,w),{x:j,y:Z}=zr(X[0],o,r,p,d,S,A,z),{x:it,y:ot}=zr(X[1],o,r,p,d,S,A,z),{x:rt,y:Et}=zr(X[2],o,r,p,d,S,A,z);Jd(i,O,R,j,Z,it,ot,rt,Et),O=rt,R=Et,x+=w}}function lg(i,t,e){const s=(r,l)=>{const h=l.x-r.x,u=l.y-r.y,d=Math.sqrt(h*h+u*u),p=h/d,m=u/d;return{len:d,nx:p,ny:m}},n=(r,l)=>{r===0?i.moveTo(l.x,l.y):i.lineTo(l.x,l.y)};let o=t[t.length-1];for(let r=0;r<t.length;r++){const l=t[r%t.length],h=l.radius??e;if(h<=0){n(r,l),o=l;continue}const u=t[(r+1)%t.length],d=s(l,o),p=s(l,u);if(d.len<1e-4||p.len<1e-4){n(r,l),o=l;continue}let m=Math.asin(d.nx*p.ny-d.ny*p.nx),g=1,y=!1;d.nx*p.nx-d.ny*-p.ny<0?m<0?m=Math.PI+m:(m=Math.PI-m,g=-1,y=!0):m>0&&(g=-1,y=!0);const x=m/2;let w,S=Math.abs(Math.cos(x)*h/Math.sin(x));S>Math.min(d.len/2,p.len/2)?(S=Math.min(d.len/2,p.len/2),w=Math.abs(S*Math.sin(x)/Math.cos(x))):w=h;const A=l.x+p.nx*S+-p.ny*w*g,L=l.y+p.ny*S+p.nx*w*g,I=Math.atan2(d.ny,d.nx)+Math.PI/2*g,O=Math.atan2(p.ny,p.nx)-Math.PI/2*g;r===0&&i.moveTo(A+Math.cos(I)*w,L+Math.sin(I)*w),i.arc(A,L,w,I,O,y),o=l}}function cg(i,t,e,s){const n=(l,h)=>Math.sqrt((l.x-h.x)**2+(l.y-h.y)**2),o=(l,h,u)=>({x:l.x+(h.x-l.x)*u,y:l.y+(h.y-l.y)*u}),r=t.length;for(let l=0;l<r;l++){const h=t[(l+1)%r],u=h.radius??e;if(u<=0){l===0?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y);continue}const d=t[l],p=t[(l+2)%r],m=n(d,h);let g;if(m<1e-4)g=h;else{const w=Math.min(m/2,u);g=o(h,d,w/m)}const y=n(p,h);let x;if(y<1e-4)x=h;else{const w=Math.min(y/2,u);x=o(h,p,w/y)}l===0?i.moveTo(g.x,g.y):i.lineTo(g.x,g.y),i.quadraticCurveTo(h.x,h.y,x.x,x.y,s)}}const hg=new Ht;class dg{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Pe,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],o=s[s.length-1];return(n!==t||o!==e)&&s.push(t,e),this}arc(t,e,s,n,o,r){this._ensurePoly(!1);const l=this._currentPoly.points;return tu(l,t,e,s,n,o,r),this}arcTo(t,e,s,n,o){this._ensurePoly();const r=this._currentPoly.points;return ng(r,t,e,s,n,o),this}arcToSvg(t,e,s,n,o,r,l){const h=this._currentPoly.points;return ag(h,this._currentPoly.lastX,this._currentPoly.lastY,r,l,t,e,s,n,o),this}bezierCurveTo(t,e,s,n,o,r,l){this._ensurePoly();const h=this._currentPoly;return Jd(this._currentPoly.points,h.lastX,h.lastY,t,e,s,n,o,r,l),this}quadraticCurveTo(t,e,s,n,o){this._ensurePoly();const r=this._currentPoly;return sg(this._currentPoly.points,r.lastX,r.lastY,t,e,s,n,o),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 o=0;o<t.instructions.length;o++){const r=t.instructions[o];this[r.action](...r.data)}if(t.checkForHoles&&s.length-n>1){let o=null;for(let r=n;r<s.length;r++){const l=s[r];if(l.shape.type==="polygon"){const h=l.shape,u=o==null?void 0:o.shape;u&&u.containsPolygon(h)?(o.holes||(o.holes=[]),o.holes.push(l),s.copyWithin(r,r+1),s.length--,r--):o=l}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,n,o){return this.drawShape(new Ht(t,e,s,n),o),this}circle(t,e,s,n){return this.drawShape(new cl(t,e,s),n),this}poly(t,e,s){const n=new qn(t);return n.closePath=e,this.drawShape(n,s),this}regularPoly(t,e,s,n,o=0,r){n=Math.max(n|0,3);const l=-1*Math.PI/2+o,h=Math.PI*2/n,u=[];for(let d=0;d<n;d++){const p=l-d*h;u.push(t+s*Math.cos(p),e+s*Math.sin(p))}return this.poly(u,!0,r),this}roundPoly(t,e,s,n,o,r=0,l){if(n=Math.max(n|0,3),o<=0)return this.regularPoly(t,e,s,n,r);const h=s*Math.sin(Math.PI/n)-.001;o=Math.min(o,h);const u=-1*Math.PI/2+r,d=Math.PI*2/n,p=(n-2)*Math.PI/n/2;for(let m=0;m<n;m++){const g=m*d+u,y=t+s*Math.cos(g),x=e+s*Math.sin(g),w=g+Math.PI+p,S=g-Math.PI-p,A=y+o*Math.cos(w),L=x+o*Math.sin(w),I=y+o*Math.cos(S),O=x+o*Math.sin(S);m===0?this.moveTo(A,L):this.lineTo(A,L),this.quadraticCurveTo(y,x,I,O,l)}return this.closePath()}roundShape(t,e,s=!1,n){return t.length<3?this:(s?cg(this,t,e,n):lg(this,t,e),this.closePath())}filletRect(t,e,s,n,o){if(o===0)return this.rect(t,e,s,n);const r=Math.min(s,n)/2,l=Math.min(r,Math.max(-r,o)),h=t+s,u=e+n,d=l<0?-l:0,p=Math.abs(l);return this.moveTo(t,e+p).arcTo(t+d,e+d,t+p,e,p).lineTo(h-p,e).arcTo(h-d,e+d,h,e+p,p).lineTo(h,u-p).arcTo(h-d,u-d,t+s-p,u,p).lineTo(t+p,u).arcTo(t+d,u-d,t,u-p,p).closePath()}chamferRect(t,e,s,n,o,r){if(o<=0)return this.rect(t,e,s,n);const l=Math.min(o,Math.min(s,n)/2),h=t+s,u=e+n,d=[t+l,e,h-l,e,h,e+l,h,u-l,h-l,u,t+l,u,t,u-l,t,e+l];for(let p=d.length-1;p>=2;p-=2)d[p]===d[p-2]&&d[p-1]===d[p-3]&&d.splice(p-1,2);return this.poly(d,!0,r)}ellipse(t,e,s,n,o){return this.drawShape(new hl(t,e,s,n),o),this}roundRect(t,e,s,n,o,r){return this.drawShape(new dl(t,e,s,n,o),r),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 qn,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 qn,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 o=e.transform,r=s;s=o.a*s+o.c*n+o.tx,n=o.b*r+o.d*n+o.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],o=n.shape.getBounds(hg);n.transform?t.addRect(o,n.transform):t.addRect(o)}return t}}class as{constructor(t,e=!1){this.instructions=[],this.uid=Gt("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?Bp(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new dg(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,o){const r=this.instructions[this.instructions.length-1],l=this.getLastPoint(ae.shared);let h=0,u=0;if(!r||r.action!=="bezierCurveTo")h=l.x,u=l.y;else{h=r.data[2],u=r.data[3];const d=l.x,p=l.y;h=d+(d-h),u=p+(p-u)}return this.instructions.push({action:"bezierCurveTo",data:[h,u,t,e,s,n,o]}),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],o=this.getLastPoint(ae.shared);let r=0,l=0;if(!n||n.action!=="quadraticCurveTo")r=o.x,l=o.y;else{r=n.data[0],l=n.data[1];const h=o.x,u=o.y;r=h+(h-r),l=u+(u-l)}return this.instructions.push({action:"quadraticCurveTo",data:[r,l,t,e,s]}),this._dirty=!0,this}rect(t,e,s,n,o){return this.instructions.push({action:"rect",data:[t,e,s,n,o]}),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,o,r,l){o||(o=n/2);const h=-1*Math.PI/2+r,u=s*2,d=Math.PI*2/u,p=[];for(let m=0;m<u;m++){const g=m%2?o:n,y=m*d+h;p.push(t+g*Math.cos(y),e+g*Math.sin(y))}return this.poly(p,!0,l),this}clone(t=!1){const e=new as;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,o=t.d,r=t.tx,l=t.ty;let h=0,u=0,d=0,p=0,m=0,g=0,y=0,x=0;for(let w=0;w<this.instructions.length;w++){const S=this.instructions[w],A=S.data;switch(S.action){case"moveTo":case"lineTo":h=A[0],u=A[1],A[0]=e*h+n*u+r,A[1]=s*h+o*u+l;break;case"bezierCurveTo":d=A[0],p=A[1],m=A[2],g=A[3],h=A[4],u=A[5],A[0]=e*d+n*p+r,A[1]=s*d+o*p+l,A[2]=e*m+n*g+r,A[3]=s*m+o*g+l,A[4]=e*h+n*u+r,A[5]=s*h+o*u+l;break;case"quadraticCurveTo":d=A[0],p=A[1],h=A[2],u=A[3],A[0]=e*d+n*p+r,A[1]=s*d+o*p+l,A[2]=e*h+n*u+r,A[3]=s*h+o*u+l;break;case"arcToSvg":h=A[5],u=A[6],y=A[0],x=A[1],A[0]=e*y+n*x,A[1]=s*y+o*x,A[5]=e*h+n*u+r,A[6]=s*h+o*u+l;break;case"circle":A[4]=vn(A[3],t);break;case"rect":A[4]=vn(A[4],t);break;case"ellipse":A[8]=vn(A[8],t);break;case"roundRect":A[5]=vn(A[5],t);break;case"addPath":A[0].transform(t);break;case"poly":A[2]=vn(A[2],t);break;default:fe("unknown transform action",S.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 vn(i,t){return i?i.prepend(t):t.clone()}function Nt(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function ug(i,t){const e=i.querySelectorAll("defs");for(let s=0;s<e.length;s++){const n=e[s];for(let o=0;o<n.children.length;o++){const r=n.children[o];switch(r.nodeName.toLowerCase()){case"lineargradient":t.defs[r.id]=fg(r);break;case"radialgradient":t.defs[r.id]=pg();break}}}}function fg(i){const t=Nt(i,"x1",0),e=Nt(i,"y1",0),s=Nt(i,"x2",1),n=Nt(i,"y2",0),o=i.getAttribute("gradientUnits")||"objectBoundingBox",r=new ls(t,e,s,n,o==="objectBoundingBox"?"local":"global");for(let l=0;l<i.children.length;l++){const h=i.children[l],u=Nt(h,"offset",0),d=Yt.shared.setValue(h.getAttribute("stop-color")).toNumber();r.addColorStop(u,d)}return r}function pg(i){return fe("[SVG Parser] Radial gradients are not yet supported"),new ls(0,0,1,0)}function Sc(i){const t=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const kc={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 eu(i,t){const e=i.getAttribute("style"),s={},n={},o={strokeStyle:s,fillStyle:n,useFill:!1,useStroke:!1};for(const r in kc){const l=i.getAttribute(r);l&&Tc(t,o,r,l.trim())}if(e){const r=e.split(";");for(let l=0;l<r.length;l++){const h=r[l].trim(),[u,d]=h.split(":");kc[u]&&Tc(t,o,u,d.trim())}}return{strokeStyle:o.useStroke?s:null,fillStyle:o.useFill?n:null,useFill:o.useFill,useStroke:o.useStroke}}function Tc(i,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const n=Sc(s);t.strokeStyle.fill=i.defs[n]}else t.strokeStyle.color=Yt.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=Sc(s);t.fillStyle.fill=i.defs[n]}else t.fillStyle.color=Yt.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 mg(i){if(i.length<=2)return!0;const t=i.map(l=>l.area).sort((l,h)=>h-l),[e,s]=t,n=t[t.length-1],o=e/s,r=s/n;return!(o>3&&r<2)}function gg(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function yg(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 d=0;d<e.length;d+=2)d+1<e.length&&(s.push(e[d]),n.push(e[d+1]));if(s.length===0||n.length===0)return 0;const o=Math.min(...s),r=Math.max(...s),l=Math.min(...n),h=Math.max(...n);return(r-o)*(h-l)}function Cc(i,t){const e=new as(i,!1);for(const s of e.instructions)t.instructions.push(s)}function bg(i,t){if(typeof i=="string"){const r=document.createElement("div");r.innerHTML=i.trim(),i=r.querySelector("svg")}const e={context:t,defs:{},path:new as};ug(i,e);const s=i.children,{fillStyle:n,strokeStyle:o}=eu(i,e);for(let r=0;r<s.length;r++){const l=s[r];l.nodeName.toLowerCase()!=="defs"&&su(l,e,n,o)}return t}function su(i,t,e,s){const n=i.children,{fillStyle:o,strokeStyle:r}=eu(i,t);o&&e?e={...e,...o}:o&&(e=o),r&&s?s={...s,...r}:r&&(s=r);const l=!e&&!s;l&&(e={color:0});let h,u,d,p,m,g,y,x,w,S,A,L,I,O,R,z,Q;switch(i.nodeName.toLowerCase()){case"path":{O=i.getAttribute("d");const X=i.getAttribute("fill-rule"),j=gg(O),Z=X==="evenodd",it=j.length>1;if(Z&&it){const rt=j.map(J=>({path:J,area:yg(J)}));if(rt.sort((J,et)=>et.area-J.area),j.length>3||!mg(rt))for(let J=0;J<rt.length;J++){const et=rt[J],bt=J===0;t.context.beginPath();const nt=new as(void 0,!0);Cc(et.path,nt),t.context.path(nt),bt?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let J=0;J<rt.length;J++){const et=rt[J],bt=J%2===1;t.context.beginPath();const nt=new as(void 0,!0);Cc(et.path,nt),t.context.path(nt),bt?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const rt=X?X==="evenodd":!0;R=new as(O,rt),t.context.path(R),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":y=Nt(i,"cx",0),x=Nt(i,"cy",0),w=Nt(i,"r",0),t.context.ellipse(y,x,w,w),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":h=Nt(i,"x",0),u=Nt(i,"y",0),z=Nt(i,"width",0),Q=Nt(i,"height",0),S=Nt(i,"rx",0),A=Nt(i,"ry",0),S||A?t.context.roundRect(h,u,z,Q,S||A):t.context.rect(h,u,z,Q),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":y=Nt(i,"cx",0),x=Nt(i,"cy",0),S=Nt(i,"rx",0),A=Nt(i,"ry",0),t.context.beginPath(),t.context.ellipse(y,x,S,A),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"line":d=Nt(i,"x1",0),p=Nt(i,"y1",0),m=Nt(i,"x2",0),g=Nt(i,"y2",0),t.context.beginPath(),t.context.moveTo(d,p),t.context.lineTo(m,g),s&&t.context.stroke(s);break;case"polygon":I=i.getAttribute("points"),L=I.match(/-?\d+/g).map(X=>parseInt(X,10)),t.context.poly(L,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":I=i.getAttribute("points"),L=I.match(/-?\d+/g).map(X=>parseInt(X,10)),t.context.poly(L,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{fe(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}l&&(e=null);for(let X=0;X<n.length;X++)su(n[X],t,e,s)}const Ac={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 cr{constructor(t,e){this.uid=Gt("fillPattern"),this._tick=0,this.transform=new _t,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Ac[e].addressModeU,t.source.style.addressModeV=Ac[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function _g(i){return Yt.isColorLike(i)}function Mc(i){return i instanceof cr}function Ec(i){return i instanceof ls}function xg(i){return i instanceof It}function vg(i,t,e){const s=Yt.shared.setValue(t??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=It.WHITE,{...e,...i}}function wg(i,t,e){return i.texture=t,{...e,...i}}function Pc(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function Ic(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 Sg(i,t){const e={...t,...i},s=Yt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function Ri(i,t){if(i==null)return null;const e={},s=i;return _g(i)?vg(e,i,t):xg(i)?wg(e,i,t):Mc(i)?Pc(e,i,t):Ec(i)?Ic(e,i,t):s.fill&&Mc(s.fill)?Pc(s,s.fill,t):s.fill&&Ec(s.fill)?Ic(s,s.fill,t):Sg(s,t)}function Ko(i,t){const{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...h}=t,u=Ri(i,h);return u?{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...u}:null}function kg(i,t){let e=1;const s=i.shapePath.shapePrimitives;for(let n=0;n<s.length;n++){const o=s[n].shape;if(o.type!=="polygon")continue;const r=o.points,l=r.length;if(l<6)continue;const h=o.closePath;for(let u=0;u<l;u+=2){if(!h&&(u===0||u===l-2))continue;const d=(u-2+l)%l,p=(u+2)%l,m=r[d],g=r[d+1],y=r[u],x=r[u+1],w=r[p],S=r[p+1],A=m-y,L=g-x,I=w-y,O=S-x,R=A*A+L*L,z=I*I+O*O;if(R<1e-12||z<1e-12)continue;let j=(A*I+L*O)/Math.sqrt(R*z);j<-1?j=-1:j>1&&(j=1);const Z=Math.sqrt((1-j)*.5);if(Z<1e-6)continue;const it=Math.min(1/Z,t);it>e&&(e=it)}}return e}const Tg=new ae,Lc=new _t,gl=class He extends Ze{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Gt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new as,this._transform=new _t,this._fillStyle={...He.defaultFillStyle},this._strokeStyle={...He.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Pe,this._boundsDirty=!0}clone(){const t=new He;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=Ri(t,He.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Ko(t,He.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Ri(t,He.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Ri(t,He.defaultStrokeStyle),this}texture(t,e,s,n,o,r){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:n||0,dw:o||t.frame.width,dh:r||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?Yt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new as,this}fill(t,e){let s;const n=this.instructions[this.instructions.length-1];return this._tick===0&&(n==null?void 0:n.action)==="stroke"?s=n.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(wt(Wt,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=Ri(t,He.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(ae.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Ko(t,He.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,o,r){this._tick++;const l=this._transform;return this._activePath.arc(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,s,n,o,r),this}arcTo(t,e,s,n,o){this._tick++;const r=this._transform;return this._activePath.arcTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*s+r.c*n+r.tx,r.b*s+r.d*n+r.ty,o),this}arcToSvg(t,e,s,n,o,r,l){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,n,o,h.a*r+h.c*l+h.tx,h.b*r+h.d*l+h.ty),this}bezierCurveTo(t,e,s,n,o,r,l){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*o+h.c*r+h.tx,h.b*o+h.d*r+h.ty,l),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.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,o=s.a*t+s.c*e+s.tx,r=s.b*t+s.d*e+s.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=o,n[0].data[1]=r,this):(this._activePath.moveTo(o,r),this)}quadraticCurveTo(t,e,s,n,o){this._tick++;const r=this._transform;return this._activePath.quadraticCurveTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*s+r.c*n+r.tx,r.b*s+r.d*n+r.ty,o),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,o){return this._tick++,this._activePath.roundRect(t,e,s,n,o,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,n,o=0,r){return this._tick++,this._activePath.regularPoly(t,e,s,n,o,r),this}roundPoly(t,e,s,n,o,r){return this._tick++,this._activePath.roundPoly(t,e,s,n,o,r),this}roundShape(t,e,s,n){return this._tick++,this._activePath.roundShape(t,e,s,n),this}filletRect(t,e,s,n,o){return this._tick++,this._activePath.filletRect(t,e,s,n,o),this}chamferRect(t,e,s,n,o,r){return this._tick++,this._activePath.chamferRect(t,e,s,n,o,r),this}star(t,e,s,n,o=0,r=0){return this._tick++,this._activePath.star(t,e,s,n,o,r,this._transform.clone()),this}svg(t){return this._tick++,bg(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,o,r){return t instanceof _t?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,n,o,r),this)}transform(t,e,s,n,o,r){return t instanceof _t?(this._transform.append(t),this):(Lc.set(t,e,s,n,o,r),this._transform.append(Lc),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 o=s.data;t.addBounds(o.path.bounds)}else if(n==="texture"){const o=s.data;t.addFrame(o.dx,o.dy,o.dx+o.dw,o.dy+o.dh,o.transform)}if(n==="stroke"){const o=s.data,r=o.style.alignment;let l=o.style.width*(1-r);o.style.join==="miter"&&(l*=kg(o.path,o.style.miterLimit));const h=o.path.bounds;t.addFrame(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){var n;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let s=!1;for(let o=0;o<e.length;o++){const r=e[o],l=r.data,h=l.path;if(!r.action||!h)continue;const u=l.style,d=h.shapePath.shapePrimitives;for(let p=0;p<d.length;p++){const m=d[p].shape;if(!u||!m)continue;const g=d[p].transform,y=g?g.applyInverse(t,Tg):t;if(r.action==="fill")s=m.contains(y.x,y.y);else{const w=u;s=m.strokeContains(y.x,y.y,w.width,w.alignment)}const x=l.hole;if(x){const w=(n=x.shapePath)==null?void 0:n.shapePrimitives;if(w)for(let S=0;S<w.length;S++)w[S].shape.contains(y.x,y.y)&&(s=!1)}if(s)return!0}}return s}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}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==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(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}};gl.defaultFillStyle={color:16777215,alpha:1,texture:It.WHITE,matrix:null,fill:null,textureSpace:"local"};gl.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:It.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let $e=gl;class Cg{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Ag{constructor(){this.instructions=new ol}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const yl=class $a{constructor(t){this._renderer=t,this._managedContexts=new no({renderer:t,type:"resource",name:"graphicsContext"})}init(t){$a.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??$a.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 Ag,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new Cg;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};yl.extension={type:[mt.CanvasSystem],name:"graphicsContext"};yl.defaultOptions={bezierSmoothness:.5};let Mg=yl;class iu{constructor(t,e){this.state=Ad.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new no({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}}iu.extension={type:[mt.CanvasPipes],name:"graphics"};function Eg(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 Pg{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{ye.return(t)}),this.batches.length=0}}class nu{constructor(t,e){this.state=Ad.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new no({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,o=this.renderer.graphicsContext.updateGpuContext(e);return!!(o.isBatchable||s!==o.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 o=s[n];o._batcher.updateElement(o)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const o=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const r=o.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=e._roundPixels|t._roundPixels,Eg(t.groupColorAlpha,r.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 o=0;o<n.length;o++){const r=n[o];s.addToBatch(r,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Pg;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const s=t.context,o=this.renderer.graphicsContext.getGpuContext(s),r=this.renderer._roundPixels|t._roundPixels;e.batches=o.batches.map(l=>{const h=ye.get(ul);return l.copyTo(h),h.renderable=t,h.roundPixels=r,h})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}nu.extension={type:[mt.WebGLPipes,mt.WebGPUPipes],name:"graphics"};Ut.add(iu);Ut.add(nu);Ut.add(Mg);Ut.add(ml);class Ft extends rl{constructor(t){t instanceof $e&&(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 $e,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==null?void 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 Ft(this._context.clone()):(this._ownedContext=null,new Ft(this._context))}lineStyle(t,e,s){wt(Wt,"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){wt(Wt,"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(){wt(Wt,"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!==$e.defaultStrokeStyle.width||t.color!==$e.defaultStrokeStyle.color||t.alpha!==$e.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return wt(Wt,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return wt(Wt,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return wt(Wt,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return wt(Wt,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return wt(Wt,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return wt(Wt,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class Ig extends rl{constructor(t,e){const{text:s,resolution:n,style:o,anchor:r,width:l,height:h,roundPixels:u,...d}=t;super({...d}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=o,this.resolution=n??null,this.allowChildren=!1,this._anchor=new Kt({_onUpdate:()=>{this.onViewUpdate()}}),r&&(this.anchor=r),this.roundPixels=u??!1,l!==void 0&&(this.width=l),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){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){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 o=0;return t.x>=n&&t.x<=n+e&&(o=-s*this.anchor.y,t.y>=o&&t.y<=o+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!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Lg(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(wt(Wt,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class Bg{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Se.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=an(t),e=an(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let o=this._canvasPool[n].pop();return o||(o=this._createCanvasAndContext(t,e)),o}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,o=(s<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,n),this._canvasPool[o].push(t)}clear(){this._canvasPool={}}}const za=new Bg;io.register(za);let wi=null,os=null;function Rg(i,t){wi||(wi=Se.get().createCanvas(256,128),os=wi.getContext("2d",{willReadFrequently:!0}),os.globalCompositeOperation="copy",os.globalAlpha=1),(wi.width<i||wi.height<t)&&(wi.width=an(i),wi.height=an(t))}function Bc(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 Rc(i,t,e,s,n){const o=4*t;for(let r=s,l=s*o+4*e;r<=n;++r,l+=o)if(i[l+3]!==0)return!1;return!0}function Dg(...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,o=t.height??e.height;let r=t.output;if(Rg(n,o),!os)throw new TypeError("Failed to get canvas 2D context");os.drawImage(e,0,0,n,o,0,0,n*s,o*s);const h=os.getImageData(0,0,n,o).data;let u=0,d=0,p=n-1,m=o-1;for(;d<o&&Bc(h,n,d);)++d;if(d===o)return Ht.EMPTY;for(;Bc(h,n,m);)--m;for(;Rc(h,n,u,d,m);)++u;for(;Rc(h,n,p,d,m);)--p;return++p,++m,os.globalCompositeOperation="source-over",os.strokeRect(u,d,p-u,m-d),os.globalCompositeOperation="copy",r??(r=new Ht),r.set(u/s,d/s,(p-u)/s,(m-d)/s),r}/**
240
+ * tiny-lru
241
+ *
242
+ * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
243
+ * @license BSD-3-Clause
244
+ * @version 11.4.7
245
+ */class $g{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 o=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=o:this.last.next=o,this.last=o}return n}set(t,e,s=!1,n=this.resetTtl){let o=this.items[t];return s||o!==void 0?(o.value=e,s===!1&&n&&(o.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(o)):(this.max>0&&this.size===this.max&&this.evict(!0),o=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=o:this.last.next=o,this.last=o),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 zg(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 $g(i,t,e)}function ou(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function ru(i){return i.includes("<")}function Fg(i,t){return i.clone().assign(t)}function Ng(i,t){const e=[],s=t.tagStyles;if(!ou(t)||!ru(i))return e.push({text:i,style:t}),e;const n=[t],o=[];let r="",l=0;for(;l<i.length;){const h=i[l];if(h==="<"){const u=i.indexOf(">",l);if(u===-1){r+=h,l++;continue}const d=i.slice(l+1,u);if(d.startsWith("/")){const p=d.slice(1).trim();if(o.length>0&&o[o.length-1]===p){r.length>0&&(e.push({text:r,style:n[n.length-1]}),r=""),n.pop(),o.pop(),l=u+1;continue}else{r+=i.slice(l,u+1),l=u+1;continue}}else{const p=d.trim();if(s[p]){r.length>0&&(e.push({text:r,style:n[n.length-1]}),r="");const m=n[n.length-1],g=Fg(m,s[p]);n.push(g),o.push(p),l=u+1;continue}else{r+=i.slice(l,u+1),l=u+1;continue}}}else r+=h,l++}return r.length>0&&e.push({text:r,style:n[n.length-1]}),e}const Wg=[10,13],Gg=new Set(Wg),Og=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Hg=new Set(Og),Ug=[9,32];new Set(Ug);const qg=[45,8208,8211,8212,173],Vg=new Set(qg),Yg=/(\r\n|\r|\n)/,jg=/(?:\r\n|\r|\n)/;function Qo(i){return typeof i!="string"?!1:Gg.has(i.charCodeAt(0))}function Me(i,t){return typeof i!="string"?!1:Hg.has(i.charCodeAt(0))}function Xg(i){return typeof i!="string"?!1:Vg.has(i.charCodeAt(0))}function au(i){return i==="normal"||i==="pre-line"}function lu(i){return i==="normal"}function ns(i){if(typeof i!="string")return"";let t=i.length-1;for(;t>=0&&Me(i[t]);)t--;return t<i.length-1?i.slice(0,t+1):i}function cu(i){const t=[],e=[];if(typeof i!="string")return t;for(let s=0;s<i.length;s++){const n=i[s],o=i[s+1];if(Me(n)||Qo(n)){e.length>0&&(t.push(e.join("")),e.length=0),n==="\r"&&o===`
246
+ `?(t.push(`\r
247
+ `),s++):t.push(n);continue}e.push(n),Xg(n)&&o&&!Me(o)&&!Qo(o)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function hu(i,t,e,s){const n=e(i),o=[];for(let r=0;r<n.length;r++){let l=n[r],h=l,u=1;for(;n[r+u];){const d=n[r+u];if(!s(h,d,i,r,t))l+=d,h=d,u++;else break}r+=u-1,o.push(l)}return o}const Zg=/\r\n|\r|\n/g;function Kg(i,t,e,s,n,o,r,l){var Et,J;const h=Ng(i,t);if(lu(t.whiteSpace))for(let et=0;et<h.length;et++){const bt=h[et];h[et]={text:bt.text.replace(Zg," "),style:bt.style}}const d=[];let p=[];for(const et of h){const bt=et.text.split(Yg);for(let nt=0;nt<bt.length;nt++){const gt=bt[nt];gt===`\r
248
+ `||gt==="\r"||gt===`
249
+ `?(d.push(p),p=[]):gt.length>0&&p.push({text:gt,style:et.style})}}(p.length>0||d.length===0)&&d.push(p);const m=e?Qg(d,t,s,n,r,l):d,g=[],y=[],x=[],w=[],S=[];let A=0;const L=t._fontString,I=o(L);I.fontSize===0&&(I.fontSize=t.fontSize,I.ascent=t.fontSize);let O="",R=!!t.dropShadow,z=((Et=t._stroke)==null?void 0:Et.width)||0;for(const et of m){let bt=0,nt=I.ascent,gt=I.descent,St="";for(const ht of et){const $t=ht.style._fontString,qt=o($t);$t!==O&&(s.font=$t,O=$t);const be=n(ht.text,ht.style.letterSpacing,s);bt+=be,nt=Math.max(nt,qt.ascent),gt=Math.max(gt,qt.descent),St+=ht.text;const Ot=((J=ht.style._stroke)==null?void 0:J.width)||0;Ot>z&&(z=Ot),!R&&ht.style.dropShadow&&(R=!0)}et.length===0&&(nt=I.ascent,gt=I.descent),g.push(bt),y.push(nt),x.push(gt),S.push(St);const At=t.lineHeight||nt+gt;w.push(At+t.leading),A=Math.max(A,bt)}const Q=z,Z=(e&&t.align!=="left"?Math.max(A,t.wordWrapWidth):A)+Q+(t.dropShadow?t.dropShadow.distance:0);let it=0;for(let et=0;et<w.length;et++)it+=w[et];it=Math.max(it,w[0]+Q);const ot=it+(t.dropShadow?t.dropShadow.distance:0),rt=t.lineHeight||I.fontSize;return{width:Z,height:ot,lines:S,lineWidths:g,lineHeight:rt+t.leading,maxLineWidth:A,fontProperties:I,runsByLine:m,lineAscents:y,lineDescents:x,lineHeights:w,hasDropShadow:R}}function Qg(i,t,e,s,n,o){var w;const{letterSpacing:r,whiteSpace:l,wordWrapWidth:h,breakWords:u}=t,d=au(l),p=h+r,m={};let g="";const y=(S,A)=>{const L=`${S}|${A.styleKey}`;let I=m[L];if(I===void 0){const O=A._fontString;O!==g&&(e.font=O,g=O),I=s(S,A.letterSpacing,e)+A.letterSpacing,m[L]=I}return I},x=[];for(const S of i){const A=Jg(S),L=x.length,I=it=>{let ot=0,rt=it;do{const{token:Et,style:J}=A[rt];ot+=y(Et,J),rt++}while(rt<A.length&&A[rt].continuesFromPrevious);return ot},O=it=>{const ot=[];let rt=it;do ot.push({token:A[rt].token,style:A[rt].style}),rt++;while(rt<A.length&&A[rt].continuesFromPrevious);return ot};let R=[],z=0,Q=!d,X=null;const j=()=>{X&&X.text.length>0&&R.push(X),X=null},Z=()=>{if(j(),R.length>0){const it=R[R.length-1];it.text=ns(it.text),it.text.length===0&&R.pop()}x.push(R),R=[],z=0,Q=!1};for(let it=0;it<A.length;it++){const{token:ot,style:rt,continuesFromPrevious:Et}=A[it],J=y(ot,rt);if(d){const nt=Me(ot),gt=(X==null?void 0:X.text[X.text.length-1])??((w=R[R.length-1])==null?void 0:w.text.slice(-1))??"",St=gt?Me(gt):!1;if(nt&&St)continue}const et=!Et,bt=et?I(it):J;if(bt>p&&et)if(z>0&&Z(),u){const nt=O(it);for(let gt=0;gt<nt.length;gt++){const St=nt[gt].token,At=nt[gt].style,ht=hu(St,u,o,n);for(const $t of ht){const qt=y($t,At);qt+z>p&&Z(),!X||X.style!==At?(j(),X={text:$t,style:At}):X.text+=$t,z+=qt}}it+=nt.length-1}else{const nt=O(it);j(),x.push(nt.map(gt=>({text:gt.token,style:gt.style}))),Q=!1,it+=nt.length-1}else if(bt+z>p&&et){if(Me(ot)){Q=!1;continue}Z(),X={text:ot,style:rt},z=J}else if(Et&&!u)!X||X.style!==rt?(j(),X={text:ot,style:rt}):X.text+=ot,z+=J;else{const nt=Me(ot);if(z===0&&nt&&!Q)continue;!X||X.style!==rt?(j(),X={text:ot,style:rt}):X.text+=ot,z+=J}}if(j(),R.length>0){const it=R[R.length-1];it.text=ns(it.text),it.text.length===0&&R.pop()}(R.length>0||x.length===L)&&x.push(R)}return x}function Jg(i){const t=[];let e=!1;for(const s of i){const n=cu(s.text);let o=!0;for(const r of n){const l=Me(r)||Qo(r),h=o&&e&&!l;t.push({token:r,style:s.style,continuesFromPrevious:h}),e=!l,o=!1}}return t}const t0={willReadFrequently:!0};function Dc(i,t,e,s,n){let o=e[i];return typeof o!="number"&&(o=n(i,t,s)+t,e[i]=o),o}function e0(i,t,e,s,n,o,r){const l=e.getContext("2d",t0);l.font=t._fontString;let h=0,u="";const d=[],p=Object.create(null),{letterSpacing:m,whiteSpace:g}=t,y=au(g),x=lu(g);let w=!y;const S=t.wordWrapWidth+m,A=cu(i);for(let I=0;I<A.length;I++){let O=A[I];if(Qo(O)){if(!x){d.push(ns(u)),w=!y,u="",h=0;continue}O=" "}if(y){const z=Me(O),Q=Me(u[u.length-1]);if(z&&Q)continue}const R=Dc(O,m,p,l,s);if(R>S)if(u!==""&&(d.push(ns(u)),u="",h=0),n(O,t.breakWords)){const z=hu(O,t.breakWords,r,o);for(const Q of z){const X=Dc(Q,m,p,l,s);X+h>S&&(d.push(ns(u)),w=!1,u="",h=0),u+=Q,h+=X}}else u.length>0&&(d.push(ns(u)),u="",h=0),d.push(ns(O)),w=!1,u="",h=0;else R+h>S&&(w=!1,d.push(ns(u)),u="",h=0),(u.length>0||!Me(O)||w)&&(u+=O,h+=R)}const L=ns(u);return L.length>0&&d.push(L),d.join(`
250
+ `)}const $c={willReadFrequently:!0},cs=class ct{static get experimentalLetterSpacingSupported(){let t=ct._experimentalLetterSpacingSupported;if(t===void 0){const e=Se.get().getCanvasRenderingContext2D().prototype;t=ct._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,o,r,l,h,u,d){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=o,this.lineWidths=r,this.lineHeight=l,this.maxLineWidth=h,this.fontProperties=u,d&&(this.runsByLine=d.runsByLine,this.lineAscents=d.lineAscents,this.lineDescents=d.lineDescents,this.lineHeights=d.lineHeights,this.hasDropShadow=d.hasDropShadow)}static measureText(t=" ",e,s=ct._canvas,n=e.wordWrap){var O;const o=`${t}-${e.styleKey}-wordWrap-${n}`;if(ct._measurementCache.has(o))return ct._measurementCache.get(o);if(ou(e)&&ru(t)){const R=Kg(t,e,n,ct._context,ct._measureText,ct.measureFont,ct.canBreakChars,ct.wordWrapSplit),z=new ct(t,e,R.width,R.height,R.lines,R.lineWidths,R.lineHeight,R.maxLineWidth,R.fontProperties,{runsByLine:R.runsByLine,lineAscents:R.lineAscents,lineDescents:R.lineDescents,lineHeights:R.lineHeights,hasDropShadow:R.hasDropShadow});return ct._measurementCache.set(o,z),z}const l=e._fontString,h=ct.measureFont(l);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const u=ct._context;u.font=l;const p=(n?ct._wordWrap(t,e,s):t).split(jg),m=new Array(p.length);let g=0;for(let R=0;R<p.length;R++){const z=ct._measureText(p[R],e.letterSpacing,u);m[R]=z,g=Math.max(g,z)}const y=((O=e._stroke)==null?void 0:O.width)??0,x=e.lineHeight||h.fontSize,w=ct._getAlignWidth(g,e,n),S=ct._adjustWidthForStyle(w,e),A=Math.max(x,h.fontSize+y)+(p.length-1)*(x+e.leading),L=ct._adjustHeightForStyle(A,e),I=new ct(t,e,S,L,p,m,x+e.leading,g,h);return ct._measurementCache.set(o,I),I}static _adjustWidthForStyle(t,e){var o;const s=((o=e._stroke)==null?void 0:o.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 _getAlignWidth(t,e,s){return s&&e.align!=="left"?Math.max(t,e.wordWrapWidth):t}static _measureText(t,e,s){let n=!1;ct.experimentalLetterSpacingSupported&&(ct.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,n=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const o=s.measureText(t);let r=o.width;const l=-(o.actualBoundingBoxLeft??0);let u=(o.actualBoundingBoxRight??0)-l;if(r>0)if(n)r-=e,u-=e;else{const d=(ct.graphemeSegmenter(t).length-1)*e;r+=d,u+=d}return Math.max(r,u)}static _wordWrap(t,e,s=ct._canvas){return e0(t,e,s,ct._measureText,ct.canBreakWords,ct.canBreakChars,ct.wordWrapSplit)}static isBreakingSpace(t,e){return Me(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,n,o){return!0}static wordWrapSplit(t){return ct.graphemeSegmenter(t)}static measureFont(t){if(ct._fonts[t])return ct._fonts[t];const e=ct._context;e.font=t;const s=e.measureText(ct.METRICS_STRING+ct.BASELINE_SYMBOL),n=s.actualBoundingBoxAscent??0,o=s.actualBoundingBoxDescent??0,r={ascent:n,descent:o,fontSize:n+o};return ct._fonts[t]=r,r}static clearMetrics(t=""){t?delete ct._fonts[t]:ct._fonts={}}static get _canvas(){if(!ct.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",$c);if(s!=null&&s.measureText)return ct.__canvas=e,e;t=Se.get().createCanvas()}catch{t=Se.get().createCanvas()}t.width=t.height=10,ct.__canvas=t}return ct.__canvas}static get _context(){return ct.__context||(ct.__context=ct._canvas.getContext("2d",$c)),ct.__context}};cs.METRICS_STRING="|ÉqÅ";cs.BASELINE_SYMBOL="M";cs.BASELINE_MULTIPLIER=1.4;cs.HEIGHT_MULTIPLIER=2;cs.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>{const e=i.segment(t),s=[];let n=0;for(const o of e)s[n++]=o.segment;return s}}return i=>[...i]})();cs.experimentalLetterSpacing=!1;cs._fonts={};cs._measurementCache=zg(1e3);let ni=cs;const s0=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Fa(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)&&!s0.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const zc=1e5;function xo(i,t,e,s=0,n=0,o=0){if(i.texture===It.WHITE&&!i.fill)return Yt.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof cr){const r=i.fill,l=t.createPattern(r.texture.source.resource,"repeat"),h=r.transform.copyTo(_t.shared);return h.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),l.setTransform(h),l}else if(i.fill instanceof ls){const r=i.fill,l=r.type==="linear",h=r.textureSpace==="local";let u=1,d=1;h&&e&&(u=e.width+s,d=e.height+s);let p,m=!1;if(l){const{start:g,end:y}=r;p=t.createLinearGradient(g.x*u+n,g.y*d+o,y.x*u+n,y.y*d+o),m=Math.abs(y.x-g.x)<Math.abs((y.y-g.y)*.1)}else{const{center:g,innerRadius:y,outerCenter:x,outerRadius:w}=r;p=t.createRadialGradient(g.x*u+n,g.y*d+o,y*u,x.x*u+n,x.y*d+o,w*u)}if(m&&h&&e){const g=e.lineHeight/d;for(let y=0;y<e.lines.length;y++){const x=(y*e.lineHeight+s/2)/d;r.colorStops.forEach(w=>{let S=x+w.offset*g;S=Math.max(0,Math.min(1,S)),p.addColorStop(Math.floor(S*zc)/zc,Yt.shared.setValue(w.color).toHex())})}}else r.colorStops.forEach(g=>{p.addColorStop(g.offset,Yt.shared.setValue(g.color).toHex())});return p}}else{const r=t.createPattern(i.texture.source.resource,"repeat"),l=i.matrix.copyTo(_t.shared);return l.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),r.setTransform(l),r}return fe("FillStyle not recognised",i),"red"}const Fc=new Ht;function Gi(i){let t=0;for(let e=0;e<i.length;e++)i.charCodeAt(e)===32&&t++;return t}class i0{getCanvasAndContext(t){const{text:e,style:s,resolution:n=1}=t,o=s._getFinalPadding(),r=ni.measureText(e||" ",s),l=Math.ceil(Math.ceil(Math.max(1,r.width)+o*2)*n),h=Math.ceil(Math.ceil(Math.max(1,r.height)+o*2)*n),u=za.getOptimalCanvasAndContext(l,h);this._renderTextToCanvas(s,o,n,u,r);const d=s.trim?Dg({canvas:u.canvas,width:l,height:h,resolution:1,output:Fc}):Fc.set(0,0,l,h);return{canvasAndContext:u,frame:d}}returnCanvasAndContext(t){za.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,n,o){var R,z,Q;if(o.runsByLine&&o.runsByLine.length>0){this._renderTaggedTextToCanvas(o,t,e,s,n);return}const{canvas:r,context:l}=n,h=Fa(t),u=o.lines,d=o.lineHeight,p=o.lineWidths,m=o.maxLineWidth,g=o.fontProperties,y=r.height;if(l.resetTransform(),l.scale(s,s),l.textBaseline=t.textBaseline,(R=t._stroke)!=null&&R.width){const X=t._stroke;l.lineWidth=X.width,l.miterLimit=X.miterLimit,l.lineJoin=X.join,l.lineCap=X.cap}l.font=h;let x,w;const S=t.dropShadow?2:1,A=t.wordWrap?t.wordWrapWidth:m,I=(((z=t._stroke)==null?void 0:z.width)??0)/2;let O=(d-g.fontSize)/2;d-g.fontSize<0&&(O=0);for(let X=0;X<S;++X){const j=t.dropShadow&&X===0,Z=j?Math.ceil(Math.max(1,y)+e*2):0,it=Z*s;if(j)this._setupDropShadow(l,t,s,it);else{const ot=t._gradientBounds,rt=t._gradientOffset;if(ot){const Et={width:ot.width,height:ot.height,lineHeight:ot.height,lines:o.lines};this._setFillAndStrokeStyles(l,t,Et,e,I,(rt==null?void 0:rt.x)??0,(rt==null?void 0:rt.y)??0)}else rt?this._setFillAndStrokeStyles(l,t,o,e,I,rt.x,rt.y):this._setFillAndStrokeStyles(l,t,o,e,I);l.shadowColor="rgba(0,0,0,0)"}for(let ot=0;ot<u.length;ot++){x=I,w=I+ot*d+g.ascent+O,x+=this._getAlignmentOffset(p[ot],A,t.align);let rt=0;if(t.align==="justify"&&t.wordWrap&&ot<u.length-1){const Et=Gi(u[ot]);Et>0&&(rt=(A-p[ot])/Et)}(Q=t._stroke)!=null&&Q.width&&this._drawLetterSpacing(u[ot],t,n,x+e,w+e-Z,!0,rt),t._fill!==void 0&&this._drawLetterSpacing(u[ot],t,n,x+e,w+e-Z,!1,rt)}}}_renderTaggedTextToCanvas(t,e,s,n,o){var I,O,R;const{canvas:r,context:l}=o,{runsByLine:h,lineWidths:u,maxLineWidth:d,lineAscents:p,lineHeights:m,hasDropShadow:g}=t,y=r.height;l.resetTransform(),l.scale(n,n),l.textBaseline=e.textBaseline;const x=g?2:1,w=e.wordWrap?e.wordWrapWidth:d;let S=((I=e._stroke)==null?void 0:I.width)??0;for(const z of h)for(const Q of z){const X=((O=Q.style._stroke)==null?void 0:O.width)??0;X>S&&(S=X)}const A=S/2,L=[];for(let z=0;z<h.length;z++){const Q=h[z],X=[];for(const j of Q){const Z=Fa(j.style);l.font=Z,X.push({width:ni._measureText(j.text,j.style.letterSpacing,l),font:Z})}L.push(X)}for(let z=0;z<x;++z){const Q=g&&z===0,X=Q?Math.ceil(Math.max(1,y)+s*2):0,j=X*n;Q||(l.shadowColor="rgba(0,0,0,0)");let Z=A;for(let it=0;it<h.length;it++){const ot=h[it],rt=u[it],Et=p[it],J=m[it],et=L[it];let bt=A;bt+=this._getAlignmentOffset(rt,w,e.align);let nt=0;if(e.align==="justify"&&e.wordWrap&&it<h.length-1){let At=0;for(const ht of ot)At+=Gi(ht.text);At>0&&(nt=(w-rt)/At)}const gt=Z+Et;let St=bt+s;for(let At=0;At<ot.length;At++){const ht=ot[At],{width:$t,font:qt}=et[At];if(l.font=qt,l.textBaseline=ht.style.textBaseline,(R=ht.style._stroke)!=null&&R.width){const Ot=ht.style._stroke;if(l.lineWidth=Ot.width,l.miterLimit=Ot.miterLimit,l.lineJoin=Ot.join,l.lineCap=Ot.cap,Q)if(ht.style.dropShadow)this._setupDropShadow(l,ht.style,n,j);else{const ke=Gi(ht.text);St+=$t+ke*nt;continue}else{const ke=ni.measureFont(qt),Le=ht.style.lineHeight||ke.fontSize,pe={width:$t,height:Le,lineHeight:Le,lines:[ht.text]};l.strokeStyle=xo(Ot,l,pe,s*2,St-s,Z)}this._drawLetterSpacing(ht.text,ht.style,o,St,gt+s-X,!0,nt)}const be=Gi(ht.text);St+=$t+be*nt}St=bt+s;for(let At=0;At<ot.length;At++){const ht=ot[At],{width:$t,font:qt}=et[At];if(l.font=qt,l.textBaseline=ht.style.textBaseline,ht.style._fill!==void 0){if(Q)if(ht.style.dropShadow)this._setupDropShadow(l,ht.style,n,j);else{const Ot=Gi(ht.text);St+=$t+Ot*nt;continue}else{const Ot=ni.measureFont(qt),ke=ht.style.lineHeight||Ot.fontSize,Le={width:$t,height:ke,lineHeight:ke,lines:[ht.text]};l.fillStyle=xo(ht.style._fill,l,Le,s*2,St-s,Z)}this._drawLetterSpacing(ht.text,ht.style,o,St,gt+s-X,!1,nt)}const be=Gi(ht.text);St+=$t+be*nt}Z+=J}}}_setFillAndStrokeStyles(t,e,s,n,o,r=0,l=0){var h;if(t.fillStyle=e._fill?xo(e._fill,t,s,n*2,r,l):null,(h=e._stroke)!=null&&h.width){const u=o+n*2;t.strokeStyle=xo(e._stroke,t,s,u,r,l)}}_setupDropShadow(t,e,s,n){t.fillStyle="black",t.strokeStyle="black";const o=e.dropShadow,r=o.color,l=o.alpha;t.shadowColor=Yt.shared.setValue(r).setAlpha(l).toRgbaString();const h=o.blur*s,u=o.distance*s;t.shadowBlur=h,t.shadowOffsetX=Math.cos(o.angle)*u,t.shadowOffsetY=Math.sin(o.angle)*u+n}_getAlignmentOffset(t,e,s){return s==="right"?e-t:s==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,s,n,o,r=!1,l=0){const{context:h}=s,u=e.letterSpacing;let d=!1;if(ni.experimentalLetterSpacingSupported&&(ni.experimentalLetterSpacing?(h.letterSpacing=`${u}px`,h.textLetterSpacing=`${u}px`,d=!0):(h.letterSpacing="0px",h.textLetterSpacing="0px")),(u===0||d)&&l===0){r?h.strokeText(t,n,o):h.fillText(t,n,o);return}if(l!==0&&(u===0||d)){const x=t.split(" ");let w=n;const S=h.measureText(" ").width;for(let A=0;A<x.length;A++)r?h.strokeText(x[A],w,o):h.fillText(x[A],w,o),w+=h.measureText(x[A]).width+S+l;return}let p=n;const m=ni.graphemeSegmenter(t);let g=h.measureText(t).width,y=0;for(let x=0;x<m.length;++x){const w=m[x];r?h.strokeText(w,p,o):h.fillText(w,p,o);let S="";for(let A=x+1;A<m.length;++A)S+=m[A];y=h.measureText(S).width,p+=g-y+u,w===" "&&(p+=l),g=y}}}const tn=new i0,bl=class Li extends Ze{constructor(t={}){super(),this.uid=Gt("textStyle"),this._tick=0,this._cachedFontString=null,n0(t),t instanceof Li&&(t=t._toObject());const n={...Li.defaultTextStyle,...t};for(const o in n){const r=o;this[r]=n[o]}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({...Li.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Li.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({...$e.defaultFillStyle,...t},()=>{this._fill=Ri({...this._originalFill},$e.defaultFillStyle)})),this._fill=Ri(t===0?"black":t,$e.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...$e.defaultStrokeStyle,...t},()=>{this._stroke=Ko({...this._originalStroke},$e.defaultStrokeStyle)})),this._stroke=Ko(t,$e.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=Li.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=Fa(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 Li(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){var s,n,o,r;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const l=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(l),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(l),(o=this._stroke)!=null&&o.texture&&this._stroke.texture.destroy(l),(r=this._originalStroke)!=null&&r.texture&&this._originalStroke.texture.destroy(l)}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,o)=>(s[n]===o||(s[n]=o,e==null||e(n,o),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Yt.isColorLike(t)||t instanceof ls||t instanceof cr)}};bl.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};bl.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 je=bl;function n0(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=je.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){wt(Wt,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Yt.isColorLike(e))s.color=e;else if(e instanceof ls||e instanceof cr)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(wt(Wt,"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&&fe("The number of fill colors must match the number of fill gradient stops.");const e=new ls({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=t.fillGradientStops.slice(),n=t.fill.map(o=>Yt.shared.setValue(o).toNumber());s.forEach((o,r)=>{e.addColorStop(o,n[r])}),i.fill={fill:e}}}function o0(i,t){const{texture:e,bounds:s}=i,n=t._style._getFinalPadding();jh(s,t._anchor,e);const o=t._anchor._x*n*2,r=t._anchor._y*n*2;s.minX-=n-o,s.minY-=n-r,s.maxX-=n-o,s.maxY-=n-r}class r0{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 a0 extends r0{}class du{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new no({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}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,o0(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 a0;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}}du.extension={type:[mt.WebGLPipes,mt.WebGPUPipes,mt.CanvasPipes],name:"text"};const l0=new Pe;function c0(i,t,e,s,n=!1){const o=l0;o.minX=0,o.minY=0,o.maxX=i.width/s|0,o.maxY=i.height/s|0;const r=or.getOptimalTexture(o.width,o.height,s,!1,n);return r.source.uploadMethodId="image",r.source.resource=i,r.source.alphaMode="premultiply-alpha-on-upload",r.frame.width=t/s,r.frame.height=e/s,r.source.emit("update",r.source),r.updateUvs(),r}class uu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,n){typeof t=="string"&&(wt("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof je||(t.style=new je(t.style)),t.textureStyle instanceof ln||(t.textureStyle=new ln(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:r,textureStyle:l,autoGenerateMipmaps:h}=t,u=t.resolution??this._renderer.resolution,{frame:d,canvasAndContext:p}=tn.getCanvasAndContext({text:o,style:r,resolution:u}),m=c0(p.canvas,d.width,d.height,u,h);if(l&&(m.source.style=l),r.trim&&(d.pad(r.padding),m.frame.copyFrom(d),m.frame.scale(1/u),m.updateUvs()),r.filters){const g=this._applyFilters(m,r.filters);return this.returnTexture(m),tn.returnCanvasAndContext(p),g}return this._renderer.texture.initSource(m._source),this._retainCanvasContext||tn.returnCanvasAndContext(p),m}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&(s!=null&&s.getContext)){const n=s.getContext("2d");n&&tn.returnCanvasAndContext({canvas:s,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",or.returnTexture(t,!0)}renderTextToCanvas(){wt("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){var e;return((e=this._activeTextures[t])==null?void 0:e.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 fu extends uu{constructor(t){super(t,!0)}}fu.extension={type:[mt.CanvasSystem],name:"canvasText"};class pu extends uu{constructor(t){super(t,!1)}}pu.extension={type:[mt.WebGLSystem,mt.WebGPUSystem],name:"canvasText"};Ut.add(fu);Ut.add(pu);Ut.add(du);class rn extends Ig{constructor(...t){const e=Lg(t,"Text");super(e,je),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof ln?e.textureStyle:new ln(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??Ie.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,n=0;if(this._style.trim){const{frame:o,canvasAndContext:r}=tn.getCanvasAndContext({text:this.text,style:this._style,resolution:1});tn.returnCanvasAndContext(r),s=o.width,n=o.height}else{const o=ni.measureText(this._text,this._style);s=o.width,n=o.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}}Ut.add(Ru,Du);const h0={Read:"📖",Write:"✏️",Edit:"🔧",Patch:"🔧",Bash:"💻",Glob:"🔍",Grep:"🔎",WebSearch:"🌐",WebFetch:"🌐",Agent:"🤖",TeamCreate:"👥",SendMessage:"💬",TaskCreate:"📋",TaskUpdate:"✅",TodoRead:"📋",TodoWrite:"✅",AskUserQuestion:"❓",EnterPlanMode:"📝",ExitPlanMode:"📝"},Nc=12,vo=[5,4,3],ze=[{id:"search",label:"Search",description:"Grep, WebSearch — Research & lookup",icon:"📚",color:15381256,colStart:0,colSpan:5,rowStart:0,rowSpan:1,x:0,y:0,width:0,height:0},{id:"terminal",label:"Terminal",description:"Bash commands — Server room",icon:"💻",color:2278750,colStart:5,colSpan:3,rowStart:0,rowSpan:1,x:0,y:0,width:0,height:0},{id:"web",label:"Web",description:"WebFetch, Browser — Network hub",icon:"🌐",color:9133302,colStart:8,colSpan:4,rowStart:0,rowSpan:1,x:0,y:0,width:0,height:0},{id:"files",label:"Files",description:"Read, Write, Edit, Glob — File storage",icon:"📁",color:3900150,colStart:0,colSpan:4,rowStart:1,rowSpan:1,x:0,y:0,width:0,height:0},{id:"thinking",label:"Thinking",description:"Planning, Questions — Conference area",icon:"💭",color:16347926,colStart:4,colSpan:5,rowStart:1,rowSpan:1,x:0,y:0,width:0,height:0},{id:"messaging",label:"Messaging",description:"SendMessage, Teams — Chat & relax",icon:"💬",color:15485081,colStart:9,colSpan:3,rowStart:1,rowSpan:1,x:0,y:0,width:0,height:0},{id:"spawn",label:"Spawn",description:"Agent spawn/despawn — Entry portal",icon:"🌀",color:11032055,colStart:0,colSpan:3,rowStart:2,rowSpan:1,x:0,y:0,width:0,height:0},{id:"idle",label:"Idle",description:"Idle agents rest here — Kitchen & lounge",icon:"☕",color:7041664,colStart:3,colSpan:5,rowStart:2,rowSpan:1,x:0,y:0,width:0,height:0},{id:"tasks",label:"Tasks",description:"TaskCreate, TaskUpdate — Kanban & planning",icon:"📋",color:1357990,colStart:8,colSpan:4,rowStart:2,rowSpan:1,x:0,y:0,width:0,height:0}],Vt=new Map(ze.map(i=>[i.id,i]));let Na=1100,Wa=980;function d0(i,t){Na=i,Wa=t}const dt=[{name:"blue",body:4886745,outline:2906762,highlight:8042741,eye:16777215,skin:16767916},{name:"green",body:5025616,outline:3046706,highlight:8505220,eye:16777215,skin:16767916},{name:"red",body:15037299,outline:12986408,highlight:16764370,eye:16777215,skin:16767916},{name:"purple",body:11225020,outline:6953882,highlight:13538264,eye:16777215,skin:16767916},{name:"orange",body:16750592,outline:15094016,highlight:16764032,eye:16777215,skin:16767916},{name:"cyan",body:2541274,outline:33679,highlight:8445674,eye:16777215,skin:16767916},{name:"pink",body:15753874,outline:12720219,highlight:16301008,eye:16777215,skin:16767916},{name:"teal",body:2533018,outline:26972,highlight:8440772,eye:16777215,skin:16767916},{name:"amber",body:16761095,outline:16748288,highlight:16769154,eye:3355443,skin:16767916},{name:"indigo",body:6056896,outline:2635155,highlight:10463450,eye:16777215,skin:16767916},{name:"lime",body:10275941,outline:5606191,highlight:12968357,eye:3355443,skin:16767916},{name:"brown",body:9268835,outline:5125166,highlight:12364452,eye:16777215,skin:16767916}],mu={background:1711672},he={"claude-opus-4-6":{input:15,output:75},"claude-opus-4-5-20250620":{input:15,output:75},"claude-sonnet-4-6":{input:3,output:15},"claude-sonnet-4-5-20250514":{input:3,output:15},"claude-sonnet-4-0-20250514":{input:3,output:15},"claude-haiku-4-5-20251001":{input:1,output:5},"claude-3-7-sonnet-20250219":{input:3,output:15},"claude-3-5-sonnet-20241022":{input:3,output:15},"claude-3-5-haiku-20241022":{input:1,output:5},"claude-3-opus-20240229":{input:15,output:75},"gpt-4o":{input:2.5,output:10},"gpt-4o-mini":{input:.15,output:.6},"gpt-4-turbo":{input:10,output:30},"gpt-4":{input:30,output:60},o1:{input:15,output:60},"o1-mini":{input:1.1,output:4.4},o3:{input:10,output:40},"o3-mini":{input:1.1,output:4.4},"o4-mini":{input:1.1,output:4.4},"gemini-2.5-pro":{input:1.25,output:10},"gemini-2.5-flash":{input:.15,output:.6},"gemini-2.0-flash":{input:.1,output:.4},"gemini-2.0-flash-lite":{input:.075,output:.3},"gemini-1.5-pro":{input:1.25,output:5},"gemini-1.5-flash":{input:.075,output:.3},"deepseek-chat":{input:.27,output:1.1},"deepseek-reasoner":{input:.55,output:2.19},"grok-3":{input:3,output:15},"grok-3-mini":{input:.3,output:.5},"grok-2":{input:2,output:10},"mistral-large":{input:2,output:6},"mistral-small":{input:.1,output:.3},codestral:{input:.1,output:.3}},Wc={input:3,output:15},Fr={claude:2e5,"gpt-4o":128e3,"gpt-4o-mini":128e3,"gpt-4-turbo":128e3,"gpt-4":8192,o1:2e5,"o1-mini":128e3,o3:2e5,"o3-mini":2e5,"o4-mini":2e5,"gemini-2":1e6,"gemini-1.5":1e6,"deepseek-chat":64e3,"deepseek-reasoner":128e3,"grok-3":131072,"grok-2":131072,"mistral-large":128e3,"mistral-small":32e3,codestral:256e3};function _l(i){if(!i)return Wc;const t=i.toLowerCase();if(he[t])return he[t];for(const[e,s]of Object.entries(he))if(t.startsWith(e)||t.includes(e))return s;return t.includes("opus")?he["claude-opus-4-6"]:t.includes("haiku")?he["claude-haiku-4-5-20251001"]:t.includes("sonnet")?he["claude-sonnet-4-6"]:t.includes("o3-mini")||t.includes("o4-mini")?he["o3-mini"]:t.includes("o1-mini")?he["o1-mini"]:t.includes("gemini-2.5")?he["gemini-2.5-pro"]:t.includes("gemini-2")?he["gemini-2.0-flash"]:t.includes("gemini")?he["gemini-1.5-pro"]:t.includes("gpt-4o")?he["gpt-4o"]:t.includes("deepseek")?he["deepseek-chat"]:t.includes("grok")?he["grok-3"]:t.includes("mistral")?he["mistral-large"]:Wc}function u0(i){if(!i)return 2e5;const t=i.toLowerCase();if(Fr[t])return Fr[t];let e=null;for(const[s,n]of Object.entries(Fr))(t.startsWith(s)||t.includes(s))&&(!e||s.length>e[0].length)&&(e=[s,n]);return e?e[1]:2e5}function gu(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%dt.length}function xl(i){const t=_l(i.model);return i.totalInputTokens/1e6*t.input+i.totalOutputTokens/1e6*t.output+i.cacheReadTokens/1e6*t.input*.1+i.cacheCreationTokens/1e6*t.input*1.25}const Gc=["Pixel","Turbo","Nimbus","Sparky","Biscuit","Wombat","Noodle","Zigzag","Pickle","Mango","Rocket","Waffle","Pebble","Comet","Doodle","Gizmo","Quasar","Tango","Breeze","Fidget","Blitz","Marble","Sprout","Fizz","Cosmo","Rusty","Tofu","Orbit","Jinx","Clover","Bolt","Mochi","Atlas","Ember","Pippin","Rumble","Sage","Twix","Flint","Bumble","Nova","Chip","Pecan","Drift","Pluto","Rune","Taffy","Zing","Vapor","Acorn","Sonic","Puffin","Quill","Dash","Hazel","Crisp","Fable","Maple","Glitch","Sable"];function eo(i){let t=0;for(let s=0;s<i.length;s++)t=(t<<5)-t+i.charCodeAt(s)|0;const e=Math.abs(t)%Gc.length;return Gc[e]}async function f0(i){const t=new Gd,e=document.getElementById("canvas-container")??i;return await t.init({background:mu.background,resizeTo:e,antialias:!1,resolution:window.devicePixelRatio||1,autoDensity:!0}),i.appendChild(t.canvas),t}const Oc=1e3,p0=1e4;class m0{constructor(t){b(this,"ws",null);b(this,"store");b(this,"reconnectMs",Oc);b(this,"reconnectTimer",null);b(this,"disposed",!1);this.store=t,this.store.setWsClient(this)}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(t))}connect(){if(this.disposed)return;const e=`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/ws`;this.ws=new WebSocket(e),this.ws.onopen=()=>{this.reconnectMs=Oc,this.store.setConnectionStatus("connected")},this.ws.onmessage=s=>{let n;try{n=JSON.parse(s.data)}catch{return}this.store.handleMessage(n)},this.ws.onclose=()=>{this.store.setConnectionStatus("disconnected"),this.scheduleReconnect()},this.ws.onerror=()=>{}}scheduleReconnect(){this.disposed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},this.reconnectMs),this.reconnectMs=Math.min(this.reconnectMs*2,p0))}disconnect(){this.disposed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}}const sr=class sr{constructor(){b(this,"agents",new Map);b(this,"listeners",new Map);b(this,"_connectionStatus","disconnected");b(this,"wsClient",null);b(this,"_timeline",[]);b(this,"_pendingPermissions",new Map);b(this,"_lastHookActivityAt",null)}get connectionStatus(){return this._connectionStatus}setWsClient(t){this.wsClient=t}getAgents(){return this.agents}getAgent(t){return this.agents.get(t)}requestHistory(t){var e;(e=this.wsClient)==null||e.send({type:"request:history",agentId:t})}requestToolChain(){var t;(t=this.wsClient)==null||t.send({type:"request:toolchain"})}requestTaskGraph(){var t;(t=this.wsClient)==null||t.send({type:"request:taskgraph"})}getPendingPermissions(){return Array.from(this._pendingPermissions.values())}isHooksActive(){return this._lastHookActivityAt!==null&&Date.now()-this._lastHookActivityAt<6e4}markHookActivity(){this._lastHookActivityAt=Date.now()}approvePermission(t,e){var s;(s=this.wsClient)==null||s.send({type:"permission:approve",permissionId:t,updatedInput:e})}denyPermission(t){var e;(e=this.wsClient)==null||e.send({type:"permission:deny",permissionId:t})}approvePermissionAlways(t,e){var s;(s=this.wsClient)==null||s.send({type:"permission:approve-always",permissionId:t,rules:e})}getTimeline(){return this._timeline}pushTimelineEvent(t,e,s){this._timeline.push({type:t,agent:{...e},timestamp:s});const n=Date.now()-1800*1e3;let o=0;for(;o<this._timeline.length&&this._timeline[o].timestamp<n;)o++;const r=this._timeline.length-sr.MAX_TIMELINE;r>0&&(o=Math.max(o,r)),o>0&&this._timeline.splice(0,o)}on(t,e){let s=this.listeners.get(t);s||(s=new Set,this.listeners.set(t,s)),s.add(e)}off(t,e){const s=this.listeners.get(t);s&&s.delete(e)}emit(t,e){const s=this.listeners.get(t);if(s)for(const n of s)n(e)}dispose(){this.listeners.clear(),this.agents.clear(),this._timeline=[],this._pendingPermissions.clear()}setConnectionStatus(t){this._connectionStatus=t,this.emit("connection:status",t)}handleMessage(t){switch(t.type){case"full_state":{this.agents.clear();for(const e of t.agents)this.agents.set(e.id,e);this.emit("state:reset",this.agents);break}case"agent:spawn":{this.agents.set(t.agent.id,t.agent),this.pushTimelineEvent("agent:spawn",t.agent,t.timestamp),this.emit("agent:spawn",t.agent);break}case"agent:update":{this.agents.set(t.agent.id,t.agent),this.pushTimelineEvent("agent:update",t.agent,t.timestamp),this.emit("agent:update",t.agent);break}case"agent:idle":{this.agents.set(t.agent.id,t.agent),this.pushTimelineEvent("agent:idle",t.agent,t.timestamp),this.emit("agent:idle",t.agent);break}case"agent:shutdown":{const e=this.agents.get(t.agentId);e&&this.pushTimelineEvent("agent:shutdown",e,t.timestamp),this.emit("agent:shutdown",t.agentId),this.agents.delete(t.agentId);break}case"agent:history":{this.emit("agent:history",{agentId:t.agentId,entries:t.entries});break}case"timeline:snapshot":{this._timeline=t.events,this.emit("timeline:snapshot",t.events);break}case"anomaly:alert":{this.emit("anomaly:alert",t.anomaly);break}case"toolchain:snapshot":{this.emit("toolchain:snapshot",t.data);break}case"taskgraph:snapshot":{this.emit("taskgraph:snapshot",t.data);break}case"permission:request":{this._pendingPermissions.set(t.permission.permissionId,t.permission),this.markHookActivity(),this.emit("permission:request",t.permission);break}case"permission:resolved":{this._pendingPermissions.delete(t.permissionId),this.emit("permission:resolved",{permissionId:t.permissionId,decision:t.decision});break}case"hooks:status":{this.markHookActivity(),this.emit("hooks:status",void 0);break}case"task:completed":{const e=t;this.emit("task:completed",{taskId:e.taskId,taskSubject:e.taskSubject,agentId:e.agentId});break}}}};b(sr,"MAX_TIMELINE",5e3);let Ga=sr;const g0=658452;function Hc(i,t){const e=new Ft;return e.rect(0,0,i,t).fill(g0),e}const k={darkWood:4861460,medWood:7029286,wood:8015920,lightWood:10121288,paleWood:12093515,woodFloor:10121280,woodFloorAlt:10516552,woodFloorDark:8413232,plankLine:6967336,tileBase:13681844,tileAlt:12892328,tileGrid:11576468,tileDiamond:12365984,carpet:4749472,carpetDot:5802160,carpetEdge:3692664,carpetWarm:10512456,carpetWarmAlt:9066552,carpetWarmDot:11565144,darkFloor:2631232,darkFloorAlt:3157584,darkFloorLine:2236472,greenFloor:3828282,greenFloorAlt:4880970,greenFloorDot:5933658,screenFrame:2763320,screenBody:3355460,screenBlue:6724044,screenGlow:8960989,screenDark:4478310,screenGreen:3385941,screenGreenGlow:5622903,led:4513092,ledOff:2245666,ledRed:14500932,ledBlue:4491485,bookRed:12599360,bookDarkRed:9449520,bookGreen:4235344,bookDarkGreen:3174464,bookBlue:4219072,bookNavy:3162240,bookYellow:12623920,bookPurple:8409264,bookOrange:13664304,bookCyan:3186864,bookBrown:8413248,bookPink:12607616,bookWhite:13158600,bookTan:11575424,chairSeat:10125408,chairBack:8941648,chairArm:7888960,metalBright:12303308,metalLight:10066602,metalMid:7829384,metalDark:5592422,metalFrame:4473941,leafDark:2783786,leaf:3840570,leafLight:5288016,leafBright:6736998,potBase:9132602,potDark:7031338,potRim:10119754,soil:4864554,white:15658734,offWhite:13948116,paper:15261904,cream:15788248,black:1118488,red:14500932,green:4504388,blue:4491485,yellow:14535748,vendingBody:4478310,vendingGlass:8956603,fridgeBody:11187392,fridgeLight:12897492,fridgeDark:8949912,couchFrame:7031352,couchSeat:9134160,couchCushion:10514528,couchHighlight:12091504,portalDeep:4465288,portalMid:6697898,portalLight:10048989,portalGlow:12285951,whiteboardFrame:12303308,whiteboardSurface:16053492,stickyYellow:15786080,stickyPink:15765664,stickyGreen:8441984,stickyBlue:8433888,stickyOrange:15769680},Uc=[[k.bookRed,k.bookGreen,k.bookBlue,k.bookYellow,k.bookPurple,k.bookOrange,k.bookBrown,k.bookCyan,k.bookPink,k.bookWhite,k.bookTan,k.bookNavy],[k.bookBlue,k.bookOrange,k.bookDarkGreen,k.bookPink,k.bookBrown,k.bookYellow,k.bookRed,k.bookWhite,k.bookNavy,k.bookCyan,k.bookTan,k.bookPurple],[k.bookPurple,k.bookTan,k.bookCyan,k.bookDarkRed,k.bookGreen,k.bookNavy,k.bookOrange,k.bookBrown,k.bookBlue,k.bookPink,k.bookYellow,k.bookWhite]],jn=4,c=i=>i*jn;function E(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function vl(i,t,e,s,n){E(i,t,e,s,n,k.medWood),E(i,t+c(1),e+c(1),s-c(2),n-c(2),k.wood),E(i,t+c(1),e+c(1),s-c(2),1,k.lightWood)}function wl(i,t,e,s,n){E(i,t,e,s,n,k.woodFloor);const o=c(4);let r=0;for(let l=0;l<n;l+=o){const h=Math.min(o,n-l);r%2===1&&E(i,t,e+l,s,h,k.woodFloorAlt),E(i,t,e+l,s,1,k.plankLine);const u=r%2*c(7);for(let d=u;d<s;d+=c(14))E(i,t+d,e+l,1,h,k.woodFloorDark);r++}}function y0(i,t,e,s,n){E(i,t,e,s,n,k.tileBase);const o=c(6);for(let r=0;r<n;r+=o)for(let l=0;l<s;l+=o){const h=(l/o+r/o)%2===0;h&&E(i,t+l,e+r,o,o,k.tileAlt),E(i,t+l,e+r,o,1,k.tileGrid),E(i,t+l,e+r,1,o,k.tileGrid),h||E(i,t+l+o/2-1,e+r+o/2-1,2,2,k.tileDiamond)}}function Sl(i,t,e,s,n,o,r,l,h=!0){E(i,t,e,s,n,o);for(let u=0;u<n;u+=c(2))for(let d=u/c(2)%2*c(2);d<s;d+=c(4))E(i,t+d,e+u,c(1),c(1),r);E(i,t,e,s,c(1),l),E(i,t,e+n-c(1),s,c(1),l),h&&(E(i,t,e,c(1),n,l),E(i,t+s-c(1),e,c(1),n,l))}function b0(i,t,e,s,n){Sl(i,t,e,s,n,k.carpet,k.carpetDot,k.carpetEdge)}function _0(i,t,e,s,n){Sl(i,t,e,s,n,k.carpetWarm,k.carpetWarmDot,k.carpetWarmAlt)}function yu(i,t,e,s,n){E(i,t,e,s,n,k.darkFloor);for(let o=0;o<n;o+=c(3))E(i,t,e+o,s,1,k.darkFloorLine);for(let o=c(1);o<n;o+=c(6))E(i,t,e+o,s,c(3),k.darkFloorAlt)}function x0(i,t,e,s,n){Sl(i,t,e,s,n,k.greenFloor,k.greenFloorDot,k.greenFloorAlt,!1)}function oi(i,t,e,s){const n=c(s?16:10),o=c(14);E(i,t,e,n,o,k.darkWood),E(i,t,e,c(1),o,k.medWood),E(i,t+n-c(1),e,c(1),o,k.medWood),E(i,t+c(1),e+c(1),n-c(2),o-c(2),k.wood),E(i,t,e,n,c(1),k.lightWood);for(let r=1;r<=3;r++){const l=e+r*c(3)+c(1);E(i,t,l,n,c(1),k.medWood),E(i,t+c(1),l,n-c(2),1,k.lightWood)}for(let r=0;r<3;r++){const l=e+(r+1)*c(3)+c(1),h=Uc[r%Uc.length];let u=t+c(1)+1,d=r*3;for(;u<t+n-c(2);){const p=jn-1,m=c(2)+(d*3+r)%3;E(i,u,l-m,p,m,h[d%h.length]),u+=p+1,d++}}E(i,t,e+o-c(1),n,c(1),k.medWood)}function Jo(i,t,e){const s=c(14),n=c(7);vl(i,t,e,s,n),E(i,t,e+n,s,c(2),k.medWood),E(i,t+c(1),e+n,s-c(2),c(1),k.darkWood);const o=t+c(4),r=e;E(i,o,r,c(6),c(5),k.screenFrame),E(i,o+c(1),r+c(1),c(4),c(3),k.screenBlue),E(i,o+c(1),r+c(1),c(2),c(1),k.screenGlow),E(i,o+c(2),r+c(5),c(2),c(1),k.screenBody),E(i,t+c(3),e+c(5),c(5),c(1),k.metalDark)}function qc(i,t,e){const s=c(14),n=c(7);E(i,t,e,s,n,k.metalDark),E(i,t+c(1),e+c(1),s-c(2),n-c(2),k.metalFrame);const o=t+c(3),r=e;E(i,o,r,c(8),c(5),k.screenFrame),E(i,o+c(1),r+c(1),c(6),c(3),k.screenGreen),E(i,o+c(1),r+c(1),c(3),c(1),k.screenGreenGlow),E(i,o+c(2),r+c(2),c(4),1,k.screenGreenGlow),E(i,o+c(2),r+c(3),c(3),1,k.screenGreenGlow),E(i,o+c(3),r+c(5),c(2),c(1),k.metalDark),E(i,t+c(2),e+c(5),c(6),c(1),k.metalFrame)}function Dt(i,t,e){E(i,t+c(1),e,c(3),c(1),k.chairBack),E(i,t,e+c(1),c(5),c(4),k.chairSeat),E(i,t+c(1),e+c(1),c(3),c(3),k.chairBack),E(i,t,e+c(1),c(1),c(3),k.chairArm),E(i,t+c(4),e+c(1),c(1),c(3),k.chairArm)}function _i(i,t,e){E(i,t+c(1),e+c(5),c(4),c(3),k.potBase),E(i,t+c(2),e+c(5),c(2),c(1),k.potRim),E(i,t+c(2),e+c(7),c(2),c(1),k.potDark),E(i,t+c(1),e+c(4),c(4),c(1),k.soil),E(i,t+c(2),e,c(2),c(5),k.leaf),E(i,t+c(1),e+c(1),c(1),c(3),k.leafDark),E(i,t+c(4),e+c(1),c(1),c(3),k.leafLight),E(i,t,e+c(2),c(1),c(2),k.leafDark),E(i,t+c(5),e+c(2),c(1),c(2),k.leafBright),E(i,t+c(2),e-c(1),c(2),c(1),k.leafLight)}function xi(i,t,e){E(i,t,e+c(3),c(3),c(2),k.potBase),E(i,t,e+c(4),c(3),c(1),k.potDark),E(i,t+c(1),e,c(1),c(3),k.leaf),E(i,t,e+c(1),c(1),c(1),k.leafDark),E(i,t+c(2),e+c(1),c(1),c(1),k.leafLight)}function Ki(i,t,e){const s=c(7),n=c(14);E(i,t,e,s,n,k.metalFrame),E(i,t,e,s,c(1),k.metalDark);for(let o=0;o<4;o++){const r=e+c(1)+o*c(3);E(i,t+c(1),r,s-c(2),c(2),k.metalDark),E(i,t+c(1),r,s-c(2),c(1),k.metalMid),E(i,t+c(2),r+c(1),c(1),c(1),o<3?k.led:k.ledOff),E(i,t+s-c(3),r+c(1),c(1),c(1),k.led),E(i,t+c(3),r+c(1),c(1),c(1),k.black)}E(i,t,e+n-c(1),s,c(1),k.metalFrame)}function en(i,t,e){const s=c(5),n=c(10);E(i,t,e,s,n,k.metalDark),E(i,t+c(1),e+c(1),s-c(2),c(3),k.metalMid),E(i,t+c(1),e+c(5),s-c(2),c(3),k.metalMid),E(i,t+c(2),e+c(2),c(1),c(1),k.metalFrame),E(i,t+c(2),e+c(6),c(1),c(1),k.metalFrame),E(i,t+c(1),e+c(1),c(2),c(1),k.paper),E(i,t+c(1),e+c(5),c(2),c(1),k.paper),E(i,t,e+n-c(1),s,c(1),k.metalFrame)}function Oa(i,t,e,s){E(i,t-s/2+3,e-s/2+3,s,s,k.darkWood);const n=s/2;E(i,t-n+c(2),e-n,s-c(4),c(1),k.medWood),E(i,t-n+c(2),e+n-c(1),s-c(4),c(1),k.medWood),E(i,t-n,e-n+c(2),c(1),s-c(4),k.medWood),E(i,t+n-c(1),e-n+c(2),c(1),s-c(4),k.medWood),E(i,t-n+c(1),e-n+c(1),s-c(2),c(1),k.medWood),E(i,t-n+c(1),e+n-c(2),s-c(2),c(1),k.medWood),E(i,t-n+c(1),e-n+c(1),c(1),s-c(2),k.medWood),E(i,t+n-c(2),e-n+c(1),c(1),s-c(2),k.medWood),E(i,t-n+c(2),e-n+c(1),s-c(4),s-c(2),k.wood),E(i,t-n+c(1),e-n+c(2),s-c(2),s-c(4),k.wood),E(i,t-c(3),e-c(2),c(5),c(1),k.lightWood),E(i,t-c(2),e,c(4),1,k.lightWood)}function Ha(i,t,e,s,n){E(i,t,e,s,n,k.whiteboardFrame),E(i,t+c(1),e+c(1),s-c(2),n-c(2),k.whiteboardSurface),E(i,t+c(2),e+c(2),s*.4,c(1),k.blue),E(i,t+c(2),e+c(4),s*.6,c(1),k.red),E(i,t+c(2),e+c(6),s*.3,c(1),k.black),s>c(16)&&(E(i,t+s/2,e+c(2),s*.3,c(1),k.green),E(i,t+s/2,e+c(4),s*.2,c(1),k.blue)),E(i,t+c(2),e+n,s-c(4),c(1),k.metalDark),E(i,t+c(3),e+n,c(1),c(1),k.red),E(i,t+c(5),e+n,c(1),c(1),k.blue)}function v0(i,t,e,s){E(i,t,e,c(3),c(3),s),E(i,t,e,c(3),1,0),E(i,t+c(1),e+c(1),c(1),1,k.metalDark)}function Vc(i,t,e,s){E(i,t,e,s,c(3),k.couchFrame),E(i,t+c(1),e+c(1),s-c(2),c(1),k.couchHighlight),E(i,t,e+c(3),s,c(5),k.couchSeat);const n=Math.floor((s-c(3))/2);E(i,t+c(1),e+c(3),n,c(4),k.couchCushion),E(i,t+c(1),e+c(3),n,c(1),k.couchHighlight),E(i,t+c(2)+n,e+c(3),n,c(4),k.couchCushion),E(i,t+c(2)+n,e+c(3),n,c(1),k.couchHighlight),E(i,t,e,c(1),c(8),k.couchFrame),E(i,t+s-c(1),e,c(1),c(8),k.couchFrame)}function so(i,t,e,s,n){vl(i,t,e,s,n)}function w0(i,t,e){const s=c(8),n=c(16);E(i,t,e,s,n,k.vendingBody),E(i,t,e,s,c(1),k.metalDark),E(i,t+c(1),e+c(2),s-c(2),c(9),k.vendingGlass);const o=[k.bookRed,k.bookOrange,k.bookGreen,k.bookBlue,k.bookYellow];for(let r=0;r<4;r++){for(let l=0;l<3;l++)E(i,t+c(2)+l*c(2),e+c(3)+r*c(2),c(1),c(1),o[(r+l)%o.length]);E(i,t+c(1),e+c(4)+r*c(2),s-c(2),1,k.metalDark)}E(i,t+c(1),e+c(12),s-c(2),c(3),k.black),E(i,t+s-c(2),e+c(4),c(1),c(1),k.red),E(i,t+s-c(2),e+c(6),c(1),c(1),k.green)}function S0(i,t,e){const s=c(6),n=c(14);E(i,t,e,s,n,k.fridgeBody),E(i,t+c(1),e+c(1),s-c(2),n-c(2),k.fridgeLight),E(i,t+c(1),e+c(6),s-c(2),c(1),k.fridgeDark),E(i,t+s-c(2),e+c(3),c(1),c(2),k.metalMid),E(i,t+s-c(2),e+c(8),c(1),c(2),k.metalMid),E(i,t,e,s,c(1),k.metalLight),E(i,t,e+n-c(1),s,c(1),k.fridgeDark)}function k0(i,t,e){E(i,t,e,c(4),c(6),k.metalDark),E(i,t+c(1),e,c(2),c(1),k.metalBright),E(i,t+c(1),e+c(3),c(2),c(1),k.red),E(i,t,e+c(5),c(4),c(1),k.metalFrame),E(i,t+c(1),e+c(4),c(2),c(2),k.white)}function T0(i,t,e){E(i,t+c(1),e,c(2),c(3),k.screenBlue),E(i,t+c(1),e,c(2),c(1),k.screenGlow),E(i,t,e+c(3),c(4),c(5),k.metalLight),E(i,t+c(1),e+c(5),c(1),c(1),k.blue),E(i,t+c(2),e+c(5),c(1),c(1),k.red),E(i,t,e+c(7),c(4),c(1),k.metalDark)}function C0(i,t,e,s){E(i,t,e,s,c(5),k.medWood),E(i,t+c(1),e+c(1),s-c(2),c(3),k.lightWood),E(i,t,e,s,c(1),k.paleWood),E(i,t,e+c(5),s,c(4),k.medWood);const n=c(4);for(let o=0;o<s-c(1);o+=n+2)E(i,t+o+1,e+c(6),n,c(2),k.wood),E(i,t+o+c(2),e+c(7),c(1),c(1),k.darkWood)}function bu(i,t,e,s,n){E(i,t,e,s,n,k.paleWood),E(i,t+c(1),e+c(1),s-c(2),n-c(2),6724044),E(i,t+c(1),e+n-c(4),c(3),c(2),k.leafDark),E(i,t+c(2),e+n-c(5),c(2),c(1),k.leaf),E(i,t+c(1),e+n-c(2),s-c(2),c(1),k.leafDark),E(i,t+s-c(3),e+c(1),c(2),c(2),k.yellow)}function _u(i,t,e){E(i,t+c(1),e,c(4),c(1),k.offWhite),E(i,t,e+c(1),c(6),c(4),k.white),E(i,t+c(1),e+c(5),c(4),c(1),k.offWhite),E(i,t+c(1),e+c(1),c(4),c(4),k.cream),E(i,t+c(3),e+c(1),c(1),c(1),k.black),E(i,t+c(4),e+c(3),c(1),c(1),k.black),E(i,t+c(3),e+c(4),c(1),c(1),k.black),E(i,t+c(1),e+c(3),c(1),c(1),k.black),E(i,t+c(3),e+c(2),c(1),c(2),k.black),E(i,t+c(3),e+c(3),c(1),c(1),k.red)}function dn(i,t,e){E(i,t,e,c(2),c(2),k.white),E(i,t+c(2),e+c(1),c(1),c(1),k.offWhite)}function zi(i,t,e){E(i,t+2,e+2,c(3),c(4),k.offWhite),E(i,t,e,c(3),c(4),k.paper),E(i,t+jn,e+jn,c(1),1,k.metalDark),E(i,t+jn,e+c(2),c(2),1,k.metalDark)}function Nr(i,t,e,s){E(i,t,e,c(4),c(3),s),E(i,t,e,c(4),c(1),k.paleWood),E(i,t+c(1),e+c(1),c(2),c(1),k.darkWood)}function A0(i,t,e){E(i,t-c(6),e-c(1),c(12),c(2),k.portalDeep),E(i,t-c(1),e-c(6),c(2),c(12),k.portalDeep),E(i,t-c(4),e-c(5),c(8),c(1),k.portalMid),E(i,t-c(5),e-c(4),c(10),c(1),k.portalLight),E(i,t-c(6),e-c(3),c(1),c(6),k.portalMid),E(i,t+c(5),e-c(3),c(1),c(6),k.portalMid),E(i,t-c(5),e-c(3),c(1),c(6),k.portalLight),E(i,t+c(4),e-c(3),c(1),c(6),k.portalLight),E(i,t-c(5),e+c(3),c(10),c(1),k.portalLight),E(i,t-c(4),e+c(4),c(8),c(1),k.portalMid),E(i,t-c(3),e-c(3),c(6),c(6),k.portalDeep),E(i,t-c(2),e-c(2),c(4),c(4),k.portalMid),E(i,t-c(1),e-c(1),c(2),c(2),k.portalGlow),E(i,t-c(3),e,c(1),c(1),k.portalGlow),E(i,t+c(2),e-c(1),c(1),c(1),k.portalGlow),E(i,t,e+c(2),c(1),c(1),k.portalGlow)}function M0(i,t,e){const s=c(12),n=c(6);vl(i,t,e,s,n),E(i,t,e+n,s,c(2),k.medWood);const o=t+c(3),r=e+c(1);E(i,o,r,c(6),c(4),k.metalDark),E(i,o+c(1),r+c(1),c(4),c(2),k.screenBlue),E(i,o+c(1),r+c(1),c(2),c(1),k.screenGlow)}function E0(i,t,e,s,n){E(i,t,e,s,n,k.whiteboardFrame),E(i,t+c(1),e+c(1),s-c(2),n-c(2),k.whiteboardSurface);const o=Math.floor((s-c(4))/3),r=[k.bookRed,k.bookYellow,k.bookGreen];for(let l=0;l<3;l++){const h=t+c(2)+l*(o+c(1));E(i,h,e+c(2),o,c(2),r[l]);const u=[k.stickyYellow,k.stickyBlue,k.stickyPink,k.stickyGreen],d=l===0?3:l===1?2:1;for(let p=0;p<d;p++)E(i,h+2,e+c(5)+p*c(3),o-4,c(2),u[(l+p)%u.length]),E(i,h+c(1),e+c(5)+p*c(3)+2,o-c(3),1,k.metalDark)}}function P0(i,t,e){const s=c(20),n=c(14);E(i,t,e,s,n,k.screenFrame),E(i,t+c(1),e+c(1),s-c(2),n-c(2),k.screenDark),E(i,t+c(2),e+c(2),s-c(4),n-c(4),k.screenBlue);const o=t+s/2,r=e+n/2;E(i,o-c(3),r-c(2),c(6),c(4),2258858),E(i,o-c(2),r-c(3),c(4),c(1),2258858),E(i,o-c(2),r+c(2),c(4),c(1),2258858),E(i,o-c(2),r-c(1),c(2),c(2),k.leafDark),E(i,o+c(1),r,c(2),c(1),k.leafDark),E(i,o-c(1),r+c(1),c(1),c(1),k.leaf),E(i,t+c(2),e+c(2),s-c(4),1,8960989),E(i,t+c(2),e+n-c(3),s-c(4),1,8960989)}function I0(i,t,e,s,n){wl(i,t,e,s,n),oi(i,t+c(2),e+c(7),!0),oi(i,t+c(20),e+c(7),!0),oi(i,t+c(38),e+c(7),!0),oi(i,t+c(56),e+c(7),!1),oi(i,t+c(2),e+c(23),!1),oi(i,t+c(2),e+c(39),!1),so(i,t+c(18),e+c(35),c(12),c(6)),Dt(i,t+c(21),e+c(43)),Dt(i,t+c(21),e+c(29)),so(i,t+c(40),e+c(35),c(12),c(6)),Dt(i,t+c(43),e+c(43)),Dt(i,t+c(43),e+c(29)),zi(i,t+c(20),e+c(36)),zi(i,t+c(42),e+c(37)),dn(i,t+c(50),e+c(36)),_i(i,t+c(2),e+n-c(12)),_i(i,t+s-c(8),e+c(23)),en(i,t+s-c(7),e+n-c(14)),en(i,t+s-c(13),e+n-c(14));const o=t+c(60),r=e+c(50);E(i,o,r,c(6),c(6),k.leafDark),E(i,o+c(1),r+c(1),c(4),c(4),4491434),E(i,o+c(2),r+c(2),c(2),c(2),k.leaf),E(i,o+c(2),r+c(6),c(2),c(2),k.darkWood)}function L0(i,t,e,s,n){yu(i,t,e,s,n),Ki(i,t+c(2),e+c(7)),Ki(i,t+c(12),e+c(7)),Ki(i,t+c(22),e+c(7)),Ki(i,t+s-c(9),e+c(25)),Ki(i,t+s-c(9),e+c(43)),qc(i,t+c(4),e+c(29)),Dt(i,t+c(8),e+c(39)),qc(i,t+c(4),e+c(49)),Dt(i,t+c(8),e+c(59)),E(i,t+c(10),e+c(23),c(1),n-c(25),k.metalDark),E(i,t+c(20),e+c(23),c(1),n-c(25),k.metalDark);for(let o=0;o<3;o++)E(i,t+c(2)+o*c(3),e+n-c(4),c(2),c(1),k.bookYellow);E(i,t+c(34),e+c(9),c(6),c(10),k.metalFrame),E(i,t+c(35),e+c(10),c(1),c(1),k.led),E(i,t+c(37),e+c(10),c(1),c(1),k.led),E(i,t+c(35),e+c(12),c(1),c(1),k.ledRed),E(i,t+c(37),e+c(12),c(1),c(1),k.led),E(i,t+c(35),e+c(14),c(1),c(1),k.ledBlue),E(i,t+c(37),e+c(14),c(1),c(1),k.led)}function B0(i,t,e,s,n){b0(i,t,e,s,n),P0(i,t+c(4),e+c(7)),Ki(i,t+s-c(9),e+c(7)),Jo(i,t+c(4),e+c(27)),Dt(i,t+c(8),e+c(37)),Jo(i,t+c(28),e+c(27)),Dt(i,t+c(32),e+c(37)),so(i,t+c(14),e+c(51),c(14),c(5)),E(i,t+c(16),e+c(52),c(8),c(3),k.metalDark),E(i,t+c(17),e+c(53),c(1),c(1),k.led),E(i,t+c(19),e+c(53),c(1),c(1),k.led),E(i,t+c(21),e+c(53),c(1),c(1),k.ledBlue),_i(i,t+c(2),e+n-c(12)),xi(i,t+s-c(5),e+n-c(8)),E(i,t+s-c(2),e+c(23),c(1),n-c(27),k.metalDark)}function R0(i,t,e,s,n){wl(i,t,e,s,n),en(i,t+c(2),e+c(7)),en(i,t+c(9),e+c(7)),en(i,t+c(16),e+c(7)),en(i,t+c(23),e+c(7)),oi(i,t+c(2),e+c(21),!0),Jo(i,t+c(24),e+c(25)),Dt(i,t+c(28),e+c(35)),Nr(i,t+c(2),e+c(39),k.paleWood),Nr(i,t+c(8),e+c(41),k.medWood),Nr(i,t+c(2),e+c(43),k.lightWood),zi(i,t+c(38),e+c(9)),zi(i,t+c(26),e+c(27)),xi(i,t+s-c(5),e+n-c(8)),_i(i,t+s-c(8),e+c(21))}function D0(i,t,e,s,n){_0(i,t,e,s,n),Oa(i,t+s/2,e+n/2-c(1),c(18)),Dt(i,t+s/2-c(12),e+n/2-c(11)),Dt(i,t+s/2+c(8),e+n/2-c(11)),Dt(i,t+s/2-c(16),e+n/2-c(1)),Dt(i,t+s/2+c(12),e+n/2-c(1)),Dt(i,t+s/2-c(12),e+n/2+c(11)),Dt(i,t+s/2+c(8),e+n/2+c(11)),Ha(i,t+c(4),e+c(7),c(24),c(12)),Ha(i,t+c(32),e+c(7),c(20),c(12)),bu(i,t+s-c(14),e+c(7),c(10),c(7)),zi(i,t+s/2-c(4),e+n/2-c(3)),dn(i,t+s/2+c(2),e+n/2-c(1)),_i(i,t+c(2),e+n-c(12)),_i(i,t+s-c(8),e+n-c(12))}function $0(i,t,e,s,n){x0(i,t,e,s,n),bu(i,t+c(8),e+c(7),c(14),c(8)),oi(i,t+c(2),e+c(7),!1),Vc(i,t+c(4),e+c(21),c(16)),so(i,t+c(6),e+c(33),c(12),c(5)),dn(i,t+c(10),e+c(34)),dn(i,t+c(14),e+c(34)),Vc(i,t+c(24),e+c(25),c(10)),so(i,t+c(26),e+c(37),c(6),c(4)),zi(i,t+c(27),e+c(38)),_i(i,t+c(2),e+n-c(12)),xi(i,t+s-c(5),e+c(7)),_u(i,t+s-c(8),e+c(7))}function z0(i,t,e,s,n){yu(i,t,e,s,n),A0(i,t+s/2,e+n/2-c(2));const o=t+(s-c(14))/2,r=e+n-c(12);E(i,o,r,c(14),c(4),k.couchSeat),E(i,o+c(1),r+c(1),c(12),c(2),k.couchCushion),xi(i,t+c(2),e+c(12)),xi(i,t+s-c(5),e+c(12));for(let l=0;l<3;l++)E(i,t+c(3)+l*c(7),e+c(7),c(2),c(2),k.portalGlow)}function F0(i,t,e,s,n){y0(i,t,e,s,n),C0(i,t+c(2),e+c(7),c(28)),k0(i,t+c(4),e+c(3)),S0(i,t+c(32),e+c(7)),w0(i,t+s-c(10),e+c(7)),T0(i,t+c(42),e+c(7)),Oa(i,t+c(18),e+c(33),c(10)),Dt(i,t+c(10),e+c(29)),Dt(i,t+c(22),e+c(29)),Dt(i,t+c(10),e+c(37)),Dt(i,t+c(22),e+c(37)),Oa(i,t+c(46),e+c(33),c(10)),Dt(i,t+c(38),e+c(29)),Dt(i,t+c(50),e+c(29)),Dt(i,t+c(38),e+c(37)),Dt(i,t+c(50),e+c(37)),dn(i,t+c(17),e+c(32)),dn(i,t+c(45),e+c(32)),_u(i,t+c(52),e+c(7)),xi(i,t+c(2),e+n-c(8)),xi(i,t+s-c(5),e+n-c(8))}function N0(i,t,e,s,n){wl(i,t,e,s,n),E0(i,t+c(2),e+c(7),c(30),c(18));const o=[k.stickyYellow,k.stickyPink,k.stickyGreen,k.stickyBlue,k.stickyOrange,k.stickyYellow];for(let r=0;r<6;r++){const l=t+c(36)+r%3*c(4),h=e+c(7)+Math.floor(r/3)*c(4);v0(i,l,h,o[r])}M0(i,t+c(6),e+c(31)),Dt(i,t+c(9),e+c(41)),Jo(i,t+c(30),e+c(31)),Dt(i,t+c(34),e+c(41)),zi(i,t+c(44),e+c(33)),Ha(i,t+c(50),e+c(7),c(14),c(10)),_i(i,t+s-c(8),e+n-c(12)),xi(i,t+c(2),e+n-c(8))}const Ue={search:I0,terminal:L0,web:B0,files:R0,thinking:D0,messaging:$0,spawn:z0,idle:F0,tasks:N0},wn=12,Wr=.15,W0=.7,G0=.15,Gr=1,O0=2,H0=1710638,U0=.55,q0=16777215,V0=.04;class Y0{constructor(){b(this,"zones",new Map);b(this,"container",new Rt);b(this,"themeDecorators",null);b(this,"useRetro",!1);for(const t of ze){const e=this.createZone(t);this.zones.set(t.id,e),this.container.addChild(e.container)}}setThemeDecorators(t){this.themeDecorators=t,this.useRetro=!!t,this.rebuild()}createZone(t){const e=new Rt;e.position.set(t.x,t.y);const s=new Ft;e.addChild(s);const n=new Ft;this.drawRoom(n,t),e.addChild(n);const o=new Ft;e.addChild(o);const r=new je({fontSize:13,fontFamily:"'Inter', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif",fill:16777215,fontWeight:"600",letterSpacing:.5,dropShadow:{alpha:.6,blur:4,color:0,distance:0}}),l=new rn({text:`${t.icon} ${t.label}`,style:r});l.position.set(14,10),e.addChild(l);const h=new Ft,u=l.width+20,d=l.height+8;return h.roundRect(6,5,u,d,8).fill({color:0,alpha:.3}),e.addChildAt(h,e.children.length-1),{container:e,staticBg:n,glowBorder:o,outerGlow:s,config:t,agentCount:0,currentGlow:0}}drawRoom(t,e){var s;if(this.useRetro){const n=((s=this.themeDecorators)==null?void 0:s[e.id])??Ue[e.id];if(n){n(t,0,0,e.width,e.height);return}}t.roundRect(0,0,e.width,e.height,wn).fill({color:H0,alpha:U0}),t.roundRect(1,1,e.width-2,e.height/3,wn).fill({color:q0,alpha:V0}),t.roundRect(0,0,e.width,e.height,wn).stroke({color:e.color,width:Gr,alpha:Wr})}setAgentCount(t,e){const s=this.zones.get(t);s&&(s.agentCount=e)}update(t){for(const e of this.zones.values()){const s=e.agentCount>0?1:0,n=3;e.currentGlow+=(s-e.currentGlow)*Math.min(1,n*t/1e3);const o=Wr+(W0-Wr)*e.currentGlow,r=Gr+(O0-Gr)*e.currentGlow,l=G0*e.currentGlow;if(e.glowBorder.clear(),e.currentGlow>.01&&e.glowBorder.roundRect(-1,-1,e.config.width+2,e.config.height+2,wn+1).stroke({color:e.config.color,width:r,alpha:o}),e.outerGlow.clear(),e.currentGlow>.01){const h=6*e.currentGlow;e.outerGlow.roundRect(-h,-h,e.config.width+h*2,e.config.height+h*2,wn+h).stroke({color:e.config.color,width:h,alpha:l})}}}rebuild(){const t=new Map;for(const[e,s]of this.zones)t.set(e,s.agentCount);this.container.removeChildren(),this.zones.clear();for(const e of ze){const s=this.createZone(e);this.zones.set(e.id,s),this.container.addChild(s.container),s.agentCount=t.get(e.id)??0}}getZoneConfig(t){var e;return(e=this.zones.get(t))==null?void 0:e.config}}const Or=.5,Hr=3,j0=.001;class X0{constructor(t,e){b(this,"zoom",1);b(this,"dragging",!1);b(this,"lastMouse",{x:0,y:0});b(this,"onWheel",t=>{t.preventDefault();const e=this.zoom;this.zoom=Math.max(Or,Math.min(Hr,this.zoom-t.deltaY*j0));const s=this.app.canvas.getBoundingClientRect(),n=t.clientX-s.left,o=t.clientY-s.top,r=this.zoom/e;this.world.position.x=n-(n-this.world.position.x)*r,this.world.position.y=o-(o-this.world.position.y)*r,this.world.scale.set(this.zoom)});b(this,"onPointerDown",t=>{t.button!==0&&t.button!==1||(this.dragging=!0,this.lastMouse.x=t.clientX,this.lastMouse.y=t.clientY)});b(this,"onPointerMove",t=>{if(!this.dragging)return;const e=t.clientX-this.lastMouse.x,s=t.clientY-this.lastMouse.y;this.world.position.x+=e,this.world.position.y+=s,this.lastMouse.x=t.clientX,this.lastMouse.y=t.clientY});b(this,"onPointerUp",()=>{this.dragging=!1});this.app=t,this.world=e;const s=t.canvas;s.addEventListener("wheel",this.onWheel,{passive:!1}),s.addEventListener("pointerdown",this.onPointerDown),s.addEventListener("pointermove",this.onPointerMove),s.addEventListener("pointerup",this.onPointerUp),s.addEventListener("pointerleave",this.onPointerUp)}setZoom(t){this.zoom=Math.max(Or,Math.min(Hr,t)),this.world.scale.set(this.zoom)}getZoom(){return this.zoom}zoomIn(){this.zoomBy(1.2)}zoomOut(){this.zoomBy(1/1.2)}resetView(t,e){const s=this.app.screen.width,n=this.app.screen.height,o=16,r=(s-o*2)/t,l=(n-o*2)/e,h=Math.min(r,l,1);this.setZoom(h),this.world.position.set((s-t*h)/2,(n-e*h)/2)}smoothFollow(t,e,s=.05){const n=this.app.screen.width,o=this.app.screen.height,r=n/2,l=o/2,h=r-t*this.zoom,u=l-e*this.zoom;this.world.position.x+=(h-this.world.position.x)*s,this.world.position.y+=(u-this.world.position.y)*s}getViewport(){const t=this.app.screen.width,e=this.app.screen.height;return{x:-this.world.position.x/this.zoom,y:-this.world.position.y/this.zoom,width:t/this.zoom,height:e/this.zoom,zoom:this.zoom}}panTo(t,e){const s=this.app.screen.width,n=this.app.screen.height,o=s/2,r=n/2;this.world.position.x=o-t*this.zoom,this.world.position.y=r-e*this.zoom}zoomBy(t){const e=this.zoom,s=Math.max(Or,Math.min(Hr,this.zoom*t));this.zoom=s;const n=this.app.screen.width,o=this.app.screen.height,r=n/2,l=o/2,h=s/e;this.world.position.x=r-(r-this.world.position.x)*h,this.world.position.y=l-(l-this.world.position.y)*h,this.world.scale.set(this.zoom)}destroy(){const t=this.app.canvas;t.removeEventListener("wheel",this.onWheel),t.removeEventListener("pointerdown",this.onPointerDown),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),t.removeEventListener("pointerleave",this.onPointerUp)}}const Yc=120,Ur=100,Oi=12,hs=8;class Z0{constructor(){b(this,"lastW",0);b(this,"lastH",0)}computeLayout(t,e){const s=Math.max(t,Yc*3+hs*4+Oi*2),n=Math.max(e,Ur*3+hs*4+Oi*2);if(s===this.lastW&&n===this.lastH)return{worldWidth:s,worldHeight:n};this.lastW=s,this.lastH=n;const o=vo.reduce((m,g)=>m+g,0),r=s-Oi*2-hs*(Nc-1),l=n-Oi*2-hs*(vo.length-1),h=r/Nc,u=vo.map(m=>Math.max(Ur,m/o*l)),d=[];let p=Oi;for(let m=0;m<vo.length;m++)d.push(p),p+=u[m]+hs;for(const m of ze)m.x=Oi+m.colStart*(h+hs),m.y=d[m.rowStart],m.width=Math.max(Yc,m.colSpan*h+(m.colSpan-1)*hs),m.height=Math.max(Ur,u[m.rowStart]*m.rowSpan+(m.rowSpan-1)*hs);return d0(s,n),{worldWidth:s,worldHeight:n}}invalidate(){this.lastW=0,this.lastH=0}}const K0=1710666,qr=.45,Q0=.15,wo=6,jc=8,Vr=18,Yr=22,J0=1e3;class ty{constructor(t,e){b(this,"overlay",new Ft);b(this,"_enabled",!1);b(this,"targetAlpha",0);b(this,"updateTimer",0);this.overlay.rect(0,0,t,e).fill({color:K0,alpha:1}),this.overlay.alpha=0,this.overlay.eventMode="none",this.overlay.visible=!1}get enabled(){return this._enabled}toggle(){this._enabled=!this._enabled,this.overlay.visible=this._enabled,this._enabled&&(this.computeTargetAlpha(),this.overlay.alpha=this.targetAlpha)}computeTargetAlpha(){const t=new Date,e=t.getHours()+t.getMinutes()/60;let s;e>=Yr||e<wo?s=qr:e>=Vr&&e<Yr?s=qr*((e-Vr)/(Yr-Vr)):e>=wo&&e<jc?s=qr*(1-(e-wo)/(jc-wo)):s=0,this.targetAlpha=Math.max(s,Q0)}update(t){if(!this._enabled)return;this.updateTimer+=t,this.updateTimer>=J0&&(this.updateTimer=0,this.computeTargetAlpha());const e=1-Math.exp(-3*t/1e3);this.overlay.alpha+=(this.targetAlpha-this.overlay.alpha)*e}}const ey=[["search","terminal"],["terminal","web"],["files","thinking"],["thinking","messaging"],["spawn","idle"],["idle","tasks"],["search","files"],["terminal","thinking"],["web","messaging"],["files","spawn"],["thinking","idle"],["messaging","tasks"]],sy=.04,iy=.12,Xc=3,ny=1200;class oy{constructor(){b(this,"container",new Rt);b(this,"linesGfx",new Ft);b(this,"particleGfx",new Ft);b(this,"particles",[]);b(this,"activeFlows",new Map);this.container.addChild(this.linesGfx),this.container.addChild(this.particleGfx)}triggerFlow(t,e,s){const n=`${t}->${e}`;this.activeFlows.set(n,2e3);for(let o=0;o<3;o++)this.particles.push({fromZone:t,toZone:e,t:-o*.15,speed:1/ny,color:s,alpha:.8})}getZoneCenter(t){const e=Vt.get(t);return e?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:0,y:0}}bezierPoint(t,e,s,n,o,r,l){const h=1-l;return{x:h*h*t+2*h*l*s+l*l*o,y:h*h*e+2*h*l*n+l*l*r}}update(t){for(const[e,s]of this.activeFlows){const n=s-t;n<=0?this.activeFlows.delete(e):this.activeFlows.set(e,n)}for(let e=this.particles.length-1;e>=0;e--){const s=this.particles[e];s.t+=s.speed*t,s.t>1&&this.particles.splice(e,1)}this.linesGfx.clear();for(const[e,s]of ey){const n=this.getZoneCenter(e),o=this.getZoneCenter(s),r=`${e}->${s}`,l=`${s}->${e}`,u=this.activeFlows.has(r)||this.activeFlows.has(l)?iy:sy,d=Vt.get(e),p=(d==null?void 0:d.color)??8947848,m=(n.x+o.x)/2,g=(n.y+o.y)/2-20;this.linesGfx.moveTo(n.x,n.y),this.linesGfx.quadraticCurveTo(m,g,o.x,o.y),this.linesGfx.stroke({color:p,width:1,alpha:u})}this.particleGfx.clear();for(const e of this.particles){if(e.t<0)continue;const s=this.getZoneCenter(e.fromZone),n=this.getZoneCenter(e.toZone),o=(s.x+n.x)/2,r=(s.y+n.y)/2-20,l=this.bezierPoint(s.x,s.y,o,r,n.x,n.y,e.t),h=e.alpha*(1-e.t*.5);this.particleGfx.circle(l.x,l.y,Xc).fill({color:e.color,alpha:h}),this.particleGfx.circle(l.x,l.y,Xc*2).fill({color:e.color,alpha:h*.3})}}}class ry{constructor(t){b(this,"root",new Rt);b(this,"gridLayer",new Rt);b(this,"zoneLayer");b(this,"agentLayer",new Rt);b(this,"effectLayer",new Rt);b(this,"uiLayer",new Rt);b(this,"zoneRenderer");b(this,"camera");b(this,"dayNight");b(this,"flowLines");b(this,"layoutEngine");b(this,"app");b(this,"_worldWidth",1100);b(this,"_worldHeight",980);b(this,"gridGraphics");b(this,"resizeHandler");b(this,"resizeRaf",0);b(this,"resizeObserver",null);this.app=t,this.layoutEngine=new Z0;const e=t.screen.width,s=t.screen.height,{worldWidth:n,worldHeight:o}=this.layoutEngine.computeLayout(e,s);this._worldWidth=n,this._worldHeight=o,this.gridGraphics=Hc(n,o),this.gridLayer.addChild(this.gridGraphics),this.zoneRenderer=new Y0,this.zoneLayer=this.zoneRenderer.container,this.flowLines=new oy,this.root.addChild(this.gridLayer),this.root.addChild(this.zoneLayer),this.root.addChild(this.flowLines.container),this.root.addChild(this.agentLayer),this.root.addChild(this.effectLayer),this.root.addChild(this.uiLayer),this.dayNight=new ty(n,o),this.root.addChild(this.dayNight.overlay),t.stage.addChild(this.root),this.camera=new X0(t,this.root),this.camera.resetView(n,o),this.resizeHandler=()=>{cancelAnimationFrame(this.resizeRaf),this.resizeRaf=requestAnimationFrame(()=>this.onResize())},window.addEventListener("resize",this.resizeHandler);const r=document.getElementById("canvas-container");if(r){let l=0;this.resizeObserver=new ResizeObserver(()=>{clearTimeout(l),l=window.setTimeout(()=>{t.resize(),this.onResize()},250)}),this.resizeObserver.observe(r)}}onResize(){const t=this.app.screen.width,e=this.app.screen.height,{worldWidth:s,worldHeight:n}=this.layoutEngine.computeLayout(t,e);(s!==this._worldWidth||n!==this._worldHeight)&&(this._worldWidth=s,this._worldHeight=n,this.gridLayer.removeChildren(),this.gridGraphics.destroy(),this.gridGraphics=Hc(s,n),this.gridLayer.addChild(this.gridGraphics),this.zoneRenderer.rebuild(),this.dayNight.overlay.clear(),this.dayNight.overlay.rect(0,0,s,n).fill({color:1710666,alpha:1})),this.camera.resetView(this._worldWidth,this._worldHeight)}resetCamera(){this.camera.resetView(this._worldWidth,this._worldHeight)}addAgent(t){const e=t instanceof Rt?t:t.container;this.agentLayer.addChild(e)}removeAgent(t){const e=t instanceof Rt?t:t.container;this.agentLayer.removeChild(e)}addEffect(t){this.effectLayer.addChild(t)}removeEffect(t){this.effectLayer.removeChild(t)}getZoneCenter(t){const e=Vt.get(t);return e?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:this._worldWidth/2,y:this._worldHeight/2}}getZoneConfig(t){return Vt.get(t)}setZoneAgentCount(t,e){this.zoneRenderer.setAgentCount(t,e)}rebuildZones(){this.zoneRenderer.rebuild()}applyTheme(t){this.zoneRenderer.setThemeDecorators(t.decorators),this.app.renderer.background.color=t.colors.background}update(t){this.zoneRenderer.update(t),this.dayNight.update(t),this.flowLines.update(t)}get worldWidth(){return this._worldWidth}get worldHeight(){return this._worldHeight}destroy(){var t;window.removeEventListener("resize",this.resizeHandler),(t=this.resizeObserver)==null||t.disconnect()}}const a="transparent",v="body",f="outline",P="highlight",Pt="eye",_="skin",ay={idle:[[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,f,a,a,a,a],[a,a,a,f,P,P,P,P,P,P,P,P,f,a,a,a],[a,a,a,f,P,_,_,_,_,_,_,P,f,a,a,a],[a,a,a,f,_,Pt,Pt,_,_,Pt,Pt,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,f,a,a,a,a],[a,a,a,f,P,P,P,P,P,P,P,P,f,a,a,a],[a,a,a,f,P,_,_,_,_,_,_,P,f,a,a,a],[a,a,a,f,_,f,f,_,_,f,f,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]]],walk:[[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,f,a,a,a,a],[a,a,a,f,P,P,P,P,P,P,P,P,f,a,a,a],[a,a,a,f,P,_,_,_,_,_,_,P,f,a,a,a],[a,a,a,f,_,Pt,Pt,_,_,Pt,Pt,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,f,a,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,a,a,a,a,f,f,a,a,a,a],[a,a,a,f,f,f,a,a,a,a,f,f,f,a,a,a]],[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,f,a,a,a,a],[a,a,a,f,P,P,P,P,P,P,P,P,f,a,a,a],[a,a,a,f,P,_,_,_,_,_,_,P,f,a,a,a],[a,a,a,f,_,Pt,Pt,_,_,Pt,Pt,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,a,f,f,a,a,a,a],[a,a,a,a,f,f,a,a,a,a,f,f,a,a,a,a],[a,a,a,f,f,f,a,a,a,f,f,f,a,a,a,a]]],working:[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,f,a,a,a,a],[a,a,a,f,P,P,P,P,P,P,P,P,f,a,a,a],[a,a,a,f,P,_,_,_,_,_,_,P,f,a,a,a],[a,a,a,f,_,Pt,Pt,_,_,Pt,Pt,_,f,a,a,a],[a,a,a,f,_,_,f,f,f,f,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,_,_,f,v,v,v,v,v,v,f,_,_,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],sleeping:[[[a,a,a,a,a,a,f,f,f,f,f,f,a,a,a,a],[a,a,a,a,a,f,P,P,P,P,P,P,f,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,P,P,f,a,a],[a,a,a,a,f,P,_,_,_,_,_,_,P,f,a,a],[a,a,a,a,f,_,f,f,_,_,f,f,_,f,a,a],[a,a,a,a,f,_,_,_,_,_,_,_,_,f,a,a],[a,a,a,a,a,f,f,_,_,_,_,f,f,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],[[a,a,a,a,a,a,f,f,f,f,f,f,a,a,a,a],[a,a,a,a,a,f,P,P,P,P,P,P,f,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,P,P,f,a,a],[a,a,a,a,f,P,_,_,_,_,_,_,P,f,a,a],[a,a,a,a,f,_,f,f,_,_,f,f,_,f,a,a],[a,a,a,a,f,_,_,_,f,f,_,_,_,f,a,a],[a,a,a,a,a,f,f,_,_,_,_,f,f,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]]],done:[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,P,P,P,P,P,P,f,a,a,a,a],[a,a,a,f,P,P,P,P,P,P,P,P,f,a,a,a],[a,a,a,f,P,_,_,_,_,_,_,P,f,a,a,a],[a,a,a,f,_,_,Pt,_,_,Pt,_,_,f,a,a,a],[a,a,a,f,_,_,_,f,f,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,_,_,f,v,v,v,v,v,v,f,_,_,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],size:16},ly={idle:[[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,P,P,P,P,P,P,f,a,a],[a,f,P,P,_,_,_,_,P,P,f,a],[a,f,_,Pt,_,_,_,_,Pt,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,P,P,P,P,P,P,f,a,a],[a,f,P,P,_,_,_,_,P,P,f,a],[a,f,_,f,_,_,_,_,f,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]]],walk:[[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,P,P,P,P,P,P,f,a,a],[a,f,P,P,_,_,_,_,P,P,f,a],[a,f,_,Pt,_,_,_,_,Pt,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,f,f,a,a,a,f,f,a,a,a],[a,a,f,f,a,a,a,a,f,f,a,a],[a,f,f,f,a,a,a,a,f,f,f,a]],[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,P,P,P,P,P,P,f,a,a],[a,f,P,P,_,_,_,_,P,P,f,a],[a,f,_,Pt,_,_,_,_,Pt,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,a,f,f,a,a],[a,a,f,f,a,a,a,a,f,f,a,a],[a,f,f,f,a,a,a,a,f,f,f,a]]],working:[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,P,P,P,P,P,P,f,a,a],[a,f,P,P,_,_,_,_,P,P,f,a],[a,f,_,Pt,_,_,_,_,Pt,_,f,a],[a,f,_,f,f,f,f,f,f,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[_,_,f,v,v,v,v,v,v,f,_,_],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],sleeping:[[[a,a,a,a,f,f,f,f,f,f,a,a],[a,a,a,f,P,P,P,P,P,P,f,a],[a,a,f,P,P,_,_,_,_,P,P,f],[a,a,f,_,f,_,_,_,_,f,_,f],[a,a,f,_,_,_,_,_,_,_,_,f],[a,a,a,f,f,_,_,_,_,f,f,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],[[a,a,a,a,f,f,f,f,f,f,a,a],[a,a,a,f,P,P,P,P,P,P,f,a],[a,a,f,P,P,_,_,_,_,P,P,f],[a,a,f,_,f,_,_,_,_,f,_,f],[a,a,f,_,_,_,f,f,_,_,_,f],[a,a,a,f,f,_,_,_,_,f,f,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]]],done:[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,P,P,P,P,P,P,f,a,a],[a,f,P,P,_,_,_,_,P,P,f,a],[a,f,_,_,Pt,_,_,Pt,_,_,f,a],[a,f,_,_,f,_,_,f,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[_,_,f,v,v,v,v,v,v,f,_,_],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],size:12},T="transparent",st="body",F="outline",le="highlight",gi="eye",ri=[T,T,T,T,T,T,T,F,F,T,T,T,T,T,T,T],ai=[T,T,T,F,F,F,F,F,F,F,F,F,F,T,T,T],li=[T,T,T,F,st,st,st,st,st,st,st,st,F,T,T,T],On=[T,T,T,F,st,gi,gi,st,st,gi,gi,st,F,T,T,T],Ua=[T,T,T,F,st,F,F,st,st,F,F,st,F,T,T,T],sn=[T,T,T,F,st,st,F,F,F,F,st,st,F,T,T,T],ci=[T,T,T,F,F,F,F,F,F,F,F,F,F,T,T,T],hi=[T,T,T,T,T,F,le,le,le,le,F,T,T,T,T,T],oe=[T,T,T,T,F,st,st,st,st,st,st,F,T,T,T,T],di=[T,T,F,F,F,st,st,st,st,st,st,F,F,F,T,T],ui=[T,T,T,F,F,st,st,st,st,st,st,F,F,T,T,T],re=[T,T,T,T,F,F,le,le,le,le,F,F,T,T,T,T],Ve=[T,T,T,T,F,F,F,T,T,F,F,F,T,T,T,T],nn=[T,T,T,F,F,F,F,T,T,F,F,F,F,T,T,T],Zc=[T,T,T,T,F,F,F,T,T,T,F,F,T,T,T,T],cy=[T,T,T,F,F,F,T,T,T,T,F,F,F,T,T,T],Kc=[T,T,T,T,T,F,F,T,T,F,F,F,T,T,T,T],hy=[T,T,T,F,F,F,T,T,T,F,F,F,T,T,T,T],dy=[T,T,T,F,st,F,le,le,le,le,F,st,F,T,T,T],uy=[T,T,T,F,st,st,st,F,F,st,st,st,F,T,T,T],fy=[ri,ai,li,On,sn,ci,hi,oe,di,ui,re,oe,re,Ve,Ve,nn],py=[ri,ai,li,Ua,sn,ci,hi,oe,di,ui,re,oe,re,Ve,Ve,nn],my={idle:[fy,py],walk:[[ri,ai,li,On,sn,ci,hi,oe,di,ui,re,oe,re,Zc,Zc,cy],[ri,ai,li,On,sn,ci,hi,oe,di,ui,re,oe,re,Kc,Kc,hy]],working:[ri,ai,li,On,dy,ci,hi,oe,di,ui,re,oe,re,Ve,Ve,nn],sleeping:[[[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T],...[ri,ai,li,Ua,sn,ci,hi,oe,di,ui,re,oe,re,Ve,nn].map(i=>[T,...i.slice(0,-1)])],[[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T],...[ri,ai,li,Ua,sn,ci,hi,oe,di,ui,re,oe,re,Ve,nn].map(i=>[T,...i.slice(0,-1)])]],done:[ri,ai,li,On,uy,ci,hi,oe,di,ui,re,oe,re,Ve,Ve,nn],size:16},ds=[T,T,T,T,T,F,F,T,T,T,T,T],us=[T,T,F,F,F,F,F,F,F,F,T,T],fs=[T,T,F,st,st,st,st,st,st,F,T,T],Sn=[T,T,F,gi,gi,st,st,gi,gi,F,T,T],jr=[T,T,F,F,F,st,st,F,F,F,T,T],Hi=[T,T,F,st,F,F,F,F,st,F,T,T],ps=[T,T,F,F,F,F,F,F,F,F,T,T],Qt=[T,T,T,F,st,st,st,st,F,T,T,T],ms=[T,F,F,F,st,st,st,st,F,F,F,T],Te=[T,T,T,F,F,T,T,F,F,T,T,T],gs=[T,T,F,F,F,T,T,F,F,F,T,T],Qc=[T,T,F,F,T,T,T,T,F,F,T,T],Jc=[T,T,T,F,F,T,T,F,F,T,T,T],gy=[T,T,F,st,le,le,le,le,st,F,T,T],yy=[T,T,F,st,st,F,F,st,st,F,T,T],by={idle:[[ds,us,fs,Sn,Hi,ps,Qt,ms,Qt,Te,Te,gs],[ds,us,fs,jr,Hi,ps,Qt,ms,Qt,Te,Te,gs]],walk:[[ds,us,fs,Sn,Hi,ps,Qt,ms,Qt,Qc,Qc,gs],[ds,us,fs,Sn,Hi,ps,Qt,ms,Qt,Jc,Jc,gs]],working:[ds,us,fs,Sn,gy,ps,Qt,ms,Qt,Te,Te,gs],sleeping:[[ds,us,fs,jr,Hi,ps,Qt,ms,Qt,Te,Te,gs],[ds,us,fs,jr,Hi,ps,Qt,ms,Qt,Te,Te,gs]],done:[ds,us,fs,Sn,yy,ps,Qt,ms,Qt,Te,Te,gs],size:12},M="transparent",ce="body",q="outline",V="skin",ys=[M,M,M,M,M,q,q,q,q,q,q,M,M,M,M,M],bs=[M,M,M,M,q,V,V,V,V,V,V,q,M,M,M,M],_s=[M,M,M,q,V,V,V,V,V,V,V,V,q,M,M,M],kn=[M,M,M,q,V,q,q,V,V,q,q,V,q,M,M,M],Xr=[M,M,M,q,V,q,M,V,V,M,q,V,q,M,M,M],Ui=[M,M,M,q,V,V,V,q,q,V,V,V,q,M,M,M],xs=[M,M,M,M,q,V,q,q,q,q,V,q,M,M,M,M],qa=[M,M,M,M,M,M,q,V,V,q,M,M,M,M,M,M],on=[M,M,M,M,q,V,ce,V,V,ce,V,q,M,M,M,M],Va=[M,M,M,M,q,ce,V,ce,ce,V,ce,q,M,M,M,M],Ya=[M,M,V,V,q,V,ce,V,V,ce,V,q,V,V,M,M],ja=[M,M,M,M,M,q,V,V,V,V,q,M,M,M,M,M],Xa=[M,M,M,M,M,q,V,q,q,V,q,M,M,M,M,M],Za=[M,M,M,M,M,q,V,M,M,V,q,M,M,M,M,M],_y=[M,M,M,M,q,q,V,M,M,V,q,q,M,M,M,M],Zr=[M,M,M,M,q,V,M,M,M,M,V,q,M,M,M,M],th=[M,M,M,q,q,V,M,M,M,V,q,q,M,M,M,M],xy=[M,M,M,M,q,V,q,V,V,q,V,q,M,M,M,M],vy=[M,M,M,q,V,V,q,q,q,q,V,V,q,M,M,M],qi=[qa,on,Ya,Va,on,ja,Xa,Za,Za,_y],wy={idle:[[ys,bs,_s,kn,Ui,xs,...qi],[ys,bs,_s,Xr,Ui,xs,...qi]],walk:[[ys,bs,_s,kn,Ui,xs,qa,on,Ya,Va,on,ja,Xa,Zr,Zr,th],[ys,bs,_s,kn,Ui,xs,qa,on,Ya,Va,on,ja,Xa,Za,Zr,th]],working:[ys,bs,_s,kn,xy,xs,...qi],sleeping:[[[M,...ys.slice(0,-1)],[M,...bs.slice(0,-1)],[M,..._s.slice(0,-1)],[M,...Xr.slice(0,-1)],[M,...Ui.slice(0,-1)],[M,...xs.slice(0,-1)],...qi],[[M,...ys.slice(0,-1)],[M,...bs.slice(0,-1)],[M,..._s.slice(0,-1)],[M,...Xr.slice(0,-1)],[M,...Ui.slice(0,-1)],[M,...xs.slice(0,-1)],...qi]],done:[ys,bs,_s,kn,vy,xs,...qi],size:16},vs=[M,M,M,q,q,q,q,q,q,M,M,M],ws=[M,M,q,V,V,V,V,V,V,q,M,M],Tn=[M,q,V,q,q,V,V,q,q,V,q,M],Kr=[M,q,V,q,M,V,V,M,q,V,q,M],Si=[M,q,V,V,q,q,q,q,V,V,q,M],Ss=[M,M,q,V,q,q,q,q,V,q,M,M],ks=[M,M,q,V,ce,V,V,ce,V,q,M,M],Ts=[M,M,q,ce,V,ce,ce,V,ce,q,M,M],Cs=[M,V,q,V,ce,V,V,ce,V,q,V,M],As=[M,M,M,q,V,V,V,V,q,M,M,M],_e=[M,M,M,q,V,M,M,V,q,M,M,M],Ms=[M,M,q,q,V,M,M,V,q,q,M,M],Qr=[M,M,q,V,M,M,M,M,V,q,M,M],Sy=[M,q,V,V,q,q,q,q,V,V,q,M],ky={idle:[[vs,ws,Tn,Si,Ss,ks,Cs,Ts,As,_e,_e,Ms],[vs,ws,Kr,Si,Ss,ks,Cs,Ts,As,_e,_e,Ms]],walk:[[vs,ws,Tn,Si,Ss,ks,Cs,Ts,As,Qr,Qr,Ms],[vs,ws,Tn,Si,Ss,ks,Cs,Ts,As,_e,Qr,Ms]],working:[vs,ws,Tn,Si,Ss,ks,Cs,Ts,As,_e,_e,Ms],sleeping:[[vs,ws,Kr,Si,Ss,ks,Cs,Ts,As,_e,_e,Ms],[vs,ws,Kr,Si,Ss,ks,Cs,Ts,As,_e,_e,Ms]],done:[vs,ws,Tn,Sy,Ss,ks,Cs,Ts,As,_e,_e,Ms],size:12},C="transparent",tt="body",W="outline",yi="highlight",ge="eye",xu=[C,C,C,C,C,C,W,W,W,W,C,C,C,C,C,C],vu=[C,C,C,C,W,W,tt,tt,tt,tt,W,W,C,C,C,C],wu=[C,C,C,W,tt,tt,tt,tt,tt,tt,tt,tt,W,C,C,C],Jr=[C,C,C,W,tt,ge,ge,W,W,ge,ge,tt,W,C,C,C],ta=[C,C,C,W,tt,W,W,W,W,W,W,tt,W,C,C,C],Es=[C,C,C,W,W,W,W,W,W,W,W,W,W,C,C,C],Ps=[C,C,C,C,W,W,W,W,W,W,W,W,C,C,C,C],No=[C,C,C,C,C,W,tt,tt,tt,tt,W,C,C,C,C,C],fi=[C,C,C,C,W,tt,tt,tt,tt,tt,tt,W,C,C,C,C],Wo=[C,C,C,W,W,tt,tt,tt,tt,tt,tt,W,W,C,C,C],Go=[C,C,W,W,W,tt,tt,tt,tt,tt,tt,W,W,W,C,C],Oo=[C,C,C,C,W,W,yi,yi,yi,yi,W,W,C,C,C,C],tr=[C,C,C,C,C,W,W,C,C,W,W,C,C,C,C,C],Ka=[C,C,C,C,W,W,W,C,C,W,W,W,C,C,C,C],eh=[C,C,C,C,W,W,C,C,C,C,W,W,C,C,C,C],Ty=[C,C,C,W,W,W,C,C,C,C,W,W,W,C,C,C],Cy=[C,C,C,C,C,W,W,C,W,W,C,C,C,C,C,C],Ay=[C,C,C,C,W,W,C,C,C,W,W,C,C,C,C,C],My=[C,C,C,W,tt,ge,W,W,W,W,ge,tt,W,C,C,C],Ey=[C,C,C,W,tt,W,ge,W,W,ge,W,tt,W,C,C,C],Vi=[xu,vu,wu],sh=[[C,...xu.slice(0,-1)],[C,...vu.slice(0,-1)],[C,...wu.slice(0,-1)]],Cn=[No,fi,Go,Wo,fi,Oo,tr,tr,Ka],Py={idle:[[...Vi,Jr,Es,Ps,...Cn],[...Vi,ta,Es,Ps,...Cn]],walk:[[...Vi,Jr,Es,Ps,No,fi,Go,Wo,fi,Oo,eh,eh,Ty],[...Vi,Jr,Es,Ps,No,fi,Go,Wo,fi,Oo,Cy,Ay,Ka]],working:[...Vi,My,Es,Ps,No,fi,Go,Wo,fi,Oo,tr,tr,Ka],sleeping:[[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C],...sh,[C,...ta.slice(0,-1)],[C,...Es.slice(0,-1)],[C,...Ps.slice(0,-1)],...Cn],[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C],...sh,[C,...ta.slice(0,-1)],[C,...Es.slice(0,-1)],[C,...Ps.slice(0,-1)],...Cn]],done:[...Vi,Ey,Es,Ps,...Cn],size:16},Is=[C,C,C,W,W,W,W,W,W,C,C,C],Ls=[C,C,W,tt,tt,tt,tt,tt,tt,W,C,C],Bs=[C,W,tt,tt,tt,tt,tt,tt,tt,tt,W,C],So=[C,W,tt,ge,ge,W,W,ge,ge,tt,W,C],ea=[C,W,tt,W,W,W,W,W,W,tt,W,C],Rs=[C,W,W,W,W,W,W,W,W,W,W,C],Jt=[C,C,W,tt,tt,tt,tt,tt,tt,W,C,C],Ds=[C,W,W,tt,tt,tt,tt,tt,tt,W,W,C],$s=[C,C,W,W,yi,yi,yi,yi,W,W,C,C],xe=[C,C,C,W,W,C,C,W,W,C,C,C],zs=[C,C,W,W,W,C,C,W,W,W,C,C],sa=[C,C,W,W,C,C,C,C,W,W,C,C],Iy=[C,W,tt,W,ge,W,W,ge,W,tt,W,C],Ly={idle:[[Is,Ls,Bs,So,Rs,Jt,Ds,Jt,$s,xe,xe,zs],[Is,Ls,Bs,ea,Rs,Jt,Ds,Jt,$s,xe,xe,zs]],walk:[[Is,Ls,Bs,So,Rs,Jt,Ds,Jt,$s,sa,sa,zs],[Is,Ls,Bs,So,Rs,Jt,Ds,Jt,$s,xe,sa,zs]],working:[Is,Ls,Bs,So,Rs,Jt,Ds,Jt,$s,xe,xe,zs],sleeping:[[Is,Ls,Bs,ea,Rs,Jt,Ds,Jt,$s,xe,xe,zs],[Is,Ls,Bs,ea,Rs,Jt,Ds,Jt,$s,xe,xe,zs]],done:[Is,Ls,Bs,Iy,Rs,Jt,Ds,Jt,$s,xe,xe,zs],size:12},D="transparent",K="body",Y="outline",bi="highlight",Ye="eye",lt="skin",By=[D,D,D,D,D,D,D,Y,Y,D,D,D,D,D,D,D],Ry=[D,D,D,D,D,D,Y,bi,bi,Y,D,D,D,D,D,D],Dy=[D,D,D,D,D,Y,bi,bi,bi,bi,Y,D,D,D,D,D],$y=[D,D,D,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,D,D,D],ia=[D,D,D,Y,lt,Ye,Ye,lt,lt,Ye,Ye,lt,Y,D,D,D],ko=[D,D,D,Y,lt,Y,Y,lt,lt,Y,Y,lt,Y,D,D,D],ki=[D,D,D,D,Y,lt,lt,lt,lt,lt,lt,Y,D,D,D,D],Ho=[D,D,D,D,D,Y,K,K,K,K,Y,D,D,D,D,D],pi=[D,D,D,D,Y,K,K,K,K,K,K,Y,D,D,D,D],Qa=[D,D,D,lt,Y,K,K,K,K,K,K,Y,lt,D,D,D],Uo=[D,D,D,Y,K,K,K,K,K,K,K,K,Y,D,D,D],qo=[D,D,Y,K,K,K,K,K,K,K,K,K,K,Y,D,D],Vo=[D,Y,K,K,K,K,K,K,K,K,K,K,K,K,Y,D],Yo=[D,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,D],zy=[D,D,lt,lt,Y,K,K,K,K,K,K,Y,lt,lt,D,D],Fy=[D,D,D,Y,lt,lt,Ye,lt,lt,Ye,lt,lt,Y,D,D,D],Ny=[D,D,D,D,Y,lt,lt,Y,Y,lt,lt,Y,D,D,D,D],Bi=[By,Ry,Dy,$y],ih=Bi.map(i=>[D,...i.slice(0,-1)]),An=[Ho,pi,Qa,pi,Uo,qo,Vo,Yo],Wy={idle:[[...Bi,ia,ki,...An],[...Bi,ko,ki,...An]],walk:[[...Bi,ia,ki,Ho,pi,Qa,pi,Uo,qo,Vo,Yo],[...Bi,ko,ki,Ho,pi,Qa,pi,Uo,qo,Vo,Yo]],working:[...Bi,ia,ki,Ho,pi,zy,pi,Uo,qo,Vo,Yo],sleeping:[[...ih,[D,...ko.slice(0,-1)],[D,...ki.slice(0,-1)],...An],[...ih,[D,...ko.slice(0,-1)],[D,...ki.slice(0,-1)],...An]],done:[...Bi,Fy,Ny,...An],size:16},Fs=[D,D,D,D,D,Y,Y,D,D,D,D,D],Ns=[D,D,D,D,Y,bi,bi,Y,D,D,D,D],Ws=[D,D,Y,Y,Y,Y,Y,Y,Y,Y,D,D],na=[D,D,Y,lt,Ye,lt,lt,Ye,lt,Y,D,D],To=[D,D,Y,lt,Y,lt,lt,Y,lt,Y,D,D],Ti=[D,D,Y,lt,lt,lt,lt,lt,lt,Y,D,D],te=[D,D,Y,K,K,K,K,K,K,Y,D,D],Gs=[D,lt,Y,K,K,K,K,K,K,Y,lt,D],Os=[D,Y,K,K,K,K,K,K,K,K,Y,D],ee=[Y,K,K,K,K,K,K,K,K,K,K,Y],Hs=[Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y],Gy=[D,D,Y,lt,lt,Ye,Ye,lt,lt,Y,D,D],Oy=[D,D,Y,lt,Y,lt,lt,Y,lt,Y,D,D],Hy={idle:[[Fs,Ns,Ws,na,Ti,te,Gs,te,Os,ee,ee,Hs],[Fs,Ns,Ws,To,Ti,te,Gs,te,Os,ee,ee,Hs]],walk:[[Fs,Ns,Ws,na,Ti,te,Gs,te,Os,ee,ee,Hs],[Fs,Ns,Ws,To,Ti,te,Gs,te,Os,ee,ee,Hs]],working:[Fs,Ns,Ws,na,Ti,te,Gs,te,Os,ee,ee,Hs],sleeping:[[Fs,Ns,Ws,To,Ti,te,Gs,te,Os,ee,ee,Hs],[Fs,Ns,Ws,To,Ti,te,Gs,te,Os,ee,ee,Hs]],done:[Fs,Ns,Ws,Gy,Oy,te,Gs,te,Os,ee,ee,Hs],size:12},G="transparent",N="body",U="outline",Su="highlight",Ee="eye",ft=[G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G],Us=[G,G,G,G,G,G,U,U,U,U,G,G,G,G,G,G],qs=[G,G,G,G,G,U,N,N,N,N,U,G,G,G,G,G],Vs=[G,G,G,G,U,N,N,Su,N,N,N,U,G,G,G,G],Ys=[G,G,G,U,N,N,N,N,N,N,N,N,U,G,G,G],Co=[G,G,G,U,N,Ee,Ee,N,N,Ee,Ee,N,U,G,G,G],oa=[G,G,G,U,N,U,U,N,N,U,U,N,U,G,G,G],Ci=[G,G,U,N,N,N,N,N,N,N,N,N,N,U,G,G],js=[G,G,U,N,N,N,N,N,N,N,N,N,N,U,G,G],Ao=[G,U,N,N,N,N,N,N,N,N,N,N,N,N,U,G],De=[G,U,N,N,N,N,N,N,N,N,N,N,N,N,U,G],Mn=[G,G,U,U,U,U,U,U,U,U,U,U,U,U,G,G],ra=[U,N,N,N,N,N,N,N,N,N,N,N,N,N,N,U],aa=[U,N,N,N,N,N,N,N,N,N,N,N,N,N,N,U],la=[G,U,U,U,U,U,U,U,U,U,U,U,U,U,U,G],Uy=[G,G,U,N,N,N,U,U,U,U,N,N,N,U,G,G],qy=[G,G,G,U,N,U,Ee,N,N,Ee,U,N,U,G,G,G],Vy=[G,U,N,N,N,N,N,N,N,N,N,N,N,N,U,G],Yy={idle:[[ft,ft,ft,ft,Us,qs,Vs,Ys,Co,Ci,js,Ao,De,De,Mn,ft],[ft,ft,ft,ft,Us,qs,Vs,Ys,oa,Ci,js,Ao,De,De,Mn,ft]],walk:[[ft,ft,ft,Us,qs,Vs,Ys,Co,Ci,js,Ao,De,De,De,Mn,ft],[ft,ft,ft,ft,ft,Us,qs,Vs,Ys,Co,Ci,js,ra,aa,la,ft]],working:[ft,ft,ft,ft,Us,qs,Vs,Ys,Co,Uy,js,Vy,De,De,Mn,ft],sleeping:[[ft,ft,ft,ft,ft,Us,qs,Vs,Ys,oa,Ci,js,ra,aa,la,ft],[ft,ft,ft,ft,ft,Us,qs,Vs,Ys,oa,Ci,js,ra,aa,la,ft]],done:[ft,ft,ft,ft,Us,qs,Vs,Ys,qy,Ci,js,Ao,De,De,Mn,ft],size:16},xt=[G,G,G,G,G,G,G,G,G,G,G,G],Xs=[G,G,G,G,U,U,U,U,G,G,G,G],Zs=[G,G,G,U,N,N,Su,N,U,G,G,G],Ks=[G,G,U,N,N,N,N,N,N,U,G,G],Mo=[G,G,U,Ee,Ee,N,N,Ee,Ee,U,G,G],ca=[G,G,U,U,U,N,N,U,U,U,G,G],Qs=[G,U,N,N,N,N,N,N,N,N,U,G],Ge=[G,U,N,N,N,N,N,N,N,N,U,G],En=[G,G,U,U,U,U,U,U,U,U,G,G],ha=[U,N,N,N,N,N,N,N,N,N,N,U],da=[G,U,U,U,U,U,U,U,U,U,U,G],jy=[G,U,N,N,U,U,U,U,N,N,U,G],Xy=[G,G,U,U,Ee,N,N,Ee,U,U,G,G],Zy={idle:[[xt,xt,xt,Xs,Zs,Ks,Mo,Qs,Ge,Ge,En,xt],[xt,xt,xt,Xs,Zs,Ks,ca,Qs,Ge,Ge,En,xt]],walk:[[xt,xt,Xs,Zs,Ks,Mo,Qs,Ge,Ge,Ge,En,xt],[xt,xt,xt,xt,Xs,Zs,Ks,Mo,Qs,ha,da,xt]],working:[xt,xt,xt,Xs,Zs,Ks,Mo,jy,Qs,Ge,En,xt],sleeping:[[xt,xt,xt,xt,Xs,Zs,Ks,ca,Qs,ha,da,xt],[xt,xt,xt,xt,Xs,Zs,Ks,ca,Qs,ha,da,xt]],done:[xt,xt,xt,Xs,Zs,Ks,Xy,Qs,Ge,Ge,En,xt],size:12},Ja=[ay,my,wy,Py,Wy,Yy],nh=[ly,by,ky,Ly,Hy,Zy];function Ky(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%Ja.length}function Qy(i,t){switch(t){case"body":return i.body;case"outline":return i.outline;case"highlight":return i.highlight;case"eye":return i.eye;case"skin":return i.skin;case"transparent":return null}}const Eo=3,oh=new Map;function se(i,t,e,s){const n=oh.get(s);if(n)return n;const o=new Ft,r=t.length,l=t[0].length;for(let u=0;u<r;u++)for(let d=0;d<l;d++){const p=Qy(e,t[u][d]);p!==null&&o.rect(d*Eo,u*Eo,Eo,Eo).fill(p)}const h=i.generateTexture({target:o});return o.destroy(),oh.set(s,h),h}function ie(i,t){return`${i}_p${t}`}function Yi(i){const t=new Rt,e=new Ft;t.addChild(e);const s=new rn({text:i.label,style:new je({fontSize:i.fontSize,fontFamily:"'Segoe UI', sans-serif",fill:16777215,fontWeight:"700",...i.letterSpacing!==void 0?{letterSpacing:i.letterSpacing}:{}})});return s.anchor.set(.5,.5),t.addChild(s),{container:t,bg:e,text:s}}function Po(i,t,e,s,n,o=.9,r=.7){i.clear(),i.circle(0,0,t).fill({color:e,alpha:o}).stroke({color:s,width:n,alpha:r})}function rh(i,t,e,s,n,o,r=.9,l=.7){i.clear(),i.roundRect(-t/2,-e/2,t,e,s).fill({color:n,alpha:r}).stroke({color:o,width:1,alpha:l})}const ah=3500,Jy=3e3,lh=500,ua=8,t1=5,e1=6,ch=160,Io=5,s1={tool:{bg:1712960,border:3821696,text:15266047},text:{bg:1712960,border:4212832,text:13421772},"input-needed":{bg:3809296,border:16750592,text:16764032}};class i1{constructor(t){b(this,"container");b(this,"bg");b(this,"pointer");b(this,"textObj");b(this,"speechTimer",0);b(this,"queue",[]);b(this,"currentIndex",0);b(this,"rotateTimer",0);b(this,"currentType","tool");b(this,"needsInputPulse",0);this.container=new Rt,this.container.visible=!1,this.bg=new Ft,this.container.addChild(this.bg),this.pointer=new Ft,this.container.addChild(this.pointer);const e=new je({fontSize:10,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:15266047,wordWrap:!0,wordWrapWidth:ch-ua*2,lineHeight:14});this.textObj=new rn({text:"",style:e}),this.textObj.anchor.set(.5,1),this.container.addChild(this.textObj),this.container.position.set(0,-t/2-8)}set(t){const e=Array.isArray(t)?t:[t];if(e.length===0||e.length===1&&!e[0].text){this.clear();return}if(this.queue=e.filter(s=>s.text),this.queue.length===0){this.clear();return}this.currentIndex=0,this.rotateTimer=0,this.speechTimer=ah,this.showCurrentMessage()}clear(){this.container.visible=!1,this.speechTimer=0,this.queue=[],this.currentIndex=0,this.needsInputPulse=0}update(t){if(!(this.speechTimer<=0)){if(this.speechTimer-=t,this.queue.length>1&&(this.rotateTimer+=t,this.rotateTimer>=Jy&&(this.rotateTimer=0,this.currentIndex=(this.currentIndex+1)%this.queue.length,this.showCurrentMessage(),this.speechTimer=ah)),this.currentType==="input-needed"){this.needsInputPulse+=t*.004;const e=.7+.3*Math.sin(this.needsInputPulse);this.bg.alpha=e,this.speechTimer=Math.max(this.speechTimer,1e3)}else this.bg.alpha=1;this.speechTimer<=lh&&this.currentType!=="input-needed"&&(this.container.alpha=Math.max(0,this.speechTimer/lh)),this.speechTimer<=0&&this.currentType!=="input-needed"&&(this.container.visible=!1,this.speechTimer=0,this.queue=[])}}isActive(){return this.speechTimer>0}showCurrentMessage(){const t=this.queue[this.currentIndex];if(!t)return;this.currentType=t.type;const e=s1[t.type],s=t.icon??"",n=s?`${s} `:"",o=80,r=n+t.text,l=r.length>o?r.slice(0,o-1)+"…":r;this.textObj.text=l,this.textObj.style.fill=e.text;const h=Math.min(this.textObj.width,ch-ua*2),u=this.textObj.height,d=h+ua*2,p=u+t1*2;this.bg.clear(),this.bg.roundRect(-d/2,-(p+Io),d,p,e1).fill({color:e.bg,alpha:.92}).stroke({color:e.border,width:1,alpha:.6}),this.pointer.clear(),this.pointer.moveTo(-Io,0).lineTo(0,Io).lineTo(Io,0).closePath().fill({color:e.bg,alpha:.92}),this.pointer.position.set(0,-6),this.textObj.position.set(0,-10),this.container.visible=!0,this.container.alpha=1}}const n1=2,o1=4,r1=.7,a1=100,l1=3,c1=1.5,h1=2,d1=2.5,u1=.8,f1=1,p1=1.5,hh=600,dh=3e3,uh=30,fh=18,qe=class qe{constructor(t,e,s){b(this,"container",new Rt);b(this,"sprite");b(this,"nameBg");b(this,"nameLabel");b(this,"speechBubble");b(this,"needsInputPulse",0);b(this,"childBadge",null);b(this,"planBadge",null);b(this,"planPulseTimer",0);b(this,"_isPlanning",!1);b(this,"waitBadge",null);b(this,"waitPulseTimer",0);b(this,"_isWaiting",!1);b(this,"waitQContainer");b(this,"waitQLetters");b(this,"waitQTimer",0);b(this,"animState","idle");b(this,"isIdleState",!1);b(this,"isDoneState",!1);b(this,"idleTimer",0);b(this,"zzzContainer");b(this,"zzzLetters");b(this,"zzzTimer",0);b(this,"doneBadge",null);b(this,"sparkles",[]);b(this,"compactBadge",null);b(this,"compactPulseTimer",0);b(this,"_isCompacting",!1);b(this,"outcomeFlash",null);b(this,"anomalyBadge",null);b(this,"anomalyPulseTimer",0);b(this,"_hasAnomaly",!1);b(this,"anomalyAutoClearTimer",null);b(this,"contextBar");b(this,"_contextPct",0);b(this,"activityRing");b(this,"activityLevel",0);b(this,"activityPhase",0);b(this,"isSubagent");b(this,"variantIndex");b(this,"spriteHeight");b(this,"textures");b(this,"frameTimer",0);b(this,"frameIndex",0);b(this,"targetX");b(this,"targetY");b(this,"isMoving",!1);b(this,"bobTimer");b(this,"baseY");b(this,"fadingOut",!1);b(this,"fadeTimer",0);b(this,"fadeResolve",null);b(this,"spawnAnimTimer",0);this.isSubagent=t.role==="subagent";const n=this.isSubagent;this.variantIndex=Ky(t.projectPath??t.sessionId);const o=this.variantIndex,r=n?nh[o]:Ja[o],l=n?`sub_v${o}`:`main_v${o}`,h=t.colorIndex;this.spriteHeight=r.size*3,this.textures={idle:[se(s,r.idle[0],e,ie(`${l}_idle0`,h)),se(s,r.idle[1],e,ie(`${l}_idle1`,h))],walk:[se(s,r.walk[0],e,ie(`${l}_walk0`,h)),se(s,r.walk[1],e,ie(`${l}_walk1`,h))],working:se(s,r.working,e,ie(`${l}_working`,h)),sleeping:[se(s,r.sleeping[0],e,ie(`${l}_sleeping0`,h)),se(s,r.sleeping[1],e,ie(`${l}_sleeping1`,h))],done:se(s,r.done,e,ie(`${l}_done`,h))},this.sprite=new Di(this.textures.idle[0]),this.sprite.anchor.set(.5,.5),this.container.addChild(this.sprite),this.nameBg=new Ft,this.container.addChild(this.nameBg);const u=t.agentName||eo(t.sessionId),d=u.length>14?u.slice(0,12)+"..":u,p=new je({fontSize:11,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:16777215,align:"center",fontWeight:"700"});this.nameLabel=new rn({text:d,style:p}),this.nameLabel.anchor.set(.5,0),this.nameLabel.position.set(0,this.spriteHeight/2+8),this.container.addChild(this.nameLabel),this.updateNameBg(),this.contextBar=new Ft,this.container.addChild(this.contextBar),this.setContextHealth(0),this.speechBubble=new i1(this.spriteHeight),this.container.addChild(this.speechBubble.container),this.zzzContainer=new Rt,this.zzzContainer.visible=!1,this.zzzLetters=[];const m=[8,10,13],g=["z","z","Z"];for(let x=0;x<3;x++){const w=new rn({text:g[x],style:new je({fontSize:m[x],fontFamily:"'Segoe UI', sans-serif",fill:8952268,fontWeight:"700",dropShadow:{alpha:.5,blur:2,color:0,distance:1}})});w.anchor.set(.5,.5),this.zzzLetters.push(w),this.zzzContainer.addChild(w)}this.zzzContainer.position.set(this.spriteHeight/3,-this.spriteHeight/2),this.container.addChild(this.zzzContainer),this.waitQContainer=new Rt,this.waitQContainer.visible=!1,this.waitQLetters=[];const y=[9,11,14];for(let x=0;x<3;x++){const w=new rn({text:"?",style:new je({fontSize:y[x],fontFamily:"'Segoe UI', sans-serif",fill:16750592,fontWeight:"700",dropShadow:{alpha:.5,blur:2,color:0,distance:1}})});w.anchor.set(.5,.5),this.waitQLetters.push(w),this.waitQContainer.addChild(w)}this.waitQContainer.position.set(this.spriteHeight/3,-this.spriteHeight/2),this.container.addChild(this.waitQContainer),this.activityRing=new Ft,this.activityRing.visible=!1,this.container.addChildAt(this.activityRing,0),this.container.eventMode="static",this.container.cursor="pointer",this.container.hitArea={contains:(x,w)=>{const S=this.spriteHeight/2+10,A=-this.spriteHeight/2-10,L=this.spriteHeight/2+25;return x>=-S&&x<=S&&w>=A&&w<=L}},this.spawnAnimTimer=qe.SPAWN_ANIM_DURATION,this.container.scale.set(.3),this.targetX=0,this.targetY=0,this.baseY=0,this.bobTimer=Math.random()*Math.PI*2}moveTo(t,e){this.targetX=t,this.targetY=e,this.isMoving=!0}setSpeech(t){this.speechBubble.set(t)}clearSpeech(){this.speechBubble.clear()}setCustomName(t){const e=t.length>14?t.slice(0,12)+"..":t;this.nameLabel.text=e,this.updateNameBg()}updateNameBg(){this.nameBg.clear();const t=6,e=3,s=this.nameLabel.width,n=this.nameLabel.height,o=s+t*2,r=n+e*2,l=this.spriteHeight/2+8-e;this.nameBg.roundRect(-o/2,l,o,r,4).fill({color:0,alpha:.55})}rebuildTextures(t,e,s){const n=this.variantIndex,o=this.isSubagent?nh[n]:Ja[n],r=this.isSubagent?`sub_v${n}`:`main_v${n}`,l=e;this.textures={idle:[se(s,o.idle[0],t,ie(`${r}_idle0`,l)),se(s,o.idle[1],t,ie(`${r}_idle1`,l))],walk:[se(s,o.walk[0],t,ie(`${r}_walk0`,l)),se(s,o.walk[1],t,ie(`${r}_walk1`,l))],working:se(s,o.working,t,ie(`${r}_working`,l)),sleeping:[se(s,o.sleeping[0],t,ie(`${r}_sleeping0`,l)),se(s,o.sleeping[1],t,ie(`${r}_sleeping1`,l))],done:se(s,o.done,t,ie(`${r}_done`,l))},this.sprite.texture=this.textures.idle[0]}setContextHealth(t,e=0){this._contextPct=Math.max(0,Math.min(1,t));const s=4,n=this.spriteHeight,o=this.spriteHeight/2+4,r=-n/2;if(this.contextBar.clear(),this.contextBar.visible=!0,this.contextBar.roundRect(o,r,s,n,2).fill({color:0,alpha:.4}),this._contextPct>0){let l;this._contextPct<.5?l=2278750:this._contextPct<.75?l=15381256:this._contextPct<.9?l=16347926:l=15680580;const h=Math.max(2,n*this._contextPct);this.contextBar.roundRect(o,r+n-h,s,h,2).fill({color:l,alpha:.9})}}setIdle(t){t&&!this.isIdleState&&(this.idleTimer=0),this.isIdleState=t}setDone(t){if(this.isDoneState=t,t){if(this.doneBadge||(this.doneBadge=Yi({label:"✓",fontSize:10}),this.doneBadge.container.position.set(0,-this.spriteHeight/2-14),this.container.addChild(this.doneBadge.container)),Po(this.doneBadge.bg,8,5025616,8505220,1.5,.9,.7),this.doneBadge.container.visible=!0,this.sparkles.length===0){const e=[{x:-14,y:-18},{x:16,y:-12},{x:-10,y:8},{x:18,y:4}];for(let s=0;s<4;s++){const n=new Ft;n.rect(-.75,-3,1.5,6).fill({color:16766287}),n.rect(-3,-.75,6,1.5).fill({color:16766287}),n.position.set(e[s].x,e[s].y),n.visible=!1,this.container.addChild(n),this.sparkles.push({gfx:n,phase:Math.random()*4e3})}}for(const e of this.sparkles)e.gfx.visible=!1}else{this.doneBadge&&(this.doneBadge.container.visible=!1);for(const e of this.sparkles)e.gfx.visible=!1}}setChildCount(t){if(t<=0){this.childBadge&&(this.childBadge.container.visible=!1);return}this.childBadge||(this.childBadge=Yi({label:"",fontSize:9}),this.childBadge.container.position.set(this.spriteHeight/2-4,-this.spriteHeight/2+4),this.container.addChild(this.childBadge.container)),this.childBadge.text.text=`${t}`,Po(this.childBadge.bg,8,11225020,16777215,1,1,.5),this.childBadge.container.visible=!0}setPlanning(t){if(this._isPlanning=t,!t){this.planBadge&&(this.planBadge.container.visible=!1);return}this.planBadge||(this.planBadge=Yi({label:"PLAN",fontSize:8,letterSpacing:.5}),this.planBadge.container.position.set(-this.spriteHeight/2+2,-this.spriteHeight/2+2),this.container.addChild(this.planBadge.container)),this.drawPlanBadge(1),this.planBadge.container.visible=!0}drawPlanBadge(t){this.planBadge&&rh(this.planBadge.bg,30,13,3,16347926,16498468,t*.9,t*.7)}setWaiting(t){if(this._isWaiting=t,!t){this.waitBadge&&(this.waitBadge.container.visible=!1),this.waitQContainer.visible=!1;return}this.waitBadge||(this.waitBadge=Yi({label:"?",fontSize:11}),this.waitBadge.container.position.set(0,-this.spriteHeight/2-14),this.container.addChild(this.waitBadge.container)),this.drawWaitBadge(1),this.waitBadge.container.visible=!0}drawWaitBadge(t){this.waitBadge&&Po(this.waitBadge.bg,9,16750592,16764032,1.5,t*.9,t*.7)}setCompacting(t){if(this._isCompacting=t,!t){this.compactBadge&&(this.compactBadge.container.visible=!1);return}this.compactBadge||(this.compactBadge=Yi({label:"↺ COMPACT",fontSize:8,letterSpacing:.3}),this.compactBadge.container.position.set(0,this.spriteHeight/2+28),this.container.addChild(this.compactBadge.container)),this.drawCompactBadge(1),this.compactBadge.container.visible=!0}drawCompactBadge(t){this.compactBadge&&rh(this.compactBadge.bg,58,13,3,8141549,10980346,t*.9,t*.7)}flashOutcome(t){this.outcomeFlash={outcome:t,timer:qe.OUTCOME_FLASH_DURATION}}bumpActivity(){this.activityLevel=Math.min(1,this.activityLevel+.35)}setAnomaly(t){this._hasAnomaly=!0,this.anomalyPulseTimer=0,this.anomalyBadge||(this.anomalyBadge=Yi({label:"!",fontSize:10}),this.anomalyBadge.container.position.set(this.spriteHeight/2+2,-this.spriteHeight/2-2),this.container.addChild(this.anomalyBadge.container)),this.anomalyBadge.container.visible=!0,this.anomalyAutoClearTimer&&clearTimeout(this.anomalyAutoClearTimer),this.anomalyAutoClearTimer=setTimeout(()=>this.clearAnomaly(),3e4)}clearAnomaly(){this._hasAnomaly=!1,this.anomalyBadge&&(this.anomalyBadge.container.visible=!1),this.anomalyAutoClearTimer&&(clearTimeout(this.anomalyAutoClearTimer),this.anomalyAutoClearTimer=null)}fadeOut(){return this.fadingOut?new Promise(t=>{const e=this.fadeResolve;this.fadeResolve=()=>{e==null||e(),t()}}):(this.fadingOut=!0,this.fadeTimer=hh,new Promise(t=>{this.fadeResolve=t}))}update(t){var n,o,r,l,h;if(this.spawnAnimTimer>0)if(this.spawnAnimTimer-=t,this.spawnAnimTimer<=0)this.spawnAnimTimer=0,this.container.scale.set(1);else{const u=1-this.spawnAnimTimer/qe.SPAWN_ANIM_DURATION,d=1-Math.pow(2,-8*u)*Math.cos(u*Math.PI*3);this.container.scale.set(Math.max(.3,Math.min(1,d)))}if(this.fadingOut){this.fadeTimer-=t,this.container.alpha=Math.max(0,this.fadeTimer/hh),this.fadeTimer<=0&&(this.fadingOut=!1,(n=this.fadeResolve)==null||n.call(this),this.fadeResolve=null);return}this.isMoving?this.updateMovement(t):this.updateBob(t),this.isIdleState&&!this.isDoneState&&(this.idleTimer+=t),this.isMoving?this.animState="walk":this.isDoneState?this.animState="done":this.isIdleState&&this.idleTimer>=qe.IDLE_TO_SLEEP_MS?this.animState="sleeping":this.speechBubble.isActive()?this.animState="working":this.animState="idle",this.frameTimer+=t;const s=1e3/(this.animState==="walk"?o1:this.animState==="sleeping"?r1:n1);if(this.animState==="working")this.sprite.texture=this.textures.working;else if(this.animState==="done")this.sprite.texture=this.textures.done;else{this.frameTimer>=s&&(this.frameTimer-=s,this.frameIndex=(this.frameIndex+1)%2);const u=this.animState==="walk"?this.textures.walk:this.animState==="sleeping"?this.textures.sleeping:this.textures.idle;this.sprite.texture=u[this.frameIndex]}if(this.animState==="sleeping"){this.zzzContainer.visible=!0,this.zzzTimer+=t;for(let u=0;u<this.zzzLetters.length;u++){const d=u/this.zzzLetters.length,p=(this.zzzTimer/dh+d)%1,m=this.zzzLetters[u];m.position.set(p*fh,-p*uh),m.alpha=Math.max(0,1-p*1.3),m.scale.set(.5+p*.6)}}else this.zzzContainer.visible=!1;if(this._isWaiting){this.waitQContainer.visible=!0,this.waitQTimer+=t;for(let u=0;u<this.waitQLetters.length;u++){const d=u/this.waitQLetters.length,p=(this.waitQTimer/dh+d)%1,m=this.waitQLetters[u];m.position.set(p*fh,-p*uh),m.alpha=Math.max(0,1-p*1.3),m.scale.set(.5+p*.6)}}else this.waitQContainer.visible=!1;if(this.isDoneState&&this.sparkles.length>0)for(let u=0;u<this.sparkles.length;u++){const d=this.sparkles[u];d.phase+=t;const p=2e3+u*700,m=d.phase%p/p;m<.15?(d.gfx.visible=!0,d.gfx.alpha=m/.15):m<.3?(d.gfx.visible=!0,d.gfx.alpha=1-(m-.15)/.15):d.gfx.visible=!1}if(!this.outcomeFlash)if(this._isWaiting){this.activityRing.visible=!0,this.activityPhase+=t*.004,this.activityRing.clear();const u=this.spriteHeight/2+6,d=.4+.3*Math.sin(this.activityPhase*2),p=Math.PI*1.2;for(let m=0;m<2;m++){const g=this.activityPhase+m*Math.PI;this.activityRing.arc(0,0,u,g,g+p).stroke({color:16750592,width:2.5,alpha:d})}for(let m=0;m<2;m++){const g=this.activityPhase+m*Math.PI;this.activityRing.arc(0,0,u+2,g,g+p*.8).stroke({color:16750592,width:3,alpha:d*.3})}}else if(this.activityLevel=Math.max(0,this.activityLevel-t*4e-4),this.activityLevel>.02&&!this.isDoneState){this.activityRing.visible=!0,this.activityPhase+=t*.003,this.activityRing.clear();const u=this.spriteHeight/2+6,d=this.activityLevel*.6,p=Math.PI*.4+this.activityLevel*Math.PI*.8;for(let m=0;m<2;m++){const g=this.activityPhase+m*Math.PI;this.activityRing.arc(0,0,u,g,g+p).stroke({color:4906624,width:2,alpha:d})}if(this.activityLevel>.3)for(let m=0;m<2;m++){const g=this.activityPhase+m*Math.PI;this.activityRing.arc(0,0,u+2,g,g+p*.8).stroke({color:4906624,width:3,alpha:d*.25})}}else this.activityRing.visible=!1;if(this._isPlanning&&((o=this.planBadge)!=null&&o.container.visible)){this.planPulseTimer+=t*.003;const u=.7+.3*Math.sin(this.planPulseTimer);this.drawPlanBadge(u)}if(this._isCompacting&&((r=this.compactBadge)!=null&&r.container.visible)){this.compactPulseTimer+=t*.003;const u=.65+.35*Math.sin(this.compactPulseTimer*1.5);this.drawCompactBadge(u);const d=1+.04*Math.sin(this.compactPulseTimer*2);this.compactBadge.container.scale.set(d,1)}if(this.outcomeFlash)if(this.outcomeFlash.timer-=t,this.outcomeFlash.timer<=0)this.outcomeFlash=null,this.activityRing.visible=!1;else{const u=this.outcomeFlash.timer/qe.OUTCOME_FLASH_DURATION,d=u*.85,p=this.spriteHeight/2+6+(1-u)*8,m=this.outcomeFlash.outcome==="success"?4906624:16281969;this.activityRing.visible=!0,this.activityRing.clear(),this.activityRing.circle(0,0,p).stroke({color:m,width:3,alpha:d}),this.activityRing.circle(0,0,p+4).stroke({color:m,width:1.5,alpha:d*.4})}if(this._hasAnomaly&&((l=this.anomalyBadge)!=null&&l.container.visible)&&this.anomalyBadge.bg){this.anomalyPulseTimer+=t*.005;const u=.85+.15*Math.sin(this.anomalyPulseTimer);this.anomalyBadge.container.scale.set(u),Po(this.anomalyBadge.bg,8,15680580,16498468,1.5,.9,.7)}if(this._isWaiting&&((h=this.waitBadge)!=null&&h.container.visible)){this.waitPulseTimer+=t*.005;const u=.5+.5*Math.sin(this.waitPulseTimer);this.drawWaitBadge(u);const d=1+.15*Math.sin(this.waitPulseTimer*.7);this.waitBadge.container.scale.set(d)}this.speechBubble.update(t)}updateMovement(t){const e=t/1e3,s=this.targetX-this.container.x,n=this.targetY-this.container.y,o=Math.sqrt(s*s+n*n);if(o<l1){this.container.x=this.targetX,this.container.y=this.targetY,this.baseY=this.container.y,this.isMoving=!1;return}const r=Math.min(a1*e,o);this.container.x+=s/o*r,this.container.y+=n/o*r}updateBob(t){const e=this.animState==="sleeping"?d1:this.animState==="done"?f1:c1,s=this.animState==="sleeping"?u1:this.animState==="done"?p1:h1;this.bobTimer=(this.bobTimer+t/1e3*s*Math.PI*2)%(Math.PI*2),this.container.y=this.baseY+Math.sin(this.bobTimer)*e}onClick(t){this.container.on("pointertap",t)}onHover(t,e){this.container.on("pointerover",t),this.container.on("pointerout",e)}getPosition(){return{x:this.container.x,y:this.container.y}}destroy(){this.anomalyAutoClearTimer&&(clearTimeout(this.anomalyAutoClearTimer),this.anomalyAutoClearTimer=null),this.container.destroy({children:!0})}};b(qe,"IDLE_TO_SLEEP_MS",3e4),b(qe,"OUTCOME_FLASH_DURATION",700),b(qe,"SPAWN_ANIM_DURATION",400);let tl=qe;const ph=6,mh=4,m1=.04,g1=3,y1=.15,b1=1,gh=.5,yh=6,bh=400,_h=4886745,_1=4521796;class x1{constructor(){b(this,"graphics",new Ft);b(this,"time",0);b(this,"pulseTimers",new Map)}pulseConnection(t,e){this.pulseTimers.set(`${t}->${e}`,bh)}update(t,e){this.time=(this.time+e)%1e6,this.graphics.clear();for(const[o,r]of this.pulseTimers){const l=r-e;l<=0?this.pulseTimers.delete(o):this.pulseTimers.set(o,l)}const s=Array.from(t.entries());for(const[o,r]of s)if(r.parentId){const l=t.get(r.parentId);if(l){const h=`${r.parentId}->${o}`,u=this.pulseTimers.get(h)??0,p=u>0?u/bh:0;this.drawGlowingDashedLine(l.x,l.y,r.x,r.y,_h,p),this.drawArrow(l.x,l.y,r.x,r.y,_h,p)}}const n=new Map;for(const[,o]of s)if(o.teamName){const r=`${o.rootSessionId}:${o.teamName}`;let l=n.get(r);l||(l=[],n.set(r,l)),l.push(o)}for(const o of n.values())if(!(o.length<2))for(let r=0;r<o.length-1;r++)this.drawGlowingDashedLine(o[r].x,o[r].y,o[r+1].x,o[r+1].y,_1,0)}drawGlowingDashedLine(t,e,s,n,o,r){const l=this.time*m1,h=y1+r*.35,u=gh+r*.4,d=g1+r*2;this.drawDashedLine(t,e,s,n,o,h,d,l),this.drawDashedLine(t,e,s,n,o,u,b1,l)}drawDashedLine(t,e,s,n,o,r,l,h){const u=s-t,d=n-e,p=Math.sqrt(u*u+d*d);if(p<1)return;const m=u/p,g=d/p,y=ph+mh;let w=-((h%y+y)%y),S=!0;for(;w<p;){const L=w+(S?ph:mh);if(S){const I=Math.max(w,0),O=Math.min(L,p);if(O>I){const R=t+m*I,z=e+g*I,Q=t+m*O,X=e+g*O;this.graphics.moveTo(R,z).lineTo(Q,X).stroke({color:o,width:l,alpha:r})}}w=L,S=!S}}drawArrow(t,e,s,n,o,r){const l=s-t,h=n-e,u=Math.sqrt(l*l+h*h);if(u<yh*3)return;const d=l/u,p=h/u,m=(t+s)/2,g=(e+n)/2,y=-p,x=d,w=yh/2,S=gh+r*.4,A=m+d*w,L=g+p*w,I=m-d*w+y*w,O=g-p*w+x*w,R=m-d*w-y*w,z=g-p*w-x*w;this.graphics.moveTo(A,L).lineTo(I,O).lineTo(R,z).closePath().fill({color:o,alpha:S})}destroy(){this.graphics.destroy()}}const v1=8,fa=3,xh=800,vh=30;class w1{constructor(t){b(this,"container",new Rt);b(this,"particles",[]);b(this,"particleTextures",new Map);this.renderer=t}emit(t,e,s){const n=this.getTexture(s);for(let o=0;o<v1;o++){const r=new Di(n);r.anchor.set(.5),r.position.set(t,e),r.alpha=1;const l=Math.random()*Math.PI*2,h=vh*(.5+Math.random()*.5);this.container.addChild(r),this.particles.push({sprite:r,vx:Math.cos(l)*h,vy:-Math.abs(Math.sin(l)*h)-vh*.5,life:xh,maxLife:xh})}}update(t){const e=t/1e3;for(let s=this.particles.length-1;s>=0;s--){const n=this.particles[s];if(n.life-=t,n.life<=0){this.container.removeChild(n.sprite),n.sprite.destroy(),this.particles.splice(s,1);continue}n.sprite.x+=n.vx*e,n.sprite.y+=n.vy*e,n.sprite.alpha=Math.max(0,n.life/n.maxLife);const o=.3+.7*(n.life/n.maxLife);n.sprite.scale.set(o)}}getTexture(t){let e=this.particleTextures.get(t);if(e)return e;const s=new Ft;return s.circle(fa,fa,fa).fill(t),e=this.renderer.generateTexture({target:s}),s.destroy(),this.particleTextures.set(t,e),e}destroy(){for(const t of this.particles)t.sprite.destroy();this.particles=[];for(const t of this.particleTextures.values())t.destroy(!0);this.particleTextures.clear(),this.container.destroy({children:!0})}}const S1=800,wh=3,Sh=3,k1=40;class T1{constructor(){b(this,"container",new Rt);b(this,"particles",[])}send(t,e,s,n,o){const r=new Ft;this.container.addChild(r),this.particles.push({gfx:r,fromX:t,fromY:e,toX:s,toY:n,color:o,elapsed:0,duration:S1})}update(t){for(let e=this.particles.length-1;e>=0;e--){const s=this.particles[e];if(s.elapsed+=t,s.elapsed>=s.duration){this.container.removeChild(s.gfx),s.gfx.destroy(),this.particles.splice(e,1);continue}const n=s.elapsed/s.duration;s.gfx.clear();for(let r=0;r<=wh;r++){const l=Math.max(0,n-r*.06),h=this.getArcPosition(s,l),u=(1-r/(wh+1))*(1-n*.3),d=Sh*(1-r*.2);s.gfx.circle(h.x,h.y,d).fill({color:s.color,alpha:u})}const o=this.getArcPosition(s,n);s.gfx.circle(o.x,o.y,Sh*2.5).fill({color:s.color,alpha:.15})}}getArcPosition(t,e){const s=(t.fromX+t.toX)/2,n=(t.fromY+t.toY)/2-k1,o=1-e,r=o*o*t.fromX+2*o*e*s+e*e*t.toX,l=o*o*t.fromY+2*o*e*n+e*e*t.toY;return{x:r,y:l}}destroy(){for(const t of this.particles)t.gfx.destroy();this.particles=[],this.container.destroy({children:!0})}}class C1{constructor(){b(this,"zoneCounts",new Map)}updateFromAgents(t){this.zoneCounts.clear();for(const e of t)this.zoneCounts.set(e,(this.zoneCounts.get(e)??0)+1);return this.zoneCounts}getCount(t){return this.zoneCounts.get(t)??0}getCounts(){return this.zoneCounts}}function A1(i){const t=[];if(i.currentTool==="AskUserQuestion")return t.push({text:"Waiting for input...",type:"input-needed",icon:"⏳"}),t;if(i.currentTool){const e=h0[i.currentTool]||"⚙️";let s=i.currentTool;if(i.currentActivity){const n=i.currentActivity;if(n.length<=50)s=`${i.currentTool}: ${n}`;else{const o=n.replace(/\\/g,"/").split("/"),r=o.length>2?`.../${o.slice(-2).join("/")}`:n.slice(0,45);s=`${i.currentTool}: ${r}`}}t.push({text:s,type:"tool",icon:e})}return i.isPlanning&&i.currentTool!=="EnterPlanMode"&&i.currentTool!=="ExitPlanMode"&&t.push({text:"Planning...",type:"tool",icon:"📝"}),i.speechText&&t.push({text:i.speechText,type:"text",icon:"💭"}),t}function Lo(i,t,e,s){const n=Vt.get(i);if(!n)return s.getZoneCenter(i);const o=[];for(const[A,L]of e)(L.state.currentZone===i||L.state.isIdle&&i==="idle")&&o.push(A);o.includes(t)||o.push(t),o.sort();const r=o.indexOf(t),l=o.length,h=n.width-40,u=n.height-70,d=n.x+20,p=n.y+50;if(l===1)return{x:d+h/2,y:p+u/2};const m=Math.ceil(Math.sqrt(l)),g=Math.ceil(l/m),y=r%m,x=Math.floor(r/m),w=h/m,S=u/g;return{x:d+w*y+w/2,y:p+S*x+S/2}}class M1{constructor(t,e,s){b(this,"agents",new Map);b(this,"lines");b(this,"particles");b(this,"messageFlow");b(this,"zoneGlow");b(this,"sound",null);b(this,"notifications",null);b(this,"_focusedAgentId",null);b(this,"_onAgentClick",null);b(this,"_onAgentHover",null);b(this,"_customizationLookup",null);b(this,"onSpawnBound");b(this,"onUpdateBound");b(this,"onIdleBound");b(this,"onShutdownBound");b(this,"onResetBound");b(this,"onAnomalyBound");this.app=t,this.world=e,this.store=s,this.lines=new x1,this.world.uiLayer.addChild(this.lines.graphics),this.particles=new w1(t.renderer),this.world.addEffect(this.particles.container),this.messageFlow=new T1,this.world.addEffect(this.messageFlow.container),this.zoneGlow=new C1,this.onSpawnBound=n=>this.onSpawn(n),this.onUpdateBound=n=>this.onUpdate(n),this.onIdleBound=n=>this.onIdle(n),this.onShutdownBound=n=>this.onShutdown(n),this.onResetBound=n=>this.onReset(n),this.store.on("agent:spawn",this.onSpawnBound),this.store.on("agent:update",this.onUpdateBound),this.store.on("agent:idle",this.onIdleBound),this.store.on("agent:shutdown",this.onShutdownBound),this.store.on("state:reset",this.onResetBound),this.onAnomalyBound=n=>{const o=this.agents.get(n.agentId);o&&o.sprite.setAnomaly(n.kind)},this.store.on("anomaly:alert",this.onAnomalyBound)}setSoundManager(t){this.sound=t}setNotificationManager(t){this.notifications=t}setClickHandler(t){this._onAgentClick=t}setHoverHandler(t){this._onAgentHover=t}setCustomizationLookup(t){this._customizationLookup=t}getDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||eo(t.sessionId)}getDisplayColorIndex(t){return this._customizationLookup?this._customizationLookup(t).colorIndex:t.colorIndex}updateChildBadges(){const t=new Map;for(const[,e]of this.agents)e.state.parentId&&t.set(e.state.parentId,(t.get(e.state.parentId)??0)+1);for(const[e,s]of this.agents)s.sprite.setChildCount(t.get(e)??0)}onSpawn(t){var h,u;if(this.agents.has(t.id))return;const e=dt[t.colorIndex%dt.length],s=new tl(t,e,this.app.renderer),n=t.parentId?this.agents.get(t.parentId):null;if(n)s.container.position.set(n.sprite.container.x,n.sprite.container.y);else{const d=this.world.getZoneCenter("spawn");s.container.position.set(d.x,d.y)}s.onClick(()=>{var d;return(d=this._onAgentClick)==null?void 0:d.call(this,t.id)}),s.onHover(()=>{var d;return(d=this._onAgentHover)==null?void 0:d.call(this,t.id,s.container.x,s.container.y)},()=>{var d;return(d=this._onAgentHover)==null?void 0:d.call(this,null,0,0)});const o=this.getDisplayName(t),r=this.getDisplayColorIndex(t);if(s.setCustomName(o),r!==t.colorIndex){const d=dt[r%dt.length];s.rebuildTextures(d,r,this.app.renderer)}s.setContextHealth(t.contextTokens/this.getContextWindowSize(t.model),t.contextCacheTokens/this.getContextWindowSize(t.model)),this.agents.set(t.id,{sprite:s,state:t,notifiedWaiting:!1,lastSeenOutcome:null}),this.world.addAgent(s.container);const l=Lo(t.currentZone,t.id,this.agents,this.world);s.moveTo(l.x,l.y),this.updateChildBadges(),(h=this.sound)==null||h.play("spawn"),(u=this.notifications)==null||u.notifySpawn(o)}getContextWindowSize(t){return u0(t)}onUpdate(t){var r,l,h,u;const e=this.agents.get(t.id);if(!e){this.onSpawn(t);return}const s=e.state.currentZone;e.state=t,e.sprite.setCustomName(this.getDisplayName(t));const n=Lo(t.currentZone,t.id,this.agents,this.world);e.sprite.moveTo(n.x,n.y);const o=A1(t);if(o.length>0?e.sprite.setSpeech(o):e.sprite.clearSpeech(),e.sprite.setIdle(!1),e.sprite.setPlanning(t.isPlanning),e.sprite.setCompacting(t.phase==="compacting"),e.sprite.setContextHealth(t.contextTokens/this.getContextWindowSize(t.model),t.contextCacheTokens/this.getContextWindowSize(t.model)),t.lastToolOutcome&&t.lastToolOutcome!==e.lastSeenOutcome&&e.sprite.flashOutcome(t.lastToolOutcome),e.lastSeenOutcome=t.lastToolOutcome,e.sprite.setWaiting(t.isWaitingForUser),t.isWaitingForUser&&!e.notifiedWaiting?(e.notifiedWaiting=!0,(r=this.sound)==null||r.play("input-needed"),(l=this.notifications)==null||l.notifyInputNeeded(this.getDisplayName(t)),this.updateDocTitle()):t.isWaitingForUser||(e.notifiedWaiting=!1,this.updateDocTitle()),t.isDone){e.sprite.setDone(!0),e.sprite.setIdle(!0),e.sprite.clearSpeech(),e.sprite.container.alpha=.65;return}if(e.sprite.setDone(!1),e.sprite.container.alpha=1,t.currentTool){const d=dt[this.getDisplayColorIndex(t)%dt.length];if(this.particles.emit(e.sprite.container.x,e.sprite.container.y,d.body),(h=this.sound)==null||h.play("tool-use"),t.currentTool==="SendMessage"){let p;if(t.messageTarget){for(const[,m]of this.agents)if((m.state.agentName===t.messageTarget||m.state.id===t.messageTarget)&&m.state.rootSessionId===t.rootSessionId){p=m;break}}if(!p&&t.parentId&&(p=this.agents.get(t.parentId)),!p){for(const[,m]of this.agents)if(m.state.parentId===t.id){p=m;break}}p&&this.messageFlow.send(e.sprite.container.x,e.sprite.container.y,p.sprite.container.x,p.sprite.container.y,d.body)}e.sprite.bumpActivity()}if(s!==t.currentZone){(u=this.sound)==null||u.play("zone-change");const d=dt[this.getDisplayColorIndex(t)%dt.length];this.world.flowLines.triggerFlow(s,t.currentZone,d.body)}}onIdle(t){var n,o;const e=this.agents.get(t.id);if(!e)return;e.state=t;const s=Lo("idle",t.id,this.agents,this.world);e.sprite.moveTo(s.x,s.y),e.sprite.setIdle(!0),e.sprite.setWaiting(!1),e.sprite.setCompacting(!1),e.sprite.clearSpeech(),e.notifiedWaiting=!1,this.updateDocTitle(),(n=this.sound)==null||n.play("idle"),(o=this.notifications)==null||o.notifyIdle(this.getDisplayName(t))}onShutdown(t){var n,o;const e=this.agents.get(t);if(!e)return;(n=this.sound)==null||n.play("shutdown"),(o=this.notifications)==null||o.notifyShutdown(this.getDisplayName(e.state));const s=this.world.getZoneCenter("spawn");e.sprite.moveTo(s.x,s.y),e.sprite.fadeOut().then(()=>{this.world.removeAgent(e.sprite.container),e.sprite.destroy(),this.agents.delete(t),this.updateChildBadges(),this.updateDocTitle()})}onReset(t){this.rebuildFromState(t)}rebuildFromState(t){for(const[,s]of this.agents)this.world.removeAgent(s.sprite.container),s.sprite.destroy();this.agents.clear();const e=this.sound;this.sound=null;for(const s of t.values()){this.onSpawn(s);const n=this.agents.get(s.id);if(n){const o=Lo(s.currentZone,s.id,this.agents,this.world);n.sprite.container.position.set(o.x,o.y),n.sprite.spawnAnimTimer=0,n.sprite.container.scale.set(1),n.sprite.setIdle(s.isIdle),n.sprite.setWaiting(s.isWaitingForUser),s.isDone&&(n.sprite.setDone(!0),n.sprite.container.alpha=.65)}}this.sound=e}update(t){for(const o of this.agents.values())o.sprite.update(t);this.particles.update(t),this.messageFlow.update(t);const e=new Map;for(const[o,r]of this.agents)e.set(o,{x:r.sprite.container.x,y:r.sprite.container.y,parentId:r.state.parentId,teamName:r.state.teamName,rootSessionId:r.state.rootSessionId,colorIndex:this.getDisplayColorIndex(r.state)});this.lines.update(e,t);const s=Array.from(this.agents.values()).map(o=>o.state.currentZone),n=this.zoneGlow.updateFromAgents(s);for(const[o,r]of n)this.world.setZoneAgentCount(o,r);for(const o of Vt.keys())n.has(o)||this.world.setZoneAgentCount(o,0)}updateDocTitle(){let t=0;for(const s of this.agents.values())s.state.isWaitingForUser&&t++;const e="Agent Move";if(t>0){const s=t===1?"⚠️ Input needed":`⚠️ ${t} agents waiting`;document.title=`${s} — ${e}`}else document.title!==e&&(document.title=e)}setFocusAgent(t){this._focusedAgentId=t}get focusedAgentId(){return this._focusedAgentId}getFocusedAgentName(){if(!this._focusedAgentId)return null;const t=this.agents.get(this._focusedAgentId);return t?this.getDisplayName(t.state):null}getActiveAgentIds(){const t=[];for(const[e,s]of this.agents)!s.state.isIdle&&!s.state.isDone&&t.push(e);if(t.length===0)for(const[e]of this.agents)t.push(e);return t.sort()}cycleNextAgent(){const t=this.getActiveAgentIds();if(t.length===0)return null;if(!this._focusedAgentId||!t.includes(this._focusedAgentId))this._focusedAgentId=t[0];else{const e=t.indexOf(this._focusedAgentId);this._focusedAgentId=t[(e+1)%t.length]}return this._focusedAgentId}dispose(){this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:update",this.onUpdateBound),this.store.off("agent:idle",this.onIdleBound),this.store.off("agent:shutdown",this.onShutdownBound),this.store.off("state:reset",this.onResetBound),this.store.off("anomaly:alert",this.onAnomalyBound);for(const[,t]of this.agents)t.sprite.destroy();this.agents.clear(),this.lines.destroy(),this.particles.destroy()}getAgentPositions(){const t=[];for(const[e,s]of this.agents)t.push({id:e,x:s.sprite.container.x,y:s.sprite.container.y,colorIndex:this.getDisplayColorIndex(s.state)});return t}getAgentState(t){var e;return(e=this.agents.get(t))==null?void 0:e.state}applyCustomization(t,e,s){const n=this.agents.get(t);if(!n)return;const o=n.state,r=e||o.agentName||eo(o.sessionId);n.sprite.setCustomName(r);const l=s??o.colorIndex,h=dt[l%dt.length];n.sprite.rebuildTextures(h,l,this.app.renderer)}getFocusedAgentPosition(){if(!this._focusedAgentId)return null;const t=this.agents.get(this._focusedAgentId);return t?{x:t.sprite.container.x,y:t.sprite.container.y}:(this._focusedAgentId=null,null)}}function Bt(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Zt(i){return Bt(i).replace(/"/g,"&quot;")}function Xe(i){return"#"+i.toString(16).padStart(6,"0")}function de(i){return i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:`${i}`}function ku(i,t){const e=i+t;return e>=1e6?`${(e/1e6).toFixed(1)}M tokens`:e>=1e3?`${(e/1e3).toFixed(1)}K tokens`:`${e} tokens`}function un(i){const t=Math.floor(i/1e3),e=Math.floor(t/3600),s=Math.floor(t%3600/60),n=t%60;return e>0?`${e}h ${s}m`:s>0?`${s}m ${n}s`:`${n}s`}function Tu(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class E1{constructor(t){b(this,"store");b(this,"agentListEl");b(this,"filterEl");b(this,"refreshTimer");b(this,"onAgentClick",null);b(this,"_customizationLookup",null);b(this,"currentFilter","all");b(this,"collapsedGroups",new Set);b(this,"renderPending",!1);b(this,"scheduleRender");b(this,"tokenHistory",new Map);b(this,"sparklineSampleTimer");b(this,"_metrics",new Map);b(this,"onAgentUpdate",t=>{let e=this._metrics.get(t.id);if(e||(e={toolTimestamps:[],failCount:0},this._metrics.set(t.id,e)),t.currentTool){const n=Date.now(),o=e.toolTimestamps.length>0?e.toolTimestamps[e.toolTimestamps.length-1]:0;n-o>1e3&&e.toolTimestamps.push(n)}t.lastToolOutcome==="failure"&&e.failCount++;const s=Date.now()-300*1e3;e.toolTimestamps=e.toolTimestamps.filter(n=>n>=s),this.scheduleRender()});this.store=t,this.agentListEl=document.getElementById("agent-list"),this.filterEl=document.createElement("div"),this.filterEl.id="filter-pills",this.agentListEl.parentElement.insertBefore(this.filterEl,this.agentListEl),this.renderFilters(),this.scheduleRender=()=>{this.renderPending||(this.renderPending=!0,requestAnimationFrame(()=>{this.renderPending=!1,this.renderAgents()}))},this.store.on("agent:spawn",this.scheduleRender),this.store.on("agent:update",this.onAgentUpdate),this.store.on("agent:idle",this.scheduleRender),this.store.on("agent:shutdown",this.scheduleRender),this.store.on("state:reset",this.scheduleRender),this.refreshTimer=setInterval(this.scheduleRender,500),this.sparklineSampleTimer=setInterval(()=>this.sampleSparklines(),2e3)}setAgentClickHandler(t){this.onAgentClick=t}setCustomizationLookup(t){this._customizationLookup=t}sampleSparklines(){const t=this.store.getAgents();for(const[e,s]of t){let n=this.tokenHistory.get(e);n||(n={samples:[]},this.tokenHistory.set(e,n)),n.samples.push(s.totalInputTokens+s.totalOutputTokens),n.samples.length>30&&n.samples.shift()}for(const e of this.tokenHistory.keys())t.has(e)||this.tokenHistory.delete(e);for(const e of this._metrics.keys())t.has(e)||this._metrics.delete(e)}toggleGroup(t){this.collapsedGroups.has(t)?this.collapsedGroups.delete(t):this.collapsedGroups.add(t),this.renderAgents()}renderFilters(){const t=[{label:"All",value:"all"},{label:"Active",value:"active"},{label:"Idle",value:"idle"},{label:"Done",value:"done"}],e=Array.from(this.store.getAgents().values()),s=e.filter(d=>d.isDone).length,n=[...new Set(e.map(d=>d.projectName).filter(Boolean))],o=n.length>1,r=typeof this.currentFilter=="string"&&this.currentFilter.startsWith("project:")?this.currentFilter.slice(8):"";this.filterEl.innerHTML=t.map(d=>{const p=d.value==="done"&&s>0?` <span class="filter-badge">${s}</span>`:"";return`<button class="filter-pill${this.currentFilter===d.value?" active":""}" data-filter="${d.value}">${d.label}${p}</button>`}).join("")+`
251
+ <select class="filter-zone-select" title="Filter by zone">
252
+ <option value="">Zone...</option>
253
+ ${ze.map(d=>`<option value="${d.id}" ${this.currentFilter===d.id?"selected":""}>${d.icon} ${d.label}</option>`).join("")}
254
+ </select>
255
+ ${o?`<select class="filter-zone-select filter-project-select" title="Filter by project">
256
+ <option value="">Project...</option>
257
+ ${n.sort().map(d=>`<option value="project:${Zt(d)}" ${r===d?"selected":""}>${Bt(d)}</option>`).join("")}
258
+ </select>`:""}
259
+ ${s>0?`<button class="clean-done-btn" title="Remove ${s} done agent${s>1?"s":""}">Clean up (${s})</button>`:""}
260
+ `,this.filterEl.querySelectorAll(".filter-pill").forEach(d=>{d.addEventListener("click",()=>{this.currentFilter=d.dataset.filter,this.filterEl.querySelector(".filter-zone-select").value="";const p=this.filterEl.querySelector(".filter-project-select");p&&(p.value=""),this.renderFilters(),this.renderAgents()})});const l=this.filterEl.querySelector(".filter-zone-select:not(.filter-project-select)");l.addEventListener("change",()=>{l.value?this.currentFilter=l.value:this.currentFilter="all";const d=this.filterEl.querySelector(".filter-project-select");d&&(d.value=""),this.renderFilters(),this.renderAgents()});const h=this.filterEl.querySelector(".filter-project-select");h&&h.addEventListener("change",()=>{h.value?this.currentFilter=h.value:this.currentFilter="all",l.value="",this.renderFilters(),this.renderAgents()});const u=this.filterEl.querySelector(".clean-done-btn");u&&u.addEventListener("click",()=>this.cleanDoneAgents())}shortenId(t){return t.length>8?t.slice(0,8):t}roleBadge(t){const s={main:{label:"MAIN",color:"#4a90d9"},subagent:{label:"SUB",color:"#ab47bc"},"team-lead":{label:"LEAD",color:"#ff9800"},"team-member":{label:"MEMBER",color:"#26c6da"}}[t]??{label:t.toUpperCase(),color:"#888"};return`<span style="
261
+ background: ${s.color}33;
262
+ color: ${s.color};
263
+ padding: 1px 6px;
264
+ border-radius: 3px;
265
+ font-size: 10px;
266
+ font-weight: bold;
267
+ margin-left: 6px;
268
+ ">${s.label}</span>`}filterAgents(t){const e=this.currentFilter;if(typeof e=="string"&&e.startsWith("project:")){const s=e.slice(8);return t.filter(n=>n.projectName===s)}switch(e){case"all":return t;case"active":return t.filter(s=>!s.isIdle&&!s.isDone);case"idle":return t.filter(s=>s.isIdle&&!s.isDone);case"done":return t.filter(s=>s.isDone);default:return t.filter(s=>s.currentZone===e)}}renderAgents(){var g;let t=Array.from(this.store.getAgents().values());const e=t.length;if(t=this.filterAgents(t),t.length===0){if(e===0)this.agentListEl.innerHTML=`
269
+ <div class="empty-state">
270
+ <div class="empty-icon">
271
+ <svg viewBox="0 0 48 48" width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5">
272
+ <rect x="14" y="6" width="20" height="16" rx="3" />
273
+ <circle cx="20" cy="14" r="2" fill="currentColor"/>
274
+ <circle cx="28" cy="14" r="2" fill="currentColor"/>
275
+ <rect x="16" y="24" width="16" height="14" rx="2" />
276
+ <rect x="10" y="26" width="6" height="4" rx="1" />
277
+ <rect x="32" y="26" width="6" height="4" rx="1" />
278
+ <rect x="18" y="38" width="4" height="6" rx="1" />
279
+ <rect x="26" y="38" width="4" height="6" rx="1" />
280
+ </svg>
281
+ </div>
282
+ <div class="empty-title">Waiting for agents</div>
283
+ <div class="empty-desc">Start a Claude Code session and agents will appear here automatically</div>
284
+ </div>`;else{const y=`No ${this.currentFilter} agents (${e} total)`;this.agentListEl.innerHTML=`<div class="empty-state"><div class="empty-desc">${y}</div></div>`}return}t.sort((y,x)=>y.isDone!==x.isDone?y.isDone?1:-1:y.isIdle!==x.isIdle?y.isIdle?1:-1:y.spawnedAt-x.spawnedAt);const s=this.store.getAgents(),n=t.filter(y=>y.role==="subagent"),o=t.filter(y=>y.role!=="subagent"),r=[],l=new Set(o.map(y=>y.id)),h=new Map;for(const y of n)if(y.parentId&&l.has(y.parentId)){let x=h.get(y.parentId);x||(x=[],h.set(y.parentId,x)),x.push(y)}else r.push(y);const u=new Map;for(const y of s.values())y.parentId&&y.role==="subagent"&&u.set(y.parentId,(u.get(y.parentId)??0)+1);const d=new Map,p=[];for(const y of o)if(y.teamName){const x=`${y.rootSessionId}:${y.teamName}`;let w=d.get(x);w||(w=[],d.set(x,w)),w.push(y)}else p.push(y);let m="";for(const[y,x]of d){const w=y.indexOf(":"),S=w>=0?y.slice(w+1):y,A=(g=x[0])==null?void 0:g.rootSessionId;x.sort((R,z)=>R.role==="team-lead"&&z.role!=="team-lead"?-1:R.role!=="team-lead"&&z.role==="team-lead"?1:0);let L=0;for(const R of s.values())R.teamName===S&&R.rootSessionId===A&&L++;const I=`team:${y}`,O=this.collapsedGroups.has(I);if(m+=`<div class="agent-group${O?" collapsed":""}">`,m+=`<div class="group-header" role="button" tabindex="0" data-group-id="${Zt(I)}">
285
+ <span class="group-chevron">${O?"&#9656;":"&#9662;"}</span>
286
+ <span class="group-icon">&#128101;</span>
287
+ <span class="group-name">${Bt(S)}</span>
288
+ <span class="group-count">${L}</span>
289
+ </div>`,!O){m+='<div class="group-children">';for(const R of x)m+=this.renderAgentWithSubs(R,h,u);m+="</div>"}m+="</div>"}for(const y of p)m+=this.renderAgentWithSubs(y,h,u);for(const y of r)m+=this.renderCard(y,!0);this.agentListEl.innerHTML=m,this.agentListEl.querySelectorAll(".group-header").forEach(y=>{y.addEventListener("click",()=>{const x=y.dataset.groupId;x&&this.toggleGroup(x)}),y.addEventListener("keydown",x=>{if(x.key==="Enter"||x.key===" "){x.preventDefault();const w=y.dataset.groupId;w&&this.toggleGroup(w)}})}),this.agentListEl.querySelectorAll(".sub-collapse-bar").forEach(y=>{y.addEventListener("click",()=>{const x=y.dataset.groupId;x&&this.toggleGroup(x)})}),this.agentListEl.querySelectorAll(".agent-card[data-agent-id]").forEach(y=>{y.addEventListener("click",()=>{const x=y.dataset.agentId;x&&this.onAgentClick&&this.onAgentClick(x)})}),this.agentListEl.querySelectorAll(".sparkline-canvas").forEach(y=>{const x=y.dataset.agentId;x&&this.drawSparkline(y,x)}),this.agentListEl.querySelectorAll(".agent-sparkline").forEach(y=>{const x=y.dataset.agentId;x&&this.drawToolVelocitySparkline(y,x)})}renderAgentWithSubs(t,e,s,n=!1){const o=e.get(t.id),r=s.get(t.id)??0,l=o&&o.length>0;let h="";if(l){const u=`sub:${t.id}`,d=this.collapsedGroups.has(u);h+=this.renderCard(t,n,0);const p=d?"&#9656;":"&#9662;",m=`${r} subagent${r>1?"s":""}`;if(h+=`<div class="sub-collapse-bar${d?" is-collapsed":""}" data-group-id="${Zt(u)}">
290
+ <span class="sub-collapse-chevron">${p}</span>
291
+ <span class="sub-collapse-label">${m}</span>
292
+ </div>`,!d){h+='<div class="subagent-group">';for(const g of o)h+=this.renderAgentWithSubs(g,e,s,!0);h+="</div>"}}else h+=this.renderCard(t,n,r);return h}getHealthColor(t){if(t.isDone||t.isIdle)return"#888";const e=this._metrics.get(t.id);if(e&&e.failCount>0){const s=e.toolTimestamps.length;return s>0&&e.failCount/s>.3?"#ef4444":"#eab308"}return"#22c55e"}renderCard(t,e=!1,s=0){var R;const n=(R=this._customizationLookup)==null?void 0:R.call(this,t),o=(n==null?void 0:n.colorIndex)??t.colorIndex,r=dt[o%dt.length],l=Xe(r.body),h=Vt.get(t.currentZone),u=h?h.label:t.currentZone,d=t.currentTool??"none",p=ku(t.totalInputTokens,t.totalOutputTokens),m=(n==null?void 0:n.displayName)||t.agentName||eo(t.sessionId),g=e?" agent-card-child":"",y=t.isDone?" agent-card-done":"",x=t.isDone?'<span class="status-badge done">DONE</span>':"",w=s>0?`<span class="sub-count" title="${s} subagent${s>1?"s":""}">${s} sub${s>1?"s":""}</span>`:"",S=t.projectPath?gu(t.projectPath):o,A=Xe(dt[S%dt.length].body),L=t.projectName?`<span style="
293
+ background: ${A}33;
294
+ color: ${A};
295
+ padding: 1px 5px;
296
+ border-radius: 3px;
297
+ font-size: 9px;
298
+ margin-left: 4px;
299
+ ">${Bt(t.projectName)}</span>`:"",I=t.isDone?"done":t.isIdle?"idle":"active",O=this.getHealthColor(t);return`<div class="agent-card${g}${y}" data-agent-id="${t.id}" style="border-left: 3px solid ${l};">
300
+ <div class="card-top-row">
301
+ <div class="name">
302
+ <span class="agent-status-dot ${I}"></span>
303
+ ${e?'<span class="child-connector">&#8627;</span>':""}${Bt(m)}${this.roleBadge(t.role)}${L}${x}${w}
304
+ </div>
305
+ <div class="card-actions">
306
+ <div class="agent-metrics">
307
+ <canvas class="agent-sparkline" data-agent-id="${t.id}" data-color-index="${o}" width="60" height="16"></canvas>
308
+ <span class="agent-health-dot" style="background: ${O};"></span>
309
+ </div>
310
+ <canvas class="sparkline-canvas" data-agent-id="${t.id}" width="60" height="20"></canvas>
311
+ </div>
312
+ </div>
313
+ ${t.taskDescription?`<div class="task-desc" title="${Zt(t.taskDescription)}">${Bt(Tu(t.taskDescription,48))}</div>`:""}
314
+ <div class="zone">${(h==null?void 0:h.icon)??""} ${u} · ${d}</div>
315
+ <div class="card-tokens">${t.contextTokens>0?(()=>{const z=Math.round(t.contextTokens/2e5*100),Q=z>=90?"#ef4444":z>=75?"#f97316":z>=50?"#eab308":"#22c55e",X=t.contextTokens-t.contextCacheTokens,j=Z=>Z>=1e3?`${Math.round(Z/1e3)}k`:`${Z}`;return`<span class="detail-ctx-bar" title="Context window: ${z}% full&#10;${X.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / 200,000"><span class="detail-ctx-breakdown">${j(X)} new · ${j(t.contextCacheTokens)} cached</span><span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${z}%;background:${Q}"></span></span><span class="detail-ctx-label" style="color:${Q}">${z}%</span></span>`})():`<span>${p}</span>`}</div>
316
+ </div>`}getToolVelocityBars(t){const e=this._metrics.get(t);if(!e||e.toolTimestamps.length===0)return[];const s=Date.now(),n=3e4,o=10,r=new Array(o).fill(0);for(const l of e.toolTimestamps){const h=s-l,u=Math.floor(h/n);u>=0&&u<o&&r[o-1-u]++}return r}drawToolVelocitySparkline(t,e){const s=t.getContext("2d");if(!s)return;const n=t.width,o=t.height;s.clearRect(0,0,n,o);const r=this.getToolVelocityBars(e);if(r.length===0)return;const l=Math.max(...r,1),h=10,u=Math.floor(n/h)-1,d=1,p=t.dataset.colorIndex,m=p?parseInt(p,10):0,g=dt[m%dt.length],y=Xe(g.body);for(let x=0;x<h;x++){const w=r[x]??0,S=Math.max(w>0?2:0,Math.round(w/l*(o-2))),A=x*(u+d),L=o-S;s.fillStyle=y,s.globalAlpha=w>0?.8:.15,s.fillRect(A,L,u,S)}s.globalAlpha=1}drawSparkline(t,e){const s=t.getContext("2d");if(!s)return;const n=this.tokenHistory.get(e);if(!n||n.samples.length<2)return;const o=t.width,r=t.height;s.clearRect(0,0,o,r);const l=[];for(let d=1;d<n.samples.length;d++)l.push(Math.max(0,n.samples[d]-n.samples[d-1]));const h=Math.max(...l,1),u=o/Math.max(l.length-1,1);s.beginPath(),s.moveTo(0,r);for(let d=0;d<l.length;d++){const p=d*u,m=r-l[d]/h*(r-2)-1;s.lineTo(p,m)}s.lineTo((l.length-1)*u,r),s.closePath(),s.fillStyle="rgba(74, 222, 128, 0.15)",s.fill(),s.beginPath();for(let d=0;d<l.length;d++){const p=d*u,m=r-l[d]/h*(r-2)-1;d===0?s.moveTo(p,m):s.lineTo(p,m)}s.strokeStyle="#4ade80",s.lineWidth=1.5,s.stroke()}async cleanDoneAgents(){try{(await fetch("/api/agents/clean-done",{method:"POST"})).ok&&(this.renderFilters(),this.renderAgents())}catch(t){console.error("Failed to clean done agents:",t)}}dispose(){clearInterval(this.refreshTimer),clearInterval(this.sparklineSampleTimer),this.store.off("agent:spawn",this.scheduleRender),this.store.off("agent:update",this.onAgentUpdate),this.store.off("agent:idle",this.scheduleRender),this.store.off("agent:shutdown",this.scheduleRender),this.store.off("state:reset",this.scheduleRender)}}class P1{constructor(t){b(this,"panelEl");b(this,"store");b(this,"selectedAgentId",null);b(this,"entries",[]);b(this,"historyListener",null);b(this,"onUpdateBound");b(this,"onIdleBound");b(this,"onShutdownBound");b(this,"_onCustomize",null);b(this,"_customizationLookup",null);b(this,"tokenSamples",[]);b(this,"toolTimestamps",[]);b(this,"sparklineTimer",null);this.store=t,this.panelEl=document.createElement("div"),this.panelEl.id="agent-detail-panel",this.panelEl.innerHTML=`
317
+ <div class="detail-header">
318
+ <div class="detail-header-buttons">
319
+ <button id="detail-back" title="Back to agent list">
320
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>
321
+ Back
322
+ </button>
323
+ <span class="detail-btn-spacer"></span>
324
+ <button id="detail-customize" title="Customize agent name and color">Edit</button>
325
+ <button id="detail-kill" title="Shut down this agent permanently">Kill</button>
326
+ </div>
327
+ <div id="detail-card"></div>
328
+ </div>
329
+ <div id="detail-info"></div>
330
+ <div class="detail-section-title">Activity Feed</div>
331
+ <div id="detail-feed"></div>
332
+ `;const e=document.getElementById("right-panel");e?e.appendChild(this.panelEl):document.body.appendChild(this.panelEl),this.panelEl.querySelector("#detail-back").addEventListener("click",()=>this.close()),this.panelEl.querySelector("#detail-kill").addEventListener("click",()=>this.showKillConfirm()),this.panelEl.querySelector("#detail-customize").addEventListener("click",()=>{if(this.selectedAgentId&&this._onCustomize){const s=this.store.getAgent(this.selectedAgentId);s&&this._onCustomize(s)}}),this.historyListener=s=>{s.agentId===this.selectedAgentId&&(this.entries=s.entries,this.renderFeed())},this.store.on("agent:history",this.historyListener),this.onUpdateBound=s=>{if(s.id===this.selectedAgentId){if(this.renderCardStats(s),this.renderInfo(s),s.currentTool){const n=Date.now(),o=this.toolTimestamps.length>0?this.toolTimestamps[this.toolTimestamps.length-1]:0;n-o>1e3&&this.toolTimestamps.push(n);const r=n-300*1e3;this.toolTimestamps=this.toolTimestamps.filter(l=>l>=r)}this.drawSparklines(s)}},this.onIdleBound=s=>{s.id===this.selectedAgentId&&this.renderCardStats(s)},this.onShutdownBound=s=>{s===this.selectedAgentId&&this.close()},this.store.on("agent:update",this.onUpdateBound),this.store.on("agent:idle",this.onIdleBound),this.store.on("agent:shutdown",this.onShutdownBound)}setCustomizeHandler(t){this._onCustomize=t}setCustomizationLookup(t){this._customizationLookup=t}getDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||t.projectName||t.id.slice(0,8)}getDisplayColorIndex(t){return this._customizationLookup?this._customizationLookup(t).colorIndex:t.colorIndex}open(t){this.selectedAgentId=t,this.entries=[],this.tokenSamples=[],this.toolTimestamps=[],this.panelEl.classList.add("open");const e=this.store.getAgent(t);e&&(this.renderHeader(e),this.renderInfo(e),this.tokenSamples.push(e.totalInputTokens+e.totalOutputTokens)),this.sparklineTimer&&clearInterval(this.sparklineTimer),this.sparklineTimer=setInterval(()=>this.sampleSparkline(),2e3),this.store.requestHistory(t)}close(){this.selectedAgentId=null,this.panelEl.classList.remove("open"),this.sparklineTimer&&(clearInterval(this.sparklineTimer),this.sparklineTimer=null)}isOpen(){return this.selectedAgentId!==null}get currentAgentId(){return this.selectedAgentId}refreshHeader(t){if(!this.selectedAgentId)return;const e=this.store.getAgent(this.selectedAgentId);e&&this.renderHeader(e,t)}renderHeader(t,e){const s=this.getDisplayColorIndex(t),n=dt[s%dt.length],o=Xe(n.body),r=e||this.getDisplayName(t),l=t.isDone?"done":t.isIdle?"idle":"active",h=t.isDone?"Agent finished":t.isIdle?"Agent is idle":"Agent is actively working",d={main:{label:"MAIN",color:"#4a90d9"},subagent:{label:"SUB",color:"#ab47bc"},"team-lead":{label:"LEAD",color:"#ff9800"},"team-member":{label:"MEMBER",color:"#26c6da"}}[t.role]??{label:t.role.toUpperCase(),color:"#888"},p=`<span class="detail-role-badge" title="Agent role: ${d.label}" style="background:${d.color}33;color:${d.color};">${d.label}</span>`;let m="";if(t.projectName){const x=t.projectPath?gu(t.projectPath):s,w=Xe(dt[x%dt.length].body);m=`<span class="detail-project-badge" title="Project: ${Zt(t.projectName)}" style="background:${w}33;color:${w};">${Bt(t.projectName)}</span>`}const g=t.isDone?'<span class="detail-done-badge" title="Agent has finished">DONE</span>':"",y=this.panelEl.querySelector("#detail-card");y.innerHTML=`
333
+ <div class="detail-card-inner" style="border-left: 3px solid ${o};">
334
+ <div class="detail-card-top">
335
+ <div class="detail-card-name">
336
+ <span class="agent-status-dot ${l}" title="${h}"></span>
337
+ ${Bt(r)}${p}${m}${g}
338
+ </div>
339
+ <div class="detail-card-actions">
340
+ <canvas class="detail-velocity-canvas" width="60" height="16" title="Tool call frequency (last 5 min)"></canvas>
341
+ <span class="detail-health-dot" title="Agent health indicator"></span>
342
+ <canvas class="detail-sparkline-canvas" width="60" height="20" title="Token usage rate over time"></canvas>
343
+ </div>
344
+ </div>
345
+ ${t.taskDescription?`<div class="detail-card-task" title="${Zt(t.taskDescription)}">${Bt(Tu(t.taskDescription,80))}</div>`:""}
346
+ <div class="detail-card-zone" id="detail-zone-line"></div>
347
+ <div class="detail-card-tokens" id="detail-token-line"></div>
348
+ </div>
349
+ `,this.renderCardStats(t)}renderCardStats(t){const e=Vt.get(t.currentZone),s=(e==null?void 0:e.icon)??"",n=(e==null?void 0:e.label)??t.currentZone,o=t.currentTool??"none",r=ku(t.totalInputTokens,t.totalOutputTokens),l=this.panelEl.querySelector("#detail-zone-line");l&&(l.innerHTML=`<span title="Current activity zone">${s} ${n}</span> <span class="detail-card-sep" title="Current tool">&middot;</span> <span class="detail-card-tool" title="Current tool: ${Zt(o)}">${Bt(o)}</span>`);const h=this.panelEl.querySelector("#detail-token-line");if(h){const d=t.contextTokens>0?Math.round(t.contextTokens/2e5*100):0,p=d>=90?"#ef4444":d>=75?"#f97316":d>=50?"#eab308":"#22c55e",m=t.contextTokens-t.contextCacheTokens,g=x=>x>=1e3?`${Math.round(x/1e3)}k`:`${x}`,y=`Context window: ${d}% full
350
+ ${m.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / 200,000`;h.innerHTML=d>0?`<span class="detail-ctx-bar" title="${y}">
351
+ <span class="detail-ctx-breakdown">${g(m)} new · ${g(t.contextCacheTokens)} cached</span>
352
+ <span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${d}%;background:${p}"></span></span>
353
+ <span class="detail-ctx-label" style="color:${p}">${d}%</span>
354
+ </span>`:`<span title="Total token usage">${r}</span>`}const u=this.panelEl.querySelector(".detail-health-dot");if(u){const d=t.isDone||t.isIdle?"#888":"#22c55e";u.style.background=d,u.title=t.isDone?"Agent finished":t.isIdle?"Agent idle":"Agent healthy"}}renderInfo(t){const e=this.panelEl.querySelector("#detail-info"),s=[];s.push(this.infoRow("Uptime",un(Date.now()-t.spawnedAt),"How long this agent has been running")),t.model&&s.push(this.infoRow("Model",`<code>${Zt(t.model)}</code>`,"AI model powering this agent")),s.push(this.infoRow("Session",`<code class="detail-session-id" title="Click to copy full session ID">${t.sessionId.slice(0,16)}…</code>
355
+ <button class="detail-copy-btn" data-copy="${Zt(t.sessionId)}" title="Copy session ID to clipboard">
356
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
357
+ </button>`,"Unique session identifier")),t.teamName&&s.push(this.infoRow("Team",Bt(t.teamName),"Team this agent belongs to")),t.gitBranch&&s.push(this.infoRow("Branch",`<code>${Zt(t.gitBranch)}</code>`,"Git branch this agent is working on"));const n=t.recentDiffs?new Set(t.recentDiffs.map(l=>l.filePath)).size:0,o=t.recentFiles?t.recentFiles.length:0;if(o>0||n>0){const l=[];o>0&&l.push(`${o} touched`),n>0&&l.push(`${n} edited`),s.push(this.infoRow("Files",l.join(", "),"Files this agent has read or modified"))}if(t.parentId){const l=this.store.getAgent(t.parentId),h=l?this.getDisplayName(l):t.parentId.slice(0,10);s.push(this.infoRow("Parent",`<a href="#" class="detail-link" data-agent-id="${Zt(t.parentId)}" title="Navigate to parent agent">${Bt(h)}</a>`,"The agent that spawned this one"))}const r=Array.from(this.store.getAgents().values()).filter(l=>l.parentId===t.id);if(r.length>0){const l=r.map(h=>{const u=this.getDisplayName(h);return`<a href="#" class="detail-link" data-agent-id="${Zt(h.id)}" title="Navigate to subagent">${Bt(u)}</a>`});s.push(this.infoRow("Subagents",l.join(", "),"Child agents spawned by this agent"))}e.innerHTML=s.join(""),e.querySelectorAll(".detail-copy-btn").forEach(l=>{l.addEventListener("click",h=>{h.stopPropagation();const u=l.dataset.copy;u&&(navigator.clipboard.writeText(u).catch(()=>{}),l.classList.add("copied"),setTimeout(()=>l.classList.remove("copied"),1200))})}),e.querySelectorAll(".detail-session-id").forEach(l=>{l.addEventListener("click",()=>{navigator.clipboard.writeText(t.sessionId).catch(()=>{})})}),e.querySelectorAll(".detail-link").forEach(l=>{l.addEventListener("click",h=>{h.preventDefault();const u=l.dataset.agentId;u&&this.open(u)})})}infoRow(t,e,s){return`<div class="detail-info-row" title="${Zt(s)}">
358
+ <span class="detail-info-label">${t}</span>
359
+ <span class="detail-info-value">${e}</span>
360
+ </div>`}sampleSparkline(){if(!this.selectedAgentId)return;const t=this.store.getAgent(this.selectedAgentId);t&&(this.tokenSamples.push(t.totalInputTokens+t.totalOutputTokens),this.tokenSamples.length>30&&this.tokenSamples.shift(),this.drawSparklines(t))}drawSparklines(t){const e=this.panelEl.querySelector(".detail-sparkline-canvas");if(e&&this.tokenSamples.length>=2){const n=e.getContext("2d");if(n){const o=e.width,r=e.height;n.clearRect(0,0,o,r);const l=[];for(let d=1;d<this.tokenSamples.length;d++)l.push(Math.max(0,this.tokenSamples[d]-this.tokenSamples[d-1]));const h=Math.max(...l,1),u=o/Math.max(l.length-1,1);n.beginPath(),n.moveTo(0,r);for(let d=0;d<l.length;d++)n.lineTo(d*u,r-l[d]/h*(r-2)-1);n.lineTo((l.length-1)*u,r),n.closePath(),n.fillStyle="rgba(74, 222, 128, 0.15)",n.fill(),n.beginPath();for(let d=0;d<l.length;d++){const p=d*u,m=r-l[d]/h*(r-2)-1;d===0?n.moveTo(p,m):n.lineTo(p,m)}n.strokeStyle="#4ade80",n.lineWidth=1.5,n.stroke()}}const s=this.panelEl.querySelector(".detail-velocity-canvas");if(s){const n=s.getContext("2d");if(!n)return;const o=s.width,r=s.height;n.clearRect(0,0,o,r);const l=Date.now(),h=3e4,u=10,d=new Array(u).fill(0);for(const w of this.toolTimestamps){const S=Math.floor((l-w)/h);S>=0&&S<u&&d[u-1-S]++}const p=Math.max(...d,1),m=Math.floor(o/u)-1,g=this.getDisplayColorIndex(t),y=dt[g%dt.length],x=Xe(y.body);for(let w=0;w<u;w++){const S=d[w]??0,A=Math.max(S>0?2:0,Math.round(S/p*(r-2)));n.fillStyle=x,n.globalAlpha=S>0?.8:.15,n.fillRect(w*(m+1),r-A,m,A)}n.globalAlpha=1}}renderFeed(){const t=this.panelEl.querySelector("#detail-feed");if(this.entries.length===0){t.innerHTML='<div class="feed-empty">No activity recorded yet</div>';return}const e=[...this.entries].reverse();t.innerHTML=e.map(s=>this.renderEntry(s)).join(""),t.scrollTop=0}relativePath(t){if(!this.selectedAgentId)return t;const e=this.store.getAgent(this.selectedAgentId);if(!(e!=null&&e.projectPath))return t;const s=e.projectPath.replace(/\\/g,"/").replace(/\/$/,"")+"/",n=t.replace(/\\/g,"/");return n.startsWith(s)?n.slice(s.length):n}shortenArgs(t){if(!this.selectedAgentId)return t;const e=this.store.getAgent(this.selectedAgentId);if(!(e!=null&&e.projectPath))return t;const s=e.projectPath.replace(/\\/g,"/").replace(/\/$/,"")+"/";return t.replace(/\\/g,"/").split(s).join("")}renderEntry(t){const s=`<span class="feed-time">${this.formatTime(t.timestamp)}</span>`;switch(t.kind){case"tool":{const n=t.toolArgs?` <span class="feed-args">${Zt(this.shortenArgs(t.toolArgs))}</span>`:"";return`<div class="feed-entry feed-tool">${s} <span class="feed-icon">&#128295;</span> <span class="feed-tool-name">${Zt(t.tool??"unknown")}</span>${n}</div>`}case"text":{const n=t.text?this.shortenArgs(t.text):"";return`<div class="feed-entry feed-text">${s} <span class="feed-icon">&#128172;</span> ${Zt(n)}</div>`}case"zone-change":{const n=Vt.get(t.prevZone),o=Vt.get(t.zone);return`<div class="feed-entry feed-zone">${s} <span class="feed-icon">&#128694;</span> ${(n==null?void 0:n.icon)??""} ${(n==null?void 0:n.label)??t.prevZone} &rarr; ${(o==null?void 0:o.icon)??""} ${(o==null?void 0:o.label)??t.zone}</div>`}case"spawn":return`<div class="feed-entry feed-spawn">${s} <span class="feed-icon">&#9889;</span> Agent spawned</div>`;case"idle":return`<div class="feed-entry feed-idle">${s} <span class="feed-icon">&#9749;</span> Went idle</div>`;case"shutdown":return`<div class="feed-entry feed-shutdown">${s} <span class="feed-icon">&#128721;</span> Agent shut down</div>`;case"tokens":return`<div class="feed-entry feed-tokens">${s} <span class="feed-icon">&#127916;</span> +${de(t.inputTokens??0)} in / +${de(t.outputTokens??0)} out</div>`;default:return""}}showKillConfirm(){var n;if(!this.selectedAgentId)return;const t=this.store.getAgent(this.selectedAgentId),e=t?this.getDisplayName(t):"this agent";(n=this.panelEl.querySelector(".kill-confirm-overlay"))==null||n.remove();const s=document.createElement("div");s.className="kill-confirm-overlay",s.innerHTML=`
361
+ <div class="kill-confirm-box">
362
+ <div class="kill-confirm-title">Kill Agent</div>
363
+ <div class="kill-confirm-msg">Are you sure you want to shut down <strong>${Zt(e)}</strong>? This cannot be undone.</div>
364
+ <div class="kill-confirm-actions">
365
+ <button class="kill-confirm-cancel">Cancel</button>
366
+ <button class="kill-confirm-yes">Kill Agent</button>
367
+ </div>
368
+ </div>
369
+ `,this.panelEl.appendChild(s),s.querySelector(".kill-confirm-cancel").addEventListener("click",()=>s.remove()),s.querySelector(".kill-confirm-yes").addEventListener("click",async()=>{s.remove(),await this.killAgent()}),s.addEventListener("click",o=>{o.target===s&&s.remove()})}async killAgent(){if(this.selectedAgentId)try{(await fetch(`/api/agents/${this.selectedAgentId}/shutdown`,{method:"POST"})).ok&&this.close()}catch(t){console.error("Failed to kill agent:",t)}}formatTime(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}dispose(){this.sparklineTimer&&clearInterval(this.sparklineTimer),this.historyListener&&this.store.off("agent:history",this.historyListener),this.store.off("agent:update",this.onUpdateBound),this.store.off("agent:idle",this.onIdleBound),this.store.off("agent:shutdown",this.onShutdownBound),this.panelEl.remove()}}function I1(i){switch(i.type){case"agent:spawn":case"agent:shutdown":return"lifecycle";case"agent:idle":return"idle";case"agent:update":return i.agent.currentTool?"tool":"zone"}}function kh(i){switch(i.type){case"agent:spawn":return"#a855f7";case"agent:shutdown":return"#f87171";case"agent:idle":return"#6b7280";case"agent:update":return"#"+dt[i.agent.colorIndex%dt.length].body.toString(16).padStart(6,"0")}}function Cu(i){return i<300*1e3?60*1e3:i<900*1e3?120*1e3:300*1e3}function L1(i,t,e,s,n,o){e.fillStyle="rgba(255,255,255,0.15)",e.font="9px monospace",e.textAlign="center";const r=Cu(o),l=Math.ceil(s/r)*r;for(let h=l;h<=n;h+=r){const u=(h-s)/o*i;e.fillRect(u,0,1,3);const d=new Date(h);e.fillText(d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),u,t-1)}}function Th(i,t,e,s,n,o,r,l){if(o)e.strokeStyle="#4ade80",e.lineWidth=2,e.beginPath(),e.moveTo(i-1,0),e.lineTo(i-1,t),e.stroke(),l.textContent="LIVE";else{const h=r*i;e.strokeStyle="#e94560",e.lineWidth=2,e.beginPath(),e.moveTo(h,0),e.lineTo(h,t),e.stroke();const u=s+r*n;l.textContent=new Date(u).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}class B1{constructor(t,e,s){b(this,"activeFilters",new Set(["tool","zone","idle","lifecycle"]));b(this,"visibleAgents",new Set);b(this,"agentFilterContainer");b(this,"customizationLookup",null);b(this,"onChanged");b(this,"getTimeline");this.agentFilterContainer=t,this.getTimeline=e,this.onChanged=s}setCustomizationLookup(t){this.customizationLookup=t}isEventVisible(t,e){return this.activeFilters.has(e)}isAgentVisible(t){return this.visibleAgents.size===0||this.visibleAgents.has(t)}toggleCategory(t,e){this.activeFilters.has(t)?(this.activeFilters.delete(t),e.classList.remove("active")):(this.activeFilters.add(t),e.classList.add("active")),this.onChanged()}getUniqueAgents(){var s;const t=this.getTimeline(),e=new Map;for(const n of t)if(!e.has(n.agent.id)){const o=(s=this.customizationLookup)==null?void 0:s.call(this,n.agent);e.set(n.agent.id,{id:n.agent.id,name:(o==null?void 0:o.displayName)||n.agent.agentName||n.agent.projectName||n.agent.id.slice(0,8),colorIndex:(o==null?void 0:o.colorIndex)??n.agent.colorIndex})}return Array.from(e.values())}getSwimLaneAgents(){const t=this.getUniqueAgents();return this.visibleAgents.size===0?t:t.filter(e=>this.visibleAgents.has(e.id))}updateAgentFilters(){const t=this.getUniqueAgents();if(this.agentFilterContainer.innerHTML="",t.length!==0)for(const e of t){const n="#"+dt[e.colorIndex%dt.length].body.toString(16).padStart(6,"0"),o=document.createElement("button");o.className="tl-agent-pill",(this.visibleAgents.size===0||this.visibleAgents.has(e.id))&&o.classList.add("active"),o.innerHTML=`<span class="tl-agent-dot" style="background:${n}"></span>${e.name}`,o.title=`Toggle ${e.name}`,o.addEventListener("click",()=>{this.toggleAgentFilter(e.id)}),this.agentFilterContainer.appendChild(o)}}toggleAgentFilter(t){const e=this.getUniqueAgents();if(this.visibleAgents.size===0){if(e.length<=1)return;this.visibleAgents.clear(),this.visibleAgents.add(t)}else this.visibleAgents.has(t)?(this.visibleAgents.delete(t),this.visibleAgents.size):(this.visibleAgents.add(t),this.visibleAgents.size>=e.length&&this.visibleAgents.clear());this.updateAgentFilters(),this.onChanged()}}class R1{constructor(t){b(this,"el");b(this,"store");b(this,"canvas");b(this,"ctx");b(this,"playBtn");b(this,"liveBtn");b(this,"timeLabel");b(this,"expandBtn");b(this,"liveRenderTimer",null);b(this,"isLive",!0);b(this,"isPlaying",!1);b(this,"playbackPosition",0);b(this,"playbackSpeed",1);b(this,"lastFrameTime",0);b(this,"animId",null);b(this,"expanded",!1);b(this,"filter");b(this,"filterContainer");b(this,"swimLabelsEl");b(this,"trackWrapper");b(this,"_customizationLookup",null);b(this,"resizeHandler",()=>this.resizeCanvas());b(this,"onTimelineBound");b(this,"onSpawnBound");b(this,"onShutdownBound");b(this,"replayAgents",new Map);b(this,"onReplayState",null);this.store=t,this.el=document.createElement("div"),this.el.id="timeline-bar",this.el.innerHTML=`
370
+ <div class="timeline-top-bar">
371
+ <div class="timeline-controls">
372
+ <button id="timeline-play" title="Play/Pause">&#9654;</button>
373
+ <button id="timeline-live" class="active" title="Jump to Live">LIVE</button>
374
+ <span id="timeline-time">--:--</span>
375
+ <span id="timeline-speed" title="Click to change speed">1x</span>
376
+ </div>
377
+ <div class="timeline-filters">
378
+ <button class="tl-filter-pill active" data-category="tool" title="Tool calls">
379
+ <span class="tl-filter-icon">&#128295;</span> Tools
380
+ </button>
381
+ <button class="tl-filter-pill active" data-category="zone" title="Zone changes">
382
+ <span class="tl-filter-icon">&#127970;</span> Zones
383
+ </button>
384
+ <button class="tl-filter-pill active" data-category="idle" title="Idle events">
385
+ <span class="tl-filter-icon">&#9749;</span> Idle
386
+ </button>
387
+ <button class="tl-filter-pill active" data-category="lifecycle" title="Spawn / Shutdown">
388
+ <span class="tl-filter-icon">&#11088;</span> Life
389
+ </button>
390
+ </div>
391
+ <div class="timeline-agent-filters"></div>
392
+ <button class="timeline-expand-btn" title="Expand swim lanes">&#9650;</button>
393
+ </div>
394
+ <div class="timeline-track" style="position:relative;">
395
+ <div class="timeline-swim-labels"></div>
396
+ <canvas id="timeline-canvas"></canvas>
397
+ </div>
398
+ `,(document.getElementById("canvas-container")??document.getElementById("app")).appendChild(this.el),this.canvas=this.el.querySelector("#timeline-canvas"),this.ctx=this.canvas.getContext("2d"),this.playBtn=this.el.querySelector("#timeline-play"),this.liveBtn=this.el.querySelector("#timeline-live"),this.timeLabel=this.el.querySelector("#timeline-time"),this.expandBtn=this.el.querySelector(".timeline-expand-btn"),this.filterContainer=this.el.querySelector(".timeline-filters");const e=this.el.querySelector(".timeline-agent-filters");this.swimLabelsEl=this.el.querySelector(".timeline-swim-labels"),this.trackWrapper=this.el.querySelector(".timeline-track");const s=this.el.querySelector("#timeline-speed");this.filter=new B1(e,()=>this.store.getTimeline(),()=>this.render()),this.resizeCanvas(),window.addEventListener("resize",this.resizeHandler),this.canvas.addEventListener("mousedown",n=>this.onTrackClick(n)),this.canvas.addEventListener("mousemove",n=>{n.buttons===1&&this.onTrackClick(n)}),this.playBtn.addEventListener("click",()=>{this.isLive&&(this.isLive=!1,this.liveBtn.classList.remove("active"),this.playbackPosition=1),this.isPlaying=!this.isPlaying,this.playBtn.innerHTML=this.isPlaying?"&#9646;&#9646;":"&#9654;",this.isPlaying?(this.lastFrameTime=performance.now(),this.startPlayback()):this.stopPlayback()}),this.liveBtn.addEventListener("click",()=>this.goLive()),s.addEventListener("click",()=>{const n=[.5,1,2,4,8],o=n.indexOf(this.playbackSpeed);this.playbackSpeed=n[(o+1)%n.length],s.textContent=`${this.playbackSpeed}x`}),this.expandBtn.addEventListener("click",()=>this.toggleExpanded()),this.filterContainer.querySelectorAll(".tl-filter-pill").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.category;this.filter.toggleCategory(o,n)})}),this.onTimelineBound=()=>{this.filter.updateAgentFilters(),this.render()},this.store.on("timeline:snapshot",this.onTimelineBound),this.onSpawnBound=()=>this.filter.updateAgentFilters(),this.onShutdownBound=()=>this.filter.updateAgentFilters(),this.store.on("agent:spawn",this.onSpawnBound),this.store.on("agent:shutdown",this.onShutdownBound),this.liveRenderTimer=setInterval(()=>{this.isLive&&this.render()},1e3)}setCustomizationLookup(t){this._customizationLookup=t,this.filter.setCustomizationLookup(t)}setReplayCallback(t){this.onReplayState=t}dispose(){this.liveRenderTimer&&clearInterval(this.liveRenderTimer),this.animId&&cancelAnimationFrame(this.animId),window.removeEventListener("resize",this.resizeHandler),this.store.off("timeline:snapshot",this.onTimelineBound),this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:shutdown",this.onShutdownBound),this.el.remove()}toggleExpanded(){this.expanded=!this.expanded,this.expanded?(this.el.classList.add("expanded"),this.expandBtn.classList.add("active"),this.expandBtn.innerHTML="&#9660;",this.expandBtn.title="Collapse swim lanes"):(this.el.classList.remove("expanded"),this.expandBtn.classList.remove("active"),this.expandBtn.innerHTML="&#9650;",this.expandBtn.title="Expand swim lanes"),this.filter.updateAgentFilters(),requestAnimationFrame(()=>{this.resizeCanvas()})}resizeCanvas(){const e=this.canvas.parentElement.getBoundingClientRect();this.canvas.width=e.width*window.devicePixelRatio,this.canvas.height=e.height*window.devicePixelRatio,this.canvas.style.width=`${e.width}px`,this.canvas.style.height=`${e.height}px`,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(window.devicePixelRatio,window.devicePixelRatio),this.render()}getTimeRange(){const t=this.store.getTimeline();if(t.length===0){const e=Date.now();return{start:e-6e4,end:e}}return{start:t[0].timestamp,end:Math.max(t[t.length-1].timestamp,Date.now())}}render(){const t=this.canvas.width/window.devicePixelRatio,e=this.canvas.height/window.devicePixelRatio,s=this.ctx;s.clearRect(0,0,t,e),this.expanded?this.renderExpanded(t,e,s):this.renderCompact(t,e,s)}renderCompact(t,e,s){this.swimLabelsEl.style.display="none",this.canvas.style.paddingLeft="0";const n=this.store.getTimeline(),{start:o,end:r}=this.getTimeRange(),l=r-o||1;s.fillStyle="rgba(255,255,255,0.04)",s.fillRect(0,4,t,e-8);for(const h of n){const u=(h.timestamp-o)/l*t,d=kh(h);s.fillStyle=d,h.type==="agent:spawn"||h.type==="agent:shutdown"?s.fillRect(u-1,2,3,e-4):(s.globalAlpha=.6,s.fillRect(u,e/2-2,2,4),s.globalAlpha=1)}L1(t,e,s,o,r,l),Th(t,e,s,o,l,this.isLive,this.playbackPosition,this.timeLabel)}renderExpanded(t,e,s){const o=this.filter.getSwimLaneAgents(),r=this.store.getTimeline(),{start:l,end:h}=this.getTimeRange(),u=h-l||1,d=t-60,p=60;if(o.length===0){this.swimLabelsEl.style.display="none",this.canvas.style.paddingLeft="0",s.fillStyle="rgba(255,255,255,0.04)",s.fillRect(0,4,t,e-8),s.fillStyle="#555",s.font="11px Inter, sans-serif",s.textAlign="center",s.fillText("No agent activity yet",t/2,e/2+4),Th(t,e,s,l,u,this.isLive,this.playbackPosition,this.timeLabel);return}const g=e-14,y=Math.max(14,Math.min(28,g/o.length)),x=y*o.length,w=new Map;o.forEach((I,O)=>w.set(I.id,O)),this.swimLabelsEl.style.display="flex",this.swimLabelsEl.innerHTML="";for(const I of o){const R="#"+dt[I.colorIndex%dt.length].body.toString(16).padStart(6,"0"),z=document.createElement("div");z.className="swim-label",z.style.height=`${y}px`,z.style.color=R,z.textContent=I.name,this.swimLabelsEl.appendChild(z)}for(let I=0;I<o.length;I++){const O=I*y;s.fillStyle=I%2===0?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",s.fillRect(p,O,d,y),I>0&&(s.strokeStyle="rgba(255,255,255,0.04)",s.lineWidth=1,s.beginPath(),s.moveTo(p,O),s.lineTo(t,O),s.stroke())}s.fillStyle="rgba(14, 16, 32, 0.8)",s.fillRect(0,0,60,x);for(const I of r){const O=I1(I);if(!this.filter.isEventVisible(I,O))continue;const R=w.get(I.agent.id);if(R===void 0)continue;const z=p+(I.timestamp-l)/u*d,Q=R*y,X=kh(I);s.fillStyle=X;const j=Q+y/2;I.type==="agent:spawn"||I.type==="agent:shutdown"?s.fillRect(z-1,Q+1,3,y-2):I.type==="agent:idle"?(s.globalAlpha=.5,s.beginPath(),s.moveTo(z,j-3),s.lineTo(z+3,j),s.lineTo(z,j+3),s.lineTo(z-3,j),s.closePath(),s.fill(),s.globalAlpha=1):(s.globalAlpha=.7,s.beginPath(),s.arc(z,j,2.5,0,Math.PI*2),s.fill(),s.globalAlpha=1)}const S=x;s.fillStyle="rgba(255,255,255,0.15)",s.font="9px monospace",s.textAlign="center";const A=Cu(u),L=Math.ceil(l/A)*A;for(let I=L;I<=h;I+=A){const O=p+(I-l)/u*d;s.fillRect(O,S,1,3);const R=new Date(I);s.fillText(R.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),O,S+12)}if(this.isLive)s.strokeStyle="#4ade80",s.lineWidth=2,s.beginPath(),s.moveTo(t-1,0),s.lineTo(t-1,e),s.stroke(),this.timeLabel.textContent="LIVE";else{const I=p+this.playbackPosition*d;s.strokeStyle="#e94560",s.lineWidth=2,s.beginPath(),s.moveTo(I,0),s.lineTo(I,e),s.stroke();const O=l+this.playbackPosition*u;this.timeLabel.textContent=new Date(O).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}onTrackClick(t){const e=this.canvas.getBoundingClientRect();let s=t.clientX-e.left;if(this.expanded){const o=e.width-60;if(s=s-60,s<0)return;const r=Math.max(0,Math.min(1,s/o));this.isLive=!1,this.liveBtn.classList.remove("active"),this.playbackPosition=r}else{const n=Math.max(0,Math.min(1,s/e.width));this.isLive=!1,this.liveBtn.classList.remove("active"),this.playbackPosition=n}this.isPlaying=!1,this.playBtn.innerHTML="&#9654;",this.stopPlayback(),this.reconstructState(),this.render()}goLive(){this.isLive=!0,this.isPlaying=!1,this.playBtn.innerHTML="&#9654;",this.liveBtn.classList.add("active"),this.stopPlayback(),this.onReplayState&&this.onReplayState(this.store.getAgents()),this.render()}startPlayback(){if(this.animId)return;this.lastFrameTime=performance.now();const t=()=>{const e=performance.now(),s=e-this.lastFrameTime;this.lastFrameTime=e;const{start:n,end:o}=this.getTimeRange(),r=o-n||1,l=s*this.playbackSpeed/r;if(this.playbackPosition=Math.min(1,this.playbackPosition+l),this.playbackPosition>=1){this.goLive();return}this.reconstructState(),this.render(),this.animId=requestAnimationFrame(t)};this.animId=requestAnimationFrame(t)}stopPlayback(){this.animId&&(cancelAnimationFrame(this.animId),this.animId=null)}reconstructState(){const t=this.store.getTimeline(),{start:e,end:s}=this.getTimeRange(),n=s-e||1,o=e+this.playbackPosition*n;this.replayAgents.clear();for(const r of t){if(r.timestamp>o)break;switch(r.type){case"agent:spawn":case"agent:update":case"agent:idle":this.replayAgents.set(r.agent.id,{...r.agent});break;case"agent:shutdown":this.replayAgents.delete(r.agent.id);break}}this.onReplayState&&this.onReplayState(this.replayAgents)}}const ir=class ir{constructor(){b(this,"ctx",null);b(this,"_volume",.3);b(this,"_muted",!1);b(this,"initialized",!1);b(this,"lastToolUseTime",0)}get volume(){return this._volume}set volume(t){this._volume=Math.max(0,Math.min(1,t))}get muted(){return this._muted}set muted(t){this._muted=t}init(){this.initialized||(this.ctx=new AudioContext,this.initialized=!0)}ensureContext(){if(!this.ctx)try{this.ctx=new AudioContext,this.initialized=!0}catch{return null}return this.ctx.state==="suspended"&&this.ctx.resume(),this.ctx}gain(){return this._muted?0:this._volume}play(t){if(this._muted||this._volume===0)return;const e=this.ensureContext();if(e)switch(t){case"spawn":this.playSpawn(e);break;case"zone-change":this.playZoneChange(e);break;case"tool-use":{const s=performance.now();if(s-this.lastToolUseTime<ir.TOOL_USE_COOLDOWN)return;this.lastToolUseTime=s,this.playToolUse(e);break}case"idle":this.playIdle(e);break;case"shutdown":this.playShutdown(e);break;case"input-needed":this.playInputNeeded(e);break}}playSpawn(t){const e=t.currentTime,s=this.gain()*.25;[523.25,659.25,783.99].forEach((o,r)=>{const l=t.createOscillator(),h=t.createGain();l.type="sine",l.frequency.value=o,h.gain.setValueAtTime(0,e+r*.1),h.gain.linearRampToValueAtTime(s,e+r*.1+.03),h.gain.exponentialRampToValueAtTime(.001,e+r*.1+.3),l.connect(h).connect(t.destination),l.start(e+r*.1),l.stop(e+r*.1+.35)})}playZoneChange(t){const e=t.currentTime,s=this.gain()*.12,n=t.createOscillator(),o=t.createGain();n.type="sine",n.frequency.setValueAtTime(440,e),n.frequency.exponentialRampToValueAtTime(660,e+.08),o.gain.setValueAtTime(s,e),o.gain.exponentialRampToValueAtTime(.001,e+.15),n.connect(o).connect(t.destination),n.start(e),n.stop(e+.2)}playToolUse(t){const e=t.currentTime,s=this.gain()*.06,n=t.createOscillator(),o=t.createGain();n.type="sine",n.frequency.setValueAtTime(880,e),n.frequency.exponentialRampToValueAtTime(600,e+.06),o.gain.setValueAtTime(s,e),o.gain.exponentialRampToValueAtTime(.001,e+.08),n.connect(o).connect(t.destination),n.start(e),n.stop(e+.1)}playIdle(t){const e=t.currentTime,s=this.gain()*.1,n=t.createOscillator(),o=t.createGain();n.type="sine",n.frequency.setValueAtTime(440,e),n.frequency.exponentialRampToValueAtTime(330,e+.2),o.gain.setValueAtTime(s,e),o.gain.exponentialRampToValueAtTime(.001,e+.3),n.connect(o).connect(t.destination),n.start(e),n.stop(e+.35)}playShutdown(t){const e=t.currentTime,s=this.gain()*.2;[659.25,523.25,392].forEach((o,r)=>{const l=t.createOscillator(),h=t.createGain();l.type="triangle",l.frequency.value=o,h.gain.setValueAtTime(0,e+r*.12),h.gain.linearRampToValueAtTime(s,e+r*.12+.02),h.gain.exponentialRampToValueAtTime(.001,e+r*.12+.3),l.connect(h).connect(t.destination),l.start(e+r*.12),l.stop(e+r*.12+.35)})}playInputNeeded(t){const e=t.currentTime,s=this.gain()*.3;[{freq:880,start:0,type:"sine"},{freq:660,start:.15,type:"sine"}].forEach(({freq:o,start:r,type:l})=>{const h=t.createOscillator(),u=t.createGain();h.type=l,h.frequency.value=o,u.gain.setValueAtTime(0,e+r),u.gain.linearRampToValueAtTime(s,e+r+.02),u.gain.exponentialRampToValueAtTime(.001,e+r+.25),h.connect(u).connect(t.destination),h.start(e+r),h.stop(e+r+.3)})}};b(ir,"TOOL_USE_COOLDOWN",300);let el=ir;class D1{constructor(){b(this,"_enabled",!0);b(this,"permissionGranted",!1)}get enabled(){return this._enabled}set enabled(t){this._enabled=t}async requestPermission(){if(!("Notification"in window))return;if(Notification.permission==="granted"){this.permissionGranted=!0;return}if(Notification.permission==="denied")return;const t=await Notification.requestPermission();this.permissionGranted=t==="granted"}notifySpawn(t){this.show("Agent Spawned",`${t} has entered the office`)}notifyShutdown(t){this.show("Agent Finished",`${t} has left the office`)}notifyIdle(t){this.show("Agent Idle",`${t} is now idle`)}notifyInputNeeded(t){this.show("⚠️ Input Needed",`${t} is waiting for your input!`)}show(t,e){if(this._enabled&&this.permissionGranted&&document.visibilityState!=="visible")try{new Notification(t,{body:e,icon:"/favicon.ico",silent:!0,tag:"agent-move"})}catch{}}}const Pn=300,$1=2,z1=3,F1=8;class N1{constructor(t){b(this,"zones",new Map);b(this,"container");b(this,"currentBucketIndex",0);b(this,"bucketTimer");b(this,"animFrame",null);b(this,"lastFrameTime",0);b(this,"animate",()=>{const t=performance.now(),e=(t-this.lastFrameTime)/1e3;this.lastFrameTime=t;for(const[s,n]of this.zones){let o=0;for(let l=0;l<Pn;l++){const h=(this.currentBucketIndex-l+Pn)%Pn,u=Math.exp(-h/60);o+=n.buckets[l]*u}const r=Math.min(1,o/(F1*15));n.heat+=(r-n.heat)*Math.min(1,$1*e),n.pulsePhase+=z1*e*(.5+n.heat*.5),this.renderZoneHeat(n,s)}this.animFrame=requestAnimationFrame(this.animate)});this.store=t,this.container=document.createElement("div"),this.container.id="zone-heatmap",this.container.style.cssText=`
399
+ position: absolute;
400
+ top: 0;
401
+ left: 0;
402
+ width: 100%;
403
+ height: 100%;
404
+ pointer-events: none;
405
+ z-index: 5;
406
+ `,document.getElementById("app").appendChild(this.container);for(const e of ze){const s=document.createElement("canvas");s.style.cssText=`
407
+ position: absolute;
408
+ pointer-events: none;
409
+ border-radius: 4px;
410
+ `,this.container.appendChild(s);const n=s.getContext("2d");this.zones.set(e.id,{buckets:new Array(Pn).fill(0),heat:0,pulsePhase:Math.random()*Math.PI*2,overlay:s,ctx:n})}this.store.on("agent:update",e=>{const s=this.zones.get(e.currentZone);s&&s.buckets[this.currentBucketIndex]++}),this.bucketTimer=setInterval(()=>{this.currentBucketIndex=(this.currentBucketIndex+1)%Pn;for(const e of this.zones.values())e.buckets[this.currentBucketIndex]=0},1e3),this.lastFrameTime=performance.now(),this.animate()}updateTransform(t,e,s){for(const n of ze){const o=this.zones.get(n.id);if(!o)continue;const r=n.x*s+t,l=n.y*s+e,h=n.width*s,u=n.height*s;o.overlay.style.left=`${r}px`,o.overlay.style.top=`${l}px`,o.overlay.style.width=`${h}px`,o.overlay.style.height=`${u}px`,o.overlay.width=Math.ceil(h),o.overlay.height=Math.ceil(u)}}renderZoneHeat(t,e){const{ctx:s,overlay:n}=t,o=n.width,r=n.height;if(o===0||r===0||(s.clearRect(0,0,o,r),t.heat<.01))return;const l=Math.sin(t.pulsePhase)*.15+.85,h=t.heat*.18*l,u=Math.floor(In(30,255,t.heat)),d=Math.floor(In(60,t.heat<.5?In(80,160,t.heat*2):In(160,50,(t.heat-.5)*2),t.heat)),p=Math.floor(In(180,20,t.heat)),m=o/2,g=r/2,y=s.createRadialGradient(m,g,0,m,g,Math.max(o,r)*.7);if(y.addColorStop(0,`rgba(${u},${d},${p},${h})`),y.addColorStop(.6,`rgba(${u},${d},${p},${h*.5})`),y.addColorStop(1,`rgba(${u},${d},${p},0)`),s.fillStyle=y,s.fillRect(0,0,o,r),t.heat>.3){const x=(t.heat-.3)*.4*l;s.strokeStyle=`rgba(${u},${d},${p},${x})`,s.lineWidth=2+t.heat*3,s.strokeRect(1,1,o-2,r-2)}}dispose(){clearInterval(this.bucketTimer),this.animFrame&&cancelAnimationFrame(this.animFrame),this.container.remove()}}function W1(i,t,e){return Math.min(Math.max(i,t),e)}function In(i,t,e){return i+(t-i)*W1(e,0,1)}class G1{constructor(t,e){b(this,"el");b(this,"inputEl");b(this,"listEl");b(this,"isOpen",!1);b(this,"actions",[]);b(this,"filteredActions",[]);b(this,"selectedIndex",0);b(this,"onCommand");b(this,"_customizationLookup",null);b(this,"globalKeydownHandler",t=>{(t.metaKey||t.ctrlKey)&&t.key==="k"&&(t.preventDefault(),this.toggle())});this.store=t,this.onCommand=e,this.el=document.createElement("div"),this.el.id="command-palette",this.el.innerHTML=`
411
+ <div class="cmd-backdrop"></div>
412
+ <div class="cmd-modal">
413
+ <div class="cmd-input-wrap">
414
+ <span class="cmd-icon"><svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" opacity="0.5"><path d="M15.5 14h-.79l-.28-.27A6.47 6.47 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg></span>
415
+ <input type="text" class="cmd-input" placeholder="Search commands, agents, zones…" autocomplete="off" />
416
+ <kbd class="cmd-kbd">ESC</kbd>
417
+ </div>
418
+ <div class="cmd-list"></div>
419
+ <div class="cmd-footer">
420
+ <span><kbd>&uarr;&darr;</kbd> Navigate</span>
421
+ <span><kbd>Enter</kbd> Select</span>
422
+ <span><kbd>Esc</kbd> Close</span>
423
+ </div>
424
+ </div>
425
+ `,document.body.appendChild(this.el),this.inputEl=this.el.querySelector(".cmd-input"),this.listEl=this.el.querySelector(".cmd-list"),this.el.querySelector(".cmd-backdrop").addEventListener("click",()=>this.close()),this.inputEl.addEventListener("input",()=>this.onFilter()),this.inputEl.addEventListener("keydown",s=>this.onKeyDown(s)),document.addEventListener("keydown",this.globalKeydownHandler),this.buildActions()}setCustomizationLookup(t){this._customizationLookup=t}buildActions(){this.actions=[];for(const t of ze)this.actions.push({id:`zone:${t.id}`,label:`Go to ${t.label}`,description:t.description,icon:t.icon,category:"zone",action:()=>this.onCommand("focus-zone",t.id)});this.actions.push({id:"view:reset",label:"Reset Camera",description:"Fit all zones in view",icon:"🔲",category:"view",action:()=>this.onCommand("reset-camera")}),this.actions.push({id:"view:zoom-in",label:"Zoom In",description:"Zoom into the scene",icon:"🔍",category:"view",action:()=>this.onCommand("zoom-in")}),this.actions.push({id:"view:zoom-out",label:"Zoom Out",description:"Zoom out of the scene",icon:"🔎",category:"view",action:()=>this.onCommand("zoom-out")}),this.actions.push({id:"audio:mute",label:"Toggle Sound",description:"Mute or unmute sound effects",icon:"🔊",category:"audio",action:()=>this.onCommand("toggle-mute")}),this.actions.push({id:"feature:heatmap",label:"Toggle Heatmap",description:"Show/hide zone activity heatmap",icon:"🌡",category:"feature",action:()=>this.onCommand("toggle-heatmap")}),this.actions.push({id:"feature:analytics",label:"Open Analytics",description:"Show cost tracker & analytics dashboard",icon:"📊",category:"feature",action:()=>this.onCommand("toggle-analytics")}),this.actions.push({id:"feature:timeline-live",label:"Jump to Live",description:"Return timeline to live mode",icon:"🟢",category:"feature",action:()=>this.onCommand("timeline-live")}),this.actions.push({id:"feature:shortcuts",label:"Keyboard Shortcuts",description:"Show all keyboard shortcuts (?)",icon:"⌨",category:"feature",action:()=>this.onCommand("toggle-shortcuts")}),this.actions.push({id:"feature:focus",label:"Toggle Focus Mode",description:"Camera follows selected agent (F)",icon:"🎯",category:"feature",action:()=>this.onCommand("toggle-focus")}),this.actions.push({id:"feature:export",label:"Export Session Summary",description:"Generate session report (E)",icon:"📋",category:"feature",action:()=>this.onCommand("session-export")}),this.actions.push({id:"feature:trails",label:"Toggle Agent Trails",description:"Show movement trail dots (T)",icon:"✨",category:"feature",action:()=>this.onCommand("toggle-trails")}),this.actions.push({id:"feature:daynight",label:"Toggle Day/Night Cycle",description:"Real-time lighting overlay (N)",icon:"🌙",category:"feature",action:()=>this.onCommand("toggle-daynight")}),this.actions.push({id:"feature:minimap",label:"Toggle Mini-map",description:"Overview navigation map (`)",icon:"🗺",category:"feature",action:()=>this.onCommand("toggle-minimap")}),this.actions.push({id:"feature:leaderboard",label:"Toggle Leaderboard",description:"Agent performance rankings (L)",icon:"🏆",category:"feature",action:()=>this.onCommand("toggle-leaderboard")}),this.actions.push({id:"feature:theme",label:"Cycle Theme",description:"Switch between Office, Space, Castle, Cyberpunk",icon:"🎨",category:"feature",action:()=>this.onCommand("cycle-theme")}),this.actions.push({id:"feature:toolchain",label:"Toggle Tool Chains",description:"Tool usage stats and transition graph (C)",icon:"🔗",category:"feature",action:()=>this.onCommand("toggle-toolchain")}),this.actions.push({id:"feature:taskgraph",label:"Toggle Task Graph",description:"Visualize task dependencies (G)",icon:"📋",category:"feature",action:()=>this.onCommand("toggle-taskgraph")}),this.actions.push({id:"feature:activity",label:"Toggle Activity Feed",description:"Scrollable event timeline (V)",icon:"📜",category:"feature",action:()=>this.onCommand("toggle-activity")}),this.actions.push({id:"feature:waterfall",label:"Toggle Waterfall View",description:"Tool call trace timeline (W)",icon:"📊",category:"feature",action:()=>this.onCommand("toggle-waterfall")}),this.actions.push({id:"feature:graph",label:"Toggle Agent Graph",description:"Agent relationship visualization (R)",icon:"🔗",category:"feature",action:()=>this.onCommand("toggle-graph")})}getAgentActions(){return Array.from(this.store.getAgents().values()).map(e=>{var o,r;const s=(o=this._customizationLookup)==null?void 0:o.call(this,e),n=(s==null?void 0:s.displayName)||e.agentName||e.projectName||e.sessionId.slice(0,10);return{id:`agent:${e.id}`,label:`Focus: ${n}`,description:`${e.isIdle?"Idle":"Active"} in ${((r=Vt.get(e.currentZone))==null?void 0:r.label)??e.currentZone}`,icon:e.isIdle?"💤":"🤖",category:"agent",action:()=>this.onCommand("focus-agent",e.id)}})}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.el.classList.add("open"),this.inputEl.value="",this.selectedIndex=0,this.onFilter(),requestAnimationFrame(()=>this.inputEl.focus())}close(){this.isOpen=!1,this.el.classList.remove("open")}dispose(){document.removeEventListener("keydown",this.globalKeydownHandler),this.el.remove()}onFilter(){const t=this.inputEl.value.toLowerCase().trim(),e=[...this.actions,...this.getAgentActions()];t?this.filteredActions=e.filter(s=>s.label.toLowerCase().includes(t)||s.description.toLowerCase().includes(t)||s.category.includes(t)):this.filteredActions=e,this.selectedIndex=0,this.renderList()}renderList(){if(this.filteredActions.length===0){this.listEl.innerHTML='<div class="cmd-empty">No matching commands</div>';return}this.listEl.innerHTML=this.filteredActions.map((t,e)=>{const s=e===this.selectedIndex?"selected":"",n=`cmd-cat-${t.category}`;return`<div class="cmd-item ${s} ${n}" data-index="${e}">
426
+ <span class="cmd-item-icon">${t.icon}</span>
427
+ <div class="cmd-item-text">
428
+ <div class="cmd-item-label">${Bt(t.label)}</div>
429
+ <div class="cmd-item-desc">${Bt(t.description)}</div>
430
+ </div>
431
+ <span class="cmd-item-cat">${t.category}</span>
432
+ </div>`}).join(""),this.listEl.querySelectorAll(".cmd-item").forEach(t=>{t.addEventListener("click",()=>{const e=parseInt(t.dataset.index,10);this.executeAction(e)}),t.addEventListener("mouseenter",()=>{this.selectedIndex=parseInt(t.dataset.index,10),this.updateSelection()})})}updateSelection(){this.listEl.querySelectorAll(".cmd-item").forEach((e,s)=>{e.classList.toggle("selected",s===this.selectedIndex)});const t=this.listEl.querySelector(".cmd-item.selected");t==null||t.scrollIntoView({block:"nearest"})}onKeyDown(t){switch(t.key){case"ArrowDown":t.preventDefault(),this.selectedIndex=Math.min(this.selectedIndex+1,this.filteredActions.length-1),this.updateSelection();break;case"ArrowUp":t.preventDefault(),this.selectedIndex=Math.max(this.selectedIndex-1,0),this.updateSelection();break;case"Enter":t.preventDefault(),this.executeAction(this.selectedIndex);break;case"Escape":t.preventDefault(),this.close();break}}executeAction(t){const e=this.filteredActions[t];e&&(this.close(),e.action())}}const O1=6e4,pa=2e3,H1=180;class U1{constructor(t,e){b(this,"containerEl");b(this,"contentEl");b(this,"store");b(this,"isVisible",!1);b(this,"refreshTimer");b(this,"sampleTimer");b(this,"tokenSamples",[]);b(this,"costThreshold",5);b(this,"thresholdAlerted",!1);b(this,"thresholdFocused",!1);b(this,"alertEl",null);b(this,"toolChainData",null);b(this,"zoneTime",new Map);b(this,"_customizationLookup",null);b(this,"onAgentUpdateBound");b(this,"onToolChainBound");this.store=t,this.containerEl=e,this.contentEl=document.createElement("div"),this.contentEl.id="analytics-content",this.contentEl.style.display="none",this.containerEl.appendChild(this.contentEl),this.alertEl=document.createElement("div"),this.alertEl.id="cost-alert",this.alertEl.style.display="none",document.body.appendChild(this.alertEl),this.refreshTimer=setInterval(()=>{this.isVisible&&this.render()},1e3),this.sampleTimer=setInterval(()=>this.takeSample(),pa),this.onAgentUpdateBound=s=>{this.checkThreshold()},this.onToolChainBound=s=>{this.toolChainData=s},this.store.on("agent:update",this.onAgentUpdateBound),this.store.on("toolchain:snapshot",this.onToolChainBound)}setCustomizationLookup(t){this._customizationLookup=t}show(){this.isVisible=!0,this.contentEl.style.display="",this.render()}hide(){this.isVisible=!1,this.contentEl.style.display="none"}toggle(){this.isVisible?this.hide():this.show()}takeSample(){const t=Array.from(this.store.getAgents().values());let e=0;for(const s of t){e+=s.totalInputTokens+s.totalOutputTokens+s.cacheReadTokens+s.cacheCreationTokens;const n=s.isIdle?"idle":s.currentZone,o=this.zoneTime.get(n)??0;this.zoneTime.set(n,o+pa/1e3)}this.tokenSamples.push({timestamp:Date.now(),totalTokens:e}),this.tokenSamples.length>H1&&this.tokenSamples.shift()}getSnapshots(){return Array.from(this.store.getAgents().values()).map(t=>{var s;const e=(s=this._customizationLookup)==null?void 0:s.call(this,t);return{id:t.id,name:(e==null?void 0:e.displayName)||t.agentName||t.projectName||t.sessionId.slice(0,10),model:t.model,inputTokens:t.totalInputTokens,outputTokens:t.totalOutputTokens,cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,colorIndex:(e==null?void 0:e.colorIndex)??t.colorIndex,zone:t.currentZone,isIdle:t.isIdle,spawnedAt:t.spawnedAt}})}calculateCost(t){return xl({totalInputTokens:t.inputTokens,totalOutputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,model:t.model})}getTokenVelocity(){if(this.tokenSamples.length<2)return 0;const e=Date.now()-O1,s=this.tokenSamples.filter(l=>l.timestamp>=e);if(s.length<2)return 0;const n=s[0],o=s[s.length-1],r=(o.timestamp-n.timestamp)/6e4;return r<.01?0:(o.totalTokens-n.totalTokens)/r}getVelocityTrend(){if(this.tokenSamples.length<10)return"stable";const t=Math.floor(this.tokenSamples.length/2),e=this.tokenSamples.slice(0,t),s=this.tokenSamples.slice(t),n=this.avgDelta(e),o=this.avgDelta(s);return o>n*1.2?"up":o<n*.8?"down":"stable"}avgDelta(t){if(t.length<2)return 0;let e=0;for(let s=1;s<t.length;s++)e+=t[s].totalTokens-t[s-1].totalTokens;return e/(t.length-1)}checkThreshold(){const e=this.getSnapshots().reduce((s,n)=>s+this.calculateCost(n),0);e>=this.costThreshold&&!this.thresholdAlerted&&(this.thresholdAlerted=!0,this.showAlert(e))}showAlert(t){this.alertEl&&(this.alertEl.textContent=`Warning: Cost threshold exceeded: $${t.toFixed(2)}`,this.alertEl.style.display="block",this.alertEl.classList.add("flash"),setTimeout(()=>{this.alertEl&&(this.alertEl.classList.remove("flash"),setTimeout(()=>{this.alertEl&&(this.alertEl.style.display="none")},5e3))},3e3))}render(){const t=this.getSnapshots(),e=t.reduce((S,A)=>S+this.calculateCost(A),0),s=t.reduce((S,A)=>S+A.inputTokens,0),n=t.reduce((S,A)=>S+A.outputTokens,0),o=t.reduce((S,A)=>S+A.cacheReadTokens,0),r=t.reduce((S,A)=>S+A.cacheCreationTokens,0),l=this.getTokenVelocity(),h=this.getVelocityTrend(),u=h==="up"?"↑":h==="down"?"↓":"→",d=h==="up"?"#f87171":h==="down"?"#4ade80":"#888",p=s+o+r,m=p>0?o/p*100:0,g=t.reduce((S,A)=>{const L=_l(A.model);return S+A.cacheReadTokens/1e6*L.input*.9},0),y=[...t].sort((S,A)=>this.calculateCost(A)-this.calculateCost(S)),x=this.renderVelocitySparkline();this.contentEl.innerHTML=`
433
+ <div class="analytics-cards">
434
+ <div class="analytics-card total-cost">
435
+ <div class="card-label">Total Cost</div>
436
+ <div class="card-value">$${e.toFixed(2)}</div>
437
+ <div class="card-sub">${de(p)} in / ${de(n)} out</div>
438
+ </div>
439
+ <div class="analytics-card velocity">
440
+ <div class="card-label">Token Velocity</div>
441
+ <div class="card-value">${de(Math.round(l))}<span class="card-unit">/min</span></div>
442
+ <div class="card-sub" style="color:${d}">${u} ${h}</div>
443
+ </div>
444
+ <div class="analytics-card agents-count">
445
+ <div class="card-label">Active Agents</div>
446
+ <div class="card-value">${t.filter(S=>!S.isIdle).length}<span class="card-unit">/${t.length}</span></div>
447
+ <div class="card-sub">${t.filter(S=>S.isIdle).length} idle</div>
448
+ </div>
449
+ <div class="analytics-card cache-card">
450
+ <div class="card-label">Cache Efficiency</div>
451
+ <div class="card-value">${Math.min(m,100).toFixed(1)}<span class="card-unit">%</span></div>
452
+ <div class="card-sub">${de(o)} read / ${de(r)} created</div>
453
+ <div class="cache-savings">~$${g.toFixed(2)} saved</div>
454
+ </div>
455
+ </div>
456
+
457
+ <div class="analytics-section">
458
+ <div class="section-title">Token Rate (last ${Math.round(this.tokenSamples.length*pa/6e4)}min)</div>
459
+ <div class="sparkline-container">${x}</div>
460
+ </div>
461
+
462
+ <div class="analytics-section">
463
+ <div class="section-title">Cost by Agent</div>
464
+ ${y.length>0?y.map(S=>this.renderAgentBar(S,e)).join(""):'<div class="analytics-empty">No agents active</div>'}
465
+ </div>
466
+
467
+ <div class="analytics-section">
468
+ <div class="section-title">Time Spent by Zone</div>
469
+ ${this.renderZoneTimeBars()}
470
+ </div>
471
+
472
+ <div class="analytics-section">
473
+ <div class="section-title">Tool Usage Distribution</div>
474
+ ${this.renderToolUsageBars()}
475
+ </div>
476
+
477
+ <div class="analytics-section">
478
+ <div class="section-title">Cost Efficiency</div>
479
+ ${this.renderCostEfficiency(t,e)}
480
+ </div>
481
+
482
+ <div class="analytics-section">
483
+ <div class="section-title">Session Duration</div>
484
+ ${this.renderSessionDurations(t)}
485
+ </div>
486
+
487
+ <div class="analytics-section threshold-section">
488
+ <div class="section-title">Alert Threshold</div>
489
+ <div class="threshold-row">
490
+ <span>$</span>
491
+ <input type="number" id="cost-threshold" name="cost-threshold" autocomplete="off" value="${this.costThreshold}" min="0.1" step="0.5" />
492
+ <span class="threshold-status">${this.thresholdAlerted?"Exceeded":"Under"}</span>
493
+ </div>
494
+ </div>
495
+ `;const w=this.contentEl.querySelector("#cost-threshold");w&&(w.addEventListener("change",()=>{this.costThreshold=parseFloat(w.value)||5,this.thresholdAlerted=!1}),this.thresholdFocused&&w.focus(),w.addEventListener("focus",()=>{this.thresholdFocused=!0}),w.addEventListener("blur",()=>{this.thresholdFocused=!1}))}renderAgentBar(t,e){const s=this.calculateCost(t),n=e>0?s/e*100:0,o=dt[t.colorIndex%dt.length],r=Xe(o.body);return`<div class="agent-bar">
496
+ <div class="agent-bar-label">
497
+ <span class="agent-dot" style="background:${r}"></span>
498
+ <span class="agent-bar-name">${Bt(t.name)}</span>
499
+ <span class="agent-bar-cost">$${s.toFixed(2)}</span>
500
+ </div>
501
+ <div class="agent-bar-track">
502
+ <div class="agent-bar-fill" style="width:${Math.max(2,n)}%;background:${r}"></div>
503
+ </div>
504
+ </div>`}renderZoneTimeBars(){if(this.zoneTime.size===0)return'<div class="analytics-empty">Collecting data...</div>';const t=Array.from(this.zoneTime.values()).reduce((s,n)=>s+n,0);return Array.from(this.zoneTime.entries()).sort((s,n)=>n[1]-s[1]).map(([s,n])=>{const o=Vt.get(s),r=s==="idle",l=t>0?n/t*100:0,h=r?"#6b7280":o?Xe(o.color):"#666",u=r?"Idle":(o==null?void 0:o.label)??s;return`<div class="zone-bar">
505
+ <div class="zone-bar-label">
506
+ <span>${r?"💤":(o==null?void 0:o.icon)??""} ${u}</span>
507
+ <span class="zone-bar-cost">${un(n*1e3)} (${l.toFixed(0)}%)</span>
508
+ </div>
509
+ <div class="zone-bar-track">
510
+ <div class="zone-bar-fill" style="width:${Math.max(2,l)}%;background:${h}"></div>
511
+ </div>
512
+ </div>`}).join("")}renderVelocitySparkline(){if(this.tokenSamples.length<2)return'<div class="analytics-empty">Collecting data...</div>';const t=260,e=50,s=this.tokenSamples,n=[];for(let d=1;d<s.length;d++)n.push(Math.max(0,s[d].totalTokens-s[d-1].totalTokens));if(n.length===0)return"";const o=Math.max(...n,1),r=t/Math.max(n.length-1,1),h=n.map((d,p)=>{const m=p*r,g=e-d/o*(e-4)-2;return`${m.toFixed(1)},${g.toFixed(1)}`}).map((d,p)=>p===0?`M${d}`:`L${d}`).join(" "),u=`${h} L${((n.length-1)*r).toFixed(1)},${e} L0,${e} Z`;return`<svg width="${t}" height="${e}" viewBox="0 0 ${t} ${e}" class="velocity-spark">
513
+ <defs>
514
+ <linearGradient id="sparkGrad" x1="0" y1="0" x2="0" y2="1">
515
+ <stop offset="0%" stop-color="#4ade80" stop-opacity="0.3"/>
516
+ <stop offset="100%" stop-color="#4ade80" stop-opacity="0"/>
517
+ </linearGradient>
518
+ </defs>
519
+ <path d="${u}" fill="url(#sparkGrad)"/>
520
+ <path d="${h}" fill="none" stroke="#4ade80" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
521
+ </svg>`}renderToolUsageBars(){var o;const t=((o=this.toolChainData)==null?void 0:o.toolCounts)??{},e=Object.entries(t);if(e.length===0)return'<div class="analytics-empty">No tool usage data yet</div>';const s=e.sort((r,l)=>l[1]-r[1]).slice(0,10),n=s[0][1];return s.map(([r,l])=>{const h=n>0?l/n*100:0,u=r.startsWith("mcp__")?"#60a5fa":"#a78bfa";let d=r;if(r.startsWith("mcp__")){const p=r.slice(5).split("__");if(p.length>=2){const m=p.slice(0,-1).join("/"),g=p[p.length-1];d=`${m} / ${g}`}}return`<div class="tool-bar">
522
+ <div class="tool-bar-label">
523
+ <span class="tool-bar-name" title="${Bt(r)}">${Bt(d)}</span>
524
+ <span class="tool-bar-count">${l}</span>
525
+ </div>
526
+ <div class="tool-bar-track">
527
+ <div class="tool-bar-fill" style="width:${Math.max(2,h)}%;background:${u}"></div>
528
+ </div>
529
+ </div>`}).join("")}renderCostEfficiency(t,e){var u;const s=Object.values(((u=this.toolChainData)==null?void 0:u.toolCounts)??{}).reduce((d,p)=>d+p,0),n=s>0?e/s:0,o=t.reduce((d,p)=>d+p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreationTokens,0),r=s>0?o/s:0,l=Date.now(),h=t.map(d=>{const p=Math.max((l-d.spawnedAt)/6e4,.5),m=this.calculateCost(d);return{name:d.name,rate:m/p,cost:m}}).filter(d=>d.cost>.001).sort((d,p)=>p.rate-d.rate);return`
530
+ <div class="analytics-cards" style="margin-bottom:8px">
531
+ <div class="analytics-card">
532
+ <div class="card-label">Cost / Tool Use</div>
533
+ <div class="card-value">$${n.toFixed(4)}</div>
534
+ <div class="card-sub">${s} total uses</div>
535
+ </div>
536
+ <div class="analytics-card">
537
+ <div class="card-label">Tokens / Tool Use</div>
538
+ <div class="card-value">${de(Math.round(r))}</div>
539
+ <div class="card-sub">${de(o)} total</div>
540
+ </div>
541
+ </div>
542
+ ${h.length>0?'<div class="cost-rate-header">Cost rate ($/min)</div>'+h.slice(0,5).map(d=>`<div class="cost-rate-row">
543
+ <span class="cost-rate-name">${Bt(d.name)}</span>
544
+ <span class="cost-rate-value">$${d.rate.toFixed(4)}/min</span>
545
+ </div>`).join(""):""}
546
+ `}renderSessionDurations(t){if(t.length===0)return'<div class="analytics-empty">No active sessions</div>';const e=Date.now();return t.map(s=>{const n=e-s.spawnedAt,o=dt[s.colorIndex%dt.length];return`<div class="session-row">
547
+ <span class="agent-dot" style="background:${Xe(o.body)}"></span>
548
+ <span class="session-name">${Bt(s.name)}</span>
549
+ <span class="session-duration">${un(n)}</span>
550
+ <span class="session-status ${s.isIdle?"idle":"active"}">${s.isIdle?"idle":"active"}</span>
551
+ </div>`}).join("")}dispose(){var t;clearInterval(this.refreshTimer),clearInterval(this.sampleTimer),this.store.off("agent:update",this.onAgentUpdateBound),this.store.off("toolchain:snapshot",this.onToolChainBound),this.contentEl.remove(),(t=this.alertEl)==null||t.remove()}}const q1="agent-move-layout",Ch=200;new Map(ze.map(i=>[i.id,{x:i.x,y:i.y,width:i.width,height:i.height}]));function V1(){try{const i=localStorage.getItem(q1);if(!i)return;const t=JSON.parse(i);if(t.version!==1||!t.zones)return;for(const[e,s]of Object.entries(t.zones)){const n=Vt.get(e);n&&(n.x=s.x,n.y=s.y,n.width=Math.max(Ch,s.width),n.height=Math.max(Ch,s.height))}}catch{}}const Y1=6e4,j1=2e3;class X1{constructor(t){b(this,"store");b(this,"refreshTimer");b(this,"sampleTimer");b(this,"samples",[]);b(this,"connectionDot");b(this,"hooksDot");b(this,"focusBar");b(this,"hookEventCount",0);b(this,"onHooksStatusBound");b(this,"onPermRequestBound");b(this,"onPermResolvedBound");b(this,"onConnectionStatusBound");this.store=t,this.connectionDot=document.getElementById("connection-dot"),this.hooksDot=document.getElementById("hooks-dot"),this.focusBar=document.getElementById("focus-sub-bar"),this.onHooksStatusBound=()=>{this.hookEventCount++},this.onPermRequestBound=()=>{this.hookEventCount++},this.onPermResolvedBound=()=>{this.hookEventCount++},t.on("hooks:status",this.onHooksStatusBound),t.on("permission:request",this.onPermRequestBound),t.on("permission:resolved",this.onPermResolvedBound),this.onConnectionStatusBound=e=>{const s=e==="connected";this.connectionDot.classList.toggle("connected",s),this.connectionDot.classList.toggle("disconnected",!s),this.connectionDot.title=s?"Connected":"Disconnected",document.getElementById("disconnected-bar").classList.toggle("visible",!s)},this.store.on("connection:status",this.onConnectionStatusBound),this.refreshTimer=setInterval(()=>this.updateStats(),1e3),this.sampleTimer=setInterval(()=>this.takeSample(),j1)}showFocus(t){this.focusBar.querySelector(".fi-name").textContent=t,this.focusBar.classList.add("visible")}hideFocus(){this.focusBar.classList.remove("visible")}takeSample(){const t=Array.from(this.store.getAgents().values());let e=0;for(const s of t)e+=s.totalInputTokens+s.totalOutputTokens;this.samples.push({timestamp:Date.now(),total:e}),this.samples.length>90&&this.samples.shift()}getVelocity(){if(this.samples.length<2)return 0;const e=Date.now()-Y1,s=this.samples.filter(l=>l.timestamp>=e);if(s.length<2)return 0;const n=s[0],o=s[s.length-1],r=(o.timestamp-n.timestamp)/6e4;return r<.01?0:(o.total-n.total)/r}updateStats(){const t=Array.from(this.store.getAgents().values()),e=t.filter(d=>!d.isIdle&&!d.isDone).length,s=t.filter(d=>d.isIdle||d.isDone).length;let n=0;for(const d of t)n+=xl(d);const o=this.getVelocity(),r=(d,p)=>{const m=document.querySelector(`#${d} .tb-stat-val`);m&&(m.textContent=p)};r("tb-active",String(e)),r("tb-idle",String(s)),r("tb-cost",n<.01?n.toFixed(4):n.toFixed(2)),r("tb-velocity",de(Math.round(o)));const l=document.querySelector("#tb-active .tb-stat-dot");l&&l.classList.toggle("pulse",e>0);const h=this.store.getPendingPermissions().length,u=this.store.isHooksActive();this.hooksDot.classList.toggle("hooks-pending",h>0),this.hooksDot.classList.toggle("hooks-active",u&&h===0),h>0?this.hooksDot.title=`Hooks: ${h} permission${h>1?"s":""} pending | ${this.hookEventCount} events received`:u?this.hooksDot.title=`Hooks: active | ${this.hookEventCount} events received`:this.hooksDot.title="Hooks: not detected (run `agent-move hooks install`)"}dispose(){clearInterval(this.refreshTimer),clearInterval(this.sampleTimer),this.store.off("hooks:status",this.onHooksStatusBound),this.store.off("permission:request",this.onPermRequestBound),this.store.off("permission:resolved",this.onPermResolvedBound),this.store.off("connection:status",this.onConnectionStatusBound)}}class Z1{constructor(){b(this,"activeTab","monitor");b(this,"collapsed",!1);b(this,"onTabChange",null);b(this,"el");b(this,"toggleBtn");this.el=document.getElementById("sidebar"),this.toggleBtn=document.getElementById("sb-toggle"),localStorage.getItem("sidebar-collapsed")==="true"&&(this.collapsed=!0,this.el.classList.add("collapsed"),document.documentElement.style.setProperty("--sidebar-nav-width","52px")),this.toggleBtn.addEventListener("click",()=>this.toggle()),this.el.querySelectorAll(".sb-item").forEach(e=>{e.addEventListener("click",()=>{const s=e.dataset.tab;this.setActiveTab(s)})})}setTabChangeHandler(t){this.onTabChange=t}getActiveTab(){return this.activeTab}setActiveTab(t){var e,s;if(t===this.activeTab&&t!=="monitor"){this.activeTab="monitor",this.updateUI(),(e=this.onTabChange)==null||e.call(this,"monitor");return}this.activeTab=t,this.updateUI(),(s=this.onTabChange)==null||s.call(this,t)}toggle(){this.collapsed=!this.collapsed,this.el.classList.toggle("collapsed",this.collapsed),document.documentElement.style.setProperty("--sidebar-nav-width",this.collapsed?"52px":"200px"),localStorage.setItem("sidebar-collapsed",String(this.collapsed))}updateUI(){this.el.querySelectorAll(".sb-item").forEach(t=>{const e=t.dataset.tab;t.classList.toggle("active",e===this.activeTab)})}}const K1=4500,Q1=5,nr=class nr{constructor(t){b(this,"containerEl");b(this,"store");b(this,"_customizationLookup",null);b(this,"toasts",[]);b(this,"onSpawnBound");b(this,"onIdleBound");b(this,"onShutdownBound");b(this,"onAnomalyBound");b(this,"onTaskBound");this.store=t,this.containerEl=document.createElement("div"),this.containerEl.id="toast-container",this.containerEl.setAttribute("aria-live","polite"),document.body.appendChild(this.containerEl),this.onSpawnBound=e=>this.onSpawn(e),this.onIdleBound=e=>this.onIdle(e),this.onShutdownBound=e=>this.onShutdown(e),this.onAnomalyBound=e=>this.onAnomaly(e),this.onTaskBound=({taskSubject:e})=>this.onTaskCompleted(e),this.store.on("agent:spawn",this.onSpawnBound),this.store.on("agent:idle",this.onIdleBound),this.store.on("agent:shutdown",this.onShutdownBound),this.store.on("anomaly:alert",this.onAnomalyBound),this.store.on("task:completed",this.onTaskBound)}setCustomizationLookup(t){this._customizationLookup=t}getName(t){var s;const e=(s=this._customizationLookup)==null?void 0:s.call(this,t);return(e==null?void 0:e.displayName)||t.agentName||t.projectName||t.sessionId.slice(0,10)}getColor(t){const e=dt[t.colorIndex%dt.length];return Xe(e.body)}onSpawn(t){const e=this.getName(t),s=this.getColor(t),n=t.role==="main"?"":` (${t.role})`;this.show(`<span class="toast-dot" style="background:${s}"></span> <strong>${Bt(e)}</strong>${n} spawned`,"spawn")}onIdle(t){if(t.isDone){const e=this.getName(t),s=this.getColor(t);this.show(`<span class="toast-dot" style="background:${s}"></span> <strong>${Bt(e)}</strong> finished`,"done")}}onShutdown(t){const e=this.store.getAgent(t),s=e?this.getName(e):t.slice(0,10);this.show(`<strong>${Bt(s)}</strong> shut down`,"shutdown")}onTaskCompleted(t){this.show(`✓ Task completed: <strong>${Bt(t)}</strong>`,"done")}onAnomaly(t){const e=nr.ANOMALY_ICONS[t.kind]??"⚠️",s=t.severity==="critical"?"critical":"warning",n=this.store.getAgent(t.agentId),o=n?this.getName(n):t.agentName;this.show(`${e} <strong>${Bt(o)}</strong>: ${Bt(t.message)}`,s)}show(t,e="info"){const s=document.createElement("div");s.className=`toast toast-${e}`,s.innerHTML=t,this.containerEl.appendChild(s),requestAnimationFrame(()=>{s.classList.add("toast-enter")});const n=setTimeout(()=>this.dismiss(s),K1);for(this.toasts.push({el:s,timer:n});this.toasts.length>Q1;){const o=this.toasts.shift();o&&(clearTimeout(o.timer),this.removeEl(o.el))}}dismiss(t){t.classList.add("toast-exit"),t.addEventListener("animationend",()=>t.remove(),{once:!0}),setTimeout(()=>t.remove(),400);const e=this.toasts.findIndex(s=>s.el===t);e>=0&&this.toasts.splice(e,1)}removeEl(t){t.classList.add("toast-exit"),t.addEventListener("animationend",()=>t.remove(),{once:!0}),setTimeout(()=>t.remove(),400)}dispose(){this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:idle",this.onIdleBound),this.store.off("agent:shutdown",this.onShutdownBound),this.store.off("anomaly:alert",this.onAnomalyBound),this.store.off("task:completed",this.onTaskBound);for(const t of this.toasts)clearTimeout(t.timer),t.el.remove();this.toasts=[],this.containerEl.remove()}};b(nr,"ANOMALY_ICONS",{"retry-loop":"🔁","token-spike":"📈","stuck-agent":"⏳"});let sl=nr;const J1=[{title:"General",shortcuts:[{keys:"?",description:"Toggle this help overlay"},{keys:"Ctrl + K",description:"Open command palette"},{keys:"Esc",description:"Close any open panel"}]},{title:"Navigation",shortcuts:[{keys:"Scroll",description:"Zoom in / out"},{keys:"Click + Drag",description:"Pan the canvas"},{keys:"+ / -",description:"Zoom in / out"},{keys:"0",description:"Reset camera to fit view"}]},{title:"Panels",shortcuts:[{keys:"A",description:"Toggle analytics panel"},{keys:"H",description:"Toggle activity heatmap"},{keys:"E",description:"Export session summary"},{keys:"M",description:"Toggle sound mute"}]},{title:"Camera & Focus",shortcuts:[{keys:"F",description:"Focus / cycle to next agent"},{keys:"Esc",description:"Exit focus mode"}]},{title:"Timeline",shortcuts:[{keys:"Space",description:"Play / pause timeline replay"}]},{title:"New Features",shortcuts:[{keys:"T",description:"Toggle agent trails"},{keys:"N",description:"Toggle day/night cycle"},{keys:"`",description:"Toggle mini-map"},{keys:"L",description:"Toggle leaderboard"},{keys:"P",description:"Cycle theme"},{keys:"C",description:"Toggle tool chains panel"},{keys:"G",description:"Toggle task graph panel"},{keys:"V",description:"Toggle activity feed"},{keys:"W",description:"Toggle waterfall trace view"},{keys:"R",description:"Toggle agent relationship graph"}]}];class tb{constructor(){b(this,"el");b(this,"isOpen",!1);b(this,"globalKeydownHandler",t=>{var s;const e=(s=t.target)==null?void 0:s.tagName;e==="INPUT"||e==="TEXTAREA"||e==="SELECT"||(t.key==="?"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this.isOpen&&(t.preventDefault(),this.close()))});this.el=document.createElement("div"),this.el.id="shortcuts-help",this.el.innerHTML=`
552
+ <div class="sh-backdrop"></div>
553
+ <div class="sh-modal">
554
+ <div class="sh-header">
555
+ <span class="sh-title">Keyboard Shortcuts</span>
556
+ <button class="sh-close">&times;</button>
557
+ </div>
558
+ <div class="sh-body">
559
+ ${J1.map(t=>`
560
+ <div class="sh-group">
561
+ <div class="sh-group-title">${t.title}</div>
562
+ ${t.shortcuts.map(e=>`
563
+ <div class="sh-row">
564
+ <span class="sh-keys">${this.renderKeys(e.keys)}</span>
565
+ <span class="sh-desc">${e.description}</span>
566
+ </div>
567
+ `).join("")}
568
+ </div>
569
+ `).join("")}
570
+ </div>
571
+ <div class="sh-footer">Press <kbd>?</kbd> to close</div>
572
+ </div>
573
+ `,document.body.appendChild(this.el),this.el.querySelector(".sh-backdrop").addEventListener("click",()=>this.close()),this.el.querySelector(".sh-close").addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.globalKeydownHandler)}renderKeys(t){return t.split(/\s*\+\s*|\s*\/\s*/).map(e=>{const s=e.trim();return s?`<kbd>${s}</kbd>`:""}).filter(Boolean).join(t.includes("+")?" + ":" / ")}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.el.classList.add("open")}close(){this.isOpen=!1,this.el.classList.remove("open")}dispose(){document.removeEventListener("keydown",this.globalKeydownHandler),this.el.remove()}}class eb{constructor(t){b(this,"el");b(this,"store");b(this,"isOpen",!1);b(this,"_customizationLookup",null);this.store=t,this.el=document.createElement("div"),this.el.id="session-export",this.el.innerHTML=`
574
+ <div class="se-backdrop"></div>
575
+ <div class="se-modal">
576
+ <div class="se-header">
577
+ <span class="se-title">Session Summary</span>
578
+ <button class="se-close">&times;</button>
579
+ </div>
580
+ <div class="se-body">
581
+ <pre class="se-content"></pre>
582
+ </div>
583
+ <div class="se-footer">
584
+ <button class="se-copy-btn">Copy to Clipboard</button>
585
+ <button class="se-download-btn">Download .md</button>
586
+ </div>
587
+ </div>
588
+ `,document.body.appendChild(this.el),this.el.querySelector(".se-backdrop").addEventListener("click",()=>this.close()),this.el.querySelector(".se-close").addEventListener("click",()=>this.close()),this.el.querySelector(".se-copy-btn").addEventListener("click",()=>this.copyToClipboard()),this.el.querySelector(".se-download-btn").addEventListener("click",()=>this.download())}setCustomizationLookup(t){this._customizationLookup=t}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.el.classList.add("open"),this.render()}close(){this.isOpen=!1,this.el.classList.remove("open")}generateReport(){var m,g,y;const t=Array.from(this.store.getAgents().values()),e=Date.now(),s=t.length>0?Math.min(...t.map(x=>x.spawnedAt)):e,n=e-s;let o=0,r=0,l=0,h=0;const u=[];for(const x of t){const w=_l(x.model),S=x.totalInputTokens/1e6*w.input+x.totalOutputTokens/1e6*w.output;o+=S,r+=x.totalInputTokens,l+=x.totalOutputTokens,h+=x.cacheReadTokens;const A=Vt.get(x.currentZone);u.push({name:((g=(m=this._customizationLookup)==null?void 0:m.call(this,x))==null?void 0:g.displayName)||x.agentName||x.projectName||x.sessionId.slice(0,10),cost:S,tokens:x.totalInputTokens+x.totalOutputTokens,duration:e-x.spawnedAt,role:x.role,zone:(A==null?void 0:A.label)??x.currentZone,status:x.isDone?"Done":x.isIdle?"Idle":"Active"})}u.sort((x,w)=>w.cost-x.cost);const d=[];if(d.push("# AgentMove Session Summary"),d.push(`> Generated ${new Date().toISOString()}`),d.push(""),d.push("## Overview"),d.push("| Metric | Value |"),d.push("|--------|-------|"),d.push(`| Duration | ${un(n)} |`),d.push(`| Total Agents | ${t.length} |`),d.push(`| Active | ${t.filter(x=>!x.isIdle&&!x.isDone).length} |`),d.push(`| Idle | ${t.filter(x=>x.isIdle&&!x.isDone).length} |`),d.push(`| Done | ${t.filter(x=>x.isDone).length} |`),d.push(`| Total Cost | $${o.toFixed(4)} |`),d.push(`| Input Tokens | ${de(r)} |`),d.push(`| Output Tokens | ${de(l)} |`),d.push(`| Cache Reads | ${de(h)} |`),d.push(""),u.length>0){d.push("## Agents"),d.push("| Agent | Role | Status | Zone | Cost | Tokens | Duration |"),d.push("|-------|------|--------|------|------|--------|----------|");for(const x of u)d.push(`| ${x.name} | ${x.role} | ${x.status} | ${x.zone} | $${x.cost.toFixed(4)} | ${de(x.tokens)} | ${un(x.duration)} |`);d.push("")}const p=new Map;for(const x of t){const w=((y=Vt.get(x.currentZone))==null?void 0:y.label)??x.currentZone;p.set(w,(p.get(w)??0)+1)}if(p.size>0){d.push("## Zone Distribution"),d.push("| Zone | Agents |"),d.push("|------|--------|");for(const[x,w]of Array.from(p.entries()).sort((S,A)=>A[1]-S[1]))d.push(`| ${x} | ${w} |`);d.push("")}return d.push("---"),d.push("*Generated by AgentMove*"),d.join(`
589
+ `)}render(){const t=this.el.querySelector(".se-content");t.textContent=this.generateReport()}async copyToClipboard(){const t=this.generateReport();try{await navigator.clipboard.writeText(t);const e=this.el.querySelector(".se-copy-btn");e.textContent="Copied!",setTimeout(()=>{e.textContent="Copy to Clipboard"},2e3)}catch{const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),e.remove()}}download(){const t=this.generateReport(),e=new Blob([t],{type:"text/markdown"}),s=URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=`agent-move-session-${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.md`,n.click(),URL.revokeObjectURL(s)}dispose(){this.el.remove()}}const Ah="agent-move:onboarding-dismissed";class sb{constructor(){b(this,"el",null);this.isDismissed()||this.show()}isDismissed(){try{return localStorage.getItem(Ah)==="1"}catch{return!1}}dismiss(){try{localStorage.setItem(Ah,"1")}catch{}this.el&&(this.el.classList.add("ob-exit"),setTimeout(()=>{var t;return(t=this.el)==null?void 0:t.remove()},400))}show(){this.el=document.createElement("div"),this.el.id="onboarding",this.el.innerHTML=`
590
+ <div class="ob-card">
591
+ <div class="ob-header">
592
+ <span class="ob-logo">AgentMove</span>
593
+ <button class="ob-close">&times;</button>
594
+ </div>
595
+ <div class="ob-body">
596
+ <p class="ob-desc">Real-time visualization of your Claude Code sessions.</p>
597
+ <div class="ob-features">
598
+ <div class="ob-feature">
599
+ <span class="ob-icon">&#128187;</span>
600
+ <div>
601
+ <strong>Start a Claude Code session</strong>
602
+ <span>Agents appear automatically as they work</span>
603
+ </div>
604
+ </div>
605
+ <div class="ob-feature">
606
+ <span class="ob-icon">&#9000;</span>
607
+ <div>
608
+ <strong>Press <kbd>?</kbd> for shortcuts</strong>
609
+ <span>Quick keys for all features</span>
610
+ </div>
611
+ </div>
612
+ <div class="ob-feature">
613
+ <span class="ob-icon">&#128269;</span>
614
+ <div>
615
+ <strong>Press <kbd>Ctrl+K</kbd></strong>
616
+ <span>Command palette to search anything</span>
617
+ </div>
618
+ </div>
619
+ <div class="ob-feature">
620
+ <span class="ob-icon">&#128202;</span>
621
+ <div>
622
+ <strong>Press <kbd>A</kbd> for analytics</strong>
623
+ <span>Live cost tracking and token stats</span>
624
+ </div>
625
+ </div>
626
+ </div>
627
+ </div>
628
+ <button class="ob-dismiss">Got it, let's go!</button>
629
+ </div>
630
+ `,document.body.appendChild(this.el),requestAnimationFrame(()=>{var t;return(t=this.el)==null?void 0:t.classList.add("ob-enter")}),this.el.querySelector(".ob-close").addEventListener("click",()=>this.dismiss()),this.el.querySelector(".ob-dismiss").addEventListener("click",()=>this.dismiss()),this.el.addEventListener("click",t=>{t.target===this.el&&this.dismiss()})}dispose(){var t;(t=this.el)==null||t.remove()}}const Au="agent-move:";function kl(i,t){try{const e=localStorage.getItem(Au+i);return e===null?t:JSON.parse(e)}catch{return t}}function er(i,t){try{localStorage.setItem(Au+i,JSON.stringify(t))}catch{}}const ib=200,Mh=5,nb=20,Eh=4e3,ob=2;class rb{constructor(){b(this,"container",new Rt);b(this,"graphics",new Ft);b(this,"trails",new Map);b(this,"timers",new Map);b(this,"_enabled",!1);this.container.addChild(this.graphics),this.container.visible=!1}get enabled(){return this._enabled}toggle(){this._enabled=!this._enabled,this.container.visible=this._enabled,this._enabled||(this.trails.clear(),this.timers.clear(),this.graphics.clear())}recordPosition(t,e,s,n,o){if(!this._enabled)return;const r=(this.timers.get(t)??0)+n;if(this.timers.set(t,r),r<ib)return;this.timers.set(t,0);let l=this.trails.get(t);l||(l=[],this.trails.set(t,l));const h=l[l.length-1];if(h){const u=e-h.x,d=s-h.y;if(u*u+d*d<Mh*Mh)return}l.push({x:e,y:s,age:0}),l.length>nb&&l.shift()}removeAgent(t){this.trails.delete(t),this.timers.delete(t)}update(t,e){if(this._enabled){this.graphics.clear();for(const[s,n]of this.trails){const o=e.get(s)??4906624;let r=0;for(;r<n.length;)if(n[r].age+=t,n[r].age>=Eh)n.splice(r,1);else{const l=.4*(1-n[r].age/Eh);this.graphics.circle(n[r].x,n[r].y,ob).fill({color:o,alpha:l}),r++}n.length===0&&this.trails.delete(s)}}}}const Ln=200,Bn=150;class ab{constructor(t,e){b(this,"canvas");b(this,"ctx");b(this,"_visible",!1);b(this,"camera");b(this,"scaleX");b(this,"scaleY");this.camera=t,this.scaleX=Ln/Math.max(1,Na),this.scaleY=Bn/Math.max(1,Wa),this.canvas=document.createElement("canvas");const s=window.devicePixelRatio||1;this.canvas.width=Ln*s,this.canvas.height=Bn*s,this.canvas.id="minimap",this.canvas.style.cssText=`
631
+ position: fixed; bottom: 12px; right: 12px;
632
+ width: ${Ln}px; height: ${Bn}px;
633
+ border: 1px solid rgba(255,255,255,0.15);
634
+ border-radius: 6px; background: rgba(10,12,20,0.85);
635
+ cursor: crosshair; z-index: 80; display: none;
636
+ box-shadow: 0 2px 12px rgba(0,0,0,0.5);
637
+ `,document.body.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this.ctx.scale(s,s),this.canvas.addEventListener("click",n=>{const o=this.canvas.getBoundingClientRect(),r=n.clientX-o.left,l=n.clientY-o.top,h=r/this.scaleX,u=l/this.scaleY;e(h,u)})}get visible(){return this._visible}toggle(){this._visible=!this._visible,this.canvas.style.display=this._visible?"block":"none"}render(t,e){if(!this._visible)return;this.scaleX=Ln/Math.max(1,Na),this.scaleY=Bn/Math.max(1,Wa);const s=this.ctx;s.clearRect(0,0,Ln,Bn),s.imageSmoothingEnabled=!1;for(const h of ze){const u=h.x*this.scaleX,d=h.y*this.scaleY,p=h.width*this.scaleX,m=h.height*this.scaleY;s.fillStyle="#"+h.color.toString(16).padStart(6,"0")+"30",s.strokeStyle="#"+h.color.toString(16).padStart(6,"0")+"60",s.lineWidth=.5,s.fillRect(u,d,p,m),s.strokeRect(u,d,p,m),s.save(),s.fillStyle="#"+h.color.toString(16).padStart(6,"0")+"aa",s.font='600 8px "Inter", "SF Pro Text", system-ui, sans-serif',s.textAlign="center",s.textBaseline="middle",s.fillText(h.label,u+p/2,d+m/2,p-4),s.restore()}for(const h of t){const u=dt[h.colorIndex%dt.length];s.fillStyle="#"+u.body.toString(16).padStart(6,"0"),s.beginPath(),s.arc(h.x*this.scaleX,h.y*this.scaleY,3,0,Math.PI*2),s.fill()}const n=e.x*this.scaleX,o=e.y*this.scaleY,r=e.width*this.scaleX,l=e.height*this.scaleY;s.strokeStyle="rgba(255, 255, 255, 0.6)",s.lineWidth=1,s.strokeRect(n,o,r,l)}dispose(){this.canvas.remove()}}const lb=["🥇","🥈","🥉"];class cb{constructor(t,e){b(this,"contentEl");b(this,"containerEl");b(this,"isVisible",!1);b(this,"refreshInterval",null);b(this,"sortColumn","tokens");b(this,"sortDir","desc");b(this,"_customizationLookup",null);this.store=t,this.containerEl=e,this.contentEl=document.createElement("div"),this.contentEl.id="leaderboard-content",this.contentEl.style.display="none",this.containerEl.appendChild(this.contentEl)}setCustomizationLookup(t){this._customizationLookup=t}show(){this.isVisible=!0,this.contentEl.style.display="",this.render(),this.refreshInterval=setInterval(()=>this.render(),1e3)}hide(){this.isVisible=!1,this.contentEl.style.display="none",this.refreshInterval&&(clearInterval(this.refreshInterval),this.refreshInterval=null)}toggle(){this.isVisible?this.hide():this.show()}computeCost(t){return xl(t)}render(){const t=Array.from(this.store.getAgents().values());if(t.length===0){this.contentEl.innerHTML='<div class="lb-empty">No agents active</div>';return}const e=t.map(n=>{const o=this.computeCost(n),r=Date.now()-n.spawnedAt,l=n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens,h=r>6e4?l/(r/6e4):l;return{...n,cost:o,duration:r,velocity:h}});e.sort((n,o)=>{let r,l;switch(this.sortColumn){case"tokens":r=n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens,l=o.totalInputTokens+o.totalOutputTokens+o.cacheReadTokens+o.cacheCreationTokens;break;case"cost":r=n.cost,l=o.cost;break;case"duration":r=n.duration,l=o.duration;break;case"tools":r=n.toolUseCount,l=o.toolUseCount;break;case"velocity":r=n.velocity,l=o.velocity;break}return this.sortDir==="desc"?l-r:r-l});const s=Math.max(...e.map(n=>n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens),1);this.contentEl.innerHTML=`
638
+ <table class="lb-table">
639
+ <thead>
640
+ <tr>
641
+ <th>#</th>
642
+ <th>Agent</th>
643
+ <th class="lb-sortable" data-col="tokens">Tokens</th>
644
+ <th class="lb-sortable" data-col="cost">Cost</th>
645
+ <th class="lb-sortable" data-col="duration">Duration</th>
646
+ <th class="lb-sortable" data-col="tools">Tools</th>
647
+ </tr>
648
+ </thead>
649
+ <tbody>
650
+ ${e.map((n,o)=>{var y;const r=(y=this._customizationLookup)==null?void 0:y.call(this,n),l=(r==null?void 0:r.colorIndex)??n.colorIndex,u="#"+dt[l%dt.length].body.toString(16).padStart(6,"0"),d=(r==null?void 0:r.displayName)||n.agentName||n.projectName||n.sessionId.slice(0,10),p=n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens,m=p/s*100;return`<tr>
651
+ <td class="lb-rank">${o<3?lb[o]:`${o+1}`}</td>
652
+ <td class="lb-name"><span class="lb-dot" style="background:${u}"></span>${Bt(d)}</td>
653
+ <td>
654
+ <div class="lb-bar-wrap">
655
+ <div class="lb-bar" style="width:${m}%;background:${u}"></div>
656
+ <span class="lb-bar-label">${de(p)}</span>
657
+ </div>
658
+ </td>
659
+ <td>$${n.cost.toFixed(2)}</td>
660
+ <td>${un(n.duration)}</td>
661
+ <td>${n.toolUseCount}</td>
662
+ </tr>`}).join("")}
663
+ </tbody>
664
+ </table>
665
+ `,this.contentEl.querySelectorAll(".lb-sortable").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.col;this.sortColumn===o?this.sortDir=this.sortDir==="desc"?"asc":"desc":(this.sortColumn=o,this.sortDir="desc"),this.render()})})}dispose(){this.refreshInterval&&clearInterval(this.refreshInterval),this.contentEl.remove()}}const ma="agent-customizations";class hb{constructor(){b(this,"el");b(this,"customizations");b(this,"currentAgent",null);b(this,"onChange",null);this.customizations=kl(ma,{}),this.el=document.createElement("div"),this.el.id="agent-customizer",this.el.innerHTML=`
666
+ <div class="ac-backdrop"></div>
667
+ <div class="ac-popover">
668
+ <div class="ac-header">Customize Agent<button class="ac-close">&times;</button></div>
669
+ <div class="ac-field">
670
+ <label>Display Name</label>
671
+ <input type="text" class="ac-name-input" maxlength="14" placeholder="Custom name..." />
672
+ </div>
673
+ <div class="ac-field">
674
+ <label>Color</label>
675
+ <div class="ac-palette"></div>
676
+ </div>
677
+ <div class="ac-actions">
678
+ <button class="ac-reset">Reset</button>
679
+ <button class="ac-save">Save</button>
680
+ </div>
681
+ </div>
682
+ `,document.body.appendChild(this.el);const t=this.el.querySelector(".ac-palette");dt.forEach((e,s)=>{const n=document.createElement("div");n.className="ac-swatch",n.style.background="#"+e.body.toString(16).padStart(6,"0"),n.dataset.index=String(s),n.addEventListener("click",()=>{t.querySelectorAll(".ac-swatch").forEach(o=>o.classList.remove("selected")),n.classList.add("selected")}),t.appendChild(n)}),this.el.querySelector(".ac-backdrop").addEventListener("click",()=>this.close()),this.el.querySelector(".ac-close").addEventListener("click",()=>this.close()),this.el.querySelector(".ac-save").addEventListener("click",()=>this.save()),this.el.querySelector(".ac-reset").addEventListener("click",()=>this.reset())}setChangeHandler(t){this.onChange=t}getDefaultName(t){return t.agentName||eo(t.sessionId)}getDisplayName(t){const e=this.customizations[t.id];return(e==null?void 0:e.displayName)||this.getDefaultName(t)}getDisplayColorIndex(t){const e=this.customizations[t.id];return(e==null?void 0:e.colorIndex)??t.colorIndex}getCustomDisplay(t){return{displayName:this.getDisplayName(t),colorIndex:this.getDisplayColorIndex(t)}}open(t){this.currentAgent=t;const e=this.customizations[t.id],s=this.getDefaultName(t);this.el.querySelector(".ac-name-input").value=(e==null?void 0:e.displayName)??s;const n=(e==null?void 0:e.colorIndex)??-1;this.el.querySelectorAll(".ac-swatch").forEach(o=>{o.classList.toggle("selected",o.dataset.index===String(n))}),this.el.classList.add("open")}close(){this.el.classList.remove("open"),this.currentAgent=null}save(){var o;if(!this.currentAgent)return;const t=this.el.querySelector(".ac-name-input").value.trim(),e=this.el.querySelector(".ac-swatch.selected"),s=e?parseInt(e.dataset.index,10):void 0,n={};t&&(n.displayName=t),s!==void 0&&(n.colorIndex=s),this.customizations[this.currentAgent.id]=n,er(ma,this.customizations),(o=this.onChange)==null||o.call(this,this.currentAgent.id,n),this.close()}reset(){var t;this.currentAgent&&(delete this.customizations[this.currentAgent.id],er(ma,this.customizations),(t=this.onChange)==null||t.call(this,this.currentAgent.id,{}),this.close())}dispose(){this.el.remove()}}const Qe=(i,t,e,s,n)=>{i.roundRect(t,e,s,n,4).fill({color:3355460,alpha:.15})},Mu={id:"office",name:"Office",icon:"🏢",colors:{background:mu.background,gridLine:1711664,gridLineSub:1316650},decorators:{search:Ue.search??Qe,terminal:Ue.terminal??Qe,web:Ue.web??Qe,files:Ue.files??Qe,thinking:Ue.thinking??Qe,messaging:Ue.messaging??Qe,spawn:Ue.spawn??Qe,idle:Ue.idle??Qe,tasks:Ue.tasks??Qe}},db=4,$=i=>i*db,pt={hull:2763322,hullLight:3816010,panel:3355472,panelLight:4473960,panelDark:2236992,floor:1973808,floorAlt:2368568,floorLine:1447466,led:4521864,ledBlue:4491519,ledRed:16729156,ledOff:2236979,screen:13124,screenGlow:43724,holo:6702335,holoBright:11176191,metal:7829384,metalDark:5592422,airlockEdge:6710920};function yt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function Je(i,t,e,s,n){yt(i,t,e,s,n,pt.floor);for(let o=0;o<n;o+=$(4))yt(i,t,e+o,s,1,pt.floorLine);for(let o=0;o<s;o+=$(8))yt(i,t+o,e,1,n,pt.floorLine);for(let o=$(2);o<n;o+=$(8))for(let r=$(2);r<s;r+=$(8))yt(i,t+r,e+o,$(1),$(1),pt.floorAlt)}function ji(i,t,e,s){yt(i,t,e,s,$(10),pt.panel),yt(i,t,e,s,$(1),pt.panelLight),yt(i,t+$(2),e+$(2),s-$(4),$(4),pt.screen),yt(i,t+$(3),e+$(3),s-$(6),$(1),pt.screenGlow);for(let n=0;n<3;n++)yt(i,t+$(2)+n*$(3),e+$(7),$(2),$(2),pt.ledBlue)}function ga(i,t,e){yt(i,t-$(3),e,$(6),$(1),pt.metalDark);for(let s=0;s<5;s++){const n=$(8)-s*$(1);yt(i,t-n/2,e-$(2)-s*$(2),n,$(1),pt.holo)}yt(i,t-$(1),e-$(4),$(2),$(2),pt.holoBright)}const ub={search:(i,t,e,s,n)=>{Je(i,t,e,s,n),ji(i,t+$(4),e+$(7),$(20)),ji(i,t+$(28),e+$(7),$(20)),ga(i,t+s/2,e+n/2)},terminal:(i,t,e,s,n)=>{Je(i,t,e,s,n);for(let o=0;o<3;o++){yt(i,t+$(2)+o*$(10),e+$(7),$(7),$(14),pt.hull);for(let r=0;r<4;r++)yt(i,t+$(3)+o*$(10),e+$(8)+r*$(3),$(5),$(2),pt.panelDark),yt(i,t+$(4)+o*$(10),e+$(9)+r*$(3),$(1),$(1),r<3?pt.led:pt.ledOff)}},web:(i,t,e,s,n)=>{Je(i,t,e,s,n),yt(i,t+$(4),e+$(7),$(20),$(14),pt.panelDark),yt(i,t+$(5),e+$(8),$(18),$(12),pt.screen),yt(i,t+$(8),e+$(11),$(12),$(6),pt.holo),ga(i,t+$(40),e+$(30))},files:(i,t,e,s,n)=>{Je(i,t,e,s,n);for(let o=0;o<4;o++)yt(i,t+$(2)+o*$(7),e+$(7),$(5),$(10),pt.metalDark),yt(i,t+$(3)+o*$(7),e+$(8),$(3),$(3),pt.metal),yt(i,t+$(3)+o*$(7),e+$(12),$(3),$(3),pt.metal);ji(i,t+$(24),e+$(25),$(14))},thinking:(i,t,e,s,n)=>{Je(i,t,e,s,n),ga(i,t+s/2,e+n/2),yt(i,t+s/2-$(9),e+n/2+$(2),$(18),$(1),pt.metalDark),ji(i,t+$(4),e+$(7),$(24)),ji(i,t+$(32),e+$(7),$(20))},messaging:(i,t,e,s,n)=>{Je(i,t,e,s,n),yt(i,t+$(4),e+$(21),$(16),$(8),pt.hull),yt(i,t+$(5),e+$(22),$(14),$(6),pt.hullLight),ji(i,t+$(4),e+$(7),$(14))},spawn:(i,t,e,s,n)=>{Je(i,t,e,s,n);const o=t+s/2,r=e+n/2;yt(i,o-$(6),r-$(6),$(12),$(12),pt.panelDark),yt(i,o-$(4),r-$(4),$(8),$(8),pt.holo),yt(i,o-$(2),r-$(2),$(4),$(4),pt.holoBright),yt(i,o-$(8),r-$(1),$(16),$(2),pt.airlockEdge),yt(i,o-$(1),r-$(8),$(2),$(16),pt.airlockEdge)},idle:(i,t,e,s,n)=>{Je(i,t,e,s,n),yt(i,t+$(2),e+$(7),$(28),$(5),pt.hull),yt(i,t+$(3),e+$(8),$(26),$(3),pt.hullLight),yt(i,t+$(4),e+$(9),$(2),$(1),pt.screenGlow),yt(i,t+$(32),e+$(7),$(6),$(14),pt.metalDark);for(let o=0;o<3;o++)yt(i,t+$(33),e+$(8)+o*$(4),$(4),$(3),pt.screen)},tasks:(i,t,e,s,n)=>{Je(i,t,e,s,n),yt(i,t+$(2),e+$(7),$(30),$(18),pt.panel),yt(i,t+$(3),e+$(8),$(28),$(16),pt.screen);const o=[pt.ledRed,pt.led,pt.ledBlue];for(let r=0;r<3;r++){const l=$(8),h=t+$(4)+r*(l+$(1));yt(i,h,e+$(9),l,$(2),o[r]);for(let u=0;u<3-r;u++)yt(i,h+2,e+$(12)+u*$(3),l-4,$(2),pt.holo)}}},fb={id:"space",name:"Space Station",icon:"🚀",colors:{background:657944,gridLine:1381672,gridLineSub:1052704},decorators:ub},pb=4,B=i=>i*pb,Tt={stone:6974058,stoneDark:4868682,stoneLight:9079434,mortar:3815994,wood:8015920,woodDark:5913120,woodLight:10119744,torch:16746496,torchGlow:16755251,torchHandle:4861984,banner:8921651,bannerEdge:6689058,scroll:15259824,rugEdge:6693427};function Ct(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function ts(i,t,e,s,n){Ct(i,t,e,s,n,Tt.stone);for(let o=0;o<n;o+=B(5)){Ct(i,t,e+o,s,1,Tt.mortar);const r=o/B(5)%2*B(6);for(let l=r;l<s;l+=B(12))Ct(i,t+l,e+o,1,B(5),Tt.mortar)}for(let o=B(2);o<n;o+=B(10))for(let r=B(3);r<s;r+=B(12))Ct(i,t+r,e+o,B(1),B(1),Tt.stoneLight)}function ve(i,t,e){Ct(i,t,e+B(3),B(1),B(4),Tt.torchHandle),Ct(i,t-1,e+B(1),B(1)+2,B(2),Tt.torch),Ct(i,t,e,B(1),B(1),Tt.torchGlow)}function Bo(i,t,e,s,n){Ct(i,t,e,s,B(1),Tt.woodDark),Ct(i,t+1,e+B(1),s-2,n,Tt.banner),Ct(i,t+1,e+B(1),s-2,B(1),Tt.bannerEdge),Ct(i,t+s/2-B(1),e+n/2,B(2),B(2),Tt.torchGlow)}function Js(i,t,e,s,n){Ct(i,t,e,s,n,Tt.woodDark),Ct(i,t+1,e+1,s-2,n-2,Tt.wood),Ct(i,t+2,e+2,s-4,1,Tt.woodLight)}const mb={search:(i,t,e,s,n)=>{ts(i,t,e,s,n);for(let o=0;o<4;o++)Ct(i,t+B(2)+o*B(16),e+B(7),B(10),B(14),Tt.woodDark),Ct(i,t+B(3)+o*B(16),e+B(8),B(8),B(12),Tt.wood);ve(i,t+B(14),e+B(8)),ve(i,t+B(30),e+B(8)),Js(i,t+B(18),e+B(35),B(12),B(6)),Ct(i,t+B(20),e+B(36),B(6),B(3),Tt.scroll)},terminal:(i,t,e,s,n)=>{ts(i,t,e,s,n);for(let o=0;o<3;o++)Ct(i,t+B(2)+o*B(10),e+B(7),B(7),B(14),Tt.stoneDark),Ct(i,t+B(3)+o*B(10),e+B(9),B(5),B(1),Tt.torch);ve(i,t+B(34),e+B(9)),Bo(i,t+B(4),e+B(28),B(8),B(12))},web:(i,t,e,s,n)=>{ts(i,t,e,s,n),Ct(i,t+B(4),e+B(7),B(20),B(14),Tt.stoneDark),Ct(i,t+B(5),e+B(8),B(18),B(12),Tt.stoneLight),Ct(i,t+B(8),e+B(11),B(12),B(6),Tt.torchGlow),ve(i,t+B(28),e+B(10)),Js(i,t+B(4),e+B(27),B(14),B(5))},files:(i,t,e,s,n)=>{ts(i,t,e,s,n);for(let o=0;o<4;o++)Ct(i,t+B(2)+o*B(7),e+B(7),B(5),B(10),Tt.woodDark);Js(i,t+B(24),e+B(25),B(14),B(6)),Ct(i,t+B(26),e+B(26),B(6),B(3),Tt.scroll),ve(i,t+B(40),e+B(9))},thinking:(i,t,e,s,n)=>{ts(i,t,e,s,n),Ct(i,t+B(8),e+n/2-B(8),B(10),B(4),Tt.rugEdge),Js(i,t+s/2-B(9),e+n/2-B(4),B(18),B(8)),Bo(i,t+B(4),e+B(7),B(10),B(14)),Bo(i,t+B(34),e+B(7),B(10),B(14)),ve(i,t+B(18),e+B(8)),ve(i,t+B(28),e+B(8))},messaging:(i,t,e,s,n)=>{ts(i,t,e,s,n),Bo(i,t+B(8),e+B(7),B(14),B(10)),Js(i,t+B(6),e+B(33),B(12),B(5)),ve(i,t+B(4),e+B(10)),ve(i,t+B(26),e+B(10))},spawn:(i,t,e,s,n)=>{ts(i,t,e,s,n);const o=t+s/2,r=e+n/2;Ct(i,o-B(4),r-B(4),B(8),B(8),Tt.mortar),Ct(i,o-B(3),r-B(3),B(6),B(6),Tt.torchGlow),Ct(i,o-B(1),r-B(1),B(2),B(2),Tt.torch),ve(i,t+B(2),e+B(12)),ve(i,t+s-B(4),e+B(12))},idle:(i,t,e,s,n)=>{ts(i,t,e,s,n),Js(i,t+B(2),e+B(7),B(28),B(5)),Ct(i,t+B(4),e+B(8),B(4),B(3),Tt.woodLight),Js(i,t+B(14),e+B(30),B(10),B(10)),Js(i,t+B(40),e+B(30),B(10),B(10)),ve(i,t+B(50),e+B(8))},tasks:(i,t,e,s,n)=>{ts(i,t,e,s,n),Ct(i,t+B(2),e+B(7),B(30),B(18),Tt.woodDark),Ct(i,t+B(3),e+B(8),B(28),B(16),Tt.wood);for(let o=0;o<3;o++)for(let r=0;r<3-o;r++)Ct(i,t+B(4)+o*B(9)+2,e+B(12)+r*B(3),B(7),B(2),Tt.scroll);ve(i,t+B(36),e+B(9))}},gb={id:"castle",name:"Medieval Castle",icon:"🏰",colors:{background:1710096,gridLine:2762784,gridLineSub:2104856},decorators:mb},yb=4,H=i=>i*yb,ut={floor:921114,floorAlt:1184288,floorLine:1710638,neonPink:16720537,neonBlue:52479,neonGreen:65416,neonPurple:11158783,neonYellow:16768256,darkPanel:1710632,panel:2236984,panelEdge:3355472,screen:6690,rain:3359846};function vt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function es(i,t,e,s,n){vt(i,t,e,s,n,ut.floor);for(let o=0;o<n;o+=H(6))vt(i,t,e+o,s,1,ut.floorLine),o/H(6)%2===0&&vt(i,t,e+o+H(3),s,H(3),ut.floorAlt);vt(i,t,e,s,1,ut.neonPink),vt(i,t,e+n-1,s,1,ut.neonBlue)}function ti(i,t,e,s,n,o){vt(i,t,e,s,n,ut.darkPanel),vt(i,t+1,e+1,s-2,n-2,ut.screen),vt(i,t+2,e+2,s-4,H(1),o),vt(i,t,e,s,1,o),vt(i,t,e+n-1,s,1,o)}function Rn(i,t,e,s,n){vt(i,t,e,s,H(1),n),vt(i,t+H(1),e-1,s-H(2),1,n)}function ss(i,t,e,s,n){for(let o=0;o<12;o++){const r=t+(o*37+11)%(s-H(1)),l=e+(o*53+7)%(n-H(4));vt(i,r,l,1,H(2),ut.rain)}}const bb={search:(i,t,e,s,n)=>{es(i,t,e,s,n),ti(i,t+H(4),e+H(7),H(20),H(12),ut.neonPink),ti(i,t+H(28),e+H(7),H(20),H(12),ut.neonBlue),Rn(i,t+H(4),e+H(26),H(44),ut.neonPurple),ss(i,t,e,s,n)},terminal:(i,t,e,s,n)=>{es(i,t,e,s,n);for(let o=0;o<3;o++){vt(i,t+H(2)+o*H(10),e+H(7),H(7),H(14),ut.darkPanel),vt(i,t+H(3)+o*H(10),e+H(9),H(5),H(1),ut.neonGreen);for(let r=0;r<3;r++)vt(i,t+H(4)+o*H(10),e+H(11)+r*H(2),H(1),H(1),ut.neonGreen)}ss(i,t,e,s,n)},web:(i,t,e,s,n)=>{es(i,t,e,s,n),ti(i,t+H(4),e+H(7),H(24),H(16),ut.neonBlue),vt(i,t+H(8),e+H(12),H(16),H(8),ut.neonPurple),Rn(i,t+H(30),e+H(20),H(10),ut.neonPink),ss(i,t,e,s,n)},files:(i,t,e,s,n)=>{es(i,t,e,s,n);for(let o=0;o<4;o++)vt(i,t+H(2)+o*H(7),e+H(7),H(5),H(10),ut.darkPanel),vt(i,t+H(2)+o*H(7),e+H(7),H(5),1,ut.neonBlue);ti(i,t+H(24),e+H(25),H(14),H(8),ut.neonGreen),ss(i,t,e,s,n)},thinking:(i,t,e,s,n)=>{es(i,t,e,s,n),ti(i,t+H(4),e+H(7),H(24),H(12),ut.neonPurple),ti(i,t+H(32),e+H(7),H(20),H(12),ut.neonBlue),vt(i,t+s/2-H(8),e+n/2+H(2),H(16),H(1),ut.panelEdge),Rn(i,t+H(4),e+n-H(4),H(40),ut.neonPink),ss(i,t,e,s,n)},messaging:(i,t,e,s,n)=>{es(i,t,e,s,n),vt(i,t+H(4),e+H(21),H(16),H(8),ut.darkPanel),vt(i,t+H(5),e+H(22),H(14),H(1),ut.neonPink),ti(i,t+H(4),e+H(7),H(14),H(8),ut.neonYellow),Rn(i,t+H(22),e+H(18),H(8),ut.neonGreen),ss(i,t,e,s,n)},spawn:(i,t,e,s,n)=>{es(i,t,e,s,n);const o=t+s/2,r=e+n/2;for(let l=0;l<3;l++){const h=H(3)+l*H(3);vt(i,o-h,r-h,h*2,1,ut.neonPurple),vt(i,o-h,r+h,h*2,1,ut.neonPurple),vt(i,o-h,r-h,1,h*2,ut.neonBlue),vt(i,o+h,r-h,1,h*2,ut.neonBlue)}vt(i,o-H(1),r-H(1),H(2),H(2),ut.neonGreen),ss(i,t,e,s,n)},idle:(i,t,e,s,n)=>{es(i,t,e,s,n),vt(i,t+H(2),e+H(7),H(28),H(5),ut.darkPanel),vt(i,t+H(2),e+H(7),H(28),1,ut.neonPink),Rn(i,t+H(34),e+H(12),H(12),ut.neonBlue),vt(i,t+H(34),e+H(7),H(8),H(14),ut.darkPanel),vt(i,t+H(35),e+H(8),H(6),H(4),ut.screen),vt(i,t+H(36),e+H(9),H(4),H(1),ut.neonGreen),ss(i,t,e,s,n)},tasks:(i,t,e,s,n)=>{es(i,t,e,s,n),ti(i,t+H(2),e+H(7),H(30),H(18),ut.neonGreen);const o=[ut.neonPink,ut.neonYellow,ut.neonBlue];for(let r=0;r<3;r++){const l=H(8),h=t+H(4)+r*(l+H(1));vt(i,h,e+H(9),l,H(2),o[r]);for(let u=0;u<3-r;u++)vt(i,h+2,e+H(12)+u*H(3),l-4,H(2),ut.panel)}ss(i,t,e,s,n)}},_b={id:"cyberpunk",name:"Cyberpunk",icon:"🌃",colors:{background:657424,gridLine:1708072,gridLineSub:1051162},decorators:bb},Ph="theme",Dn=[Mu,fb,gb,_b];class xb{constructor(){b(this,"_current");b(this,"_onChange",null);const t=kl(Ph,"office");this._current=Dn.find(e=>e.id===t)??Mu}get current(){return this._current}setTheme(t){var s;const e=Dn.find(n=>n.id===t);!e||e.id===this._current.id||(this._current=e,er(Ph,e.id),(s=this._onChange)==null||s.call(this,e))}onChange(t){this._onChange=t}cycleNext(){const t=Dn.indexOf(this._current),e=Dn[(t+1)%Dn.length];this.setTheme(e.id)}}const Ih="zone-annotations";let ya=0;class vb{constructor(){b(this,"container");b(this,"annotations",new Map);b(this,"noteEls",new Map);b(this,"visible",!0);b(this,"rootX",0);b(this,"rootY",0);b(this,"scale",1);this.container=document.createElement("div"),this.container.id="zone-annotations",this.container.style.cssText="position:absolute;top:0;left:0;pointer-events:none;z-index:15;";const t=document.getElementById("canvas-container");t&&t.appendChild(this.container),this.load(),this.renderAll()}load(){try{const t=localStorage.getItem(Ih);if(t){const e=JSON.parse(t);for(const s of e){this.annotations.set(s.id,s);const n=parseInt(s.id.replace("ann-",""),10);!isNaN(n)&&n>=ya&&(ya=n+1)}}}catch{}}save(){localStorage.setItem(Ih,JSON.stringify(Array.from(this.annotations.values())))}renderAll(){for(const t of this.annotations.values())this.createNoteEl(t)}createNoteEl(t){const e=document.createElement("div");e.className="zone-annotation",e.style.pointerEvents="auto",e.innerHTML=`<span class="za-text">${this.escapeHtml(t.text)}</span><button class="za-delete" title="Delete">&times;</button>`,e.querySelector(".za-delete").addEventListener("click",s=>{s.stopPropagation(),this.removeAnnotation(t.id)}),this.makeDraggable(e,t),this.container.appendChild(e),this.noteEls.set(t.id,e),this.positionNote(t,e)}positionNote(t,e){const s=Vt.get(t.zoneId);if(!s)return;const n=s.x+t.relX*s.width,o=s.y+t.relY*s.height,r=n*this.scale+this.rootX,l=o*this.scale+this.rootY;e.style.transform=`translate(${r}px, ${l}px) scale(${Math.min(1,this.scale)})`}makeDraggable(t,e){let s=0,n=0,o=0,r=0;const l=Vt.get(e.zoneId);if(!l)return;const h=p=>{p.target.classList.contains("za-delete")||(p.stopPropagation(),s=p.clientX,n=p.clientY,o=e.relX,r=e.relY,t.setPointerCapture(p.pointerId),t.addEventListener("pointermove",u),t.addEventListener("pointerup",d,{once:!0}))},u=p=>{const m=(p.clientX-s)/this.scale,g=(p.clientY-n)/this.scale;e.relX=Math.max(.05,Math.min(.95,o+m/l.width)),e.relY=Math.max(.05,Math.min(.95,r+g/l.height)),this.positionNote(e,t)},d=()=>{t.removeEventListener("pointermove",u),this.save()};t.addEventListener("pointerdown",h)}addAnnotationAtWorld(t,e){for(const s of ze){const n=Vt.get(s.id);if(t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height){this.promptAndAdd(s.id,(t-n.x)/n.width,(e-n.y)/n.height);return}}}addAnnotationFromScreen(t,e){const s=(t-this.rootX)/this.scale,n=(e-this.rootY)/this.scale;this.addAnnotationAtWorld(s,n)}promptAndAdd(t,e,s){const n=Vt.get(t);if(!n)return;const o=n.x+e*n.width,r=n.y+s*n.height,l=o*this.scale+this.rootX,h=r*this.scale+this.rootY,u=document.createElement("textarea");u.className="zone-annotation za-input",u.style.cssText=`position:absolute;pointer-events:auto;transform:translate(${l}px,${h}px);z-index:20;`,u.placeholder="Type a note...",u.rows=2,this.container.appendChild(u),u.focus();const d=()=>{const p=u.value.trim();if(u.remove(),p){const m=`ann-${ya++}`,g={id:m,text:p,relX:e,relY:s,zoneId:t};this.annotations.set(m,g),this.createNoteEl(g),this.save()}};u.addEventListener("blur",d,{once:!0}),u.addEventListener("keydown",p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),u.blur()),p.key==="Escape"&&(u.value="",u.blur())})}removeAnnotation(t){this.annotations.delete(t);const e=this.noteEls.get(t);e&&(e.remove(),this.noteEls.delete(t)),this.save()}updateTransform(t,e,s){if(this.rootX=t,this.rootY=e,this.scale=s,!!this.visible)for(const n of this.annotations.values()){const o=this.noteEls.get(n.id);o&&this.positionNote(n,o)}}toggle(){this.visible=!this.visible,this.container.style.display=this.visible?"":"none"}get isVisible(){return this.visible}escapeHtml(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class wb{constructor(t,e){b(this,"container");b(this,"data",null);b(this,"visible",!1);b(this,"selectedTool",null);b(this,"onSnapshot");this.store=t,this.container=document.createElement("div"),this.container.id="toolchain-content",this.container.style.display="none",e.appendChild(this.container),this.onSnapshot=s=>{this.data=s,this.visible&&this.render()},this.store.on("toolchain:snapshot",this.onSnapshot)}destroy(){this.store.off("toolchain:snapshot",this.onSnapshot),this.container.remove()}show(){this.visible=!0,this.container.style.display="",this.store.requestToolChain(),this.render()}hide(){this.visible=!1,this.container.style.display="none"}render(){var w;if(!this.data||this.data.transitions.length===0){this.container.innerHTML='<div class="tc-empty">No tool transitions recorded yet</div>';return}const{transitions:t,toolCounts:e,toolSuccesses:s,toolFailures:n,toolAvgDuration:o}=this.data,r=Math.max(...t.map(S=>S.count)),l=Object.entries(e).sort((S,A)=>A[1]-S[1]),h=((w=l[0])==null?void 0:w[1])??1,u=l.reduce((S,[,A])=>S+A,0),d=this.selectedTool?t.filter(S=>S.from===this.selectedTool||S.to===this.selectedTool):t,p=Math.max(...d.map(S=>S.count),1),m=Object.keys(s??{}).length>0||Object.keys(n??{}).length>0;let g="";g+=`<div class="tc-section"><div class="tc-section-title">Tool Usage <span class="tc-hint">(${u} total calls)</span></div>`,m&&(g+='<div class="tc-col-header"><span class="tc-col-name">Tool</span><span class="tc-col-mid"></span><span class="tc-col-count">Calls</span><span class="tc-col-status">Status</span><span class="tc-col-avg">Avg</span></div>'),g+='<div class="tc-tools">';for(const[S,A]of l){const L=A/h*100,I=S===this.selectedTool,O=(s==null?void 0:s[S])??0,R=(n==null?void 0:n[S])??0,z=O+R,Q=z>0?R/z:0,X=o==null?void 0:o[S];if(g+=`<div class="tc-tool-row ${I?"tc-selected":""}" data-tool="${this.esc(S)}">`,g+=`<span class="tc-tool-name">${this.esc(this.shortName(S))}</span>`,g+='<div class="tc-tool-bar-wrap">',g+=`<div class="tc-tool-bar" style="width:${L}%"></div>`,R>0){const j=z>0?R/z*L:0;g+=`<div class="tc-tool-bar tc-fail-bar" style="width:${j}%"></div>`}g+="</div>",g+=`<span class="tc-tool-count">${A}</span>`,m&&z>0&&Q>0?g+=`<span class="tc-outcome tc-outcome-fail" title="${R} failed">${Math.round(Q*100)}%</span>`:m&&z>0?g+=`<span class="tc-outcome tc-outcome-ok" title="${O} succeeded">✓</span>`:m&&(g+='<span class="tc-outcome"></span>'),m&&(g+=`<span class="tc-duration" title="avg per call">${X!==void 0?this.fmtMs(X):"—"}</span>`),g+="</div>"}g+="</div></div>",g+='<div class="tc-section"><div class="tc-section-title">',g+=this.selectedTool?`Transitions for <strong>${this.esc(this.shortName(this.selectedTool))}</strong> <button class="tc-clear-filter">Clear</button>`:'Top Transitions <span class="tc-hint">(click a tool above to filter)</span>',g+="</div>",g+='<div class="tc-transitions">';const y=[...d].sort((S,A)=>A.count-S.count).slice(0,20);for(const S of y){const A=S.count/p*100,L=S.count/r,I=Math.round(100+L*155),O=Math.round(130+L*40),R=Math.round(180-L*100);g+='<div class="tc-transition-row">',g+=`<span class="tc-t-from">${this.esc(this.shortName(S.from))}</span>`,g+='<span class="tc-t-arrow">→</span>',g+=`<span class="tc-t-to">${this.esc(this.shortName(S.to))}</span>`,g+=`<div class="tc-t-bar-wrap"><div class="tc-t-bar" style="width:${A}%;background:rgb(${I},${O},${R})"></div></div>`,g+=`<span class="tc-t-count">${S.count}×</span>`,g+="</div>"}y.length===0&&(g+='<div class="tc-empty" style="padding:12px">No transitions for this tool</div>'),g+="</div></div>",this.container.innerHTML=g,this.container.querySelectorAll(".tc-tool-row").forEach(S=>{S.addEventListener("click",()=>{const A=S.dataset.tool;this.selectedTool=this.selectedTool===A?null:A,this.render()})});const x=this.container.querySelector(".tc-clear-filter");x&&x.addEventListener("click",S=>{S.stopPropagation(),this.selectedTool=null,this.render()})}fmtMs(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.round(t/6e4)}m`}shortName(t){if(t.startsWith("mcp__")){const e=t.split("__");return e[e.length-1].slice(0,18)}return t.length>18?t.slice(0,16)+"..":t}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}const Ro={pending:"#a78bfa",in_progress:"#38bdf8",completed:"#4ade80",deleted:"#f87171"},Do={pending:"○",in_progress:"◔",completed:"✓",deleted:"✕"},ei=210,$n=56,Sb=50,zn=12,$o=16;class kb{constructor(t,e){b(this,"container");b(this,"data",null);b(this,"visible",!1);b(this,"onSnapshot");this.store=t,this.container=document.createElement("div"),this.container.id="taskgraph-content",this.container.style.display="none",e.appendChild(this.container),this.onSnapshot=s=>{this.data=s,this.visible&&this.render()},this.store.on("taskgraph:snapshot",this.onSnapshot)}destroy(){this.store.off("taskgraph:snapshot",this.onSnapshot),this.container.remove()}show(){this.visible=!0,this.container.style.display="",this.store.requestTaskGraph(),this.render()}hide(){this.visible=!1,this.container.style.display="none"}render(){if(!this.data||this.data.tasks.length===0){this.container.innerHTML='<div class="tg-empty">No tasks created yet</div>';return}const t=this.data.tasks.filter(d=>d.status!=="deleted");if(t.length===0){this.container.innerHTML='<div class="tg-empty">No tasks created yet</div>';return}const e=d=>d._rootKey??d.id,s=new Map(t.map(d=>[e(d),d])),n=new Set;for(const d of t){const p=d.blockedBy.some(g=>s.has(g)),m=d.blocks.some(g=>s.has(g));if(p||m){n.add(e(d));for(const g of d.blockedBy)s.has(g)&&n.add(g);for(const g of d.blocks)s.has(g)&&n.add(g)}}const o=t.filter(d=>!n.has(e(d))),r=t.filter(d=>n.has(e(d))),l={in_progress:0,pending:1,completed:2,deleted:3};o.sort((d,p)=>{const m=(l[d.status]??9)-(l[p.status]??9);return m!==0?m:parseInt(d.id)-parseInt(p.id)});const h={pending:0,in_progress:0,completed:0};for(const d of t)d.status in h&&h[d.status]++;let u="";if(u+='<div class="tg-summary">',h.in_progress>0&&(u+=`<span class="tg-badge tg-badge-active">${h.in_progress} active</span>`),h.pending>0&&(u+=`<span class="tg-badge tg-badge-pending">${h.pending} pending</span>`),h.completed>0&&(u+=`<span class="tg-badge tg-badge-done">${h.completed} done</span>`),u+=`<span class="tg-total">${t.length} total</span>`,u+="</div>",o.length>0){u+='<div class="tg-standalone">';for(const d of o){const p=Ro[d.status]??Ro.pending,m=Do[d.status]??Do.pending;u+=`<div class="tg-row" style="--sc:${p}">`,u+=`<span class="tg-row-icon" style="color:${p}">${m}</span>`,u+=`<span class="tg-row-subj">${si(d.subject)}</span>`,u+=this.renderRowTags(d),u+=`<span class="tg-row-id">#${si(d.id)}</span>`,u+="</div>"}u+="</div>"}if(r.length>0){const d=this.findClusters(r,s,e);for(const p of d)u+=this.renderCluster(p,s,e)}this.container.innerHTML=u}renderCluster(t,e,s){const n=new Map(t.map(d=>[s(d),d])),o=this.layoutCluster(t,n,s),r=new Map(o.map(d=>[s(d.task),d])),l=Math.max(...o.map(d=>d.x+ei))+$o,h=Math.max(...o.map(d=>d.y+$n))+$o;let u='<div class="tg-cluster">';u+=`<svg class="tg-svg" width="${l}" height="${h}" viewBox="0 0 ${l} ${h}">`,u+='<defs><marker id="tg-arr" viewBox="0 0 10 8" refX="10" refY="4" markerWidth="7" markerHeight="5" orient="auto-start-reverse"><path d="M0,0 L10,4 L0,8 Z" fill="#666"/></marker></defs>';for(const d of o)for(const p of d.task.blockedBy){const m=r.get(p);if(!m)continue;const g=m.x+ei/2,y=m.y+$n,x=d.x+ei/2,w=d.y,S=Math.max((w-y)*.4,12);u+=`<path class="tg-edge" d="M${g},${y} C${g},${y+S} ${x},${w-S} ${x},${w}" marker-end="url(#tg-arr)"/>`}for(const d of o){const p=d.task,m=Ro[p.status]??Ro.pending,g=Do[p.status]??Do.pending;u+='<g class="tg-node">',u+=`<rect x="${d.x}" y="${d.y}" width="${ei}" height="${$n}" rx="5" class="tg-node-bg"/>`,u+=`<rect x="${d.x}" y="${d.y}" width="3" height="${$n}" rx="1" fill="${m}"/>`,u+=`<text x="${d.x+12}" y="${d.y+18}" class="tg-node-icon" fill="${m}">${g}</text>`,u+=`<text x="${d.x+ei-7}" y="${d.y+16}" class="tg-node-id" text-anchor="end">#${si(p.id)}</text>`,u+=`<text x="${d.x+25}" y="${d.y+18}" class="tg-node-subj">${si(Bh(p.subject,24))}</text>`;const y=this.nodeInfoText(p);y&&(u+=`<text x="${d.x+12}" y="${d.y+38}" class="tg-node-info">${si(Bh(y,28))}</text>`),u+="</g>"}return u+="</svg></div>",u}findClusters(t,e,s){const n=new Set(t.map(l=>s(l))),o=new Set,r=[];for(const l of t){const h=s(l);if(o.has(h))continue;const u=[],d=[h];for(o.add(h);d.length>0;){const p=d.shift(),m=e.get(p);if(m){u.push(m);for(const g of[...m.blockedBy,...m.blocks])n.has(g)&&!o.has(g)&&(o.add(g),d.push(g))}}r.push(u)}return r}layoutCluster(t,e,s){const n=new Map,o=(m,g)=>{if(n.has(m))return n.get(m);if(g.has(m))return 0;g.add(m);const y=e.get(m);if(!y||y.blockedBy.filter(S=>e.has(S)).length===0)return n.set(m,0),0;let x=0;for(const S of y.blockedBy)e.has(S)&&(x=Math.max(x,o(S,g)));const w=x+1;return n.set(m,w),w};for(const m of t)o(s(m),new Set);const r=Math.max(0,...n.values()),l=Array.from({length:r+1},()=>[]);for(const m of t)l[n.get(s(m))??0].push(m);const h={in_progress:0,pending:1,completed:2,deleted:3};for(const m of l)m.sort((g,y)=>{const x=(h[g.status]??9)-(h[y.status]??9);return x!==0?x:parseInt(g.id)-parseInt(y.id)});for(let m=1;m<l.length;m++){const g=new Map;l[m-1].forEach((y,x)=>g.set(s(y),x)),l[m].sort((y,x)=>Lh(y,g)-Lh(x,g))}const d=Math.max(...l.map(m=>m.length))*(ei+zn)-zn,p=[];for(let m=0;m<l.length;m++){const g=l[m],y=g.length*(ei+zn)-zn,x=$o+(d-y)/2,w=$o+m*($n+Sb);for(let S=0;S<g.length;S++)p.push({task:g[S],x:x+S*(ei+zn),y:w})}return p}nodeInfoText(t){const e=[];return t.projectName&&e.push(t.projectName),t.agentName&&t.agentName!==t.projectName&&e.push(t.agentName),t.owner&&t.owner!==t.agentName&&e.push(t.owner),e.join(" · ")}renderRowTags(t){let e="";return t.projectName&&(e+=`<span class="tg-row-tag">${si(t.projectName)}</span>`),t.agentName&&t.agentName!==t.projectName&&(e+=`<span class="tg-row-tag">${si(t.agentName)}</span>`),t.owner&&t.owner!==t.agentName&&(e+=`<span class="tg-row-tag">${si(t.owner)}</span>`),e}}function Lh(i,t,e){const s=[];for(const n of i.blockedBy){const o=t.get(n);o!==void 0&&s.push(o)}return s.length===0?999:s.reduce((n,o)=>n+o,0)/s.length}function si(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Bh(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class Tb{constructor(t){b(this,"container");b(this,"store");b(this,"permissions",[]);b(this,"onPermRequestBound");b(this,"onPermResolvedBound");this.store=t,this.container=document.createElement("div"),this.container.id="permission-panel",this.container.setAttribute("role","alertdialog"),this.container.setAttribute("aria-label","Permission requests"),document.body.appendChild(this.container),this.onPermRequestBound=e=>{this.permissions.push(e),this.render()},this.onPermResolvedBound=({permissionId:e})=>{this.permissions=this.permissions.filter(s=>s.permissionId!==e),this.render()},t.on("permission:request",this.onPermRequestBound),t.on("permission:resolved",this.onPermResolvedBound)}render(){var e;if(this.permissions.length===0){this.container.classList.remove("visible"),this.container.innerHTML="";return}this.container.classList.add("visible");let t=`<div class="perm-header">
683
+ <span class="perm-badge">${this.permissions.length}</span>
684
+ Permission Request${this.permissions.length>1?"s":""}
685
+ </div>`;for(const s of this.permissions){const n=s.toolName==="AskUserQuestion",o=s.toolName==="ExitPlanMode",r=Math.round((Date.now()-s.timestamp)/1e3),l=r<60?`${r}s ago`:`${Math.round(r/60)}m ago`;t+=`<div class="perm-card" data-id="${this.esc(s.permissionId)}">`,t+='<div class="perm-tool">',t+=`<span class="perm-tool-name">${this.esc(s.toolName)}</span>`,t+=`<span class="perm-time">${l}</span>`,t+="</div>",n?t+=this.renderAskQuestion(s):o?t+=this.renderPlanReview(s):t+=this.renderToolInput(s),o&&(t+='<textarea class="perm-answer perm-feedback" placeholder="Optional feedback..." rows="2"></textarea>'),t+='<div class="perm-actions">',!n&&!o&&((e=s.permissionSuggestions)!=null&&e.length)&&(t+=`<button class="perm-btn perm-always" data-action="always" data-id="${this.esc(s.permissionId)}">Always Allow</button>`),t+=`<button class="perm-btn perm-approve" data-action="approve" data-id="${this.esc(s.permissionId)}">Approve</button>`,t+=`<button class="perm-btn perm-deny" data-action="deny" data-id="${this.esc(s.permissionId)}">Deny</button>`,t+="</div>",t+="</div>"}this.container.innerHTML=t,this.wireActions()}renderToolInput(t){const e=t.toolInput;if(!e)return"";const s=e,n=s.command??s.file_path??s.pattern??s.query??s.url??s.prompt;if(n){const l=n.length>200?n.slice(0,197)+"...":n;return`<div class="perm-preview"><code>${this.esc(l)}</code></div>`}const o=JSON.stringify(e,null,2),r=o.length>300?o.slice(0,297)+"...":o;return`<div class="perm-preview"><code>${this.esc(r)}</code></div>`}renderAskQuestion(t){const e=t.toolInput;if(!e)return"";const s=e.questions;if(!(s!=null&&s.length))return"";let n='<div class="perm-question">';for(const o of s)n+=`<p class="perm-q-text">${this.esc(o)}</p>`;return n+='<textarea class="perm-answer" placeholder="Type your answer..." rows="2"></textarea>',n+="</div>",n}renderPlanReview(t){const e=t.toolInput;if(!e)return'<div class="perm-preview">Plan review requested</div>';const s=e.plan??e.content??"";if(s){const n=s.length>500?s.slice(0,497)+"...":s;return`<div class="perm-preview perm-plan"><pre>${this.esc(n)}</pre></div>`}return'<div class="perm-preview">Plan review requested</div>'}wireActions(){this.container.querySelectorAll(".perm-btn").forEach(t=>{t.addEventListener("click",e=>{const s=e.currentTarget,n=s.dataset.action,o=s.dataset.id,r=s.closest(".perm-card");if(n==="approve"){const l=r==null?void 0:r.querySelector(".perm-answer:not(.perm-feedback)"),h=r==null?void 0:r.querySelector(".perm-feedback");l!=null&&l.value?this.store.approvePermission(o,{answer:l.value}):h!=null&&h.value?this.store.approvePermission(o,{userFeedback:h.value}):this.store.approvePermission(o)}else if(n==="deny")this.store.denyPermission(o);else if(n==="always"){const l=this.permissions.find(u=>u.permissionId===o),h=(l==null?void 0:l.permissionSuggestions)??[];this.store.approvePermissionAlways(o,h)}})})}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}dispose(){this.store.off("permission:request",this.onPermRequestBound),this.store.off("permission:resolved",this.onPermResolvedBound),this.container.remove()}}const Cb=50;let Ab=0;class Mb{constructor(t){b(this,"container");b(this,"store");b(this,"_customizationLookup",null);b(this,"notifications",[]);b(this,"visible",!1);b(this,"badgeEl");b(this,"onPermRequestBound");b(this,"onAnomalyBound");b(this,"onTaskBound");b(this,"onSpawnBound");b(this,"onShutdownBound");this.store=t,this.badgeEl=document.createElement("span"),this.badgeEl.id="notif-badge",this.badgeEl.className="notif-badge",this.badgeEl.style.display="none",this.container=document.createElement("div"),this.container.id="notification-panel",this.container.style.display="none",document.body.appendChild(this.container),this.onPermRequestBound=e=>this.addPermission(e),this.onAnomalyBound=e=>this.addAnomaly(e),this.onTaskBound=({taskSubject:e})=>this.addTask(e),this.onSpawnBound=e=>this.push({kind:"lifecycle",priority:"low",agentId:e.id,message:" spawned"}),this.onShutdownBound=e=>{var o,r;const s=t.getAgent(e),n=s?((r=(o=this._customizationLookup)==null?void 0:o.call(this,s))==null?void 0:r.displayName)||s.agentName||s.projectName||s.sessionId.slice(0,10):e.slice(0,10);this.push({kind:"lifecycle",priority:"low",message:`${n} shut down`})},t.on("permission:request",this.onPermRequestBound),t.on("anomaly:alert",this.onAnomalyBound),t.on("task:completed",this.onTaskBound),t.on("agent:spawn",this.onSpawnBound),t.on("agent:shutdown",this.onShutdownBound)}setCustomizationLookup(t){this._customizationLookup=t}getBadgeElement(){return this.badgeEl}toggle(){this.visible=!this.visible,this.container.style.display=this.visible?"":"none",this.visible&&this.render()}addPermission(t){this.push({kind:"permission",priority:"urgent",message:`Permission: ${t.toolName}`,detail:this.summarizeInput(t.toolInput)})}addAnomaly(t){this.push({kind:"anomaly",priority:t.severity==="critical"?"urgent":"high",agentId:t.agentId,message:`: ${t.message}`})}addTask(t){this.push({kind:"task",priority:"normal",message:`Task completed: ${t}`})}resolveName(t){var s,n;const e=this.store.getAgent(t);return e?((n=(s=this._customizationLookup)==null?void 0:s.call(this,e))==null?void 0:n.displayName)||e.agentName||e.projectName||e.sessionId.slice(0,10):t.slice(0,10)}push(t){const e={id:`n${++Ab}`,...t,timestamp:Date.now()};this.notifications.unshift(e),this.notifications.length>Cb&&this.notifications.pop(),this.updateBadge(),this.visible&&this.render()}updateBadge(){const t=this.notifications.filter(e=>e.priority==="urgent"||e.priority==="high").length;t>0?(this.badgeEl.textContent=String(t),this.badgeEl.style.display=""):this.badgeEl.style.display="none"}render(){if(this.notifications.length===0){this.container.innerHTML='<div class="notif-empty">No notifications</div>';return}let t='<div class="notif-header">Notifications <button class="notif-clear">Clear</button></div>';t+='<div class="notif-list">';for(const s of this.notifications){const n=this.formatAge(s.timestamp),o=s.agentId?this.resolveName(s.agentId)+s.message:s.message;t+=`<div class="notif-item notif-${this.esc(s.priority)} notif-${this.esc(s.kind)}">`,t+=`<span class="notif-icon">${this.icon(s.kind)}</span>`,t+=`<span class="notif-msg">${this.esc(o)}</span>`,s.detail&&(t+=`<span class="notif-detail">${this.esc(s.detail)}</span>`),t+=`<span class="notif-age">${n}</span>`,t+="</div>"}t+="</div>",this.container.innerHTML=t;const e=this.container.querySelector(".notif-clear");e==null||e.addEventListener("click",()=>{this.notifications=[],this.updateBadge(),this.render()},{once:!0})}icon(t){switch(t){case"permission":return"🔒";case"failure":return"❌";case"anomaly":return"⚠️";case"task":return"✅";case"lifecycle":return"🟢"}}formatAge(t){const e=Math.round((Date.now()-t)/1e3);return e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}summarizeInput(t){if(!t)return;const e=t,s=e.command??e.file_path??e.pattern??e.query;if(s)return s.length>80?s.slice(0,77)+"...":s}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}dispose(){this.store.off("permission:request",this.onPermRequestBound),this.store.off("anomaly:alert",this.onAnomalyBound),this.store.off("task:completed",this.onTaskBound),this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:shutdown",this.onShutdownBound),this.container.remove(),this.badgeEl.remove()}}const Rh=200,Eb=["all","spawn","tool","idle","shutdown","permission","anomaly","task"],Pb=200;class Ib{constructor(t,e){b(this,"container");b(this,"toolbarEl");b(this,"searchInput");b(this,"filtersEl");b(this,"agentSelect");b(this,"clearBtn");b(this,"listEl");b(this,"store");b(this,"entries",[]);b(this,"visible",!1);b(this,"autoScroll",!0);b(this,"_customizationLookup",null);b(this,"searchQuery","");b(this,"activeKind","all");b(this,"activeAgent","");b(this,"debounceTimer",null);b(this,"boundListeners",[]);this.store=t,this.container=document.createElement("div"),this.container.id="activity-feed",this.container.style.display="none",e.appendChild(this.container),this.toolbarEl=document.createElement("div"),this.toolbarEl.className="feed-toolbar",this.container.appendChild(this.toolbarEl),this.searchInput=document.createElement("input"),this.searchInput.type="text",this.searchInput.className="feed-search",this.searchInput.placeholder="Search feed…",this.searchInput.addEventListener("input",()=>this.onSearchInput()),this.toolbarEl.appendChild(this.searchInput),this.filtersEl=document.createElement("div"),this.filtersEl.className="feed-filters";for(const n of Eb){const o=document.createElement("button");o.className=`feed-chip${n==="all"?" active":""}`,o.textContent=n.charAt(0).toUpperCase()+n.slice(1),o.dataset.kind=n,o.addEventListener("click",()=>this.onChipClick(n)),this.filtersEl.appendChild(o)}this.toolbarEl.appendChild(this.filtersEl),this.agentSelect=document.createElement("select"),this.agentSelect.className="feed-agent-select",this.agentSelect.innerHTML='<option value="">All Agents</option>',this.agentSelect.addEventListener("change",()=>{this.activeAgent=this.agentSelect.value,this.applyFilters()}),this.toolbarEl.appendChild(this.agentSelect),this.clearBtn=document.createElement("button"),this.clearBtn.className="feed-chip",this.clearBtn.textContent="Clear",this.clearBtn.addEventListener("click",()=>this.clearFilters()),this.toolbarEl.appendChild(this.clearBtn),this.listEl=document.createElement("div"),this.listEl.className="feed-list",this.container.appendChild(this.listEl),this.listEl.addEventListener("scroll",()=>{const{scrollTop:n,scrollHeight:o,clientHeight:r}=this.listEl;this.autoScroll=o-n-r<40});const s=(n,o)=>{t.on(n,o),this.boundListeners.push({event:n,fn:o})};s("state:reset",n=>{for(const[,o]of n)this.add("spawn",this.agentHtml(o,"connected"),this.name(o));this.refreshAgentDropdown()}),s("agent:spawn",n=>this.add("spawn",this.agentHtml(n,"spawned"),this.name(n))),s("agent:update",n=>{n.currentTool&&this.add("tool",`<span class="feed-name">${this.esc(this.name(n))}</span> using <strong>${this.esc(n.currentTool)}</strong>${n.currentActivity?` — <span class="feed-dim">${this.esc(n.currentActivity.slice(0,60))}</span>`:""}`,this.name(n))}),s("agent:idle",n=>this.add("idle",this.agentHtml(n,"idle"),this.name(n))),s("agent:shutdown",n=>{const o=this.store.getAgent(n),r=o?this.name(o):n.slice(0,10);this.add("shutdown",`<span class="feed-name">${this.esc(r)}</span> shut down`,r)}),s("permission:request",n=>this.add("permission",`🔒 Permission request: <strong>${this.esc(n.toolName)}</strong>`,"")),s("permission:resolved",({permissionId:n,decision:o})=>this.add("permission",`🔓 Permission ${o}: <span class="feed-dim">${this.esc(n.slice(0,8))}</span>`,"")),s("anomaly:alert",n=>this.add("anomaly",`⚠️ ${this.esc(n.agentName)}: ${this.esc(n.message)}`,n.agentName)),s("task:completed",({taskSubject:n})=>this.add("task",`✅ Task completed: ${this.esc(n)}`,"")),s("hooks:status",()=>this.add("hooks","Hook event received",""))}setCustomizationLookup(t){this._customizationLookup=t}show(){this.visible=!0,this.container.style.display="flex",this.container.style.flexDirection="column",this.refreshAgentDropdown(),this.applyFilters()}hide(){this.visible=!1,this.container.style.display="none"}add(t,e,s){const n=e.replace(/<[^>]*>/g,"");if(this.entries.push({timestamp:Date.now(),html:e,kind:t,agentName:s,rawText:n}),this.entries.length>Rh&&this.entries.shift(),this.visible){const o=this.entries[this.entries.length-1];this.matchesFilters(o)&&this.appendEntry(o)}}matchesFilters(t){return!(this.activeKind!=="all"&&t.kind!==this.activeKind||this.activeAgent&&t.agentName!==this.activeAgent||this.searchQuery&&!t.rawText.toLowerCase().includes(this.searchQuery))}appendEntry(t){const e=document.createElement("div");e.className=`feed-entry feed-${t.kind}`;let s=t.html;for(this.searchQuery&&(s=this.highlightHtml(s,this.searchQuery)),e.innerHTML=`<span class="feed-time">${this.formatTime(t.timestamp)}</span> ${s}`,this.listEl.appendChild(e);this.listEl.children.length>Rh;)this.listEl.removeChild(this.listEl.firstChild);this.autoScroll&&(this.listEl.scrollTop=this.listEl.scrollHeight)}highlightHtml(t,e){const s=t.split(/(<[^>]*>)/),n=e.toLowerCase();for(let o=0;o<s.length;o++)o%2===0&&s[o]&&(s[o]=this.highlightText(s[o],n));return s.join("")}highlightText(t,e){const s=t.toLowerCase();let n="",o=0,r=s.indexOf(e,o);for(;r!==-1;)n+=t.slice(o,r),n+=`<mark>${t.slice(r,r+e.length)}</mark>`,o=r+e.length,r=s.indexOf(e,o);return n+=t.slice(o),n}applyFilters(){this.listEl.innerHTML="";for(const t of this.entries)if(this.matchesFilters(t)){const e=document.createElement("div");e.className=`feed-entry feed-${t.kind}`;let s=t.html;this.searchQuery&&(s=this.highlightHtml(s,this.searchQuery)),e.innerHTML=`<span class="feed-time">${this.formatTime(t.timestamp)}</span> ${s}`,this.listEl.appendChild(e)}this.autoScroll&&(this.listEl.scrollTop=this.listEl.scrollHeight)}onSearchInput(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.searchQuery=this.searchInput.value.trim().toLowerCase(),this.applyFilters()},Pb)}onChipClick(t){this.activeKind=t,this.filtersEl.querySelectorAll(".feed-chip").forEach(s=>{const n=s;n.classList.toggle("active",n.dataset.kind===t)}),this.applyFilters()}clearFilters(){this.searchQuery="",this.searchInput.value="",this.activeKind="all",this.activeAgent="",this.agentSelect.value="",this.filtersEl.querySelectorAll(".feed-chip").forEach(e=>{const s=e;s.classList.toggle("active",s.dataset.kind==="all")}),this.applyFilters()}refreshAgentDropdown(){const t=this.store.getAgents(),e=this.agentSelect.value;this.agentSelect.innerHTML='<option value="">All Agents</option>';const s=new Set;for(const[,n]of t){const o=n.agentName||n.projectName||n.sessionId.slice(0,10);if(!s.has(o)){s.add(o);const r=document.createElement("option");r.value=o,r.textContent=o,this.agentSelect.appendChild(r)}}for(const n of this.entries)if(n.agentName&&!s.has(n.agentName)){s.add(n.agentName);const o=document.createElement("option");o.value=n.agentName,o.textContent=n.agentName,this.agentSelect.appendChild(o)}e&&(this.agentSelect.value=e,this.agentSelect.value||(this.activeAgent=""))}agentHtml(t,e){return`<span class="feed-name">${this.esc(this.name(t))}</span> ${e}`}name(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||t.projectName||t.sessionId.slice(0,10)}formatTime(t){const e=new Date(t);return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}destroy(){this.debounceTimer&&clearTimeout(this.debounceTimer);for(const{event:t,fn:e}of this.boundListeners)this.store.off(t,e);this.boundListeners=[],this.container.remove()}}const Dh={files:"#34d399",terminal:"#fb923c",search:"#60a5fa",web:"#f59e0b",thinking:"#a78bfa",messaging:"#38bdf8",tasks:"#f472b6",idle:"#6b7280",spawn:"#6b7280"},$h=500,is=28,Fn=2,Ce=32,ne=120,Lb=300*1e3,Bb=1e4,Rb=30*6e4;class Db{constructor(t,e){b(this,"container");b(this,"canvas");b(this,"ctx");b(this,"tooltip");b(this,"visible",!1);b(this,"spans",[]);b(this,"agentLanes",[]);b(this,"agentNames",new Map);b(this,"agentCurrentTool",new Map);b(this,"_customizationLookup",null);b(this,"viewEndTime",Date.now());b(this,"viewWindowMs",Lb);b(this,"autoScroll",!0);b(this,"animFrame",null);b(this,"resizeObserver",null);b(this,"onSpawn");b(this,"onUpdate");b(this,"onIdle");b(this,"onShutdown");b(this,"onReset");b(this,"handleMouseMove",t=>{const e=this.hitTest(t.clientX,t.clientY);if(e){const s=(e.endTime??Date.now())-e.startTime;let n=`${this.shortToolName(e.toolName)}
686
+ `;n+=`Duration: ${this.fmtDuration(s)}
687
+ `,n+=`Zone: ${e.zone}`,e.outcome&&(n+=`
688
+ Outcome: ${e.outcome}`),this.tooltip.textContent=n,this.tooltip.style.display="";const o=this.container.getBoundingClientRect(),r=t.clientX-o.left+12,l=t.clientY-o.top-10;this.tooltip.style.left=`${Math.min(r,this.container.clientWidth-200)}px`,this.tooltip.style.top=`${l}px`,this.canvas.style.cursor="pointer"}else this.tooltip.style.display="none",this.canvas.style.cursor="crosshair"});b(this,"handleMouseLeave",()=>{this.tooltip.style.display="none",this.canvas.style.cursor="crosshair"});b(this,"handleClick",t=>{const e=this.hitTest(t.clientX,t.clientY);if(e){const s=(e.endTime??Date.now())-e.startTime;let n=`Tool: ${e.toolName}
689
+ `;n+=`Agent: ${e.agentName}
690
+ `,n+=`Zone: ${e.zone}
691
+ `,n+=`Duration: ${this.fmtDuration(s)}
692
+ `,n+=`Start: ${new Date(e.startTime).toLocaleTimeString()}
693
+ `,e.endTime?n+=`End: ${new Date(e.endTime).toLocaleTimeString()}
694
+ `:n+=`Status: In progress
695
+ `,e.outcome&&(n+=`Outcome: ${e.outcome}
696
+ `),e.toolInput&&(n+=`
697
+ Input:
698
+ ${e.toolInput}`),this.tooltip.textContent=n,this.tooltip.style.display="";const o=this.container.getBoundingClientRect(),r=t.clientX-o.left+12,l=t.clientY-o.top-10;this.tooltip.style.left=`${Math.min(r,this.container.clientWidth-200)}px`,this.tooltip.style.top=`${Math.max(l,4)}px`}});b(this,"handleWheel",t=>{t.preventDefault();const e=this.canvas.getBoundingClientRect(),s=t.clientX-e.left;if(t.ctrlKey||t.metaKey||Math.abs(t.deltaY)>Math.abs(t.deltaX)){const n=t.deltaY>0?1.15:.87,o=Math.max(Bb,Math.min(Rb,this.viewWindowMs*n)),r=this.container.clientWidth-ne,l=Math.max(0,(s-ne)/r),u=this.viewEndTime-this.viewWindowMs+l*this.viewWindowMs;this.viewWindowMs=o,this.viewEndTime=u+(1-l)*o,this.autoScroll=!1}else{const n=t.deltaX/(this.container.clientWidth-ne)*this.viewWindowMs;this.viewEndTime+=n,this.autoScroll=!1}Math.abs(this.viewEndTime-Date.now())<2e3&&(this.autoScroll=!0)});this.store=t,this.container=document.createElement("div"),this.container.id="waterfall-content",this.container.style.cssText="display:none;position:relative;width:100%;height:100%;overflow:hidden;",e.appendChild(this.container),this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width:100%;display:block;cursor:crosshair;",this.container.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this.tooltip=document.createElement("div"),this.tooltip.style.cssText="display:none;position:absolute;pointer-events:none;background:#1e1e2e;border:1px solid #444;border-radius:4px;padding:6px 10px;color:#e0e0e0;font-size:11px;line-height:1.4;z-index:100;max-width:320px;white-space:pre-wrap;word-break:break-all;",this.container.appendChild(this.tooltip),this.onSpawn=s=>this.handleSpawn(s),this.onUpdate=s=>this.handleUpdate(s),this.onIdle=s=>this.handleIdle(s),this.onShutdown=s=>this.handleShutdown(s),this.onReset=s=>this.handleReset(s),this.store.on("agent:spawn",this.onSpawn),this.store.on("agent:update",this.onUpdate),this.store.on("agent:idle",this.onIdle),this.store.on("agent:shutdown",this.onShutdown),this.store.on("state:reset",this.onReset),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("click",this.handleClick),this.canvas.addEventListener("wheel",this.handleWheel,{passive:!1}),this.resizeObserver=new ResizeObserver(()=>this.updateCanvasSize()),this.resizeObserver.observe(this.container);for(const[,s]of this.store.getAgents())this.ensureLane(s)}setCustomizationLookup(t){this._customizationLookup=t;for(const[e]of this.agentNames){const s=this.store.getAgent(e);s&&this.agentNames.set(e,this.resolveDisplayName(s))}}resolveDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName??t.projectName??t.id.slice(0,8)}show(){this.visible=!0,this.container.style.display="",this.autoScroll=!0,this.updateCanvasSize(),this.startRenderLoop()}hide(){this.visible=!1,this.container.style.display="none",this.stopRenderLoop(),this.tooltip.style.display="none"}destroy(){var t;this.store.off("agent:spawn",this.onSpawn),this.store.off("agent:update",this.onUpdate),this.store.off("agent:idle",this.onIdle),this.store.off("agent:shutdown",this.onShutdown),this.store.off("state:reset",this.onReset),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("click",this.handleClick),this.canvas.removeEventListener("wheel",this.handleWheel),(t=this.resizeObserver)==null||t.disconnect(),this.stopRenderLoop(),this.container.remove()}ensureLane(t){this.agentLanes.includes(t.id)||this.agentLanes.push(t.id),this.agentNames.set(t.id,this.resolveDisplayName(t))}handleSpawn(t){this.ensureLane(t),this.agentCurrentTool.set(t.id,null),this.updateCanvasSize()}handleUpdate(t){this.ensureLane(t);const e=this.agentCurrentTool.get(t.id)??null,s=t.currentTool;if(s!==e){const n=Date.now();this.closeOpenSpan(t.id,n,t.lastToolOutcome),s&&this.openSpan(t,s,n),this.agentCurrentTool.set(t.id,s)}}handleIdle(t){const e=Date.now();this.closeOpenSpan(t.id,e,t.lastToolOutcome),this.agentCurrentTool.set(t.id,null)}handleShutdown(t){const e=Date.now();this.closeOpenSpan(t,e,null),this.agentCurrentTool.delete(t)}handleReset(t){this.spans=[],this.agentLanes=[],this.agentNames.clear(),this.agentCurrentTool.clear();for(const[,e]of t)this.ensureLane(e);this.updateCanvasSize()}openSpan(t,e,s){const n={agentId:t.id,agentName:this.agentNames.get(t.id)??this.resolveDisplayName(t),toolName:e,zone:t.currentZone,startTime:s,endTime:null,outcome:null,toolInput:t.currentActivity?t.currentActivity.slice(0,200):null};this.spans.push(n),this.trimSpans()}closeOpenSpan(t,e,s){for(let n=this.spans.length-1;n>=0;n--){const o=this.spans[n];if(o.agentId===t&&o.endTime===null){o.endTime=e,o.outcome=s;break}}}trimSpans(){this.spans.length>$h&&this.spans.splice(0,this.spans.length-$h)}updateCanvasSize(){const t=this.container.clientWidth,e=Math.max(this.agentLanes.length,1),s=Ce+e*(is+Fn)+8,n=window.devicePixelRatio||1;this.canvas.width=t*n,this.canvas.height=s*n,this.canvas.style.height=`${s}px`,this.ctx.setTransform(n,0,0,n,0,0)}startRenderLoop(){if(this.animFrame!==null)return;const t=()=>{this.visible&&(this.draw(),this.animFrame=requestAnimationFrame(t))};this.animFrame=requestAnimationFrame(t)}stopRenderLoop(){this.animFrame!==null&&(cancelAnimationFrame(this.animFrame),this.animFrame=null)}draw(){const t=this.ctx,e=this.container.clientWidth,s=Math.max(this.agentLanes.length,1),n=Ce+s*(is+Fn)+8;Math.abs(parseFloat(this.canvas.style.height)-n)>1&&this.updateCanvasSize(),this.autoScroll&&(this.viewEndTime=Date.now());const o=this.viewEndTime-this.viewWindowMs,r=e-ne;t.fillStyle="#111827",t.fillRect(0,0,e,n),t.fillStyle="#1f2937",t.fillRect(0,0,e,Ce),t.strokeStyle="#374151",t.lineWidth=1,t.beginPath(),t.moveTo(0,Ce),t.lineTo(e,Ce),t.stroke();const l=this.pickGridInterval(),h=Math.ceil(o/l)*l;t.font="10px monospace",t.textAlign="center",t.textBaseline="middle";for(let u=h;u<=this.viewEndTime;u+=l){const d=ne+(u-o)/this.viewWindowMs*r;t.strokeStyle="#1f2937",t.beginPath(),t.moveTo(d,Ce),t.lineTo(d,n),t.stroke(),t.fillStyle="#9ca3af",t.fillText(this.formatTime(u),d,Ce/2)}t.textAlign="right",t.textBaseline="middle",t.font="11px sans-serif";for(let u=0;u<this.agentLanes.length;u++){const d=this.agentLanes[u],p=this.agentNames.get(d)??d.slice(0,8),m=Ce+u*(is+Fn);t.fillStyle=u%2===0?"#111827":"#0f172a",t.fillRect(0,m,e,is);const g=this.store.getAgent(d),y=g?dt[g.colorIndex%dt.length]:null;t.fillStyle=y?`#${y.body.toString(16).padStart(6,"0")}`:"#9ca3af";const x=p.length>14?p.slice(0,12)+"..":p;t.fillText(x,ne-8,m+is/2)}t.strokeStyle="#374151",t.beginPath(),t.moveTo(ne,0),t.lineTo(ne,n),t.stroke();for(const u of this.spans){const d=u.endTime??Date.now();if(d<o||u.startTime>this.viewEndTime)continue;const p=this.agentLanes.indexOf(u.agentId);if(p<0)continue;const m=Math.max(u.startTime,o),g=Math.min(d,this.viewEndTime),y=ne+(m-o)/this.viewWindowMs*r,x=ne+(g-o)/this.viewWindowMs*r,w=Math.max(x-y,2),S=Ce+p*(is+Fn)+3,A=is-6,L=Dh[u.zone]??Dh.thinking;if(t.fillStyle=L,t.globalAlpha=u.endTime===null?.7:.85,t.beginPath(),this.roundRect(t,y,S,w,A,3),t.fill(),t.globalAlpha=1,u.outcome&&(t.strokeStyle=u.outcome==="success"?"#22c55e":"#ef4444",t.lineWidth=1.5,t.beginPath(),this.roundRect(t,y,S,w,A,3),t.stroke()),u.endTime===null){const I=.4+.6*Math.abs(Math.sin(Date.now()/600));t.strokeStyle=`rgba(255,255,255,${I*.5})`,t.lineWidth=1,t.beginPath(),this.roundRect(t,y,S,w,A,3),t.stroke()}if(w>40){t.fillStyle="#ffffff",t.font="9px monospace",t.textAlign="left",t.textBaseline="middle";const I=this.shortToolName(u.toolName),O=Math.floor((w-6)/5.5),R=I.length>O?I.slice(0,O-1)+"..":I;t.fillText(R,y+4,S+A/2)}}if(this.autoScroll){const u=ne+r;t.strokeStyle="#ef4444",t.lineWidth=1,t.setLineDash([3,3]),t.beginPath(),t.moveTo(u,Ce),t.lineTo(u,n),t.stroke(),t.setLineDash([])}this.spans.length===0&&(t.fillStyle="#6b7280",t.font="13px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("No tool spans recorded yet",e/2,n/2))}roundRect(t,e,s,n,o,r){r=Math.min(r,n/2,o/2),t.moveTo(e+r,s),t.lineTo(e+n-r,s),t.arcTo(e+n,s,e+n,s+r,r),t.lineTo(e+n,s+o-r),t.arcTo(e+n,s+o,e+n-r,s+o,r),t.lineTo(e+r,s+o),t.arcTo(e,s+o,e,s+o-r,r),t.lineTo(e,s+r),t.arcTo(e,s,e+r,s,r),t.closePath()}pickGridInterval(){const t=[1e3,2e3,5e3,1e4,15e3,3e4,6e4,12e4,3e5,6e5],e=this.container.clientWidth-ne,s=60;for(const n of t)if(n/this.viewWindowMs*e>=s)return n;return 6e5}formatTime(t){const e=new Date(t),s=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0"),o=e.getSeconds().toString().padStart(2,"0");return`${s}:${n}:${o}`}shortToolName(t){if(t.startsWith("mcp__")){const e=t.split("__");return e[e.length-1]}return t}hitTest(t,e){const s=this.canvas.getBoundingClientRect(),n=t-s.left,o=e-s.top;if(n<ne||o<Ce)return null;const r=this.viewEndTime-this.viewWindowMs,l=this.container.clientWidth-ne;for(let h=this.spans.length-1;h>=0;h--){const u=this.spans[h],d=u.endTime??Date.now();if(d<r||u.startTime>this.viewEndTime)continue;const p=this.agentLanes.indexOf(u.agentId);if(p<0)continue;const m=Math.max(u.startTime,r),g=Math.min(d,this.viewEndTime),y=ne+(m-r)/this.viewWindowMs*l,x=ne+(g-r)/this.viewWindowMs*l,w=Math.max(x-y,2),S=Ce+p*(is+Fn)+3,A=is-6;if(n>=y&&n<=y+w&&o>=S&&o<=S+A)return u}return null}fmtDuration(t){if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(1)}s`;const e=Math.floor(t/6e4),s=Math.floor(t%6e4/1e3);return`${e}m ${s}s`}}const ii=20,$b=25,zb=120,Fb=4e3,Nb=.005,zh=.9,ba=3,Fh=.01,Nh={running:"#4caf50",idle:"#9e9e9e",compacting:"#9c27b0"},Wb={main:"MAIN",subagent:"SUB","team-lead":"LEAD"};function Gb(i){return"#"+i.toString(16).padStart(6,"0")}function Ob(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class Hb{constructor(t,e){b(this,"container");b(this,"canvas");b(this,"ctx");b(this,"nodes",new Map);b(this,"edges",[]);b(this,"animFrame",null);b(this,"visible",!1);b(this,"messageAnimT",0);b(this,"store");b(this,"_customizationLookup",null);b(this,"listeners",[]);b(this,"onClick",t=>{const e=this.canvas.getBoundingClientRect(),s=t.clientX-e.left,n=t.clientY-e.top;let o=null,r=$b;for(const l of this.nodes.values()){const h=l.x-s,u=l.y-n,d=Math.sqrt(h*h+u*u);d<r&&(r=d,o=l)}o&&this.canvas.dispatchEvent(new CustomEvent("node-click",{detail:{agentId:o.id},bubbles:!0}))});this.store=t,this.container=document.createElement("div"),this.container.id="relationship-content",this.container.style.display="none",this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.container.appendChild(this.canvas),e.appendChild(this.container);const s=this.canvas.getContext("2d");if(!s)throw new Error("Canvas 2D not supported");this.ctx=s,this.canvas.addEventListener("click",this.onClick),new ResizeObserver(()=>this.resizeCanvas()).observe(this.container);const o=(r,l)=>{t.on(r,l),this.listeners.push({event:r,fn:l})};o("state:reset",()=>this.rebuildFromStore()),o("agent:spawn",()=>this.rebuildFromStore()),o("agent:update",()=>this.rebuildFromStore()),o("agent:idle",()=>this.rebuildFromStore()),o("agent:shutdown",()=>this.rebuildFromStore())}setCustomizationLookup(t){this._customizationLookup=t;for(const[e,s]of this.nodes){const n=this.store.getAgent(e);n&&(s.label=this.resolveDisplayName(n),s.colorIndex=this.resolveColorIndex(n))}}resolveDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName??t.projectName??t.id.slice(0,8)}resolveColorIndex(t){return this._customizationLookup?this._customizationLookup(t).colorIndex:t.colorIndex}show(){this.visible=!0,this.container.style.display="block",this.resizeCanvas(),this.rebuildFromStore(),this.startLoop()}hide(){this.visible=!1,this.container.style.display="none",this.stopLoop()}destroy(){this.stopLoop(),this.canvas.removeEventListener("click",this.onClick);for(const{event:t,fn:e}of this.listeners)this.store.off(t,e);this.listeners.length=0,this.container.remove()}resizeCanvas(){const t=this.container.getBoundingClientRect(),e=window.devicePixelRatio||1;this.canvas.width=t.width*e,this.canvas.height=t.height*e,this.ctx.setTransform(e,0,0,e,0,0)}rebuildFromStore(){const t=this.store.getAgents(),e=new Set;for(const[s,n]of t){e.add(s);let o=this.nodes.get(s);if(o)o.phase=n.phase,o.role=n.role,o.parentId=n.parentId,o.teamName=n.teamName,o.messageTarget=n.messageTarget,o.label=this.resolveDisplayName(n),o.colorIndex=this.resolveColorIndex(n),o.agentName=n.agentName;else{const r=this.canvas.width/(window.devicePixelRatio||1)/2,l=this.canvas.height/(window.devicePixelRatio||1)/2;o={id:s,label:this.resolveDisplayName(n),x:r+(Math.random()-.5)*100,y:l+(Math.random()-.5)*100,vx:0,vy:0,colorIndex:this.resolveColorIndex(n),phase:n.phase,role:n.role,parentId:n.parentId,teamName:n.teamName,messageTarget:n.messageTarget,agentName:n.agentName},this.nodes.set(s,o)}}for(const s of this.nodes.keys())e.has(s)||this.nodes.delete(s);this.rebuildEdges()}rebuildEdges(){this.edges=[];const t=Array.from(this.nodes.values());for(const s of t)s.parentId&&this.nodes.has(s.parentId)&&this.edges.push({source:s.parentId,target:s.id,kind:"parent-child"});const e=new Map;for(const s of t)if(s.teamName){let n=e.get(s.teamName);n||(n=[],e.set(s.teamName,n)),n.push(s.id)}for(const s of e.values())for(let n=0;n<s.length;n++)for(let o=n+1;o<s.length;o++)this.edges.some(l=>l.kind==="parent-child"&&(l.source===s[n]&&l.target===s[o]||l.source===s[o]&&l.target===s[n]))||this.edges.push({source:s[n],target:s[o],kind:"teammate"});for(const s of t)if(s.messageTarget){const n=t.find(o=>o.agentName===s.messageTarget);n&&this.edges.push({source:s.id,target:n.id,kind:"message"})}}startLoop(){if(this.animFrame!==null)return;const t=()=>{this.visible&&(this.simulate(),this.draw(),this.messageAnimT=(this.messageAnimT+.02)%1,this.animFrame=requestAnimationFrame(t))};this.animFrame=requestAnimationFrame(t)}stopLoop(){this.animFrame!==null&&(cancelAnimationFrame(this.animFrame),this.animFrame=null)}simulate(){const t=Array.from(this.nodes.values());if(t.length===0)return;const e=this.canvas.width/(window.devicePixelRatio||1),s=this.canvas.height/(window.devicePixelRatio||1),n=e/2,o=s/2;for(let l=0;l<t.length;l++)for(let h=l+1;h<t.length;h++){const u=t[l],d=t[h],p=d.x-u.x,m=d.y-u.y,g=Math.sqrt(p*p+m*m)||1,y=Fb/(g*g),x=p/g*y,w=m/g*y;u.vx-=x,u.vy-=w,d.vx+=x,d.vy+=w}const r=new Set;for(const l of this.edges){const h=this.nodes.get(l.source),u=this.nodes.get(l.target);if(!h||!u)continue;r.add(l.source),r.add(l.target);const d=u.x-h.x,p=u.y-h.y,m=Math.sqrt(d*d+p*p)||1,g=m-zb,y=Nb*g,x=d/m*y,w=p/m*y;h.vx+=x,h.vy+=w,u.vx-=x,u.vy-=w}for(const l of t)l.vx+=(n-l.x)*Fh,l.vy+=(o-l.y)*Fh;for(const l of t){l.vx*=zh,l.vy*=zh;const h=Math.sqrt(l.vx*l.vx+l.vy*l.vy);h>ba&&(l.vx=l.vx/h*ba,l.vy=l.vy/h*ba),l.x+=l.vx,l.y+=l.vy,l.x=Math.max(ii,Math.min(e-ii,l.x)),l.y=Math.max(ii+15,Math.min(s-ii-15,l.y))}}draw(){const t=this.canvas.width/(window.devicePixelRatio||1),e=this.canvas.height/(window.devicePixelRatio||1),s=this.ctx;s.clearRect(0,0,t,e);for(const n of this.edges){const o=this.nodes.get(n.source),r=this.nodes.get(n.target);if(!(!o||!r)&&(s.beginPath(),s.moveTo(o.x,o.y),s.lineTo(r.x,r.y),n.kind==="teammate"?(s.setLineDash([6,4]),s.strokeStyle="#666",s.lineWidth=1.5):n.kind==="message"?(s.setLineDash([]),s.strokeStyle="#ff9800",s.lineWidth=2):(s.setLineDash([]),s.strokeStyle="#888",s.lineWidth=1.5),s.stroke(),s.setLineDash([]),n.kind==="message")){const l=this.messageAnimT;for(let h=0;h<3;h++){const u=(l+h*.33)%1,d=o.x+(r.x-o.x)*u,p=o.y+(r.y-o.y)*u;s.beginPath(),s.arc(d,p,3,0,Math.PI*2),s.fillStyle="#ffcc80",s.fill()}}}for(const n of this.nodes.values()){const o=dt[n.colorIndex%dt.length],r=Gb(o.body),l=Nh[n.phase]??Nh.idle;s.beginPath(),s.arc(n.x,n.y,ii+3,0,Math.PI*2),s.strokeStyle=l,s.lineWidth=3,s.stroke(),s.beginPath(),s.arc(n.x,n.y,ii,0,Math.PI*2),s.fillStyle=r,s.fill();const h=Wb[n.role];h&&(s.font="9px monospace",s.textAlign="center",s.fillStyle="#aaa",s.fillText(h,n.x,n.y-ii-8)),s.font="11px sans-serif",s.textAlign="center",s.fillStyle="#ddd",s.fillText(Ob(n.label,12),n.x,n.y+ii+14)}}}class Ub{constructor(t){b(this,"el");b(this,"currentAgentId",null);b(this,"hideTimer",null);b(this,"store");b(this,"onFocus",null);b(this,"onDetail",null);this.store=t,this.el=document.createElement("div"),this.el.id="agent-hover-bar",this.el.innerHTML=`
699
+ <button class="ahb-btn ahb-focus" title="Focus camera">
700
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><circle cx="12" cy="12" r="3"/><path d="M12 2a10 10 0 100 20 10 10 0 000-20zm0 18a8 8 0 110-16 8 8 0 010 16z"/></svg>
701
+ </button>
702
+ <button class="ahb-btn ahb-detail" title="View details">
703
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>
704
+ </button>
705
+ <button class="ahb-btn ahb-approve" title="Approve pending" style="display:none">
706
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></svg>
707
+ </button>
708
+ <button class="ahb-btn ahb-copy" title="Copy session ID">
709
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
710
+ </button>
711
+ `,document.body.appendChild(this.el),this.el.addEventListener("mouseenter",()=>{this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)}),this.el.addEventListener("mouseleave",()=>{this.scheduleHide()}),this.el.querySelector(".ahb-focus").addEventListener("click",e=>{e.stopPropagation(),this.currentAgentId&&this.onFocus&&this.onFocus(this.currentAgentId)}),this.el.querySelector(".ahb-detail").addEventListener("click",e=>{e.stopPropagation(),this.currentAgentId&&this.onDetail&&this.onDetail(this.currentAgentId)}),this.el.querySelector(".ahb-approve").addEventListener("click",e=>{if(e.stopPropagation(),!this.currentAgentId)return;const s=this.store.getAgent(this.currentAgentId);if(!s)return;const n=this.store.getPendingPermissions();for(const o of n)o.sessionId===s.sessionId&&this.store.approvePermission(o.permissionId)}),this.el.querySelector(".ahb-copy").addEventListener("click",e=>{if(e.stopPropagation(),!this.currentAgentId)return;const s=this.store.getAgent(this.currentAgentId);s&&navigator.clipboard.writeText(s.sessionId).catch(()=>{})})}setFocusHandler(t){this.onFocus=t}setDetailHandler(t){this.onDetail=t}show(t,e,s){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null),this.currentAgentId=t;const n=this.store.getAgent(t),o=this.el.querySelector(".ahb-approve");if(n){const l=this.store.getPendingPermissions().some(h=>h.sessionId===n.sessionId);o.style.display=l?"":"none"}this.el.style.left=`${e}px`,this.el.style.top=`${s-60}px`,this.el.classList.add("visible")}hide(){this.scheduleHide()}scheduleHide(){this.hideTimer||(this.hideTimer=setTimeout(()=>{this.el.classList.remove("visible"),this.currentAgentId=null,this.hideTimer=null},300))}dispose(){this.hideTimer&&clearTimeout(this.hideTimer),this.el.remove()}}async function qb(){const i=document.getElementById("app"),t=await f0(i),e=new Ga;V1();const s=new ry(t),n=new M1(t,s,e),o=new el,r=new D1;n.setSoundManager(o),n.setNotificationManager(r);const l=new X1(e),h=new Z1,u=new E1(e),d=new P1(e);u.setAgentClickHandler(at=>{d.open(at),ht(at)}),n.setClickHandler(at=>{d.open(at),ht(at)});const p=new Ub(e);p.setFocusHandler(at=>ht(at)),p.setDetailHandler(at=>{d.open(at),ht(at)}),n.setHoverHandler((at,Mt,kt)=>{if(at){const Xt=s.root,oo=Mt*Xt.scale.x+Xt.x,Eu=kt*Xt.scale.y+Xt.y,Tl=t.canvas.getBoundingClientRect();p.show(at,oo+Tl.left,Eu+Tl.top)}else p.hide()});const m=new R1(e);m.setReplayCallback(at=>{n.rebuildFromState(at)});const g=new N1(e);let y=!0;const x=document.getElementById("right-panel-content"),w=document.getElementById("overlay"),S=document.getElementById("right-panel-title"),A=new U1(e,x),L=new cb(e,x),I=new wb(e,x),O=new kb(e,x),R=new vb,z=new Ib(e,x),Q=new Db(e,x),X=new Hb(e,x),j=new Tb(e),Z=new Mb(e),it=new sl(e),ot=new tb,rt=new eb(e);new sb;const Et=new rb;s.addEffect(Et.container);const J=new ab(s.camera,(at,Mt)=>{s.camera.panTo(at,Mt)}),et=new hb,bt=at=>et.getCustomDisplay(at);n.setCustomizationLookup(bt),d.setCustomizationLookup(bt),u.setCustomizationLookup(bt),L.setCustomizationLookup(bt),A.setCustomizationLookup(bt),Q.setCustomizationLookup(bt),X.setCustomizationLookup(bt),z.setCustomizationLookup(bt),it.setCustomizationLookup(bt),Z.setCustomizationLookup(bt),m.setCustomizationLookup(bt),rt.setCustomizationLookup(bt),et.setChangeHandler((at,Mt)=>{n.applyCustomization(at,Mt.displayName,Mt.colorIndex),d.currentAgentId===at&&d.refreshHeader(Mt.displayName),u.scheduleRender()}),d.setCustomizeHandler(at=>{et.open(at)}),t.canvas.addEventListener("contextmenu",at=>{at.preventDefault()}),t.canvas.addEventListener("dblclick",at=>{const Mt=t.canvas.getBoundingClientRect(),kt=at.clientX-Mt.left,Xt=at.clientY-Mt.top;R.addAnnotationFromScreen(kt,Xt)});const nt=new xb;s.applyTheme(nt.current);const gt=document.getElementById("theme-select");gt.value=nt.current.id,gt.addEventListener("change",()=>nt.setTheme(gt.value)),nt.onChange(at=>{s.applyTheme(at),gt.value=at.id});let St=!1;function At(){if(St&&n.focusedAgentId){const at=n.getFocusedAgentName()||"Agent";l.showFocus(at)}else l.hideFocus()}function ht(at){n.setFocusAgent(at),St=!0,At()}function $t(){St=!1,n.setFocusAgent(null),At()}let qt=null;function be(){return qt||(qt=document.getElementById("zone-heatmap")),qt}document.getElementById("focus-stop").addEventListener("click",$t);let Ot=kl("activeTab","monitor");const ke={analytics:{show:()=>A.show(),hide:()=>A.hide(),title:"Analytics"},leaderboard:{show:()=>L.show(),hide:()=>L.hide(),title:"Leaderboard"},toolchain:{show:()=>I.show(),hide:()=>I.hide(),title:"Tool Chains"},taskgraph:{show:()=>O.show(),hide:()=>O.hide(),title:"Task Graph"},activity:{show:()=>z.show(),hide:()=>z.hide(),title:"Activity Feed"},waterfall:{show:()=>Q.show(),hide:()=>Q.hide(),title:"Waterfall"},graph:{show:()=>X.show(),hide:()=>X.hide(),title:"Agent Graph"}};function Le(at){var Mt;if(er("activeTab",at),(Mt=ke[Ot])==null||Mt.hide(),Ot=at,at==="monitor")w.style.display="",x.style.display="none",S.textContent="Agents";else{d.isOpen()&&d.close(),w.style.display="none",x.style.display="";const kt=ke[at];S.textContent=(kt==null?void 0:kt.title)??at,kt==null||kt.show()}}h.setTabChangeHandler(at=>{Le(at)}),Ot!=="monitor"&&h.setActiveTab(Ot),document.getElementById("right-panel");function pe(at){h.setActiveTab(Ot===at?"monitor":at)}function Fi(at,Mt){switch(at){case"focus-zone":{const kt=Mt?Vt.get(Mt):null;kt&&s.camera.panTo(kt.x+kt.width/2,kt.y+kt.height/2);break}case"focus-agent":Mt&&(d.open(Mt),ht(Mt));break;case"reset-camera":s.resetCamera();break;case"zoom-in":s.camera.zoomIn();break;case"zoom-out":s.camera.zoomOut();break;case"toggle-mute":o.init(),o.muted=!o.muted,fn();break;case"toggle-heatmap":y=!y;{const kt=be();kt&&(kt.style.display=y?"block":"none")}break;case"toggle-shortcuts":ot.toggle();break;case"toggle-focus":St?$t():(n.cycleNextAgent(),St=!!n.focusedAgentId,At());break;case"cycle-focus":St?n.cycleNextAgent()||$t():(n.cycleNextAgent(),St=!!n.focusedAgentId),At();break;case"exit-focus":St&&$t();break;case"session-export":rt.toggle();break;case"toggle-trails":Et.toggle();break;case"toggle-daynight":s.dayNight.toggle();break;case"toggle-minimap":J.toggle();break;case"cycle-theme":nt.cycleNext();break;case"toggle-annotations":R.toggle();break;case"toggle-sidebar":h.toggle();break;case"toggle-analytics":pe("analytics");break;case"toggle-leaderboard":pe("leaderboard");break;case"toggle-toolchain":pe("toolchain");break;case"toggle-taskgraph":pe("taskgraph");break;case"toggle-activity":pe("activity");break;case"toggle-waterfall":pe("waterfall");break;case"toggle-graph":pe("graph");break}}const Fe=new G1(e,Fi);Fe.setCustomizationLookup(bt),e.on("agent:shutdown",at=>{Et.removeAgent(at)});const Ne=new m0(e);Ne.connect(),document.getElementById("zoom-in").addEventListener("click",()=>s.camera.zoomIn()),document.getElementById("zoom-out").addEventListener("click",()=>s.camera.zoomOut()),document.getElementById("zoom-reset").addEventListener("click",()=>s.resetCamera());const Be=document.getElementById("mute-btn"),We=document.getElementById("volume-slider");function fn(){Be.textContent=o.muted||o.volume===0?"🔇":"🔈",Be.classList.toggle("muted",o.muted||o.volume===0)}Be.addEventListener("click",()=>{o.init(),o.muted=!o.muted,fn()}),We.addEventListener("input",()=>{o.init(),o.volume=Number(We.value)/100,o.muted&&o.volume>0&&(o.muted=!1),fn()});const pn=document.getElementById("notif-btn");pn.appendChild(Z.getBadgeElement()),pn.addEventListener("click",()=>{Z.toggle()}),document.getElementById("shortcuts-btn").addEventListener("click",()=>{ot.toggle()}),document.getElementById("cmd-hint").addEventListener("click",()=>{Fe.toggle()}),document.addEventListener("click",()=>{o.init(),r.requestPermission()},{once:!0});const hr={a:"toggle-analytics",h:"toggle-heatmap",m:"toggle-mute",f:"cycle-focus",e:"session-export",Escape:"exit-focus",t:"toggle-trails",n:"toggle-daynight","`":"toggle-minimap",l:"toggle-leaderboard",p:"cycle-theme",o:"toggle-annotations",c:"toggle-toolchain",g:"toggle-taskgraph",v:"toggle-activity",w:"toggle-waterfall",r:"toggle-graph","[":"toggle-sidebar"};document.addEventListener("keydown",at=>{var Xt;const Mt=(Xt=at.target)==null?void 0:Xt.tagName;if(Mt==="INPUT"||Mt==="TEXTAREA"||Mt==="SELECT"||at.ctrlKey||at.metaKey||at.altKey)return;const kt=hr[at.key];kt&&Fi(kt)}),window.addEventListener("beforeunload",()=>{Ne.disconnect(),n.dispose(),u.dispose(),d.dispose(),m.dispose(),A.dispose(),L.dispose(),l.dispose(),it.dispose(),Z.dispose(),j.dispose(),Q.destroy(),z.destroy(),J.dispose(),e.dispose()}),t.ticker.add(()=>{const at=t.ticker.deltaMS;n.update(at),s.update(at);const Mt=s.root;if(y&&g.updateTransform(Mt.x,Mt.y,Mt.scale.x),R.updateTransform(Mt.x,Mt.y,Mt.scale.x),St){const kt=n.getFocusedAgentPosition();kt&&s.camera.smoothFollow(kt.x,kt.y)}if(Et.enabled){const kt=new Map;for(const Xt of n.getAgentPositions()){const oo=dt[Xt.colorIndex%dt.length];kt.set(Xt.id,oo.body),Et.recordPosition(Xt.id,Xt.x,Xt.y,at,oo.body)}Et.update(at,kt)}if(J.visible){const kt=s.camera.getViewport(),Xt=n.getAgentPositions();J.render(Xt,kt)}}),console.log("AgentMove started")}qb().catch(console.error);export{or as $,Dd as A,Jn as B,Yt as C,Se as D,Ze as E,ls as F,ar as G,al as H,Ld as I,Ie as J,Td as K,za as L,_t as M,pm as N,gm as O,ae as P,Sm as Q,Ca as R,ll as S,It as T,Xo as U,xm as V,Vu as W,Cm as X,ye as Y,Qh as Z,Pe as _,Ad as a,Gl as a0,Di as a1,r0 as a2,kf as a3,Hl as a4,xr as a5,Ul as a6,Cf as a7,ln as a8,Ht as a9,ed as aa,Eg as ab,$d as ac,wt as ad,io as ae,Wt as af,Ep as ag,kp as ah,Zp as ai,Hp as aj,mm as ak,ym as al,km as am,wm as an,Tm as ao,vd as b,Wp as c,me as d,Gt as e,Lt as f,Xf as g,zo as h,mt as i,Ft as j,Om as k,Bm as l,td as m,cr as n,hd as o,Ut as p,Ji as q,af as r,lr as s,Rt as t,rp as u,zp as v,fe as w,no as x,nc as y,Fo as z};