@foothill/agent-move 1.0.10 → 1.0.12
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.
- package/.github/screenshot.png +0 -0
- package/package.json +1 -1
- package/packages/client/dist/assets/{BufferResource-Dfd5uHKt.js → BufferResource-Dhljy8H8.js} +1 -1
- package/packages/client/dist/assets/{CanvasRenderer-7Cv6xZVP.js → CanvasRenderer-Bpr11iOT.js} +1 -1
- package/packages/client/dist/assets/{Filter-CBX7EB7j.js → Filter-DL2yN3-o.js} +1 -1
- package/packages/client/dist/assets/{RenderTargetSystem-ko-v73NG.js → RenderTargetSystem-BTwylEdr.js} +1 -1
- package/packages/client/dist/assets/{WebGLRenderer-vhPQEPUG.js → WebGLRenderer-wH1P7d1x.js} +1 -1
- package/packages/client/dist/assets/{WebGPURenderer-Dwywvwqe.js → WebGPURenderer-C7n8jUXC.js} +1 -1
- package/packages/client/dist/assets/{browserAll-QyCAT8_K.js → browserAll-CgAMpWnT.js} +1 -1
- package/packages/client/dist/assets/index-DG7HqEmM.js +1338 -0
- package/packages/client/dist/assets/index-Nz5TZeB1.css +1 -0
- package/packages/client/dist/assets/{webworkerAll-hM-gNP7L.js → webworkerAll-wrP2P1GC.js} +1 -1
- package/packages/client/dist/index.html +16 -2
- package/packages/server/dist/index.d.ts.map +1 -1
- package/packages/server/dist/index.js +954 -31
- package/packages/server/dist/index.js.map +1 -1
- package/packages/server/dist/routes/sessions-api.d.ts +5 -0
- package/packages/server/dist/routes/sessions-api.d.ts.map +1 -0
- package/packages/server/dist/routes/sessions-api.js +88 -0
- package/packages/server/dist/routes/sessions-api.js.map +1 -0
- package/packages/server/dist/state/activity-processor.d.ts.map +1 -1
- package/packages/server/dist/state/activity-processor.js +0 -2
- package/packages/server/dist/state/activity-processor.js.map +1 -1
- package/packages/server/dist/state/agent-state-manager.d.ts.map +1 -1
- package/packages/server/dist/state/agent-state-manager.js +3 -5
- package/packages/server/dist/state/agent-state-manager.js.map +1 -1
- package/packages/server/dist/state/identity-manager.d.ts.map +1 -1
- package/packages/server/dist/state/identity-manager.js +0 -3
- package/packages/server/dist/state/identity-manager.js.map +1 -1
- package/packages/server/dist/storage/session-recorder.d.ts +38 -0
- package/packages/server/dist/storage/session-recorder.d.ts.map +1 -0
- package/packages/server/dist/storage/session-recorder.js +941 -0
- package/packages/server/dist/storage/session-recorder.js.map +1 -0
- package/packages/server/dist/storage/session-store.d.ts +60 -0
- package/packages/server/dist/storage/session-store.d.ts.map +1 -0
- package/packages/server/dist/storage/session-store.js +330 -0
- package/packages/server/dist/storage/session-store.js.map +1 -0
- package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts +15 -0
- package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts.map +1 -1
- package/packages/server/dist/watcher/opencode/opencode-watcher.js +61 -4
- package/packages/server/dist/watcher/opencode/opencode-watcher.js.map +1 -1
- package/packages/server/dist/ws/broadcaster.d.ts.map +1 -1
- package/packages/server/dist/ws/broadcaster.js +3 -18
- package/packages/server/dist/ws/broadcaster.js.map +1 -1
- package/packages/shared/dist/constants/tools.d.ts +4 -0
- package/packages/shared/dist/constants/tools.d.ts.map +1 -1
- package/packages/shared/dist/constants/tools.js +4 -0
- package/packages/shared/dist/constants/tools.js.map +1 -1
- package/packages/shared/dist/index.d.ts +2 -1
- package/packages/shared/dist/index.d.ts.map +1 -1
- package/packages/shared/dist/index.js +1 -1
- package/packages/shared/dist/index.js.map +1 -1
- package/packages/shared/dist/types/session-record.d.ts +87 -0
- package/packages/shared/dist/types/session-record.d.ts.map +1 -0
- package/packages/shared/dist/types/session-record.js +2 -0
- package/packages/shared/dist/types/session-record.js.map +1 -0
- package/packages/shared/dist/types/websocket.d.ts +3 -0
- package/packages/shared/dist/types/websocket.d.ts.map +1 -1
- package/packages/client/dist/assets/index-BPJtz4FL.js +0 -722
- package/packages/client/dist/assets/index-CMmR_RuS.css +0 -1
|
@@ -0,0 +1,1338 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-CgAMpWnT.js","assets/webworkerAll-wrP2P1GC.js","assets/Filter-DL2yN3-o.js","assets/WebGPURenderer-C7n8jUXC.js","assets/BufferResource-Dhljy8H8.js","assets/RenderTargetSystem-BTwylEdr.js","assets/WebGLRenderer-wH1P7d1x.js","assets/CanvasRenderer-Bpr11iOT.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var rp=Object.defineProperty;var ap=(i,t,e)=>t in i?rp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var y=(i,t,e)=>ap(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 lp="modulepreload",cp=function(i){return"/"+i},Xl={},co=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){let r=function(d){return Promise.all(d.map(c=>Promise.resolve(c).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};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(d=>{if(d=cp(d),d in Xl)return;Xl[d]=!0;const c=d.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${f}`))return;const g=document.createElement("link");if(g.rel=c?"stylesheet":lp,c||(g.as="script"),g.crossOrigin="",g.href=d,h&&g.setAttribute("nonce",h),document.head.appendChild(g),c)return new Promise((m,v)=>{g.addEventListener("load",m),g.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${d}`)))})}))}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 bt=(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))(bt||{});const Ha=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},Co=(i,t)=>Ha(i).priority??t,Kt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Ha).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(Ha).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)=>Co(r.value,e)-Co(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)=>Co(o,e)-Co(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))}},hp={extension:{type:bt.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await co(()=>import("./browserAll-CgAMpWnT.js"),__vite__mapDeps([0,1,2]))}},dp={extension:{type:bt.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await co(()=>import("./webworkerAll-wrP2P1GC.js"),__vite__mapDeps([1,2]))}};class ie{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new ie(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 pd(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Dr={exports:{}},Zl;function up(){return Zl||(Zl=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,d,c){this.fn=h,this.context=d,this.once=c||!1}function o(h,d,c,f,g){if(typeof c!="function")throw new TypeError("The listener must be a function");var m=new n(c,f||h,g),v=e?e+d:d;return h._events[v]?h._events[v].fn?h._events[v]=[h._events[v],m]:h._events[v].push(m):(h._events[v]=m,h._eventsCount++),h}function r(h,d){--h._eventsCount===0?h._events=new s:delete h._events[d]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],c,f;if(this._eventsCount===0)return d;for(f in c=this._events)t.call(c,f)&&d.push(e?f.slice(1):f);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},l.prototype.listeners=function(d){var c=e?e+d:d,f=this._events[c];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,m=f.length,v=new Array(m);g<m;g++)v[g]=f[g].fn;return v},l.prototype.listenerCount=function(d){var c=e?e+d:d,f=this._events[c];return f?f.fn?1:f.length:0},l.prototype.emit=function(d,c,f,g,m,v){var b=e?e+d:d;if(!this._events[b])return!1;var _=this._events[b],x=arguments.length,C,$;if(_.fn){switch(_.once&&this.removeListener(d,_.fn,void 0,!0),x){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,c),!0;case 3:return _.fn.call(_.context,c,f),!0;case 4:return _.fn.call(_.context,c,f,g),!0;case 5:return _.fn.call(_.context,c,f,g,m),!0;case 6:return _.fn.call(_.context,c,f,g,m,v),!0}for($=1,C=new Array(x-1);$<x;$++)C[$-1]=arguments[$];_.fn.apply(_.context,C)}else{var P=_.length,H;for($=0;$<P;$++)switch(_[$].once&&this.removeListener(d,_[$].fn,void 0,!0),x){case 1:_[$].fn.call(_[$].context);break;case 2:_[$].fn.call(_[$].context,c);break;case 3:_[$].fn.call(_[$].context,c,f);break;case 4:_[$].fn.call(_[$].context,c,f,g);break;default:if(!C)for(H=1,C=new Array(x-1);H<x;H++)C[H-1]=arguments[H];_[$].fn.apply(_[$].context,C)}}return!0},l.prototype.on=function(d,c,f){return o(this,d,c,f,!1)},l.prototype.once=function(d,c,f){return o(this,d,c,f,!0)},l.prototype.removeListener=function(d,c,f,g){var m=e?e+d:d;if(!this._events[m])return this;if(!c)return r(this,m),this;var v=this._events[m];if(v.fn)v.fn===c&&(!g||v.once)&&(!f||v.context===f)&&r(this,m);else{for(var b=0,_=[],x=v.length;b<x;b++)(v[b].fn!==c||g&&!v[b].once||f&&v[b].context!==f)&&_.push(v[b]);_.length?this._events[m]=_.length===1?_[0]:_:r(this,m)}return this},l.prototype.removeAllListeners=function(d){var c;return d?(c=e?e+d:d,this._events[c]&&r(this,c)):(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 pp=up();const cs=pd(pp),fp=Math.PI*2,mp=180/Math.PI,gp=Math.PI/180;class ye{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ye(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 zr.x=0,zr.y=0,zr}}const zr=new ye;class Tt{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 ye;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 ye;const s=this.a,n=this.b,o=this.c,r=this.d,l=this.tx,h=this.ty,d=1/(s*r+o*-n),c=t.x,f=t.y;return e.x=r*d*c+-o*d*f+(h*o-l*r)*d,e.y=s*d*f+-n*d*c+(-h*s+l*n)*d,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,d=e.a,c=e.b,f=e.c,g=e.d;return this.a=s*d+n*f,this.b=s*c+n*g,this.c=o*d+r*f,this.d=o*c+r*g,this.tx=l*d+h*f+e.tx,this.ty=l*c+h*g+e.ty,this}setTransform(t,e,s,n,o,r,l,h,d){return this.a=Math.cos(l+d)*o,this.b=Math.sin(l+d)*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),d=Math.abs(l+h);return d<1e-5||Math.abs(fp-d)<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 Tt;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 yp.identity()}static get shared(){return vp.identity()}}const vp=new Tt,yp=new Tt,Ui=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],qi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Vi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],ji=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ua=[],fd=[],Ao=Math.sign;function bp(){for(let i=0;i<16;i++){const t=[];Ua.push(t);for(let e=0;e<16;e++){const s=Ao(Ui[i]*Ui[e]+Vi[i]*qi[e]),n=Ao(qi[i]*Ui[e]+ji[i]*qi[e]),o=Ao(Ui[i]*Vi[e]+Vi[i]*ji[e]),r=Ao(qi[i]*Vi[e]+ji[i]*ji[e]);for(let l=0;l<16;l++)if(Ui[l]===s&&qi[l]===n&&Vi[l]===o&&ji[l]===r){t.push(l);break}}}for(let i=0;i<16;i++){const t=new Tt;t.set(Ui[i],qi[i],Vi[i],ji[i],0,0),fd.push(t)}}bp();const Rt={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=>Ui[i],uY:i=>qi[i],vX:i=>Vi[i],vY:i=>ji[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Ua[i][t],sub:(i,t)=>Ua[i][Rt.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?Rt.S:Rt.N:Math.abs(t)*2<=Math.abs(i)?i>0?Rt.E:Rt.W:t>0?i>0?Rt.SE:Rt.SW:i>0?Rt.NE:Rt.NW,matrixAppendRotationInv:(i,t,e=0,s=0,n=0,o=0)=>{const r=fd[Rt.inv(t)],l=r.a,h=r.b,d=r.c,c=r.d,f=e-Math.min(0,l*n,d*o,l*n+d*o),g=s-Math.min(0,h*n,c*o,h*n+c*o),m=i.a,v=i.b,b=i.c,_=i.d;i.a=l*m+h*b,i.b=l*v+h*_,i.c=d*m+c*b,i.d=d*v+c*_,i.tx=f*m+g*b+i.tx,i.ty=f*v+g*_+i.ty},transformRectCoords:(i,t,e,s)=>{const{x:n,y:o,width:r,height:l}=i,{x:h,y:d,width:c,height:f}=t;return e===Rt.E?(s.set(n+h,o+d,r,l),s):e===Rt.S?s.set(c-o-l+h,n+d,l,r):e===Rt.W?s.set(c-n-r+h,f-o-l+d,r,l):e===Rt.N?s.set(o+h,f-n-r+d,l,r):s.set(n+h,o+d,r,l)}},Eo=[new ye,new ye,new ye,new ye];class Xt{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 Xt(0,0,0,0)}clone(){return new Xt(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,d=s*(1-n),c=s-d,f=l-d,g=l+o+d,m=h-d,v=h+r+d,b=l+c,_=l+o-c,x=h+c,C=h+r-c;return t>=f&&t<=g&&e>=m&&e<=v&&!(t>b&&t<_&&e>x&&e<C)}intersects(t,e){if(!e){const et=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=et)return!1;const X=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>X}const s=this.left,n=this.right,o=this.top,r=this.bottom;if(n<=s||r<=o)return!1;const l=Eo[0].set(t.left,t.top),h=Eo[1].set(t.left,t.bottom),d=Eo[2].set(t.right,t.top),c=Eo[3].set(t.right,t.bottom);if(d.x<=l.x||h.y<=l.y)return!1;const f=Math.sign(e.a*e.d-e.b*e.c);if(f===0||(e.apply(l,l),e.apply(h,h),e.apply(d,d),e.apply(c,c),Math.max(l.x,h.x,d.x,c.x)<=s||Math.min(l.x,h.x,d.x,c.x)>=n||Math.max(l.y,h.y,d.y,c.y)<=o||Math.min(l.y,h.y,d.y,c.y)>=r))return!1;const g=f*(h.y-l.y),m=f*(l.x-h.x),v=g*s+m*o,b=g*n+m*o,_=g*s+m*r,x=g*n+m*r;if(Math.max(v,b,_,x)<=g*l.x+m*l.y||Math.min(v,b,_,x)>=g*c.x+m*c.y)return!1;const C=f*(l.y-d.y),$=f*(d.x-l.x),P=C*s+$*o,H=C*n+$*o,R=C*s+$*r,O=C*n+$*r;return!(Math.max(P,H,R,O)<=C*l.x+$*l.y||Math.min(P,H,R,O)>=C*c.x+$*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),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 Xt),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 Yt(i="default"){return Fr[i]===void 0&&(Fr[i]=-1),++Fr[i]}const Kl=new Set,jt="8.0.0",wp="8.3.4",bn={quiet:!1,noColor:!1},Mt=((i,t,e=3)=>{if(bn.quiet||Kl.has(t))return;let s=new Error().stack;const n=`${t}
|
|
3
|
+
Deprecated since v${i}`,o=typeof console.groupCollapsed=="function"&&!bn.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))),Kl.add(t)});Object.defineProperties(Mt,{quiet:{get:()=>bn.quiet,set:i=>{bn.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>bn.noColor,set:i=>{bn.noColor=i},enumerable:!0,configurable:!1}});const md=()=>{};function Cn(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 Ql(i){return!(i&i-1)&&!!i}function gd(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const Jl=Object.create(null);function _p(i){const t=Jl[i];return t===void 0&&(Jl[i]=Yt("resource")),t}const vd=class yd extends cs{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...yd.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){Mt(jt,"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=_p(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};vd.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let An=vd;const bd=class wd extends cs{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=Yt("textureSource"),this._resourceType="textureSource",this._resourceId=Yt("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={...wd.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 An(gd(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=Yt("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=Yt("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=Ql(this.pixelWidth)&&Ql(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};bd.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 He=bd;class El extends He{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}}El.extension=bt.TextureSource;const tc=new Tt;class xp{constructor(t,e){this.mapCoord=new Tt,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&&(tc.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(tc));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 Bt extends cs{constructor({source:t,label:e,frame:s,orig:n,trim:o,defaultAnchor:r,defaultBorders:l,rotate:h,dynamic:d}={}){if(super(),this.uid=Yt("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Xt,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new He,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:c,height:f}=this._source;this.frame.width=c,this.frame.height=f}this.orig=n||this.frame,this.trim=o,this.rotate=h??0,this.defaultAnchor=r,this.defaultBorders=l,this.destroyed=!1,this.dynamic=d||!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 xp(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 d=this.rotate;if(d){const c=l/2,f=h/2,g=o+c,m=r+f;d=Rt.add(d,Rt.NW),t.x0=g+c*Rt.uX(d),t.y0=m+f*Rt.uY(d),d=Rt.add(d,2),t.x1=g+c*Rt.uX(d),t.y1=m+f*Rt.uY(d),d=Rt.add(d,2),t.x2=g+c*Rt.uX(d),t.y2=m+f*Rt.uY(d),d=Rt.add(d,2),t.x3=g+c*Rt.uX(d),t.y3=m+f*Rt.uY(d)}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 Mt(jt,"Texture.baseTexture is now Texture.source"),this._source}}Bt.EMPTY=new Bt({label:"EMPTY",source:new He({label:"EMPTY"})});Bt.EMPTY.destroy=md;Bt.WHITE=new Bt({source:new El({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});Bt.WHITE.destroy=md;function _d(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 ec=new Tt;class We{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=ec,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 Xt);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=ec,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,d=o.d,c=o.tx,f=o.ty;let g=this.minX,m=this.minY,v=this.maxX,b=this.maxY,_=r*t+h*e+c,x=l*t+d*e+f;_<g&&(g=_),x<m&&(m=x),_>v&&(v=_),x>b&&(b=x),_=r*s+h*e+c,x=l*s+d*e+f,_<g&&(g=_),x<m&&(m=x),_>v&&(v=_),x>b&&(b=x),_=r*t+h*n+c,x=l*t+d*n+f,_<g&&(g=_),x<m&&(m=x),_>v&&(v=_),x>b&&(b=x),_=r*s+h*n+c,x=l*s+d*n+f,_<g&&(g=_),x<m&&(m=x),_>v&&(v=_),x>b&&(b=x),this.minX=g,this.minY=m,this.maxX=v,this.maxY=b}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,tx:c,ty:f}=t;let g=r*e+h*s+c,m=l*e+d*s+f;this.minX=g,this.minY=m,this.maxX=g,this.maxY=m,g=r*n+h*s+c,m=l*n+d*s+f,this.minX=g<this.minX?g:this.minX,this.minY=m<this.minY?m:this.minY,this.maxX=g>this.maxX?g:this.maxX,this.maxY=m>this.maxY?m:this.maxY,g=r*e+h*o+c,m=l*e+d*o+f,this.minX=g<this.minX?g:this.minX,this.minY=m<this.minY?m:this.minY,this.maxX=g>this.maxX?g:this.maxX,this.maxY=m>this.maxY?m:this.maxY,g=r*n+h*o+c,m=l*n+d*o+f,this.minX=g<this.minX?g:this.minX,this.minY=m<this.minY?m:this.minY,this.maxX=g>this.maxX?g:this.maxX,this.maxY=m>this.maxY?m: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 We(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 d=n.a,c=n.b,f=n.c,g=n.d,m=n.tx,v=n.ty;for(let b=e;b<s;b+=2){const _=t[b],x=t[b+1],C=d*_+f*x+m,$=c*_+g*x+v;o=C<o?C:o,r=$<r?$:r,l=C>l?C:l,h=$>h?$: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 Sp={grad:.9,turn:360,rad:360/(2*Math.PI)},us=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},te=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},Ne=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},xd=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},sc=function(i){return{r:Ne(i.r,0,255),g:Ne(i.g,0,255),b:Ne(i.b,0,255),a:Ne(i.a)}},Nr=function(i){return{r:te(i.r),g:te(i.g),b:te(i.b),a:te(i.a,3)}},Tp=/^#([0-9a-f]{3,8})$/i,Mo=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},Sd=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}},Td=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),d=o%6;return{r:255*[s,l,r,r,h,s][d],g:255*[h,s,s,l,r,r][d],b:255*[r,r,h,s,s,l][d],a:n}},ic=function(i){return{h:xd(i.h),s:Ne(i.s,0,100),l:Ne(i.l,0,100),a:Ne(i.a)}},nc=function(i){return{h:te(i.h),s:te(i.s),l:te(i.l),a:te(i.a,3)}},oc=function(i){return Td((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},ho=function(i){return{h:(t=Sd(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},kp=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Cp=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ap=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ep=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qa={string:[[function(i){var t=Tp.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?te(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?te(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=Ap.exec(i)||Ep.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:sc({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=kp.exec(i)||Cp.exec(i);if(!t)return null;var e,s,n=ic({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(Sp[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return oc(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 us(t)&&us(e)&&us(s)?sc({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(!us(t)||!us(e)||!us(s))return null;var r=ic({h:Number(t),s:Number(e),l:Number(s),a:Number(o)});return oc(r)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,o=n===void 0?1:n;if(!us(t)||!us(e)||!us(s))return null;var r=(function(l){return{h:xd(l.h),s:Ne(l.s,0,100),v:Ne(l.v,0,100),a:Ne(l.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(o)});return Td(r)},"hsv"]]},rc=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]},Mp=function(i){return typeof i=="string"?rc(i.trim(),qa.string):typeof i=="object"&&i!==null?rc(i,qa.object):[null,void 0]},Or=function(i,t){var e=ho(i);return{h:e.h,s:Ne(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},ac=function(i,t){var e=ho(i);return{h:e.h,s:e.s,l:Ne(e.l+100*t,0,100),a:e.a}},Va=(function(){function i(t){this.parsed=Mp(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 te(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=Nr(this.rgba),e=t.r,s=t.g,n=t.b,r=(o=t.a)<1?Mo(te(255*o)):"","#"+Mo(e)+Mo(s)+Mo(n)+r;var t,e,s,n,o,r},i.prototype.toRgb=function(){return Nr(this.rgba)},i.prototype.toRgbString=function(){return t=Nr(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 nc(ho(this.rgba))},i.prototype.toHslString=function(){return t=nc(ho(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=Sd(this.rgba),{h:te(t.h),s:te(t.s),v:te(t.v),a:te(t.a,3)};var t},i.prototype.invert=function(){return ss({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),ss(Or(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),ss(Or(this.rgba,-t))},i.prototype.grayscale=function(){return ss(Or(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),ss(ac(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),ss(ac(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"?ss({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):te(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=ho(this.rgba);return typeof t=="number"?ss({h:t,s:e.s,l:e.l,a:e.a}):te(e.h)},i.prototype.isEqual=function(t){return this.toHex()===ss(t).toHex()},i})(),ss=function(i){return i instanceof Va?i:new Va(i)},lc=[],Ip=function(i){i.forEach(function(t){lc.indexOf(t)<0&&(t(Va,qa),lc.push(t))})};function Pp(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,d=s[this.toHex()];if(d)return d;if(r!=null&&r.closest){var c=this.toRgb(),f=1/0,g="black";if(!o.length)for(var m in e)o[m]=new i(e[m]).toRgb();for(var v in e){var b=(l=c,h=o[v],Math.pow(l.r-h.r,2)+Math.pow(l.g-h.g,2)+Math.pow(l.b-h.b,2));b<f&&(f=b,g=v)}return g}},t.string.push([function(r){var l=r.toLowerCase(),h=l==="transparent"?"#0000":e[l];return h?new i(h).toRgb():null},"name"])}Ip([Pp]);const En=class oo{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 oo)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]=oo._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=oo.HEX_PATTERN.exec(t);l&&(t=`#${l[2]}`)}const r=ss(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 oo||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}};En.shared=new En;En._temp=new En;En.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Jt=En;const Lp={cullArea:null,cullable:!1,cullableChildren:!0};let Wr=0;const cc=500;function Se(...i){Wr!==cc&&(Wr++,Wr===cc?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const xo={_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 $p{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 Bp{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 $p(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 Ae=new Bp;xo.register(Ae);const Rp={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){Mt("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function Dp(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 zp={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)}Dp(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||Mt(jt,"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)}},Fp={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 hc{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 Np{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 Ae.get(s.maskClass,t)}return t}returnMaskEffect(t){Ae.return(t)}}const ja=new Np;Kt.handleByList(bt.MaskEffect,ja._effectClasses);const Op={_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),ja.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=ja.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 hc);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 hc),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},Gp={label:null,get name(){return Mt(jt,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){Mt(jt,"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}},xe=Ae.getPool(Tt),_s=Ae.getPool(We),Wp=new Tt,Hp={getFastGlobalBounds(i,t){t||(t=new We),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=_s.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(Wp).invert()),t.addBounds(s),_s.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),_s.return(s))}};function kd(i,t,e){e.clear();let s,n;return i.parent?t?s=i.parent.worldTransform:(n=xe.get().identity(),s=Ml(i,n)):s=Tt.IDENTITY,Cd(i,e,s,t),n&&xe.return(n),e.isValid||e.set(0,0,0,0),e}function Cd(i,t,e,s){var l,h;if(!i.visible||!i.measurable)return;let n;s?n=i.worldTransform:(i.updateLocalTransform(),n=xe.get(),n.appendFrom(i.localTransform,e));const o=t,r=!!i.effects.length;if(r&&(t=_s.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{const d=i.bounds;d&&!d.isEmpty()&&(t.matrix=n,t.addBounds(d));for(let c=0;c<i.children.length;c++)Cd(i.children[c],t,n,s)}if(r){for(let d=0;d<i.effects.length;d++)(h=(l=i.effects[d]).addBounds)==null||h.call(l,t);o.addBounds(t,Tt.IDENTITY),_s.return(t)}s||xe.return(n)}function Ml(i,t){const e=i.parent;return e&&(Ml(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function Ad(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,d=s*r/255|0,c=n*l/255|0;return(h<<16)+(d<<8)+c}const dc=16777215;function uc(i,t){return i===dc?t:t===dc?i:Ad(i,t)}function or(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const Up={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 Tt,t){if(t)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Ml(this,xe.get().identity());return i.appendFrom(this.localTransform,e),xe.return(e),i},getGlobalTint(i){if(i)return this.renderGroup?or(this.renderGroup.worldColor):this.parentRenderGroup?or(uc(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=uc(t,e.localColor),e=e.parent;return or(t)}};function Ed(i,t,e){return t.clear(),e||(e=Tt.IDENTITY),Md(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function Md(i,t,e,s,n){var h,d;let o;if(n)o=xe.get(),o=e.copyTo(o);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const c=i.localTransform;o=xe.get(),o.appendFrom(c,e)}const r=t,l=!!i.effects.length;if(l&&(t=_s.get().clear()),i.boundsArea)t.addRect(i.boundsArea,o);else{i.renderPipeId&&(t.matrix=o,t.addBounds(i.bounds));const c=i.children;for(let f=0;f<c.length;f++)Md(c[f],t,o,s,!1)}if(l){for(let c=0;c<i.effects.length;c++)(d=(h=i.effects[c]).addLocalBounds)==null||d.call(h,t,s);r.addBounds(t,Tt.IDENTITY),_s.return(t)}xe.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 qp=new Tt,Vp={_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 We});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,qp),i.localBounds},getBounds(i,t){return kd(this,i,t||new We)}},jp={_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}},Yp={_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(Xp))}};function Xp(i,t){return i._zIndex-t._zIndex}const Zp={getGlobalPosition(i=new ye,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(xe.get(),e);return t=s.apply(i,t),xe.return(s),t},toLocal(i,t,e,s){t&&(i=t.toGlobal(i,e,s));const n=this.getGlobalTransform(xe.get(),s);return e=n.applyInverse(i,e),xe.return(n),e}};class Il{constructor(){this.uid=Yt("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 Kp=0;class Qp{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new An(this.textureOptions)}createTexture(t,e,s,n){const o=new He({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:n});return new Bt({source:o,label:`texturePool_${Kp++}`})}getOptimalTexture(t,e,s=1,n,o=!1){let r=Math.ceil(t*s-1e-6),l=Math.ceil(e*s-1e-6);r=Cn(r),l=Cn(l);const h=n?1:0,d=o?1:0,c=(r<<17)+(l<<2)+(d<<1)+h;this._texturePool[c]||(this._texturePool[c]=[]);let f=this._texturePool[c].pop();return f||(f=this.createTexture(r,l,n,o)),f.source._resolution=s,f.source.width=r/s,f.source.height=l/s,f.source.pixelWidth=r,f.source.pixelHeight=l,f.frame.x=0,f.frame.y=0,f.frame.width=t,f.frame.height=e,f.updateUvs(),this._poolKeyHash[f.uid]=c,f}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 Ir=new Qp;xo.register(Ir);class Jp{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new Tt,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 Il,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&&(Ir.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 Tt),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new Tt),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 Tt),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 Hr=new ie(null),Io=new ie(null),Ur=new ie(null,1,1),Po=new ie(null),pc=1,ef=2,qr=4;class Nt extends cs{constructor(t={}){var e,s;super(),this.uid=Yt("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 Tt,this.relativeGroupTransform=new Tt,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ie(this,0,0),this._scale=Ur,this._pivot=Io,this._origin=Po,this._skew=Hr,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){Mt("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),Kt.mixin(Nt,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||Mt(jt,"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=Ae.get(Jp,this),this.groupTransform=Tt.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Ae.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 Tt),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*mp}set angle(t){this.rotation=t*gp}get pivot(){return this._pivot===Io&&(this._pivot=new ie(this,0,0)),this._pivot}set pivot(t){this._pivot===Io&&(this._pivot=new ie(this,0,0),this._origin!==Po&&Se("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===Hr&&(this._skew=new ie(this,0,0)),this._skew}set skew(t){this._skew===Hr&&(this._skew=new ie(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Ur&&(this._scale=new ie(this,1,1)),this._scale}set scale(t){this._scale===Ur&&(this._scale=new ie(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===Po&&(this._origin=new ie(this,0,0)),this._origin}set origin(t){this._origin===Po&&(this._origin=new ie(this,0,0),this._pivot!==Io&&Se("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,d=n._x,c=n._y,f=-o._x,g=-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-(d*e.a+c*e.c)+(f*e.a+g*e.c)-f,e.ty=r._y-(d*e.b+c*e.d)+(f*e.b+g*e.d)-g}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=pc,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Jt.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=pc,this._onUpdate())}get tint(){return or(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ef,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|=qr,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|=qr,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|=qr,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}}Kt.mixin(Nt,zp,Hp,Zp,jp,Vp,Op,Gp,Yp,Lp,Rp,Up,Fp);class Pl extends Nt{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 We(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 d=0;d<h;d++)l[d].collectRenderables(t,e,s);n.blendMode.popBlendMode(t)}}class tn extends Pl{constructor(t=Bt.EMPTY){t instanceof Bt&&(t={texture:t});const{texture:e=Bt.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 ie({_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 Bt?new tn(t):new tn(Bt.from(t,e))}set texture(t){t||(t=Bt.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 _d(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return Mt("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 sf=new We;function Pd(i,t,e){const s=sf;i.measurable=!0,kd(i,e,s),t.addBoundsMask(s),i.measurable=!1}function Ld(i,t,e){const s=_s.get();i.measurable=!0;const n=xe.get().identity(),o=$d(i,e,n);Ed(i,s,o),i.measurable=!1,t.addBoundsMask(s),xe.return(n),_s.return(s)}function $d(i,t,e){return i?(i!==t&&($d(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(Se("Mask bounds, renderable is not inside the root container"),e)}class Bd{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 tn),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||Pd(this.mask,t,e)}addLocalBounds(t,e){Ld(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof tn}}Bd.extension=bt.MaskEffect;class Rd{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"}}Rd.extension=bt.MaskEffect;class Dd{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){Pd(this.mask,t,e)}addLocalBounds(t,e){Ld(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Nt}}Dd.extension=bt.MaskEffect;const nf={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 fc=nf;const Be={get(){return fc},set(i){fc=i}};class zd extends He{constructor(t){t.resource||(t.resource=Be.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"))}}zd.extension=bt.TextureSource;class gr extends He{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}}gr.extension=bt.TextureSource;var vr=(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))(vr||{});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 Fd=class Le{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/Le.targetFPMS,this.elapsedMS=1/Le.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=vr.NORMAL){return this._addListener(new Vr(t,e,s))}addOnce(t,e,s=vr.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*Le.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,Le.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(!Le._shared){const t=Le._shared=new Le;t.autoStart=!0,t._protected=!0}return Le._shared}static get system(){if(!Le._system){const t=Le._system=new Le;t.autoStart=!0,t._protected=!0}return Le._system}};Fd.targetFPMS=.06;let wn=Fd,jr;async function of(){return jr??(jr=(async()=>{var r;const t=Be.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"})()),jr}const Pr=class Nd extends He{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Nd.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=wn.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 of(),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&&(wn.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||(wn.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(wn.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Pr.extension=bt.TextureSource;Pr.defaultOptions={...He.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Pr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let rf=Pr;const gn=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class af{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||Se(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=gn(t);let n;for(let h=0;h<this.parsers.length;h++){const d=this.parsers[h];if(d.test(e)){n=d.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 d=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==d&&Se("[Cache] already has key:",h),this._cache.set(h,o.get(h))})}remove(t){if(!this._cacheMap.has(t)){Se(`[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 vn=new af,Ya=[];Kt.handleByList(bt.TextureSource,Ya);function Od(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n<Ya.length;n++){const o=Ya[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&&vn.has(s))return vn.get(s);const o=new Bt({source:Od(n)});return o.on("destroy",()=>{vn.has(s)&&vn.remove(s)}),t||vn.set(s,o),o}function cf(i,t=!1){return typeof i=="string"?vn.get(i):i instanceof He?new Bt({source:i}):lf(i,t)}Bt.from=cf;He.from=Od;Kt.add(Bd,Rd,Dd,rf,gr,zd,El);var Gd=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Gd||{});function Ue(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Rn(i){return i.split("?")[0].split("#")[0]}function hf(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function df(i,t,e){return i.replace(new RegExp(hf(t),"g"),e)}function uf(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 mo={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){Ue(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(Ue(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Rn(this.toPosix(t??Be.get().getBaseUrl())),n=Rn(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?mo.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(Ue(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=uf(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return Ue(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(Ue(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(Ue(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){Ue(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){Ue(i),t&&Ue(t),i=Rn(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){Ue(i),i=Rn(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){Ue(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Rn(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,d=i.length-1,c=0;for(;d>=n;--d){if(e=i.charCodeAt(d),e===47){if(!h){r=d+1;break}continue}l===-1&&(h=!1,l=d+1),e===46?o===-1?o=d:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||l===-1||c===0||c===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 Wd(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?Wd(i.replace(s[e],l),t,e+1,s,n):n.push(i.replace(s[e],l))}}function pf(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)}),Wd(i,n,0,e,s)}else s.push(i);return s}const mc=i=>!Array.isArray(i);class Hd{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 gn(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&&Se("[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 d=this._createBundleAssetId(t,l);s.push(d),h=[l,d]}else{const d=l.map(c=>this._createBundleAssetId(t,c));s.push(...d),h=[...l,...d]}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)&&Se(`[Resolver] already has key: ${o} overwriting`)},gn(e).forEach(o=>{const{src:r}=o;let{data:l,format:h,loadParser:d,parser:c}=o;const f=gn(r).map(b=>typeof b=="string"?pf(b):Array.isArray(b)?b:[b]),g=this.getAlias(o);Array.isArray(g)?g.forEach(s):s(g);const m=[],v=b=>{const _=this._parsers.find(x=>x.test(b));return{src:b,..._==null?void 0:_.parse(b)}};f.forEach(b=>{b.forEach(_=>{let x={};if(typeof _!="object"?x=v(_):(l=_.data??l,h=_.format??h,(_.loadParser||_.parser)&&(d=_.loadParser??d,c=_.parser??c),x={...v(_.src),..._}),!g)throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);x=this._buildResolvedAsset(x,{aliases:g,data:l,format:h,loadParser:d,parser:c,progressSize:o.progressSize}),m.push(x)})}),g.forEach(b=>{this._assetMap[b]=m})})}resolveBundle(t){const e=mc(t);t=gn(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 d=r[h];l[this._extractAssetIdFromBundle(n,h)]=d}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=mc(t);t=gn(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 d=o.filter(c=>c[l]?c[l]===h:!1);d.length&&(o=d)})}),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=mo.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}}Hd.RETINA_PREFIX=/@([0-9\.]+)x/;function ff(i){return i.split(".").pop().split("?").shift().split("#").shift()}const gc=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Ud=class ro{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof He&&(s={texture:t,data:e});const{texture:n,data:o,cachePrefix:r=""}=s;this.cachePrefix=r,this._texture=n instanceof Bt?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<=ro.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:ro.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,d=null;const c=r.trimmed!==!1&&r.sourceSize?r.sourceSize:r.frame,f=new Xt(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);r.rotated?h=new Xt(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 Xt(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&&(d=new Xt(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 Bt({source:this.textureSource,frame:h,orig:f,trim:d,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*ro.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ro.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=[]}};Ud.BATCH_SIZE=1e3;let vc=Ud;const mf=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function qd(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=mo.dirname(i[0]);t.linkedSheets.forEach((o,r)=>{const l=qd([`${n}/${t.data.meta.related_multi_packs[r]}`],o,!0);Object.assign(s,l)})}return s}const gf={extension:bt.Asset,cache:{test:i=>i instanceof vc,getCacheableAssets:(i,t)=>qd(i,t,!1)},resolver:{extension:{type:bt.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&mf.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Hd.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:bt.LoadParser,priority:Gd.Normal,name:"spritesheetLoader"},async testParse(i,t){return mo.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var f,g;const{texture:s,imageFilename:n,textureOptions:o,cachePrefix:r}=(t==null?void 0:t.data)??{};let l=mo.dirname(t.src);l&&l.lastIndexOf("/")!==l.length-1&&(l+="/");let h;if(s instanceof Bt)h=s;else{const m=gc(l+(n??i.meta.image),t.src);h=(await e.load([{src:m,data:o}]))[m]}const d=new vc({texture:h.source,data:i,cachePrefix:r});await d.parse();const c=(f=i==null?void 0:i.meta)==null?void 0:f.related_multi_packs;if(Array.isArray(c)){const m=[];for(const b of c){if(typeof b!="string")continue;let _=l+b;(g=t.data)!=null&&g.ignoreMultiPack||(_=gc(_,t.src),m.push(e.load({src:_,data:{textureOptions:o,ignoreMultiPack:!0}})))}const v=await Promise.all(m);d.linkedSheets=v,v.forEach(b=>{b.linkedSheets=[d].concat(d.linkedSheets.filter(_=>_!==b))})}return d},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};Kt.add(gf);const Yr=Object.create(null),yc=Object.create(null);function Ll(i,t){let e=yc[i];return e===void 0&&(Yr[t]===void 0&&(Yr[t]=1),yc[i]=e=Yr[t]++),e}let on;function Vd(){return(!on||on!=null&&on.isContextLost())&&(on=Be.get().createCanvas().getContext("webgl",{})),on}let Lo;function vf(){if(!Lo){Lo="mediump";const i=Vd();i&&i.getShaderPrecisionFormat&&(Lo=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return Lo}function yf(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 bf(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 wf(i,t){return t?`#version 300 es
|
|
22
|
+
${i}`:i}const _f={},xf={};function Sf(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?_f:xf;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 Tf(i,t){return t?i.replace("#version 300 es",""):i}const Xr={stripVersion:Tf,ensurePrecision:bf,addProgramDefines:yf,setProgramName:Sf,insertVersion:wf},Dn=Object.create(null),jd=class Xa{constructor(t){t={...Xa.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:vf()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,o=t.vertex;Object.keys(Xr).forEach(r=>{const l=s[r];n=Xr[r](n,l,!0),o=Xr[r](o,l,!1)}),this.fragment=n,this.vertex=o,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Ll(`${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,Dn[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Dn[e]||(Dn[e]=new Xa(t),Dn[e]._cacheKey=e),Dn[e]}};jd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Yd=jd;const bc={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function kf(i){return bc[i]??bc.float32}const Cf={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"},wc=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function _c(i,t){let e;for(;(e=wc.exec(i))!==null;){const s=Cf[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:s,stride:kf(s).stride,offset:0,instance:!1,start:0}}wc.lastIndex=0}function Af(i){return i.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Ef({source:i,entryPoint:t}){const e={},s=Af(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(_c(r,e),Object.keys(e).length===0){const l=r.match(/\(\s*\w+\s*:\s*(\w+)/);if(l){const h=l[1],d=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=s.match(d);c&&_c(c[1],e)}}return e}function Zr(i){var f,g;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+)/,d=(f=i.match(t))==null?void 0:f.map(m=>({group:parseInt(m.match(e)[1],10),binding:parseInt(m.match(s)[1],10),name:m.match(n)[2],isUniform:m.match(n)[1]==="<uniform>",type:m.match(o)[1]}));if(!d)return{groups:[],structs:[]};const c=((g=i.match(r))==null?void 0:g.map(m=>{const v=m.match(h)[1],b=m.match(l).reduce((_,x)=>{const[C,$]=x.split(":");return _[C.trim()]=$.trim(),_},{});return b?{name:v,members:b}:null}).filter(({name:m})=>d.some(v=>v.type===m||v.type.includes(`<${m}>`))))??[];return{groups:d,structs:c}}var Yi=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Yi||{});function Mf({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:Yi.VERTEX|Yi.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Yi.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:Yi.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:Yi.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:Yi.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function If({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 Pf(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 zn=Object.create(null);class Lr{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 d=Zr(e.source);this.structsAndGroups=d}else{const d=Zr(s.source),c=Zr(e.source);this.structsAndGroups=Pf(d,c)}this.layout=n??If(this.structsAndGroups),this.gpuLayout=o??Mf(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=Ll(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Ef(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,zn[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return zn[e]||(zn[e]=new Lr(t),zn[e]._cacheKey=e),zn[e]}}const Xd=["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>"],Lf=Xd.reduce((i,t)=>(i[t]=!0,i),{});function $f(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 Zd=class Kd{constructor(t,e){this._touched=0,this.uid=Yt("uniform"),this._resourceType="uniformGroup",this._resourceId=Yt("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,!Lf[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: ${Xd.join(", ")}`)}o.value??(o.value=$f(o.type,o.size)),s[n]=o.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ll(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Zd.defaultOptions={ubo:!1,isStatic:!1};let Qd=Zd;class rr{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 Za=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.CANVAS=4]="CANVAS",i[i.BOTH=3]="BOTH",i))(Za||{});class $l extends cs{constructor(t){super(),this.uid=Yt("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|=Za.WEBGPU),s&&(r|=Za.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 d in l)for(const c in l[d]){const f=l[d][c];h[f]={group:d,binding:c,name:f}}else if(e&&n&&!l){const d=e.structsAndGroups.groups;l={},d.forEach(c=>{l[c.group]=l[c.group]||{},l[c.group][c.binding]=c.name,h[c.name]=c})}else if(o){n={},l={},e&&e.structsAndGroups.groups.forEach(f=>{l[f.group]=l[f.group]||{},l[f.group][f.binding]=f.name,h[f.name]=f});let d=0;for(const c in o)h[c]||(n[99]||(n[99]=new rr,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:d,name:c},l[99]=l[99]||{},l[99][d]=c,d++);for(const c in o){const f=c;let g=o[c];!g.source&&!g._resourceType&&(g=new Qd(g));const m=h[f];m&&(n[m.group]||(n[m.group]=new rr,this._ownedBindGroups.push(n[m.group])),n[m.group].setResource(g,m.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 rr,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=Lr.from(e)),s&&(r=Yd.from(s)),new $l({gpuProgram:o,glProgram:r,...n})}}const Bf={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},Kr=0,Qr=1,Jr=2,ta=3,ea=4,sa=5,Ka=class Jd{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Kr)}set blend(t){!!(this.data&1<<Kr)!==t&&(this.data^=1<<Kr)}get offsets(){return!!(this.data&1<<Qr)}set offsets(t){!!(this.data&1<<Qr)!==t&&(this.data^=1<<Qr)}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<<Jr)}set culling(t){!!(this.data&1<<Jr)!==t&&(this.data^=1<<Jr)}get depthTest(){return!!(this.data&1<<ta)}set depthTest(t){!!(this.data&1<<ta)!==t&&(this.data^=1<<ta)}get depthMask(){return!!(this.data&1<<sa)}set depthMask(t){!!(this.data&1<<sa)!==t&&(this.data^=1<<sa)}get clockwiseFrontFace(){return!!(this.data&1<<ea)}set clockwiseFrontFace(t){!!(this.data&1<<ea)!==t&&(this.data^=1<<ea)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=Bf[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 Jd;return t.depthTest=!1,t.blend=!0,t}};Ka.default2d=Ka.for2d();let tu=Ka;const Qa=[];Kt.handleByNamedList(bt.Environment,Qa);async function Rf(i){if(!i)for(let t=0;t<Qa.length;t++){const e=Qa[t];if(e.value.test()){await e.value.load();return}}}let Fn;function Df(){if(typeof Fn=="boolean")return Fn;try{Fn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Fn=!1}return Fn}function xc(i,t,e=2){const s=t&&t.length,n=s?t[0]*e:i.length;let o=eu(i,0,n,e,!0);const r=[];if(!o||o.next===o.prev)return r;let l,h,d;if(s&&(o=Gf(i,t,o,e)),i.length>80*e){l=i[0],h=i[1];let c=l,f=h;for(let g=e;g<n;g+=e){const m=i[g],v=i[g+1];m<l&&(l=m),v<h&&(h=v),m>c&&(c=m),v>f&&(f=v)}d=Math.max(c-l,f-h),d=d!==0?32767/d:0}return go(o,r,e,l,h,d,0),r}function eu(i,t,e,s,n){let o;if(n===Qf(i,t,e,s)>0)for(let r=t;r<e;r+=s)o=Sc(r/s|0,i[r],i[r+1],o);else for(let r=e-s;r>=t;r-=s)o=Sc(r/s|0,i[r],i[r+1],o);return o&&Mn(o,o.next)&&(yo(o),o=o.next),o}function en(i,t){if(!i)return i;t||(t=i);let e=i,s;do if(s=!1,!e.steiner&&(Mn(e,e.next)||Ut(e.prev,e,e.next)===0)){if(yo(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function go(i,t,e,s,n,o,r){if(!i)return;!r&&o&&Vf(i,s,n,o);let l=i;for(;i.prev!==i.next;){const h=i.prev,d=i.next;if(o?Ff(i,s,n,o):zf(i)){t.push(h.i,i.i,d.i),yo(i),i=d.next,l=d.next;continue}if(i=d,i===l){r?r===1?(i=Nf(en(i),t),go(i,t,e,s,n,o,2)):r===2&&Of(i,t,e,s,n,o):go(en(i),t,e,s,n,o,1);break}}}function zf(i){const t=i.prev,e=i,s=i.next;if(Ut(t,e,s)>=0)return!1;const n=t.x,o=e.x,r=s.x,l=t.y,h=e.y,d=s.y,c=Math.min(n,o,r),f=Math.min(l,h,d),g=Math.max(n,o,r),m=Math.max(l,h,d);let v=s.next;for(;v!==t;){if(v.x>=c&&v.x<=g&&v.y>=f&&v.y<=m&&ao(n,l,o,h,r,d,v.x,v.y)&&Ut(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function Ff(i,t,e,s){const n=i.prev,o=i,r=i.next;if(Ut(n,o,r)>=0)return!1;const l=n.x,h=o.x,d=r.x,c=n.y,f=o.y,g=r.y,m=Math.min(l,h,d),v=Math.min(c,f,g),b=Math.max(l,h,d),_=Math.max(c,f,g),x=Ja(m,v,t,e,s),C=Ja(b,_,t,e,s);let $=i.prevZ,P=i.nextZ;for(;$&&$.z>=x&&P&&P.z<=C;){if($.x>=m&&$.x<=b&&$.y>=v&&$.y<=_&&$!==n&&$!==r&&ao(l,c,h,f,d,g,$.x,$.y)&&Ut($.prev,$,$.next)>=0||($=$.prevZ,P.x>=m&&P.x<=b&&P.y>=v&&P.y<=_&&P!==n&&P!==r&&ao(l,c,h,f,d,g,P.x,P.y)&&Ut(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;$&&$.z>=x;){if($.x>=m&&$.x<=b&&$.y>=v&&$.y<=_&&$!==n&&$!==r&&ao(l,c,h,f,d,g,$.x,$.y)&&Ut($.prev,$,$.next)>=0)return!1;$=$.prevZ}for(;P&&P.z<=C;){if(P.x>=m&&P.x<=b&&P.y>=v&&P.y<=_&&P!==n&&P!==r&&ao(l,c,h,f,d,g,P.x,P.y)&&Ut(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function Nf(i,t){let e=i;do{const s=e.prev,n=e.next.next;!Mn(s,n)&&iu(s,e,e.next,n)&&vo(s,n)&&vo(n,s)&&(t.push(s.i,e.i,n.i),yo(e),yo(e.next),e=i=n),e=e.next}while(e!==i);return en(e)}function Of(i,t,e,s,n,o){let r=i;do{let l=r.next.next;for(;l!==r.prev;){if(r.i!==l.i&&Xf(r,l)){let h=nu(r,l);r=en(r,r.next),h=en(h,h.next),go(r,t,e,s,n,o,0),go(h,t,e,s,n,o,0);return}l=l.next}r=r.next}while(r!==i)}function Gf(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,d=eu(i,l,h,s,!1);d===d.next&&(d.steiner=!0),n.push(Yf(d))}n.sort(Wf);for(let o=0;o<n.length;o++)e=Hf(n[o],e);return e}function Wf(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 Hf(i,t){const e=Uf(i,t);if(!e)return t;const s=nu(e,i);return en(s,s.next),en(e,e.next)}function Uf(i,t){let e=t;const s=i.x,n=i.y;let o=-1/0,r;if(Mn(i,e))return e;do{if(Mn(i,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const f=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=s&&f>o&&(o=f,r=e.x<e.next.x?e:e.next,f===s))return r}e=e.next}while(e!==t);if(!r)return null;const l=r,h=r.x,d=r.y;let c=1/0;e=r;do{if(s>=e.x&&e.x>=h&&s!==e.x&&su(n<d?s:o,n,h,d,n<d?o:s,n,e.x,e.y)){const f=Math.abs(n-e.y)/(s-e.x);vo(e,i)&&(f<c||f===c&&(e.x>r.x||e.x===r.x&&qf(r,e)))&&(r=e,c=f)}e=e.next}while(e!==l);return r}function qf(i,t){return Ut(i.prev,i,t.prev)<0&&Ut(t.next,i,i.next)<0}function Vf(i,t,e,s){let n=i;do n.z===0&&(n.z=Ja(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,jf(n)}function jf(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 d=0;d<e&&(l++,r=r.nextZ,!!r);d++);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 Ja(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 Yf(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 su(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 ao(i,t,e,s,n,o,r,l){return!(i===r&&t===l)&&su(i,t,e,s,n,o,r,l)}function Xf(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Zf(i,t)&&(vo(i,t)&&vo(t,i)&&Kf(i,t)&&(Ut(i.prev,i,t.prev)||Ut(i,t.prev,t))||Mn(i,t)&&Ut(i.prev,i,i.next)>0&&Ut(t.prev,t,t.next)>0)}function Ut(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Mn(i,t){return i.x===t.x&&i.y===t.y}function iu(i,t,e,s){const n=Bo(Ut(i,t,e)),o=Bo(Ut(i,t,s)),r=Bo(Ut(e,s,i)),l=Bo(Ut(e,s,t));return!!(n!==o&&r!==l||n===0&&$o(i,e,t)||o===0&&$o(i,s,t)||r===0&&$o(e,i,s)||l===0&&$o(e,t,s))}function $o(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 Bo(i){return i>0?1:i<0?-1:0}function Zf(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&&iu(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function vo(i,t){return Ut(i.prev,i,i.next)<0?Ut(i,t,i.next)>=0&&Ut(i,i.prev,t)>=0:Ut(i,t,i.prev)<0||Ut(i,i.next,t)<0}function Kf(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 nu(i,t){const e=tl(i.i,i.x,i.y),s=tl(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 Sc(i,t,e,s){const n=tl(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 yo(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 tl(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Qf(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 Jf=xc.default||xc;var ou=(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))(ou||{});class tm{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,o,r,l,h){const{name:d,items:c}=this;for(let f=0,g=c.length;f<g;f++)c[f][d](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 em=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],ru=class au extends cs{constructor(t){super(),this.tick=0,this.uid=Yt("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=[...em,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Rf(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={...au.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 Nt&&(s={container:s},e&&(Mt(jt,"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:Jt.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=ou.ALL);const{clear:s,clearColor:n,target:o,mipLevel:r,layer:l}=t;Jt.shared.setValue(n??this.background.colorRgba),e.renderTarget.clear(o,s,Jt.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 tm(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)&&xo.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(!Df())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()}};ru.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let lu=ru,Ro;function sm(i){return Ro!==void 0||(Ro=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??lu.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Be.get().getWebGLRenderingContext())return!1;let n=Be.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}})()),Ro}let Do;async function im(i={}){return Do!==void 0||(Do=await(async()=>{const t=Be.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),Do}const Tc=["webgl","webgpu","canvas"];async function nm(i){let t=[];i.preference?(t.push(i.preference),Tc.forEach(o=>{o!==i.preference&&t.push(o)})):t=Tc.slice();let e,s={};for(let o=0;o<t.length;o++){const r=t[o];if(r==="webgpu"&&await im()){const{WebGPURenderer:l}=await co(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-C7n8jUXC.js");return{WebGPURenderer:h}},__vite__mapDeps([3,4,5,2]));e=l,s={...i,...i.webgpu};break}else if(r==="webgl"&&sm(i.failIfMajorPerformanceCaveat??lu.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await co(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-wH1P7d1x.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 co(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer-Bpr11iOT.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 cu="8.17.0";class hu{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,cu)}static destroy(){}}hu.extension=bt.Application;class om{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,cu)}destroy(){this._renderer=null}}om.extension={type:[bt.WebGLSystem,bt.WebGPUSystem],name:"initHook",priority:-10};class du{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}}du.extension=bt.Application;class uu{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,vr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?wn.shared:new wn,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}uu.extension=bt.Application;Kt.add(du);Kt.add(uu);const pu=class el{constructor(...t){this.stage=new Nt,t[0]!==void 0&&Mt(jt,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new Nt),this.renderer=await nm(t),el._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return Mt(jt,"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=el._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}};pu._plugins=[];let fu=pu;Kt.handleByList(bt.Application,fu._plugins);Kt.add(hu);var ia,kc;function rm(){if(kc)return ia;kc=1,ia=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,d){var c=h.toLowerCase();for(d=n(d),c=="m"&&d.length>2&&(r.push([h].concat(d.splice(0,2))),c="l",h=h=="m"?"l":"L");;){if(d.length==i[c])return d.unshift(h),r.push(d);if(d.length<i[c])throw new Error("malformed path data");r.push([h].concat(d.splice(0,i[c])))}}),r}var s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function n(o){var r=o.match(s);return r?r.map(Number):[]}return ia}var am=rm();const lm=pd(am);function cm(i,t){const e=lm(i),s=[];let n=null,o=0,r=0;for(let l=0;l<e.length;l++){const h=e[l],d=h[0],c=h;switch(d){case"M":o=c[1],r=c[2],t.moveTo(o,r);break;case"m":o+=c[1],r+=c[2],t.moveTo(o,r);break;case"H":o=c[1],t.lineTo(o,r);break;case"h":o+=c[1],t.lineTo(o,r);break;case"V":r=c[1],t.lineTo(o,r);break;case"v":r+=c[1],t.lineTo(o,r);break;case"L":o=c[1],r=c[2],t.lineTo(o,r);break;case"l":o+=c[1],r+=c[2],t.lineTo(o,r);break;case"C":o=c[5],r=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],o,r);break;case"c":t.bezierCurveTo(o+c[1],r+c[2],o+c[3],r+c[4],o+c[5],r+c[6]),o+=c[5],r+=c[6];break;case"S":o=c[3],r=c[4],t.bezierCurveToShort(c[1],c[2],o,r);break;case"s":t.bezierCurveToShort(o+c[1],r+c[2],o+c[3],r+c[4]),o+=c[3],r+=c[4];break;case"Q":o=c[3],r=c[4],t.quadraticCurveTo(c[1],c[2],o,r);break;case"q":t.quadraticCurveTo(o+c[1],r+c[2],o+c[3],r+c[4]),o+=c[3],r+=c[4];break;case"T":o=c[1],r=c[2],t.quadraticCurveToShort(o,r);break;case"t":o+=c[1],r+=c[2],t.quadraticCurveToShort(o,r);break;case"A":o=c[6],r=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],o,r);break;case"a":o+=c[6],r+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[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:Se(`Unknown SVG path command: ${d}`)}d!=="Z"&&d!=="z"&&n===null&&(n={startX:o,startY:r},s.push(n))}return t}class Bl{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Bl(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,d=Math.sqrt(o*o+r*r);return d<=l+h&&d>l-(s-h)}getBounds(t){return t||(t=new Xt),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 Rl{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 Rl(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,d=o-h,c=r-h,f=o+l,g=r+l,m=t-this.x,v=e-this.y,b=m*m/(d*d)+v*v/(c*c),_=m*m/(f*f)+v*v/(g*g);return b>1&&_<=1}getBounds(t){return t||(t=new Xt),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 hm(i,t,e,s,n,o){const r=i-e,l=t-s,h=n-e,d=o-s,c=r*h+l*d,f=h*h+d*d;let g=-1;f!==0&&(g=c/f);let m,v;g<0?(m=e,v=s):g>1?(m=n,v=o):(m=e+g*h,v=s+g*d);const b=i-m,_=t-v;return b*b+_*_}let dm,um;class uo{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(dm),s=t.getBounds(um);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 uo(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],d=this.points[r*2],c=this.points[r*2+1];h>e!=c>e&&t<(d-l)*((e-h)/(c-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,d=h.length-(this.closePath?0:2);for(let c=0;c<d;c+=2){const f=h[c],g=h[c+1],m=h[(c+2)%h.length],v=h[(c+3)%h.length],b=hm(t,e,f,g,m,v),_=Math.sign((m-f)*(e-g)-(v-g)*(t-f));if(b<=(_<0?l:r))return!0}return!1}getBounds(t){t||(t=new Xt);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 d=e[l],c=e[l+1];s=d<s?d:s,n=d>n?d:n,o=c<o?c:o,r=c>r?c: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 Mt("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return Mt("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 zo=(i,t,e,s,n,o,r)=>{const l=i-e,h=t-s,d=Math.sqrt(l*l+h*h);return d>=n-o&&d<=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 Xt),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:d}=this,c=s*(1-n),f=s-c,g=o+d,m=r+d,v=l-d*2,b=h-d*2,_=o+l,x=r+h;return(t>=o-c&&t<=o+f||t>=_-f&&t<=_+c)&&e>=m&&e<=m+b||(e>=r-c&&e<=r+f||e>=x-f&&e<=x+c)&&t>=g&&t<=g+v?!0:t<g&&e<m&&zo(t,e,g,m,d,f,c)||t>_-d&&e<m&&zo(t,e,_-d,m,d,f,c)||t>_-d&&e>x-d&&zo(t,e,_-d,x-d,d,f,c)||t<g&&e>x-d&&zo(t,e,g,x-d,d,f,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const mu={};function pm(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 mu[s]||fm(i,t,s,e)}function fm(i,t,e,s){const n={};let o=0;for(let l=0;l<s;l++){const h=l<t?i[l]:Bt.EMPTY.source;n[o++]=h.source,n[o++]=h.style}const r=new rr(n);return mu[e]=r,r}class Cc{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 Ac(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 mm={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var gm=(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))(gm||{});function Ec(i,t){return t.alphaMode==="no-premultiply-alpha"&&mm[i]||i}const vm=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
24
|
+
`);function ym(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 bm(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=vm.replace(/%forloop%/gi,ym(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 rn=null;function wm(){var t;if(rn)return rn;const i=Vd();return rn=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),rn=bm(rn,i),(t=i.getExtension("WEBGL_lose_context"))==null||t.loseContext(),rn}class _m{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 xm{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new _m,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 po=[];let yr=0;xo.register({clear:()=>{if(po.length>0)for(const i of po)i&&i.destroy();po.length=0,yr=0}});function Mc(){return yr>0?po[--yr]:new xm}function Ic(i){i.elements=null,po[yr++]=i}let Nn=0;const gu=class vu{constructor(t){this.uid=Yt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...vu.defaultOptions,...t},t.maxTextures||(Mt("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=wm());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new Cc(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++)Ic(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=Mc(),n=s.textures;n.clear();const o=e[this.elementStart];let r=Ec(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,d=this.attributeBuffer.uint32View,c=this.indexBuffer;let f=this._batchIndexSize,g=this._batchIndexStart,m="startBatch",v=[];const b=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){const x=e[_];e[_]=null;const $=x.texture._source,P=Ec(x.blendMode,$),H=r!==P||l!==x.topology;if($._batchTick===Nn&&!H){x._textureId=$._textureBindLocation,f+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,h,d,x._attributeStart,x._textureId),this.packQuadIndex(c,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,h,d,x._attributeStart,x._textureId),this.packIndex(x,c,x._indexStart,x._attributeStart/this.vertexSize)),x._batch=s,v.push(x);continue}$._batchTick=Nn,(n.count>=b||H)&&(this._finishBatch(s,g,f-g,n,r,l,t,m,v),m="renderBatch",g=f,r=P,l=x.topology,s=Mc(),n=s.textures,n.clear(),v=[],++Nn),x._textureId=$._textureBindLocation=n.count,n.ids[$.uid]=n.count,n.textures[n.count++]=$,x._batch=s,v.push(x),f+=x.indexSize,x.packAsQuad?(this.packQuadAttributes(x,h,d,x._attributeStart,x._textureId),this.packQuadIndex(c,x._indexStart,x._attributeStart/this.vertexSize)):(this.packAttributes(x,h,d,x._attributeStart,x._textureId),this.packIndex(x,c,x._indexStart,x._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,g,f-g,n,r,l,t,m,v),g=f,++Nn),this.elementStart=this.elementSize,this._batchIndexStart=g,this._batchIndexSize=f}_finishBatch(t,e,s,n,o,r,l,h,d){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=d,++Nn,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 Cc(e);Ac(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 Ac(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 d=0;d<r;d++)e[s++]=n+o[d+l]-h}destroy(t={}){var e;if(this.batches!==null){for(let s=0;s<this.batchIndex;s++)Ic(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}}};gu.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let Sm=gu;var ke=(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))(ke||{});class bo extends cs{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=Yt("buffer"),this._resourceType="buffer",this._resourceId=Yt("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&ke.STATIC)}set static(t){t?this.descriptor.usage|=ke.STATIC:this.descriptor.usage&=~ke.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=Yt("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 yu(i,t){if(!(i instanceof bo)){let e=t?ke.INDEX:ke.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=ke.INDEX|ke.COPY_DST):(i=new Float32Array(i),e=ke.VERTEX|ke.COPY_DST)),i=new bo({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function Tm(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 d=n.BYTES_PER_ELEMENT,c=(s.offset||0)/d,f=(s.stride||8)/d;for(let g=c;g<n.length;g+=f){const m=n[g],v=n[g+1];m>l&&(l=m),v>h&&(h=v),m<o&&(o=m),v<r&&(r=v)}return e.minX=o,e.minY=r,e.maxX=l,e.maxY=h,e}function km(i){return(i instanceof bo||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=yu(i.buffer,!1),i}class Cm extends cs{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Yt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new We,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=km(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=yu(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Tm(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 Am=new Float32Array(1),Em=new Uint32Array(1);class Mm extends Cm{constructor(){const e=new bo({data:Am,label:"attribute-batch-buffer",usage:ke.VERTEX|ke.COPY_DST,shrinkToFit:!1}),s=new bo({data:Em,label:"index-batch-buffer",usage:ke.INDEX|ke.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 Pc(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 Se(`${s} placement hook does not exist in shader`)}}const Im=/\{\{(.*?)\}\}/g;function Lc(i){var s;const t={};return(((s=i.match(Im))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function $c(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Bc(i,t,e=!1){const s=[];$c(t,s),i.forEach(l=>{l.header&&$c(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 Rc(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Pm(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function Lm(i){const t=/@.*?\s+/g;return i.replace(t,"")}function $m(i,t){const e=[];Rc(t,e),i.forEach(h=>{h.header&&Rc(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 ${Lm(h)};`).join(`
|
|
30
|
+
`),r=`return VSOutput(
|
|
31
|
+
${e.sort().map(h=>` ${Pm(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 Dc(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 $i=Object.create(null),na=new Map;let Bm=0;function Rm({template:i,bits:t}){const e=bu(i,t);if($i[e])return $i[e];const{vertex:s,fragment:n}=zm(i,t);return $i[e]=wu(s,n,t),$i[e]}function Dm({template:i,bits:t}){const e=bu(i,t);return $i[e]||($i[e]=wu(i.vertex,i.fragment,t)),$i[e]}function zm(i,t){const e=t.map(r=>r.vertex).filter(r=>!!r),s=t.map(r=>r.fragment).filter(r=>!!r);let n=Bc(e,i.vertex,!0);n=$m(e,n);const o=Bc(s,i.fragment,!0);return{vertex:n,fragment:o}}function bu(i,t){return t.map(e=>(na.has(e)||na.set(e,Bm++),na.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function wu(i,t,e){const s=Lc(i),n=Lc(t);return e.forEach(o=>{Pc(o.vertex,s,o.name),Pc(o.fragment,n,o.name)}),{vertex:Dc(i,s),fragment:Dc(t,n)}}const Fm=`
|
|
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
|
+
`,Nm=`
|
|
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
|
+
`,Om=`
|
|
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
|
+
`,Gm=`
|
|
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
|
+
`,Wm={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
|
+
`}},Hm={name:"global-uniforms-bit",vertex:{header:`
|
|
176
|
+
uniform mat3 uProjectionMatrix;
|
|
177
|
+
uniform mat3 uWorldTransformMatrix;
|
|
178
|
+
uniform vec4 uWorldColorAlpha;
|
|
179
|
+
uniform vec2 uResolution;
|
|
180
|
+
`}};function Um({bits:i,name:t}){const e=Rm({template:{fragment:Nm,vertex:Fm},bits:[Wm,...i]});return Lr.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function qm({bits:i,name:t}){return new Yd({name:t,...Dm({template:{vertex:Om,fragment:Gm},bits:[Hm,...i]})})}const Vm={name:"color-bit",vertex:{header:`
|
|
181
|
+
@in aColor: vec4<f32>;
|
|
182
|
+
`,main:`
|
|
183
|
+
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
184
|
+
`}},jm={name:"color-bit",vertex:{header:`
|
|
185
|
+
in vec4 aColor;
|
|
186
|
+
`,main:`
|
|
187
|
+
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
188
|
+
`}},oa={};function Ym(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 Xm(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 Zm(i){return oa[i]||(oa[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
|
+
${Ym(i)}
|
|
204
|
+
`,main:`
|
|
205
|
+
var uvDx = dpdx(vUV);
|
|
206
|
+
var uvDy = dpdy(vUV);
|
|
207
|
+
|
|
208
|
+
${Xm(i)}
|
|
209
|
+
`}}),oa[i]}const ra={};function Km(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 Qm(i){return ra[i]||(ra[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
|
+
${Km(i)}
|
|
229
|
+
`}}),ra[i]}const Jm={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
|
+
`}},tg={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
|
+
`}},zc={};function eg(i){let t=zc[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=zc[i]=new Qd({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class Fc extends $l{constructor(t){const e=qm({name:"batch",bits:[jm,Qm(t),tg]}),s=Um({name:"batch",bits:[Vm,Zm(t),Jm]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:eg(t)}}),this.maxTextures=t}}let On=null;const _u=class xu extends Sm{constructor(t){super(t),this.geometry=new Mm,this.name=xu.extension.name,this.vertexSize=6,On??(On=new Fc(t.maxTextures)),this.shader=On}packAttributes(t,e,s,n,o){const r=o<<16|t.roundPixels&65535,l=t.transform,h=l.a,d=l.b,c=l.c,f=l.d,g=l.tx,m=l.ty,{positions:v,uvs:b}=t,_=t.color,x=t.attributeOffset,C=x+t.attributeSize;for(let $=x;$<C;$++){const P=$*2,H=v[P],R=v[P+1];e[n++]=h*H+c*R+g,e[n++]=f*R+d*H+m,e[n++]=b[P],e[n++]=b[P+1],s[n++]=_,s[n++]=r}}packQuadAttributes(t,e,s,n,o){const r=t.texture,l=t.transform,h=l.a,d=l.b,c=l.c,f=l.d,g=l.tx,m=l.ty,v=t.bounds,b=v.maxX,_=v.minX,x=v.maxY,C=v.minY,$=r.uvs,P=t.color,H=o<<16|t.roundPixels&65535;e[n+0]=h*_+c*C+g,e[n+1]=f*C+d*_+m,e[n+2]=$.x0,e[n+3]=$.y0,s[n+4]=P,s[n+5]=H,e[n+6]=h*b+c*C+g,e[n+7]=f*C+d*b+m,e[n+8]=$.x1,e[n+9]=$.y1,s[n+10]=P,s[n+11]=H,e[n+12]=h*b+c*x+g,e[n+13]=f*x+d*b+m,e[n+14]=$.x2,e[n+15]=$.y2,s[n+16]=P,s[n+17]=H,e[n+18]=h*_+c*x+g,e[n+19]=f*x+d*_+m,e[n+20]=$.x3,e[n+21]=$.y3,s[n+22]=P,s[n+23]=H}_updateMaxTextures(t){this.shader.maxTextures!==t&&(On=new Fc(t),this.shader=On)}destroy(){this.shader=null,super.destroy()}};_u.extension={type:[bt.Batcher],name:"default"};let sg=_u;class So{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 ig(i,t,e,s,n,o,r,l=null){let h=0;e*=t,n*=o;const d=l.a,c=l.b,f=l.c,g=l.d,m=l.tx,v=l.ty;for(;h<r;){const b=i[e],_=i[e+1];s[n]=d*b+f*_+m,s[n+1]=c*b+g*_+v,n+=o,e+=t,h++}}function ng(i,t,e,s){let n=0;for(t*=e;n<s;)i[t]=0,i[t+1]=0,t+=e,n++}function Su(i,t,e,s,n){const o=t.a,r=t.b,l=t.c,h=t.d,d=t.tx,c=t.ty;e||(e=0),s||(s=2),n||(n=i.length/s-e);let f=e*s;for(let g=0;g<n;g++){const m=i[f],v=i[f+1];i[f]=o*m+l*v+d,i[f+1]=r*m+h*v+c,f+=s}}const og=new Tt;class zl{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?Ad(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)||og}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 wo={extension:{type:bt.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,o,r,l;if(i.type==="circle"){const P=i;if(r=l=P.radius,r<=0)return!1;e=P.x,s=P.y,n=o=0}else if(i.type==="ellipse"){const P=i;if(r=P.halfWidth,l=P.halfHeight,r<=0||l<=0)return!1;e=P.x,s=P.y,n=o=0}else{const P=i,H=P.width/2,R=P.height/2;e=P.x+H,s=P.y+R,r=l=Math.max(0,Math.min(P.radius,Math.min(H,R))),n=H-r,o=R-l}if(n<0||o<0)return!1;const h=Math.ceil(2.3*Math.sqrt(r+l)),d=h*8+(n?4:0)+(o?4:0);if(d===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 c=0,f=h*4+(n?2:0)+2,g=f,m=d,v=n+r,b=o,_=e+v,x=e-v,C=s+b;if(t[c++]=_,t[c++]=C,t[--f]=C,t[--f]=x,o){const P=s-b;t[g++]=x,t[g++]=P,t[--m]=P,t[--m]=_}for(let P=1;P<h;P++){const H=Math.PI/2*(P/h),R=n+Math.cos(H)*r,O=o+Math.sin(H)*l,et=e+R,Z=e-R,X=s+O,J=s-O;t[c++]=et,t[c++]=X,t[--f]=X,t[--f]=Z,t[g++]=Z,t[g++]=J,t[--m]=J,t[--m]=et}v=n,b=o+l,_=e+v,x=e-v,C=s+b;const $=s-b;return t[c++]=_,t[c++]=C,t[--m]=$,t[--m]=_,n&&(t[c++]=x,t[c++]=C,t[--m]=$,t[--m]=x),!0},triangulate(i,t,e,s,n,o){if(i.length===0)return;let r=0,l=0;for(let c=0;c<i.length;c+=2)r+=i[c],l+=i[c+1];r/=i.length/2,l/=i.length/2;let h=s;t[h*e]=r,t[h*e+1]=l;const d=h++;for(let c=0;c<i.length;c+=2)t[h*e]=i[c],t[h*e+1]=i[c+1],c>0&&(n[o++]=h,n[o++]=d,n[o++]=h-1),h++;n[o++]=d+1,n[o++]=d,n[o++]=h-1}},rg={...wo,extension:{...wo.extension,name:"ellipse"}},ag={...wo,extension:{...wo.extension,name:"roundedRectangle"}},Tu=1e-4,Nc=1e-4;function lg(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 Oc(i,t,e,s,n,o,r,l){const h=i-e*n,d=t-s*n,c=i+e*o,f=t+s*o;let g,m;r?(g=s,m=-e):(g=-s,m=e);const v=h+g,b=d+m,_=c+g,x=f+m;return l.push(v,b),l.push(_,x),2}function Fi(i,t,e,s,n,o,r,l){const h=e-i,d=s-t;let c=Math.atan2(h,d),f=Math.atan2(n-i,o-t);l&&c<f?c+=Math.PI*2:!l&&c>f&&(f+=Math.PI*2);let g=c;const m=f-c,v=Math.abs(m),b=Math.sqrt(h*h+d*d),_=(15*v*Math.sqrt(b)/Math.PI>>0)+1,x=m/_;if(g+=x,l){r.push(i,t),r.push(e,s);for(let C=1,$=g;C<_;C++,$+=x)r.push(i,t),r.push(i+Math.sin($)*b,t+Math.cos($)*b);r.push(i,t),r.push(n,o)}else{r.push(e,s),r.push(i,t);for(let C=1,$=g;C<_;C++,$+=x)r.push(i+Math.sin($)*b,t+Math.cos($)*b),r.push(i,t);r.push(n,o),r.push(i,t)}return _*2}function cg(i,t,e,s,n,o){const r=Tu;if(i.length===0)return;const l=t;let h=l.alignment;if(t.alignment!==.5){let lt=lg(i);h=(h-.5)*lt+.5}const d=new ye(i[0],i[1]),c=new ye(i[i.length-2],i[i.length-1]),f=s,g=Math.abs(d.x-c.x)<r&&Math.abs(d.y-c.y)<r;if(f){i=i.slice(),g&&(i.pop(),i.pop(),c.set(i[i.length-2],i[i.length-1]));const lt=(d.x+c.x)*.5,wt=(c.y+d.y)*.5;i.unshift(lt,wt),i.push(lt,wt)}const m=n,v=i.length/2;let b=i.length;const _=m.length/2,x=l.width/2,C=x*x,$=l.miterLimit*l.miterLimit;let P=i[0],H=i[1],R=i[2],O=i[3],et=0,Z=0,X=-(H-O),J=P-R,st=0,it=0,ht=Math.sqrt(X*X+J*J);X/=ht,J/=ht,X*=x,J*=x;const Dt=h,nt=(1-Dt)*2,rt=Dt*2;f||(l.cap==="round"?b+=Fi(P-X*(nt-rt)*.5,H-J*(nt-rt)*.5,P-X*nt,H-J*nt,P+X*rt,H+J*rt,m,!0)+2:l.cap==="square"&&(b+=Oc(P,H,X,J,nt,rt,!0,m))),m.push(P-X*nt,H-J*nt),m.push(P+X*rt,H+J*rt);for(let lt=1;lt<v-1;++lt){P=i[(lt-1)*2],H=i[(lt-1)*2+1],R=i[lt*2],O=i[lt*2+1],et=i[(lt+1)*2],Z=i[(lt+1)*2+1],X=-(H-O),J=P-R,ht=Math.sqrt(X*X+J*J),X/=ht,J/=ht,X*=x,J*=x,st=-(O-Z),it=R-et,ht=Math.sqrt(st*st+it*it),st/=ht,it/=ht,st*=x,it*=x;const wt=R-P,zt=H-O,_t=R-et,pt=Z-O,Wt=wt*_t+zt*pt,Ft=zt*_t-pt*wt,ae=Ft<0;if(Math.abs(Ft)<.001*Math.abs(Wt)){m.push(R-X*nt,O-J*nt),m.push(R+X*rt,O+J*rt),Wt>=0&&(l.join==="round"?b+=Fi(R,O,R-X*nt,O-J*nt,R-st*nt,O-it*nt,m,!1)+4:b+=2,m.push(R-st*rt,O-it*rt),m.push(R+st*nt,O+it*nt));continue}const qt=(-X+P)*(-J+O)-(-X+R)*(-J+H),Te=(-st+et)*(-it+O)-(-st+R)*(-it+Z),Ee=(wt*Te-_t*qt)/Ft,Xe=(pt*qt-zt*Te)/Ft,hs=(Ee-R)*(Ee-R)+(Xe-O)*(Xe-O),Ze=R+(Ee-R)*nt,ds=O+(Xe-O)*nt,ee=R-(Ee-R)*rt,Ke=O-(Xe-O)*rt,To=Math.min(wt*wt+zt*zt,_t*_t+pt*pt),Pn=ae?nt:rt,Ln=To+Pn*Pn*C;hs<=Ln?l.join==="bevel"||hs/C>$?(ae?(m.push(Ze,ds),m.push(R+X*rt,O+J*rt),m.push(Ze,ds),m.push(R+st*rt,O+it*rt)):(m.push(R-X*nt,O-J*nt),m.push(ee,Ke),m.push(R-st*nt,O-it*nt),m.push(ee,Ke)),b+=2):l.join==="round"?ae?(m.push(Ze,ds),m.push(R+X*rt,O+J*rt),b+=Fi(R,O,R+X*rt,O+J*rt,R+st*rt,O+it*rt,m,!0)+4,m.push(Ze,ds),m.push(R+st*rt,O+it*rt)):(m.push(R-X*nt,O-J*nt),m.push(ee,Ke),b+=Fi(R,O,R-X*nt,O-J*nt,R-st*nt,O-it*nt,m,!1)+4,m.push(R-st*nt,O-it*nt),m.push(ee,Ke)):(m.push(Ze,ds),m.push(ee,Ke)):(m.push(R-X*nt,O-J*nt),m.push(R+X*rt,O+J*rt),l.join==="round"?ae?b+=Fi(R,O,R+X*rt,O+J*rt,R+st*rt,O+it*rt,m,!0)+2:b+=Fi(R,O,R-X*nt,O-J*nt,R-st*nt,O-it*nt,m,!1)+2:l.join==="miter"&&hs/C<=$&&(ae?(m.push(ee,Ke),m.push(ee,Ke)):(m.push(Ze,ds),m.push(Ze,ds)),b+=2),m.push(R-st*nt,O-it*nt),m.push(R+st*rt,O+it*rt),b+=2)}P=i[(v-2)*2],H=i[(v-2)*2+1],R=i[(v-1)*2],O=i[(v-1)*2+1],X=-(H-O),J=P-R,ht=Math.sqrt(X*X+J*J),X/=ht,J/=ht,X*=x,J*=x,m.push(R-X*nt,O-J*nt),m.push(R+X*rt,O+J*rt),f||(l.cap==="round"?b+=Fi(R-X*(nt-rt)*.5,O-J*(nt-rt)*.5,R-X*nt,O-J*nt,R+X*rt,O+J*rt,m,!1)+2:l.cap==="square"&&(b+=Oc(R,O,X,J,nt,rt,!1,m)));const Ot=Nc*Nc;for(let lt=_;lt<b+_-2;++lt)P=m[lt*2],H=m[lt*2+1],R=m[(lt+1)*2],O=m[(lt+1)*2+1],et=m[(lt+2)*2],Z=m[(lt+2)*2+1],!(Math.abs(P*(O-Z)+R*(Z-H)+et*(H-O))<Ot)&&o.push(lt,lt+1,lt+2)}function hg(i,t,e,s){const n=Tu;if(i.length===0)return;const o=i[0],r=i[1],l=i[i.length-2],h=i[i.length-1],d=t||Math.abs(o-l)<n&&Math.abs(r-h)<n,c=e,f=i.length/2,g=c.length/2;for(let m=0;m<f;m++)c.push(i[m*2]),c.push(i[m*2+1]);for(let m=0;m<f-1;m++)s.push(g+m,g+m+1);d&&s.push(g+f-1,g)}function ku(i,t,e,s,n,o,r){const l=Jf(i,t,2);if(!l)return;for(let d=0;d<l.length;d+=3)o[r++]=l[d]+n,o[r++]=l[d+1]+n,o[r++]=l[d+2]+n;let h=n*s;for(let d=0;d<i.length;d+=2)e[h]=i[d],e[h+1]=i[d+1],h+=s}const dg=[],ug={extension:{type:bt.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){ku(i,dg,t,e,s,n,o)}},pg={extension:{type:bt.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}},fg={extension:{type:bt.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}},Gc=[{offset:0,color:"white"},{offset:1,color:"black"}],Fl=class sl{constructor(...t){this.uid=Yt("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=mg(t);e={...e.type==="radial"?sl.defaultRadialOptions:sl.defaultLinearOptions,...gd(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:Jt.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 _=t;t=s,s=_,o*=-1}if(r<0){const _=e;e=n,n=_,r*=-1}}const h=this.colorStops.length?this.colorStops:Gc,d=this._textureSize,{canvas:c,context:f}=Hc(d,1),g=l?f.createLinearGradient(this._textureSize,0,0,0):f.createLinearGradient(0,0,this._textureSize,0);Wc(g,h),f.fillStyle=g,f.fillRect(0,0,d,1),this.texture=new Bt({source:new gr({resource:c,addressMode:this._wrapMode})});const m=Math.sqrt(o*o+r*r),v=Math.atan2(r,o),b=new Tt;b.scale(m/d,1),b.rotate(v),b.translate(t,e),this.textureSpace==="local"&&b.scale(d,d),this.transform=b}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Gc,e=this._textureSize,{canvas:s,context:n}=Hc(e,e),{x:o,y:r}=this.center,{x:l,y:h}=this.outerCenter,d=this.innerRadius,c=this.outerRadius,f=l-c,g=h-c,m=e/(c*2),v=(o-f)*m,b=(r-g)*m,_=n.createRadialGradient(v,b,d*m,(l-f)*m,(h-g)*m,c*m);Wc(_,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=_,n.translate(v,b),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-v,-b),n.fillRect(0,0,e,e),this.texture=new Bt({source:new gr({resource:s,addressMode:this._wrapMode})});const x=new Tt;x.scale(1/m,1/m),x.translate(f,g),this.textureSpace==="local"&&x.scale(e,e),this.transform=x}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 ks=Fl;function Wc(i,t){for(let e=0;e<t.length;e++){const s=t[e];i.addColorStop(s.offset,s.color)}}function Hc(i,t){const e=Be.get().createCanvas(i,t),s=e.getContext("2d");return{canvas:e,context:s}}function mg(i){let t=i[0]??{};return(typeof t=="number"||i[1])&&(Mt("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]??ks.defaultLinearOptions.textureSize}),t}const gg=new Tt,vg=new Xt;function yg(i,t,e,s){const n=t.matrix?i.copyFrom(t.matrix).invert():i.identity();if(t.textureSpace==="local"){const r=e.getBounds(vg);t.width&&r.pad(t.width);const{x:l,y:h}=r,d=1/r.width,c=1/r.height,f=-l*d,g=-h*c,m=n.a,v=n.b,b=n.c,_=n.d;n.a*=d,n.b*=d,n.c*=c,n.d*=c,n.tx=f*m+g*b+n.tx,n.ty=f*v+g*_+n.ty}else n.translate(t.texture.frame.x,t.texture.frame.y),n.scale(1/t.texture.source.width,1/t.texture.source.height);const o=t.texture.source.style;return!(t.fill instanceof ks)&&o.addressMode==="clamp-to-edge"&&(o.addressMode="repeat",o.update()),s&&n.append(gg.copyFrom(s).invert()),n}const $r={};Kt.handleByMap(bt.ShapeBuilder,$r);Kt.add(pg,ug,fg,wo,rg,ag);const bg=new Xt,wg=new Tt;function _g(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")xg(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,d=o.data.hole;r&&d&&Uc(d.shapePath,h,!0,s,e),d&&(l.shapePrimitives[l.shapePrimitives.length-1].holes=d.shapePath.shapePrimitives),Uc(l,h,r,s,e)}}}function xg(i,t,e){const s=[],n=$r.rectangle,o=bg;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:d}=e,c=d.length,f=l.length/2;r&&Su(s,r),n.triangulate(s,l,2,f,d,c);const g=i.image,m=g.uvs;h.push(m.x0,m.y0,m.x1,m.y1,m.x3,m.y3,m.x2,m.y2);const v=Ae.get(zl);v.indexOffset=c,v.indexSize=d.length-c,v.attributeOffset=f,v.attributeSize=l.length/2-f,v.baseColor=i.style,v.alpha=i.alpha,v.texture=g,v.geometryData=e,t.push(v)}function Uc(i,t,e,s,n){const{vertices:o,uvs:r,indices:l}=n;i.shapePrimitives.forEach(({shape:h,transform:d,holes:c})=>{const f=[],g=$r[h.type];if(!g.build(h,f))return;const m=l.length,v=o.length/2;let b="triangle-list";if(d&&Su(f,d),e){const $=h.closePath??!0,P=t;P.pixelLine?(hg(f,$,o,l),b="line-list"):cg(f,P,!1,$,o,l)}else if(c){const $=[],P=f.slice();Sg(c).forEach(R=>{$.push(P.length/2),P.push(...R)}),ku(P,$,o,2,v,l,m)}else g.triangulate(f,o,2,v,l,m);const _=r.length/2,x=t.texture;if(x!==Bt.WHITE){const $=yg(wg,t,h,d);ig(o,2,v,r,_,2,o.length/2-v,$)}else ng(r,_,2,o.length/2-v);const C=Ae.get(zl);C.indexOffset=m,C.indexSize=l.length-m,C.attributeOffset=v,C.attributeSize=o.length/2-v,C.baseColor=t.color,C.alpha=t.alpha,C.texture=x,C.geometryData=n,C.topology=b,s.push(C)})}function Sg(i){const t=[];for(let e=0;e<i.length;e++){const s=i[e].shape,n=[];$r[s.type].build(s,n)&&t.push(n)}return t}class Tg{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{Ae.return(t)}),this.graphicsData&&Ae.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 kg{constructor(){this.instructions=new Il}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new sg({maxTextures:e}),this.instructions.reset()}get geometry(){return Mt(wp,"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 Nl=class il{constructor(t){this._renderer=t,this._managedContexts=new So({renderer:t,type:"resource",name:"graphicsContext"})}init(t){il.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??il.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(),_g(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=Ae.get(kg,{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 f=0;f<n.length;f++)n[f].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(r),h.ensureIndexBuffer(l),h.begin();for(let f=0;f<n.length;f++){const g=n[f];h.add(g)}h.finish(e.instructions);const d=h.geometry;d.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,!0),d.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,!0);const c=h.batches;for(let f=0;f<c.length;f++){const g=c[f];g.bindGroup=pm(g.textures.textures,g.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new Tg;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Nl.extension={type:[bt.WebGLSystem,bt.WebGPUSystem],name:"graphicsContext"};Nl.defaultOptions={bezierSmoothness:.5};let Ol=Nl;const Cg=8,Fo=11920929e-14,Ag=1;function Cu(i,t,e,s,n,o,r,l,h,d){const f=Math.min(.99,Math.max(0,d??Ol.defaultOptions.bezierSmoothness));let g=(Ag-f)/1;return g*=g,Eg(t,e,s,n,o,r,l,h,i,g),i}function Eg(i,t,e,s,n,o,r,l,h,d){nl(i,t,e,s,n,o,r,l,h,d,0),h.push(r,l)}function nl(i,t,e,s,n,o,r,l,h,d,c){if(c>Cg)return;const f=(i+e)/2,g=(t+s)/2,m=(e+n)/2,v=(s+o)/2,b=(n+r)/2,_=(o+l)/2,x=(f+m)/2,C=(g+v)/2,$=(m+b)/2,P=(v+_)/2,H=(x+$)/2,R=(C+P)/2;if(c>0){let O=r-i,et=l-t;const Z=Math.abs((e-r)*et-(s-l)*O),X=Math.abs((n-r)*et-(o-l)*O);if(Z>Fo&&X>Fo){if((Z+X)*(Z+X)<=d*(O*O+et*et)){h.push(H,R);return}}else if(Z>Fo){if(Z*Z<=d*(O*O+et*et)){h.push(H,R);return}}else if(X>Fo){if(X*X<=d*(O*O+et*et)){h.push(H,R);return}}else if(O=H-(i+r)/2,et=R-(t+l)/2,O*O+et*et<=d){h.push(H,R);return}}nl(i,t,f,g,x,C,H,R,h,d,c+1),nl(H,R,$,P,b,_,r,l,h,d,c+1)}const Mg=8,Ig=11920929e-14,Pg=1;function Lg(i,t,e,s,n,o,r,l){const d=Math.min(.99,Math.max(0,l??Ol.defaultOptions.bezierSmoothness));let c=(Pg-d)/1;return c*=c,$g(t,e,s,n,o,r,i,c),i}function $g(i,t,e,s,n,o,r,l){ol(r,i,t,e,s,n,o,l,0),r.push(n,o)}function ol(i,t,e,s,n,o,r,l,h){if(h>Mg)return;const d=(t+s)/2,c=(e+n)/2,f=(s+o)/2,g=(n+r)/2,m=(d+f)/2,v=(c+g)/2;let b=o-t,_=r-e;const x=Math.abs((s-o)*_-(n-r)*b);if(x>Ig){if(x*x<=l*(b*b+_*_)){i.push(m,v);return}}else if(b=m-(t+o)/2,_=v-(e+r)/2,b*b+_*_<=l){i.push(m,v);return}ol(i,t,e,d,c,m,v,l,h+1),ol(i,m,v,f,g,o,r,l,h+1)}function Au(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 d=h/l,c=n;d*=r?-1:1;for(let f=0;f<l+1;f++){const g=Math.cos(c),m=Math.sin(c),v=t+g*s,b=e+m*s;i.push(v,b),c+=d}}function Bg(i,t,e,s,n,o){const r=i[i.length-2],h=i[i.length-1]-e,d=r-t,c=n-e,f=s-t,g=Math.abs(h*f-d*c);if(g<1e-8||o===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const m=h*h+d*d,v=c*c+f*f,b=h*c+d*f,_=o*Math.sqrt(m)/g,x=o*Math.sqrt(v)/g,C=_*b/m,$=x*b/v,P=_*f+x*d,H=_*c+x*h,R=d*(x+C),O=h*(x+C),et=f*(_+$),Z=c*(_+$),X=Math.atan2(O-H,R-P),J=Math.atan2(Z-H,et-P);Au(i,P+t,H+e,o,X,J,d*c>f*h)}const fo=Math.PI*2,aa={centerX:0,centerY:0,ang1:0,ang2:0},la=({x:i,y:t},e,s,n,o,r,l,h)=>{i*=e,t*=s;const d=n*i-o*t,c=o*i+n*t;return h.x=d+r,h.y=c+l,h};function Rg(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 qc=(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)},Dg=(i,t,e,s,n,o,r,l,h,d,c,f,g)=>{const m=Math.pow(n,2),v=Math.pow(o,2),b=Math.pow(c,2),_=Math.pow(f,2);let x=m*v-m*_-v*b;x<0&&(x=0),x/=m*_+v*b,x=Math.sqrt(x)*(r===l?-1:1);const C=x*n/o*f,$=x*-o/n*c,P=d*C-h*$+(i+e)/2,H=h*C+d*$+(t+s)/2,R=(c-C)/n,O=(f-$)/o,et=(-c-C)/n,Z=(-f-$)/o,X=qc(1,0,R,O);let J=qc(R,O,et,Z);l===0&&J>0&&(J-=fo),l===1&&J<0&&(J+=fo),g.centerX=P,g.centerY=H,g.ang1=X,g.ang2=J};function zg(i,t,e,s,n,o,r,l=0,h=0,d=0){if(o===0||r===0)return;const c=Math.sin(l*fo/360),f=Math.cos(l*fo/360),g=f*(t-s)/2+c*(e-n)/2,m=-c*(t-s)/2+f*(e-n)/2;if(g===0&&m===0)return;o=Math.abs(o),r=Math.abs(r);const v=Math.pow(g,2)/Math.pow(o,2)+Math.pow(m,2)/Math.pow(r,2);v>1&&(o*=Math.sqrt(v),r*=Math.sqrt(v)),Dg(t,e,s,n,o,r,h,d,c,f,g,m,aa);let{ang1:b,ang2:_}=aa;const{centerX:x,centerY:C}=aa;let $=Math.abs(_)/(fo/4);Math.abs(1-$)<1e-7&&($=1);const P=Math.max(Math.ceil($),1);_/=P;let H=i[i.length-2],R=i[i.length-1];const O={x:0,y:0};for(let et=0;et<P;et++){const Z=Rg(b,_),{x:X,y:J}=la(Z[0],o,r,f,c,x,C,O),{x:st,y:it}=la(Z[1],o,r,f,c,x,C,O),{x:ht,y:Dt}=la(Z[2],o,r,f,c,x,C,O);Cu(i,H,R,X,J,st,it,ht,Dt),H=ht,R=Dt,b+=_}}function Fg(i,t,e){const s=(r,l)=>{const h=l.x-r.x,d=l.y-r.y,c=Math.sqrt(h*h+d*d),f=h/c,g=d/c;return{len:c,nx:f,ny:g}},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 d=t[(r+1)%t.length],c=s(l,o),f=s(l,d);if(c.len<1e-4||f.len<1e-4){n(r,l),o=l;continue}let g=Math.asin(c.nx*f.ny-c.ny*f.nx),m=1,v=!1;c.nx*f.nx-c.ny*-f.ny<0?g<0?g=Math.PI+g:(g=Math.PI-g,m=-1,v=!0):g>0&&(m=-1,v=!0);const b=g/2;let _,x=Math.abs(Math.cos(b)*h/Math.sin(b));x>Math.min(c.len/2,f.len/2)?(x=Math.min(c.len/2,f.len/2),_=Math.abs(x*Math.sin(b)/Math.cos(b))):_=h;const C=l.x+f.nx*x+-f.ny*_*m,$=l.y+f.ny*x+f.nx*_*m,P=Math.atan2(c.ny,c.nx)+Math.PI/2*m,H=Math.atan2(f.ny,f.nx)-Math.PI/2*m;r===0&&i.moveTo(C+Math.cos(P)*_,$+Math.sin(P)*_),i.arc(C,$,_,P,H,v),o=l}}function Ng(i,t,e,s){const n=(l,h)=>Math.sqrt((l.x-h.x)**2+(l.y-h.y)**2),o=(l,h,d)=>({x:l.x+(h.x-l.x)*d,y:l.y+(h.y-l.y)*d}),r=t.length;for(let l=0;l<r;l++){const h=t[(l+1)%r],d=h.radius??e;if(d<=0){l===0?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y);continue}const c=t[l],f=t[(l+2)%r],g=n(c,h);let m;if(g<1e-4)m=h;else{const _=Math.min(g/2,d);m=o(h,c,_/g)}const v=n(f,h);let b;if(v<1e-4)b=h;else{const _=Math.min(v/2,d);b=o(h,f,_/v)}l===0?i.moveTo(m.x,m.y):i.lineTo(m.x,m.y),i.quadraticCurveTo(h.x,h.y,b.x,b.y,s)}}const Og=new Xt;class Gg{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new We,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 Au(l,t,e,s,n,o,r),this}arcTo(t,e,s,n,o){this._ensurePoly();const r=this._currentPoly.points;return Bg(r,t,e,s,n,o),this}arcToSvg(t,e,s,n,o,r,l){const h=this._currentPoly.points;return zg(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 Cu(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 Lg(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,d=o==null?void 0:o.shape;d&&d.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 Xt(t,e,s,n),o),this}circle(t,e,s,n){return this.drawShape(new Bl(t,e,s),n),this}poly(t,e,s){const n=new uo(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,d=[];for(let c=0;c<n;c++){const f=l-c*h;d.push(t+s*Math.cos(f),e+s*Math.sin(f))}return this.poly(d,!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 d=-1*Math.PI/2+r,c=Math.PI*2/n,f=(n-2)*Math.PI/n/2;for(let g=0;g<n;g++){const m=g*c+d,v=t+s*Math.cos(m),b=e+s*Math.sin(m),_=m+Math.PI+f,x=m-Math.PI-f,C=v+o*Math.cos(_),$=b+o*Math.sin(_),P=v+o*Math.cos(x),H=b+o*Math.sin(x);g===0?this.moveTo(C,$):this.lineTo(C,$),this.quadraticCurveTo(v,b,P,H,l)}return this.closePath()}roundShape(t,e,s=!1,n){return t.length<3?this:(s?Ng(this,t,e,n):Fg(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,d=e+n,c=l<0?-l:0,f=Math.abs(l);return this.moveTo(t,e+f).arcTo(t+c,e+c,t+f,e,f).lineTo(h-f,e).arcTo(h-c,e+c,h,e+f,f).lineTo(h,d-f).arcTo(h-c,d-c,t+s-f,d,f).lineTo(t+f,d).arcTo(t+c,d-c,t,d-f,f).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,d=e+n,c=[t+l,e,h-l,e,h,e+l,h,d-l,h-l,d,t+l,d,t,d-l,t,e+l];for(let f=c.length-1;f>=2;f-=2)c[f]===c[f-2]&&c[f-1]===c[f-3]&&c.splice(f-1,2);return this.poly(c,!0,r)}ellipse(t,e,s,n,o){return this.drawShape(new Rl(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 uo,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 uo,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(Og);n.transform?t.addRect(o,n.transform):t.addRect(o)}return t}}class xs{constructor(t,e=!1){this.instructions=[],this.uid=Yt("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?cm(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Gg(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(ye.shared);let h=0,d=0;if(!r||r.action!=="bezierCurveTo")h=l.x,d=l.y;else{h=r.data[2],d=r.data[3];const c=l.x,f=l.y;h=c+(c-h),d=f+(f-d)}return this.instructions.push({action:"bezierCurveTo",data:[h,d,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(ye.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,d=o.y;r=h+(h-r),l=d+(d-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,d=s*2,c=Math.PI*2/d,f=[];for(let g=0;g<d;g++){const m=g%2?o:n,v=g*c+h;f.push(t+m*Math.cos(v),e+m*Math.sin(v))}return this.poly(f,!0,l),this}clone(t=!1){const e=new xs;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,d=0,c=0,f=0,g=0,m=0,v=0,b=0;for(let _=0;_<this.instructions.length;_++){const x=this.instructions[_],C=x.data;switch(x.action){case"moveTo":case"lineTo":h=C[0],d=C[1],C[0]=e*h+n*d+r,C[1]=s*h+o*d+l;break;case"bezierCurveTo":c=C[0],f=C[1],g=C[2],m=C[3],h=C[4],d=C[5],C[0]=e*c+n*f+r,C[1]=s*c+o*f+l,C[2]=e*g+n*m+r,C[3]=s*g+o*m+l,C[4]=e*h+n*d+r,C[5]=s*h+o*d+l;break;case"quadraticCurveTo":c=C[0],f=C[1],h=C[2],d=C[3],C[0]=e*c+n*f+r,C[1]=s*c+o*f+l,C[2]=e*h+n*d+r,C[3]=s*h+o*d+l;break;case"arcToSvg":h=C[5],d=C[6],v=C[0],b=C[1],C[0]=e*v+n*b,C[1]=s*v+o*b,C[5]=e*h+n*d+r,C[6]=s*h+o*d+l;break;case"circle":C[4]=Gn(C[3],t);break;case"rect":C[4]=Gn(C[4],t);break;case"ellipse":C[8]=Gn(C[8],t);break;case"roundRect":C[5]=Gn(C[5],t);break;case"addPath":C[0].transform(t);break;case"poly":C[2]=Gn(C[2],t);break;default:Se("unknown transform action",x.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,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 Gn(i,t){return i?i.prepend(t):t.clone()}function Vt(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function Wg(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]=Hg(r);break;case"radialgradient":t.defs[r.id]=Ug();break}}}}function Hg(i){const t=Vt(i,"x1",0),e=Vt(i,"y1",0),s=Vt(i,"x2",1),n=Vt(i,"y2",0),o=i.getAttribute("gradientUnits")||"objectBoundingBox",r=new ks(t,e,s,n,o==="objectBoundingBox"?"local":"global");for(let l=0;l<i.children.length;l++){const h=i.children[l],d=Vt(h,"offset",0),c=Jt.shared.setValue(h.getAttribute("stop-color")).toNumber();r.addColorStop(d,c)}return r}function Ug(i){return Se("[SVG Parser] Radial gradients are not yet supported"),new ks(0,0,1,0)}function Vc(i){const t=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const jc={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 jc){const l=i.getAttribute(r);l&&Yc(t,o,r,l.trim())}if(e){const r=e.split(";");for(let l=0;l<r.length;l++){const h=r[l].trim(),[d,c]=h.split(":");jc[d]&&Yc(t,o,d,c.trim())}}return{strokeStyle:o.useStroke?s:null,fillStyle:o.useFill?n:null,useFill:o.useFill,useStroke:o.useStroke}}function Yc(i,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const n=Vc(s);t.strokeStyle.fill=i.defs[n]}else t.strokeStyle.color=Jt.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=Vc(s);t.fillStyle.fill=i.defs[n]}else t.fillStyle.color=Jt.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 qg(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 Vg(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function jg(i){const t=i.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],n=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(s.push(e[c]),n.push(e[c+1]));if(s.length===0||n.length===0)return 0;const o=Math.min(...s),r=Math.max(...s),l=Math.min(...n),h=Math.max(...n);return(r-o)*(h-l)}function Xc(i,t){const e=new xs(i,!1);for(const s of e.instructions)t.instructions.push(s)}function Yg(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 xs};Wg(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"&&Mu(l,e,n,o)}return t}function Mu(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,d,c,f,g,m,v,b,_,x,C,$,P,H,R,O,et;switch(i.nodeName.toLowerCase()){case"path":{H=i.getAttribute("d");const Z=i.getAttribute("fill-rule"),X=Vg(H),J=Z==="evenodd",st=X.length>1;if(J&&st){const ht=X.map(nt=>({path:nt,area:jg(nt)}));if(ht.sort((nt,rt)=>rt.area-nt.area),X.length>3||!qg(ht))for(let nt=0;nt<ht.length;nt++){const rt=ht[nt],Ot=nt===0;t.context.beginPath();const lt=new xs(void 0,!0);Xc(rt.path,lt),t.context.path(lt),Ot?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let nt=0;nt<ht.length;nt++){const rt=ht[nt],Ot=nt%2===1;t.context.beginPath();const lt=new xs(void 0,!0);Xc(rt.path,lt),t.context.path(lt),Ot?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const ht=Z?Z==="evenodd":!0;R=new xs(H,ht),t.context.path(R),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":v=Vt(i,"cx",0),b=Vt(i,"cy",0),_=Vt(i,"r",0),t.context.ellipse(v,b,_,_),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":h=Vt(i,"x",0),d=Vt(i,"y",0),O=Vt(i,"width",0),et=Vt(i,"height",0),x=Vt(i,"rx",0),C=Vt(i,"ry",0),x||C?t.context.roundRect(h,d,O,et,x||C):t.context.rect(h,d,O,et),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":v=Vt(i,"cx",0),b=Vt(i,"cy",0),x=Vt(i,"rx",0),C=Vt(i,"ry",0),t.context.beginPath(),t.context.ellipse(v,b,x,C),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"line":c=Vt(i,"x1",0),f=Vt(i,"y1",0),g=Vt(i,"x2",0),m=Vt(i,"y2",0),t.context.beginPath(),t.context.moveTo(c,f),t.context.lineTo(g,m),s&&t.context.stroke(s);break;case"polygon":P=i.getAttribute("points"),$=P.match(/-?\d+/g).map(Z=>parseInt(Z,10)),t.context.poly($,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":P=i.getAttribute("points"),$=P.match(/-?\d+/g).map(Z=>parseInt(Z,10)),t.context.poly($,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{Se(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}l&&(e=null);for(let Z=0;Z<n.length;Z++)Mu(n[Z],t,e,s)}const Zc={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 Br{constructor(t,e){this.uid=Yt("fillPattern"),this._tick=0,this.transform=new Tt,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Zc[e].addressModeU,t.source.style.addressModeV=Zc[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 Xg(i){return Jt.isColorLike(i)}function Kc(i){return i instanceof Br}function Qc(i){return i instanceof ks}function Zg(i){return i instanceof Bt}function Kg(i,t,e){const s=Jt.shared.setValue(t??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=Bt.WHITE,{...e,...i}}function Qg(i,t,e){return i.texture=t,{...e,...i}}function Jc(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function th(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 Jg(i,t){const e={...t,...i},s=Jt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function Ki(i,t){if(i==null)return null;const e={},s=i;return Xg(i)?Kg(e,i,t):Zg(i)?Qg(e,i,t):Kc(i)?Jc(e,i,t):Qc(i)?th(e,i,t):s.fill&&Kc(s.fill)?Jc(s,s.fill,t):s.fill&&Qc(s.fill)?th(s,s.fill,t):Jg(s,t)}function br(i,t){const{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...h}=t,d=Ki(i,h);return d?{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...d}:null}function t0(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 d=0;d<l;d+=2){if(!h&&(d===0||d===l-2))continue;const c=(d-2+l)%l,f=(d+2)%l,g=r[c],m=r[c+1],v=r[d],b=r[d+1],_=r[f],x=r[f+1],C=g-v,$=m-b,P=_-v,H=x-b,R=C*C+$*$,O=P*P+H*H;if(R<1e-12||O<1e-12)continue;let X=(C*P+$*H)/Math.sqrt(R*O);X<-1?X=-1:X>1&&(X=1);const J=Math.sqrt((1-X)*.5);if(J<1e-6)continue;const st=Math.min(1/J,t);st>e&&(e=st)}}return e}const e0=new ye,eh=new Tt,Gl=class is extends cs{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Yt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new xs,this._transform=new Tt,this._fillStyle={...is.defaultFillStyle},this._strokeStyle={...is.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new We,this._boundsDirty=!0}clone(){const t=new is;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=Ki(t,is.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=br(t,is.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Ki(t,is.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Ki(t,is.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?Jt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new xs,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"&&(Mt(jt,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=Ki(t,is.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(ye.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=br(t,is.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++,Yg(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 Tt?(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 Tt?(this._transform.append(t),this):(eh.set(t,e,s,n,o,r),this._transform.append(eh),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*=t0(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 d=l.style,c=h.shapePath.shapePrimitives;for(let f=0;f<c.length;f++){const g=c[f].shape;if(!d||!g)continue;const m=c[f].transform,v=m?m.applyInverse(t,e0):t;if(r.action==="fill")s=g.contains(v.x,v.y);else{const _=d;s=g.strokeContains(v.x,v.y,_.width,_.alignment)}const b=l.hole;if(b){const _=(n=b.shapePath)==null?void 0:n.shapePrimitives;if(_)for(let x=0;x<_.length;x++)_[x].shape.contains(v.x,v.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:Bt.WHITE,matrix:null,fill:null,textureSpace:"local"};Gl.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Bt.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let je=Gl;class s0{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class i0{constructor(){this.instructions=new Il}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Wl=class rl{constructor(t){this._renderer=t,this._managedContexts=new So({renderer:t,type:"resource",name:"graphicsContext"})}init(t){rl.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??rl.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 i0,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new s0;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Wl.extension={type:[bt.CanvasSystem],name:"graphicsContext"};Wl.defaultOptions={bezierSmoothness:.5};let n0=Wl;class Iu{constructor(t,e){this.state=tu.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new So({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:[bt.CanvasPipes],name:"graphics"};function o0(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 r0{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Ae.return(t)}),this.batches.length=0}}class Pu{constructor(t,e){this.state=tu.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new So({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,o0(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 r0;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=Ae.get(zl);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}}Pu.extension={type:[bt.WebGLPipes,bt.WebGPUPipes],name:"graphics"};Kt.add(Iu);Kt.add(Pu);Kt.add(n0);Kt.add(Ol);class Ht extends Pl{constructor(t){t instanceof je&&(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 je,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 Ht(this._context.clone()):(this._ownedContext=null,new Ht(this._context))}lineStyle(t,e,s){Mt(jt,"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){Mt(jt,"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(){Mt(jt,"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!==je.defaultStrokeStyle.width||t.color!==je.defaultStrokeStyle.color||t.alpha!==je.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return Mt(jt,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return Mt(jt,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return Mt(jt,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return Mt(jt,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return Mt(jt,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return Mt(jt,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class a0 extends Pl{constructor(t,e){const{text:s,resolution:n,style:o,anchor:r,width:l,height:h,roundPixels:d,...c}=t;super({...c}),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 ie({_onUpdate:()=>{this.onViewUpdate()}}),r&&(this.anchor=r),this.roundPixels=d??!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 l0(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(Mt(jt,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class c0{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Be.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=Cn(t),e=Cn(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 al=new c0;xo.register(al);let Ni=null,ws=null;function h0(i,t){Ni||(Ni=Be.get().createCanvas(256,128),ws=Ni.getContext("2d",{willReadFrequently:!0}),ws.globalCompositeOperation="copy",ws.globalAlpha=1),(Ni.width<i||Ni.height<t)&&(Ni.width=Cn(i),Ni.height=Cn(t))}function sh(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 ih(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 d0(...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(h0(n,o),!ws)throw new TypeError("Failed to get canvas 2D context");ws.drawImage(e,0,0,n,o,0,0,n*s,o*s);const h=ws.getImageData(0,0,n,o).data;let d=0,c=0,f=n-1,g=o-1;for(;c<o&&sh(h,n,c);)++c;if(c===o)return Xt.EMPTY;for(;sh(h,n,g);)--g;for(;ih(h,n,d,c,g);)++d;for(;ih(h,n,f,c,g);)--f;return++f,++g,ws.globalCompositeOperation="source-over",ws.strokeRect(d,c,f-d,g-c),ws.globalCompositeOperation="copy",r??(r=new Xt),r.set(d/s,c/s,(f-d)/s,(g-c)/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 u0{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 p0(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 u0(i,t,e)}function Lu(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function $u(i){return i.includes("<")}function f0(i,t){return i.clone().assign(t)}function m0(i,t){const e=[],s=t.tagStyles;if(!Lu(t)||!$u(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 d=i.indexOf(">",l);if(d===-1){r+=h,l++;continue}const c=i.slice(l+1,d);if(c.startsWith("/")){const f=c.slice(1).trim();if(o.length>0&&o[o.length-1]===f){r.length>0&&(e.push({text:r,style:n[n.length-1]}),r=""),n.pop(),o.pop(),l=d+1;continue}else{r+=i.slice(l,d+1),l=d+1;continue}}else{const f=c.trim();if(s[f]){r.length>0&&(e.push({text:r,style:n[n.length-1]}),r="");const g=n[n.length-1],m=f0(g,s[f]);n.push(m),o.push(f),l=d+1;continue}else{r+=i.slice(l,d+1),l=d+1;continue}}}else r+=h,l++}return r.length>0&&e.push({text:r,style:n[n.length-1]}),e}const g0=[10,13],v0=new Set(g0),y0=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],b0=new Set(y0),w0=[9,32];new Set(w0);const _0=[45,8208,8211,8212,173],x0=new Set(_0),S0=/(\r\n|\r|\n)/,T0=/(?:\r\n|\r|\n)/;function wr(i){return typeof i!="string"?!1:v0.has(i.charCodeAt(0))}function Oe(i,t){return typeof i!="string"?!1:b0.has(i.charCodeAt(0))}function k0(i){return typeof i!="string"?!1:x0.has(i.charCodeAt(0))}function Bu(i){return i==="normal"||i==="pre-line"}function Ru(i){return i==="normal"}function bs(i){if(typeof i!="string")return"";let t=i.length-1;for(;t>=0&&Oe(i[t]);)t--;return t<i.length-1?i.slice(0,t+1):i}function Du(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(Oe(n)||wr(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),k0(n)&&o&&!Oe(o)&&!wr(o)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function zu(i,t,e,s){const n=e(i),o=[];for(let r=0;r<n.length;r++){let l=n[r],h=l,d=1;for(;n[r+d];){const c=n[r+d];if(!s(h,c,i,r,t))l+=c,h=c,d++;else break}r+=d-1,o.push(l)}return o}const C0=/\r\n|\r|\n/g;function A0(i,t,e,s,n,o,r,l){var Dt,nt;const h=m0(i,t);if(Ru(t.whiteSpace))for(let rt=0;rt<h.length;rt++){const Ot=h[rt];h[rt]={text:Ot.text.replace(C0," "),style:Ot.style}}const c=[];let f=[];for(const rt of h){const Ot=rt.text.split(S0);for(let lt=0;lt<Ot.length;lt++){const wt=Ot[lt];wt===`\r
|
|
248
|
+
`||wt==="\r"||wt===`
|
|
249
|
+
`?(c.push(f),f=[]):wt.length>0&&f.push({text:wt,style:rt.style})}}(f.length>0||c.length===0)&&c.push(f);const g=e?E0(c,t,s,n,r,l):c,m=[],v=[],b=[],_=[],x=[];let C=0;const $=t._fontString,P=o($);P.fontSize===0&&(P.fontSize=t.fontSize,P.ascent=t.fontSize);let H="",R=!!t.dropShadow,O=((Dt=t._stroke)==null?void 0:Dt.width)||0;for(const rt of g){let Ot=0,lt=P.ascent,wt=P.descent,zt="";for(const pt of rt){const Wt=pt.style._fontString,Ft=o(Wt);Wt!==H&&(s.font=Wt,H=Wt);const ae=n(pt.text,pt.style.letterSpacing,s);Ot+=ae,lt=Math.max(lt,Ft.ascent),wt=Math.max(wt,Ft.descent),zt+=pt.text;const qt=((nt=pt.style._stroke)==null?void 0:nt.width)||0;qt>O&&(O=qt),!R&&pt.style.dropShadow&&(R=!0)}rt.length===0&&(lt=P.ascent,wt=P.descent),m.push(Ot),v.push(lt),b.push(wt),x.push(zt);const _t=t.lineHeight||lt+wt;_.push(_t+t.leading),C=Math.max(C,Ot)}const et=O,J=(e&&t.align!=="left"?Math.max(C,t.wordWrapWidth):C)+et+(t.dropShadow?t.dropShadow.distance:0);let st=0;for(let rt=0;rt<_.length;rt++)st+=_[rt];st=Math.max(st,_[0]+et);const it=st+(t.dropShadow?t.dropShadow.distance:0),ht=t.lineHeight||P.fontSize;return{width:J,height:it,lines:x,lineWidths:m,lineHeight:ht+t.leading,maxLineWidth:C,fontProperties:P,runsByLine:g,lineAscents:v,lineDescents:b,lineHeights:_,hasDropShadow:R}}function E0(i,t,e,s,n,o){var _;const{letterSpacing:r,whiteSpace:l,wordWrapWidth:h,breakWords:d}=t,c=Bu(l),f=h+r,g={};let m="";const v=(x,C)=>{const $=`${x}|${C.styleKey}`;let P=g[$];if(P===void 0){const H=C._fontString;H!==m&&(e.font=H,m=H),P=s(x,C.letterSpacing,e)+C.letterSpacing,g[$]=P}return P},b=[];for(const x of i){const C=M0(x),$=b.length,P=st=>{let it=0,ht=st;do{const{token:Dt,style:nt}=C[ht];it+=v(Dt,nt),ht++}while(ht<C.length&&C[ht].continuesFromPrevious);return it},H=st=>{const it=[];let ht=st;do it.push({token:C[ht].token,style:C[ht].style}),ht++;while(ht<C.length&&C[ht].continuesFromPrevious);return it};let R=[],O=0,et=!c,Z=null;const X=()=>{Z&&Z.text.length>0&&R.push(Z),Z=null},J=()=>{if(X(),R.length>0){const st=R[R.length-1];st.text=bs(st.text),st.text.length===0&&R.pop()}b.push(R),R=[],O=0,et=!1};for(let st=0;st<C.length;st++){const{token:it,style:ht,continuesFromPrevious:Dt}=C[st],nt=v(it,ht);if(c){const lt=Oe(it),wt=(Z==null?void 0:Z.text[Z.text.length-1])??((_=R[R.length-1])==null?void 0:_.text.slice(-1))??"",zt=wt?Oe(wt):!1;if(lt&&zt)continue}const rt=!Dt,Ot=rt?P(st):nt;if(Ot>f&&rt)if(O>0&&J(),d){const lt=H(st);for(let wt=0;wt<lt.length;wt++){const zt=lt[wt].token,_t=lt[wt].style,pt=zu(zt,d,o,n);for(const Wt of pt){const Ft=v(Wt,_t);Ft+O>f&&J(),!Z||Z.style!==_t?(X(),Z={text:Wt,style:_t}):Z.text+=Wt,O+=Ft}}st+=lt.length-1}else{const lt=H(st);X(),b.push(lt.map(wt=>({text:wt.token,style:wt.style}))),et=!1,st+=lt.length-1}else if(Ot+O>f&&rt){if(Oe(it)){et=!1;continue}J(),Z={text:it,style:ht},O=nt}else if(Dt&&!d)!Z||Z.style!==ht?(X(),Z={text:it,style:ht}):Z.text+=it,O+=nt;else{const lt=Oe(it);if(O===0&<&&!et)continue;!Z||Z.style!==ht?(X(),Z={text:it,style:ht}):Z.text+=it,O+=nt}}if(X(),R.length>0){const st=R[R.length-1];st.text=bs(st.text),st.text.length===0&&R.pop()}(R.length>0||b.length===$)&&b.push(R)}return b}function M0(i){const t=[];let e=!1;for(const s of i){const n=Du(s.text);let o=!0;for(const r of n){const l=Oe(r)||wr(r),h=o&&e&&!l;t.push({token:r,style:s.style,continuesFromPrevious:h}),e=!l,o=!1}}return t}const I0={willReadFrequently:!0};function nh(i,t,e,s,n){let o=e[i];return typeof o!="number"&&(o=n(i,t,s)+t,e[i]=o),o}function P0(i,t,e,s,n,o,r){const l=e.getContext("2d",I0);l.font=t._fontString;let h=0,d="";const c=[],f=Object.create(null),{letterSpacing:g,whiteSpace:m}=t,v=Bu(m),b=Ru(m);let _=!v;const x=t.wordWrapWidth+g,C=Du(i);for(let P=0;P<C.length;P++){let H=C[P];if(wr(H)){if(!b){c.push(bs(d)),_=!v,d="",h=0;continue}H=" "}if(v){const O=Oe(H),et=Oe(d[d.length-1]);if(O&&et)continue}const R=nh(H,g,f,l,s);if(R>x)if(d!==""&&(c.push(bs(d)),d="",h=0),n(H,t.breakWords)){const O=zu(H,t.breakWords,r,o);for(const et of O){const Z=nh(et,g,f,l,s);Z+h>x&&(c.push(bs(d)),_=!1,d="",h=0),d+=et,h+=Z}}else d.length>0&&(c.push(bs(d)),d="",h=0),c.push(bs(H)),_=!1,d="",h=0;else R+h>x&&(_=!1,c.push(bs(d)),d="",h=0),(d.length>0||!Oe(H)||_)&&(d+=H,h+=R)}const $=bs(d);return $.length>0&&c.push($),c.join(`
|
|
250
|
+
`)}const oh={willReadFrequently:!0},As=class ut{static get experimentalLetterSpacingSupported(){let t=ut._experimentalLetterSpacingSupported;if(t===void 0){const e=Be.get().getCanvasRenderingContext2D().prototype;t=ut._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,o,r,l,h,d,c){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=d,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,s=ut._canvas,n=e.wordWrap){var H;const o=`${t}-${e.styleKey}-wordWrap-${n}`;if(ut._measurementCache.has(o))return ut._measurementCache.get(o);if(Lu(e)&&$u(t)){const R=A0(t,e,n,ut._context,ut._measureText,ut.measureFont,ut.canBreakChars,ut.wordWrapSplit),O=new ut(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 ut._measurementCache.set(o,O),O}const l=e._fontString,h=ut.measureFont(l);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const d=ut._context;d.font=l;const f=(n?ut._wordWrap(t,e,s):t).split(T0),g=new Array(f.length);let m=0;for(let R=0;R<f.length;R++){const O=ut._measureText(f[R],e.letterSpacing,d);g[R]=O,m=Math.max(m,O)}const v=((H=e._stroke)==null?void 0:H.width)??0,b=e.lineHeight||h.fontSize,_=ut._getAlignWidth(m,e,n),x=ut._adjustWidthForStyle(_,e),C=Math.max(b,h.fontSize+v)+(f.length-1)*(b+e.leading),$=ut._adjustHeightForStyle(C,e),P=new ut(t,e,x,$,f,g,b+e.leading,m,h);return ut._measurementCache.set(o,P),P}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;ut.experimentalLetterSpacingSupported&&(ut.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 d=(o.actualBoundingBoxRight??0)-l;if(r>0)if(n)r-=e,d-=e;else{const c=(ut.graphemeSegmenter(t).length-1)*e;r+=c,d+=c}return Math.max(r,d)}static _wordWrap(t,e,s=ut._canvas){return P0(t,e,s,ut._measureText,ut.canBreakWords,ut.canBreakChars,ut.wordWrapSplit)}static isBreakingSpace(t,e){return Oe(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,n,o){return!0}static wordWrapSplit(t){return ut.graphemeSegmenter(t)}static measureFont(t){if(ut._fonts[t])return ut._fonts[t];const e=ut._context;e.font=t;const s=e.measureText(ut.METRICS_STRING+ut.BASELINE_SYMBOL),n=s.actualBoundingBoxAscent??0,o=s.actualBoundingBoxDescent??0,r={ascent:n,descent:o,fontSize:n+o};return ut._fonts[t]=r,r}static clearMetrics(t=""){t?delete ut._fonts[t]:ut._fonts={}}static get _canvas(){if(!ut.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",oh);if(s!=null&&s.measureText)return ut.__canvas=e,e;t=Be.get().createCanvas()}catch{t=Be.get().createCanvas()}t.width=t.height=10,ut.__canvas=t}return ut.__canvas}static get _context(){return ut.__context||(ut.__context=ut._canvas.getContext("2d",oh)),ut.__context}};As.METRICS_STRING="|ÉqÅ";As.BASELINE_SYMBOL="M";As.BASELINE_MULTIPLIER=1.4;As.HEIGHT_MULTIPLIER=2;As.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]})();As.experimentalLetterSpacing=!1;As._fonts={};As._measurementCache=p0(1e3);let xi=As;const L0=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ll(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)&&!L0.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const rh=1e5;function No(i,t,e,s=0,n=0,o=0){if(i.texture===Bt.WHITE&&!i.fill)return Jt.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Br){const r=i.fill,l=t.createPattern(r.texture.source.resource,"repeat"),h=r.transform.copyTo(Tt.shared);return h.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),l.setTransform(h),l}else if(i.fill instanceof ks){const r=i.fill,l=r.type==="linear",h=r.textureSpace==="local";let d=1,c=1;h&&e&&(d=e.width+s,c=e.height+s);let f,g=!1;if(l){const{start:m,end:v}=r;f=t.createLinearGradient(m.x*d+n,m.y*c+o,v.x*d+n,v.y*c+o),g=Math.abs(v.x-m.x)<Math.abs((v.y-m.y)*.1)}else{const{center:m,innerRadius:v,outerCenter:b,outerRadius:_}=r;f=t.createRadialGradient(m.x*d+n,m.y*c+o,v*d,b.x*d+n,b.y*c+o,_*d)}if(g&&h&&e){const m=e.lineHeight/c;for(let v=0;v<e.lines.length;v++){const b=(v*e.lineHeight+s/2)/c;r.colorStops.forEach(_=>{let x=b+_.offset*m;x=Math.max(0,Math.min(1,x)),f.addColorStop(Math.floor(x*rh)/rh,Jt.shared.setValue(_.color).toHex())})}}else r.colorStops.forEach(m=>{f.addColorStop(m.offset,Jt.shared.setValue(m.color).toHex())});return f}}else{const r=t.createPattern(i.texture.source.resource,"repeat"),l=i.matrix.copyTo(Tt.shared);return l.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),r.setTransform(l),r}return Se("FillStyle not recognised",i),"red"}const ah=new Xt;function an(i){let t=0;for(let e=0;e<i.length;e++)i.charCodeAt(e)===32&&t++;return t}class $0{getCanvasAndContext(t){const{text:e,style:s,resolution:n=1}=t,o=s._getFinalPadding(),r=xi.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),d=al.getOptimalCanvasAndContext(l,h);this._renderTextToCanvas(s,o,n,d,r);const c=s.trim?d0({canvas:d.canvas,width:l,height:h,resolution:1,output:ah}):ah.set(0,0,l,h);return{canvasAndContext:d,frame:c}}returnCanvasAndContext(t){al.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,n,o){var R,O,et;if(o.runsByLine&&o.runsByLine.length>0){this._renderTaggedTextToCanvas(o,t,e,s,n);return}const{canvas:r,context:l}=n,h=ll(t),d=o.lines,c=o.lineHeight,f=o.lineWidths,g=o.maxLineWidth,m=o.fontProperties,v=r.height;if(l.resetTransform(),l.scale(s,s),l.textBaseline=t.textBaseline,(R=t._stroke)!=null&&R.width){const Z=t._stroke;l.lineWidth=Z.width,l.miterLimit=Z.miterLimit,l.lineJoin=Z.join,l.lineCap=Z.cap}l.font=h;let b,_;const x=t.dropShadow?2:1,C=t.wordWrap?t.wordWrapWidth:g,P=(((O=t._stroke)==null?void 0:O.width)??0)/2;let H=(c-m.fontSize)/2;c-m.fontSize<0&&(H=0);for(let Z=0;Z<x;++Z){const X=t.dropShadow&&Z===0,J=X?Math.ceil(Math.max(1,v)+e*2):0,st=J*s;if(X)this._setupDropShadow(l,t,s,st);else{const it=t._gradientBounds,ht=t._gradientOffset;if(it){const Dt={width:it.width,height:it.height,lineHeight:it.height,lines:o.lines};this._setFillAndStrokeStyles(l,t,Dt,e,P,(ht==null?void 0:ht.x)??0,(ht==null?void 0:ht.y)??0)}else ht?this._setFillAndStrokeStyles(l,t,o,e,P,ht.x,ht.y):this._setFillAndStrokeStyles(l,t,o,e,P);l.shadowColor="rgba(0,0,0,0)"}for(let it=0;it<d.length;it++){b=P,_=P+it*c+m.ascent+H,b+=this._getAlignmentOffset(f[it],C,t.align);let ht=0;if(t.align==="justify"&&t.wordWrap&&it<d.length-1){const Dt=an(d[it]);Dt>0&&(ht=(C-f[it])/Dt)}(et=t._stroke)!=null&&et.width&&this._drawLetterSpacing(d[it],t,n,b+e,_+e-J,!0,ht),t._fill!==void 0&&this._drawLetterSpacing(d[it],t,n,b+e,_+e-J,!1,ht)}}}_renderTaggedTextToCanvas(t,e,s,n,o){var P,H,R;const{canvas:r,context:l}=o,{runsByLine:h,lineWidths:d,maxLineWidth:c,lineAscents:f,lineHeights:g,hasDropShadow:m}=t,v=r.height;l.resetTransform(),l.scale(n,n),l.textBaseline=e.textBaseline;const b=m?2:1,_=e.wordWrap?e.wordWrapWidth:c;let x=((P=e._stroke)==null?void 0:P.width)??0;for(const O of h)for(const et of O){const Z=((H=et.style._stroke)==null?void 0:H.width)??0;Z>x&&(x=Z)}const C=x/2,$=[];for(let O=0;O<h.length;O++){const et=h[O],Z=[];for(const X of et){const J=ll(X.style);l.font=J,Z.push({width:xi._measureText(X.text,X.style.letterSpacing,l),font:J})}$.push(Z)}for(let O=0;O<b;++O){const et=m&&O===0,Z=et?Math.ceil(Math.max(1,v)+s*2):0,X=Z*n;et||(l.shadowColor="rgba(0,0,0,0)");let J=C;for(let st=0;st<h.length;st++){const it=h[st],ht=d[st],Dt=f[st],nt=g[st],rt=$[st];let Ot=C;Ot+=this._getAlignmentOffset(ht,_,e.align);let lt=0;if(e.align==="justify"&&e.wordWrap&&st<h.length-1){let _t=0;for(const pt of it)_t+=an(pt.text);_t>0&&(lt=(_-ht)/_t)}const wt=J+Dt;let zt=Ot+s;for(let _t=0;_t<it.length;_t++){const pt=it[_t],{width:Wt,font:Ft}=rt[_t];if(l.font=Ft,l.textBaseline=pt.style.textBaseline,(R=pt.style._stroke)!=null&&R.width){const qt=pt.style._stroke;if(l.lineWidth=qt.width,l.miterLimit=qt.miterLimit,l.lineJoin=qt.join,l.lineCap=qt.cap,et)if(pt.style.dropShadow)this._setupDropShadow(l,pt.style,n,X);else{const Te=an(pt.text);zt+=Wt+Te*lt;continue}else{const Te=xi.measureFont(Ft),Ee=pt.style.lineHeight||Te.fontSize,Xe={width:Wt,height:Ee,lineHeight:Ee,lines:[pt.text]};l.strokeStyle=No(qt,l,Xe,s*2,zt-s,J)}this._drawLetterSpacing(pt.text,pt.style,o,zt,wt+s-Z,!0,lt)}const ae=an(pt.text);zt+=Wt+ae*lt}zt=Ot+s;for(let _t=0;_t<it.length;_t++){const pt=it[_t],{width:Wt,font:Ft}=rt[_t];if(l.font=Ft,l.textBaseline=pt.style.textBaseline,pt.style._fill!==void 0){if(et)if(pt.style.dropShadow)this._setupDropShadow(l,pt.style,n,X);else{const qt=an(pt.text);zt+=Wt+qt*lt;continue}else{const qt=xi.measureFont(Ft),Te=pt.style.lineHeight||qt.fontSize,Ee={width:Wt,height:Te,lineHeight:Te,lines:[pt.text]};l.fillStyle=No(pt.style._fill,l,Ee,s*2,zt-s,J)}this._drawLetterSpacing(pt.text,pt.style,o,zt,wt+s-Z,!1,lt)}const ae=an(pt.text);zt+=Wt+ae*lt}J+=nt}}}_setFillAndStrokeStyles(t,e,s,n,o,r=0,l=0){var h;if(t.fillStyle=e._fill?No(e._fill,t,s,n*2,r,l):null,(h=e._stroke)!=null&&h.width){const d=o+n*2;t.strokeStyle=No(e._stroke,t,s,d,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=Jt.shared.setValue(r).setAlpha(l).toRgbaString();const h=o.blur*s,d=o.distance*s;t.shadowBlur=h,t.shadowOffsetX=Math.cos(o.angle)*d,t.shadowOffsetY=Math.sin(o.angle)*d+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,d=e.letterSpacing;let c=!1;if(xi.experimentalLetterSpacingSupported&&(xi.experimentalLetterSpacing?(h.letterSpacing=`${d}px`,h.textLetterSpacing=`${d}px`,c=!0):(h.letterSpacing="0px",h.textLetterSpacing="0px")),(d===0||c)&&l===0){r?h.strokeText(t,n,o):h.fillText(t,n,o);return}if(l!==0&&(d===0||c)){const b=t.split(" ");let _=n;const x=h.measureText(" ").width;for(let C=0;C<b.length;C++)r?h.strokeText(b[C],_,o):h.fillText(b[C],_,o),_+=h.measureText(b[C]).width+x+l;return}let f=n;const g=xi.graphemeSegmenter(t);let m=h.measureText(t).width,v=0;for(let b=0;b<g.length;++b){const _=g[b];r?h.strokeText(_,f,o):h.fillText(_,f,o);let x="";for(let C=b+1;C<g.length;++C)x+=g[C];v=h.measureText(x).width,f+=m-v+d,_===" "&&(f+=l),m=v}}}const _n=new $0,Hl=class Xi extends cs{constructor(t={}){super(),this.uid=Yt("textStyle"),this._tick=0,this._cachedFontString=null,B0(t),t instanceof Xi&&(t=t._toObject());const n={...Xi.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({...Xi.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Xi.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({...je.defaultFillStyle,...t},()=>{this._fill=Ki({...this._originalFill},je.defaultFillStyle)})),this._fill=Ki(t===0?"black":t,je.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...je.defaultStrokeStyle,...t},()=>{this._stroke=br({...this._originalStroke},je.defaultStrokeStyle)})),this._stroke=br(t,je.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=Xi.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=ll(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 Xi(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&&!(Jt.isColorLike(t)||t instanceof ks||t instanceof Br)}};Hl.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Hl.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 Ye=Hl;function B0(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=Ye.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){Mt(jt,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Jt.isColorLike(e))s.color=e;else if(e instanceof ks||e instanceof Br)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(Mt(jt,"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&&Se("The number of fill colors must match the number of fill gradient stops.");const e=new ks({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=t.fillGradientStops.slice(),n=t.fill.map(o=>Jt.shared.setValue(o).toNumber());s.forEach((o,r)=>{e.addColorStop(o,n[r])}),i.fill={fill:e}}}function R0(i,t){const{texture:e,bounds:s}=i,n=t._style._getFinalPadding();_d(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 D0{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 z0 extends D0{}class Fu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new So({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,R0(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 z0;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}}Fu.extension={type:[bt.WebGLPipes,bt.WebGPUPipes,bt.CanvasPipes],name:"text"};const F0=new We;function N0(i,t,e,s,n=!1){const o=F0;o.minX=0,o.minY=0,o.maxX=i.width/s|0,o.maxY=i.height/s|0;const r=Ir.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 Nu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,n){typeof t=="string"&&(Mt("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof Ye||(t.style=new Ye(t.style)),t.textureStyle instanceof An||(t.textureStyle=new An(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:r,textureStyle:l,autoGenerateMipmaps:h}=t,d=t.resolution??this._renderer.resolution,{frame:c,canvasAndContext:f}=_n.getCanvasAndContext({text:o,style:r,resolution:d}),g=N0(f.canvas,c.width,c.height,d,h);if(l&&(g.source.style=l),r.trim&&(c.pad(r.padding),g.frame.copyFrom(c),g.frame.scale(1/d),g.updateUvs()),r.filters){const m=this._applyFilters(g,r.filters);return this.returnTexture(g),_n.returnCanvasAndContext(f),m}return this._renderer.texture.initSource(g._source),this._retainCanvasContext||_n.returnCanvasAndContext(f),g}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&(s!=null&&s.getContext)){const n=s.getContext("2d");n&&_n.returnCanvasAndContext({canvas:s,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Ir.returnTexture(t,!0)}renderTextToCanvas(){Mt("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 Ou extends Nu{constructor(t){super(t,!0)}}Ou.extension={type:[bt.CanvasSystem],name:"canvasText"};class Gu extends Nu{constructor(t){super(t,!1)}}Gu.extension={type:[bt.WebGLSystem,bt.WebGPUSystem],name:"canvasText"};Kt.add(Ou);Kt.add(Gu);Kt.add(Fu);class Qi extends a0{constructor(...t){const e=l0(t,"Text");super(e,Ye),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof An?e.textureStyle:new An(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??He.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,n=0;if(this._style.trim){const{frame:o,canvasAndContext:r}=_n.getCanvasAndContext({text:this.text,style:this._style,resolution:1});_n.returnCanvasAndContext(r),s=o.width,n=o.height}else{const o=xi.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}}Kt.add(hp,dp);const O0={Read:"📖",Write:"✏️",Edit:"🔧",Patch:"🔧",Bash:"💻",Glob:"🔍",Grep:"🔎",WebSearch:"🌐",WebFetch:"🌐",Agent:"🤖",TeamCreate:"👥",SendMessage:"💬",TaskCreate:"📋",TaskUpdate:"✅",TodoRead:"📋",TodoWrite:"✅",AskUserQuestion:"❓",EnterPlanMode:"📝",ExitPlanMode:"📝"},Wu=new Set(["Edit","Write","NotebookEdit"]),Hu=new Set(["Read","Glob","Grep"]),lh=12,Oo=[5,4,3],ne=[{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}],Zt=new Map(ne.map(i=>[i.id,i]));let cl=1100,hl=980;function G0(i,t){cl=i,hl=t}const ft=[{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}],W0={background:14995640},_e={"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}},ch={input:3,output:15},ca={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 Uu(i){if(!i)return ch;const t=i.toLowerCase();if(_e[t])return _e[t];for(const[e,s]of Object.entries(_e))if(t.startsWith(e)||t.includes(e))return s;return t.includes("opus")?_e["claude-opus-4-6"]:t.includes("haiku")?_e["claude-haiku-4-5-20251001"]:t.includes("sonnet")?_e["claude-sonnet-4-6"]:t.includes("o3-mini")||t.includes("o4-mini")?_e["o3-mini"]:t.includes("o1-mini")?_e["o1-mini"]:t.includes("gemini-2.5")?_e["gemini-2.5-pro"]:t.includes("gemini-2")?_e["gemini-2.0-flash"]:t.includes("gemini")?_e["gemini-1.5-pro"]:t.includes("gpt-4o")?_e["gpt-4o"]:t.includes("deepseek")?_e["deepseek-chat"]:t.includes("grok")?_e["grok-3"]:t.includes("mistral")?_e["mistral-large"]:ch}function Ul(i){if(!i)return 2e5;const t=i.toLowerCase();if(ca[t])return ca[t];let e=null;for(const[s,n]of Object.entries(ca))(t.startsWith(s)||t.includes(s))&&(!e||s.length>e[0].length)&&(e=[s,n]);return e?e[1]:2e5}function qu(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%ft.length}function Ji(i){const t=Uu(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 hh=["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 Ss(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)%hh.length;return hh[e]}async function H0(i){const t=new fu,e=document.getElementById("canvas-container")??i;return await t.init({background:W0.background,resizeTo:e,antialias:!1,resolution:window.devicePixelRatio||1,autoDensity:!0}),i.appendChild(t.canvas),t}const dh=1e3,U0=1e4;class q0{constructor(t){y(this,"ws",null);y(this,"store");y(this,"reconnectMs",dh);y(this,"reconnectTimer",null);y(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=dh,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,U0))}disconnect(){this.disposed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}}const Ar=class Ar{constructor(){y(this,"agents",new Map);y(this,"listeners",new Map);y(this,"_connectionStatus","disconnected");y(this,"wsClient",null);y(this,"_timeline",[]);y(this,"_pendingPermissions",new Map);y(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-Ar.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._timeline=t.timeline??[],this.emit("state:reset",this.agents),t.timeline&&this.emit("timeline:snapshot",t.timeline),t.toolchain&&this.emit("toolchain:snapshot",t.toolchain),t.taskgraph&&this.emit("taskgraph:snapshot",t.taskgraph);break}case"agent:spawn":{if(this.agents.has(t.agent.id)){this.agents.set(t.agent.id,t.agent),this.pushTimelineEvent("agent:update",t.agent,t.timestamp),this.emit("agent:update",t.agent);break}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}}}};y(Ar,"MAX_TIMELINE",5e3);let dl=Ar;const V0=658452;function uh(i,t,e){const s=new Ht;return e?(e(s,i,t),s):(s.rect(0,0,i,t).fill(V0),s)}const k={deskTop:15262944,deskEdge:13683912,deskHighlight:16052976,darkWood:8015920,medWood:10119224,wood:12093512,lightWood:13674584,paleWood:15255672,screenFrame:2236980,screenBlue:4491502,screenGlow:8965375,screenDark:3359829,screenGreen:2280550,screenGreenGlow:4517512,led:4521830,ledRed:16729156,ledBlue:4500223,ledYellow:16763938,bookRed:14496563,bookDarkRed:11149858,bookGreen:4500036,bookDarkGreen:3377203,bookBlue:3364300,bookNavy:2241416,bookYellow:14531362,bookPurple:10044620,bookOrange:15628066,bookCyan:2271931,bookBrown:8939076,bookPink:14505352,bookWhite:15263976,bookTan:13150839,chairSeat:3816008,chairBack:2763320,chairArm:4868696,chairWheel:2236976,chairHighlight:5921384,sofaBody:14190664,sofaDark:12087352,sofaLight:15771752,sofaHighlight:16304264,sofaArm:12613696,metalBright:13684960,metalLight:11579588,metalMid:8947864,metalDark:5592424,metalFrame:4473946,metalShine:15263984,shelfFrame:7899296,shelfBack:8951984,shelfEdge:6846624,shelfHighlight:10004672,leafDark:2783786,leaf:4108350,leafLight:5950554,leafBright:7794294,potBase:11561024,potDark:9063978,potRim:13404240,potHighlight:14721120,soil:5915184,white:16053492,offWhite:14736856,paper:15788244,cream:16577764,black:1315872,red:15610675,green:3394628,blue:3377390,yellow:15649843,vendingBody:3824250,vendingGlass:8960972,vendingLight:11197934,fridgeBody:13161690,fridgeLight:14740208,fridgeDark:8951972,fridgeHandle:10529464,portalDeep:5575082,portalMid:7812044,portalLight:11163135,portalGlow:14522879,whiteboardFrame:13421789,whiteboardSurface:16316668,stickyYellow:16772676,stickyPink:16746666,stickyGreen:8973960,stickyBlue:8961023,stickyOrange:16755268,stickyPurple:13404415},ph=[[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]],T=4,u=i=>i*T;function M(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function _r(i,t,e,s,n,o,r){i.rect(t,e,s,n).fill({color:o,alpha:r})}function re(i,t,e,s,n){_r(i,t+3,e+n,s,4,0,.12)}function xr(i,t,e){const s=u(16),n=u(8);re(i,t,e,s,n),M(i,t,e+u(2),s,n-u(2),k.deskTop),M(i,t+T,e+u(2),s-T*2,T,k.deskHighlight),M(i,t,e+n-T,s,T,k.deskEdge),M(i,t+u(3),e,u(8),u(6),k.screenFrame),M(i,t+u(4),e+T,u(6),u(4),k.screenBlue),M(i,t+u(4),e+T,u(3),u(2),k.screenGlow),M(i,t+u(6),e+u(5),u(2),T,k.metalDark),M(i,t+u(5),e+u(6),u(4),T,k.metalDark),M(i,t+u(3),e+u(6),u(7),u(2),k.offWhite),M(i,t+u(3)+1,e+u(6)+1,u(7)-2,T-2,k.white),M(i,t+u(11),e+u(6),u(2),u(2),k.metalMid),M(i,t+u(11),e+u(6),u(2),T,k.metalLight)}function j0(i,t,e){const s=u(14),n=u(7);re(i,t,e,s,n),M(i,t,e,s,n,k.deskTop),M(i,t+T,e,s-T*2,T,k.deskHighlight),M(i,t,e+n-T,s,T,k.deskEdge),M(i,t+u(3),e+T,u(7),u(4),k.metalDark),M(i,t+u(4),e+u(1)+2,u(5),u(3)-2,k.screenBlue),M(i,t+u(4),e+u(1)+2,u(3),u(1),k.screenGlow),M(i,t+u(3),e+u(5),u(7),u(2),k.metalFrame),M(i,t+u(4),e+u(5)+2,u(5),T,k.metalMid),M(i,t+u(11),e+u(4),u(2),u(2),k.metalMid)}function fh(i,t,e){const s=u(16),n=u(8);re(i,t,e,s,n),M(i,t,e+u(2),s,n-u(2),k.metalFrame),M(i,t+T,e+u(3),s-T*2,n-u(4),k.metalDark),M(i,t,e+n-T,s,T,k.metalMid),M(i,t+u(2),e,u(10),u(7),k.screenFrame),M(i,t+u(3),e+T,u(8),u(5),k.screenGreen);for(let o=0;o<u(5);o+=T)M(i,t+u(3),e+T+o,u(8),1,k.screenGreenGlow);M(i,t+u(3),e+u(1),u(4),1,k.screenGreenGlow),M(i,t+u(3),e+u(2),u(6),1,k.screenGreenGlow),M(i,t+u(3),e+u(3),u(3),1,k.screenGreenGlow),M(i,t+u(6),e+u(6),u(2),T,k.metalDark)}function Gt(i,t,e){M(i,t+T,e+u(5),u(3),T,k.chairWheel),M(i,t,e+u(1),u(5),u(4),k.chairSeat),M(i,t+T,e+u(1),u(3),u(4),k.chairHighlight),M(i,t+T,e,u(3),u(2),k.chairBack),M(i,t+u(2),e,T,T,k.chairHighlight),M(i,t,e+u(2),T,u(2),k.chairArm),M(i,t+u(4),e+u(2),T,u(2),k.chairArm)}function Si(i,t,e,s){const n=u(s?18:11),o=u(16);re(i,t,e,n,o),M(i,t,e,n,o,k.shelfFrame),M(i,t,e,T,o,k.shelfEdge),M(i,t+n-T,e,T,o,k.shelfEdge),M(i,t+T,e+T,n-T*2,o-T*2,k.shelfBack),M(i,t,e,n,T,k.shelfHighlight);for(let r=1;r<=4;r++){const l=e+r*u(3);M(i,t,l,n,T+1,k.shelfFrame),M(i,t+T,l,n-T*2,1,k.shelfHighlight)}for(let r=0;r<4;r++){const l=e+(r+1)*u(3),h=ph[r%ph.length];let d=t+T+1,c=r*3;for(;d<t+n-T-1;){const f=T-1,g=u(2)+(c*7+r*3)%4;M(i,d,l-g,f,g,h[c%h.length]),d+=f+1,c++}}M(i,t,e+o-T,n,T,k.shelfFrame)}function yn(i,t,e){const s=u(8),n=u(16);re(i,t,e,s,n),M(i,t,e,s,n,k.metalFrame),M(i,t,e,T,n,k.metalDark),M(i,t+s-T,e,T,n,k.metalDark),M(i,t,e,s,T,k.metalMid);for(let o=0;o<5;o++){const r=e+u(1)+o*u(3);M(i,t+T,r,s-T*2,u(2),k.metalDark),M(i,t+T,r,s-T*2,T,k.metalMid),M(i,t+u(1),r+T,T,T,o===2?k.ledRed:o===4?k.ledBlue:k.led),M(i,t+u(2),r+T,s-u(4),1,k.metalDark)}M(i,t,e+n-T,s,T,k.metalMid)}function xn(i,t,e){const s=u(6),n=u(12);re(i,t,e,s,n),M(i,t,e,s,n,k.metalDark),M(i,t,e,T,n,k.metalMid),M(i,t,e,s,T,k.metalLight);for(let o=0;o<2;o++){const r=e+T+o*u(5);M(i,t+T,r,s-T*2,u(4),k.metalMid),M(i,t+T,r,s-T*2,T,k.metalLight),M(i,t+u(1),r,s-u(3),T,k.paper),M(i,t+u(2),r+u(2),u(2),T,k.metalFrame),M(i,t+u(2),r+u(2),u(2),1,k.metalBright)}M(i,t,e+n-T,s,T,k.metalMid)}function ul(i,t,e,s){_r(i,t-s/2+4,e-s/2+4,s,s,0,.12);const n=s/2;M(i,t-n+u(2),e-n,s-u(4),T,k.medWood),M(i,t-n+u(2),e+n-T,s-u(4),T,k.medWood),M(i,t-n,e-n+u(2),T,s-u(4),k.medWood),M(i,t+n-T,e-n+u(2),T,s-u(4),k.medWood),M(i,t-n+T,e-n+T,s-T*2,T,k.medWood),M(i,t-n+T,e+n-T*2,s-T*2,T,k.medWood),M(i,t-n+T,e-n+T,T,s-T*2,k.medWood),M(i,t+n-T*2,e-n+T,T,s-T*2,k.medWood),M(i,t-n+u(2),e-n+T,s-u(4),s-T*2,k.lightWood),M(i,t-n+T,e-n+u(2),s-T*2,s-u(4),k.lightWood),M(i,t-u(3),e-u(2),u(6),T,k.paleWood)}function pl(i,t,e,s,n){re(i,t,e,s,n),M(i,t,e,s,n,k.whiteboardFrame),M(i,t+T,e+T,s-T*2,n-T*2,k.whiteboardSurface),M(i,t+u(2),e+u(2),s*.45,T,k.blue),M(i,t+u(2),e+u(4),s*.65,T,k.red),M(i,t+u(2),e+u(6),s*.35,T,k.black),s>u(14)&&M(i,t+s/2,e+u(2),s*.3,T,k.green),M(i,t+u(2),e+n,s-u(4),T,k.metalDark),M(i,t+u(3),e+n,T,T,k.red),M(i,t+u(5),e+n,T,T,k.blue),M(i,t+u(7),e+n,T,T,k.green)}function Y0(i,t,e,s){_r(i,t+2,e+2,u(4),u(4),0,.09),M(i,t,e,u(4),u(4),s),_r(i,t,e,u(4),T,16777215,.2),M(i,t+T,e+u(1)+2,u(2),1,k.metalDark),M(i,t+T,e+u(2)+1,u(2)+2,1,k.metalDark)}function mh(i,t,e,s){re(i,t,e,s,u(9)),M(i,t,e,s,u(3),k.sofaDark),M(i,t+T,e,s-T*2,T,k.sofaLight),M(i,t,e,T*2,u(9),k.sofaArm),M(i,t+s-T*2,e,T*2,u(9),k.sofaArm);const n=Math.floor((s-u(3)-T*4)/2);M(i,t+T*2,e+u(3),s-T*4,u(6),k.sofaBody),M(i,t+T*2+n,e+u(3),T,u(6),k.sofaDark),M(i,t+T*2,e+u(3),n,T,k.sofaHighlight),M(i,t+T*2+n+T,e+u(3),n-1,T,k.sofaHighlight),M(i,t,e+u(8),s,T,k.sofaDark)}function _o(i,t,e,s,n){re(i,t,e,s,n),M(i,t+T,e+n-T,s,T,k.medWood),M(i,t,e,s,n-T,k.lightWood),M(i,t+T,e,s-T*2,T,k.paleWood),M(i,t,e,T,n-T,k.paleWood)}function ls(i,t,e){re(i,t+T,e+u(6),u(5),u(3)),M(i,t+T,e+u(6),u(5),u(3),k.potBase),M(i,t+T,e+u(6),u(5),T,k.potRim),M(i,t+u(2),e+u(6),u(3),T,k.potHighlight),M(i,t+T,e+u(8),u(5),T,k.potDark),M(i,t+u(2),e+u(5),u(3),T,k.soil),M(i,t+u(3),e+u(2),T,u(4),k.leaf),M(i,t+u(1),e+u(3),T,u(2),k.leaf),M(i,t+u(5),e+u(3),T,u(2),k.leaf),M(i,t+u(2),e,u(3),u(3),k.leaf),M(i,t+u(3),e+T,u(2),u(3),k.leafLight),M(i,t,e+u(2),u(2),u(2),k.leafDark),M(i,t+u(5),e+u(2),u(2),u(2),k.leafLight),M(i,t+u(1),e+u(1),T,u(2),k.leafDark),M(i,t+u(5),e+u(1),T,u(2),k.leafBright),M(i,t+u(3),e,T,T,k.leafBright)}function Cs(i,t,e){M(i,t,e+u(3),u(3),u(2),k.potBase),M(i,t,e+u(3),u(3),T,k.potRim),M(i,t+T,e+u(3),T,T,k.potHighlight),M(i,t,e+u(4),u(3),T,k.potDark),M(i,t+T,e,T,u(3),k.leaf),M(i,t,e+T,T,u(2),k.leafDark),M(i,t+u(2),e+T,T,u(2),k.leafLight),M(i,t+T,e,T,T,k.leafBright)}function Vu(i,t,e,s,n){re(i,t,e,s,n),M(i,t,e,s,n,k.darkWood),M(i,t+T,e+T,s-T*2,n-T*2,8956620),M(i,t+s-u(4),e+u(1),u(3),u(3),k.yellow),M(i,t+T,e+n-u(5),u(4),u(3),4482696),M(i,t+u(3),e+n-u(6),u(3),u(1),5601177),M(i,t+u(3),e+n-u(6),T,T,k.white),M(i,t+T,e+n-u(2),s-T*2,T,k.leaf)}function ju(i,t,e){M(i,t+T,e,u(4),T,k.offWhite),M(i,t,e+T,u(6),u(4),k.white),M(i,t+T,e+u(5),u(4),T,k.offWhite),M(i,t+T,e+T,u(4),u(4),k.cream),M(i,t+u(3),e+T,T,T,k.black),M(i,t+u(5)-T,e+u(3),T,T,k.black),M(i,t+u(3),e+u(5)-T,T,T,k.black),M(i,t+T+1,e+u(3),T,T,k.black),M(i,t+u(3),e+u(2),T,u(2),k.black),M(i,t+u(3),e+u(3),T,T,k.red)}function zi(i,t,e){M(i,t,e,u(2),u(3),k.white),M(i,t,e+u(2),u(2),T,k.offWhite),M(i,t+u(2),e+T,T,T,k.offWhite),M(i,t,e,u(2),T,11171652)}function sn(i,t,e){M(i,t+3,e+3,u(4),u(5),k.offWhite),M(i,t,e,u(4),u(5),k.paper),M(i,t+T,e+u(1),u(2),1,k.metalDark),M(i,t+T,e+u(2),u(3)-1,1,k.metalDark),M(i,t+T,e+u(3),u(2)+1,1,k.metalDark)}function ha(i,t,e,s){re(i,t,e,u(4),u(4)),M(i,t,e,u(4),u(4),s),M(i,t,e,u(4),T,k.paleWood),M(i,t,e+u(3),u(4),T,k.darkWood),M(i,t+T,e+T,u(2),u(2),k.offWhite)}function X0(i,t,e){const s=u(9),n=u(18);re(i,t,e,s,n),M(i,t,e,s,n,k.vendingBody),M(i,t,e,T,n,k.metalMid),M(i,t,e,s,T,k.metalDark),M(i,t+T,e+u(2),s-T*2,u(10),k.vendingGlass),M(i,t+T,e+u(2),s-T*2,T,k.vendingLight);const o=[k.bookRed,k.bookOrange,k.bookGreen,k.bookBlue,k.bookYellow,k.bookPink];for(let r=0;r<4;r++){for(let l=0;l<3;l++)M(i,t+u(2)+l*u(2),e+u(3)+r*u(2),u(1)+1,u(1)+1,o[(r*2+l)%o.length]);M(i,t+T,e+u(4)+r*u(2),s-T*2,1,k.metalDark)}M(i,t+T,e+u(13),s-T*2,u(3),k.metalFrame),M(i,t+s-u(2),e+u(14),T,T,k.ledRed),M(i,t+s-u(2),e+u(15),T,T,k.green),M(i,t,e+n-T,s,T,k.metalDark)}function Z0(i,t,e){const s=u(7),n=u(16);re(i,t,e,s,n),M(i,t,e,s,n,k.fridgeBody),M(i,t,e,s,T,k.metalShine),M(i,t,e,T,n,k.fridgeLight),M(i,t+T,e+T,s-T*2,n-T*2,k.fridgeLight),M(i,t+T,e+u(5),s-T*2,T,k.fridgeDark),M(i,t+s-T*2,e+u(2),T,u(2),k.fridgeHandle),M(i,t+s-T*2,e+u(7),T,u(2),k.fridgeHandle),M(i,t,e+n-T,s,T,k.fridgeDark)}function K0(i,t,e){M(i,t,e,u(5),u(7),k.metalDark),M(i,t,e,T,u(7),k.metalMid),M(i,t,e,u(5),T,k.metalBright),M(i,t+u(1),e+T,u(3),u(3),k.screenBlue),M(i,t+u(1),e+T,u(3),T,k.screenGlow),M(i,t+T,e+u(4),u(3),u(2),k.metalMid),M(i,t+u(1),e+u(4),T,T,k.red),M(i,t+u(2),e+u(4),T,T,k.led),M(i,t,e+u(6),u(5),T,k.metalFrame),M(i,t+u(1),e+u(5)+2,u(2),u(2),k.white)}function Q0(i,t,e){M(i,t,e+u(3),u(4),u(6),k.fridgeLight),M(i,t,e+u(3),T,u(6),k.fridgeBody),M(i,t,e+u(3),u(4),T,k.metalShine),M(i,t+T,e,u(2),u(4),k.screenBlue),M(i,t+T,e,u(2),T,k.screenGlow),M(i,t+T,e+u(5),T,T,k.blue),M(i,t+u(2),e+u(5),T,T,k.red),M(i,t,e+u(8),u(4),T,k.fridgeDark)}function J0(i,t,e,s){re(i,t,e,s,u(9)),M(i,t,e+u(5),s,u(5),k.deskTop),M(i,t,e+u(5),T,u(5),k.deskHighlight);const n=u(5);for(let o=0;o<s-T;o+=n+2)M(i,t+o+2,e+u(6),n-1,u(3),k.deskEdge),M(i,t+o+u(2),e+u(7),T,T,k.metalMid);M(i,t,e,s,u(5),k.deskTop),M(i,t+T,e+T,s-T*2,u(3),k.deskHighlight),M(i,t,e,s,T,k.white),M(i,t,e+u(5)-T,s,T,k.deskEdge)}function tv(i,t,e,s,n){re(i,t,e,s,n),M(i,t,e,s,n,k.whiteboardFrame),M(i,t+T,e+T,s-T*2,n-T*2,k.whiteboardSurface);const o=Math.floor((s-u(5))/3),r=[k.bookRed,k.bookYellow,k.bookGreen];for(let l=0;l<3;l++){const h=t+u(2)+l*(o+T);M(i,h,e+u(2),o,u(2),r[l]),M(i,h,e+u(2),o,T,15658734);const d=[k.stickyYellow,k.stickyBlue,k.stickyPink,k.stickyGreen,k.stickyOrange,k.stickyPurple],c=l===0?3:l===1?2:1;for(let f=0;f<c;f++)M(i,h+2,e+u(5)+f*(u(3)+2),o-4,u(2),d[(l+f*2)%d.length]),M(i,h+2,e+u(5)+f*(u(3)+2),o-4,1,15658734),M(i,h+T,e+u(5)+f*(u(3)+2)+T+1,o-T*2,1,k.metalDark)}}function ev(i,t,e){const s=u(22),n=u(15);re(i,t,e,s,n),M(i,t,e,s,n,k.screenFrame),M(i,t,e,s,T,k.metalMid),M(i,t+T,e+T,s-T*2,n-T*2,k.screenDark),M(i,t+u(2),e+u(2),s-u(4),n-u(4),k.screenBlue);const o=t+s/2,r=e+n/2;M(i,o-u(3),r-u(3),u(6),u(6),1140411),M(i,o-u(2),r-u(1),u(3),u(2),k.leafDark),M(i,o+u(1),r,u(2),u(1),k.leaf),M(i,t+u(2),e+u(2),s-u(4),1,4491468),M(i,t+u(2),e+n-u(3),s-u(4),1,4491468),M(i,t+u(4),e+u(4),T,T,k.led),M(i,t+s-u(6),e+u(4),T,T,k.ledRed),M(i,t+s/2-u(1),e+n,u(2),T,k.metalDark),M(i,t+s/2-u(2),e+n+T,u(4),T,k.metalDark)}function sv(i,t,e){M(i,t-u(7),e-u(1),u(14),u(2),k.portalDeep),M(i,t-u(1),e-u(7),u(2),u(14),k.portalDeep),M(i,t-u(5),e-u(6),u(10),T,k.portalMid),M(i,t-u(6),e-u(5),T,u(10),k.portalMid),M(i,t-u(5),e+u(5),u(10),T,k.portalMid),M(i,t+u(5),e-u(5),T,u(10),k.portalMid),M(i,t-u(4),e-u(5),u(8),T,k.portalLight),M(i,t-u(5),e-u(4),T,u(8),k.portalLight),M(i,t-u(4),e+u(4),u(8),T,k.portalLight),M(i,t+u(4),e-u(4),T,u(8),k.portalLight),M(i,t-u(3),e-u(3),u(6),u(6),k.portalDeep),M(i,t-u(2),e-u(2),u(4),u(4),k.portalMid),M(i,t-u(1),e-u(1),u(2),u(2),k.portalGlow),M(i,t-u(4),e,T,T,k.portalGlow),M(i,t+u(3),e-u(1),T,T,k.portalGlow),M(i,t,e+u(3),T,T,k.portalGlow)}function iv(i,t,e,s,n){Si(i,t+u(2),e+u(4),!0),Si(i,t+u(22),e+u(4),!0),Si(i,t+u(42),e+u(4),!0),Si(i,t+u(62),e+u(4),!1),Si(i,t+u(2),e+u(23),!1),Si(i,t+u(2),e+u(42),!1),_o(i,t+u(20),e+u(33),u(14),u(7)),Gt(i,t+u(24),e+u(42)),Gt(i,t+u(24),e+u(27)),sn(i,t+u(22),e+u(34)),zi(i,t+u(30),e+u(34)),_o(i,t+u(44),e+u(33),u(14),u(7)),Gt(i,t+u(48),e+u(42)),Gt(i,t+u(48),e+u(27)),sn(i,t+u(46),e+u(35)),ls(i,t+u(2),e+n-u(12)),ls(i,t+s-u(9),e+u(22)),Cs(i,t+s-u(6),e+n-u(8)),xn(i,t+s-u(8),e+n-u(15)),xn(i,t+s-u(15),e+n-u(15))}function nv(i,t,e,s,n){yn(i,t+u(2),e+u(4)),yn(i,t+u(13),e+u(4)),yn(i,t+u(24),e+u(4)),yn(i,t+s-u(10),e+u(25)),yn(i,t+s-u(10),e+u(45)),fh(i,t+u(2),e+u(25)),Gt(i,t+u(6),e+u(37)),fh(i,t+u(2),e+u(47)),Gt(i,t+u(6),e+u(59)),M(i,t+u(11),e+u(22),T,n-u(24),k.metalFrame),M(i,t+u(22),e+u(22),T,n-u(24),k.metalFrame),M(i,t+u(36),e+u(6),u(7),u(12),k.metalFrame),M(i,t+u(37),e+u(7),T,T,k.led),M(i,t+u(39),e+u(7),T,T,k.led),M(i,t+u(37),e+u(9),T,T,k.ledRed),M(i,t+u(39),e+u(9),T,T,k.led),M(i,t+u(37),e+u(11),T,T,k.ledBlue),M(i,t+u(39),e+u(11),T,T,k.ledYellow)}function ov(i,t,e,s,n){ev(i,t+u(2),e+u(4)),yn(i,t+s-u(10),e+u(4)),xr(i,t+u(2),e+u(25)),Gt(i,t+u(6),e+u(37)),xr(i,t+u(26),e+u(25)),Gt(i,t+u(30),e+u(37)),_o(i,t+u(12),e+u(49),u(16),u(6)),M(i,t+u(14),e+u(50),u(10),u(3),k.metalDark),M(i,t+u(14),e+u(50),u(10),T,k.metalMid);for(let o=0;o<6;o++)M(i,t+u(15)+o*u(1)+2,e+u(51)+2,T-1,T-1,o<5?k.led:k.ledRed);ls(i,t+u(2),e+n-u(13)),Cs(i,t+s-u(5),e+n-u(9))}function rv(i,t,e,s,n){xn(i,t+u(2),e+u(4)),xn(i,t+u(10),e+u(4)),xn(i,t+u(18),e+u(4)),xn(i,t+u(26),e+u(4)),Si(i,t+u(2),e+u(19),!0),xr(i,t+u(26),e+u(23)),Gt(i,t+u(30),e+u(35)),ha(i,t+u(2),e+u(39),k.paleWood),ha(i,t+u(8),e+u(41),k.medWood),ha(i,t+u(2),e+u(45),k.wood),sn(i,t+u(38),e+u(6)),sn(i,t+u(28),e+u(25)),Cs(i,t+s-u(5),e+n-u(9)),ls(i,t+s-u(9),e+u(19))}function av(i,t,e,s,n){ul(i,t+s/2,e+n/2-u(2),u(20)),Gt(i,t+s/2-u(14),e+n/2-u(13)),Gt(i,t+s/2+u(9),e+n/2-u(13)),Gt(i,t+s/2-u(18),e+n/2-u(3)),Gt(i,t+s/2+u(14),e+n/2-u(3)),Gt(i,t+s/2-u(14),e+n/2+u(8)),Gt(i,t+s/2+u(9),e+n/2+u(8)),pl(i,t+u(4),e+u(4),u(26),u(14)),pl(i,t+u(34),e+u(4),u(22),u(14)),Vu(i,t+s-u(16),e+u(4),u(12),u(8)),sn(i,t+s/2-u(5),e+n/2-u(4)),zi(i,t+s/2+u(3),e+n/2-u(2)),ls(i,t+u(2),e+n-u(14)),ls(i,t+s-u(9),e+n-u(14))}function lv(i,t,e,s,n){Vu(i,t+u(10),e+u(4),u(16),u(9)),Si(i,t+u(2),e+u(4),!1),mh(i,t+u(3),e+u(19),u(18)),_o(i,t+u(5),e+u(31),u(14),u(6)),zi(i,t+u(9),e+u(32)),zi(i,t+u(14),e+u(32)),sn(i,t+u(7),e+u(33)),mh(i,t+u(26),e+u(23),u(12)),_o(i,t+u(28),e+u(37),u(8),u(5)),zi(i,t+u(30),e+u(38)),ls(i,t+u(2),e+n-u(13)),Cs(i,t+s-u(5),e+u(4)),ju(i,t+s-u(9),e+u(5))}function cv(i,t,e,s,n){sv(i,t+s/2,e+n/2-u(4));const o=t+(s-u(16))/2,r=e+n-u(14);M(i,o,r,u(16),u(5),k.sofaBody),M(i,o+T,r+T,u(14),u(3),k.sofaHighlight),M(i,o,r,u(16),T,k.sofaDark),M(i,o,r+u(4),u(16),T,k.sofaDark),Cs(i,t+u(2),e+u(7)),Cs(i,t+s-u(5),e+u(7)),ls(i,t+u(2),e+n-u(14)),ls(i,t+s-u(9),e+n-u(14));for(let l=0;l<4;l++)M(i,t+u(4)+l*u(7),e+u(5),T,T,k.portalGlow)}function hv(i,t,e,s,n){J0(i,t+u(2),e+u(4),u(30)),K0(i,t+u(4),e+u(-1)),zi(i,t+u(10),e+u(1)),Z0(i,t+u(34),e+u(4)),X0(i,t+s-u(11),e+u(4)),Q0(i,t+u(45),e+u(4)),ul(i,t+u(18),e+u(33),u(11)),Gt(i,t+u(10),e+u(29)),Gt(i,t+u(22),e+u(29)),Gt(i,t+u(10),e+u(38)),Gt(i,t+u(22),e+u(38)),zi(i,t+u(17),e+u(32)),ul(i,t+u(48),e+u(33),u(11)),Gt(i,t+u(40),e+u(29)),Gt(i,t+u(52),e+u(29)),Gt(i,t+u(40),e+u(38)),Gt(i,t+u(52),e+u(38)),zi(i,t+u(47),e+u(32)),ju(i,t+u(58),e+u(5)),Cs(i,t+u(2),e+n-u(9)),Cs(i,t+s-u(5),e+n-u(9))}function dv(i,t,e,s,n){tv(i,t+u(2),e+u(4),u(32),u(20));const o=[k.stickyYellow,k.stickyPink,k.stickyGreen,k.stickyBlue,k.stickyOrange,k.stickyPurple];for(let r=0;r<6;r++)Y0(i,t+u(38)+r%3*u(5),e+u(4)+Math.floor(r/3)*u(5),o[r]);j0(i,t+u(4),e+u(31)),Gt(i,t+u(7),e+u(42)),xr(i,t+u(30),e+u(31)),Gt(i,t+u(34),e+u(42)),sn(i,t+u(46),e+u(33)),pl(i,t+u(52),e+u(4),u(14),u(12)),ls(i,t+s-u(9),e+n-u(14)),Cs(i,t+u(2),e+n-u(9))}const Ve={search:iv,terminal:nv,web:ov,files:rv,thinking:av,messaging:lv,spawn:cv,idle:hv,tasks:dv},gh={search:{wallMain:15787220,wallDark:14471360,wallLight:16314596,wallBaseboard:13155496,floorType:"wood",floorA:13942944,floorB:13416600,floorGrid:12101760},terminal:{wallMain:4737120,wallDark:3684424,wallLight:5789808,wallBaseboard:3158080,floorType:"dark",floorA:2763324,floorB:3289674,floorGrid:2236980},web:{wallMain:8943784,wallDark:7364760,wallLight:9996472,wallBaseboard:6312064,floorType:"carpet",floorA:8684736,floorB:7895220,floorGrid:6842532},files:{wallMain:14734532,wallDark:13155500,wallLight:15523016,wallBaseboard:12101784,floorType:"wood",floorA:13679768,floorB:12890248,floorGrid:11575416},thinking:{wallMain:8943784,wallDark:7364760,wallLight:9996472,wallBaseboard:6312064,floorType:"carpet",floorA:9737416,floorB:8947900,floorGrid:7895212},messaging:{wallMain:15788252,wallDark:14209220,wallLight:16314600,wallBaseboard:13156528,floorType:"tile",floorA:15789284,floorB:14999768,floorGrid:13683908},spawn:{wallMain:4737120,wallDark:3684424,wallLight:5789808,wallBaseboard:3158080,floorType:"dark",floorA:3158090,floorB:3816020,floorGrid:2631740},idle:{wallMain:15260872,wallDark:13681840,wallLight:15787220,wallBaseboard:12629152,floorType:"tile",floorA:15788248,floorB:14998728,floorGrid:13945012},tasks:{wallMain:12631232,wallDark:11052200,wallLight:13683920,wallBaseboard:9999512,floorType:"carpet",floorA:12631232,floorB:11841716,floorGrid:10789028}},Je=14,Re=10,le=6,ts=6,uv=1710638,pv=.55;function Et(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function fv(i,t,e,s,n,o,r,l){Et(i,t,e,s,n,o);const h=20;let d=0;for(let c=0;c<n;c+=h){const f=Math.min(h,n-c);d%2===1&&Et(i,t,e+c,s,f,r),Et(i,t,e+c,s,1,l);const g=d%2*32;for(let m=g;m<s;m+=64)Et(i,t+m,e+c+1,1,f-2,l);d++}}function mv(i,t,e,s,n,o,r,l){Et(i,t,e,s,n,o);const h=24;for(let d=0;d<n;d+=h)for(let c=0;c<s;c+=h)(c/h+d/h)%2===0&&Et(i,t+c,e+d,Math.min(h,s-c),Math.min(h,n-d),r),Et(i,t+c,e+d,Math.min(h,s-c),1,l),Et(i,t+c,e+d,1,Math.min(h,n-d),l)}function gv(i,t,e,s,n,o,r,l){Et(i,t,e,s,n,o);for(let h=0;h<n;h+=12)for(let d=h/12%2*12;d<s;d+=24)Et(i,t+d,e+h,4,4,r);Et(i,t,e,s,4,l),Et(i,t,e+n-4,s,4,l),Et(i,t,e,4,n,l),Et(i,t+s-4,e,4,n,l)}function vv(i,t,e,s,n,o,r,l){Et(i,t,e,s,n,o);const h=16;for(let d=0;d<n;d+=h)for(let c=0;c<s;c+=h)(c/h+d/h)%2===0&&Et(i,t+c,e+d,Math.min(h,s-c),Math.min(h,n-d),r),Et(i,t+c,e+d,Math.min(h,s-c),1,l),Et(i,t+c,e+d,1,Math.min(h,n-d),l)}const yv={wood:fv,tile:mv,carpet:gv,dark:vv};class bv{constructor(){y(this,"zones",new Map);y(this,"container",new Nt);y(this,"themeDecorators",null);y(this,"usePixelRooms",!1);for(const t of ne){const e=this.createZone(t);this.zones.set(t.id,e),this.container.addChild(e.container)}}setThemeDecorators(t,e=!1){this.themeDecorators=t,this.usePixelRooms=e,this.rebuild()}createZone(t){const e=new Nt;e.position.set(t.x,t.y);const s=new Ht;e.addChild(s);const n=new Ht;this.drawRoom(n,t),e.addChild(n);const o=new Ht;return e.addChild(o),this.usePixelRooms?this.addRetroLabel(e,t):this.addGlassLabel(e,t),{container:e,staticBg:n,glowBorder:o,outerGlow:s,config:t,agentCount:0,currentGlow:0}}addRetroLabel(t,e){const s=gh[e.id],n=s&&(s.floorType==="dark"||s.floorType==="carpet"),o=new Ye({fontSize:11,fontFamily:"'Inter', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif",fill:16777215,fontWeight:"700",letterSpacing:.5}),r=new Qi({text:`${e.icon} ${e.label}`,style:o});r.position.set(Re+8,1);const l=r.width+16,h=r.height+6,d=new Ht;d.roundRect(Re+2,-1,l,h,4).fill({color:0,alpha:n?.5:.55}),t.addChild(d),t.addChild(r)}addGlassLabel(t,e){const s=new Ye({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}}),n=new Qi({text:`${e.icon} ${e.label}`,style:s});n.position.set(14,10);const o=n.width+20,r=n.height+8,l=new Ht;l.roundRect(6,5,o,r,8).fill({color:0,alpha:.3}),t.addChild(l),t.addChild(n)}drawRoom(t,e){var o;if(this.usePixelRooms){this.drawPixelRoom(t,e);return}t.roundRect(0,0,e.width,e.height,8).fill({color:uv,alpha:pv}),t.roundRect(0,0,e.width,e.height,8).stroke({color:e.color,width:1,alpha:.15});const s=14,n=((o=this.themeDecorators)==null?void 0:o[e.id])??Ve[e.id];n&&n(t,s,s+16,e.width-s*2,e.height-s*2-16)}drawPixelRoom(t,e){var v;const s=e.width,n=e.height,o=gh[e.id];if(!o)return;Et(t,0,0,s,n,o.wallMain);const r=Re,l=Je,h=s-Re-ts,d=n-Je-le,c=yv[o.floorType];c(t,r,l,h,d,o.floorA,o.floorB,o.floorGrid),Et(t,0,0,s,Je,o.wallDark),Et(t,Re,Je-2,s-Re-ts,2,o.wallLight),Et(t,0,0,Re,n,o.wallMain),Et(t,Re-2,Je,2,n-Je-le,o.wallLight),Et(t,0,n-le,s,le,o.wallLight),Et(t,Re,n-le,s-Re-ts,1,o.wallBaseboard),Et(t,s-ts,0,ts,n,o.wallLight),Et(t,s-ts,Je,1,n-Je-le,o.wallBaseboard),Et(t,0,0,Re,Je,o.wallDark),Et(t,s-ts,0,ts,Je,o.wallMain),Et(t,0,n-le,Re,le,o.wallMain),Et(t,s-ts,n-le,ts,le,o.wallLight);const f=Math.min(Math.floor(s*.2),60),g=Math.floor((s-f)/2);Et(t,g,n-le,f,le,o.floorA),Et(t,g,n-le,2,le,o.wallBaseboard),Et(t,g+f-2,n-le,2,le,o.wallBaseboard);const m=((v=this.themeDecorators)==null?void 0:v[e.id])??Ve[e.id];m&&m(t,r,l,h,d)}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;e.currentGlow+=(s-e.currentGlow)*Math.min(1,3*t/1e3);const n=e.currentGlow;if(e.glowBorder.clear(),n>.01){const o=1+2*n;e.glowBorder.rect(-o,-o,e.config.width+o*2,e.config.height+o*2).stroke({color:e.config.color,width:o,alpha:.7*n})}if(e.outerGlow.clear(),n>.01){const o=8*n;e.outerGlow.rect(-o,-o,e.config.width+o*2,e.config.height+o*2).stroke({color:e.config.color,width:o,alpha:.15*n})}}}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 ne){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 da=.5,ua=3,wv=.001;class _v{constructor(t,e){y(this,"zoom",1);y(this,"dragging",!1);y(this,"lastMouse",{x:0,y:0});y(this,"onWheel",t=>{t.preventDefault();const e=this.zoom;this.zoom=Math.max(da,Math.min(ua,this.zoom-t.deltaY*wv));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)});y(this,"onPointerDown",t=>{t.button!==0&&t.button!==1||(this.dragging=!0,this.lastMouse.x=t.clientX,this.lastMouse.y=t.clientY)});y(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});y(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(da,Math.min(ua,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,d=l-e*this.zoom;this.world.position.x+=(h-this.world.position.x)*s,this.world.position.y+=(d-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(da,Math.min(ua,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 vh=120,pa=100,ln=48,Es=4;class xv{constructor(){y(this,"lastW",0);y(this,"lastH",0)}computeLayout(t,e){const s=Math.max(t,vh*3+Es*4+ln*2),n=Math.max(e,pa*3+Es*4+ln*2);if(s===this.lastW&&n===this.lastH)return{worldWidth:s,worldHeight:n};this.lastW=s,this.lastH=n;const o=Oo.reduce((g,m)=>g+m,0),r=s-ln*2-Es*(lh-1),l=n-ln*2-Es*(Oo.length-1),h=r/lh,d=Oo.map(g=>Math.max(pa,g/o*l)),c=[];let f=ln;for(let g=0;g<Oo.length;g++)c.push(f),f+=d[g]+Es;for(const g of ne)g.x=ln+g.colStart*(h+Es),g.y=c[g.rowStart],g.width=Math.max(vh,g.colSpan*h+(g.colSpan-1)*Es),g.height=Math.max(pa,d[g.rowStart]*g.rowSpan+(g.rowSpan-1)*Es);return G0(s,n),{worldWidth:s,worldHeight:n}}invalidate(){this.lastW=0,this.lastH=0}}const Sv=1710666,fa=.45,Tv=.15,Go=6,yh=8,ma=18,ga=22,kv=1e3;class Cv{constructor(t,e){y(this,"overlay",new Ht);y(this,"_enabled",!1);y(this,"targetAlpha",0);y(this,"updateTimer",0);this.overlay.rect(0,0,t,e).fill({color:Sv,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>=ga||e<Go?s=fa:e>=ma&&e<ga?s=fa*((e-ma)/(ga-ma)):e>=Go&&e<yh?s=fa*(1-(e-Go)/(yh-Go)):s=0,this.targetAlpha=Math.max(s,Tv)}update(t){if(!this._enabled)return;this.updateTimer+=t,this.updateTimer>=kv&&(this.updateTimer=0,this.computeTargetAlpha());const e=1-Math.exp(-3*t/1e3);this.overlay.alpha+=(this.targetAlpha-this.overlay.alpha)*e}}const Av=[["search","terminal"],["terminal","web"],["files","thinking"],["thinking","messaging"],["spawn","idle"],["idle","tasks"],["search","files"],["terminal","thinking"],["web","messaging"],["files","spawn"],["thinking","idle"],["messaging","tasks"]],Ev=.04,Mv=.12,bh=3,Iv=1200;class Pv{constructor(){y(this,"container",new Nt);y(this,"linesGfx",new Ht);y(this,"particleGfx",new Ht);y(this,"particles",[]);y(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/Iv,color:s,alpha:.8})}getZoneCenter(t){const e=Zt.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 Av){const n=this.getZoneCenter(e),o=this.getZoneCenter(s),r=`${e}->${s}`,l=`${s}->${e}`,d=this.activeFlows.has(r)||this.activeFlows.has(l)?Mv:Ev,c=Zt.get(e),f=(c==null?void 0:c.color)??8947848,g=(n.x+o.x)/2,m=(n.y+o.y)/2-20;this.linesGfx.moveTo(n.x,n.y),this.linesGfx.quadraticCurveTo(g,m,o.x,o.y),this.linesGfx.stroke({color:f,width:1,alpha:d})}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,bh).fill({color:e.color,alpha:h}),this.particleGfx.circle(l.x,l.y,bh*2).fill({color:e.color,alpha:h*.3})}}}class Lv{constructor(t){y(this,"root",new Nt);y(this,"gridLayer",new Nt);y(this,"zoneLayer");y(this,"agentLayer",new Nt);y(this,"effectLayer",new Nt);y(this,"uiLayer",new Nt);y(this,"zoneRenderer");y(this,"camera");y(this,"dayNight");y(this,"flowLines");y(this,"layoutEngine");y(this,"app");y(this,"_worldWidth",1100);y(this,"_worldHeight",980);y(this,"gridGraphics");y(this,"gridRendererFn");y(this,"resizeHandler");y(this,"resizeRaf",0);y(this,"resizeObserver",null);this.app=t,this.layoutEngine=new xv;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=uh(n,o),this.gridLayer.addChild(this.gridGraphics),this.zoneRenderer=new bv,this.zoneLayer=this.zoneRenderer.container,this.flowLines=new Pv,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 Cv(n,o),this.root.addChild(this.dayNight.overlay),t.stage.addChild(this.root),this.camera=new _v(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.rebuildGrid(),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 Nt?t:t.container;this.agentLayer.addChild(e)}removeAgent(t){const e=t instanceof Nt?t:t.container;this.agentLayer.removeChild(e)}addEffect(t){this.effectLayer.addChild(t)}removeEffect(t){this.effectLayer.removeChild(t)}getZoneCenter(t){const e=Zt.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 Zt.get(t)}setZoneAgentCount(t,e){this.zoneRenderer.setAgentCount(t,e)}rebuildZones(){this.zoneRenderer.rebuild()}applyTheme(t){this.zoneRenderer.setThemeDecorators(t.decorators,t.pixelRooms??!1),this.app.renderer.background.color=t.colors.background,this.gridRendererFn=t.gridRenderer,this.rebuildGrid()}rebuildGrid(){this.gridLayer.removeChildren(),this.gridGraphics.destroy(),this.gridGraphics=uh(this._worldWidth,this._worldHeight,this.gridRendererFn),this.gridLayer.addChild(this.gridGraphics)}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",S="body",p="outline",L="highlight",$t="eye",w="skin",$v={idle:[[[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,p,a,a,a,a],[a,a,a,p,L,L,L,L,L,L,L,L,p,a,a,a],[a,a,a,p,L,w,w,w,w,w,w,L,p,a,a,a],[a,a,a,p,w,$t,$t,w,w,$t,$t,w,p,a,a,a],[a,a,a,p,w,w,w,w,w,w,w,w,p,a,a,a],[a,a,a,a,p,p,w,w,w,w,p,p,a,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,p,p,p,a,a,p,p,p,a,a,a,a]],[[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,p,a,a,a,a],[a,a,a,p,L,L,L,L,L,L,L,L,p,a,a,a],[a,a,a,p,L,w,w,w,w,w,w,L,p,a,a,a],[a,a,a,p,w,p,p,w,w,p,p,w,p,a,a,a],[a,a,a,p,w,w,w,w,w,w,w,w,p,a,a,a],[a,a,a,a,p,p,w,w,w,w,p,p,a,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,p,p,p,a,a,p,p,p,a,a,a,a]]],walk:[[[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,p,a,a,a,a],[a,a,a,p,L,L,L,L,L,L,L,L,p,a,a,a],[a,a,a,p,L,w,w,w,w,w,w,L,p,a,a,a],[a,a,a,p,w,$t,$t,w,w,$t,$t,w,p,a,a,a],[a,a,a,p,w,w,w,w,w,w,w,w,p,a,a,a],[a,a,a,a,p,p,w,w,w,w,p,p,a,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,p,p,a,a,a,p,p,a,a,a,a,a],[a,a,a,a,p,p,a,a,a,a,p,p,a,a,a,a],[a,a,a,p,p,p,a,a,a,a,p,p,p,a,a,a]],[[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,p,a,a,a,a],[a,a,a,p,L,L,L,L,L,L,L,L,p,a,a,a],[a,a,a,p,L,w,w,w,w,w,w,L,p,a,a,a],[a,a,a,p,w,$t,$t,w,w,$t,$t,w,p,a,a,a],[a,a,a,p,w,w,w,w,w,w,w,w,p,a,a,a],[a,a,a,a,p,p,w,w,w,w,p,p,a,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,a,p,p,a,a,a,a],[a,a,a,a,p,p,a,a,a,a,p,p,a,a,a,a],[a,a,a,p,p,p,a,a,a,p,p,p,a,a,a,a]]],working:[[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,p,a,a,a,a],[a,a,a,p,L,L,L,L,L,L,L,L,p,a,a,a],[a,a,a,p,L,w,w,w,w,w,w,L,p,a,a,a],[a,a,a,p,w,$t,$t,w,w,$t,$t,w,p,a,a,a],[a,a,a,p,w,w,p,p,p,p,w,w,p,a,a,a],[a,a,a,a,p,p,w,w,w,w,p,p,a,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,w,w,p,S,S,S,S,S,S,p,w,w,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,p,p,p,a,a,p,p,p,a,a,a,a]],sleeping:[[[a,a,a,a,a,a,p,p,p,p,p,p,a,a,a,a],[a,a,a,a,a,p,L,L,L,L,L,L,p,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,L,L,p,a,a],[a,a,a,a,p,L,w,w,w,w,w,w,L,p,a,a],[a,a,a,a,p,w,p,p,w,w,p,p,w,p,a,a],[a,a,a,a,p,w,w,w,w,w,w,w,w,p,a,a],[a,a,a,a,a,p,p,w,w,w,w,p,p,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,p,p,p,a,a,p,p,p,a,a,a,a]],[[a,a,a,a,a,a,p,p,p,p,p,p,a,a,a,a],[a,a,a,a,a,p,L,L,L,L,L,L,p,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,L,L,p,a,a],[a,a,a,a,p,L,w,w,w,w,w,w,L,p,a,a],[a,a,a,a,p,w,p,p,w,w,p,p,w,p,a,a],[a,a,a,a,p,w,w,w,p,p,w,w,w,p,a,a],[a,a,a,a,a,p,p,w,w,w,w,p,p,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,p,p,p,a,a,p,p,p,a,a,a,a]]],done:[[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,p,L,L,L,L,L,L,p,a,a,a,a],[a,a,a,p,L,L,L,L,L,L,L,L,p,a,a,a],[a,a,a,p,L,w,w,w,w,w,w,L,p,a,a,a],[a,a,a,p,w,w,$t,w,w,$t,w,w,p,a,a,a],[a,a,a,p,w,w,w,p,p,w,w,w,p,a,a,a],[a,a,a,a,p,p,w,w,w,w,p,p,a,a,a,a],[a,a,a,a,a,p,S,S,S,S,p,a,a,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,w,w,p,S,S,S,S,S,S,p,w,w,a,a],[a,a,a,w,p,S,S,S,S,S,S,p,w,a,a,a],[a,a,a,a,p,S,S,S,S,S,S,p,a,a,a,a],[a,a,a,a,a,p,p,p,p,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,a,p,p,a,a,p,p,a,a,a,a,a],[a,a,a,a,p,p,p,a,a,p,p,p,a,a,a,a]],size:16},Bv={idle:[[[a,a,a,p,p,p,p,p,p,a,a,a],[a,a,p,L,L,L,L,L,L,p,a,a],[a,p,L,L,w,w,w,w,L,L,p,a],[a,p,w,$t,w,w,w,w,$t,w,p,a],[a,p,w,w,w,w,w,w,w,w,p,a],[a,a,p,p,w,w,w,w,p,p,a,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,w,p,S,S,S,S,S,S,p,w,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,p,p,p,a,a,p,p,p,a,a]],[[a,a,a,p,p,p,p,p,p,a,a,a],[a,a,p,L,L,L,L,L,L,p,a,a],[a,p,L,L,w,w,w,w,L,L,p,a],[a,p,w,p,w,w,w,w,p,w,p,a],[a,p,w,w,w,w,w,w,w,w,p,a],[a,a,p,p,w,w,w,w,p,p,a,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,w,p,S,S,S,S,S,S,p,w,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,p,p,p,a,a,p,p,p,a,a]]],walk:[[[a,a,a,p,p,p,p,p,p,a,a,a],[a,a,p,L,L,L,L,L,L,p,a,a],[a,p,L,L,w,w,w,w,L,L,p,a],[a,p,w,$t,w,w,w,w,$t,w,p,a],[a,p,w,w,w,w,w,w,w,w,p,a],[a,a,p,p,w,w,w,w,p,p,a,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,w,p,S,S,S,S,S,S,p,w,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,p,p,a,a,a,p,p,a,a,a],[a,a,p,p,a,a,a,a,p,p,a,a],[a,p,p,p,a,a,a,a,p,p,p,a]],[[a,a,a,p,p,p,p,p,p,a,a,a],[a,a,p,L,L,L,L,L,L,p,a,a],[a,p,L,L,w,w,w,w,L,L,p,a],[a,p,w,$t,w,w,w,w,$t,w,p,a],[a,p,w,w,w,w,w,w,w,w,p,a],[a,a,p,p,w,w,w,w,p,p,a,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,w,p,S,S,S,S,S,S,p,w,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,a,p,p,a,a,a,p,p,a,a],[a,a,p,p,a,a,a,a,p,p,a,a],[a,p,p,p,a,a,a,a,p,p,p,a]]],working:[[a,a,a,p,p,p,p,p,p,a,a,a],[a,a,p,L,L,L,L,L,L,p,a,a],[a,p,L,L,w,w,w,w,L,L,p,a],[a,p,w,$t,w,w,w,w,$t,w,p,a],[a,p,w,p,p,p,p,p,p,w,p,a],[a,a,p,p,w,w,w,w,p,p,a,a],[a,a,p,S,S,S,S,S,S,p,a,a],[w,w,p,S,S,S,S,S,S,p,w,w],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,p,p,p,a,a,p,p,p,a,a]],sleeping:[[[a,a,a,a,p,p,p,p,p,p,a,a],[a,a,a,p,L,L,L,L,L,L,p,a],[a,a,p,L,L,w,w,w,w,L,L,p],[a,a,p,w,p,w,w,w,w,p,w,p],[a,a,p,w,w,w,w,w,w,w,w,p],[a,a,a,p,p,w,w,w,w,p,p,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,w,p,S,S,S,S,S,S,p,w,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,p,p,p,a,a,p,p,p,a,a]],[[a,a,a,a,p,p,p,p,p,p,a,a],[a,a,a,p,L,L,L,L,L,L,p,a],[a,a,p,L,L,w,w,w,w,L,L,p],[a,a,p,w,p,w,w,w,w,p,w,p],[a,a,p,w,w,w,p,p,w,w,w,p],[a,a,a,p,p,w,w,w,w,p,p,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,w,p,S,S,S,S,S,S,p,w,a],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,p,p,p,a,a,p,p,p,a,a]]],done:[[a,a,a,p,p,p,p,p,p,a,a,a],[a,a,p,L,L,L,L,L,L,p,a,a],[a,p,L,L,w,w,w,w,L,L,p,a],[a,p,w,w,$t,w,w,$t,w,w,p,a],[a,p,w,w,p,w,w,p,w,w,p,a],[a,a,p,p,w,w,w,w,p,p,a,a],[a,a,p,S,S,S,S,S,S,p,a,a],[w,w,p,S,S,S,S,S,S,p,w,w],[a,a,p,S,S,S,S,S,S,p,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,a,p,p,a,a,p,p,a,a,a],[a,a,p,p,p,a,a,p,p,p,a,a]],size:12},A="transparent",at="body",F="outline",be="highlight",Bi="eye",Ti=[A,A,A,A,A,A,A,F,F,A,A,A,A,A,A,A],ki=[A,A,A,F,F,F,F,F,F,F,F,F,F,A,A,A],Ci=[A,A,A,F,at,at,at,at,at,at,at,at,F,A,A,A],lo=[A,A,A,F,at,Bi,Bi,at,at,Bi,Bi,at,F,A,A,A],fl=[A,A,A,F,at,F,F,at,at,F,F,at,F,A,A,A],Sn=[A,A,A,F,at,at,F,F,F,F,at,at,F,A,A,A],Ai=[A,A,A,F,F,F,F,F,F,F,F,F,F,A,A,A],Ei=[A,A,A,A,A,F,be,be,be,be,F,A,A,A,A,A],ge=[A,A,A,A,F,at,at,at,at,at,at,F,A,A,A,A],Mi=[A,A,F,F,F,at,at,at,at,at,at,F,F,F,A,A],Ii=[A,A,A,F,F,at,at,at,at,at,at,F,F,A,A,A],ve=[A,A,A,A,F,F,be,be,be,be,F,F,A,A,A,A],os=[A,A,A,A,F,F,F,A,A,F,F,F,A,A,A,A],Tn=[A,A,A,F,F,F,F,A,A,F,F,F,F,A,A,A],wh=[A,A,A,A,F,F,F,A,A,A,F,F,A,A,A,A],Rv=[A,A,A,F,F,F,A,A,A,A,F,F,F,A,A,A],_h=[A,A,A,A,A,F,F,A,A,F,F,F,A,A,A,A],Dv=[A,A,A,F,F,F,A,A,A,F,F,F,A,A,A,A],zv=[A,A,A,F,at,F,be,be,be,be,F,at,F,A,A,A],Fv=[A,A,A,F,at,at,at,F,F,at,at,at,F,A,A,A],Nv=[Ti,ki,Ci,lo,Sn,Ai,Ei,ge,Mi,Ii,ve,ge,ve,os,os,Tn],Ov=[Ti,ki,Ci,fl,Sn,Ai,Ei,ge,Mi,Ii,ve,ge,ve,os,os,Tn],Gv={idle:[Nv,Ov],walk:[[Ti,ki,Ci,lo,Sn,Ai,Ei,ge,Mi,Ii,ve,ge,ve,wh,wh,Rv],[Ti,ki,Ci,lo,Sn,Ai,Ei,ge,Mi,Ii,ve,ge,ve,_h,_h,Dv]],working:[Ti,ki,Ci,lo,zv,Ai,Ei,ge,Mi,Ii,ve,ge,ve,os,os,Tn],sleeping:[[[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],...[Ti,ki,Ci,fl,Sn,Ai,Ei,ge,Mi,Ii,ve,ge,ve,os,Tn].map(i=>[A,...i.slice(0,-1)])],[[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],...[Ti,ki,Ci,fl,Sn,Ai,Ei,ge,Mi,Ii,ve,ge,ve,os,Tn].map(i=>[A,...i.slice(0,-1)])]],done:[Ti,ki,Ci,lo,Fv,Ai,Ei,ge,Mi,Ii,ve,ge,ve,os,os,Tn],size:16},Ms=[A,A,A,A,A,F,F,A,A,A,A,A],Is=[A,A,F,F,F,F,F,F,F,F,A,A],Ps=[A,A,F,at,at,at,at,at,at,F,A,A],Wn=[A,A,F,Bi,Bi,at,at,Bi,Bi,F,A,A],va=[A,A,F,F,F,at,at,F,F,F,A,A],cn=[A,A,F,at,F,F,F,F,at,F,A,A],Ls=[A,A,F,F,F,F,F,F,F,F,A,A],ce=[A,A,A,F,at,at,at,at,F,A,A,A],$s=[A,F,F,F,at,at,at,at,F,F,F,A],De=[A,A,A,F,F,A,A,F,F,A,A,A],Bs=[A,A,F,F,F,A,A,F,F,F,A,A],xh=[A,A,F,F,A,A,A,A,F,F,A,A],Sh=[A,A,A,F,F,A,A,F,F,A,A,A],Wv=[A,A,F,at,be,be,be,be,at,F,A,A],Hv=[A,A,F,at,at,F,F,at,at,F,A,A],Uv={idle:[[Ms,Is,Ps,Wn,cn,Ls,ce,$s,ce,De,De,Bs],[Ms,Is,Ps,va,cn,Ls,ce,$s,ce,De,De,Bs]],walk:[[Ms,Is,Ps,Wn,cn,Ls,ce,$s,ce,xh,xh,Bs],[Ms,Is,Ps,Wn,cn,Ls,ce,$s,ce,Sh,Sh,Bs]],working:[Ms,Is,Ps,Wn,Wv,Ls,ce,$s,ce,De,De,Bs],sleeping:[[Ms,Is,Ps,va,cn,Ls,ce,$s,ce,De,De,Bs],[Ms,Is,Ps,va,cn,Ls,ce,$s,ce,De,De,Bs]],done:[Ms,Is,Ps,Wn,Hv,Ls,ce,$s,ce,De,De,Bs],size:12},I="transparent",we="body",V="outline",j="skin",Rs=[I,I,I,I,I,V,V,V,V,V,V,I,I,I,I,I],Ds=[I,I,I,I,V,j,j,j,j,j,j,V,I,I,I,I],zs=[I,I,I,V,j,j,j,j,j,j,j,j,V,I,I,I],Hn=[I,I,I,V,j,V,V,j,j,V,V,j,V,I,I,I],ya=[I,I,I,V,j,V,I,j,j,I,V,j,V,I,I,I],hn=[I,I,I,V,j,j,j,V,V,j,j,j,V,I,I,I],Fs=[I,I,I,I,V,j,V,V,V,V,j,V,I,I,I,I],ml=[I,I,I,I,I,I,V,j,j,V,I,I,I,I,I,I],kn=[I,I,I,I,V,j,we,j,j,we,j,V,I,I,I,I],gl=[I,I,I,I,V,we,j,we,we,j,we,V,I,I,I,I],vl=[I,I,j,j,V,j,we,j,j,we,j,V,j,j,I,I],yl=[I,I,I,I,I,V,j,j,j,j,V,I,I,I,I,I],bl=[I,I,I,I,I,V,j,V,V,j,V,I,I,I,I,I],wl=[I,I,I,I,I,V,j,I,I,j,V,I,I,I,I,I],qv=[I,I,I,I,V,V,j,I,I,j,V,V,I,I,I,I],ba=[I,I,I,I,V,j,I,I,I,I,j,V,I,I,I,I],Th=[I,I,I,V,V,j,I,I,I,j,V,V,I,I,I,I],Vv=[I,I,I,I,V,j,V,j,j,V,j,V,I,I,I,I],jv=[I,I,I,V,j,j,V,V,V,V,j,j,V,I,I,I],dn=[ml,kn,vl,gl,kn,yl,bl,wl,wl,qv],Yv={idle:[[Rs,Ds,zs,Hn,hn,Fs,...dn],[Rs,Ds,zs,ya,hn,Fs,...dn]],walk:[[Rs,Ds,zs,Hn,hn,Fs,ml,kn,vl,gl,kn,yl,bl,ba,ba,Th],[Rs,Ds,zs,Hn,hn,Fs,ml,kn,vl,gl,kn,yl,bl,wl,ba,Th]],working:[Rs,Ds,zs,Hn,Vv,Fs,...dn],sleeping:[[[I,...Rs.slice(0,-1)],[I,...Ds.slice(0,-1)],[I,...zs.slice(0,-1)],[I,...ya.slice(0,-1)],[I,...hn.slice(0,-1)],[I,...Fs.slice(0,-1)],...dn],[[I,...Rs.slice(0,-1)],[I,...Ds.slice(0,-1)],[I,...zs.slice(0,-1)],[I,...ya.slice(0,-1)],[I,...hn.slice(0,-1)],[I,...Fs.slice(0,-1)],...dn]],done:[Rs,Ds,zs,Hn,jv,Fs,...dn],size:16},Ns=[I,I,I,V,V,V,V,V,V,I,I,I],Os=[I,I,V,j,j,j,j,j,j,V,I,I],Un=[I,V,j,V,V,j,j,V,V,j,V,I],wa=[I,V,j,V,I,j,j,I,V,j,V,I],Oi=[I,V,j,j,V,V,V,V,j,j,V,I],Gs=[I,I,V,j,V,V,V,V,j,V,I,I],Ws=[I,I,V,j,we,j,j,we,j,V,I,I],Hs=[I,I,V,we,j,we,we,j,we,V,I,I],Us=[I,j,V,j,we,j,j,we,j,V,j,I],qs=[I,I,I,V,j,j,j,j,V,I,I,I],Me=[I,I,I,V,j,I,I,j,V,I,I,I],Vs=[I,I,V,V,j,I,I,j,V,V,I,I],_a=[I,I,V,j,I,I,I,I,j,V,I,I],Xv=[I,V,j,j,V,V,V,V,j,j,V,I],Zv={idle:[[Ns,Os,Un,Oi,Gs,Ws,Us,Hs,qs,Me,Me,Vs],[Ns,Os,wa,Oi,Gs,Ws,Us,Hs,qs,Me,Me,Vs]],walk:[[Ns,Os,Un,Oi,Gs,Ws,Us,Hs,qs,_a,_a,Vs],[Ns,Os,Un,Oi,Gs,Ws,Us,Hs,qs,Me,_a,Vs]],working:[Ns,Os,Un,Oi,Gs,Ws,Us,Hs,qs,Me,Me,Vs],sleeping:[[Ns,Os,wa,Oi,Gs,Ws,Us,Hs,qs,Me,Me,Vs],[Ns,Os,wa,Oi,Gs,Ws,Us,Hs,qs,Me,Me,Vs]],done:[Ns,Os,Un,Xv,Gs,Ws,Us,Hs,qs,Me,Me,Vs],size:12},E="transparent",ot="body",G="outline",Ri="highlight",Ce="eye",Yu=[E,E,E,E,E,E,G,G,G,G,E,E,E,E,E,E],Xu=[E,E,E,E,G,G,ot,ot,ot,ot,G,G,E,E,E,E],Zu=[E,E,E,G,ot,ot,ot,ot,ot,ot,ot,ot,G,E,E,E],xa=[E,E,E,G,ot,Ce,Ce,G,G,Ce,Ce,ot,G,E,E,E],Sa=[E,E,E,G,ot,G,G,G,G,G,G,ot,G,E,E,E],js=[E,E,E,G,G,G,G,G,G,G,G,G,G,E,E,E],Ys=[E,E,E,E,G,G,G,G,G,G,G,G,E,E,E,E],ar=[E,E,E,E,E,G,ot,ot,ot,ot,G,E,E,E,E,E],Pi=[E,E,E,E,G,ot,ot,ot,ot,ot,ot,G,E,E,E,E],lr=[E,E,E,G,G,ot,ot,ot,ot,ot,ot,G,G,E,E,E],cr=[E,E,G,G,G,ot,ot,ot,ot,ot,ot,G,G,G,E,E],hr=[E,E,E,E,G,G,Ri,Ri,Ri,Ri,G,G,E,E,E,E],Sr=[E,E,E,E,E,G,G,E,E,G,G,E,E,E,E,E],_l=[E,E,E,E,G,G,G,E,E,G,G,G,E,E,E,E],kh=[E,E,E,E,G,G,E,E,E,E,G,G,E,E,E,E],Kv=[E,E,E,G,G,G,E,E,E,E,G,G,G,E,E,E],Qv=[E,E,E,E,E,G,G,E,G,G,E,E,E,E,E,E],Jv=[E,E,E,E,G,G,E,E,E,G,G,E,E,E,E,E],ty=[E,E,E,G,ot,Ce,G,G,G,G,Ce,ot,G,E,E,E],ey=[E,E,E,G,ot,G,Ce,G,G,Ce,G,ot,G,E,E,E],un=[Yu,Xu,Zu],Ch=[[E,...Yu.slice(0,-1)],[E,...Xu.slice(0,-1)],[E,...Zu.slice(0,-1)]],qn=[ar,Pi,cr,lr,Pi,hr,Sr,Sr,_l],sy={idle:[[...un,xa,js,Ys,...qn],[...un,Sa,js,Ys,...qn]],walk:[[...un,xa,js,Ys,ar,Pi,cr,lr,Pi,hr,kh,kh,Kv],[...un,xa,js,Ys,ar,Pi,cr,lr,Pi,hr,Qv,Jv,_l]],working:[...un,ty,js,Ys,ar,Pi,cr,lr,Pi,hr,Sr,Sr,_l],sleeping:[[[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],...Ch,[E,...Sa.slice(0,-1)],[E,...js.slice(0,-1)],[E,...Ys.slice(0,-1)],...qn],[[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],...Ch,[E,...Sa.slice(0,-1)],[E,...js.slice(0,-1)],[E,...Ys.slice(0,-1)],...qn]],done:[...un,ey,js,Ys,...qn],size:16},Xs=[E,E,E,G,G,G,G,G,G,E,E,E],Zs=[E,E,G,ot,ot,ot,ot,ot,ot,G,E,E],Ks=[E,G,ot,ot,ot,ot,ot,ot,ot,ot,G,E],Wo=[E,G,ot,Ce,Ce,G,G,Ce,Ce,ot,G,E],Ta=[E,G,ot,G,G,G,G,G,G,ot,G,E],Qs=[E,G,G,G,G,G,G,G,G,G,G,E],he=[E,E,G,ot,ot,ot,ot,ot,ot,G,E,E],Js=[E,G,G,ot,ot,ot,ot,ot,ot,G,G,E],ti=[E,E,G,G,Ri,Ri,Ri,Ri,G,G,E,E],Ie=[E,E,E,G,G,E,E,G,G,E,E,E],ei=[E,E,G,G,G,E,E,G,G,G,E,E],ka=[E,E,G,G,E,E,E,E,G,G,E,E],iy=[E,G,ot,G,Ce,G,G,Ce,G,ot,G,E],ny={idle:[[Xs,Zs,Ks,Wo,Qs,he,Js,he,ti,Ie,Ie,ei],[Xs,Zs,Ks,Ta,Qs,he,Js,he,ti,Ie,Ie,ei]],walk:[[Xs,Zs,Ks,Wo,Qs,he,Js,he,ti,ka,ka,ei],[Xs,Zs,Ks,Wo,Qs,he,Js,he,ti,Ie,ka,ei]],working:[Xs,Zs,Ks,Wo,Qs,he,Js,he,ti,Ie,Ie,ei],sleeping:[[Xs,Zs,Ks,Ta,Qs,he,Js,he,ti,Ie,Ie,ei],[Xs,Zs,Ks,Ta,Qs,he,Js,he,ti,Ie,Ie,ei]],done:[Xs,Zs,Ks,iy,Qs,he,Js,he,ti,Ie,Ie,ei],size:12},D="transparent",tt="body",Y="outline",Di="highlight",rs="eye",dt="skin",oy=[D,D,D,D,D,D,D,Y,Y,D,D,D,D,D,D,D],ry=[D,D,D,D,D,D,Y,Di,Di,Y,D,D,D,D,D,D],ay=[D,D,D,D,D,Y,Di,Di,Di,Di,Y,D,D,D,D,D],ly=[D,D,D,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,D,D,D],Ca=[D,D,D,Y,dt,rs,rs,dt,dt,rs,rs,dt,Y,D,D,D],Ho=[D,D,D,Y,dt,Y,Y,dt,dt,Y,Y,dt,Y,D,D,D],Gi=[D,D,D,D,Y,dt,dt,dt,dt,dt,dt,Y,D,D,D,D],dr=[D,D,D,D,D,Y,tt,tt,tt,tt,Y,D,D,D,D,D],Li=[D,D,D,D,Y,tt,tt,tt,tt,tt,tt,Y,D,D,D,D],xl=[D,D,D,dt,Y,tt,tt,tt,tt,tt,tt,Y,dt,D,D,D],ur=[D,D,D,Y,tt,tt,tt,tt,tt,tt,tt,tt,Y,D,D,D],pr=[D,D,Y,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,Y,D,D],fr=[D,Y,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,Y,D],mr=[D,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,D],cy=[D,D,dt,dt,Y,tt,tt,tt,tt,tt,tt,Y,dt,dt,D,D],hy=[D,D,D,Y,dt,dt,rs,dt,dt,rs,dt,dt,Y,D,D,D],dy=[D,D,D,D,Y,dt,dt,Y,Y,dt,dt,Y,D,D,D,D],Zi=[oy,ry,ay,ly],Ah=Zi.map(i=>[D,...i.slice(0,-1)]),Vn=[dr,Li,xl,Li,ur,pr,fr,mr],uy={idle:[[...Zi,Ca,Gi,...Vn],[...Zi,Ho,Gi,...Vn]],walk:[[...Zi,Ca,Gi,dr,Li,xl,Li,ur,pr,fr,mr],[...Zi,Ho,Gi,dr,Li,xl,Li,ur,pr,fr,mr]],working:[...Zi,Ca,Gi,dr,Li,cy,Li,ur,pr,fr,mr],sleeping:[[...Ah,[D,...Ho.slice(0,-1)],[D,...Gi.slice(0,-1)],...Vn],[...Ah,[D,...Ho.slice(0,-1)],[D,...Gi.slice(0,-1)],...Vn]],done:[...Zi,hy,dy,...Vn],size:16},si=[D,D,D,D,D,Y,Y,D,D,D,D,D],ii=[D,D,D,D,Y,Di,Di,Y,D,D,D,D],ni=[D,D,Y,Y,Y,Y,Y,Y,Y,Y,D,D],Aa=[D,D,Y,dt,rs,dt,dt,rs,dt,Y,D,D],Uo=[D,D,Y,dt,Y,dt,dt,Y,dt,Y,D,D],Wi=[D,D,Y,dt,dt,dt,dt,dt,dt,Y,D,D],de=[D,D,Y,tt,tt,tt,tt,tt,tt,Y,D,D],oi=[D,dt,Y,tt,tt,tt,tt,tt,tt,Y,dt,D],ri=[D,Y,tt,tt,tt,tt,tt,tt,tt,tt,Y,D],ue=[Y,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,Y],ai=[Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y],py=[D,D,Y,dt,dt,rs,rs,dt,dt,Y,D,D],fy=[D,D,Y,dt,Y,dt,dt,Y,dt,Y,D,D],my={idle:[[si,ii,ni,Aa,Wi,de,oi,de,ri,ue,ue,ai],[si,ii,ni,Uo,Wi,de,oi,de,ri,ue,ue,ai]],walk:[[si,ii,ni,Aa,Wi,de,oi,de,ri,ue,ue,ai],[si,ii,ni,Uo,Wi,de,oi,de,ri,ue,ue,ai]],working:[si,ii,ni,Aa,Wi,de,oi,de,ri,ue,ue,ai],sleeping:[[si,ii,ni,Uo,Wi,de,oi,de,ri,ue,ue,ai],[si,ii,ni,Uo,Wi,de,oi,de,ri,ue,ue,ai]],done:[si,ii,ni,py,fy,de,oi,de,ri,ue,ue,ai],size:12},W="transparent",N="body",q="outline",Ku="highlight",Ge="eye",vt=[W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W],li=[W,W,W,W,W,W,q,q,q,q,W,W,W,W,W,W],ci=[W,W,W,W,W,q,N,N,N,N,q,W,W,W,W,W],hi=[W,W,W,W,q,N,N,Ku,N,N,N,q,W,W,W,W],di=[W,W,W,q,N,N,N,N,N,N,N,N,q,W,W,W],qo=[W,W,W,q,N,Ge,Ge,N,N,Ge,Ge,N,q,W,W,W],Ea=[W,W,W,q,N,q,q,N,N,q,q,N,q,W,W,W],Hi=[W,W,q,N,N,N,N,N,N,N,N,N,N,q,W,W],ui=[W,W,q,N,N,N,N,N,N,N,N,N,N,q,W,W],Vo=[W,q,N,N,N,N,N,N,N,N,N,N,N,N,q,W],qe=[W,q,N,N,N,N,N,N,N,N,N,N,N,N,q,W],jn=[W,W,q,q,q,q,q,q,q,q,q,q,q,q,W,W],Ma=[q,N,N,N,N,N,N,N,N,N,N,N,N,N,N,q],Ia=[q,N,N,N,N,N,N,N,N,N,N,N,N,N,N,q],Pa=[W,q,q,q,q,q,q,q,q,q,q,q,q,q,q,W],gy=[W,W,q,N,N,N,q,q,q,q,N,N,N,q,W,W],vy=[W,W,W,q,N,q,Ge,N,N,Ge,q,N,q,W,W,W],yy=[W,q,N,N,N,N,N,N,N,N,N,N,N,N,q,W],by={idle:[[vt,vt,vt,vt,li,ci,hi,di,qo,Hi,ui,Vo,qe,qe,jn,vt],[vt,vt,vt,vt,li,ci,hi,di,Ea,Hi,ui,Vo,qe,qe,jn,vt]],walk:[[vt,vt,vt,li,ci,hi,di,qo,Hi,ui,Vo,qe,qe,qe,jn,vt],[vt,vt,vt,vt,vt,li,ci,hi,di,qo,Hi,ui,Ma,Ia,Pa,vt]],working:[vt,vt,vt,vt,li,ci,hi,di,qo,gy,ui,yy,qe,qe,jn,vt],sleeping:[[vt,vt,vt,vt,vt,li,ci,hi,di,Ea,Hi,ui,Ma,Ia,Pa,vt],[vt,vt,vt,vt,vt,li,ci,hi,di,Ea,Hi,ui,Ma,Ia,Pa,vt]],done:[vt,vt,vt,vt,li,ci,hi,di,vy,Hi,ui,Vo,qe,qe,jn,vt],size:16},Ct=[W,W,W,W,W,W,W,W,W,W,W,W],pi=[W,W,W,W,q,q,q,q,W,W,W,W],fi=[W,W,W,q,N,N,Ku,N,q,W,W,W],mi=[W,W,q,N,N,N,N,N,N,q,W,W],jo=[W,W,q,Ge,Ge,N,N,Ge,Ge,q,W,W],La=[W,W,q,q,q,N,N,q,q,q,W,W],gi=[W,q,N,N,N,N,N,N,N,N,q,W],es=[W,q,N,N,N,N,N,N,N,N,q,W],Yn=[W,W,q,q,q,q,q,q,q,q,W,W],$a=[q,N,N,N,N,N,N,N,N,N,N,q],Ba=[W,q,q,q,q,q,q,q,q,q,q,W],wy=[W,q,N,N,q,q,q,q,N,N,q,W],_y=[W,W,q,q,Ge,N,N,Ge,q,q,W,W],xy={idle:[[Ct,Ct,Ct,pi,fi,mi,jo,gi,es,es,Yn,Ct],[Ct,Ct,Ct,pi,fi,mi,La,gi,es,es,Yn,Ct]],walk:[[Ct,Ct,pi,fi,mi,jo,gi,es,es,es,Yn,Ct],[Ct,Ct,Ct,Ct,pi,fi,mi,jo,gi,$a,Ba,Ct]],working:[Ct,Ct,Ct,pi,fi,mi,jo,wy,gi,es,Yn,Ct],sleeping:[[Ct,Ct,Ct,Ct,pi,fi,mi,La,gi,$a,Ba,Ct],[Ct,Ct,Ct,Ct,pi,fi,mi,La,gi,$a,Ba,Ct]],done:[Ct,Ct,Ct,pi,fi,mi,_y,gi,es,es,Yn,Ct],size:12},Sl=[$v,Gv,Yv,sy,uy,by],Eh=[Bv,Uv,Zv,ny,my,xy];function Sy(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%Sl.length}function Ty(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 Yo=3,Mh=new Map;function pe(i,t,e,s){const n=Mh.get(s);if(n)return n;const o=new Ht,r=t.length,l=t[0].length;for(let d=0;d<r;d++)for(let c=0;c<l;c++){const f=Ty(e,t[d][c]);f!==null&&o.rect(c*Yo,d*Yo,Yo,Yo).fill(f)}const h=i.generateTexture({target:o});return o.destroy(),Mh.set(s,h),h}function fe(i,t){return`${i}_p${t}`}function pn(i){const t=new Nt,e=new Ht;t.addChild(e);const s=new Qi({text:i.label,style:new Ye({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 Xo(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 Ih(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 Ph=3500,ky=3e3,Lh=500,Ra=8,Cy=5,Ay=6,$h=160,Zo=5,Ey={tool:{bg:1712960,border:3821696,text:15266047},text:{bg:1712960,border:4212832,text:13421772},"input-needed":{bg:3809296,border:16750592,text:16764032}};class My{constructor(t){y(this,"container");y(this,"bg");y(this,"pointer");y(this,"textObj");y(this,"speechTimer",0);y(this,"queue",[]);y(this,"currentIndex",0);y(this,"rotateTimer",0);y(this,"currentType","tool");y(this,"needsInputPulse",0);this.container=new Nt,this.container.visible=!1,this.bg=new Ht,this.container.addChild(this.bg),this.pointer=new Ht,this.container.addChild(this.pointer);const e=new Ye({fontSize:10,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:15266047,wordWrap:!0,wordWrapWidth:$h-Ra*2,lineHeight:14});this.textObj=new Qi({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=Ph,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>=ky&&(this.rotateTimer=0,this.currentIndex=(this.currentIndex+1)%this.queue.length,this.showCurrentMessage(),this.speechTimer=Ph)),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=Ey[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,$h-Ra*2),d=this.textObj.height,c=h+Ra*2,f=d+Cy*2;this.bg.clear(),this.bg.roundRect(-c/2,-(f+Zo),c,f,Ay).fill({color:e.bg,alpha:.92}).stroke({color:e.border,width:1,alpha:.6}),this.pointer.clear(),this.pointer.moveTo(-Zo,0).lineTo(0,Zo).lineTo(Zo,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 Iy=2,Py=4,Ly=.7,$y=100,By=3,Ry=1.5,Dy=2,zy=2.5,Fy=.8,Ny=1,Oy=1.5,Bh=600,Rh=3e3,Dh=30,zh=18,ns=class ns{constructor(t,e,s){y(this,"container",new Nt);y(this,"sprite");y(this,"nameBg");y(this,"nameLabel");y(this,"speechBubble");y(this,"needsInputPulse",0);y(this,"childBadge",null);y(this,"planBadge",null);y(this,"planPulseTimer",0);y(this,"_isPlanning",!1);y(this,"waitBadge",null);y(this,"waitPulseTimer",0);y(this,"_isWaiting",!1);y(this,"waitQContainer");y(this,"waitQLetters");y(this,"waitQTimer",0);y(this,"animState","idle");y(this,"isIdleState",!1);y(this,"isDoneState",!1);y(this,"idleTimer",0);y(this,"zzzContainer");y(this,"zzzLetters");y(this,"zzzTimer",0);y(this,"doneBadge",null);y(this,"sparkles",[]);y(this,"compactBadge",null);y(this,"compactPulseTimer",0);y(this,"_isCompacting",!1);y(this,"outcomeFlash",null);y(this,"anomalyBadge",null);y(this,"anomalyPulseTimer",0);y(this,"_hasAnomaly",!1);y(this,"anomalyAutoClearTimer",null);y(this,"contextBar");y(this,"_contextPct",0);y(this,"activityRing");y(this,"activityLevel",0);y(this,"activityPhase",0);y(this,"isSubagent");y(this,"variantIndex");y(this,"spriteHeight");y(this,"textures");y(this,"frameTimer",0);y(this,"frameIndex",0);y(this,"targetX");y(this,"targetY");y(this,"isMoving",!1);y(this,"bobTimer");y(this,"baseY");y(this,"fadingOut",!1);y(this,"fadeTimer",0);y(this,"fadeResolve",null);y(this,"spawnAnimTimer",0);this.isSubagent=t.role==="subagent";const n=this.isSubagent;this.variantIndex=Sy(t.projectPath??t.sessionId);const o=this.variantIndex,r=n?Eh[o]:Sl[o],l=n?`sub_v${o}`:`main_v${o}`,h=t.colorIndex;this.spriteHeight=r.size*3,this.textures={idle:[pe(s,r.idle[0],e,fe(`${l}_idle0`,h)),pe(s,r.idle[1],e,fe(`${l}_idle1`,h))],walk:[pe(s,r.walk[0],e,fe(`${l}_walk0`,h)),pe(s,r.walk[1],e,fe(`${l}_walk1`,h))],working:pe(s,r.working,e,fe(`${l}_working`,h)),sleeping:[pe(s,r.sleeping[0],e,fe(`${l}_sleeping0`,h)),pe(s,r.sleeping[1],e,fe(`${l}_sleeping1`,h))],done:pe(s,r.done,e,fe(`${l}_done`,h))},this.sprite=new tn(this.textures.idle[0]),this.sprite.anchor.set(.5,.5),this.container.addChild(this.sprite),this.nameBg=new Ht,this.container.addChild(this.nameBg);const d=t.agentName||Ss(t.sessionId),c=d.length>14?d.slice(0,12)+"..":d,f=new Ye({fontSize:11,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:16777215,align:"center",fontWeight:"700"});this.nameLabel=new Qi({text:c,style:f}),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 Ht,this.container.addChild(this.contextBar),this.setContextHealth(0),this.speechBubble=new My(this.spriteHeight),this.container.addChild(this.speechBubble.container),this.zzzContainer=new Nt,this.zzzContainer.visible=!1,this.zzzLetters=[];const g=[8,10,13],m=["z","z","Z"];for(let b=0;b<3;b++){const _=new Qi({text:m[b],style:new Ye({fontSize:g[b],fontFamily:"'Segoe UI', sans-serif",fill:8952268,fontWeight:"700",dropShadow:{alpha:.5,blur:2,color:0,distance:1}})});_.anchor.set(.5,.5),this.zzzLetters.push(_),this.zzzContainer.addChild(_)}this.zzzContainer.position.set(this.spriteHeight/3,-this.spriteHeight/2),this.container.addChild(this.zzzContainer),this.waitQContainer=new Nt,this.waitQContainer.visible=!1,this.waitQLetters=[];const v=[9,11,14];for(let b=0;b<3;b++){const _=new Qi({text:"?",style:new Ye({fontSize:v[b],fontFamily:"'Segoe UI', sans-serif",fill:16750592,fontWeight:"700",dropShadow:{alpha:.5,blur:2,color:0,distance:1}})});_.anchor.set(.5,.5),this.waitQLetters.push(_),this.waitQContainer.addChild(_)}this.waitQContainer.position.set(this.spriteHeight/3,-this.spriteHeight/2),this.container.addChild(this.waitQContainer),this.activityRing=new Ht,this.activityRing.visible=!1,this.container.addChildAt(this.activityRing,0),this.container.eventMode="static",this.container.cursor="pointer",this.container.hitArea={contains:(b,_)=>{const x=this.spriteHeight/2+10,C=-this.spriteHeight/2-10,$=this.spriteHeight/2+25;return b>=-x&&b<=x&&_>=C&&_<=$}},this.spawnAnimTimer=ns.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()}setNameVisible(t){this.nameLabel.visible=t,this.nameBg.visible=t}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?Eh[n]:Sl[n],r=this.isSubagent?`sub_v${n}`:`main_v${n}`,l=e;this.textures={idle:[pe(s,o.idle[0],t,fe(`${r}_idle0`,l)),pe(s,o.idle[1],t,fe(`${r}_idle1`,l))],walk:[pe(s,o.walk[0],t,fe(`${r}_walk0`,l)),pe(s,o.walk[1],t,fe(`${r}_walk1`,l))],working:pe(s,o.working,t,fe(`${r}_working`,l)),sleeping:[pe(s,o.sleeping[0],t,fe(`${r}_sleeping0`,l)),pe(s,o.sleeping[1],t,fe(`${r}_sleeping1`,l))],done:pe(s,o.done,t,fe(`${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=pn({label:"✓",fontSize:10}),this.doneBadge.container.position.set(0,-this.spriteHeight/2-14),this.container.addChild(this.doneBadge.container)),Xo(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 Ht;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=pn({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}`,Xo(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=pn({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&&Ih(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=pn({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&&Xo(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=pn({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&&Ih(this.compactBadge.bg,58,13,3,8141549,10980346,t*.9,t*.7)}flashOutcome(t){this.outcomeFlash={outcome:t,timer:ns.OUTCOME_FLASH_DURATION}}bumpActivity(){this.activityLevel=Math.min(1,this.activityLevel+.35)}setAnomaly(t){this._hasAnomaly=!0,this.anomalyPulseTimer=0,this.anomalyBadge||(this.anomalyBadge=pn({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=Bh,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 d=1-this.spawnAnimTimer/ns.SPAWN_ANIM_DURATION,c=1-Math.pow(2,-8*d)*Math.cos(d*Math.PI*3);this.container.scale.set(Math.max(.3,Math.min(1,c)))}if(this.fadingOut){this.fadeTimer-=t,this.container.alpha=Math.max(0,this.fadeTimer/Bh),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>=ns.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"?Py:this.animState==="sleeping"?Ly:Iy);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 d=this.animState==="walk"?this.textures.walk:this.animState==="sleeping"?this.textures.sleeping:this.textures.idle;this.sprite.texture=d[this.frameIndex]}if(this.animState==="sleeping"){this.zzzContainer.visible=!0,this.zzzTimer+=t;for(let d=0;d<this.zzzLetters.length;d++){const c=d/this.zzzLetters.length,f=(this.zzzTimer/Rh+c)%1,g=this.zzzLetters[d];g.position.set(f*zh,-f*Dh),g.alpha=Math.max(0,1-f*1.3),g.scale.set(.5+f*.6)}}else this.zzzContainer.visible=!1;if(this._isWaiting){this.waitQContainer.visible=!0,this.waitQTimer+=t;for(let d=0;d<this.waitQLetters.length;d++){const c=d/this.waitQLetters.length,f=(this.waitQTimer/Rh+c)%1,g=this.waitQLetters[d];g.position.set(f*zh,-f*Dh),g.alpha=Math.max(0,1-f*1.3),g.scale.set(.5+f*.6)}}else this.waitQContainer.visible=!1;if(this.isDoneState&&this.sparkles.length>0)for(let d=0;d<this.sparkles.length;d++){const c=this.sparkles[d];c.phase+=t;const f=2e3+d*700,g=c.phase%f/f;g<.15?(c.gfx.visible=!0,c.gfx.alpha=g/.15):g<.3?(c.gfx.visible=!0,c.gfx.alpha=1-(g-.15)/.15):c.gfx.visible=!1}if(!this.outcomeFlash)if(this._isWaiting){this.activityRing.visible=!0,this.activityPhase+=t*.004,this.activityRing.clear();const d=this.spriteHeight/2+6,c=.4+.3*Math.sin(this.activityPhase*2),f=Math.PI*1.2;for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d,m,m+f).stroke({color:16750592,width:2.5,alpha:c})}for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d+2,m,m+f*.8).stroke({color:16750592,width:3,alpha:c*.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 d=this.spriteHeight/2+6,c=this.activityLevel*.6,f=Math.PI*.4+this.activityLevel*Math.PI*.8;for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d,m,m+f).stroke({color:4906624,width:2,alpha:c})}if(this.activityLevel>.3)for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d+2,m,m+f*.8).stroke({color:4906624,width:3,alpha:c*.25})}}else this.activityRing.visible=!1;if(this._isPlanning&&((o=this.planBadge)!=null&&o.container.visible)){this.planPulseTimer+=t*.003;const d=.7+.3*Math.sin(this.planPulseTimer);this.drawPlanBadge(d)}if(this._isCompacting&&((r=this.compactBadge)!=null&&r.container.visible)){this.compactPulseTimer+=t*.003;const d=.65+.35*Math.sin(this.compactPulseTimer*1.5);this.drawCompactBadge(d);const c=1+.04*Math.sin(this.compactPulseTimer*2);this.compactBadge.container.scale.set(c,1)}if(this.outcomeFlash)if(this.outcomeFlash.timer-=t,this.outcomeFlash.timer<=0)this.outcomeFlash=null,this.activityRing.visible=!1;else{const d=this.outcomeFlash.timer/ns.OUTCOME_FLASH_DURATION,c=d*.85,f=this.spriteHeight/2+6+(1-d)*8,g=this.outcomeFlash.outcome==="success"?4906624:16281969;this.activityRing.visible=!0,this.activityRing.clear(),this.activityRing.circle(0,0,f).stroke({color:g,width:3,alpha:c}),this.activityRing.circle(0,0,f+4).stroke({color:g,width:1.5,alpha:c*.4})}if(this._hasAnomaly&&((l=this.anomalyBadge)!=null&&l.container.visible)&&this.anomalyBadge.bg){this.anomalyPulseTimer+=t*.005;const d=.85+.15*Math.sin(this.anomalyPulseTimer);this.anomalyBadge.container.scale.set(d),Xo(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 d=.5+.5*Math.sin(this.waitPulseTimer);this.drawWaitBadge(d);const c=1+.15*Math.sin(this.waitPulseTimer*.7);this.waitBadge.container.scale.set(c)}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<By){this.container.x=this.targetX,this.container.y=this.targetY,this.baseY=this.container.y,this.isMoving=!1;return}const r=Math.min($y*e,o);this.container.x+=s/o*r,this.container.y+=n/o*r}updateBob(t){const e=this.animState==="sleeping"?zy:this.animState==="done"?Ny:Ry,s=this.animState==="sleeping"?Fy:this.animState==="done"?Oy:Dy;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})}};y(ns,"IDLE_TO_SLEEP_MS",3e4),y(ns,"OUTCOME_FLASH_DURATION",700),y(ns,"SPAWN_ANIM_DURATION",400);let Tl=ns;const Fh=6,Nh=4,Gy=.04,Wy=3,Hy=.15,Uy=1,Oh=.5,Gh=6,Wh=400,Hh=4886745,qy=4521796;class Vy{constructor(){y(this,"graphics",new Ht);y(this,"time",0);y(this,"pulseTimers",new Map)}pulseConnection(t,e){this.pulseTimers.set(`${t}->${e}`,Wh)}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}`,d=this.pulseTimers.get(h)??0,f=d>0?d/Wh:0;this.drawGlowingDashedLine(l.x,l.y,r.x,r.y,Hh,f),this.drawArrow(l.x,l.y,r.x,r.y,Hh,f)}}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,qy,0)}drawGlowingDashedLine(t,e,s,n,o,r){const l=this.time*Gy,h=Hy+r*.35,d=Oh+r*.4,c=Wy+r*2;this.drawDashedLine(t,e,s,n,o,h,c,l),this.drawDashedLine(t,e,s,n,o,d,Uy,l)}drawDashedLine(t,e,s,n,o,r,l,h){const d=s-t,c=n-e,f=Math.sqrt(d*d+c*c);if(f<1)return;const g=d/f,m=c/f,v=Fh+Nh;let _=-((h%v+v)%v),x=!0;for(;_<f;){const $=_+(x?Fh:Nh);if(x){const P=Math.max(_,0),H=Math.min($,f);if(H>P){const R=t+g*P,O=e+m*P,et=t+g*H,Z=e+m*H;this.graphics.moveTo(R,O).lineTo(et,Z).stroke({color:o,width:l,alpha:r})}}_=$,x=!x}}drawArrow(t,e,s,n,o,r){const l=s-t,h=n-e,d=Math.sqrt(l*l+h*h);if(d<Gh*3)return;const c=l/d,f=h/d,g=(t+s)/2,m=(e+n)/2,v=-f,b=c,_=Gh/2,x=Oh+r*.4,C=g+c*_,$=m+f*_,P=g-c*_+v*_,H=m-f*_+b*_,R=g-c*_-v*_,O=m-f*_-b*_;this.graphics.moveTo(C,$).lineTo(P,H).lineTo(R,O).closePath().fill({color:o,alpha:x})}destroy(){this.graphics.destroy()}}const jy=8,Da=3,Uh=800,qh=30;class Yy{constructor(t){y(this,"container",new Nt);y(this,"particles",[]);y(this,"particleTextures",new Map);this.renderer=t}emit(t,e,s){const n=this.getTexture(s);for(let o=0;o<jy;o++){const r=new tn(n);r.anchor.set(.5),r.position.set(t,e),r.alpha=1;const l=Math.random()*Math.PI*2,h=qh*(.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)-qh*.5,life:Uh,maxLife:Uh})}}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 Ht;return s.circle(Da,Da,Da).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 Xy=800,Vh=3,jh=3,Zy=40;class Ky{constructor(){y(this,"container",new Nt);y(this,"particles",[])}send(t,e,s,n,o){const r=new Ht;this.container.addChild(r),this.particles.push({gfx:r,fromX:t,fromY:e,toX:s,toY:n,color:o,elapsed:0,duration:Xy})}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<=Vh;r++){const l=Math.max(0,n-r*.06),h=this.getArcPosition(s,l),d=(1-r/(Vh+1))*(1-n*.3),c=jh*(1-r*.2);s.gfx.circle(h.x,h.y,c).fill({color:s.color,alpha:d})}const o=this.getArcPosition(s,n);s.gfx.circle(o.x,o.y,jh*2.5).fill({color:s.color,alpha:.15})}}getArcPosition(t,e){const s=(t.fromX+t.toX)/2,n=(t.fromY+t.toY)/2-Zy,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 Qy{constructor(){y(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 Jy(i){const t=[];if(i.currentTool==="AskUserQuestion")return t.push({text:"Waiting for input...",type:"input-needed",icon:"⏳"}),t;if(i.currentTool){const e=O0[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 Ko(i,t,e,s){const n=Zt.get(i);if(!n)return s.getZoneCenter(i);const o=[];for(const[C,$]of e)($.state.currentZone===i||$.state.isIdle&&i==="idle")&&o.push(C);o.includes(t)||o.push(t),o.sort();const r=o.indexOf(t),l=o.length,h=n.width-40,d=n.height-70,c=n.x+20,f=n.y+50;if(l===1)return{x:c+h/2,y:f+d/2};const g=Math.ceil(Math.sqrt(l)),m=Math.ceil(l/g),v=r%g,b=Math.floor(r/g),_=h/g,x=d/m;return{x:c+_*v+_/2,y:f+x*b+x/2}}class t1{constructor(t,e,s){y(this,"agents",new Map);y(this,"lines");y(this,"particles");y(this,"messageFlow");y(this,"zoneGlow");y(this,"sound",null);y(this,"notifications",null);y(this,"_focusedAgentId",null);y(this,"_onAgentClick",null);y(this,"_onAgentHover",null);y(this,"_showNames",!0);y(this,"_customizationLookup",null);y(this,"onSpawnBound");y(this,"onUpdateBound");y(this,"onIdleBound");y(this,"onShutdownBound");y(this,"onResetBound");y(this,"onAnomalyBound");this.app=t,this.world=e,this.store=s,this.lines=new Vy,this.world.uiLayer.addChild(this.lines.graphics),this.particles=new Yy(t.renderer),this.world.addEffect(this.particles.container),this.messageFlow=new Ky,this.world.addEffect(this.messageFlow.container),this.zoneGlow=new Qy,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}setShowNames(t){if(t!==this._showNames){this._showNames=t;for(const e of this.agents.values())e.sprite.setNameVisible(t)}}getDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||Ss(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,d;if(this.agents.has(t.id))return;const e=ft[t.colorIndex%ft.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 c=this.world.getZoneCenter("spawn");s.container.position.set(c.x,c.y)}s.onClick(()=>{var c;return(c=this._onAgentClick)==null?void 0:c.call(this,t.id)}),s.onHover(()=>{var c;return(c=this._onAgentHover)==null?void 0:c.call(this,t.id,s.container.x,s.container.y)},()=>{var c;return(c=this._onAgentHover)==null?void 0:c.call(this,null,0,0)});const o=this.getDisplayName(t),r=this.getDisplayColorIndex(t);if(s.setCustomName(o),r!==t.colorIndex){const c=ft[r%ft.length];s.rebuildTextures(c,r,this.app.renderer)}s.setContextHealth(t.contextTokens/this.getContextWindowSize(t.model),t.contextCacheTokens/this.getContextWindowSize(t.model)),this._showNames||s.setNameVisible(!1),this.agents.set(t.id,{sprite:s,state:t,notifiedWaiting:!1,lastSeenOutcome:null}),this.world.addAgent(s.container);const l=Ko(t.currentZone,t.id,this.agents,this.world);s.moveTo(l.x,l.y),this.updateChildBadges(),(h=this.sound)==null||h.play("spawn"),(d=this.notifications)==null||d.notifySpawn(o)}getContextWindowSize(t){return Ul(t)}onUpdate(t){var r,l,h,d;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=Ko(t.currentZone,t.id,this.agents,this.world);e.sprite.moveTo(n.x,n.y);const o=Jy(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 c=ft[this.getDisplayColorIndex(t)%ft.length];if(this.particles.emit(e.sprite.container.x,e.sprite.container.y,c.body),(h=this.sound)==null||h.play("tool-use"),t.currentTool==="SendMessage"){let f;if(t.messageTarget){for(const[,g]of this.agents)if((g.state.agentName===t.messageTarget||g.state.id===t.messageTarget)&&g.state.rootSessionId===t.rootSessionId){f=g;break}}if(!f&&t.parentId&&(f=this.agents.get(t.parentId)),!f){for(const[,g]of this.agents)if(g.state.parentId===t.id){f=g;break}}f&&this.messageFlow.send(e.sprite.container.x,e.sprite.container.y,f.sprite.container.x,f.sprite.container.y,c.body)}e.sprite.bumpActivity()}if(s!==t.currentZone){(d=this.sound)==null||d.play("zone-change");const c=ft[this.getDisplayColorIndex(t)%ft.length];this.world.flowLines.triggerFlow(s,t.currentZone,c.body)}}onIdle(t){var n,o;const e=this.agents.get(t.id);if(!e)return;e.state=t;const s=Ko("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=Ko(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 Zt.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||Ss(o.sessionId);n.sprite.setCustomName(r);const l=s??o.colorIndex,h=ft[l%ft.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 ct(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Qt(i){return ct(i).replace(/"/g,""")}function as(i){return"#"+i.toString(16).padStart(6,"0")}function gt(i){return i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:`${i}`}function Qu(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 oe(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 ql(i,t){return i.length>t?i.slice(0,t-1)+"…":i}const Vl={claude:{label:"CC",color:"#a78bfa",title:"Claude Code"},opencode:{label:"OC",color:"#22d3ee",title:"OpenCode"},pi:{label:"PI",color:"#f59e0b",title:"pi coding agent"},codex:{label:"CX",color:"#10b981",title:"Codex CLI"}};function Ju(i){const t=Vl[i];return`<span class="cli-badge" title="${t.title}" style="
|
|
251
|
+
background: ${t.color}22;
|
|
252
|
+
color: ${t.color};
|
|
253
|
+
border: 1px solid ${t.color}44;
|
|
254
|
+
padding: 0 3px;
|
|
255
|
+
border-radius: 3px;
|
|
256
|
+
font-size: 8px;
|
|
257
|
+
font-weight: 700;
|
|
258
|
+
letter-spacing: 0.5px;
|
|
259
|
+
margin-left: 4px;
|
|
260
|
+
vertical-align: middle;
|
|
261
|
+
">${t.label}</span>`}function Tr(i){var t;return((t=Vl[i])==null?void 0:t.label)??i.toUpperCase().slice(0,2)}function Yh(i){var t;return((t=Vl[i])==null?void 0:t.title)??i}let Xn=null,Xh=0;const e1=2e3;function s1(){const i=Date.now();if(Xn&&i-Xh<e1)return Xn;try{Xn=JSON.parse(localStorage.getItem("agent-customizations")??"{}"),Xh=i}catch{Xn={}}return Xn}function kr(i){const e=s1()[i.agentId];return e!=null&&e.displayName?e.displayName:i.agentName||Ss(i.agentId)}class i1{constructor(t){y(this,"store");y(this,"agentListEl");y(this,"filterEl");y(this,"refreshTimer");y(this,"onAgentClick",null);y(this,"_customizationLookup",null);y(this,"currentFilter","all");y(this,"collapsedGroups",new Set);y(this,"renderPending",!1);y(this,"scheduleRender");y(this,"tokenHistory",new Map);y(this,"sparklineSampleTimer");y(this,"_metrics",new Map);y(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(c=>c.isDone).length,n=[...new Set(e.map(c=>c.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(c=>{const f=c.value==="done"&&s>0?` <span class="filter-badge">${s}</span>`:"";return`<button class="filter-pill${this.currentFilter===c.value?" active":""}" data-filter="${c.value}">${c.label}${f}</button>`}).join("")+`
|
|
262
|
+
<select class="filter-zone-select" title="Filter by zone">
|
|
263
|
+
<option value="">Zone...</option>
|
|
264
|
+
${ne.map(c=>`<option value="${c.id}" ${this.currentFilter===c.id?"selected":""}>${c.icon} ${c.label}</option>`).join("")}
|
|
265
|
+
</select>
|
|
266
|
+
${o?`<select class="filter-zone-select filter-project-select" title="Filter by project">
|
|
267
|
+
<option value="">Project...</option>
|
|
268
|
+
${n.sort().map(c=>`<option value="project:${Qt(c)}" ${r===c?"selected":""}>${ct(c)}</option>`).join("")}
|
|
269
|
+
</select>`:""}
|
|
270
|
+
${s>0?`<button class="clean-done-btn" title="Remove ${s} done agent${s>1?"s":""}">Clean up (${s})</button>`:""}
|
|
271
|
+
`,this.filterEl.querySelectorAll(".filter-pill").forEach(c=>{c.addEventListener("click",()=>{this.currentFilter=c.dataset.filter,this.filterEl.querySelector(".filter-zone-select").value="";const f=this.filterEl.querySelector(".filter-project-select");f&&(f.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 c=this.filterEl.querySelector(".filter-project-select");c&&(c.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 d=this.filterEl.querySelector(".clean-done-btn");d&&d.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="
|
|
272
|
+
background: ${s.color}33;
|
|
273
|
+
color: ${s.color};
|
|
274
|
+
padding: 1px 6px;
|
|
275
|
+
border-radius: 3px;
|
|
276
|
+
font-size: 10px;
|
|
277
|
+
font-weight: bold;
|
|
278
|
+
margin-left: 6px;
|
|
279
|
+
">${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 m;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=`
|
|
280
|
+
<div class="empty-state">
|
|
281
|
+
<div class="empty-icon">
|
|
282
|
+
<svg viewBox="0 0 48 48" width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
283
|
+
<rect x="14" y="6" width="20" height="16" rx="3" />
|
|
284
|
+
<circle cx="20" cy="14" r="2" fill="currentColor"/>
|
|
285
|
+
<circle cx="28" cy="14" r="2" fill="currentColor"/>
|
|
286
|
+
<rect x="16" y="24" width="16" height="14" rx="2" />
|
|
287
|
+
<rect x="10" y="26" width="6" height="4" rx="1" />
|
|
288
|
+
<rect x="32" y="26" width="6" height="4" rx="1" />
|
|
289
|
+
<rect x="18" y="38" width="4" height="6" rx="1" />
|
|
290
|
+
<rect x="26" y="38" width="4" height="6" rx="1" />
|
|
291
|
+
</svg>
|
|
292
|
+
</div>
|
|
293
|
+
<div class="empty-title">Waiting for agents</div>
|
|
294
|
+
<div class="empty-desc">Start a Claude Code session and agents will appear here automatically</div>
|
|
295
|
+
</div>`;else{const v=`No ${this.currentFilter} agents (${e} total)`;this.agentListEl.innerHTML=`<div class="empty-state"><div class="empty-desc">${v}</div></div>`}return}t.sort((v,b)=>v.isDone!==b.isDone?v.isDone?1:-1:v.isIdle!==b.isIdle?v.isIdle?1:-1:v.spawnedAt-b.spawnedAt);const s=this.store.getAgents(),n=t.filter(v=>v.role==="subagent"),o=t.filter(v=>v.role!=="subagent"),r=[],l=new Set(o.map(v=>v.id)),h=new Map;for(const v of n)if(v.parentId&&l.has(v.parentId)){let b=h.get(v.parentId);b||(b=[],h.set(v.parentId,b)),b.push(v)}else r.push(v);const d=new Map;for(const v of s.values())v.parentId&&v.role==="subagent"&&d.set(v.parentId,(d.get(v.parentId)??0)+1);const c=new Map,f=[];for(const v of o)if(v.teamName){const b=`${v.rootSessionId}:${v.teamName}`;let _=c.get(b);_||(_=[],c.set(b,_)),_.push(v)}else f.push(v);let g="";for(const[v,b]of c){const _=v.indexOf(":"),x=_>=0?v.slice(_+1):v,C=(m=b[0])==null?void 0:m.rootSessionId;b.sort((R,O)=>R.role==="team-lead"&&O.role!=="team-lead"?-1:R.role!=="team-lead"&&O.role==="team-lead"?1:0);let $=0;for(const R of s.values())R.teamName===x&&R.rootSessionId===C&&$++;const P=`team:${v}`,H=this.collapsedGroups.has(P);if(g+=`<div class="agent-group${H?" collapsed":""}">`,g+=`<div class="group-header" role="button" tabindex="0" data-group-id="${Qt(P)}">
|
|
296
|
+
<span class="group-chevron">${H?"▸":"▾"}</span>
|
|
297
|
+
<span class="group-icon">👥</span>
|
|
298
|
+
<span class="group-name">${ct(x)}</span>
|
|
299
|
+
<span class="group-count">${$}</span>
|
|
300
|
+
</div>`,!H){g+='<div class="group-children">';for(const R of b)g+=this.renderAgentWithSubs(R,h,d);g+="</div>"}g+="</div>"}for(const v of f)g+=this.renderAgentWithSubs(v,h,d);for(const v of r)g+=this.renderCard(v,!0);this.agentListEl.innerHTML=g,this.agentListEl.querySelectorAll(".group-header").forEach(v=>{v.addEventListener("click",()=>{const b=v.dataset.groupId;b&&this.toggleGroup(b)}),v.addEventListener("keydown",b=>{if(b.key==="Enter"||b.key===" "){b.preventDefault();const _=v.dataset.groupId;_&&this.toggleGroup(_)}})}),this.agentListEl.querySelectorAll(".sub-collapse-bar").forEach(v=>{v.addEventListener("click",()=>{const b=v.dataset.groupId;b&&this.toggleGroup(b)})}),this.agentListEl.querySelectorAll(".agent-card[data-agent-id]").forEach(v=>{v.addEventListener("click",()=>{const b=v.dataset.agentId;b&&this.onAgentClick&&this.onAgentClick(b)})}),this.agentListEl.querySelectorAll(".sparkline-canvas").forEach(v=>{const b=v.dataset.agentId;b&&this.drawSparkline(v,b)}),this.agentListEl.querySelectorAll(".agent-sparkline").forEach(v=>{const b=v.dataset.agentId;b&&this.drawToolVelocitySparkline(v,b)})}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 d=`sub:${t.id}`,c=this.collapsedGroups.has(d);h+=this.renderCard(t,n,0);const f=c?"▸":"▾",g=`${r} subagent${r>1?"s":""}`;if(h+=`<div class="sub-collapse-bar${c?" is-collapsed":""}" data-group-id="${Qt(d)}">
|
|
301
|
+
<span class="sub-collapse-chevron">${f}</span>
|
|
302
|
+
<span class="sub-collapse-label">${g}</span>
|
|
303
|
+
</div>`,!c){h+='<div class="subagent-group">';for(const m of o)h+=this.renderAgentWithSubs(m,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 O;const n=(O=this._customizationLookup)==null?void 0:O.call(this,t),o=(n==null?void 0:n.colorIndex)??t.colorIndex,r=ft[o%ft.length],l=as(r.body),h=Zt.get(t.currentZone),d=h?h.label:t.currentZone,c=t.currentTool??"none",f=Qu(t.totalInputTokens,t.totalOutputTokens),g=(n==null?void 0:n.displayName)||t.agentName||Ss(t.sessionId),m=e?" agent-card-child":"",v=t.isDone?" agent-card-done":"",b=t.isDone?'<span class="status-badge done">DONE</span>':"",_=s>0?`<span class="sub-count" title="${s} subagent${s>1?"s":""}">${s} sub${s>1?"s":""}</span>`:"",x=t.projectPath?qu(t.projectPath):o,C=as(ft[x%ft.length].body),$=t.projectName?`<span style="
|
|
304
|
+
background: ${C}33;
|
|
305
|
+
color: ${C};
|
|
306
|
+
padding: 1px 5px;
|
|
307
|
+
border-radius: 3px;
|
|
308
|
+
font-size: 9px;
|
|
309
|
+
margin-left: 4px;
|
|
310
|
+
">${ct(t.projectName)}</span>`:"",P=Ju(t.agentType),H=t.isDone?"done":t.isIdle?"idle":"active",R=this.getHealthColor(t);return`<div class="agent-card${m}${v}" data-agent-id="${t.id}" style="border-left: 3px solid ${l};">
|
|
311
|
+
<div class="card-top-row">
|
|
312
|
+
<div class="name">
|
|
313
|
+
<span class="agent-status-dot ${H}"></span>
|
|
314
|
+
${e?'<span class="child-connector">↳</span>':""}${ct(g)}${P}${this.roleBadge(t.role)}${$}${b}${_}
|
|
315
|
+
</div>
|
|
316
|
+
<div class="card-actions">
|
|
317
|
+
<div class="agent-metrics">
|
|
318
|
+
<canvas class="agent-sparkline" data-agent-id="${t.id}" data-color-index="${o}" width="60" height="16"></canvas>
|
|
319
|
+
<span class="agent-health-dot" style="background: ${R};"></span>
|
|
320
|
+
</div>
|
|
321
|
+
<canvas class="sparkline-canvas" data-agent-id="${t.id}" width="60" height="20"></canvas>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
${t.taskDescription?`<div class="task-desc" title="${Qt(t.taskDescription)}">${ct(ql(t.taskDescription,48))}</div>`:""}
|
|
325
|
+
<div class="zone">${(h==null?void 0:h.icon)??""} ${d} · ${c}</div>
|
|
326
|
+
<div class="card-tokens">${t.contextTokens>0?(()=>{const et=Ul(t.model),Z=Math.round(t.contextTokens/et*100),X=Z>=90?"#ef4444":Z>=75?"#f97316":Z>=50?"#eab308":"#22c55e",J=t.contextTokens-t.contextCacheTokens,st=it=>it>=1e3?`${Math.round(it/1e3)}k`:`${it}`;return`<span class="detail-ctx-bar" title="Context window: ${Z}% full ${J.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / ${et.toLocaleString()}"><span class="detail-ctx-breakdown">${st(J)} new · ${st(t.contextCacheTokens)} cached</span><span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${Z}%;background:${X}"></span></span><span class="detail-ctx-label" style="color:${X}">${Z}%</span></span>`})():`<span>${f}</span>`}</div>
|
|
327
|
+
</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,d=Math.floor(h/n);d>=0&&d<o&&r[o-1-d]++}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,d=Math.floor(n/h)-1,c=1,f=t.dataset.colorIndex,g=f?parseInt(f,10):0,m=ft[g%ft.length],v=as(m.body);for(let b=0;b<h;b++){const _=r[b]??0,x=Math.max(_>0?2:0,Math.round(_/l*(o-2))),C=b*(d+c),$=o-x;s.fillStyle=v,s.globalAlpha=_>0?.8:.15,s.fillRect(C,$,d,x)}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 c=1;c<n.samples.length;c++)l.push(Math.max(0,n.samples[c]-n.samples[c-1]));const h=Math.max(...l,1),d=o/Math.max(l.length-1,1);s.beginPath(),s.moveTo(0,r);for(let c=0;c<l.length;c++){const f=c*d,g=r-l[c]/h*(r-2)-1;s.lineTo(f,g)}s.lineTo((l.length-1)*d,r),s.closePath(),s.fillStyle="rgba(74, 222, 128, 0.15)",s.fill(),s.beginPath();for(let c=0;c<l.length;c++){const f=c*d,g=r-l[c]/h*(r-2)-1;c===0?s.moveTo(f,g):s.lineTo(f,g)}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 n1{constructor(t){y(this,"panelEl");y(this,"store");y(this,"selectedAgentId",null);y(this,"entries",[]);y(this,"historyListener",null);y(this,"onUpdateBound");y(this,"onIdleBound");y(this,"onShutdownBound");y(this,"_onCustomize",null);y(this,"_customizationLookup",null);y(this,"tokenSamples",[]);y(this,"toolTimestamps",[]);y(this,"sparklineTimer",null);this.store=t,this.panelEl=document.createElement("div"),this.panelEl.id="agent-detail-panel",this.panelEl.innerHTML=`
|
|
328
|
+
<div class="detail-header">
|
|
329
|
+
<div class="detail-header-buttons">
|
|
330
|
+
<button id="detail-back" title="Back to agent list">
|
|
331
|
+
<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>
|
|
332
|
+
Back
|
|
333
|
+
</button>
|
|
334
|
+
<span class="detail-btn-spacer"></span>
|
|
335
|
+
<button id="detail-customize" title="Customize agent name and color">Edit</button>
|
|
336
|
+
<button id="detail-kill" title="Shut down this agent permanently">Kill</button>
|
|
337
|
+
</div>
|
|
338
|
+
<div id="detail-card"></div>
|
|
339
|
+
</div>
|
|
340
|
+
<div id="detail-info"></div>
|
|
341
|
+
<div class="detail-section-title">Activity Feed</div>
|
|
342
|
+
<div id="detail-feed"></div>
|
|
343
|
+
`;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=ft[s%ft.length],o=as(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",c={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"},f=`<span class="detail-role-badge" title="Agent role: ${c.label}" style="background:${c.color}33;color:${c.color};">${c.label}</span>`;let g="";if(t.projectName){const b=t.projectPath?qu(t.projectPath):s,_=as(ft[b%ft.length].body);g=`<span class="detail-project-badge" title="Project: ${Qt(t.projectName)}" style="background:${_}33;color:${_};">${ct(t.projectName)}</span>`}const m=t.isDone?'<span class="detail-done-badge" title="Agent has finished">DONE</span>':"",v=this.panelEl.querySelector("#detail-card");v.innerHTML=`
|
|
344
|
+
<div class="detail-card-inner" style="border-left: 3px solid ${o};">
|
|
345
|
+
<div class="detail-card-top">
|
|
346
|
+
<div class="detail-card-name">
|
|
347
|
+
<span class="agent-status-dot ${l}" title="${h}"></span>
|
|
348
|
+
${ct(r)}${f}${g}${m}
|
|
349
|
+
</div>
|
|
350
|
+
<div class="detail-card-actions">
|
|
351
|
+
<canvas class="detail-velocity-canvas" width="60" height="16" title="Tool call frequency (last 5 min)"></canvas>
|
|
352
|
+
<span class="detail-health-dot" title="Agent health indicator"></span>
|
|
353
|
+
<canvas class="detail-sparkline-canvas" width="60" height="20" title="Token usage rate over time"></canvas>
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
${t.taskDescription?`<div class="detail-card-task" title="${Qt(t.taskDescription)}">${ct(ql(t.taskDescription,80))}</div>`:""}
|
|
357
|
+
<div class="detail-card-zone" id="detail-zone-line"></div>
|
|
358
|
+
<div class="detail-card-tokens" id="detail-token-line"></div>
|
|
359
|
+
</div>
|
|
360
|
+
`,this.renderCardStats(t)}renderCardStats(t){const e=Zt.get(t.currentZone),s=(e==null?void 0:e.icon)??"",n=(e==null?void 0:e.label)??t.currentZone,o=t.currentTool??"none",r=Qu(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">·</span> <span class="detail-card-tool" title="Current tool: ${Qt(o)}">${ct(o)}</span>`);const h=this.panelEl.querySelector("#detail-token-line");if(h){const c=Ul(t.model),f=t.contextTokens>0?Math.round(t.contextTokens/c*100):0,g=f>=90?"#ef4444":f>=75?"#f97316":f>=50?"#eab308":"#22c55e",m=t.contextTokens-t.contextCacheTokens,v=_=>_>=1e3?`${Math.round(_/1e3)}k`:`${_}`,b=`Context window: ${f}% full
|
|
361
|
+
${m.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / ${c.toLocaleString()}`;h.innerHTML=f>0?`<span class="detail-ctx-bar" title="${b}">
|
|
362
|
+
<span class="detail-ctx-breakdown">${v(m)} new · ${v(t.contextCacheTokens)} cached</span>
|
|
363
|
+
<span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${f}%;background:${g}"></span></span>
|
|
364
|
+
<span class="detail-ctx-label" style="color:${g}">${f}%</span>
|
|
365
|
+
</span>`:`<span title="Total token usage">${r}</span>`}const d=this.panelEl.querySelector(".detail-health-dot");if(d){const c=t.isDone||t.isIdle?"#888":"#22c55e";d.style.background=c,d.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",oe(Date.now()-t.spawnedAt),"How long this agent has been running")),s.push(this.infoRow("CLI",Ju(t.agentType),"Agent CLI source")),t.model&&s.push(this.infoRow("Model",`<code>${Qt(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>
|
|
366
|
+
<button class="detail-copy-btn" data-copy="${Qt(t.sessionId)}" title="Copy session ID to clipboard">
|
|
367
|
+
<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>
|
|
368
|
+
</button>`,"Unique session identifier")),t.teamName&&s.push(this.infoRow("Team",ct(t.teamName),"Team this agent belongs to")),t.gitBranch&&s.push(this.infoRow("Branch",`<code>${Qt(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="${Qt(t.parentId)}" title="Navigate to parent agent">${ct(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 d=this.getDisplayName(h);return`<a href="#" class="detail-link" data-agent-id="${Qt(h.id)}" title="Navigate to subagent">${ct(d)}</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 d=l.dataset.copy;d&&(navigator.clipboard.writeText(d).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 d=l.dataset.agentId;d&&this.open(d)})})}infoRow(t,e,s){return`<div class="detail-info-row" title="${Qt(s)}">
|
|
369
|
+
<span class="detail-info-label">${t}</span>
|
|
370
|
+
<span class="detail-info-value">${e}</span>
|
|
371
|
+
</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 c=1;c<this.tokenSamples.length;c++)l.push(Math.max(0,this.tokenSamples[c]-this.tokenSamples[c-1]));const h=Math.max(...l,1),d=o/Math.max(l.length-1,1);n.beginPath(),n.moveTo(0,r);for(let c=0;c<l.length;c++)n.lineTo(c*d,r-l[c]/h*(r-2)-1);n.lineTo((l.length-1)*d,r),n.closePath(),n.fillStyle="rgba(74, 222, 128, 0.15)",n.fill(),n.beginPath();for(let c=0;c<l.length;c++){const f=c*d,g=r-l[c]/h*(r-2)-1;c===0?n.moveTo(f,g):n.lineTo(f,g)}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,d=10,c=new Array(d).fill(0);for(const _ of this.toolTimestamps){const x=Math.floor((l-_)/h);x>=0&&x<d&&c[d-1-x]++}const f=Math.max(...c,1),g=Math.floor(o/d)-1,m=this.getDisplayColorIndex(t),v=ft[m%ft.length],b=as(v.body);for(let _=0;_<d;_++){const x=c[_]??0,C=Math.max(x>0?2:0,Math.round(x/f*(r-2)));n.fillStyle=b,n.globalAlpha=x>0?.8:.15,n.fillRect(_*(g+1),r-C,g,C)}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">${Qt(this.shortenArgs(t.toolArgs))}</span>`:"";return`<div class="feed-entry feed-tool">${s} <span class="feed-icon">🔧</span> <span class="feed-tool-name">${Qt(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">💬</span> ${Qt(n)}</div>`}case"zone-change":{const n=Zt.get(t.prevZone),o=Zt.get(t.zone);return`<div class="feed-entry feed-zone">${s} <span class="feed-icon">🚶</span> ${(n==null?void 0:n.icon)??""} ${(n==null?void 0:n.label)??t.prevZone} → ${(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">⚡</span> Agent spawned</div>`;case"idle":return`<div class="feed-entry feed-idle">${s} <span class="feed-icon">☕</span> Went idle</div>`;case"shutdown":return`<div class="feed-entry feed-shutdown">${s} <span class="feed-icon">🛑</span> Agent shut down</div>`;case"tokens":return`<div class="feed-entry feed-tokens">${s} <span class="feed-icon">🎬</span> +${gt(t.inputTokens??0)} in / +${gt(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=`
|
|
372
|
+
<div class="kill-confirm-box">
|
|
373
|
+
<div class="kill-confirm-title">Kill Agent</div>
|
|
374
|
+
<div class="kill-confirm-msg">Are you sure you want to shut down <strong>${Qt(e)}</strong>? This cannot be undone.</div>
|
|
375
|
+
<div class="kill-confirm-actions">
|
|
376
|
+
<button class="kill-confirm-cancel">Cancel</button>
|
|
377
|
+
<button class="kill-confirm-yes">Kill Agent</button>
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
`,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 o1(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 Zh(i){switch(i.type){case"agent:spawn":return"#a855f7";case"agent:shutdown":return"#f87171";case"agent:idle":return"#6b7280";case"agent:update":return"#"+ft[i.agent.colorIndex%ft.length].body.toString(16).padStart(6,"0")}}function tp(i){return i<300*1e3?60*1e3:i<900*1e3?120*1e3:300*1e3}function r1(i,t,e,s,n,o){e.fillStyle="rgba(255,255,255,0.15)",e.font="9px monospace",e.textAlign="center";const r=tp(o),l=Math.ceil(s/r)*r;for(let h=l;h<=n;h+=r){const d=(h-s)/o*i;e.fillRect(d,0,1,3);const c=new Date(h);e.fillText(c.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d,t-1)}}function Kh(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 d=s+r*n;l.textContent=new Date(d).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}class a1{constructor(t,e,s){y(this,"activeFilters",new Set(["tool","zone","idle","lifecycle"]));y(this,"visibleAgents",new Set);y(this,"agentFilterContainer");y(this,"customizationLookup",null);y(this,"onChanged");y(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="#"+ft[e.colorIndex%ft.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 l1{constructor(t){y(this,"el");y(this,"store");y(this,"canvas");y(this,"ctx");y(this,"playBtn");y(this,"liveBtn");y(this,"timeLabel");y(this,"expandBtn");y(this,"liveRenderTimer",null);y(this,"isLive",!0);y(this,"isPlaying",!1);y(this,"playbackPosition",0);y(this,"playbackSpeed",1);y(this,"lastFrameTime",0);y(this,"animId",null);y(this,"expanded",!1);y(this,"filter");y(this,"filterContainer");y(this,"swimLabelsEl");y(this,"trackWrapper");y(this,"_customizationLookup",null);y(this,"resizeHandler",()=>this.resizeCanvas());y(this,"onTimelineBound");y(this,"onSpawnBound");y(this,"onShutdownBound");y(this,"replayAgents",new Map);y(this,"onReplayState",null);this.store=t,this.el=document.createElement("div"),this.el.id="timeline-bar",this.el.innerHTML=`
|
|
381
|
+
<div class="timeline-top-bar">
|
|
382
|
+
<div class="timeline-controls">
|
|
383
|
+
<button id="timeline-play" title="Play/Pause">▶</button>
|
|
384
|
+
<button id="timeline-live" class="active" title="Jump to Live">LIVE</button>
|
|
385
|
+
<span id="timeline-time">--:--</span>
|
|
386
|
+
<span id="timeline-speed" title="Click to change speed">1x</span>
|
|
387
|
+
</div>
|
|
388
|
+
<div class="timeline-filters">
|
|
389
|
+
<button class="tl-filter-pill active" data-category="tool" title="Tool calls">
|
|
390
|
+
<span class="tl-filter-icon">🔧</span> Tools
|
|
391
|
+
</button>
|
|
392
|
+
<button class="tl-filter-pill active" data-category="zone" title="Zone changes">
|
|
393
|
+
<span class="tl-filter-icon">🏢</span> Zones
|
|
394
|
+
</button>
|
|
395
|
+
<button class="tl-filter-pill active" data-category="idle" title="Idle events">
|
|
396
|
+
<span class="tl-filter-icon">☕</span> Idle
|
|
397
|
+
</button>
|
|
398
|
+
<button class="tl-filter-pill active" data-category="lifecycle" title="Spawn / Shutdown">
|
|
399
|
+
<span class="tl-filter-icon">⭐</span> Life
|
|
400
|
+
</button>
|
|
401
|
+
</div>
|
|
402
|
+
<div class="timeline-agent-filters"></div>
|
|
403
|
+
<button class="timeline-expand-btn" title="Expand swim lanes">▲</button>
|
|
404
|
+
</div>
|
|
405
|
+
<div class="timeline-track" style="position:relative;">
|
|
406
|
+
<div class="timeline-swim-labels"></div>
|
|
407
|
+
<canvas id="timeline-canvas"></canvas>
|
|
408
|
+
</div>
|
|
409
|
+
`,(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 a1(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?"▮▮":"▶",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="▼",this.expandBtn.title="Collapse swim lanes"):(this.el.classList.remove("expanded"),this.expandBtn.classList.remove("active"),this.expandBtn.innerHTML="▲",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 d=(h.timestamp-o)/l*t,c=Zh(h);s.fillStyle=c,h.type==="agent:spawn"||h.type==="agent:shutdown"?s.fillRect(d-1,2,3,e-4):(s.globalAlpha=.6,s.fillRect(d,e/2-2,2,4),s.globalAlpha=1)}r1(t,e,s,o,r,l),Kh(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(),d=h-l||1,c=t-60,f=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),Kh(t,e,s,l,d,this.isLive,this.playbackPosition,this.timeLabel);return}const m=e-14,v=Math.max(14,Math.min(28,m/o.length)),b=v*o.length,_=new Map;o.forEach((P,H)=>_.set(P.id,H)),this.swimLabelsEl.style.display="flex",this.swimLabelsEl.innerHTML="";for(const P of o){const R="#"+ft[P.colorIndex%ft.length].body.toString(16).padStart(6,"0"),O=document.createElement("div");O.className="swim-label",O.style.height=`${v}px`,O.style.color=R,O.textContent=P.name,this.swimLabelsEl.appendChild(O)}for(let P=0;P<o.length;P++){const H=P*v;s.fillStyle=P%2===0?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",s.fillRect(f,H,c,v),P>0&&(s.strokeStyle="rgba(255,255,255,0.04)",s.lineWidth=1,s.beginPath(),s.moveTo(f,H),s.lineTo(t,H),s.stroke())}s.fillStyle="rgba(14, 16, 32, 0.8)",s.fillRect(0,0,60,b);for(const P of r){const H=o1(P);if(!this.filter.isEventVisible(P,H))continue;const R=_.get(P.agent.id);if(R===void 0)continue;const O=f+(P.timestamp-l)/d*c,et=R*v,Z=Zh(P);s.fillStyle=Z;const X=et+v/2;P.type==="agent:spawn"||P.type==="agent:shutdown"?s.fillRect(O-1,et+1,3,v-2):P.type==="agent:idle"?(s.globalAlpha=.5,s.beginPath(),s.moveTo(O,X-3),s.lineTo(O+3,X),s.lineTo(O,X+3),s.lineTo(O-3,X),s.closePath(),s.fill(),s.globalAlpha=1):(s.globalAlpha=.7,s.beginPath(),s.arc(O,X,2.5,0,Math.PI*2),s.fill(),s.globalAlpha=1)}const x=b;s.fillStyle="rgba(255,255,255,0.15)",s.font="9px monospace",s.textAlign="center";const C=tp(d),$=Math.ceil(l/C)*C;for(let P=$;P<=h;P+=C){const H=f+(P-l)/d*c;s.fillRect(H,x,1,3);const R=new Date(P);s.fillText(R.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),H,x+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 P=f+this.playbackPosition*c;s.strokeStyle="#e94560",s.lineWidth=2,s.beginPath(),s.moveTo(P,0),s.lineTo(P,e),s.stroke();const H=l+this.playbackPosition*d;this.timeLabel.textContent=new Date(H).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="▶",this.stopPlayback(),this.reconstructState(),this.render()}goLive(){this.isLive=!0,this.isPlaying=!1,this.playBtn.innerHTML="▶",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)}}function Ts(i,t,e,s,n,o,r,l){s.forEach((h,d)=>{const c=i.createOscillator(),f=i.createGain();c.type=n,c.frequency.value=h;const g=t+d*o;f.gain.setValueAtTime(0,g),f.gain.linearRampToValueAtTime(e,g+r),f.gain.exponentialRampToValueAtTime(.001,g+l),c.connect(f).connect(i.destination),c.start(g),c.stop(g+l+.05)})}function $e(i,t,e,s,n,o,r,l){const h=i.createOscillator(),d=i.createGain();h.type=o,h.frequency.setValueAtTime(s,t),h.frequency.exponentialRampToValueAtTime(n,t+r),d.gain.setValueAtTime(e,t),d.gain.exponentialRampToValueAtTime(.001,t+l),h.connect(d).connect(i.destination),h.start(t),h.stop(t+l+.05)}const c1=[{id:"chime",label:"Chime",play:(i,t,e)=>Ts(i,t,e*.25,[523.25,659.25,783.99],"sine",.1,.03,.3)},{id:"fanfare",label:"Fanfare",play:(i,t,e)=>Ts(i,t,e*.2,[392,523.25,659.25],"square",.12,.02,.35)},{id:"pixel-pop",label:"Pixel Pop",play:(i,t,e)=>$e(i,t,e*.2,200,1200,"square",.15,.25)},{id:"synth-rise",label:"Synth Rise",play:(i,t,e)=>$e(i,t,e*.18,220,880,"sawtooth",.3,.4)},{id:"harp",label:"Harp",play:(i,t,e)=>Ts(i,t,e*.2,[261.63,329.63,392,523.25],"triangle",.06,.01,.5)}],h1=[{id:"blip",label:"Blip",play:(i,t,e)=>$e(i,t,e*.12,440,660,"sine",.08,.15)},{id:"swoosh",label:"Swoosh",play:(i,t,e)=>$e(i,t,e*.1,1200,200,"sawtooth",.12,.18)},{id:"pop",label:"Pop",play:(i,t,e)=>$e(i,t,e*.15,600,300,"sine",.04,.08)},{id:"warp",label:"Warp",play(i,t,e){const s=e*.07;["sine","triangle"].forEach((n,o)=>{const r=i.createOscillator(),l=i.createGain();r.type=n,r.frequency.setValueAtTime(300+o*20,t),r.frequency.exponentialRampToValueAtTime(800+o*40,t+.1),r.frequency.exponentialRampToValueAtTime(400,t+.18),l.gain.setValueAtTime(s,t),l.gain.exponentialRampToValueAtTime(.001,t+.22),r.connect(l).connect(i.destination),r.start(t),r.stop(t+.27)})}}],d1=[{id:"tap",label:"Tap",play:(i,t,e)=>$e(i,t,e*.06,880,600,"sine",.06,.08)},{id:"click",label:"Click",play:(i,t,e)=>$e(i,t,e*.08,1200,400,"square",.02,.04)},{id:"hammer",label:"Hammer",play:(i,t,e)=>$e(i,t,e*.07,200,80,"triangle",.05,.1)},{id:"beep",label:"Beep",play:(i,t,e)=>$e(i,t,e*.06,1e3,980,"sine",.04,.06)},{id:"typewriter",label:"Typewriter",play(i,t,e){const s=e*.05;[0,.03].forEach(n=>{$e(i,t+n,s,800+Math.random()*400,200,"square",.015,.025)})}}],u1=[{id:"descend",label:"Descend",play:(i,t,e)=>$e(i,t,e*.1,440,330,"sine",.2,.3)},{id:"wind-down",label:"Wind Down",play(i,t,e){const s=e*.08,n=i.createOscillator(),o=i.createOscillator(),r=i.createGain(),l=i.createGain();n.type="triangle",n.frequency.setValueAtTime(500,t),n.frequency.exponentialRampToValueAtTime(150,t+.4),o.type="sine",o.frequency.value=8,r.gain.value=30,o.connect(r).connect(n.frequency),l.gain.setValueAtTime(s,t),l.gain.exponentialRampToValueAtTime(.001,t+.45),n.connect(l).connect(i.destination),o.start(t),n.start(t),n.stop(t+.5),o.stop(t+.5)}},{id:"sigh",label:"Sigh",play:(i,t,e)=>$e(i,t,e*.08,600,200,"sawtooth",.3,.4)},{id:"music-box",label:"Music Box",play:(i,t,e)=>Ts(i,t,e*.12,[659.25,440],"sine",.2,.01,.4)}],p1=[{id:"farewell",label:"Farewell",play:(i,t,e)=>Ts(i,t,e*.2,[659.25,523.25,392],"triangle",.12,.02,.3)},{id:"power-down",label:"Power Down",play:(i,t,e)=>$e(i,t,e*.15,800,60,"square",.5,.55)},{id:"portal",label:"Portal",play(i,t,e){const s=e*.12;[0,5].forEach(n=>{const o=i.createOscillator(),r=i.createGain();o.type="sine",o.frequency.setValueAtTime(900+n,t),o.frequency.exponentialRampToValueAtTime(200,t+.35),o.detune.value=n*10,r.gain.setValueAtTime(s*.6,t),r.gain.exponentialRampToValueAtTime(.001,t+.4),o.connect(r).connect(i.destination),o.start(t),o.stop(t+.45)})}},{id:"wave",label:"Wave",play:(i,t,e)=>Ts(i,t,e*.15,[392,523.25,440,330],"sine",.08,.02,.2)}],f1=[{id:"doorbell",label:"Doorbell",play:(i,t,e)=>Ts(i,t,e*.3,[880,660],"sine",.15,.02,.25)},{id:"alarm",label:"Alarm",play(i,t,e){const s=e*.2;for(let n=0;n<4;n++){const o=i.createOscillator(),r=i.createGain();o.type="square",o.frequency.value=n%2===0?1e3:800;const l=t+n*.08;r.gain.setValueAtTime(s,l),r.gain.setValueAtTime(.001,l+.06),o.connect(r).connect(i.destination),o.start(l),o.stop(l+.07)}}},{id:"ping",label:"Ping",play:(i,t,e)=>Ts(i,t,e*.25,[1047],"sine",0,.01,.6)},{id:"siren",label:"Siren",play(i,t,e){const s=e*.15,n=i.createOscillator(),o=i.createGain();n.type="sine",n.frequency.setValueAtTime(600,t),n.frequency.linearRampToValueAtTime(1e3,t+.15),n.frequency.linearRampToValueAtTime(600,t+.3),n.frequency.linearRampToValueAtTime(1e3,t+.45),o.gain.setValueAtTime(s,t),o.gain.setValueAtTime(s,t+.4),o.gain.exponentialRampToValueAtTime(.001,t+.5),n.connect(o).connect(i.destination),n.start(t),n.stop(t+.55)}},{id:"chime-alert",label:"Chime Alert",play:(i,t,e)=>Ts(i,t,e*.25,[1047,1319],"sine",.12,.01,.4)}],kl={spawn:c1,"zone-change":h1,"tool-use":d1,idle:u1,shutdown:p1,"input-needed":f1},Cr={spawn:"chime","zone-change":"blip","tool-use":"tap",idle:"descend",shutdown:"farewell","input-needed":"doorbell"},Er=class Er{constructor(){y(this,"ctx",null);y(this,"_volume",.3);y(this,"_muted",!1);y(this,"initialized",!1);y(this,"lastToolUseTime",0);y(this,"_enabledEvents",{spawn:!0,"zone-change":!0,"tool-use":!0,idle:!0,shutdown:!0,"input-needed":!0});y(this,"_voices",{...Cr})}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}setEnabledEvents(t){this._enabledEvents={...t}}setVoices(t){this._voices={...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}getVoice(t){const e=this._voices[t],s=kl[t];return s.find(n=>n.id===e)??s[0]}play(t){if(this._muted||this._volume===0||!this._enabledEvents[t])return;if(t==="tool-use"){const n=performance.now();if(n-this.lastToolUseTime<Er.TOOL_USE_COOLDOWN)return;this.lastToolUseTime=n}const e=this.ensureContext();if(!e)return;const s=this.getVoice(t);s==null||s.play(e,e.currentTime,this.gain())}preview(t,e){const s=this.ensureContext();if(!s)return;const n=kl[t],o=n.find(l=>l.id===e)??n[0],r=this._volume>0?this._volume:.3;o==null||o.play(s,s.currentTime,r)}};y(Er,"TOOL_USE_COOLDOWN",300);let Cl=Er;class m1{constructor(){y(this,"_enabled",!0);y(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 Zn=300,g1=2,v1=3,y1=8;class b1{constructor(t){y(this,"zones",new Map);y(this,"container");y(this,"currentBucketIndex",0);y(this,"bucketTimer");y(this,"animFrame",null);y(this,"lastFrameTime",0);y(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<Zn;l++){const h=(this.currentBucketIndex-l+Zn)%Zn,d=Math.exp(-h/60);o+=n.buckets[l]*d}const r=Math.min(1,o/(y1*15));n.heat+=(r-n.heat)*Math.min(1,g1*e),n.pulsePhase+=v1*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=`
|
|
410
|
+
position: absolute;
|
|
411
|
+
top: 0;
|
|
412
|
+
left: 0;
|
|
413
|
+
width: 100%;
|
|
414
|
+
height: 100%;
|
|
415
|
+
pointer-events: none;
|
|
416
|
+
z-index: 5;
|
|
417
|
+
`,document.getElementById("app").appendChild(this.container);for(const e of ne){const s=document.createElement("canvas");s.style.cssText=`
|
|
418
|
+
position: absolute;
|
|
419
|
+
pointer-events: none;
|
|
420
|
+
border-radius: 4px;
|
|
421
|
+
`,this.container.appendChild(s);const n=s.getContext("2d");this.zones.set(e.id,{buckets:new Array(Zn).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)%Zn;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 ne){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,d=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=`${d}px`,o.overlay.width=Math.ceil(h),o.overlay.height=Math.ceil(d)}}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,d=Math.floor(Kn(30,255,t.heat)),c=Math.floor(Kn(60,t.heat<.5?Kn(80,160,t.heat*2):Kn(160,50,(t.heat-.5)*2),t.heat)),f=Math.floor(Kn(180,20,t.heat)),g=o/2,m=r/2,v=s.createRadialGradient(g,m,0,g,m,Math.max(o,r)*.7);if(v.addColorStop(0,`rgba(${d},${c},${f},${h})`),v.addColorStop(.6,`rgba(${d},${c},${f},${h*.5})`),v.addColorStop(1,`rgba(${d},${c},${f},0)`),s.fillStyle=v,s.fillRect(0,0,o,r),t.heat>.3){const b=(t.heat-.3)*.4*l;s.strokeStyle=`rgba(${d},${c},${f},${b})`,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 Kn(i,t,e){return i+(t-i)*w1(e,0,1)}class _1{constructor(t,e){y(this,"el");y(this,"inputEl");y(this,"listEl");y(this,"isOpen",!1);y(this,"actions",[]);y(this,"filteredActions",[]);y(this,"selectedIndex",0);y(this,"onCommand");y(this,"_customizationLookup",null);y(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=`
|
|
422
|
+
<div class="cmd-backdrop"></div>
|
|
423
|
+
<div class="cmd-modal">
|
|
424
|
+
<div class="cmd-input-wrap">
|
|
425
|
+
<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>
|
|
426
|
+
<input type="text" class="cmd-input" placeholder="Search commands, agents, zones…" autocomplete="off" />
|
|
427
|
+
<kbd class="cmd-kbd">ESC</kbd>
|
|
428
|
+
</div>
|
|
429
|
+
<div class="cmd-list"></div>
|
|
430
|
+
<div class="cmd-footer">
|
|
431
|
+
<span><kbd>↑↓</kbd> Navigate</span>
|
|
432
|
+
<span><kbd>Enter</kbd> Select</span>
|
|
433
|
+
<span><kbd>Esc</kbd> Close</span>
|
|
434
|
+
</div>
|
|
435
|
+
</div>
|
|
436
|
+
`,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 ne)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")}),this.actions.push({id:"feature:settings",label:"Open Settings",description:"Sound, notifications, cost alerts, display (S)",icon:"⚙",category:"feature",action:()=>this.onCommand("toggle-settings")})}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=Zt.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}">
|
|
437
|
+
<span class="cmd-item-icon">${t.icon}</span>
|
|
438
|
+
<div class="cmd-item-text">
|
|
439
|
+
<div class="cmd-item-label">${ct(t.label)}</div>
|
|
440
|
+
<div class="cmd-item-desc">${ct(t.description)}</div>
|
|
441
|
+
</div>
|
|
442
|
+
<span class="cmd-item-cat">${t.category}</span>
|
|
443
|
+
</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 x1=6e4,za=2e3,S1=180;class T1{constructor(t,e){y(this,"containerEl");y(this,"contentEl");y(this,"store");y(this,"isVisible",!1);y(this,"refreshTimer");y(this,"sampleTimer");y(this,"tokenSamples",[]);y(this,"costThreshold",5);y(this,"thresholdAlerted",!1);y(this,"thresholdFocused",!1);y(this,"alertEl",null);y(this,"toolChainData",null);y(this,"zoneTime",new Map);y(this,"_customizationLookup",null);y(this,"onAgentUpdateBound");y(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(),za),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}setCostThreshold(t){this.costThreshold=t,this.thresholdAlerted=!1}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+za/1e3)}this.tokenSamples.push({timestamp:Date.now(),totalTokens:e}),this.tokenSamples.length>S1&&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 Ji({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()-x1,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((x,C)=>x+this.calculateCost(C),0),s=t.reduce((x,C)=>x+C.inputTokens,0),n=t.reduce((x,C)=>x+C.outputTokens,0),o=t.reduce((x,C)=>x+C.cacheReadTokens,0),r=t.reduce((x,C)=>x+C.cacheCreationTokens,0),l=this.getTokenVelocity(),h=this.getVelocityTrend(),d=h==="up"?"↑":h==="down"?"↓":"→",c=h==="up"?"#f87171":h==="down"?"#4ade80":"#888",f=s+o+r,g=f>0?o/f*100:0,m=t.reduce((x,C)=>{const $=Uu(C.model);return x+C.cacheReadTokens/1e6*$.input*.9},0),v=[...t].sort((x,C)=>this.calculateCost(C)-this.calculateCost(x)),b=this.renderVelocitySparkline();this.contentEl.innerHTML=`
|
|
444
|
+
<div class="analytics-cards">
|
|
445
|
+
<div class="analytics-card total-cost">
|
|
446
|
+
<div class="card-label">Total Cost</div>
|
|
447
|
+
<div class="card-value">$${e.toFixed(2)}</div>
|
|
448
|
+
<div class="card-sub">${gt(f)} in / ${gt(n)} out</div>
|
|
449
|
+
</div>
|
|
450
|
+
<div class="analytics-card velocity">
|
|
451
|
+
<div class="card-label">Token Velocity</div>
|
|
452
|
+
<div class="card-value">${gt(Math.round(l))}<span class="card-unit">/min</span></div>
|
|
453
|
+
<div class="card-sub" style="color:${c}">${d} ${h}</div>
|
|
454
|
+
</div>
|
|
455
|
+
<div class="analytics-card agents-count">
|
|
456
|
+
<div class="card-label">Active Agents</div>
|
|
457
|
+
<div class="card-value">${t.filter(x=>!x.isIdle).length}<span class="card-unit">/${t.length}</span></div>
|
|
458
|
+
<div class="card-sub">${t.filter(x=>x.isIdle).length} idle</div>
|
|
459
|
+
</div>
|
|
460
|
+
<div class="analytics-card cache-card">
|
|
461
|
+
<div class="card-label">Cache Efficiency</div>
|
|
462
|
+
<div class="card-value">${Math.min(g,100).toFixed(1)}<span class="card-unit">%</span></div>
|
|
463
|
+
<div class="card-sub">${gt(o)} read / ${gt(r)} created</div>
|
|
464
|
+
<div class="cache-savings">~$${m.toFixed(2)} saved</div>
|
|
465
|
+
</div>
|
|
466
|
+
</div>
|
|
467
|
+
|
|
468
|
+
<div class="analytics-section">
|
|
469
|
+
<div class="section-title">Token Rate (last ${Math.round(this.tokenSamples.length*za/6e4)}min)</div>
|
|
470
|
+
<div class="sparkline-container">${b}</div>
|
|
471
|
+
</div>
|
|
472
|
+
|
|
473
|
+
<div class="analytics-section">
|
|
474
|
+
<div class="section-title">Cost by Agent</div>
|
|
475
|
+
${v.length>0?v.map(x=>this.renderAgentBar(x,e)).join(""):'<div class="analytics-empty">No agents active</div>'}
|
|
476
|
+
</div>
|
|
477
|
+
|
|
478
|
+
<div class="analytics-section">
|
|
479
|
+
<div class="section-title">Time Spent by Zone</div>
|
|
480
|
+
${this.renderZoneTimeBars()}
|
|
481
|
+
</div>
|
|
482
|
+
|
|
483
|
+
<div class="analytics-section">
|
|
484
|
+
<div class="section-title">Tool Usage Distribution</div>
|
|
485
|
+
${this.renderToolUsageBars()}
|
|
486
|
+
</div>
|
|
487
|
+
|
|
488
|
+
<div class="analytics-section">
|
|
489
|
+
<div class="section-title">Cost Efficiency</div>
|
|
490
|
+
${this.renderCostEfficiency(t,e)}
|
|
491
|
+
</div>
|
|
492
|
+
|
|
493
|
+
<div class="analytics-section">
|
|
494
|
+
<div class="section-title">Session Duration</div>
|
|
495
|
+
${this.renderSessionDurations(t)}
|
|
496
|
+
</div>
|
|
497
|
+
|
|
498
|
+
<div class="analytics-section threshold-section">
|
|
499
|
+
<div class="section-title">Alert Threshold</div>
|
|
500
|
+
<div class="threshold-row">
|
|
501
|
+
<span>$</span>
|
|
502
|
+
<input type="number" id="cost-threshold" name="cost-threshold" autocomplete="off" value="${this.costThreshold}" min="0.1" step="0.5" />
|
|
503
|
+
<span class="threshold-status">${this.thresholdAlerted?"Exceeded":"Under"}</span>
|
|
504
|
+
</div>
|
|
505
|
+
</div>
|
|
506
|
+
`;const _=this.contentEl.querySelector("#cost-threshold");_&&(_.addEventListener("change",()=>{this.costThreshold=parseFloat(_.value)||5,this.thresholdAlerted=!1}),this.thresholdFocused&&_.focus(),_.addEventListener("focus",()=>{this.thresholdFocused=!0}),_.addEventListener("blur",()=>{this.thresholdFocused=!1}))}renderAgentBar(t,e){const s=this.calculateCost(t),n=e>0?s/e*100:0,o=ft[t.colorIndex%ft.length],r=as(o.body);return`<div class="agent-bar">
|
|
507
|
+
<div class="agent-bar-label">
|
|
508
|
+
<span class="agent-dot" style="background:${r}"></span>
|
|
509
|
+
<span class="agent-bar-name">${ct(t.name)}</span>
|
|
510
|
+
<span class="agent-bar-cost">$${s.toFixed(2)}</span>
|
|
511
|
+
</div>
|
|
512
|
+
<div class="agent-bar-track">
|
|
513
|
+
<div class="agent-bar-fill" style="width:${Math.max(2,n)}%;background:${r}"></div>
|
|
514
|
+
</div>
|
|
515
|
+
</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=Zt.get(s),r=s==="idle",l=t>0?n/t*100:0,h=r?"#6b7280":o?as(o.color):"#666",d=r?"Idle":(o==null?void 0:o.label)??s;return`<div class="zone-bar">
|
|
516
|
+
<div class="zone-bar-label">
|
|
517
|
+
<span>${r?"💤":(o==null?void 0:o.icon)??""} ${d}</span>
|
|
518
|
+
<span class="zone-bar-cost">${oe(n*1e3)} (${l.toFixed(0)}%)</span>
|
|
519
|
+
</div>
|
|
520
|
+
<div class="zone-bar-track">
|
|
521
|
+
<div class="zone-bar-fill" style="width:${Math.max(2,l)}%;background:${h}"></div>
|
|
522
|
+
</div>
|
|
523
|
+
</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 c=1;c<s.length;c++)n.push(Math.max(0,s[c].totalTokens-s[c-1].totalTokens));if(n.length===0)return"";const o=Math.max(...n,1),r=t/Math.max(n.length-1,1),h=n.map((c,f)=>{const g=f*r,m=e-c/o*(e-4)-2;return`${g.toFixed(1)},${m.toFixed(1)}`}).map((c,f)=>f===0?`M${c}`:`L${c}`).join(" "),d=`${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">
|
|
524
|
+
<defs>
|
|
525
|
+
<linearGradient id="sparkGrad" x1="0" y1="0" x2="0" y2="1">
|
|
526
|
+
<stop offset="0%" stop-color="#4ade80" stop-opacity="0.3"/>
|
|
527
|
+
<stop offset="100%" stop-color="#4ade80" stop-opacity="0"/>
|
|
528
|
+
</linearGradient>
|
|
529
|
+
</defs>
|
|
530
|
+
<path d="${d}" fill="url(#sparkGrad)"/>
|
|
531
|
+
<path d="${h}" fill="none" stroke="#4ade80" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
532
|
+
</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,d=r.startsWith("mcp__")?"#60a5fa":"#a78bfa";let c=r;if(r.startsWith("mcp__")){const f=r.slice(5).split("__");if(f.length>=2){const g=f.slice(0,-1).join("/"),m=f[f.length-1];c=`${g} / ${m}`}}return`<div class="tool-bar">
|
|
533
|
+
<div class="tool-bar-label">
|
|
534
|
+
<span class="tool-bar-name" title="${ct(r)}">${ct(c)}</span>
|
|
535
|
+
<span class="tool-bar-count">${l}</span>
|
|
536
|
+
</div>
|
|
537
|
+
<div class="tool-bar-track">
|
|
538
|
+
<div class="tool-bar-fill" style="width:${Math.max(2,h)}%;background:${d}"></div>
|
|
539
|
+
</div>
|
|
540
|
+
</div>`}).join("")}renderCostEfficiency(t,e){var d;const s=Object.values(((d=this.toolChainData)==null?void 0:d.toolCounts)??{}).reduce((c,f)=>c+f,0),n=s>0?e/s:0,o=t.reduce((c,f)=>c+f.inputTokens+f.outputTokens+f.cacheReadTokens+f.cacheCreationTokens,0),r=s>0?o/s:0,l=Date.now(),h=t.map(c=>{const f=Math.max((l-c.spawnedAt)/6e4,.5),g=this.calculateCost(c);return{name:c.name,rate:g/f,cost:g}}).filter(c=>c.cost>.001).sort((c,f)=>f.rate-c.rate);return`
|
|
541
|
+
<div class="analytics-cards" style="margin-bottom:8px">
|
|
542
|
+
<div class="analytics-card">
|
|
543
|
+
<div class="card-label">Cost / Tool Use</div>
|
|
544
|
+
<div class="card-value">$${n.toFixed(4)}</div>
|
|
545
|
+
<div class="card-sub">${s} total uses</div>
|
|
546
|
+
</div>
|
|
547
|
+
<div class="analytics-card">
|
|
548
|
+
<div class="card-label">Tokens / Tool Use</div>
|
|
549
|
+
<div class="card-value">${gt(Math.round(r))}</div>
|
|
550
|
+
<div class="card-sub">${gt(o)} total</div>
|
|
551
|
+
</div>
|
|
552
|
+
</div>
|
|
553
|
+
${h.length>0?'<div class="cost-rate-header">Cost rate ($/min)</div>'+h.slice(0,5).map(c=>`<div class="cost-rate-row">
|
|
554
|
+
<span class="cost-rate-name">${ct(c.name)}</span>
|
|
555
|
+
<span class="cost-rate-value">$${c.rate.toFixed(4)}/min</span>
|
|
556
|
+
</div>`).join(""):""}
|
|
557
|
+
`}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=ft[s.colorIndex%ft.length];return`<div class="session-row">
|
|
558
|
+
<span class="agent-dot" style="background:${as(o.body)}"></span>
|
|
559
|
+
<span class="session-name">${ct(s.name)}</span>
|
|
560
|
+
<span class="session-duration">${oe(n)}</span>
|
|
561
|
+
<span class="session-status ${s.isIdle?"idle":"active"}">${s.isIdle?"idle":"active"}</span>
|
|
562
|
+
</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 k1="agent-move-layout",Qh=200;new Map(ne.map(i=>[i.id,{x:i.x,y:i.y,width:i.width,height:i.height}]));function C1(){try{const i=localStorage.getItem(k1);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=Zt.get(e);n&&(n.x=s.x,n.y=s.y,n.width=Math.max(Qh,s.width),n.height=Math.max(Qh,s.height))}}catch{}}const A1=6e4,E1=2e3;class M1{constructor(t){y(this,"store");y(this,"refreshTimer");y(this,"sampleTimer");y(this,"samples",[]);y(this,"connectionDot");y(this,"hooksDot");y(this,"focusBar");y(this,"hookEventCount",0);y(this,"onHooksStatusBound");y(this,"onPermRequestBound");y(this,"onPermResolvedBound");y(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(),E1)}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()-A1,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(c=>!c.isIdle&&!c.isDone).length,s=t.filter(c=>c.isIdle||c.isDone).length;let n=0;for(const c of t)n+=Ji(c);const o=this.getVelocity(),r=(c,f)=>{const g=document.querySelector(`#${c} .tb-stat-val`);g&&(g.textContent=f)};r("tb-active",String(e)),r("tb-idle",String(s)),r("tb-cost",n<.01?n.toFixed(4):n.toFixed(2)),r("tb-velocity",gt(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,d=this.store.isHooksActive();this.hooksDot.classList.toggle("hooks-pending",h>0),this.hooksDot.classList.toggle("hooks-active",d&&h===0),h>0?this.hooksDot.title=`Hooks: ${h} permission${h>1?"s":""} pending | ${this.hookEventCount} events received`:d?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 I1{constructor(){y(this,"activeTab","monitor");y(this,"collapsed",!1);y(this,"onTabChange",null);y(this,"el");y(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 P1=4500,L1=5,Mr=class Mr{constructor(t){y(this,"containerEl");y(this,"store");y(this,"_customizationLookup",null);y(this,"toasts",[]);y(this,"onSpawnBound");y(this,"onIdleBound");y(this,"onShutdownBound");y(this,"onAnomalyBound");y(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=ft[t.colorIndex%ft.length];return as(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>${ct(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>${ct(e)}</strong> finished`,"done")}}onShutdown(t){const e=this.store.getAgent(t),s=e?this.getName(e):t.slice(0,10);this.show(`<strong>${ct(s)}</strong> shut down`,"shutdown")}onTaskCompleted(t){this.show(`✓ Task completed: <strong>${ct(t)}</strong>`,"done")}onAnomaly(t){const e=Mr.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>${ct(o)}</strong>: ${ct(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),P1);for(this.toasts.push({el:s,timer:n});this.toasts.length>L1;){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()}};y(Mr,"ANOMALY_ICONS",{"retry-loop":"🔁","token-spike":"📈","stuck-agent":"⏳"});let Al=Mr;const $1=[{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"},{keys:"S",description:"Open settings panel"}]}];class B1{constructor(){y(this,"el");y(this,"isOpen",!1);y(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=`
|
|
563
|
+
<div class="sh-backdrop"></div>
|
|
564
|
+
<div class="sh-modal">
|
|
565
|
+
<div class="sh-header">
|
|
566
|
+
<span class="sh-title">Keyboard Shortcuts</span>
|
|
567
|
+
<button class="sh-close">×</button>
|
|
568
|
+
</div>
|
|
569
|
+
<div class="sh-body">
|
|
570
|
+
${$1.map(t=>`
|
|
571
|
+
<div class="sh-group">
|
|
572
|
+
<div class="sh-group-title">${t.title}</div>
|
|
573
|
+
${t.shortcuts.map(e=>`
|
|
574
|
+
<div class="sh-row">
|
|
575
|
+
<span class="sh-keys">${this.renderKeys(e.keys)}</span>
|
|
576
|
+
<span class="sh-desc">${e.description}</span>
|
|
577
|
+
</div>
|
|
578
|
+
`).join("")}
|
|
579
|
+
</div>
|
|
580
|
+
`).join("")}
|
|
581
|
+
</div>
|
|
582
|
+
<div class="sh-footer">Press <kbd>?</kbd> to close</div>
|
|
583
|
+
</div>
|
|
584
|
+
`,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 R1{constructor(t){y(this,"el");y(this,"store");y(this,"isOpen",!1);y(this,"_customizationLookup",null);this.store=t,this.el=document.createElement("div"),this.el.id="session-export",this.el.innerHTML=`
|
|
585
|
+
<div class="se-backdrop"></div>
|
|
586
|
+
<div class="se-modal">
|
|
587
|
+
<div class="se-header">
|
|
588
|
+
<span class="se-title">Session Summary</span>
|
|
589
|
+
<button class="se-close">×</button>
|
|
590
|
+
</div>
|
|
591
|
+
<div class="se-body">
|
|
592
|
+
<pre class="se-content"></pre>
|
|
593
|
+
</div>
|
|
594
|
+
<div class="se-footer">
|
|
595
|
+
<button class="se-copy-btn">Copy to Clipboard</button>
|
|
596
|
+
<button class="se-download-btn">Download .md</button>
|
|
597
|
+
</div>
|
|
598
|
+
</div>
|
|
599
|
+
`,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 g,m,v;const t=Array.from(this.store.getAgents().values()),e=Date.now(),s=t.length>0?Math.min(...t.map(b=>b.spawnedAt)):e,n=e-s;let o=0,r=0,l=0,h=0;const d=[];for(const b of t){const _=Ji(b);o+=_,r+=b.totalInputTokens,l+=b.totalOutputTokens,h+=b.cacheReadTokens;const x=Zt.get(b.currentZone);d.push({name:((m=(g=this._customizationLookup)==null?void 0:g.call(this,b))==null?void 0:m.displayName)||b.agentName||b.projectName||b.sessionId.slice(0,10),cost:_,tokens:b.totalInputTokens+b.totalOutputTokens,duration:e-b.spawnedAt,role:b.role,zone:(x==null?void 0:x.label)??b.currentZone,status:b.isDone?"Done":b.isIdle?"Idle":"Active"})}d.sort((b,_)=>_.cost-b.cost);const c=[];if(c.push("# AgentMove Session Summary"),c.push(`> Generated ${new Date().toISOString()}`),c.push(""),c.push("## Overview"),c.push("| Metric | Value |"),c.push("|--------|-------|"),c.push(`| Duration | ${oe(n)} |`),c.push(`| Total Agents | ${t.length} |`),c.push(`| Active | ${t.filter(b=>!b.isIdle&&!b.isDone).length} |`),c.push(`| Idle | ${t.filter(b=>b.isIdle&&!b.isDone).length} |`),c.push(`| Done | ${t.filter(b=>b.isDone).length} |`),c.push(`| Total Cost | $${o.toFixed(4)} |`),c.push(`| Input Tokens | ${gt(r)} |`),c.push(`| Output Tokens | ${gt(l)} |`),c.push(`| Cache Reads | ${gt(h)} |`),c.push(""),d.length>0){c.push("## Agents"),c.push("| Agent | Role | Status | Zone | Cost | Tokens | Duration |"),c.push("|-------|------|--------|------|------|--------|----------|");for(const b of d)c.push(`| ${b.name} | ${b.role} | ${b.status} | ${b.zone} | $${b.cost.toFixed(4)} | ${gt(b.tokens)} | ${oe(b.duration)} |`);c.push("")}const f=new Map;for(const b of t){const _=((v=Zt.get(b.currentZone))==null?void 0:v.label)??b.currentZone;f.set(_,(f.get(_)??0)+1)}if(f.size>0){c.push("## Zone Distribution"),c.push("| Zone | Agents |"),c.push("|------|--------|");for(const[b,_]of Array.from(f.entries()).sort((x,C)=>C[1]-x[1]))c.push(`| ${b} | ${_} |`);c.push("")}return c.push("---"),c.push("*Generated by AgentMove*"),c.join(`
|
|
600
|
+
`)}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 Jh="agent-move:onboarding-dismissed";class D1{constructor(){y(this,"el",null);this.isDismissed()||this.show()}isDismissed(){try{return localStorage.getItem(Jh)==="1"}catch{return!1}}dismiss(){try{localStorage.setItem(Jh,"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=`
|
|
601
|
+
<div class="ob-card">
|
|
602
|
+
<div class="ob-header">
|
|
603
|
+
<span class="ob-logo">AgentMove</span>
|
|
604
|
+
<button class="ob-close">×</button>
|
|
605
|
+
</div>
|
|
606
|
+
<div class="ob-body">
|
|
607
|
+
<p class="ob-desc">Real-time visualization of your Claude Code sessions.</p>
|
|
608
|
+
<div class="ob-features">
|
|
609
|
+
<div class="ob-feature">
|
|
610
|
+
<span class="ob-icon">💻</span>
|
|
611
|
+
<div>
|
|
612
|
+
<strong>Start a Claude Code session</strong>
|
|
613
|
+
<span>Agents appear automatically as they work</span>
|
|
614
|
+
</div>
|
|
615
|
+
</div>
|
|
616
|
+
<div class="ob-feature">
|
|
617
|
+
<span class="ob-icon">⌨</span>
|
|
618
|
+
<div>
|
|
619
|
+
<strong>Press <kbd>?</kbd> for shortcuts</strong>
|
|
620
|
+
<span>Quick keys for all features</span>
|
|
621
|
+
</div>
|
|
622
|
+
</div>
|
|
623
|
+
<div class="ob-feature">
|
|
624
|
+
<span class="ob-icon">🔍</span>
|
|
625
|
+
<div>
|
|
626
|
+
<strong>Press <kbd>Ctrl+K</kbd></strong>
|
|
627
|
+
<span>Command palette to search anything</span>
|
|
628
|
+
</div>
|
|
629
|
+
</div>
|
|
630
|
+
<div class="ob-feature">
|
|
631
|
+
<span class="ob-icon">📊</span>
|
|
632
|
+
<div>
|
|
633
|
+
<strong>Press <kbd>A</kbd> for analytics</strong>
|
|
634
|
+
<span>Live cost tracking and token stats</span>
|
|
635
|
+
</div>
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
</div>
|
|
639
|
+
<button class="ob-dismiss">Got it, let's go!</button>
|
|
640
|
+
</div>
|
|
641
|
+
`,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 ep="agent-move:";function Rr(i,t){try{const e=localStorage.getItem(ep+i);return e===null?t:JSON.parse(e)}catch{return t}}function In(i,t){try{localStorage.setItem(ep+i,JSON.stringify(t))}catch{}}const z1=200,td=5,F1=20,ed=4e3,N1=2;class O1{constructor(){y(this,"container",new Nt);y(this,"graphics",new Ht);y(this,"trails",new Map);y(this,"timers",new Map);y(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<z1)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 d=e-h.x,c=s-h.y;if(d*d+c*c<td*td)return}l.push({x:e,y:s,age:0}),l.length>F1&&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>=ed)n.splice(r,1);else{const l=.4*(1-n[r].age/ed);this.graphics.circle(n[r].x,n[r].y,N1).fill({color:o,alpha:l}),r++}n.length===0&&this.trails.delete(s)}}}}const Qn=200,Jn=150;class G1{constructor(t,e){y(this,"canvas");y(this,"ctx");y(this,"_visible",!1);y(this,"camera");y(this,"scaleX");y(this,"scaleY");this.camera=t,this.scaleX=Qn/Math.max(1,cl),this.scaleY=Jn/Math.max(1,hl),this.canvas=document.createElement("canvas");const s=window.devicePixelRatio||1;this.canvas.width=Qn*s,this.canvas.height=Jn*s,this.canvas.id="minimap",this.canvas.style.cssText=`
|
|
642
|
+
position: fixed; bottom: 12px; right: 12px;
|
|
643
|
+
width: ${Qn}px; height: ${Jn}px;
|
|
644
|
+
border: 1px solid rgba(255,255,255,0.15);
|
|
645
|
+
border-radius: 6px; background: rgba(10,12,20,0.85);
|
|
646
|
+
cursor: crosshair; z-index: 80; display: none;
|
|
647
|
+
box-shadow: 0 2px 12px rgba(0,0,0,0.5);
|
|
648
|
+
`,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,d=l/this.scaleY;e(h,d)})}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=Qn/Math.max(1,cl),this.scaleY=Jn/Math.max(1,hl);const s=this.ctx;s.clearRect(0,0,Qn,Jn),s.imageSmoothingEnabled=!1;for(const h of ne){const d=h.x*this.scaleX,c=h.y*this.scaleY,f=h.width*this.scaleX,g=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(d,c,f,g),s.strokeRect(d,c,f,g),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,d+f/2,c+g/2,f-4),s.restore()}for(const h of t){const d=ft[h.colorIndex%ft.length];s.fillStyle="#"+d.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 W1=["🥇","🥈","🥉"];class H1{constructor(t,e){y(this,"contentEl");y(this,"containerEl");y(this,"isVisible",!1);y(this,"refreshInterval",null);y(this,"sortColumn","tokens");y(this,"sortDir","desc");y(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 Ji(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=`
|
|
649
|
+
<table class="lb-table">
|
|
650
|
+
<thead>
|
|
651
|
+
<tr>
|
|
652
|
+
<th>#</th>
|
|
653
|
+
<th>Agent</th>
|
|
654
|
+
<th class="lb-sortable" data-col="tokens">Tokens</th>
|
|
655
|
+
<th class="lb-sortable" data-col="cost">Cost</th>
|
|
656
|
+
<th class="lb-sortable" data-col="duration">Duration</th>
|
|
657
|
+
<th class="lb-sortable" data-col="tools">Tools</th>
|
|
658
|
+
</tr>
|
|
659
|
+
</thead>
|
|
660
|
+
<tbody>
|
|
661
|
+
${e.map((n,o)=>{var v;const r=(v=this._customizationLookup)==null?void 0:v.call(this,n),l=(r==null?void 0:r.colorIndex)??n.colorIndex,d="#"+ft[l%ft.length].body.toString(16).padStart(6,"0"),c=(r==null?void 0:r.displayName)||n.agentName||n.projectName||n.sessionId.slice(0,10),f=n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens,g=f/s*100;return`<tr>
|
|
662
|
+
<td class="lb-rank">${o<3?W1[o]:`${o+1}`}</td>
|
|
663
|
+
<td class="lb-name"><span class="lb-dot" style="background:${d}"></span>${ct(c)}</td>
|
|
664
|
+
<td>
|
|
665
|
+
<div class="lb-bar-wrap">
|
|
666
|
+
<div class="lb-bar" style="width:${g}%;background:${d}"></div>
|
|
667
|
+
<span class="lb-bar-label">${gt(f)}</span>
|
|
668
|
+
</div>
|
|
669
|
+
</td>
|
|
670
|
+
<td>$${n.cost.toFixed(2)}</td>
|
|
671
|
+
<td>${oe(n.duration)}</td>
|
|
672
|
+
<td>${n.toolUseCount}</td>
|
|
673
|
+
</tr>`}).join("")}
|
|
674
|
+
</tbody>
|
|
675
|
+
</table>
|
|
676
|
+
`,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 Fa="agent-customizations";class U1{constructor(){y(this,"el");y(this,"customizations");y(this,"currentAgent",null);y(this,"onChange",null);this.customizations=Rr(Fa,{}),this.el=document.createElement("div"),this.el.id="agent-customizer",this.el.innerHTML=`
|
|
677
|
+
<div class="ac-backdrop"></div>
|
|
678
|
+
<div class="ac-popover">
|
|
679
|
+
<div class="ac-header">Customize Agent<button class="ac-close">×</button></div>
|
|
680
|
+
<div class="ac-field">
|
|
681
|
+
<label>Display Name</label>
|
|
682
|
+
<input type="text" class="ac-name-input" maxlength="14" placeholder="Custom name..." />
|
|
683
|
+
</div>
|
|
684
|
+
<div class="ac-field">
|
|
685
|
+
<label>Color</label>
|
|
686
|
+
<div class="ac-palette"></div>
|
|
687
|
+
</div>
|
|
688
|
+
<div class="ac-actions">
|
|
689
|
+
<button class="ac-reset">Reset</button>
|
|
690
|
+
<button class="ac-save">Save</button>
|
|
691
|
+
</div>
|
|
692
|
+
</div>
|
|
693
|
+
`,document.body.appendChild(this.el);const t=this.el.querySelector(".ac-palette");ft.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||Ss(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,In(Fa,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],In(Fa,this.customizations),(t=this.onChange)==null||t.call(this,this.currentAgent.id,{}),this.close())}dispose(){this.el.remove()}}const ps=(i,t,e,s,n)=>{i.roundRect(t,e,s,n,4).fill({color:3355460,alpha:.15})},q1=14995640,V1=14469296,j1=14207152,Qo=13154464,Jo=12114072,Y1=11061384,Fe=4,K=i=>i*Fe;function xt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function X1(i,t,e){const s=K(7),n=s/2;xt(i,t-2,e+n-K(2),Fe+1,K(2),9067056),xt(i,t-2,e+n-K(2),2,K(2),8014368),xt(i,t-n+K(2),e-n,s-K(4),K(1),2779690),xt(i,t-n+K(2),e+n-K(1),s-K(4),K(1),2779690),xt(i,t-n,e-n+K(2),K(1),s-K(4),2779690),xt(i,t+n-K(1),e-n+K(2),K(1),s-K(4),2779690),xt(i,t-n+K(1),e-n+K(1),s-K(2),s-K(2),3836474),xt(i,t-n+K(2),e-n+K(2),s-K(4),s-K(4),4893258),xt(i,t-K(2),e-n+K(1),K(3),K(2),6736998),xt(i,t-K(1),e-n,K(2),K(1),8973960)}function Z1(i,t,e){xt(i,t-1,e+K(1),3,K(2),9067056),xt(i,t-K(2),e-K(1),K(4),K(2),2783786),xt(i,t-K(1),e-K(2),K(2),K(4),2783786),xt(i,t-K(2)+Fe,e-K(2)+Fe,K(2),K(2),3836474),xt(i,t-K(1),e-K(1),K(2),K(2),4893258),xt(i,t-Fe,e-K(2),Fe,Fe,6736998)}function K1(i,t,e){xt(i,t-1,e+K(2),3,K(2),6965792),xt(i,t-K(1),e-K(3),K(2),K(5),1731098),xt(i,t-K(2),e-K(2),K(4),K(3),2783786),xt(i,t-K(1),e-K(2),K(2),K(3),3836474),xt(i,t-Fe,e-K(2),Fe,K(2),4889162),xt(i,t-1,e-K(3),3,Fe,5941850)}const sd=[X1,Z1,K1];function tr(i,t,e,s){sd[s%sd.length](i,t,e)}function Q1(i,t,e){xt(i,t-K(2),e-K(1),K(4),K(2),3836474),xt(i,t-K(1),e-K(2),K(2),K(4),3836474),xt(i,t-K(1),e-K(1),K(2),K(2),5941850),xt(i,t,e-K(2),Fe,Fe,6736964)}function J1(i,t,e){xt(i,0,0,t,e,q1);const s=K(12);for(let m=0;m<e;m+=s)for(let v=0;v<t;v+=s)(v/s+m/s)%5===0&&xt(i,v,m,s,s,V1);const n=K(8);xt(i,0,0,t,n,Jo),xt(i,0,e-n,t,n,Jo),xt(i,0,0,n,e,Jo),xt(i,t-n,0,n,e,Jo);const o=K(2);for(let m=0;m<e;m+=K(4))for(let v=0;v<t;v+=K(4))(v<n||v>t-n-o||m<n||m>e-n-o)&&(v*7+m*13)%97<20&&xt(i,v,m,o,o,Y1);let r=0,l=0,h=0,d=0;if(ne.length>0){r=Math.min(...ne.map(v=>v.x)),l=Math.min(...ne.map(v=>v.y)),h=Math.max(...ne.map(v=>v.x+v.width)),d=Math.max(...ne.map(v=>v.y+v.height));const m=12;xt(i,r-m,l-m,h-r+m*2,d-l+m*2,j1),xt(i,r-m,l-m,h-r+m*2,2,Qo),xt(i,r-m,d+m-2,h-r+m*2,2,Qo),xt(i,r-m,l-m,2,d-l+m*2,Qo),xt(i,h+m-2,l-m,2,d-l+m*2,Qo),xt(i,r,l,h-r,d-l,15260872)}const c=K(4),f=K(24);let g=0;for(let m=c;m<t-c;m+=f)tr(i,m,c,g++);for(let m=c+K(12);m<t-c;m+=f)tr(i,m,e-c,g++);for(let m=c+f;m<e-c;m+=f)tr(i,c,m,g++);for(let m=c+K(12);m<e-c;m+=f)tr(i,t-c,m,g++);if(ne.length>0)for(let m=r+K(10);m<h-K(8);m+=K(18))Q1(i,m,d+16)}const sp={id:"office",name:"Office",icon:"🏢",colors:{background:14995640,gridLine:14206124,gridLineSub:13416608},decorators:{search:Ve.search??ps,terminal:Ve.terminal??ps,web:Ve.web??ps,files:Ve.files??ps,thinking:Ve.thinking??ps,messaging:Ve.messaging??ps,spawn:Ve.spawn??ps,idle:Ve.idle??ps,tasks:Ve.tasks??ps},gridRenderer:J1,pixelRooms:!0},tb=4,z=i=>i*tb,yt={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 St(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function fs(i,t,e,s,n){St(i,t,e,s,n,yt.floor);for(let o=0;o<n;o+=z(4))St(i,t,e+o,s,1,yt.floorLine);for(let o=0;o<s;o+=z(8))St(i,t+o,e,1,n,yt.floorLine);for(let o=z(2);o<n;o+=z(8))for(let r=z(2);r<s;r+=z(8))St(i,t+r,e+o,z(1),z(1),yt.floorAlt)}function fn(i,t,e,s){St(i,t,e,s,z(10),yt.panel),St(i,t,e,s,z(1),yt.panelLight),St(i,t+z(2),e+z(2),s-z(4),z(4),yt.screen),St(i,t+z(3),e+z(3),s-z(6),z(1),yt.screenGlow);for(let n=0;n<3;n++)St(i,t+z(2)+n*z(3),e+z(7),z(2),z(2),yt.ledBlue)}function Na(i,t,e){St(i,t-z(3),e,z(6),z(1),yt.metalDark);for(let s=0;s<5;s++){const n=z(8)-s*z(1);St(i,t-n/2,e-z(2)-s*z(2),n,z(1),yt.holo)}St(i,t-z(1),e-z(4),z(2),z(2),yt.holoBright)}const eb={search:(i,t,e,s,n)=>{fs(i,t,e,s,n),fn(i,t+z(4),e+z(7),z(20)),fn(i,t+z(28),e+z(7),z(20)),Na(i,t+s/2,e+n/2)},terminal:(i,t,e,s,n)=>{fs(i,t,e,s,n);for(let o=0;o<3;o++){St(i,t+z(2)+o*z(10),e+z(7),z(7),z(14),yt.hull);for(let r=0;r<4;r++)St(i,t+z(3)+o*z(10),e+z(8)+r*z(3),z(5),z(2),yt.panelDark),St(i,t+z(4)+o*z(10),e+z(9)+r*z(3),z(1),z(1),r<3?yt.led:yt.ledOff)}},web:(i,t,e,s,n)=>{fs(i,t,e,s,n),St(i,t+z(4),e+z(7),z(20),z(14),yt.panelDark),St(i,t+z(5),e+z(8),z(18),z(12),yt.screen),St(i,t+z(8),e+z(11),z(12),z(6),yt.holo),Na(i,t+z(40),e+z(30))},files:(i,t,e,s,n)=>{fs(i,t,e,s,n);for(let o=0;o<4;o++)St(i,t+z(2)+o*z(7),e+z(7),z(5),z(10),yt.metalDark),St(i,t+z(3)+o*z(7),e+z(8),z(3),z(3),yt.metal),St(i,t+z(3)+o*z(7),e+z(12),z(3),z(3),yt.metal);fn(i,t+z(24),e+z(25),z(14))},thinking:(i,t,e,s,n)=>{fs(i,t,e,s,n),Na(i,t+s/2,e+n/2),St(i,t+s/2-z(9),e+n/2+z(2),z(18),z(1),yt.metalDark),fn(i,t+z(4),e+z(7),z(24)),fn(i,t+z(32),e+z(7),z(20))},messaging:(i,t,e,s,n)=>{fs(i,t,e,s,n),St(i,t+z(4),e+z(21),z(16),z(8),yt.hull),St(i,t+z(5),e+z(22),z(14),z(6),yt.hullLight),fn(i,t+z(4),e+z(7),z(14))},spawn:(i,t,e,s,n)=>{fs(i,t,e,s,n);const o=t+s/2,r=e+n/2;St(i,o-z(6),r-z(6),z(12),z(12),yt.panelDark),St(i,o-z(4),r-z(4),z(8),z(8),yt.holo),St(i,o-z(2),r-z(2),z(4),z(4),yt.holoBright),St(i,o-z(8),r-z(1),z(16),z(2),yt.airlockEdge),St(i,o-z(1),r-z(8),z(2),z(16),yt.airlockEdge)},idle:(i,t,e,s,n)=>{fs(i,t,e,s,n),St(i,t+z(2),e+z(7),z(28),z(5),yt.hull),St(i,t+z(3),e+z(8),z(26),z(3),yt.hullLight),St(i,t+z(4),e+z(9),z(2),z(1),yt.screenGlow),St(i,t+z(32),e+z(7),z(6),z(14),yt.metalDark);for(let o=0;o<3;o++)St(i,t+z(33),e+z(8)+o*z(4),z(4),z(3),yt.screen)},tasks:(i,t,e,s,n)=>{fs(i,t,e,s,n),St(i,t+z(2),e+z(7),z(30),z(18),yt.panel),St(i,t+z(3),e+z(8),z(28),z(16),yt.screen);const o=[yt.ledRed,yt.led,yt.ledBlue];for(let r=0;r<3;r++){const l=z(8),h=t+z(4)+r*(l+z(1));St(i,h,e+z(9),l,z(2),o[r]);for(let d=0;d<3-r;d++)St(i,h+2,e+z(12)+d*z(3),l-4,z(2),yt.holo)}}},sb={id:"space",name:"Space Station",icon:"🚀",colors:{background:657944,gridLine:1381672,gridLineSub:1052704},decorators:eb},ib=4,B=i=>i*ib,Pt={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 Lt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function ms(i,t,e,s,n){Lt(i,t,e,s,n,Pt.stone);for(let o=0;o<n;o+=B(5)){Lt(i,t,e+o,s,1,Pt.mortar);const r=o/B(5)%2*B(6);for(let l=r;l<s;l+=B(12))Lt(i,t+l,e+o,1,B(5),Pt.mortar)}for(let o=B(2);o<n;o+=B(10))for(let r=B(3);r<s;r+=B(12))Lt(i,t+r,e+o,B(1),B(1),Pt.stoneLight)}function Pe(i,t,e){Lt(i,t,e+B(3),B(1),B(4),Pt.torchHandle),Lt(i,t-1,e+B(1),B(1)+2,B(2),Pt.torch),Lt(i,t,e,B(1),B(1),Pt.torchGlow)}function er(i,t,e,s,n){Lt(i,t,e,s,B(1),Pt.woodDark),Lt(i,t+1,e+B(1),s-2,n,Pt.banner),Lt(i,t+1,e+B(1),s-2,B(1),Pt.bannerEdge),Lt(i,t+s/2-B(1),e+n/2,B(2),B(2),Pt.torchGlow)}function vi(i,t,e,s,n){Lt(i,t,e,s,n,Pt.woodDark),Lt(i,t+1,e+1,s-2,n-2,Pt.wood),Lt(i,t+2,e+2,s-4,1,Pt.woodLight)}const nb={search:(i,t,e,s,n)=>{ms(i,t,e,s,n);for(let o=0;o<4;o++)Lt(i,t+B(2)+o*B(16),e+B(7),B(10),B(14),Pt.woodDark),Lt(i,t+B(3)+o*B(16),e+B(8),B(8),B(12),Pt.wood);Pe(i,t+B(14),e+B(8)),Pe(i,t+B(30),e+B(8)),vi(i,t+B(18),e+B(35),B(12),B(6)),Lt(i,t+B(20),e+B(36),B(6),B(3),Pt.scroll)},terminal:(i,t,e,s,n)=>{ms(i,t,e,s,n);for(let o=0;o<3;o++)Lt(i,t+B(2)+o*B(10),e+B(7),B(7),B(14),Pt.stoneDark),Lt(i,t+B(3)+o*B(10),e+B(9),B(5),B(1),Pt.torch);Pe(i,t+B(34),e+B(9)),er(i,t+B(4),e+B(28),B(8),B(12))},web:(i,t,e,s,n)=>{ms(i,t,e,s,n),Lt(i,t+B(4),e+B(7),B(20),B(14),Pt.stoneDark),Lt(i,t+B(5),e+B(8),B(18),B(12),Pt.stoneLight),Lt(i,t+B(8),e+B(11),B(12),B(6),Pt.torchGlow),Pe(i,t+B(28),e+B(10)),vi(i,t+B(4),e+B(27),B(14),B(5))},files:(i,t,e,s,n)=>{ms(i,t,e,s,n);for(let o=0;o<4;o++)Lt(i,t+B(2)+o*B(7),e+B(7),B(5),B(10),Pt.woodDark);vi(i,t+B(24),e+B(25),B(14),B(6)),Lt(i,t+B(26),e+B(26),B(6),B(3),Pt.scroll),Pe(i,t+B(40),e+B(9))},thinking:(i,t,e,s,n)=>{ms(i,t,e,s,n),Lt(i,t+B(8),e+n/2-B(8),B(10),B(4),Pt.rugEdge),vi(i,t+s/2-B(9),e+n/2-B(4),B(18),B(8)),er(i,t+B(4),e+B(7),B(10),B(14)),er(i,t+B(34),e+B(7),B(10),B(14)),Pe(i,t+B(18),e+B(8)),Pe(i,t+B(28),e+B(8))},messaging:(i,t,e,s,n)=>{ms(i,t,e,s,n),er(i,t+B(8),e+B(7),B(14),B(10)),vi(i,t+B(6),e+B(33),B(12),B(5)),Pe(i,t+B(4),e+B(10)),Pe(i,t+B(26),e+B(10))},spawn:(i,t,e,s,n)=>{ms(i,t,e,s,n);const o=t+s/2,r=e+n/2;Lt(i,o-B(4),r-B(4),B(8),B(8),Pt.mortar),Lt(i,o-B(3),r-B(3),B(6),B(6),Pt.torchGlow),Lt(i,o-B(1),r-B(1),B(2),B(2),Pt.torch),Pe(i,t+B(2),e+B(12)),Pe(i,t+s-B(4),e+B(12))},idle:(i,t,e,s,n)=>{ms(i,t,e,s,n),vi(i,t+B(2),e+B(7),B(28),B(5)),Lt(i,t+B(4),e+B(8),B(4),B(3),Pt.woodLight),vi(i,t+B(14),e+B(30),B(10),B(10)),vi(i,t+B(40),e+B(30),B(10),B(10)),Pe(i,t+B(50),e+B(8))},tasks:(i,t,e,s,n)=>{ms(i,t,e,s,n),Lt(i,t+B(2),e+B(7),B(30),B(18),Pt.woodDark),Lt(i,t+B(3),e+B(8),B(28),B(16),Pt.wood);for(let o=0;o<3;o++)for(let r=0;r<3-o;r++)Lt(i,t+B(4)+o*B(9)+2,e+B(12)+r*B(3),B(7),B(2),Pt.scroll);Pe(i,t+B(36),e+B(9))}},ob={id:"castle",name:"Medieval Castle",icon:"🏰",colors:{background:1710096,gridLine:2762784,gridLineSub:2104856},decorators:nb},rb=4,U=i=>i*rb,mt={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 At(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function gs(i,t,e,s,n){At(i,t,e,s,n,mt.floor);for(let o=0;o<n;o+=U(6))At(i,t,e+o,s,1,mt.floorLine),o/U(6)%2===0&&At(i,t,e+o+U(3),s,U(3),mt.floorAlt);At(i,t,e,s,1,mt.neonPink),At(i,t,e+n-1,s,1,mt.neonBlue)}function yi(i,t,e,s,n,o){At(i,t,e,s,n,mt.darkPanel),At(i,t+1,e+1,s-2,n-2,mt.screen),At(i,t+2,e+2,s-4,U(1),o),At(i,t,e,s,1,o),At(i,t,e+n-1,s,1,o)}function to(i,t,e,s,n){At(i,t,e,s,U(1),n),At(i,t+U(1),e-1,s-U(2),1,n)}function vs(i,t,e,s,n){for(let o=0;o<12;o++){const r=t+(o*37+11)%(s-U(1)),l=e+(o*53+7)%(n-U(4));At(i,r,l,1,U(2),mt.rain)}}const ab={search:(i,t,e,s,n)=>{gs(i,t,e,s,n),yi(i,t+U(4),e+U(7),U(20),U(12),mt.neonPink),yi(i,t+U(28),e+U(7),U(20),U(12),mt.neonBlue),to(i,t+U(4),e+U(26),U(44),mt.neonPurple),vs(i,t,e,s,n)},terminal:(i,t,e,s,n)=>{gs(i,t,e,s,n);for(let o=0;o<3;o++){At(i,t+U(2)+o*U(10),e+U(7),U(7),U(14),mt.darkPanel),At(i,t+U(3)+o*U(10),e+U(9),U(5),U(1),mt.neonGreen);for(let r=0;r<3;r++)At(i,t+U(4)+o*U(10),e+U(11)+r*U(2),U(1),U(1),mt.neonGreen)}vs(i,t,e,s,n)},web:(i,t,e,s,n)=>{gs(i,t,e,s,n),yi(i,t+U(4),e+U(7),U(24),U(16),mt.neonBlue),At(i,t+U(8),e+U(12),U(16),U(8),mt.neonPurple),to(i,t+U(30),e+U(20),U(10),mt.neonPink),vs(i,t,e,s,n)},files:(i,t,e,s,n)=>{gs(i,t,e,s,n);for(let o=0;o<4;o++)At(i,t+U(2)+o*U(7),e+U(7),U(5),U(10),mt.darkPanel),At(i,t+U(2)+o*U(7),e+U(7),U(5),1,mt.neonBlue);yi(i,t+U(24),e+U(25),U(14),U(8),mt.neonGreen),vs(i,t,e,s,n)},thinking:(i,t,e,s,n)=>{gs(i,t,e,s,n),yi(i,t+U(4),e+U(7),U(24),U(12),mt.neonPurple),yi(i,t+U(32),e+U(7),U(20),U(12),mt.neonBlue),At(i,t+s/2-U(8),e+n/2+U(2),U(16),U(1),mt.panelEdge),to(i,t+U(4),e+n-U(4),U(40),mt.neonPink),vs(i,t,e,s,n)},messaging:(i,t,e,s,n)=>{gs(i,t,e,s,n),At(i,t+U(4),e+U(21),U(16),U(8),mt.darkPanel),At(i,t+U(5),e+U(22),U(14),U(1),mt.neonPink),yi(i,t+U(4),e+U(7),U(14),U(8),mt.neonYellow),to(i,t+U(22),e+U(18),U(8),mt.neonGreen),vs(i,t,e,s,n)},spawn:(i,t,e,s,n)=>{gs(i,t,e,s,n);const o=t+s/2,r=e+n/2;for(let l=0;l<3;l++){const h=U(3)+l*U(3);At(i,o-h,r-h,h*2,1,mt.neonPurple),At(i,o-h,r+h,h*2,1,mt.neonPurple),At(i,o-h,r-h,1,h*2,mt.neonBlue),At(i,o+h,r-h,1,h*2,mt.neonBlue)}At(i,o-U(1),r-U(1),U(2),U(2),mt.neonGreen),vs(i,t,e,s,n)},idle:(i,t,e,s,n)=>{gs(i,t,e,s,n),At(i,t+U(2),e+U(7),U(28),U(5),mt.darkPanel),At(i,t+U(2),e+U(7),U(28),1,mt.neonPink),to(i,t+U(34),e+U(12),U(12),mt.neonBlue),At(i,t+U(34),e+U(7),U(8),U(14),mt.darkPanel),At(i,t+U(35),e+U(8),U(6),U(4),mt.screen),At(i,t+U(36),e+U(9),U(4),U(1),mt.neonGreen),vs(i,t,e,s,n)},tasks:(i,t,e,s,n)=>{gs(i,t,e,s,n),yi(i,t+U(2),e+U(7),U(30),U(18),mt.neonGreen);const o=[mt.neonPink,mt.neonYellow,mt.neonBlue];for(let r=0;r<3;r++){const l=U(8),h=t+U(4)+r*(l+U(1));At(i,h,e+U(9),l,U(2),o[r]);for(let d=0;d<3-r;d++)At(i,h+2,e+U(12)+d*U(3),l-4,U(2),mt.panel)}vs(i,t,e,s,n)}},lb={id:"cyberpunk",name:"Cyberpunk",icon:"🌃",colors:{background:657424,gridLine:1708072,gridLineSub:1051162},decorators:ab},id="theme",eo=[sp,sb,ob,lb];class cb{constructor(){y(this,"_current");y(this,"_onChange",null);const t=Rr(id,"office");this._current=eo.find(e=>e.id===t)??sp}get current(){return this._current}setTheme(t){var s;const e=eo.find(n=>n.id===t);!e||e.id===this._current.id||(this._current=e,In(id,e.id),(s=this._onChange)==null||s.call(this,e))}onChange(t){this._onChange=t}cycleNext(){const t=eo.indexOf(this._current),e=eo[(t+1)%eo.length];this.setTheme(e.id)}}const nd="zone-annotations";let Oa=0;class hb{constructor(){y(this,"container");y(this,"annotations",new Map);y(this,"noteEls",new Map);y(this,"visible",!0);y(this,"rootX",0);y(this,"rootY",0);y(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(nd);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>=Oa&&(Oa=n+1)}}}catch{}}save(){localStorage.setItem(nd,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">×</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=Zt.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=Zt.get(e.zoneId);if(!l)return;const h=f=>{f.target.classList.contains("za-delete")||(f.stopPropagation(),s=f.clientX,n=f.clientY,o=e.relX,r=e.relY,t.setPointerCapture(f.pointerId),t.addEventListener("pointermove",d),t.addEventListener("pointerup",c,{once:!0}))},d=f=>{const g=(f.clientX-s)/this.scale,m=(f.clientY-n)/this.scale;e.relX=Math.max(.05,Math.min(.95,o+g/l.width)),e.relY=Math.max(.05,Math.min(.95,r+m/l.height)),this.positionNote(e,t)},c=()=>{t.removeEventListener("pointermove",d),this.save()};t.addEventListener("pointerdown",h)}addAnnotationAtWorld(t,e){for(const s of ne){const n=Zt.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=Zt.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,d=document.createElement("textarea");d.className="zone-annotation za-input",d.style.cssText=`position:absolute;pointer-events:auto;transform:translate(${l}px,${h}px);z-index:20;`,d.placeholder="Type a note...",d.rows=2,this.container.appendChild(d),d.focus();const c=()=>{const f=d.value.trim();if(d.remove(),f){const g=`ann-${Oa++}`,m={id:g,text:f,relX:e,relY:s,zoneId:t};this.annotations.set(g,m),this.createNoteEl(m),this.save()}};d.addEventListener("blur",c,{once:!0}),d.addEventListener("keydown",f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),d.blur()),f.key==="Escape"&&(d.value="",d.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,"&").replace(/</g,"<").replace(/>/g,">")}}class db{constructor(t,e){y(this,"container");y(this,"data",null);y(this,"visible",!1);y(this,"selectedTool",null);y(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 _;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(x=>x.count)),l=Object.entries(e).sort((x,C)=>C[1]-x[1]),h=((_=l[0])==null?void 0:_[1])??1,d=l.reduce((x,[,C])=>x+C,0),c=this.selectedTool?t.filter(x=>x.from===this.selectedTool||x.to===this.selectedTool):t,f=Math.max(...c.map(x=>x.count),1),g=Object.keys(s??{}).length>0||Object.keys(n??{}).length>0;let m="";m+=`<div class="tc-section"><div class="tc-section-title">Tool Usage <span class="tc-hint">(${d} total calls)</span></div>`,g&&(m+='<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>'),m+='<div class="tc-tools">';for(const[x,C]of l){const $=C/h*100,P=x===this.selectedTool,H=(s==null?void 0:s[x])??0,R=(n==null?void 0:n[x])??0,O=H+R,et=O>0?R/O:0,Z=o==null?void 0:o[x];if(m+=`<div class="tc-tool-row ${P?"tc-selected":""}" data-tool="${this.esc(x)}">`,m+=`<span class="tc-tool-name">${this.esc(this.shortName(x))}</span>`,m+='<div class="tc-tool-bar-wrap">',m+=`<div class="tc-tool-bar" style="width:${$}%"></div>`,R>0){const X=O>0?R/O*$:0;m+=`<div class="tc-tool-bar tc-fail-bar" style="width:${X}%"></div>`}m+="</div>",m+=`<span class="tc-tool-count">${C}</span>`,g&&O>0&&et>0?m+=`<span class="tc-outcome tc-outcome-fail" title="${R} failed">${Math.round(et*100)}%</span>`:g&&O>0?m+=`<span class="tc-outcome tc-outcome-ok" title="${H} succeeded">✓</span>`:g&&(m+='<span class="tc-outcome"></span>'),g&&(m+=`<span class="tc-duration" title="avg per call">${Z!==void 0?this.fmtMs(Z):"—"}</span>`),m+="</div>"}m+="</div></div>",m+='<div class="tc-section"><div class="tc-section-title">',m+=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>',m+="</div>",m+='<div class="tc-transitions">';const v=[...c].sort((x,C)=>C.count-x.count).slice(0,20);for(const x of v){const C=x.count/f*100,$=x.count/r,P=Math.round(100+$*155),H=Math.round(130+$*40),R=Math.round(180-$*100);m+='<div class="tc-transition-row">',m+=`<span class="tc-t-from">${this.esc(this.shortName(x.from))}</span>`,m+='<span class="tc-t-arrow">→</span>',m+=`<span class="tc-t-to">${this.esc(this.shortName(x.to))}</span>`,m+=`<div class="tc-t-bar-wrap"><div class="tc-t-bar" style="width:${C}%;background:rgb(${P},${H},${R})"></div></div>`,m+=`<span class="tc-t-count">${x.count}×</span>`,m+="</div>"}v.length===0&&(m+='<div class="tc-empty" style="padding:12px">No transitions for this tool</div>'),m+="</div></div>",this.container.innerHTML=m,this.container.querySelectorAll(".tc-tool-row").forEach(x=>{x.addEventListener("click",()=>{const C=x.dataset.tool;this.selectedTool=this.selectedTool===C?null:C,this.render()})});const b=this.container.querySelector(".tc-clear-filter");b&&b.addEventListener("click",x=>{x.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}}const sr={pending:"#a78bfa",in_progress:"#38bdf8",completed:"#4ade80",deleted:"#f87171"},ir={pending:"○",in_progress:"◔",completed:"✓",deleted:"✕"},bi=210,so=56,ub=50,io=12,nr=16;class pb{constructor(t,e){y(this,"container");y(this,"data",null);y(this,"visible",!1);y(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(c=>c.status!=="deleted");if(t.length===0){this.container.innerHTML='<div class="tg-empty">No tasks created yet</div>';return}const e=c=>c._rootKey??c.id,s=new Map(t.map(c=>[e(c),c])),n=new Set;for(const c of t){const f=c.blockedBy.some(m=>s.has(m)),g=c.blocks.some(m=>s.has(m));if(f||g){n.add(e(c));for(const m of c.blockedBy)s.has(m)&&n.add(m);for(const m of c.blocks)s.has(m)&&n.add(m)}}const o=t.filter(c=>!n.has(e(c))),r=t.filter(c=>n.has(e(c))),l={in_progress:0,pending:1,completed:2,deleted:3};o.sort((c,f)=>{const g=(l[c.status]??9)-(l[f.status]??9);return g!==0?g:parseInt(c.id)-parseInt(f.id)});const h={pending:0,in_progress:0,completed:0};for(const c of t)c.status in h&&h[c.status]++;let d="";if(d+='<div class="tg-summary">',h.in_progress>0&&(d+=`<span class="tg-badge tg-badge-active">${h.in_progress} active</span>`),h.pending>0&&(d+=`<span class="tg-badge tg-badge-pending">${h.pending} pending</span>`),h.completed>0&&(d+=`<span class="tg-badge tg-badge-done">${h.completed} done</span>`),d+=`<span class="tg-total">${t.length} total</span>`,d+="</div>",o.length>0){d+='<div class="tg-standalone">';for(const c of o){const f=sr[c.status]??sr.pending,g=ir[c.status]??ir.pending;d+=`<div class="tg-row" style="--sc:${f}">`,d+=`<span class="tg-row-icon" style="color:${f}">${g}</span>`,d+=`<span class="tg-row-subj">${wi(c.subject)}</span>`,d+=this.renderRowTags(c),d+=`<span class="tg-row-id">#${wi(c.id)}</span>`,d+="</div>"}d+="</div>"}if(r.length>0){const c=this.findClusters(r,s,e);for(const f of c)d+=this.renderCluster(f,s,e)}this.container.innerHTML=d}renderCluster(t,e,s){const n=new Map(t.map(c=>[s(c),c])),o=this.layoutCluster(t,n,s),r=new Map(o.map(c=>[s(c.task),c])),l=Math.max(...o.map(c=>c.x+bi))+nr,h=Math.max(...o.map(c=>c.y+so))+nr;let d='<div class="tg-cluster">';d+=`<svg class="tg-svg" width="${l}" height="${h}" viewBox="0 0 ${l} ${h}">`,d+='<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 c of o)for(const f of c.task.blockedBy){const g=r.get(f);if(!g)continue;const m=g.x+bi/2,v=g.y+so,b=c.x+bi/2,_=c.y,x=Math.max((_-v)*.4,12);d+=`<path class="tg-edge" d="M${m},${v} C${m},${v+x} ${b},${_-x} ${b},${_}" marker-end="url(#tg-arr)"/>`}for(const c of o){const f=c.task,g=sr[f.status]??sr.pending,m=ir[f.status]??ir.pending;d+='<g class="tg-node">',d+=`<rect x="${c.x}" y="${c.y}" width="${bi}" height="${so}" rx="5" class="tg-node-bg"/>`,d+=`<rect x="${c.x}" y="${c.y}" width="3" height="${so}" rx="1" fill="${g}"/>`,d+=`<text x="${c.x+12}" y="${c.y+18}" class="tg-node-icon" fill="${g}">${m}</text>`,d+=`<text x="${c.x+bi-7}" y="${c.y+16}" class="tg-node-id" text-anchor="end">#${wi(f.id)}</text>`,d+=`<text x="${c.x+25}" y="${c.y+18}" class="tg-node-subj">${wi(rd(f.subject,24))}</text>`;const v=this.nodeInfoText(f);v&&(d+=`<text x="${c.x+12}" y="${c.y+38}" class="tg-node-info">${wi(rd(v,28))}</text>`),d+="</g>"}return d+="</svg></div>",d}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 d=[],c=[h];for(o.add(h);c.length>0;){const f=c.shift(),g=e.get(f);if(g){d.push(g);for(const m of[...g.blockedBy,...g.blocks])n.has(m)&&!o.has(m)&&(o.add(m),c.push(m))}}r.push(d)}return r}layoutCluster(t,e,s){const n=new Map,o=(g,m)=>{if(n.has(g))return n.get(g);if(m.has(g))return 0;m.add(g);const v=e.get(g);if(!v||v.blockedBy.filter(x=>e.has(x)).length===0)return n.set(g,0),0;let b=0;for(const x of v.blockedBy)e.has(x)&&(b=Math.max(b,o(x,m)));const _=b+1;return n.set(g,_),_};for(const g of t)o(s(g),new Set);const r=Math.max(0,...n.values()),l=Array.from({length:r+1},()=>[]);for(const g of t)l[n.get(s(g))??0].push(g);const h={in_progress:0,pending:1,completed:2,deleted:3};for(const g of l)g.sort((m,v)=>{const b=(h[m.status]??9)-(h[v.status]??9);return b!==0?b:parseInt(m.id)-parseInt(v.id)});for(let g=1;g<l.length;g++){const m=new Map;l[g-1].forEach((v,b)=>m.set(s(v),b)),l[g].sort((v,b)=>od(v,m)-od(b,m))}const c=Math.max(...l.map(g=>g.length))*(bi+io)-io,f=[];for(let g=0;g<l.length;g++){const m=l[g],v=m.length*(bi+io)-io,b=nr+(c-v)/2,_=nr+g*(so+ub);for(let x=0;x<m.length;x++)f.push({task:m[x],x:b+x*(bi+io),y:_})}return f}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">${wi(t.projectName)}</span>`),t.agentName&&t.agentName!==t.projectName&&(e+=`<span class="tg-row-tag">${wi(t.agentName)}</span>`),t.owner&&t.owner!==t.agentName&&(e+=`<span class="tg-row-tag">${wi(t.owner)}</span>`),e}}function od(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 wi(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function rd(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class fb{constructor(t){y(this,"container");y(this,"store");y(this,"permissions",[]);y(this,"onPermRequestBound");y(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">
|
|
694
|
+
<span class="perm-badge">${this.permissions.length}</span>
|
|
695
|
+
Permission Request${this.permissions.length>1?"s":""}
|
|
696
|
+
</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(d=>d.permissionId===o),h=(l==null?void 0:l.permissionSuggestions)??[];this.store.approvePermissionAlways(o,h)}})})}esc(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}dispose(){this.store.off("permission:request",this.onPermRequestBound),this.store.off("permission:resolved",this.onPermResolvedBound),this.container.remove()}}const mb=50;let gb=0;class vb{constructor(t){y(this,"container");y(this,"store");y(this,"_customizationLookup",null);y(this,"notifications",[]);y(this,"visible",!1);y(this,"badgeEl");y(this,"onPermRequestBound");y(this,"onAnomalyBound");y(this,"onTaskBound");y(this,"onSpawnBound");y(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${++gb}`,...t,timestamp:Date.now()};this.notifications.unshift(e),this.notifications.length>mb&&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,"&").replace(/</g,"<").replace(/>/g,">")}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 ad=200,yb=["all","spawn","tool","idle","shutdown","permission","anomaly","task"],bb=200;class wb{constructor(t,e){y(this,"container");y(this,"toolbarEl");y(this,"searchInput");y(this,"filtersEl");y(this,"agentSelect");y(this,"clearBtn");y(this,"listEl");y(this,"store");y(this,"entries",[]);y(this,"visible",!1);y(this,"autoScroll",!0);y(this,"_customizationLookup",null);y(this,"searchQuery","");y(this,"activeKind","all");y(this,"activeAgent","");y(this,"debounceTimer",null);y(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 yb){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>ad&&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>ad;)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()},bb)}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,"&").replace(/</g,"<").replace(/>/g,">")}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 ld={files:"#34d399",terminal:"#fb923c",search:"#60a5fa",web:"#f59e0b",thinking:"#a78bfa",messaging:"#38bdf8",tasks:"#f472b6",idle:"#6b7280",spawn:"#6b7280"},cd=500,ys=28,no=2,ze=32,me=120,_b=300*1e3,xb=1e4,Sb=30*6e4;class Tb{constructor(t,e){y(this,"container");y(this,"canvas");y(this,"ctx");y(this,"tooltip");y(this,"visible",!1);y(this,"spans",[]);y(this,"agentLanes",[]);y(this,"agentNames",new Map);y(this,"agentCurrentTool",new Map);y(this,"_customizationLookup",null);y(this,"viewEndTime",Date.now());y(this,"viewWindowMs",_b);y(this,"autoScroll",!0);y(this,"animFrame",null);y(this,"resizeObserver",null);y(this,"onSpawn");y(this,"onUpdate");y(this,"onIdle");y(this,"onShutdown");y(this,"onReset");y(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)}
|
|
697
|
+
`;n+=`Duration: ${this.fmtDuration(s)}
|
|
698
|
+
`,n+=`Zone: ${e.zone}`,e.outcome&&(n+=`
|
|
699
|
+
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"});y(this,"handleMouseLeave",()=>{this.tooltip.style.display="none",this.canvas.style.cursor="crosshair"});y(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}
|
|
700
|
+
`;n+=`Agent: ${e.agentName}
|
|
701
|
+
`,n+=`Zone: ${e.zone}
|
|
702
|
+
`,n+=`Duration: ${this.fmtDuration(s)}
|
|
703
|
+
`,n+=`Start: ${new Date(e.startTime).toLocaleTimeString()}
|
|
704
|
+
`,e.endTime?n+=`End: ${new Date(e.endTime).toLocaleTimeString()}
|
|
705
|
+
`:n+=`Status: In progress
|
|
706
|
+
`,e.outcome&&(n+=`Outcome: ${e.outcome}
|
|
707
|
+
`),e.toolInput&&(n+=`
|
|
708
|
+
Input:
|
|
709
|
+
${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`}});y(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(xb,Math.min(Sb,this.viewWindowMs*n)),r=this.container.clientWidth-me,l=Math.max(0,(s-me)/r),d=this.viewEndTime-this.viewWindowMs+l*this.viewWindowMs;this.viewWindowMs=o,this.viewEndTime=d+(1-l)*o,this.autoScroll=!1}else{const n=t.deltaX/(this.container.clientWidth-me)*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>cd&&this.spans.splice(0,this.spans.length-cd)}updateCanvasSize(){const t=this.container.clientWidth,e=Math.max(this.agentLanes.length,1),s=ze+e*(ys+no)+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=ze+s*(ys+no)+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-me;t.fillStyle="#111827",t.fillRect(0,0,e,n),t.fillStyle="#1f2937",t.fillRect(0,0,e,ze),t.strokeStyle="#374151",t.lineWidth=1,t.beginPath(),t.moveTo(0,ze),t.lineTo(e,ze),t.stroke();const l=this.pickGridInterval(),h=Math.ceil(o/l)*l;t.font="10px monospace",t.textAlign="center",t.textBaseline="middle";for(let d=h;d<=this.viewEndTime;d+=l){const c=me+(d-o)/this.viewWindowMs*r;t.strokeStyle="#1f2937",t.beginPath(),t.moveTo(c,ze),t.lineTo(c,n),t.stroke(),t.fillStyle="#9ca3af",t.fillText(this.formatTime(d),c,ze/2)}t.textAlign="right",t.textBaseline="middle",t.font="11px sans-serif";for(let d=0;d<this.agentLanes.length;d++){const c=this.agentLanes[d],f=this.agentNames.get(c)??c.slice(0,8),g=ze+d*(ys+no);t.fillStyle=d%2===0?"#111827":"#0f172a",t.fillRect(0,g,e,ys);const m=this.store.getAgent(c),v=m?ft[m.colorIndex%ft.length]:null;t.fillStyle=v?`#${v.body.toString(16).padStart(6,"0")}`:"#9ca3af";const b=f.length>14?f.slice(0,12)+"..":f;t.fillText(b,me-8,g+ys/2)}t.strokeStyle="#374151",t.beginPath(),t.moveTo(me,0),t.lineTo(me,n),t.stroke();for(const d of this.spans){const c=d.endTime??Date.now();if(c<o||d.startTime>this.viewEndTime)continue;const f=this.agentLanes.indexOf(d.agentId);if(f<0)continue;const g=Math.max(d.startTime,o),m=Math.min(c,this.viewEndTime),v=me+(g-o)/this.viewWindowMs*r,b=me+(m-o)/this.viewWindowMs*r,_=Math.max(b-v,2),x=ze+f*(ys+no)+3,C=ys-6,$=ld[d.zone]??ld.thinking;if(t.fillStyle=$,t.globalAlpha=d.endTime===null?.7:.85,t.beginPath(),this.roundRect(t,v,x,_,C,3),t.fill(),t.globalAlpha=1,d.outcome&&(t.strokeStyle=d.outcome==="success"?"#22c55e":"#ef4444",t.lineWidth=1.5,t.beginPath(),this.roundRect(t,v,x,_,C,3),t.stroke()),d.endTime===null){const P=.4+.6*Math.abs(Math.sin(Date.now()/600));t.strokeStyle=`rgba(255,255,255,${P*.5})`,t.lineWidth=1,t.beginPath(),this.roundRect(t,v,x,_,C,3),t.stroke()}if(_>40){t.fillStyle="#ffffff",t.font="9px monospace",t.textAlign="left",t.textBaseline="middle";const P=this.shortToolName(d.toolName),H=Math.floor((_-6)/5.5),R=P.length>H?P.slice(0,H-1)+"..":P;t.fillText(R,v+4,x+C/2)}}if(this.autoScroll){const d=me+r;t.strokeStyle="#ef4444",t.lineWidth=1,t.setLineDash([3,3]),t.beginPath(),t.moveTo(d,ze),t.lineTo(d,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-me,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<me||o<ze)return null;const r=this.viewEndTime-this.viewWindowMs,l=this.container.clientWidth-me;for(let h=this.spans.length-1;h>=0;h--){const d=this.spans[h],c=d.endTime??Date.now();if(c<r||d.startTime>this.viewEndTime)continue;const f=this.agentLanes.indexOf(d.agentId);if(f<0)continue;const g=Math.max(d.startTime,r),m=Math.min(c,this.viewEndTime),v=me+(g-r)/this.viewWindowMs*l,b=me+(m-r)/this.viewWindowMs*l,_=Math.max(b-v,2),x=ze+f*(ys+no)+3,C=ys-6;if(n>=v&&n<=v+_&&o>=x&&o<=x+C)return d}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 _i=20,kb=25,Cb=120,Ab=4e3,Eb=.005,hd=.9,Ga=3,dd=.01,ud={running:"#4caf50",idle:"#9e9e9e",compacting:"#9c27b0"},Mb={main:"MAIN",subagent:"SUB","team-lead":"LEAD"};function Ib(i){return"#"+i.toString(16).padStart(6,"0")}function Pb(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class Lb{constructor(t,e){y(this,"container");y(this,"canvas");y(this,"ctx");y(this,"nodes",new Map);y(this,"edges",[]);y(this,"animFrame",null);y(this,"visible",!1);y(this,"messageAnimT",0);y(this,"store");y(this,"_customizationLookup",null);y(this,"listeners",[]);y(this,"onClick",t=>{const e=this.canvas.getBoundingClientRect(),s=t.clientX-e.left,n=t.clientY-e.top;let o=null,r=kb;for(const l of this.nodes.values()){const h=l.x-s,d=l.y-n,c=Math.sqrt(h*h+d*d);c<r&&(r=c,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 d=t[l],c=t[h],f=c.x-d.x,g=c.y-d.y,m=Math.sqrt(f*f+g*g)||1,v=Ab/(m*m),b=f/m*v,_=g/m*v;d.vx-=b,d.vy-=_,c.vx+=b,c.vy+=_}const r=new Set;for(const l of this.edges){const h=this.nodes.get(l.source),d=this.nodes.get(l.target);if(!h||!d)continue;r.add(l.source),r.add(l.target);const c=d.x-h.x,f=d.y-h.y,g=Math.sqrt(c*c+f*f)||1,m=g-Cb,v=Eb*m,b=c/g*v,_=f/g*v;h.vx+=b,h.vy+=_,d.vx-=b,d.vy-=_}for(const l of t)l.vx+=(n-l.x)*dd,l.vy+=(o-l.y)*dd;for(const l of t){l.vx*=hd,l.vy*=hd;const h=Math.sqrt(l.vx*l.vx+l.vy*l.vy);h>Ga&&(l.vx=l.vx/h*Ga,l.vy=l.vy/h*Ga),l.x+=l.vx,l.y+=l.vy,l.x=Math.max(_i,Math.min(e-_i,l.x)),l.y=Math.max(_i+15,Math.min(s-_i-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 d=(l+h*.33)%1,c=o.x+(r.x-o.x)*d,f=o.y+(r.y-o.y)*d;s.beginPath(),s.arc(c,f,3,0,Math.PI*2),s.fillStyle="#ffcc80",s.fill()}}}for(const n of this.nodes.values()){const o=ft[n.colorIndex%ft.length],r=Ib(o.body),l=ud[n.phase]??ud.idle;s.beginPath(),s.arc(n.x,n.y,_i+3,0,Math.PI*2),s.strokeStyle=l,s.lineWidth=3,s.stroke(),s.beginPath(),s.arc(n.x,n.y,_i,0,Math.PI*2),s.fillStyle=r,s.fill();const h=Mb[n.role];h&&(s.font="9px monospace",s.textAlign="center",s.fillStyle="#aaa",s.fillText(h,n.x,n.y-_i-8)),s.font="11px sans-serif",s.textAlign="center",s.fillStyle="#ddd",s.fillText(Pb(n.label,12),n.x,n.y+_i+14)}}}class $b{constructor(t){y(this,"el");y(this,"currentAgentId",null);y(this,"hideTimer",null);y(this,"store");y(this,"onFocus",null);y(this,"onDetail",null);this.store=t,this.el=document.createElement("div"),this.el.id="agent-hover-bar",this.el.innerHTML=`
|
|
710
|
+
<button class="ahb-btn ahb-focus" title="Focus camera">
|
|
711
|
+
<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>
|
|
712
|
+
</button>
|
|
713
|
+
<button class="ahb-btn ahb-detail" title="View details">
|
|
714
|
+
<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>
|
|
715
|
+
</button>
|
|
716
|
+
<button class="ahb-btn ahb-approve" title="Approve pending" style="display:none">
|
|
717
|
+
<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>
|
|
718
|
+
</button>
|
|
719
|
+
<button class="ahb-btn ahb-copy" title="Copy session ID">
|
|
720
|
+
<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>
|
|
721
|
+
</button>
|
|
722
|
+
`,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()}}function nn(){return window.location.origin}async function Bb(){return(await(await fetch(`${nn()}/api/sessions/live`)).json()).sessions}async function Rb(i){const t=new URLSearchParams;return i!=null&&i.project&&t.set("project",i.project),t.set("limit",String(i.limit)),i!=null&&i.offset&&t.set("offset",String(i.offset)),(await fetch(`${nn()}/api/sessions?${t}`)).json()}async function ip(i){const t=await fetch(`${nn()}/api/sessions/${i}`);if(!t.ok)throw new Error(`Session ${i} not found`);return t.json()}async function Db(i){return(await(await fetch(`${nn()}/api/sessions/${i}/timeline`)).json()).timeline}async function zb(i,t){const e=new URLSearchParams({a:i,b:t}),s=await fetch(`${nn()}/api/sessions/compare?${e}`);if(!s.ok)throw new Error("Comparison failed");return s.json()}async function Fb(i){await fetch(`${nn()}/api/sessions/${i}`,{method:"DELETE"})}async function Nb(i,t){await fetch(`${nn()}/api/sessions/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:t})})}class Ob{constructor(t,e){y(this,"containerEl");y(this,"contentEl");y(this,"isVisible",!1);y(this,"sessions",[]);y(this,"liveSessions",[]);y(this,"total",0);y(this,"selectedIds",new Set);y(this,"expandedId",null);y(this,"expandedSession",null);y(this,"onCompare",null);y(this,"onOpenSession",null);y(this,"onOpenLiveSession",null);y(this,"refreshTimer",null);y(this,"shutdownRefreshTimer",null);y(this,"store",null);y(this,"shutdownListener",null);this.containerEl=t,e&&(this.store=e,this.shutdownListener=()=>{this.shutdownRefreshTimer&&clearTimeout(this.shutdownRefreshTimer),this.shutdownRefreshTimer=setTimeout(()=>{this.isVisible&&this.loadSessions()},3500)},e.on("agent:shutdown",this.shutdownListener)),this.contentEl=document.createElement("div"),this.contentEl.id="session-history-content",this.contentEl.style.display="none",this.containerEl.appendChild(this.contentEl)}setCompareHandler(t){this.onCompare=t}setOpenSessionHandler(t){this.onOpenSession=t}setOpenLiveSessionHandler(t){this.onOpenLiveSession=t}show(){this.isVisible=!0,this.contentEl.style.display="",this.loadSessions(),this.refreshTimer=setInterval(()=>{this.isVisible&&this.loadSessions()},1e4)}hide(){this.isVisible=!1,this.contentEl.style.display="none",this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null)}async loadSessions(){try{const[t,e]=await Promise.all([Rb({limit:50}),Bb()]);this.sessions=t.sessions,this.total=t.total,this.liveSessions=e;const s=new Set(this.sessions.map(n=>n.id));for(const n of this.selectedIds)s.has(n)||this.selectedIds.delete(n);this.expandedId&&!s.has(this.expandedId)&&(this.expandedId=null,this.expandedSession=null),this.render()}catch(t){console.error("Failed to load sessions:",t)}}render(){var s;const t=this.selectedIds.size===2,e=this.liveSessions.length>0?`
|
|
723
|
+
<div class="sh-section-title">
|
|
724
|
+
<span class="sh-status-badge sh-status-live"><span class="sh-live-dot"></span>Live</span>
|
|
725
|
+
<span class="sh-section-count">${this.liveSessions.length} active</span>
|
|
726
|
+
</div>
|
|
727
|
+
<div class="sh-list sh-list-live">
|
|
728
|
+
${this.liveSessions.map(n=>this.renderLiveSessionRow(n)).join("")}
|
|
729
|
+
</div>
|
|
730
|
+
<div class="sh-section-divider"></div>
|
|
731
|
+
`:"";this.contentEl.innerHTML=`
|
|
732
|
+
<div class="sh-toolbar">
|
|
733
|
+
<button class="sh-btn sh-compare-btn ${t?"":"disabled"}"
|
|
734
|
+
${t?"":"disabled"}>
|
|
735
|
+
Compare Selected (${this.selectedIds.size}/2)
|
|
736
|
+
</button>
|
|
737
|
+
</div>
|
|
738
|
+
|
|
739
|
+
${e}
|
|
740
|
+
|
|
741
|
+
${this.sessions.length>0&&this.liveSessions.length>0?`
|
|
742
|
+
<div class="sh-section-title">
|
|
743
|
+
<span class="sh-status-badge sh-status-recorded">Recorded</span>
|
|
744
|
+
<span class="sh-section-count">${this.total} total</span>
|
|
745
|
+
</div>
|
|
746
|
+
`:""}
|
|
747
|
+
|
|
748
|
+
${this.sessions.length===0?'<div class="sh-empty">No recorded sessions yet. Sessions are automatically recorded when agents shut down.</div>':`<div class="sh-list">
|
|
749
|
+
${this.sessions.map(n=>this.renderSessionRow(n)).join("")}
|
|
750
|
+
</div>`}
|
|
751
|
+
|
|
752
|
+
${this.total>this.sessions.length?`<div class="sh-footer">${this.sessions.length} of ${this.total} sessions shown</div>`:""}
|
|
753
|
+
`,(s=this.contentEl.querySelector(".sh-compare-btn"))==null||s.addEventListener("click",()=>{var n;if(t){const o=[...this.selectedIds];(n=this.onCompare)==null||n.call(this,o[0],o[1])}}),this.contentEl.querySelectorAll(".sh-checkbox").forEach(n=>{n.addEventListener("change",()=>{const o=n.dataset.id;if(n.checked){if(this.selectedIds.size>=2){const r=this.selectedIds.values().next().value;this.selectedIds.delete(r)}this.selectedIds.add(o)}else this.selectedIds.delete(o);this.render()})}),this.contentEl.querySelectorAll(".sh-row:not(.sh-row-live) .sh-row-main").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.id;o&&(this.onOpenSession?this.onOpenSession(o):this.toggleExpand(o))})}),this.contentEl.querySelectorAll(".sh-row-live .sh-row-main").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.rootId;if(o&&this.onOpenLiveSession){const r=this.liveSessions.find(l=>l.rootSessionId===o);r&&this.onOpenLiveSession(r)}})}),this.contentEl.querySelectorAll(".sh-label-edit").forEach(n=>{n.addEventListener("click",async o=>{o.stopPropagation();const r=n.dataset.id,l=n.dataset.label||"",h=prompt("Session label:",l);h!==null&&(await Nb(r,h||null),await this.loadSessions())})}),this.contentEl.querySelectorAll(".sh-delete-btn").forEach(n=>{n.addEventListener("click",async o=>{o.stopPropagation();const r=n.dataset.id;confirm("Delete this recorded session?")&&(await Fb(r),this.selectedIds.delete(r),this.expandedId===r&&(this.expandedId=null,this.expandedSession=null),await this.loadSessions())})})}async toggleExpand(t){if(this.expandedId===t){this.expandedId=null,this.expandedSession=null,this.render();return}this.expandedId=t,this.expandedSession=null,this.render();try{this.expandedSession=await ip(t),this.render()}catch(e){console.error("Failed to load session detail:",e),this.expandedSession=null,this.render()}}renderLiveSessionRow(t){const s=new Date(t.startedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),n=Tr(t.source),o=Date.now()-t.startedAt;return`
|
|
754
|
+
<div class="sh-row sh-row-live">
|
|
755
|
+
<div class="sh-row-main" data-root-id="${t.rootSessionId}">
|
|
756
|
+
<div class="sh-row-header">
|
|
757
|
+
<span class="sh-source-badge">${n}</span>
|
|
758
|
+
<span class="sh-project">${ct(t.projectName)}</span>
|
|
759
|
+
<span class="sh-expand-icon">▶</span>
|
|
760
|
+
</div>
|
|
761
|
+
<div class="sh-row-meta">
|
|
762
|
+
<span>Started ${s}</span>
|
|
763
|
+
<span class="sh-meta-sep">|</span>
|
|
764
|
+
<span>${oe(o)} elapsed</span>
|
|
765
|
+
<span class="sh-meta-sep">|</span>
|
|
766
|
+
<span>${t.agentCount} agent${t.agentCount!==1?"s":""}</span>
|
|
767
|
+
</div>
|
|
768
|
+
</div>
|
|
769
|
+
</div>
|
|
770
|
+
`}renderSessionRow(t){const e=this.selectedIds.has(t.id),s=this.expandedId===t.id,n=new Date(t.startedAt),o=n.toLocaleDateString(void 0,{month:"short",day:"numeric"}),r=n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),l=Tr(t.source),h=t.label==="(recovered)",d=h?'<span class="sh-status-badge sh-status-recovered">Recovered</span>':'<span class="sh-status-badge sh-status-recorded">Recorded</span>',c=t.label&&!h?`<span class="sh-label">${ct(t.label)}</span>`:"";let f="";return s&&(f=this.renderSessionDetail(t)),`
|
|
771
|
+
<div class="sh-row ${e?"selected":""} ${s?"expanded":""}">
|
|
772
|
+
<div class="sh-row-check">
|
|
773
|
+
<input type="checkbox" class="sh-checkbox" data-id="${t.id}"
|
|
774
|
+
${e?"checked":""} />
|
|
775
|
+
</div>
|
|
776
|
+
<div class="sh-row-main" data-id="${t.id}">
|
|
777
|
+
<div class="sh-row-header">
|
|
778
|
+
<span class="sh-source-badge">${l}</span>
|
|
779
|
+
<span class="sh-project">${ct(t.projectName)}</span>
|
|
780
|
+
${d}
|
|
781
|
+
${c}
|
|
782
|
+
<span class="sh-expand-icon">${s?"▼":"▶"}</span>
|
|
783
|
+
</div>
|
|
784
|
+
<div class="sh-row-meta">
|
|
785
|
+
<span>${o} ${r}</span>
|
|
786
|
+
<span class="sh-meta-sep">|</span>
|
|
787
|
+
<span>${oe(t.durationMs)}</span>
|
|
788
|
+
<span class="sh-meta-sep">|</span>
|
|
789
|
+
<span>$${t.totalCost.toFixed(2)}</span>
|
|
790
|
+
<span class="sh-meta-sep">|</span>
|
|
791
|
+
<span>${t.totalToolUses} tools</span>
|
|
792
|
+
<span class="sh-meta-sep">|</span>
|
|
793
|
+
<span>${t.agentCount} agent${t.agentCount!==1?"s":""}</span>
|
|
794
|
+
</div>
|
|
795
|
+
${t.model?`<div class="sh-row-model">${ct(t.model)}</div>`:""}
|
|
796
|
+
${f}
|
|
797
|
+
</div>
|
|
798
|
+
<div class="sh-row-actions">
|
|
799
|
+
<button class="sh-label-edit" data-id="${t.id}" data-label="${ct(t.label||"")}" title="Edit label">
|
|
800
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 000-1.41l-2.34-2.34a1 1 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
|
|
801
|
+
</button>
|
|
802
|
+
<button class="sh-delete-btn" data-id="${t.id}" title="Delete session">
|
|
803
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>
|
|
804
|
+
</button>
|
|
805
|
+
</div>
|
|
806
|
+
</div>
|
|
807
|
+
`}renderSessionDetail(t){if(!this.expandedSession)return'<div class="sh-detail"><div class="sh-detail-loading">Loading details...</div></div>';const e=this.expandedSession,s=e.agents;return`
|
|
808
|
+
<div class="sh-detail">
|
|
809
|
+
${e.model?`
|
|
810
|
+
<div class="sh-detail-row">
|
|
811
|
+
<span class="sh-detail-label">Model</span>
|
|
812
|
+
<span class="sh-detail-value">${ct(e.model)}</span>
|
|
813
|
+
</div>
|
|
814
|
+
`:""}
|
|
815
|
+
<div class="sh-detail-row">
|
|
816
|
+
<span class="sh-detail-label">Tokens</span>
|
|
817
|
+
<span class="sh-detail-value">${gt(e.totalInputTokens)} in / ${gt(e.totalOutputTokens)} out</span>
|
|
818
|
+
</div>
|
|
819
|
+
<div class="sh-detail-row">
|
|
820
|
+
<span class="sh-detail-label">Cache</span>
|
|
821
|
+
<span class="sh-detail-value">${gt(e.totalCacheReadTokens)} read / ${gt(e.totalCacheCreationTokens)} created</span>
|
|
822
|
+
</div>
|
|
823
|
+
${s.length>0?`
|
|
824
|
+
<div class="sh-detail-agents-title">Agents (${s.length})</div>
|
|
825
|
+
<div class="sh-detail-agents">
|
|
826
|
+
${s.map(n=>`
|
|
827
|
+
<div class="sh-detail-agent">
|
|
828
|
+
<div class="sh-detail-agent-name">${ct(kr(n))}</div>
|
|
829
|
+
<div class="sh-detail-agent-meta">
|
|
830
|
+
${n.model?`<span>${ct(n.model)}</span>`:""}
|
|
831
|
+
<span>$${n.cost.toFixed(3)}</span>
|
|
832
|
+
<span>${n.toolUseCount} tools</span>
|
|
833
|
+
<span>${gt(n.totalInputTokens+n.totalOutputTokens)} tok</span>
|
|
834
|
+
<span>${oe(n.endedAt-n.spawnedAt)}</span>
|
|
835
|
+
</div>
|
|
836
|
+
</div>
|
|
837
|
+
`).join("")}
|
|
838
|
+
</div>
|
|
839
|
+
`:""}
|
|
840
|
+
</div>
|
|
841
|
+
`}dispose(){this.refreshTimer&&clearInterval(this.refreshTimer),this.shutdownRefreshTimer&&clearTimeout(this.shutdownRefreshTimer),this.store&&this.shutdownListener&&this.store.off("agent:shutdown",this.shutdownListener),this.contentEl.remove()}}class Gb{constructor(){y(this,"el");y(this,"bodyEl");y(this,"isOpen",!1);y(this,"comparison",null);y(this,"keydownHandler",t=>{t.key==="Escape"&&this.isOpen&&this.close()});this.el=document.createElement("div"),this.el.id="session-comparison",this.el.innerHTML=`
|
|
842
|
+
<div class="scm-backdrop"></div>
|
|
843
|
+
<div class="scm-modal">
|
|
844
|
+
<div class="scm-header">
|
|
845
|
+
<span class="scm-title">Session Comparison</span>
|
|
846
|
+
<div class="scm-header-labels"></div>
|
|
847
|
+
<button class="scm-close">×</button>
|
|
848
|
+
</div>
|
|
849
|
+
<div class="scm-body"></div>
|
|
850
|
+
</div>
|
|
851
|
+
`,document.body.appendChild(this.el),this.bodyEl=this.el.querySelector(".scm-body"),this.el.querySelector(".scm-backdrop").addEventListener("click",()=>this.close()),this.el.querySelector(".scm-close").addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.keydownHandler)}async open(t,e){this.isOpen=!0,this.comparison=null,this.el.classList.add("open"),this.bodyEl.innerHTML='<div class="scm-loading">Loading comparison...</div>',this.el.querySelector(".scm-header-labels").innerHTML="";try{this.comparison=await zb(t,e),this.render()}catch(s){console.error("Failed to load comparison:",s),this.bodyEl.innerHTML='<div class="scm-loading">Failed to load comparison.</div>'}}close(){this.isOpen=!1,this.el.classList.remove("open")}render(){if(!this.comparison)return;const t=this.comparison.sessionA,e=this.comparison.sessionB,s=t.label||t.projectName,n=e.label||e.projectName,o=t.source==="opencode"?"OpenCode":"Claude Code",r=e.source==="opencode"?"OpenCode":"Claude Code";this.el.querySelector(".scm-header-labels").innerHTML=`
|
|
852
|
+
<div class="scm-label scm-label-a">
|
|
853
|
+
<span class="sc-dot sc-dot-a"></span>
|
|
854
|
+
A: ${ct(s)}
|
|
855
|
+
<span class="sc-source">${o}</span>
|
|
856
|
+
</div>
|
|
857
|
+
<span class="scm-vs">vs</span>
|
|
858
|
+
<div class="scm-label scm-label-b">
|
|
859
|
+
<span class="sc-dot sc-dot-b"></span>
|
|
860
|
+
B: ${ct(n)}
|
|
861
|
+
<span class="sc-source">${r}</span>
|
|
862
|
+
</div>
|
|
863
|
+
`,this.bodyEl.innerHTML=`
|
|
864
|
+
${this.renderSideBySideOverview(t,e)}
|
|
865
|
+
${this.renderSideBySideAgents(t,e)}
|
|
866
|
+
${this.renderSideBySideToolUsage(t,e)}
|
|
867
|
+
${this.renderSideBySideFiles(t,e)}
|
|
868
|
+
${this.renderSideBySideToolSequence(t,e)}
|
|
869
|
+
`}renderSideBySideOverview(t,e){const s=t.totalInputTokens+t.totalCacheReadTokens,n=e.totalInputTokens+e.totalCacheReadTokens,o=s>0?t.totalCacheReadTokens/s*100:0,r=n>0?e.totalCacheReadTokens/n*100:0,l=t.durationMs>0?t.totalCost/(t.durationMs/6e4):0,h=e.durationMs>0?e.totalCost/(e.durationMs/6e4):0;return`
|
|
870
|
+
<div class="sc-section">
|
|
871
|
+
<div class="sc-section-title">Overview</div>
|
|
872
|
+
<table class="sc-table">
|
|
873
|
+
<thead>
|
|
874
|
+
<tr><th>Metric</th><th class="sc-th-a">Session A</th><th class="sc-th-delta"></th><th class="sc-th-b">Session B</th></tr>
|
|
875
|
+
</thead>
|
|
876
|
+
<tbody>
|
|
877
|
+
${[{label:"Duration",vA:oe(t.durationMs),vB:oe(e.durationMs),delta:this.pctDelta(t.durationMs,e.durationMs),low:!0},{label:"Total Cost",vA:`$${t.totalCost.toFixed(3)}`,vB:`$${e.totalCost.toFixed(3)}`,delta:this.pctDelta(t.totalCost,e.totalCost),low:!0},{label:"Cost/min",vA:`$${l.toFixed(4)}`,vB:`$${h.toFixed(4)}`,delta:this.pctDelta(l,h),low:!0},{label:"Tool Uses",vA:String(t.totalToolUses),vB:String(e.totalToolUses),delta:this.pctDelta(t.totalToolUses,e.totalToolUses),low:!0},{label:"Input Tokens",vA:gt(t.totalInputTokens),vB:gt(e.totalInputTokens),delta:this.pctDelta(t.totalInputTokens,e.totalInputTokens),low:!0},{label:"Output Tokens",vA:gt(t.totalOutputTokens),vB:gt(e.totalOutputTokens),delta:this.pctDelta(t.totalOutputTokens,e.totalOutputTokens),low:!0},{label:"Cache Read",vA:gt(t.totalCacheReadTokens),vB:gt(e.totalCacheReadTokens),delta:this.pctDelta(t.totalCacheReadTokens,e.totalCacheReadTokens),low:!1},{label:"Cache Hit %",vA:`${o.toFixed(1)}%`,vB:`${r.toFixed(1)}%`,delta:this.pctDelta(o,r),low:!1},{label:"Agents",vA:String(t.agentCount),vB:String(e.agentCount),delta:this.pctDelta(t.agentCount,e.agentCount),low:!1},{label:"Model",vA:t.model||"-",vB:e.model||"-",delta:NaN,low:!1}].map(c=>`
|
|
878
|
+
<tr>
|
|
879
|
+
<td class="sc-td-label">${c.label}</td>
|
|
880
|
+
<td class="sc-td-a">${c.label==="Model"?ct(c.vA):c.vA}</td>
|
|
881
|
+
<td class="sc-td-delta">${isNaN(c.delta)?"":`<span class="sc-delta ${this.deltaClass(c.delta,c.low)}">${this.formatDelta(c.delta)}</span>`}</td>
|
|
882
|
+
<td class="sc-td-b">${c.label==="Model"?ct(c.vB):c.vB}</td>
|
|
883
|
+
</tr>
|
|
884
|
+
`).join("")}
|
|
885
|
+
</tbody>
|
|
886
|
+
</table>
|
|
887
|
+
</div>
|
|
888
|
+
`}renderSideBySideAgents(t,e){if(t.agents.length===0&&e.agents.length===0)return"";const s=r=>`
|
|
889
|
+
<div class="sc-agent-card">
|
|
890
|
+
<div class="sc-agent-name">${ct(kr(r))}</div>
|
|
891
|
+
<div class="sc-agent-model">${r.model?ct(r.model):""}</div>
|
|
892
|
+
<div class="sc-agent-grid">
|
|
893
|
+
<span class="sc-ag-label">Cost</span><span class="sc-ag-val">$${r.cost.toFixed(3)}</span>
|
|
894
|
+
<span class="sc-ag-label">Tools</span><span class="sc-ag-val">${r.toolUseCount}</span>
|
|
895
|
+
<span class="sc-ag-label">Tokens</span><span class="sc-ag-val">${gt(r.totalInputTokens)} in / ${gt(r.totalOutputTokens)} out</span>
|
|
896
|
+
<span class="sc-ag-label">Duration</span><span class="sc-ag-val">${oe(r.endedAt-r.spawnedAt)}</span>
|
|
897
|
+
<span class="sc-ag-label">Cache</span><span class="sc-ag-val">${gt(r.cacheReadTokens)} read</span>
|
|
898
|
+
</div>
|
|
899
|
+
</div>
|
|
900
|
+
`,n=Math.max(t.agents.length,e.agents.length),o=Array.from({length:n},(r,l)=>`
|
|
901
|
+
<div class="sc-split-row">
|
|
902
|
+
<div class="sc-split-left">${t.agents[l]?s(t.agents[l]):'<div class="sc-empty-cell">-</div>'}</div>
|
|
903
|
+
<div class="sc-split-right">${e.agents[l]?s(e.agents[l]):'<div class="sc-empty-cell">-</div>'}</div>
|
|
904
|
+
</div>
|
|
905
|
+
`).join("");return`
|
|
906
|
+
<div class="sc-section">
|
|
907
|
+
<div class="sc-section-title">Agents</div>
|
|
908
|
+
<div class="sc-split-header">
|
|
909
|
+
<div class="sc-split-left sc-col-header sc-col-a">Session A (${t.agents.length})</div>
|
|
910
|
+
<div class="sc-split-right sc-col-header sc-col-b">Session B (${e.agents.length})</div>
|
|
911
|
+
</div>
|
|
912
|
+
${o}
|
|
913
|
+
</div>
|
|
914
|
+
`}renderSideBySideToolUsage(t,e){var h,d;const s=((h=t.toolChain)==null?void 0:h.toolCounts)??{},n=((d=e.toolChain)==null?void 0:d.toolCounts)??{},r=[...new Set([...Object.keys(s),...Object.keys(n)])].map(c=>({tool:c,countA:s[c]??0,countB:n[c]??0})).sort((c,f)=>f.countA+f.countB-(c.countA+c.countB));if(r.length===0)return"";const l=Math.max(...r.map(c=>Math.max(c.countA,c.countB)),1);return`
|
|
915
|
+
<div class="sc-section">
|
|
916
|
+
<div class="sc-section-title">Tool Usage</div>
|
|
917
|
+
<div class="sc-tool-table">
|
|
918
|
+
${r.map(c=>{const f=c.countA/l*100,g=c.countB/l*100,m=c.countB===0&&c.countA>0,v=c.countA===0&&c.countB>0,b=m?'<span class="sc-unique sc-unique-a">A</span>':v?'<span class="sc-unique sc-unique-b">B</span>':"",_=this.pctDelta(c.countA,c.countB);return`
|
|
919
|
+
<div class="sc-tool-cmp-row">
|
|
920
|
+
<div class="sc-tool-cmp-bar sc-tool-cmp-bar-a">
|
|
921
|
+
<span class="sc-tool-cmp-count">${c.countA}</span>
|
|
922
|
+
<div class="sc-tool-cmp-fill sc-bar-a" style="width:${Math.max(1,f)}%"></div>
|
|
923
|
+
</div>
|
|
924
|
+
<div class="sc-tool-cmp-name">${ct(this.shortenToolName(c.tool))} ${b}</div>
|
|
925
|
+
<div class="sc-tool-cmp-bar sc-tool-cmp-bar-b">
|
|
926
|
+
<div class="sc-tool-cmp-fill sc-bar-b" style="width:${Math.max(1,g)}%"></div>
|
|
927
|
+
<span class="sc-tool-cmp-count">${c.countB}</span>
|
|
928
|
+
</div>
|
|
929
|
+
<span class="sc-delta sc-tool-cmp-delta ${this.deltaClass(_,!0)}">${this.formatDelta(_)}</span>
|
|
930
|
+
</div>
|
|
931
|
+
`}).join("")}
|
|
932
|
+
</div>
|
|
933
|
+
</div>
|
|
934
|
+
`}renderSideBySideFiles(t,e){const s=v=>{const b=new Map;for(const _ of v){if(_.kind!=="tool"||!_.tool||!_.toolArgs)continue;const x=_.toolArgs;let C=null;const $=x.match(/^([A-Za-z]:[/\\][^\s,]+|\/[^\s,]+)/);if($&&(C=$[1].replace(/\\/g,"/")),!C)continue;const P=this.shortenPath(C),H=b.get(P)??{path:P,readCount:0,writeCount:0};Wu.has(_.tool)?H.writeCount++:(Hu.has(_.tool),H.readCount++),b.set(P,H)}return[...b.values()].sort((_,x)=>x.writeCount+x.readCount-(_.writeCount+_.readCount))},n=s(t.timeline),o=s(e.timeline);if(n.length===0&&o.length===0)return"";const r=new Set(n.map(v=>v.path)),l=new Set(o.map(v=>v.path)),h=n.filter(v=>l.has(v.path)),d=n.filter(v=>!l.has(v.path)),c=o.filter(v=>!r.has(v.path)),f=n.filter(v=>v.writeCount>0),g=o.filter(v=>v.writeCount>0),m=(v,b)=>v.length===0?'<div class="sc-empty-cell">No files</div>':`
|
|
935
|
+
<div class="sc-file-list">
|
|
936
|
+
${v.slice(0,b).map(_=>`
|
|
937
|
+
<div class="sc-file-item">
|
|
938
|
+
<span class="sc-file-icon">${_.writeCount>0?"W":"R"}</span>
|
|
939
|
+
<span class="sc-file-path" title="${ct(_.path)}">${ct(_.path)}</span>
|
|
940
|
+
<span class="sc-file-counts">${_.writeCount>0?`${_.writeCount}w`:""}${_.readCount>0?` ${_.readCount}r`:""}</span>
|
|
941
|
+
</div>
|
|
942
|
+
`).join("")}
|
|
943
|
+
${v.length>b?`<div class="sc-call-more">+${v.length-b} more</div>`:""}
|
|
944
|
+
</div>
|
|
945
|
+
`;return`
|
|
946
|
+
<div class="sc-section">
|
|
947
|
+
<div class="sc-section-title">Files Touched</div>
|
|
948
|
+
<div class="sc-file-summary">
|
|
949
|
+
<span>A: <strong>${f.length}</strong> written, <strong>${n.length}</strong> total</span>
|
|
950
|
+
<span class="sc-file-shared">${h.length} shared files</span>
|
|
951
|
+
<span>B: <strong>${g.length}</strong> written, <strong>${o.length}</strong> total</span>
|
|
952
|
+
</div>
|
|
953
|
+
<div class="sc-split-header">
|
|
954
|
+
<div class="sc-split-left sc-col-header sc-col-a">Session A files</div>
|
|
955
|
+
<div class="sc-split-right sc-col-header sc-col-b">Session B files</div>
|
|
956
|
+
</div>
|
|
957
|
+
<div class="sc-split-row">
|
|
958
|
+
<div class="sc-split-left">${m(n,20)}</div>
|
|
959
|
+
<div class="sc-split-right">${m(o,20)}</div>
|
|
960
|
+
</div>
|
|
961
|
+
${d.length>0||c.length>0?`
|
|
962
|
+
<div class="sc-file-diff-header">Unique files</div>
|
|
963
|
+
<div class="sc-split-row">
|
|
964
|
+
<div class="sc-split-left">${d.length>0?m(d,10):'<div class="sc-empty-cell">None unique to A</div>'}</div>
|
|
965
|
+
<div class="sc-split-right">${c.length>0?m(c,10):'<div class="sc-empty-cell">None unique to B</div>'}</div>
|
|
966
|
+
</div>
|
|
967
|
+
`:""}
|
|
968
|
+
</div>
|
|
969
|
+
`}renderSideBySideToolSequence(t,e){const s=h=>h.filter(d=>d.kind==="tool"&&d.tool).map(d=>({tool:d.tool,args:d.toolArgs||""})),n=s(t.timeline),o=s(e.timeline);if(n.length===0&&o.length===0)return"";const r=50,l=h=>`
|
|
970
|
+
<div class="sc-seq-list">
|
|
971
|
+
${h.slice(0,r).map((c,f)=>{const g=c.args.length>50?c.args.slice(0,47)+"...":c.args;return`
|
|
972
|
+
<div class="sc-seq-row" title="${ct(c.args)}">
|
|
973
|
+
<span class="sc-seq-num">${f+1}</span>
|
|
974
|
+
<span class="sc-seq-tool">${ct(this.shortenToolName(c.tool))}</span>
|
|
975
|
+
<span class="sc-seq-args">${ct(g)}</span>
|
|
976
|
+
</div>
|
|
977
|
+
`}).join("")}
|
|
978
|
+
${h.length>r?`<div class="sc-call-more">+${h.length-r} more</div>`:""}
|
|
979
|
+
<div class="sc-seq-total">${h.length} total calls</div>
|
|
980
|
+
</div>
|
|
981
|
+
`;return`
|
|
982
|
+
<div class="sc-section">
|
|
983
|
+
<div class="sc-section-title">Tool Sequence</div>
|
|
984
|
+
<div class="sc-split-header">
|
|
985
|
+
<div class="sc-split-left sc-col-header sc-col-a">Session A (${n.length} calls)</div>
|
|
986
|
+
<div class="sc-split-right sc-col-header sc-col-b">Session B (${o.length} calls)</div>
|
|
987
|
+
</div>
|
|
988
|
+
<div class="sc-split-row sc-split-row-scroll">
|
|
989
|
+
<div class="sc-split-left">${l(n)}</div>
|
|
990
|
+
<div class="sc-split-right">${l(o)}</div>
|
|
991
|
+
</div>
|
|
992
|
+
</div>
|
|
993
|
+
`}shortenToolName(t){if(t.startsWith("mcp__")){const e=t.slice(5).split("__");if(e.length>=2)return`${e.slice(0,-1).join("/")}.${e[e.length-1]}`}return t}shortenPath(t){const e=t.replace(/\\/g,"/"),s=e.match(/\/packages\/(.+)/)||e.match(/\/src\/(.+)/);if(s)return s[0];const n=e.split("/");return n.length>3?".../"+n.slice(-3).join("/"):e}pctDelta(t,e){return t===0&&e===0?0:t===0?100:(e-t)/t*100}formatDelta(t){return Math.abs(t)<.5?"=":`${t>0?"+":""}${t.toFixed(0)}%`}deltaClass(t,e){return Math.abs(t)<5?"sc-delta-neutral":e?t>0?"sc-delta-worse":"sc-delta-better":t>0?"sc-delta-better":"sc-delta-worse"}dispose(){document.removeEventListener("keydown",this.keydownHandler),this.el.remove()}}class Wb{constructor(t){y(this,"panelEl");y(this,"store");y(this,"session",null);y(this,"timeline",[]);y(this,"liveSession",null);y(this,"isLive",!1);y(this,"_onNavigateToAgent",null);y(this,"_onClose",null);y(this,"liveActivityEntries",new Map);y(this,"shutdownTotals",{cost:0,input:0,output:0,tools:0});y(this,"liveListeners",[]);y(this,"renderDebounceTimer",null);this.store=t,this.panelEl=document.createElement("div"),this.panelEl.id="session-detail-panel",this.panelEl.innerHTML=`
|
|
994
|
+
<div class="sd-header">
|
|
995
|
+
<button id="sd-back" title="Back to session list">
|
|
996
|
+
<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>
|
|
997
|
+
Back
|
|
998
|
+
</button>
|
|
999
|
+
</div>
|
|
1000
|
+
<div id="sd-content" class="sd-content"></div>
|
|
1001
|
+
`;const e=document.getElementById("right-panel");e?e.appendChild(this.panelEl):document.body.appendChild(this.panelEl),this.panelEl.querySelector("#sd-back").addEventListener("click",()=>this.close())}setNavigateToAgentHandler(t){this._onNavigateToAgent=t}setCloseHandler(t){this._onClose=t}async openRecorded(t){this.cleanupLiveListeners(),this.isLive=!1,this.liveSession=null,this.session=null,this.timeline=[],this.panelEl.classList.add("open"),this.renderLoading();try{const[e,s]=await Promise.all([ip(t),Db(t)]);this.session=e,this.timeline=s,this.renderSession()}catch(e){console.error("Failed to load session:",e),this.renderError()}}openLive(t){this.cleanupLiveListeners(),this.isLive=!0,this.liveSession=t,this.session=null,this.timeline=[],this.liveActivityEntries.clear(),this.shutdownTotals={cost:0,input:0,output:0,tools:0},this.panelEl.classList.add("open"),this.renderLiveSession();const e=this.getSessionAgents(t.rootSessionId);for(const n of e)this.store.requestHistory(n.id);this.addLiveListener("agent:history",n=>{if(!this.isLive||!this.liveSession)return;const o=this.store.getAgent(n.agentId);(o==null?void 0:o.rootSessionId)===this.liveSession.rootSessionId&&(this.liveActivityEntries.set(n.agentId,n.entries),this.debouncedRenderLive())});const s=n=>{!this.isLive||!this.liveSession||n.rootSessionId===this.liveSession.rootSessionId&&this.debouncedRenderLive()};this.addLiveListener("agent:update",s),this.addLiveListener("agent:spawn",s),this.addLiveListener("agent:shutdown",n=>{if(!this.isLive||!this.liveSession)return;const o=this.store.getAgent(n);o&&o.rootSessionId===this.liveSession.rootSessionId&&(this.shutdownTotals.cost+=Ji(o),this.shutdownTotals.input+=o.totalInputTokens??0,this.shutdownTotals.output+=o.totalOutputTokens??0,this.shutdownTotals.tools+=o.toolUseCount??0,this.debouncedRenderLive())})}close(){var t;this.cleanupLiveListeners(),this.session=null,this.liveSession=null,this.timeline=[],this.liveActivityEntries.clear(),this.panelEl.classList.remove("open"),(t=this._onClose)==null||t.call(this)}addLiveListener(t,e){this.store.on(t,e),this.liveListeners.push({event:t,fn:e})}cleanupLiveListeners(){for(const{event:t,fn:e}of this.liveListeners)this.store.off(t,e);this.liveListeners=[],this.renderDebounceTimer&&(clearTimeout(this.renderDebounceTimer),this.renderDebounceTimer=null)}debouncedRenderLive(){this.renderDebounceTimer||(this.renderDebounceTimer=setTimeout(()=>{this.renderDebounceTimer=null,this.isLive&&this.liveSession&&this.renderLiveSession()},200))}isOpen(){return this.panelEl.classList.contains("open")}getSessionAgents(t){const e=[];for(const s of this.store.getAgents().values())s.rootSessionId===t&&e.push(s);return e}renderLoading(){const t=this.panelEl.querySelector("#sd-content");t.innerHTML='<div class="sd-loading">Loading session details...</div>'}renderError(){const t=this.panelEl.querySelector("#sd-content");t.innerHTML='<div class="sd-loading">Failed to load session.</div>'}renderLiveSession(){const t=this.panelEl.querySelector("#sd-content"),e=this.liveSession,s=Date.now()-e.startedAt,n=new Date(e.startedAt),o=Tr(e.source),r=Yh(e.source),l=this.getSessionAgents(e.rootSessionId);let h=this.shutdownTotals.cost,d=this.shutdownTotals.input,c=this.shutdownTotals.output,f=this.shutdownTotals.tools;const g=new Set;for(const x of l)h+=Ji(x),d+=x.totalInputTokens??0,c+=x.totalOutputTokens??0,f+=x.toolUseCount??0,x.model&&g.add(x.model);const m=[];for(const[x,C]of this.liveActivityEntries)for(const $ of C)m.push({timestamp:$.timestamp,agentId:x,kind:$.kind,zone:$.zone,tool:$.tool,toolArgs:$.toolArgs,inputTokens:$.inputTokens,outputTokens:$.outputTokens});m.sort((x,C)=>x.timestamp-C.timestamp);const v={};for(const x of m)x.kind==="tool"&&x.tool&&(v[x.tool]=(v[x.tool]??0)+1);const b=Object.entries(v).sort((x,C)=>C[1]-x[1]),_=b.length>0?b[0][1]:1;t.innerHTML=`
|
|
1002
|
+
<div class="sd-card">
|
|
1003
|
+
<div class="sd-card-header">
|
|
1004
|
+
<span class="sh-source-badge">${o}</span>
|
|
1005
|
+
<span class="sd-project-name">${ct(e.projectName)}</span>
|
|
1006
|
+
<span class="sh-status-badge sh-status-live"><span class="sh-live-dot"></span>Live</span>
|
|
1007
|
+
</div>
|
|
1008
|
+
</div>
|
|
1009
|
+
|
|
1010
|
+
<div class="sd-section">
|
|
1011
|
+
<div class="sd-section-title">Overview</div>
|
|
1012
|
+
<div class="sd-info-grid">
|
|
1013
|
+
${this.infoRow("Source",`<span class="sd-source-label">${r}</span>`)}
|
|
1014
|
+
${g.size>0?this.infoRow("Model",`<code>${ct([...g].join(", "))}</code>`):""}
|
|
1015
|
+
${this.infoRow("Started",n.toLocaleString())}
|
|
1016
|
+
${this.infoRow("Elapsed",oe(s))}
|
|
1017
|
+
${this.infoRow("Agents",String(l.length))}
|
|
1018
|
+
${this.infoRow("Session ID",`<code class="sd-session-id" title="Click to copy">${e.rootSessionId.slice(0,20)}...</code>`)}
|
|
1019
|
+
</div>
|
|
1020
|
+
</div>
|
|
1021
|
+
|
|
1022
|
+
${h>0||d>0?`
|
|
1023
|
+
<div class="sd-section">
|
|
1024
|
+
<div class="sd-section-title">Cost & Tokens (live)</div>
|
|
1025
|
+
<div class="sd-info-grid">
|
|
1026
|
+
${this.infoRow("Total Cost",`<span class="sd-cost">$${h.toFixed(3)}</span>`)}
|
|
1027
|
+
${this.infoRow("Input Tokens",gt(d))}
|
|
1028
|
+
${this.infoRow("Output Tokens",gt(c))}
|
|
1029
|
+
${this.infoRow("Tool Uses",String(f))}
|
|
1030
|
+
</div>
|
|
1031
|
+
</div>
|
|
1032
|
+
`:""}
|
|
1033
|
+
|
|
1034
|
+
${l.length>0?`
|
|
1035
|
+
<div class="sd-section">
|
|
1036
|
+
<div class="sd-section-title">Active Agents (${l.length})</div>
|
|
1037
|
+
<div class="sd-agents-list">
|
|
1038
|
+
${l.map(x=>{const C=x.agentName||Ss(x.id),$=x.isDone?"done":x.isIdle?"idle":"active",P=oe(Date.now()-x.spawnedAt);return`
|
|
1039
|
+
<div class="sd-agent-card">
|
|
1040
|
+
<div class="sd-agent-header">
|
|
1041
|
+
<span class="agent-status-dot ${$}"></span>
|
|
1042
|
+
<a href="#" class="sd-agent-link" data-agent-id="${Qt(x.id)}">${ct(C)}</a>
|
|
1043
|
+
<span class="sd-agent-role">${x.role.toUpperCase()}</span>
|
|
1044
|
+
</div>
|
|
1045
|
+
<div class="sd-agent-meta">
|
|
1046
|
+
${x.model?`<span>${ct(x.model)}</span>`:""}
|
|
1047
|
+
<span>${P}</span>
|
|
1048
|
+
<span>${x.currentTool?ct(x.currentTool):"idle"}</span>
|
|
1049
|
+
<span>$${Ji(x).toFixed(3)}</span>
|
|
1050
|
+
<span>${gt((x.totalInputTokens??0)+(x.totalOutputTokens??0))} tok</span>
|
|
1051
|
+
</div>
|
|
1052
|
+
</div>
|
|
1053
|
+
`}).join("")}
|
|
1054
|
+
</div>
|
|
1055
|
+
</div>
|
|
1056
|
+
`:""}
|
|
1057
|
+
|
|
1058
|
+
${b.length>0?`
|
|
1059
|
+
<div class="sd-section">
|
|
1060
|
+
<div class="sd-section-title">Tool Usage (${f} total)</div>
|
|
1061
|
+
<div class="sd-tool-list">
|
|
1062
|
+
${this.renderToolBars(b,_)}
|
|
1063
|
+
</div>
|
|
1064
|
+
</div>
|
|
1065
|
+
`:""}
|
|
1066
|
+
|
|
1067
|
+
${m.length>0?`
|
|
1068
|
+
<div class="sd-section">
|
|
1069
|
+
<div class="sd-section-title">Activity History (${m.length} events)</div>
|
|
1070
|
+
<div class="sd-timeline">
|
|
1071
|
+
${this.renderTimelineEvents(m,e.startedAt,x=>{const C=this.store.getAgent(x);return(C==null?void 0:C.agentName)||Ss(x)})}
|
|
1072
|
+
</div>
|
|
1073
|
+
</div>
|
|
1074
|
+
`:""}
|
|
1075
|
+
`,this.bindAgentLinks(t),this.bindSessionIdCopy(t)}renderSession(){var _;const t=this.panelEl.querySelector("#sd-content"),e=this.session,s=new Date(e.startedAt),n=new Date(e.endedAt),o=Tr(e.source),r=Yh(e.source),l=e.totalInputTokens+e.totalCacheReadTokens,h=l>0?e.totalCacheReadTokens/l*100:0,d=e.durationMs>0?(e.totalInputTokens+e.totalOutputTokens)/(e.durationMs/6e4):0,c=((_=e.toolChain)==null?void 0:_.toolCounts)??{},f=Object.entries(c).sort((x,C)=>C[1]-x[1]),g=f.length>0?f[0][1]:1,m=this.analyzeFiles(),v=Object.entries(m).sort((x,C)=>C[1].readCount+C[1].writeCount-(x[1].readCount+x[1].writeCount)),b=new Set;for(const x of this.store.getAgents().values())b.add(x.id);t.innerHTML=`
|
|
1076
|
+
<div class="sd-card">
|
|
1077
|
+
<div class="sd-card-header">
|
|
1078
|
+
<span class="sh-source-badge">${o}</span>
|
|
1079
|
+
<span class="sd-project-name">${ct(e.projectName)}</span>
|
|
1080
|
+
${e.label?`<span class="sh-label">${ct(e.label)}</span>`:""}
|
|
1081
|
+
</div>
|
|
1082
|
+
${e.projectPath?`<div class="sd-project-path">${ct(e.projectPath)}</div>`:""}
|
|
1083
|
+
</div>
|
|
1084
|
+
|
|
1085
|
+
<div class="sd-section">
|
|
1086
|
+
<div class="sd-section-title">Overview</div>
|
|
1087
|
+
<div class="sd-info-grid">
|
|
1088
|
+
${this.infoRow("Source",`<span class="sd-source-label">${r}</span>`)}
|
|
1089
|
+
${e.model?this.infoRow("Model",`<code>${ct(e.model)}</code>`):""}
|
|
1090
|
+
${this.infoRow("Started",s.toLocaleString())}
|
|
1091
|
+
${this.infoRow("Ended",n.toLocaleString())}
|
|
1092
|
+
${this.infoRow("Duration",oe(e.durationMs))}
|
|
1093
|
+
${this.infoRow("Session ID",`<code class="sd-session-id" title="Click to copy">${e.rootSessionId.slice(0,20)}...</code>`)}
|
|
1094
|
+
</div>
|
|
1095
|
+
</div>
|
|
1096
|
+
|
|
1097
|
+
<div class="sd-section">
|
|
1098
|
+
<div class="sd-section-title">Cost & Tokens</div>
|
|
1099
|
+
<div class="sd-info-grid">
|
|
1100
|
+
${this.infoRow("Total Cost",`<span class="sd-cost">$${e.totalCost.toFixed(3)}</span>`)}
|
|
1101
|
+
${this.infoRow("Input Tokens",gt(e.totalInputTokens))}
|
|
1102
|
+
${this.infoRow("Output Tokens",gt(e.totalOutputTokens))}
|
|
1103
|
+
${this.infoRow("Cache Read",gt(e.totalCacheReadTokens))}
|
|
1104
|
+
${this.infoRow("Cache Created",gt(e.totalCacheCreationTokens))}
|
|
1105
|
+
${this.infoRow("Cache Hit",`${h.toFixed(1)}%`)}
|
|
1106
|
+
${this.infoRow("Tokens/min",gt(Math.round(d)))}
|
|
1107
|
+
</div>
|
|
1108
|
+
</div>
|
|
1109
|
+
|
|
1110
|
+
${e.agents.length>0?`
|
|
1111
|
+
<div class="sd-section">
|
|
1112
|
+
<div class="sd-section-title">Agents (${e.agents.length})</div>
|
|
1113
|
+
<div class="sd-agents-list">
|
|
1114
|
+
${e.agents.map(x=>this.renderAgent(x,b.has(x.agentId))).join("")}
|
|
1115
|
+
</div>
|
|
1116
|
+
</div>
|
|
1117
|
+
`:""}
|
|
1118
|
+
|
|
1119
|
+
${f.length>0?`
|
|
1120
|
+
<div class="sd-section">
|
|
1121
|
+
<div class="sd-section-title">Tool Usage (${e.totalToolUses} total)</div>
|
|
1122
|
+
<div class="sd-tool-list">
|
|
1123
|
+
${this.renderToolBars(f,g)}
|
|
1124
|
+
</div>
|
|
1125
|
+
</div>
|
|
1126
|
+
`:""}
|
|
1127
|
+
|
|
1128
|
+
${v.length>0?`
|
|
1129
|
+
<div class="sd-section">
|
|
1130
|
+
<div class="sd-section-title">Files (${v.length} unique)</div>
|
|
1131
|
+
<div class="sd-file-list">
|
|
1132
|
+
${v.slice(0,30).map(([x,C])=>{const $=this.shortenPath(x,e.projectPath);return`
|
|
1133
|
+
<div class="sd-file-row">
|
|
1134
|
+
<span class="sd-file-path" title="${Qt(x)}">${ct($)}</span>
|
|
1135
|
+
<span class="sd-file-counts">
|
|
1136
|
+
${C.readCount>0?`<span class="sd-file-read" title="Read ${C.readCount} times">R:${C.readCount}</span>`:""}
|
|
1137
|
+
${C.writeCount>0?`<span class="sd-file-write" title="Written ${C.writeCount} times">W:${C.writeCount}</span>`:""}
|
|
1138
|
+
</span>
|
|
1139
|
+
</div>
|
|
1140
|
+
`}).join("")}
|
|
1141
|
+
${v.length>30?`<div class="sd-file-more">+${v.length-30} more files</div>`:""}
|
|
1142
|
+
</div>
|
|
1143
|
+
</div>
|
|
1144
|
+
`:""}
|
|
1145
|
+
|
|
1146
|
+
${this.timeline.length>0?`
|
|
1147
|
+
<div class="sd-section">
|
|
1148
|
+
<div class="sd-section-title">Timeline (${this.timeline.length} events)</div>
|
|
1149
|
+
<div class="sd-timeline">
|
|
1150
|
+
${this.renderTimelineEvents(this.timeline,e.startedAt,x=>this.getAgentName(x))}
|
|
1151
|
+
</div>
|
|
1152
|
+
</div>
|
|
1153
|
+
`:""}
|
|
1154
|
+
`,this.bindAgentLinks(t),this.bindSessionIdCopy(t)}renderAgent(t,e){const s=kr(t),n=oe(t.endedAt-t.spawnedAt),o=t.totalInputTokens+t.totalOutputTokens;return`
|
|
1155
|
+
<div class="sd-agent-card">
|
|
1156
|
+
<div class="sd-agent-header">
|
|
1157
|
+
${e?`<a href="#" class="sd-agent-link" data-agent-id="${Qt(t.agentId)}" title="View in monitor">${ct(s)}</a>`:`<span class="sd-agent-name-text">${ct(s)}</span>`}
|
|
1158
|
+
<span class="sd-agent-role">${t.role.toUpperCase()}</span>
|
|
1159
|
+
</div>
|
|
1160
|
+
<div class="sd-agent-meta">
|
|
1161
|
+
${t.model?`<span>${ct(t.model)}</span>`:""}
|
|
1162
|
+
<span>$${t.cost.toFixed(3)}</span>
|
|
1163
|
+
<span>${t.toolUseCount} tools</span>
|
|
1164
|
+
<span>${gt(o)} tok</span>
|
|
1165
|
+
<span>${n}</span>
|
|
1166
|
+
</div>
|
|
1167
|
+
<div class="sd-agent-tokens">
|
|
1168
|
+
<span>${gt(t.totalInputTokens)} in</span>
|
|
1169
|
+
<span>${gt(t.totalOutputTokens)} out</span>
|
|
1170
|
+
<span>${gt(t.cacheReadTokens)} cached</span>
|
|
1171
|
+
</div>
|
|
1172
|
+
</div>
|
|
1173
|
+
`}renderTimelineEvents(t,e,s){return t.slice(-100).map(o=>{const r=oe(o.timestamp-e),l=s(o.agentId);switch(o.kind){case"tool":{const h=o.toolArgs?` ${ql(o.toolArgs,60)}`:"";return`<div class="sd-tl-event sd-tl-tool">
|
|
1174
|
+
<span class="sd-tl-time">${r}</span>
|
|
1175
|
+
<span class="sd-tl-agent">${ct(l)}</span>
|
|
1176
|
+
<span class="sd-tl-icon">🔧</span>
|
|
1177
|
+
<span class="sd-tl-tool-name">${ct(o.tool??"unknown")}</span>
|
|
1178
|
+
<span class="sd-tl-args">${ct(h)}</span>
|
|
1179
|
+
</div>`}case"spawn":return`<div class="sd-tl-event sd-tl-spawn">
|
|
1180
|
+
<span class="sd-tl-time">${r}</span>
|
|
1181
|
+
<span class="sd-tl-agent">${ct(l)}</span>
|
|
1182
|
+
<span class="sd-tl-icon">⚡</span> Spawned
|
|
1183
|
+
</div>`;case"shutdown":return`<div class="sd-tl-event sd-tl-shutdown">
|
|
1184
|
+
<span class="sd-tl-time">${r}</span>
|
|
1185
|
+
<span class="sd-tl-agent">${ct(l)}</span>
|
|
1186
|
+
<span class="sd-tl-icon">🛑</span> Shut down
|
|
1187
|
+
</div>`;case"idle":return`<div class="sd-tl-event sd-tl-idle">
|
|
1188
|
+
<span class="sd-tl-time">${r}</span>
|
|
1189
|
+
<span class="sd-tl-agent">${ct(l)}</span>
|
|
1190
|
+
<span class="sd-tl-icon">☕</span> Idle
|
|
1191
|
+
</div>`;case"zone-change":{const h=o.zone?Zt.get(o.zone):null;return`<div class="sd-tl-event sd-tl-zone">
|
|
1192
|
+
<span class="sd-tl-time">${r}</span>
|
|
1193
|
+
<span class="sd-tl-agent">${ct(l)}</span>
|
|
1194
|
+
<span class="sd-tl-icon">🚶</span> ${(h==null?void 0:h.icon)??""} ${(h==null?void 0:h.label)??o.zone??""}
|
|
1195
|
+
</div>`}case"tokens":return`<div class="sd-tl-event sd-tl-tokens">
|
|
1196
|
+
<span class="sd-tl-time">${r}</span>
|
|
1197
|
+
<span class="sd-tl-agent">${ct(l)}</span>
|
|
1198
|
+
<span class="sd-tl-icon">🎬</span> +${gt(o.inputTokens??0)} in / +${gt(o.outputTokens??0)} out
|
|
1199
|
+
</div>`;default:return""}}).join("")}renderToolBars(t,e){return t.map(([s,n])=>{const o=n/e*100;return`
|
|
1200
|
+
<div class="sd-tool-row">
|
|
1201
|
+
<span class="sd-tool-name">${ct(s)}</span>
|
|
1202
|
+
<div class="sd-tool-bar-track">
|
|
1203
|
+
<div class="sd-tool-bar-fill" style="width:${Math.max(2,o)}%"></div>
|
|
1204
|
+
</div>
|
|
1205
|
+
<span class="sd-tool-count">${n}</span>
|
|
1206
|
+
</div>
|
|
1207
|
+
`}).join("")}getAgentName(t){if(this.session){const e=this.session.agents.find(s=>s.agentId===t);if(e)return kr(e)}return Ss(t)}analyzeFiles(){const t={};for(const e of this.timeline){if(e.kind!=="tool"||!e.tool||!e.toolArgs)continue;const s=Wu.has(e.tool),n=Hu.has(e.tool);if(!s&&!n)continue;const o=e.toolArgs.match(/(?:file_path|path|file)["']?\s*[:=]\s*["']?([^\s"',}]+)/i);if(!o)continue;const r=o[1];t[r]||(t[r]={readCount:0,writeCount:0}),s?t[r].writeCount++:t[r].readCount++}return t}shortenPath(t,e){const s=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/").replace(/\/$/,"")+"/";return s.startsWith(n)?s.slice(n.length):s}infoRow(t,e){return`<div class="sd-info-row">
|
|
1208
|
+
<span class="sd-info-label">${t}</span>
|
|
1209
|
+
<span class="sd-info-value">${e}</span>
|
|
1210
|
+
</div>`}bindAgentLinks(t){t.querySelectorAll(".sd-agent-link").forEach(e=>{e.addEventListener("click",s=>{s.preventDefault();const n=e.dataset.agentId;n&&this._onNavigateToAgent&&this._onNavigateToAgent(n)})})}bindSessionIdCopy(t){t.querySelectorAll(".sd-session-id").forEach(e=>{e.addEventListener("click",()=>{var n,o;const s=((n=this.session)==null?void 0:n.rootSessionId)??((o=this.liveSession)==null?void 0:o.rootSessionId)??"";s&&navigator.clipboard.writeText(s).catch(()=>{})})})}dispose(){this.cleanupLiveListeners(),this.panelEl.remove()}}const Hb=["spawn","zone-change","tool-use","idle","shutdown","input-needed"],Ub={spawn:"Agent Spawn","zone-change":"Zone Change","tool-use":"Tool Use",idle:"Agent Idle",shutdown:"Agent Shutdown","input-needed":"Input Needed"},mn={masterVolume:.3,muted:!1,soundEvents:{spawn:!0,"zone-change":!0,"tool-use":!0,idle:!0,shutdown:!0,"input-needed":!0},soundVoices:{...Cr},browserNotifications:!0,costThreshold:5,showTrails:!1,showHeatmap:!0,showAgentNames:!0},Wa="settings";class qb{constructor(t){y(this,"contentEl");y(this,"containerEl");y(this,"isVisible",!1);y(this,"settings");y(this,"onChange",null);y(this,"soundManager",null);this.containerEl=t,this.settings=this.loadSettings(),this.contentEl=document.createElement("div"),this.contentEl.id="settings-content",this.contentEl.style.display="none",this.containerEl.appendChild(this.contentEl)}setSoundManager(t){this.soundManager=t}loadSettings(){const t=Rr(Wa,{});return{...mn,...t,soundEvents:{...mn.soundEvents,...t.soundEvents??{}},soundVoices:{...mn.soundVoices,...t.soundVoices??{}}}}save(){var t;In(Wa,this.settings),(t=this.onChange)==null||t.call(this,this.settings)}getSettings(){return this.settings}updateSetting(t,e){this.settings[t]!==e&&(this.settings[t]=e,In(Wa,this.settings),this.isVisible&&this.render())}setChangeHandler(t){this.onChange=t}show(){this.isVisible=!0,this.contentEl.style.display="",this.render()}hide(){this.isVisible=!1,this.contentEl.style.display="none"}render(){const t=this.settings;this.contentEl.innerHTML=`
|
|
1211
|
+
<div class="settings-panel">
|
|
1212
|
+
<!-- Sound -->
|
|
1213
|
+
<div class="settings-section">
|
|
1214
|
+
<h3 class="settings-section-title">
|
|
1215
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>
|
|
1216
|
+
Sound
|
|
1217
|
+
</h3>
|
|
1218
|
+
<div class="settings-row">
|
|
1219
|
+
<label class="settings-label">Master Volume</label>
|
|
1220
|
+
<div class="settings-control">
|
|
1221
|
+
<input type="range" id="s-volume" min="0" max="100" value="${Math.round(t.masterVolume*100)}" class="settings-slider" />
|
|
1222
|
+
<span class="settings-value" id="s-volume-val">${Math.round(t.masterVolume*100)}%</span>
|
|
1223
|
+
</div>
|
|
1224
|
+
</div>
|
|
1225
|
+
<div class="settings-row">
|
|
1226
|
+
<label class="settings-label">Mute All</label>
|
|
1227
|
+
<div class="settings-control">
|
|
1228
|
+
<label class="settings-toggle">
|
|
1229
|
+
<input type="checkbox" id="s-mute" ${t.muted?"checked":""} />
|
|
1230
|
+
<span class="settings-toggle-track"></span>
|
|
1231
|
+
</label>
|
|
1232
|
+
</div>
|
|
1233
|
+
</div>
|
|
1234
|
+
<div class="settings-sub-title">Sound Events</div>
|
|
1235
|
+
${Hb.map(e=>{const s=kl[e],n=t.soundVoices[e]||Cr[e];return`
|
|
1236
|
+
<div class="settings-sound-row">
|
|
1237
|
+
<label class="settings-toggle settings-sound-toggle">
|
|
1238
|
+
<input type="checkbox" data-sound="${e}" ${t.soundEvents[e]?"checked":""} />
|
|
1239
|
+
<span class="settings-toggle-track"></span>
|
|
1240
|
+
</label>
|
|
1241
|
+
<span class="settings-sound-label">${Ub[e]}</span>
|
|
1242
|
+
<select class="settings-voice-select" data-voice-event="${e}">
|
|
1243
|
+
${s.map(o=>`<option value="${o.id}" ${o.id===n?"selected":""}>${o.label}</option>`).join("")}
|
|
1244
|
+
</select>
|
|
1245
|
+
<button class="settings-preview-btn" data-preview="${e}" title="Preview sound">
|
|
1246
|
+
<svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
|
|
1247
|
+
</button>
|
|
1248
|
+
</div>
|
|
1249
|
+
`}).join("")}
|
|
1250
|
+
</div>
|
|
1251
|
+
|
|
1252
|
+
<!-- Notifications -->
|
|
1253
|
+
<div class="settings-section">
|
|
1254
|
+
<h3 class="settings-section-title">
|
|
1255
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"/></svg>
|
|
1256
|
+
Notifications
|
|
1257
|
+
</h3>
|
|
1258
|
+
<div class="settings-row">
|
|
1259
|
+
<div class="settings-label-group">
|
|
1260
|
+
<label class="settings-label">Browser Notifications</label>
|
|
1261
|
+
<span class="settings-hint">Show alerts when tab is in background</span>
|
|
1262
|
+
</div>
|
|
1263
|
+
<div class="settings-control">
|
|
1264
|
+
<label class="settings-toggle">
|
|
1265
|
+
<input type="checkbox" id="s-notif" ${t.browserNotifications?"checked":""} />
|
|
1266
|
+
<span class="settings-toggle-track"></span>
|
|
1267
|
+
</label>
|
|
1268
|
+
</div>
|
|
1269
|
+
</div>
|
|
1270
|
+
</div>
|
|
1271
|
+
|
|
1272
|
+
<!-- Cost Alerts -->
|
|
1273
|
+
<div class="settings-section">
|
|
1274
|
+
<h3 class="settings-section-title">
|
|
1275
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.78 0 2.44.85 2.5 2.1h2.21c-.07-1.72-1.12-3.3-3.21-3.81V3h-3v2.16c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-2.06 0-2.87-.92-2.98-2.1h-2.2c.12 2.19 1.76 3.42 3.68 3.83V21h3v-2.15c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"/></svg>
|
|
1276
|
+
Cost Alerts
|
|
1277
|
+
</h3>
|
|
1278
|
+
<div class="settings-row">
|
|
1279
|
+
<div class="settings-label-group">
|
|
1280
|
+
<label class="settings-label">Spend Threshold</label>
|
|
1281
|
+
<span class="settings-hint">Alert when total cost exceeds this amount</span>
|
|
1282
|
+
</div>
|
|
1283
|
+
<div class="settings-control">
|
|
1284
|
+
<span class="settings-input-prefix">$</span>
|
|
1285
|
+
<input type="number" id="s-threshold" value="${t.costThreshold}" min="0.1" step="0.5" class="settings-number" />
|
|
1286
|
+
</div>
|
|
1287
|
+
</div>
|
|
1288
|
+
</div>
|
|
1289
|
+
|
|
1290
|
+
<!-- Display -->
|
|
1291
|
+
<div class="settings-section">
|
|
1292
|
+
<h3 class="settings-section-title">
|
|
1293
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>
|
|
1294
|
+
Display
|
|
1295
|
+
</h3>
|
|
1296
|
+
<div class="settings-row">
|
|
1297
|
+
<div class="settings-label-group">
|
|
1298
|
+
<label class="settings-label">Agent Trails</label>
|
|
1299
|
+
<span class="settings-hint">Show movement trails behind agents</span>
|
|
1300
|
+
</div>
|
|
1301
|
+
<div class="settings-control">
|
|
1302
|
+
<label class="settings-toggle">
|
|
1303
|
+
<input type="checkbox" id="s-trails" ${t.showTrails?"checked":""} />
|
|
1304
|
+
<span class="settings-toggle-track"></span>
|
|
1305
|
+
</label>
|
|
1306
|
+
</div>
|
|
1307
|
+
</div>
|
|
1308
|
+
<div class="settings-row">
|
|
1309
|
+
<div class="settings-label-group">
|
|
1310
|
+
<label class="settings-label">Zone Heatmap</label>
|
|
1311
|
+
<span class="settings-hint">Overlay showing zone activity intensity</span>
|
|
1312
|
+
</div>
|
|
1313
|
+
<div class="settings-control">
|
|
1314
|
+
<label class="settings-toggle">
|
|
1315
|
+
<input type="checkbox" id="s-heatmap" ${t.showHeatmap?"checked":""} />
|
|
1316
|
+
<span class="settings-toggle-track"></span>
|
|
1317
|
+
</label>
|
|
1318
|
+
</div>
|
|
1319
|
+
</div>
|
|
1320
|
+
<div class="settings-row">
|
|
1321
|
+
<div class="settings-label-group">
|
|
1322
|
+
<label class="settings-label">Agent Names</label>
|
|
1323
|
+
<span class="settings-hint">Show name labels above agent sprites</span>
|
|
1324
|
+
</div>
|
|
1325
|
+
<div class="settings-control">
|
|
1326
|
+
<label class="settings-toggle">
|
|
1327
|
+
<input type="checkbox" id="s-names" ${t.showAgentNames?"checked":""} />
|
|
1328
|
+
<span class="settings-toggle-track"></span>
|
|
1329
|
+
</label>
|
|
1330
|
+
</div>
|
|
1331
|
+
</div>
|
|
1332
|
+
</div>
|
|
1333
|
+
|
|
1334
|
+
<div class="settings-footer">
|
|
1335
|
+
<button id="s-reset" class="settings-reset-btn">Reset to Defaults</button>
|
|
1336
|
+
</div>
|
|
1337
|
+
</div>
|
|
1338
|
+
`,this.bindEvents()}bindEvents(){const t=this.contentEl.querySelector("#s-volume"),e=this.contentEl.querySelector("#s-volume-val");t==null||t.addEventListener("input",()=>{const c=Number(t.value);e.textContent=`${c}%`,this.settings.masterVolume=c/100,this.save()});const s=this.contentEl.querySelector("#s-mute");s==null||s.addEventListener("change",()=>{this.settings.muted=s.checked,this.save()}),this.contentEl.querySelectorAll("[data-sound]").forEach(c=>{c.addEventListener("change",()=>{const f=c.dataset.sound;this.settings.soundEvents[f]=c.checked,this.save()})}),this.contentEl.querySelectorAll("[data-voice-event]").forEach(c=>{c.addEventListener("change",()=>{var g;const f=c.dataset.voiceEvent;this.settings.soundVoices[f]=c.value,this.save(),(g=this.soundManager)==null||g.preview(f,c.value)})}),this.contentEl.querySelectorAll("[data-preview]").forEach(c=>{c.addEventListener("click",()=>{var m;const f=c.dataset.preview,g=this.settings.soundVoices[f]||Cr[f];(m=this.soundManager)==null||m.preview(f,g),c.classList.add("settings-preview-active"),setTimeout(()=>c.classList.remove("settings-preview-active"),300)})});const n=this.contentEl.querySelector("#s-notif");n==null||n.addEventListener("change",()=>{this.settings.browserNotifications=n.checked,this.save()});const o=this.contentEl.querySelector("#s-threshold");o==null||o.addEventListener("change",()=>{this.settings.costThreshold=parseFloat(o.value)||5,this.save()});const r=this.contentEl.querySelector("#s-trails");r==null||r.addEventListener("change",()=>{this.settings.showTrails=r.checked,this.save()});const l=this.contentEl.querySelector("#s-heatmap");l==null||l.addEventListener("change",()=>{this.settings.showHeatmap=l.checked,this.save()});const h=this.contentEl.querySelector("#s-names");h==null||h.addEventListener("change",()=>{this.settings.showAgentNames=h.checked,this.save()});const d=this.contentEl.querySelector("#s-reset");d==null||d.addEventListener("click",()=>{this.settings={...mn,soundEvents:{...mn.soundEvents},soundVoices:{...mn.soundVoices}},this.save(),this.render()})}}async function Vb(){const i=document.getElementById("app"),t=await H0(i),e=new dl;C1();const s=new Lv(t),n=new t1(t,s,e),o=new Cl,r=new m1;n.setSoundManager(o),n.setNotificationManager(r);const l=new M1(e),h=new I1,d=new i1(e),c=new n1(e);d.setAgentClickHandler(Q=>{c.open(Q),qt(Q)}),n.setClickHandler(Q=>{c.open(Q),qt(Q)});const f=new $b(e);f.setFocusHandler(Q=>qt(Q)),f.setDetailHandler(Q=>{c.open(Q),qt(Q)}),n.setHoverHandler((Q,kt,It)=>{if(Q){const se=s.root,ko=kt*se.scale.x+se.x,op=It*se.scale.y+se.y,Yl=t.canvas.getBoundingClientRect();f.show(Q,ko+Yl.left,op+Yl.top)}else f.hide()});const g=new l1(e);g.setReplayCallback(Q=>{n.rebuildFromState(Q)});const m=new b1(e);let v=!0;const b=document.getElementById("right-panel-content"),_=document.getElementById("overlay"),x=document.getElementById("right-panel-title"),C=new T1(e,b),$=new H1(e,b),P=new db(e,b),H=new pb(e,b),R=new hb,O=new wb(e,b),et=new Tb(e,b),Z=new Lb(e,b),X=new Ob(b,e),J=new Gb,st=new Wb(e);X.setCompareHandler((Q,kt)=>{J.open(Q,kt)}),X.setOpenSessionHandler(Q=>{st.openRecorded(Q)}),X.setOpenLiveSessionHandler(Q=>{st.openLive(Q)}),st.setNavigateToAgentHandler(Q=>{st.close(),h.setActiveTab("monitor"),c.open(Q),qt(Q)});const it=new qb(b);it.setSoundManager(o);const ht=new fb(e),Dt=new vb(e),nt=new Al(e),rt=new B1,Ot=new R1(e);new D1;const lt=new O1;s.addEffect(lt.container);const wt=new G1(s.camera,(Q,kt)=>{s.camera.panTo(Q,kt)}),zt=new U1,_t=Q=>zt.getCustomDisplay(Q);n.setCustomizationLookup(_t),c.setCustomizationLookup(_t),d.setCustomizationLookup(_t),$.setCustomizationLookup(_t),C.setCustomizationLookup(_t),et.setCustomizationLookup(_t),Z.setCustomizationLookup(_t),O.setCustomizationLookup(_t),nt.setCustomizationLookup(_t),Dt.setCustomizationLookup(_t),g.setCustomizationLookup(_t),Ot.setCustomizationLookup(_t),zt.setChangeHandler((Q,kt)=>{n.applyCustomization(Q,kt.displayName,kt.colorIndex),c.currentAgentId===Q&&c.refreshHeader(kt.displayName),d.scheduleRender()}),c.setCustomizeHandler(Q=>{zt.open(Q)}),t.canvas.addEventListener("contextmenu",Q=>{Q.preventDefault()}),t.canvas.addEventListener("dblclick",Q=>{const kt=t.canvas.getBoundingClientRect(),It=Q.clientX-kt.left,se=Q.clientY-kt.top;R.addAnnotationFromScreen(It,se)});const pt=new cb;s.applyTheme(pt.current);const Wt=document.getElementById("theme-select");Wt.value=pt.current.id,Wt.addEventListener("change",()=>pt.setTheme(Wt.value)),pt.onChange(Q=>{s.applyTheme(Q),Wt.value=Q.id});let Ft=!1;function ae(){if(Ft&&n.focusedAgentId){const Q=n.getFocusedAgentName()||"Agent";l.showFocus(Q)}else l.hideFocus()}function qt(Q){n.setFocusAgent(Q),Ft=!0,ae()}function Te(){Ft=!1,n.setFocusAgent(null),ae()}let Ee=null;function Xe(){return Ee||(Ee=document.getElementById("zone-heatmap")),Ee}document.getElementById("focus-stop").addEventListener("click",Te);let hs=Rr("activeTab","monitor");const Ze={analytics:{show:()=>C.show(),hide:()=>C.hide(),title:"Analytics"},leaderboard:{show:()=>$.show(),hide:()=>$.hide(),title:"Leaderboard"},toolchain:{show:()=>P.show(),hide:()=>P.hide(),title:"Tool Chains"},taskgraph:{show:()=>H.show(),hide:()=>H.hide(),title:"Task Graph"},activity:{show:()=>O.show(),hide:()=>O.hide(),title:"Activity Feed"},waterfall:{show:()=>et.show(),hide:()=>et.hide(),title:"Waterfall"},graph:{show:()=>Z.show(),hide:()=>Z.hide(),title:"Agent Graph"},sessions:{show:()=>X.show(),hide:()=>X.hide(),title:"Sessions"},settings:{show:()=>it.show(),hide:()=>it.hide(),title:"Settings"}};function ds(Q){var kt;if(In("activeTab",Q),(kt=Ze[hs])==null||kt.hide(),hs=Q,st.isOpen()&&st.close(),Q==="monitor")_.style.display="",b.style.display="none",x.textContent="Agents";else{c.isOpen()&&c.close(),_.style.display="none",b.style.display="";const It=Ze[Q];x.textContent=(It==null?void 0:It.title)??Q,It==null||It.show()}}h.setTabChangeHandler(Q=>{ds(Q)}),hs!=="monitor"&&h.setActiveTab(hs),document.getElementById("right-panel");function ee(Q){h.setActiveTab(hs===Q?"monitor":Q)}function Ke(Q,kt){switch(Q){case"focus-zone":{const It=kt?Zt.get(kt):null;It&&s.camera.panTo(It.x+It.width/2,It.y+It.height/2);break}case"focus-agent":kt&&(c.open(kt),qt(kt));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,Bn();break;case"toggle-heatmap":v=!v;{const It=Xe();It&&(It.style.display=v?"block":"none")}break;case"toggle-shortcuts":rt.toggle();break;case"toggle-focus":Ft?Te():(n.cycleNextAgent(),Ft=!!n.focusedAgentId,ae());break;case"cycle-focus":Ft?n.cycleNextAgent()||Te():(n.cycleNextAgent(),Ft=!!n.focusedAgentId),ae();break;case"exit-focus":Ft&&Te();break;case"session-export":Ot.toggle();break;case"toggle-trails":lt.toggle();break;case"toggle-daynight":s.dayNight.toggle();break;case"toggle-minimap":wt.toggle();break;case"cycle-theme":pt.cycleNext();break;case"toggle-annotations":R.toggle();break;case"toggle-sidebar":h.toggle();break;case"toggle-analytics":ee("analytics");break;case"toggle-leaderboard":ee("leaderboard");break;case"toggle-toolchain":ee("toolchain");break;case"toggle-taskgraph":ee("taskgraph");break;case"toggle-activity":ee("activity");break;case"toggle-waterfall":ee("waterfall");break;case"toggle-graph":ee("graph");break;case"toggle-sessions":ee("sessions");break;case"toggle-settings":ee("settings");break}}const To=new _1(e,Ke);To.setCustomizationLookup(_t),e.on("agent:shutdown",Q=>{lt.removeAgent(Q)});const Pn=new q0(e);Pn.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 Ln=document.getElementById("mute-btn"),$n=document.getElementById("volume-slider");function Bn(){Ln.textContent=o.muted||o.volume===0?"🔇":"🔈",Ln.classList.toggle("muted",o.muted||o.volume===0)}Ln.addEventListener("click",()=>{o.init(),o.muted=!o.muted,Bn(),it.updateSetting("muted",o.muted)}),$n.addEventListener("input",()=>{o.init(),o.volume=Number($n.value)/100,o.muted&&o.volume>0&&(o.muted=!1),Bn(),it.updateSetting("masterVolume",o.volume),o.muted||it.updateSetting("muted",!1)});const Qe=it.getSettings();if(o.volume=Qe.masterVolume,o.muted=Qe.muted,$n.value=String(Math.round(Qe.masterVolume*100)),Bn(),o.setEnabledEvents(Qe.soundEvents),o.setVoices(Qe.soundVoices),r.enabled=Qe.browserNotifications,C.setCostThreshold(Qe.costThreshold),Qe.showTrails&<.toggle(),v=Qe.showHeatmap,!v){const Q=Xe();Q&&(Q.style.display="none")}n.setShowNames(Qe.showAgentNames),it.setChangeHandler(Q=>{o.volume=Q.masterVolume,o.muted=Q.muted,o.setEnabledEvents(Q.soundEvents),o.setVoices(Q.soundVoices),$n.value=String(Math.round(Q.masterVolume*100)),Bn(),r.enabled=Q.browserNotifications,C.setCostThreshold(Q.costThreshold),Q.showTrails!==lt.enabled&<.toggle(),v=Q.showHeatmap;{const kt=Xe();kt&&(kt.style.display=v?"block":"none")}n.setShowNames(Q.showAgentNames)});const jl=document.getElementById("notif-btn");jl.appendChild(Dt.getBadgeElement()),jl.addEventListener("click",()=>{Dt.toggle()}),document.getElementById("shortcuts-btn").addEventListener("click",()=>{rt.toggle()}),document.getElementById("cmd-hint").addEventListener("click",()=>{To.toggle()}),document.addEventListener("click",()=>{o.init(),r.requestPermission()},{once:!0});const np={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",s:"toggle-sessions","[":"toggle-sidebar",S:"toggle-settings"};document.addEventListener("keydown",Q=>{var se;const kt=(se=Q.target)==null?void 0:se.tagName;if(kt==="INPUT"||kt==="TEXTAREA"||kt==="SELECT"||Q.ctrlKey||Q.metaKey||Q.altKey)return;const It=np[Q.key];It&&Ke(It)}),window.addEventListener("beforeunload",()=>{Pn.disconnect(),n.dispose(),d.dispose(),c.dispose(),g.dispose(),C.dispose(),$.dispose(),l.dispose(),nt.dispose(),Dt.dispose(),ht.dispose(),et.destroy(),O.destroy(),X.dispose(),st.dispose(),J.dispose(),wt.dispose(),e.dispose()}),t.ticker.add(()=>{const Q=t.ticker.deltaMS;n.update(Q),s.update(Q);const kt=s.root;if(v&&m.updateTransform(kt.x,kt.y,kt.scale.x),R.updateTransform(kt.x,kt.y,kt.scale.x),Ft){const It=n.getFocusedAgentPosition();It&&s.camera.smoothFollow(It.x,It.y)}if(lt.enabled){const It=new Map;for(const se of n.getAgentPositions()){const ko=ft[se.colorIndex%ft.length];It.set(se.id,ko.body),lt.recordPosition(se.id,se.x,se.y,Q,ko.body)}lt.update(Q,It)}if(wt.visible){const It=s.camera.getViewport(),se=n.getAgentPositions();wt.render(se,It)}}),console.log("AgentMove started")}Vb().catch(console.error);export{Ir as $,lu as A,bo as B,Jt as C,Be as D,cs as E,ks as F,Lr as G,Ll as H,ou as I,He as J,Qd as K,al as L,Tt as M,Um as N,Vm as O,ye as P,Jm as Q,Za as R,$l as S,Bt as T,vr as U,Zm as V,xp as W,sg as X,Ae as Y,kd as Z,We as _,tu as a,hc as a0,tn as a1,D0 as a2,Jp as a3,uc as a4,qr as a5,pc as a6,ef as a7,An as a8,Xt as a9,Ed as aa,o0 as ab,cu as ac,Mt as ad,xo as ae,jt as af,om as ag,tm as ah,Cm as ai,bm as aj,qm as ak,jm as al,tg as am,Qm as an,eg as ao,Yd as b,gm as c,ke as d,Yt as e,Rt as f,kf as g,or as h,bt as i,Ht as j,yg as k,cg as l,Ad as m,Br as n,zd as o,Kt as p,wn as q,Dp as r,$r as s,Nt as t,Df as u,pm as v,Se as w,So as x,Ac as y,rr as z};
|