@nxuss/lemma 0.5.9 → 0.6.1
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/README.md +20 -6
- package/dashboard/dist/assets/{index-0N21ZtpO.js → index-BJzMIGrT.js} +2 -2
- package/dashboard/dist/assets/{index-0N21ZtpO.js.map → index-BJzMIGrT.js.map} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/cjs/cli/lemma-proxy.d.ts.map +1 -1
- package/dist/cjs/cli/lemma-proxy.js +311 -39
- package/dist/cjs/cli/lemma-proxy.js.map +1 -1
- package/dist/cjs/mcp/index.js +276 -0
- package/dist/cjs/mcp/index.js.map +1 -1
- package/dist/cjs/utils/ContextSqueezer.d.ts +4 -0
- package/dist/cjs/utils/ContextSqueezer.d.ts.map +1 -1
- package/dist/cjs/utils/ContextSqueezer.js +35 -1
- package/dist/cjs/utils/ContextSqueezer.js.map +1 -1
- package/dist/esm/cli/lemma-proxy.d.ts.map +1 -1
- package/dist/esm/cli/lemma-proxy.js +311 -39
- package/dist/esm/cli/lemma-proxy.js.map +1 -1
- package/dist/esm/mcp/index.js +276 -0
- package/dist/esm/mcp/index.js.map +1 -1
- package/dist/esm/utils/ContextSqueezer.d.ts +4 -0
- package/dist/esm/utils/ContextSqueezer.d.ts.map +1 -1
- package/dist/esm/utils/ContextSqueezer.js +34 -1
- package/dist/esm/utils/ContextSqueezer.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 🧠 Lemma v0.
|
|
1
|
+
# 🧠 Lemma v0.6.1
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@nxuss/lemma)
|
|
4
4
|
[](https://github.com/Nxusbets/lemma/blob/main/LICENSE)
|
|
@@ -25,8 +25,20 @@ Lemma is a high-performance orchestration layer that sits between your developme
|
|
|
25
25
|
### 🖥️ Real-Time Telemetry & Time-Travel Dashboard
|
|
26
26
|
**Full Observability & Interactive Debugging.** Spin up a gorgeous React-based dashboard at `http://localhost:8081/dashboard/` to monitor your entire AI workflow. View real-time charts of cost savings, token compactions, and cache hits. Walk through complex multi-agent conversations step-by-step using a time-travel slider, select and inspect active agent states, and export detailed telemetry audits instantly.
|
|
27
27
|
|
|
28
|
-
###
|
|
29
|
-
**
|
|
28
|
+
### 🛸 Kiro/Cursor Composer Bypass (Pro Option) 💎
|
|
29
|
+
**Autonomous Multi-File Editing For Free.** Exposes `write_workspace_file`, smart `apply_workspace_patch` (smart search-and-replace patching), and sandbox terminal tool `run_workspace_command` (compile/lint check) to Cursor's standard chat or Claude Desktop via MCP. Any standard free chat instantly acts as a fully-featured, unlimited autonomous multi-file Composer without needing a premium Kiro/Cursor Pro subscription.
|
|
30
|
+
|
|
31
|
+
### 🌌 AST Time-Travel Telemetry: El Multiverso de Código (Pro Option) 💎
|
|
32
|
+
**Regressive Error Debugging & Time-Travel.** Spawns a background recursive file watcher that debounces filesystem edits and calculates incremental AST diffs on every save. Merges active compiler crash logs to package a chronologically ordered time-traveling timeline resource (`lemma://multiverse/timeline`) so your LLM agents can inspect past codebase states and regressions instantly when you say "It broke".
|
|
33
|
+
|
|
34
|
+
### 🗺️ Zero-Shot Project Onboarding (Pro Option) 💎
|
|
35
|
+
**One-Shot Architecture Map.** Exposes a dynamic onboard resource (`lemma://project/onboarding`) that scans package files, folders, and key directory markers to compile a beautiful, structured markdown guide of your codebase's stack, directory layouts, and design principles so the LLM gets fully onboarded in a single shot.
|
|
36
|
+
|
|
37
|
+
### 🧠 Cross-Project Bug Telepathy (Pro Option) 💎
|
|
38
|
+
**Global Developer Hive Mind.** Lemma dynamically scans and queries vector memory indexes of all other local projects on your computer. If you solved a compiler issue or technical blocker in a different workspace last week, Lemma will telepathically inject that high-confidence solution to the current project's chat without you typing a single word.
|
|
39
|
+
|
|
40
|
+
### ✂️ Codebase Context Squeezer & Log Collapsing
|
|
41
|
+
**Massive Speedups & Zero Token Waste.** Get instant model responses and make your context windows go up to 10x further. Lemma dynamically squeezes outgoing codebase payloads, strips comments/whitespaces, and collapses repetitive console logs or redundant compiler stack traces, saving up to 95% on token consumption automatically.
|
|
30
42
|
|
|
31
43
|
### 🛸 Local Cache-Augmented Response Synthesis (CARS)
|
|
32
44
|
**Zero-Cost Answer Synthesis.** Experience instantaneous responses for questions similar to what you've asked before—without hitting the cloud or spending a single penny on API tokens. Lemma automatically refines past knowledge to answer your current questions in under a second, keeping your work completely private and free of charge.
|
|
@@ -141,8 +153,10 @@ Create or edit `lemma.config.json` in your project root to disable or fine-tune
|
|
|
141
153
|
| **Privacy Firewall** | ✅ Included | ✅ Advanced Masking |
|
|
142
154
|
| **Complexity Router** | ✅ Included | ✅ Custom Routing Policies |
|
|
143
155
|
| **Caching** | Exact Match | **Semantic Memory** |
|
|
144
|
-
| **Hive Mind** | Local Only | **Cloud Sync (Team Memory)
|
|
145
|
-
| **
|
|
156
|
+
| **Hive Mind** | Local Only | **Cloud Sync (Team Memory) + Cross-Project Telepathy 💎** |
|
|
157
|
+
| **AST Time-Travel Telemetry** | ❌ None | **Codebase Multiverse (Cap 10 AST Snapshots) 💎** |
|
|
158
|
+
| **Kiro/Cursor Composer Bypass** | ❌ None | **Smart Patches & Sandbox Terminal MCP 💎** |
|
|
159
|
+
| **Zero-Shot Onboarding Guide** | ❌ None | **Codebase Architecture Map MCP 💎** |
|
|
146
160
|
| **Telemetry Dashboard** | Basic Stats | **Time-Travel Debugger & 60fps Graph** |
|
|
147
161
|
| **Limits** | 300 requests/mo | **Unlimited Agentic Power** |
|
|
148
162
|
|
|
@@ -160,7 +174,7 @@ You don't need to change your habits. Just point your tool's "Base URL" to Lemma
|
|
|
160
174
|
* **Custom Apps:** Replace `https://api.openai.com/v1` with `http://localhost:8081/v1` in your SDK initialization.
|
|
161
175
|
|
|
162
176
|
### 💎 Pro Integration (Model Context Protocol - MCP)
|
|
163
|
-
For **Lemma Pro** users, you can expose Lemma's entire intelligence layer (Privacy Firewall, Semantic Brain Search, and Auto-Heal) directly as native tools using the **Model Context Protocol (MCP)**.
|
|
177
|
+
For **Lemma Pro** users, you can expose Lemma's entire intelligence layer (Privacy Firewall, Semantic Brain Search, and Auto-Heal, plus the new Composer Bypass Suite, AST Timeline, and Zero-Shot Onboarding Map) directly as native tools using the **Model Context Protocol (MCP)**. This lets the LLM read, search, write, patch, and compile files in your workspace autonomously.
|
|
164
178
|
|
|
165
179
|
#### 🟢 Cursor:
|
|
166
180
|
1. Go to **Settings > Features > MCP**.
|
|
@@ -405,7 +405,7 @@ to {
|
|
|
405
405
|
* This source code is licensed under the MIT license found in the
|
|
406
406
|
* LICENSE file in the root directory of this source tree.
|
|
407
407
|
*/var Qc=j,C$=T$;function N$(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var M$=typeof Object.is=="function"?Object.is:N$,I$=C$.useSyncExternalStore,D$=Qc.useRef,R$=Qc.useEffect,L$=Qc.useMemo,B$=Qc.useDebugValue;B_.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var o=D$(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=L$(function(){function l(p){if(!u){if(u=!0,f=p,p=n(p),i!==void 0&&a.hasValue){var h=a.value;if(i(h,p))return c=h}return c=p}if(h=c,M$(f,p))return h;var m=n(p);return i!==void 0&&i(h,m)?(f=p,h):(f=p,c=m)}var u=!1,f,c,d=r===void 0?null:r;return[function(){return l(t())},d===null?void 0:function(){return l(d())}]},[t,r,n,i]);var s=I$(e,o[0],o[1]);return R$(function(){a.hasValue=!0,a.value=s},[s]),B$(s),s};L_.exports=B_;var z$=L_.exports;const F$=me(z$),U_={},{useDebugValue:U$}=E,{useSyncExternalStoreWithSelector:W$}=F$;let s0=!1;const H$=e=>e;function V$(e,t=H$,r){(U_?"production":void 0)!=="production"&&r&&!s0&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),s0=!0);const n=W$(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return U$(n),n}const q$=e=>{(U_?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?w$(e):e,r=(n,i)=>V$(t,n,i);return Object.assign(r,t),r},K$=e=>q$;var W_=Symbol.for("immer-nothing"),l0=Symbol.for("immer-draftable"),Nt=Symbol.for("immer-state");function cr(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var es=Object.getPrototypeOf;function co(e){return!!e&&!!e[Nt]}function ci(e){var t;return e?H_(e)||Array.isArray(e)||!!e[l0]||!!((t=e.constructor)!=null&&t[l0])||qs(e)||Jc(e):!1}var G$=Object.prototype.constructor.toString(),u0=new WeakMap;function H_(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(r===Object)return!0;if(typeof r!="function")return!1;let n=u0.get(r);return n===void 0&&(n=Function.toString.call(r),u0.set(r,n)),n===G$}function ju(e,t,r=!0){Zc(e)===0?(r?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((n,i)=>t(i,n,e))}function Zc(e){const t=e[Nt];return t?t.type_:Array.isArray(e)?1:qs(e)?2:Jc(e)?3:0}function Qp(e,t){return Zc(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function V_(e,t,r){const n=Zc(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function X$(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qs(e){return e instanceof Map}function Jc(e){return e instanceof Set}function Wn(e){return e.copy_||e.base_}function Zp(e,t){if(qs(e))return new Map(e);if(Jc(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=H_(e);if(t===!0||t==="class_only"&&!r){const n=Object.getOwnPropertyDescriptors(e);delete n[Nt];let i=Reflect.ownKeys(n);for(let o=0;o<i.length;o++){const a=i[o],s=n[a];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(n[a]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[a]})}return Object.create(es(e),n)}else{const n=es(e);if(n!==null&&r)return{...e};const i=Object.create(n);return Object.assign(i,e)}}function Cy(e,t=!1){return ef(e)||co(e)||!ci(e)||(Zc(e)>1&&Object.defineProperties(e,{set:_l,add:_l,clear:_l,delete:_l}),Object.freeze(e),t&&Object.values(e).forEach(r=>Cy(r,!0))),e}function Y$(){cr(2)}var _l={value:Y$};function ef(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var Q$={};function fi(e){const t=Q$[e];return t||cr(0,e),t}var ts;function q_(){return ts}function Z$(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function c0(e,t){t&&(fi("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Jp(e){eh(e),e.drafts_.forEach(J$),e.drafts_=null}function eh(e){e===ts&&(ts=e.parent_)}function f0(e){return ts=Z$(ts,e)}function J$(e){const t=e[Nt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function d0(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[Nt].modified_&&(Jp(t),cr(4)),ci(e)&&(e=$u(t,e),t.parent_||Tu(t,e)),t.patches_&&fi("Patches").generateReplacementPatches_(r[Nt].base_,e,t.patches_,t.inversePatches_)):e=$u(t,r,[]),Jp(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==W_?e:void 0}function $u(e,t,r){if(ef(t))return t;const n=e.immer_.shouldUseStrictIteration(),i=t[Nt];if(!i)return ju(t,(o,a)=>p0(e,i,t,o,a,r),n),t;if(i.scope_!==e)return t;if(!i.modified_)return Tu(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const o=i.copy_;let a=o,s=!1;i.type_===3&&(a=new Set(o),o.clear(),s=!0),ju(a,(l,u)=>p0(e,i,o,l,u,r,s),n),Tu(e,o,!1),r&&e.patches_&&fi("Patches").generatePatches_(i,r,e.patches_,e.inversePatches_)}return i.copy_}function p0(e,t,r,n,i,o,a){if(i==null||typeof i!="object"&&!a)return;const s=ef(i);if(!(s&&!a)){if(co(i)){const l=o&&t&&t.type_!==3&&!Qp(t.assigned_,n)?o.concat(n):void 0,u=$u(e,i,l);if(V_(r,n,u),co(u))e.canAutoFreeze_=!1;else return}else a&&r.add(i);if(ci(i)&&!s){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[n]===i&&s)return;$u(e,i),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&(qs(r)?r.has(n):Object.prototype.propertyIsEnumerable.call(r,n))&&Tu(e,i)}}}function Tu(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Cy(t,r)}function eT(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:q_(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,o=Ny;r&&(i=[n],o=rs);const{revoke:a,proxy:s}=Proxy.revocable(i,o);return n.draft_=s,n.revoke_=a,s}var Ny={get(e,t){if(t===Nt)return e;const r=Wn(e);if(!Qp(r,t))return tT(e,r,t);const n=r[t];return e.finalized_||!ci(n)?n:n===xd(e.base_,t)?(wd(e),e.copy_[t]=rh(n,e)):n},has(e,t){return t in Wn(e)},ownKeys(e){return Reflect.ownKeys(Wn(e))},set(e,t,r){const n=K_(Wn(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const i=xd(Wn(e),t),o=i==null?void 0:i[Nt];if(o&&o.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(X$(r,i)&&(r!==void 0||Qp(e.base_,t)))return!0;wd(e),th(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return xd(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,wd(e),th(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=Wn(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){cr(11)},getPrototypeOf(e){return es(e.base_)},setPrototypeOf(){cr(12)}},rs={};ju(Ny,(e,t)=>{rs[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});rs.deleteProperty=function(e,t){return rs.set.call(this,e,t,void 0)};rs.set=function(e,t,r){return Ny.set.call(this,e[0],t,r,e[0])};function xd(e,t){const r=e[Nt];return(r?Wn(r):e)[t]}function tT(e,t,r){var i;const n=K_(t,r);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(e.draft_):void 0}function K_(e,t){if(!(t in e))return;let r=es(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=es(r)}}function th(e){e.modified_||(e.modified_=!0,e.parent_&&th(e.parent_))}function wd(e){e.copy_||(e.copy_=Zp(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var rT=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){const o=r;r=t;const a=this;return function(l=o,...u){return a.produce(l,f=>r.call(this,f,...u))}}typeof r!="function"&&cr(6),n!==void 0&&typeof n!="function"&&cr(7);let i;if(ci(t)){const o=f0(this),a=rh(t,void 0);let s=!0;try{i=r(a),s=!1}finally{s?Jp(o):eh(o)}return c0(o,n),d0(i,o)}else if(!t||typeof t!="object"){if(i=r(t),i===void 0&&(i=t),i===W_&&(i=void 0),this.autoFreeze_&&Cy(i,!0),n){const o=[],a=[];fi("Patches").generateReplacementPatches_(t,i,o,a),n(o,a)}return i}else cr(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(a,...s)=>this.produceWithPatches(a,l=>t(l,...s));let n,i;return[this.produce(t,r,(a,s)=>{n=a,i=s}),n,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ci(e)||cr(8),co(e)&&(e=nT(e));const t=f0(this),r=rh(e,void 0);return r[Nt].isManual_=!0,eh(t),r}finishDraft(e,t){const r=e&&e[Nt];(!r||!r.isManual_)&&cr(9);const{scope_:n}=r;return c0(n,t),d0(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const i=t[r];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}r>-1&&(t=t.slice(r+1));const n=fi("Patches").applyPatches_;return co(e)?n(e,t):this.produce(e,i=>n(i,t))}};function rh(e,t){const r=qs(e)?fi("MapSet").proxyMap_(e,t):Jc(e)?fi("MapSet").proxySet_(e,t):eT(e,t);return(t?t.scope_:q_()).drafts_.push(r),r}function nT(e){return co(e)||cr(10,e),G_(e)}function G_(e){if(!ci(e)||ef(e))return e;const t=e[Nt];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Zp(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=Zp(e,!0);return ju(r,(i,o)=>{V_(r,i,G_(o))},n),t&&(t.finalized_=!1),r}var iT=new rT,oT=iT.produce;const aT=e=>(t,r,n)=>(n.setState=(i,o,...a)=>{const s=typeof i=="function"?oT(i):i;return t(s,o,...a)},e(n.setState,r,n)),sT=aT,lT=()=>{if(typeof window>"u")return 5;try{const e=window.localStorage.getItem("dashboardSettings");if(!e)return 5;const t=JSON.parse(e),r=Number(t.refreshIntervalSeconds??t.refreshInterval??5);return Number.isFinite(r)?Math.min(30,Math.max(2,r)):5}catch{return 5}},h0={metrics:null,isLoadingMetrics:!1,metricsError:null,agents:[],selectedAgentId:null,isLoadingAgents:!1,events:[],eventFilter:"all",eventPage:1,eventPageSize:50,totalEvents:0,topQueries:[],isLoadingCacheStats:!1,isConnected:!1,connectionStatus:"idle",isPaused:!1,selectedEventId:null,debuggerState:null,showDebugger:!1,activeSidePanel:"agents",refreshIntervalSeconds:lT(),searchQuery:"",searchResults:[],isSearching:!1,savingsBreakdown:null},fe=K$()(sT(e=>({...h0,setMetrics:t=>{e(r=>{r.metrics=t,r.isLoadingMetrics=!1,r.metricsError=null})},setMetricsLoading:t=>{e(r=>{r.isLoadingMetrics=t})},setMetricsError:t=>{e(r=>{r.metricsError=t})},setAgents:t=>{e(r=>{r.agents=t,r.isLoadingAgents=!1})},setSelectedAgent:t=>{e(r=>{r.selectedAgentId=t})},addAgent:t=>{e(r=>{r.agents.find(i=>i.id===t.id)||r.agents.push(t)})},removeAgent:t=>{e(r=>{r.agents=r.agents.filter(n=>n.id!==t),r.selectedAgentId===t&&(r.selectedAgentId=null)})},setEvents:t=>{e(r=>{r.events=t})},addEvent:t=>{e(r=>{r.events.unshift(t),r.events.length>1e3&&r.events.pop()})},setEventFilter:t=>{e(r=>{r.eventFilter=t==="all"?"all":t,r.eventPage=1})},setEventPage:t=>{e(r=>{r.eventPage=t})},setTotalEvents:t=>{e(r=>{r.totalEvents=t})},setTopQueries:t=>{e(r=>{r.topQueries=t,r.isLoadingCacheStats=!1})},setConnected:t=>{e(r=>{r.isConnected=t})},setConnectionStatus:t=>{e(r=>{r.connectionStatus=t})},setPaused:t=>{e(r=>{r.isPaused=t})},setSelectedEvent:t=>{e(r=>{r.selectedEventId=t})},setDebuggerState:t=>{e(r=>{r.debuggerState=t})},setShowDebugger:t=>{e(r=>{r.showDebugger=t})},setActiveSidePanel:t=>{e(r=>{r.activeSidePanel=t})},setRefreshIntervalSeconds:t=>{e(r=>{r.refreshIntervalSeconds=Math.min(30,Math.max(2,t))})},setSearchQuery:t=>{e(r=>{r.searchQuery=t})},setSearchResults:t=>{e(r=>{r.searchResults=t,r.isSearching=!1})},setIsSearching:t=>{e(r=>{r.isSearching=t})},setSavingsBreakdown:t=>{e(r=>{r.savingsBreakdown=t})},reset:()=>{e(()=>h0)}}))),kr=Object.create(null);kr.open="0";kr.close="1";kr.ping="2";kr.pong="3";kr.message="4";kr.upgrade="5";kr.noop="6";const Jl=Object.create(null);Object.keys(kr).forEach(e=>{Jl[kr[e]]=e});const nh={type:"error",data:"parser error"},X_=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Y_=typeof ArrayBuffer=="function",Q_=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,My=({type:e,data:t},r,n)=>X_&&t instanceof Blob?r?n(t):m0(t,n):Y_&&(t instanceof ArrayBuffer||Q_(t))?r?n(t):m0(new Blob([t]),n):n(kr[e]+(t||"")),m0=(e,t)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];t("b"+(n||""))},r.readAsDataURL(e)};function y0(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Sd;function uT(e,t){if(X_&&e.data instanceof Blob)return e.data.arrayBuffer().then(y0).then(t);if(Y_&&(e.data instanceof ArrayBuffer||Q_(e.data)))return t(y0(e.data));My(e,!1,r=>{Sd||(Sd=new TextEncoder),t(Sd.encode(r))})}const v0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wa=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<v0.length;e++)wa[v0.charCodeAt(e)]=e;const cT=e=>{let t=e.length*.75,r=e.length,n,i=0,o,a,s,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),f=new Uint8Array(u);for(n=0;n<r;n+=4)o=wa[e.charCodeAt(n)],a=wa[e.charCodeAt(n+1)],s=wa[e.charCodeAt(n+2)],l=wa[e.charCodeAt(n+3)],f[i++]=o<<2|a>>4,f[i++]=(a&15)<<4|s>>2,f[i++]=(s&3)<<6|l&63;return u},fT=typeof ArrayBuffer=="function",Iy=(e,t)=>{if(typeof e!="string")return{type:"message",data:Z_(e,t)};const r=e.charAt(0);return r==="b"?{type:"message",data:dT(e.substring(1),t)}:Jl[r]?e.length>1?{type:Jl[r],data:e.substring(1)}:{type:Jl[r]}:nh},dT=(e,t)=>{if(fT){const r=cT(e);return Z_(r,t)}else return{base64:!0,data:e}},Z_=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},J_="",pT=(e,t)=>{const r=e.length,n=new Array(r);let i=0;e.forEach((o,a)=>{My(o,!1,s=>{n[a]=s,++i===r&&t(n.join(J_))})})},hT=(e,t)=>{const r=e.split(J_),n=[];for(let i=0;i<r.length;i++){const o=Iy(r[i],t);if(n.push(o),o.type==="error")break}return n};function mT(){return new TransformStream({transform(e,t){uT(e,r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,n)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(r)})}})}let _d;function Ol(e){return e.reduce((t,r)=>t+r.length,0)}function Pl(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let i=0;i<t;i++)r[i]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function yT(e,t){_d||(_d=new TextDecoder);const r=[];let n=0,i=-1,o=!1;return new TransformStream({transform(a,s){for(r.push(a);;){if(n===0){if(Ol(r)<1)break;const l=Pl(r,1);o=(l[0]&128)===128,i=l[0]&127,i<126?n=3:i===126?n=1:n=2}else if(n===1){if(Ol(r)<2)break;const l=Pl(r,2);i=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),n=3}else if(n===2){if(Ol(r)<8)break;const l=Pl(r,8),u=new DataView(l.buffer,l.byteOffset,l.length),f=u.getUint32(0);if(f>Math.pow(2,21)-1){s.enqueue(nh);break}i=f*Math.pow(2,32)+u.getUint32(4),n=3}else{if(Ol(r)<i)break;const l=Pl(r,i);s.enqueue(Iy(o?l:_d.decode(l),t)),n=0}if(i===0||i>e){s.enqueue(nh);break}}}})}const eO=4;function Le(e){if(e)return vT(e)}function vT(e){for(var t in Le.prototype)e[t]=Le.prototype[t];return e}Le.prototype.on=Le.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Le.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};Le.prototype.off=Le.prototype.removeListener=Le.prototype.removeAllListeners=Le.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,i=0;i<r.length;i++)if(n=r[i],n===t||n.fn===t){r.splice(i,1);break}return r.length===0&&delete this._callbacks["$"+e],this};Le.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,i=r.length;n<i;++n)r[n].apply(this,t)}return this};Le.prototype.emitReserved=Le.prototype.emit;Le.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Le.prototype.hasListeners=function(e){return!!this.listeners(e).length};const tf=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,r)=>r(t,0),Wt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),gT="arraybuffer";function tO(e,...t){return t.reduce((r,n)=>(e.hasOwnProperty(n)&&(r[n]=e[n]),r),{})}const bT=Wt.setTimeout,xT=Wt.clearTimeout;function rf(e,t){t.useNativeTimers?(e.setTimeoutFn=bT.bind(Wt),e.clearTimeoutFn=xT.bind(Wt)):(e.setTimeoutFn=Wt.setTimeout.bind(Wt),e.clearTimeoutFn=Wt.clearTimeout.bind(Wt))}const wT=1.33;function ST(e){return typeof e=="string"?_T(e):Math.ceil((e.byteLength||e.size)*wT)}function _T(e){let t=0,r=0;for(let n=0,i=e.length;n<i;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}function rO(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function OT(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function PT(e){let t={},r=e.split("&");for(let n=0,i=r.length;n<i;n++){let o=r[n].split("=");t[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return t}class AT extends Error{constructor(t,r,n){super(t),this.description=r,this.context=n,this.type="TransportError"}}class Dy extends Le{constructor(t){super(),this.writable=!1,rf(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,r,n){return super.emitReserved("error",new AT(t,r,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const r=Iy(t,this.socket.binaryType);this.onPacket(r)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,r={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const r=OT(t);return r.length?"?"+r:""}}class ET extends Dy{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const r=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};hT(t,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,pT(t,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=rO()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(t,r)}}let nO=!1;try{nO=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const kT=nO;function jT(){}class $T extends ET{constructor(t){if(super(t),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||n!==t.port}}doWrite(t,r){const n=this.request({method:"POST",data:t});n.on("success",r),n.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=t}}class Pr extends Le{constructor(t,r,n){super(),this.createRequest=t,rf(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var t;const r=tO(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&n.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var i;n.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=Pr.requestsCount++,Pr.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=jT,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Pr.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Pr.requestsCount=0;Pr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",g0);else if(typeof addEventListener=="function"){const e="onpagehide"in Wt?"pagehide":"unload";addEventListener(e,g0,!1)}}function g0(){for(let e in Pr.requests)Pr.requests.hasOwnProperty(e)&&Pr.requests[e].abort()}const TT=function(){const e=iO({xdomain:!1});return e&&e.responseType!==null}();class CT extends $T{constructor(t){super(t);const r=t&&t.forceBase64;this.supportsBinary=TT&&!r}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Pr(iO,this.uri(),t)}}function iO(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||kT))return new XMLHttpRequest}catch{}if(!t)try{return new Wt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const oO=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class NT extends Dy{get name(){return"websocket"}doOpen(){const t=this.uri(),r=this.opts.protocols,n=oO?{}:tO(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,r,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],i=r===t.length-1;My(n,this.supportsBinary,o=>{try{this.doWrite(n,o)}catch{}i&&tf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=rO()),this.supportsBinary||(r.b64=1),this.createUri(t,r)}}const Od=Wt.WebSocket||Wt.MozWebSocket;class MT extends NT{createSocket(t,r,n){return oO?new Od(t,r,n):r?new Od(t,r):new Od(t)}doWrite(t,r){this.ws.send(r)}}class IT extends Dy{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const r=yT(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=t.readable.pipeThrough(r).getReader(),i=mT();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();const o=()=>{n.read().then(({done:s,value:l})=>{s||(this.onPacket(l),o())}).catch(s=>{})};o();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],i=r===t.length-1;this._writer.write(n).then(()=>{i&&tf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const DT={websocket:MT,webtransport:IT,polling:CT},RT=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,LT=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ih(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),n=e.indexOf("]");r!=-1&&n!=-1&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let i=RT.exec(e||""),o={},a=14;for(;a--;)o[LT[a]]=i[a]||"";return r!=-1&&n!=-1&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=BT(o,o.path),o.queryKey=zT(o,o.query),o}function BT(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&n.splice(0,1),t.slice(-1)=="/"&&n.splice(n.length-1,1),n}function zT(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,o){i&&(r[i]=o)}),r}const oh=typeof addEventListener=="function"&&typeof removeEventListener=="function",eu=[];oh&&addEventListener("offline",()=>{eu.forEach(e=>e())},!1);class On extends Le{constructor(t,r){if(super(),this.binaryType=gT,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){const n=ih(t);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=ih(r.host).host);rf(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const i=n.prototype.name;this.transports.push(i),this._transportsByName[i]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=PT(this.opts.query)),oh&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},eu.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const r=Object.assign({},this.opts.query);r.EIO=eO,r.transport=t,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&On.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(t);r.open(),this.setTransport(r)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",On.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=t.data,this._onError(r);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let n=0;n<this.writeBuffer.length;n++){const i=this.writeBuffer[n].data;if(i&&(r+=ST(i)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,tf(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,n){return this._sendPacket("message",t,r,n),this}send(t,r,n){return this._sendPacket("message",t,r,n),this}_sendPacket(t,r,n,i){if(typeof r=="function"&&(i=r,r=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const o={type:t,data:r,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():t()}):this.upgrading?n():t()),this}_onError(t){if(On.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),oh&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=eu.indexOf(this._offlineEventListener);n!==-1&&eu.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}}On.protocol=eO;class FT extends On{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let r=this.createTransport(t),n=!1;On.priorWebsocketSuccess=!1;const i=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",c=>{if(!n)if(c.type==="pong"&&c.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;On.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(f(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const d=new Error("probe error");d.transport=r.name,this.emitReserved("upgradeError",d)}}))};function o(){n||(n=!0,f(),r.close(),r=null)}const a=c=>{const d=new Error("probe error: "+c);d.transport=r.name,o(),this.emitReserved("upgradeError",d)};function s(){a("transport closed")}function l(){a("socket closed")}function u(c){r&&c.name!==r.name&&o()}const f=()=>{r.removeListener("open",i),r.removeListener("error",a),r.removeListener("close",s),this.off("close",l),this.off("upgrading",u)};r.once("open",i),r.once("error",a),r.once("close",s),this.once("close",l),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const r=[];for(let n=0;n<t.length;n++)~this.transports.indexOf(t[n])&&r.push(t[n]);return r}}let UT=class extends FT{constructor(t,r={}){const n=typeof t=="object"?t:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(i=>DT[i]).filter(i=>!!i)),super(t,n)}};function WT(e,t="",r){let n=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),n=ih(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const o=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+o+":"+n.port+t,n.href=n.protocol+"://"+o+(r&&r.port===n.port?"":":"+n.port),n}const HT=typeof ArrayBuffer=="function",VT=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,aO=Object.prototype.toString,qT=typeof Blob=="function"||typeof Blob<"u"&&aO.call(Blob)==="[object BlobConstructor]",KT=typeof File=="function"||typeof File<"u"&&aO.call(File)==="[object FileConstructor]";function Ry(e){return HT&&(e instanceof ArrayBuffer||VT(e))||qT&&e instanceof Blob||KT&&e instanceof File}function tu(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(tu(e[r]))return!0;return!1}if(Ry(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return tu(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&tu(e[r]))return!0;return!1}function GT(e){const t=[],r=e.data,n=e;return n.data=ah(r,t),n.attachments=t.length,{packet:n,buffers:t}}function ah(e,t){if(!e)return e;if(Ry(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=ah(e[n],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=ah(e[n],t));return r}return e}function XT(e,t){return e.data=sh(e.data,t),delete e.attachments,e}function sh(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=sh(e[r],t);else if(typeof e=="object")for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=sh(e[r],t));return e}const YT=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var re;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(re||(re={}));class QT{constructor(t){this.replacer=t}encode(t){return(t.type===re.EVENT||t.type===re.ACK)&&tu(t)?this.encodeAsBinary({type:t.type===re.EVENT?re.BINARY_EVENT:re.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===re.BINARY_EVENT||t.type===re.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),r}encodeAsBinary(t){const r=GT(t),n=this.encodeAsString(r.packet),i=r.buffers;return i.unshift(n),i}}class Ly extends Le{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);const n=r.type===re.BINARY_EVENT;n||r.type===re.BINARY_ACK?(r.type=n?re.EVENT:re.ACK,this.reconstructor=new ZT(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Ry(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0;const n={type:Number(t.charAt(0))};if(re[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===re.BINARY_EVENT||n.type===re.BINARY_ACK){const o=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);const a=t.substring(o,r);if(a!=Number(a)||t.charAt(r)!=="-")throw new Error("Illegal attachments");const s=Number(a);if(!JT(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=s}if(t.charAt(r+1)==="/"){const o=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););n.nsp=t.substring(o,r)}else n.nsp="/";const i=t.charAt(r+1);if(i!==""&&Number(i)==i){const o=r+1;for(;++r;){const a=t.charAt(r);if(a==null||Number(a)!=a){--r;break}if(r===t.length)break}n.id=Number(t.substring(o,r+1))}if(t.charAt(++r)){const o=this.tryParse(t.substr(r));if(Ly.isPayloadValid(n.type,o))n.data=o;else throw new Error("invalid payload")}return n}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case re.CONNECT:return b0(r);case re.DISCONNECT:return r===void 0;case re.CONNECT_ERROR:return typeof r=="string"||b0(r);case re.EVENT:case re.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&YT.indexOf(r[0])===-1);case re.ACK:case re.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ZT{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const r=XT(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const JT=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function b0(e){return Object.prototype.toString.call(e)==="[object Object]"}const eC=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ly,Encoder:QT,get PacketType(){return re}},Symbol.toStringTag,{value:"Module"}));function ir(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const tC=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class sO extends Le{constructor(t,r,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[ir(t,"open",this.onopen.bind(this)),ir(t,"packet",this.onpacket.bind(this)),ir(t,"error",this.onerror.bind(this)),ir(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...r){var n,i,o;if(tC.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const a={type:re.EVENT,data:r};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const f=this.ids++,c=r.pop();this._registerAckCallback(f,c),a.id=f}const s=(i=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||i===void 0?void 0:i.writable,l=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._hasPingExpired());return this.flags.volatile&&!s||(l?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a)),this.flags={},this}_registerAckCallback(t,r){var n;const i=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(i===void 0){this.acks[t]=r;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===t&&this.sendBuffer.splice(s,1);r.call(this,new Error("operation has timed out"))},i),a=(...s)=>{this.io.clearTimeoutFn(o),r.apply(this,s)};a.withError=!0,this.acks[t]=a}emitWithAck(t,...r){return new Promise((n,i)=>{const o=(a,s)=>a?i(a):n(s);o.withError=!0,r.push(o),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...o)=>(this._queue[0],i!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(i)):(this._queue.shift(),r&&r(null,...o)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!t||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:re.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(n=>String(n.id)===t)){const n=this.acks[t];delete this.acks[t],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case re.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case re.EVENT:case re.BINARY_EVENT:this.onevent(t);break;case re.ACK:case re.BINARY_ACK:this.onack(t);break;case re.DISCONNECT:this.ondisconnect();break;case re.CONNECT_ERROR:this.destroy();const n=new Error(t.data.message);n.data=t.data.data,this.emitReserved("connect_error",n);break}}onevent(t){const r=t.data||[];t.id!=null&&r.push(this.ack(t.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const r=this;let n=!1;return function(...i){n||(n=!0,r.packet({type:re.ACK,id:t,data:i}))}}onack(t){const r=this.acks[t.id];typeof r=="function"&&(delete this.acks[t.id],r.withError&&t.data.unshift(null),r.apply(this,t.data))}onconnect(t,r){this.id=t,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:re.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const r=this._anyListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,t.data)}}}function Ro(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ro.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0};Ro.prototype.reset=function(){this.attempts=0};Ro.prototype.setMin=function(e){this.ms=e};Ro.prototype.setMax=function(e){this.max=e};Ro.prototype.setJitter=function(e){this.jitter=e};class lh extends Le{constructor(t,r){var n;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,rf(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new Ro({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;const i=r.parser||eC;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new UT(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=ir(r,"open",function(){n.onopen(),t&&t()}),o=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},a=ir(r,"error",o);if(this._timeout!==!1){const s=this._timeout,l=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),r.close()},s);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(i),this.subs.push(a),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(ir(t,"ping",this.onping.bind(this)),ir(t,"data",this.ondata.bind(this)),ir(t,"error",this.onerror.bind(this)),ir(t,"close",this.onclose.bind(this)),ir(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){tf(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,r){let n=this.nsps[t];return n?this._autoConnect&&!n.active&&n.connect():(n=new sO(this,t,r),this.nsps[t]=n),n}_destroy(t){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(t){const r=this.encoder.encode(t);for(let n=0;n<r.length;n++)this.engine.write(r[n],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const oa={};function ru(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const r=WT(e,t.path||"/socket.io"),n=r.source,i=r.id,o=r.path,a=oa[i]&&o in oa[i].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||a;let l;return s?l=new lh(n,t):(oa[i]||(oa[i]=new lh(n,t)),l=oa[i]),r.query&&!t.query&&(t.query=r.queryKey),l.socket(r.path,t)}Object.assign(ru,{Manager:lh,Socket:sO,io:ru,connect:ru});const rC=()=>typeof window<"u"?["8082","5173","3000"].includes(window.location.port)?{apiUrl:"http://localhost:8081",wsUrl:"http://localhost:8081"}:{apiUrl:window.location.origin,wsUrl:window.location.origin}:{apiUrl:"http://localhost:8081",wsUrl:"http://localhost:8081"},lO=rC(),gr=lO.apiUrl,nC=lO.wsUrl,iC=e=>({"agent:joined":"agent_join","agent:left":"agent_leave","agent:error":"error","cache:hit":"cache_hit","cache:miss":"cache_miss","debugger:paused":"debugger_paused","debugger:resumed":"debugger_resumed"})[e]||e.replace(/:/g,"_"),Pi=e=>({...e,type:iC(e.type)});function nf(e={}){const t=fe(),r=e.enableSocket??!1,n={current:null};j.useEffect(()=>{if(r){t.setConnectionStatus("connecting");try{n.current=ru(nC,{reconnection:!0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,reconnectionAttempts:5}),t.setConnected(!0),t.setConnectionStatus("connected"),n.current.on("connect",()=>{var h;console.log("✓ Connected to Dashboard API via WebSocket"),t.setConnected(!0),t.setConnectionStatus("connected"),(h=n.current)==null||h.emit("subscribe:metrics")}),n.current.on("connect_error",()=>{t.setConnected(!0),t.setConnectionStatus("connected")}),n.current.on("metrics:update",h=>{t.setMetrics({totalRequests:h.totalRequests,cacheHits:h.cacheHits,cacheMisses:h.cacheMisses,hitRate:parseFloat(h.hitRate),averageLatency:h.averageLatency,tokensSaved:h.tokensSaved,costSaved:h.costSaved,activeAgents:h.activeAgents||0,totalAgents:h.totalAgents||0,uptime:h.uptime||0,timestamp:h.timestamp})}),n.current.on("agent:joined",h=>{console.log("Agent joined:",h),h.capabilities&&t.addAgent({id:h.agentId,name:h.agentName,status:"active",capabilities:h.capabilities,tasksCompleted:0,lastSeen:new Date().toISOString(),errorCount:0,cacheHitRate:0}),t.addEvent(Pi(h))}),n.current.on("agent:left",h=>{console.log("Agent left:",h),t.removeAgent(h.agentId),t.addEvent(Pi(h))}),n.current.on("agent:error",h=>{console.log("Agent error:",h),t.addEvent(Pi(h)),ve.error(`Agent ${h.agentId} error: ${h.errorMessage}`)}),n.current.on("cache:hit",h=>{t.addEvent(Pi(h))}),n.current.on("cache:miss",h=>{t.addEvent(Pi(h))}),n.current.on("debugger:paused",()=>{t.setPaused(!0)}),n.current.on("debugger:resumed",()=>{t.setPaused(!1)}),n.current.on("disconnect",()=>{console.log("✗ Disconnected from Dashboard API"),t.setConnected(!1),t.setConnectionStatus("disconnected")}),n.current.on("error",h=>{console.error("WebSocket error:",h),ve.error("WebSocket connection error")})}catch(h){console.error("Failed to initialize WebSocket:",h),t.setConnectionStatus("disconnected")}return()=>{n.current&&n.current.disconnect()}}},[r]);const i=j.useCallback(async()=>{try{t.setMetricsLoading(!0);const h=await fetch(`${gr}/api/metrics`);if(!h.ok)throw new Error("Failed to fetch metrics");const m=await h.json();t.setConnectionStatus("connected"),t.setConnected(!0),t.setMetrics({totalRequests:m.totalRequests,cacheHits:m.cacheHits,cacheMisses:m.cacheMisses,hitRate:parseFloat(m.hitRate),averageLatency:m.averageLatency,tokensSaved:m.tokensSaved,costSaved:m.costSaved,activeAgents:m.activeAgents,totalAgents:m.totalAgents,uptime:m.uptime||0,timestamp:m.timestamp})}catch(h){console.error("Error fetching metrics:",h),t.setMetricsError(h.message)}},[]),o=j.useCallback(async()=>{try{const h=await fetch(`${gr}/api/agents`);if(!h.ok)throw new Error("Failed to fetch agents");const m=await h.json();t.setAgents(m.agents)}catch(h){console.error("Error fetching agents:",h),ve.error("Failed to fetch agents")}},[]),a=j.useCallback(async(h=1,m=50)=>{try{const b=await fetch(`${gr}/api/events?page=${h}&limit=${m}`);if(!b.ok)throw new Error("Failed to fetch events");const v=await b.json();t.setEvents((v.events||[]).map(Pi)),t.setTotalEvents(v.pagination.total)}catch(b){console.error("Error fetching events:",b),ve.error("Failed to fetch events")}},[]),s=j.useCallback(async()=>{try{const h=await fetch(`${gr}/api/cache-stats`);if(!h.ok)throw new Error("Failed to fetch cache stats");const m=await h.json();t.setTopQueries(m.topQueries)}catch(h){console.error("Error fetching cache stats:",h),ve.error("Failed to fetch cache stats")}},[]),l=j.useCallback(async()=>{try{const h=await fetch(`${gr}/api/savings-breakdown`);if(!h.ok)return;const m=await h.json();t.setSavingsBreakdown(m)}catch{}},[]),u=j.useCallback(async()=>{try{const h=await fetch(`${gr}/api/cache/clear`,{method:"POST"});if(!h.ok)throw new Error("Failed to clear cache");const m=await h.json();ve.success(`Cleared ${m.clearedEntries} cache entries`),i()}catch(h){console.error("Error clearing cache:",h),ve.error("Failed to clear cache")}},[]),f=j.useCallback(async()=>{try{if(!(await fetch(`${gr}/api/debugger/pause`,{method:"POST"})).ok)throw new Error("Failed to pause");t.setPaused(!0),ve.success("Paused agent processing")}catch(h){console.error("Error pausing:",h),ve.error("Failed to pause")}},[]),c=j.useCallback(async()=>{try{if(!(await fetch(`${gr}/api/debugger/resume`,{method:"POST"})).ok)throw new Error("Failed to resume");t.setPaused(!1),ve.success("Resumed agent processing")}catch(h){console.error("Error resuming:",h),ve.error("Failed to resume")}},[]),d=j.useCallback(async h=>{try{const m=await fetch(`${gr}/api/debugger/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:h})});if(!m.ok)throw new Error("Failed to rewind");const b=await m.json();t.setDebuggerState(b.state),ve.success("Rewound to selected event")}catch(m){console.error("Error rewinding:",m),ve.error("Failed to rewind")}},[]),p=j.useCallback(async h=>{if(!h.trim()){t.setSearchResults([]);return}try{t.setIsSearching(!0);const m=await fetch(`${gr}/api/search?q=${encodeURIComponent(h)}`);if(!m.ok)throw new Error("Search failed");const b=await m.json();t.setSearchResults(b.results||[])}catch(m){console.error("Error during search:",m),ve.error("Search failed: "+m.message),t.setIsSearching(!1)}},[]);return{fetchMetrics:i,fetchAgents:o,fetchEvents:a,fetchCacheStats:s,fetchSavingsBreakdown:l,clearCache:u,pauseDebugger:f,resumeDebugger:c,rewindToEvent:d,fetchSearch:p}}const oC=({isOpen:e,onClose:t})=>{const r=fe(d=>d.metrics),n=fe(d=>d.refreshIntervalSeconds),i=fe(d=>d.setRefreshIntervalSeconds),[o,a]=j.useState(n),s=fe(d=>d.events),l=fe(d=>d.setEvents);j.useEffect(()=>{e&&a(n)},[e,n]);const u=()=>{i(o),localStorage.setItem("dashboardSettings",JSON.stringify({refreshIntervalSeconds:o})),ve.success("Settings saved!"),t()},f=()=>{if(!r){ve.error("No metrics to export");return}const d=[["Metric","Value"],["Total Requests",r.totalRequests||0],["Cache Hits",r.cacheHits||0],["Cache Misses",r.cacheMisses||0],["Hit Rate (%)",((r.hitRate||0)*100).toFixed(2)],["Avg Latency (ms)",r.averageLatency||0],["Tokens Saved",r.tokensSaved||0],["Cost Saved ($)",(r.costSaved||0).toFixed(2)],["Active Agents",r.activeAgents||0],["Total Agents",r.totalAgents||0],["Uptime (ms)",r.uptime||0]].map(b=>b.join(",")).join(`
|
|
408
|
-
`),p=new Blob([d],{type:"text/csv"}),h=window.URL.createObjectURL(p),m=document.createElement("a");m.href=h,m.download=`lemma-metrics-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(m),m.click(),window.URL.revokeObjectURL(h),document.body.removeChild(m),ve.success("Metrics exported!")},c=()=>{l([]),ve.success("Event log cleared")};return e?x.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:x.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4",children:[x.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[x.jsx("h2",{className:"text-lg font-bold text-gray-900",children:"⚙️ Settings"}),x.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-100 rounded transition",children:x.jsx(R_,{size:20,className:"text-gray-600"})})]}),x.jsxs("div",{className:"p-6 space-y-6",children:[x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-semibold text-gray-900 mb-3",children:"📊 Dashboard Refresh Interval"}),x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("input",{type:"range",min:"2",max:"30",value:o,onChange:d=>a(Number(d.target.value)),className:"flex-1"}),x.jsxs("span",{className:"text-sm font-semibold text-gray-600 w-16 text-right",children:[o,"s"]})]}),x.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"How often to fetch updated metrics from the server"})]}),x.jsx("hr",{className:"border-gray-200"}),x.jsxs("button",{onClick:f,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-blue-50 hover:bg-blue-100 text-blue-600 rounded-lg font-medium transition",children:[x.jsx(n$,{size:16}),"📥 Export Metrics as CSV"]}),x.jsxs("button",{onClick:c,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-red-50 hover:bg-red-100 text-red-600 rounded-lg font-medium transition",children:[x.jsx(v$,{size:16}),"🗑️ Clear Event Log (",s.length," events)"]}),x.jsx("hr",{className:"border-gray-200"}),x.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[x.jsx("h3",{className:"text-xs font-semibold text-gray-600 uppercase mb-2",children:"API Status"}),x.jsxs("div",{className:"space-y-1 text-xs text-gray-600",children:[x.jsxs("div",{children:["API: ",x.jsx("span",{className:"text-green-600 font-semibold",children:"http://localhost:3001"})]}),x.jsxs("div",{children:["WS: ",x.jsx("span",{className:"text-green-600 font-semibold",children:"ws://localhost:3001"})]}),x.jsxs("div",{children:["Dashboard: ",x.jsx("span",{className:"text-green-600 font-semibold",children:"localhost:5173"})]})]})]})]}),x.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 flex gap-3",children:[x.jsx("button",{onClick:t,className:"flex-1 px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-900 rounded font-medium transition",children:"Cancel"}),x.jsx("button",{onClick:u,className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded font-medium transition",children:"Save Settings"})]})]})}):null},aC={idle:{label:"Standby",description:"Waiting to connect",dot:"bg-gray-400",badge:"bg-gray-100/20 border-gray-400/30 text-gray-200",pulse:!1},connecting:{label:"Connecting",description:"Establishing connection…",dot:"bg-amber-400",badge:"bg-amber-400/20 border-amber-300/40 text-amber-200",pulse:!0},connected:{label:"Live",description:"System is running",dot:"bg-emerald-400",badge:"bg-emerald-400/20 border-emerald-300/40 text-emerald-200",pulse:!0},disconnected:{label:"Offline",description:"Connection lost",dot:"bg-red-400",badge:"bg-red-400/20 border-red-400/40 text-red-200",pulse:!1}},sC=()=>{const[e,t]=j.useState(!1),r=fe(o=>o.connectionStatus),{clearCache:n}=nf({enableSocket:!1}),i=aC[r];return x.jsxs(x.Fragment,{children:[x.jsx("header",{className:"bg-slate-900/60 backdrop-blur-xl px-6 py-3 border-b border-white/5 relative overflow-hidden flex-shrink-0",children:x.jsxs("div",{className:"flex items-center justify-between relative",children:[x.jsxs("div",{className:"flex items-center gap-4",children:[x.jsx("div",{className:"w-9 h-9 bg-indigo-600/20 backdrop-blur rounded-lg flex items-center justify-center border border-indigo-500/30",children:x.jsx(M_,{className:"w-5 h-5 text-indigo-400"})}),x.jsxs("div",{children:[x.jsxs("h1",{className:"text-lg font-black text-white tracking-tight leading-none uppercase italic",children:["Lemma ",x.jsx("span",{className:"text-indigo-500 font-bold not-italic text-sm ml-1",children:"v0.5.2"})]}),x.jsx("p",{className:"text-[10px] text-slate-500 mt-1 font-bold uppercase tracking-widest",children:"Semantic Cache & AI Orchestrator"})]}),x.jsx("div",{className:"hidden sm:block h-6 w-px bg-white/5 mx-2"}),x.jsxs("div",{className:`hidden sm:flex items-center gap-2 px-3 py-1 rounded-full border ${i.badge} backdrop-blur-sm`,children:[x.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i.dot} ${i.pulse?"animate-pulse":""}`}),x.jsx("span",{className:"text-[10px] font-black tracking-widest uppercase",children:i.label})]}),x.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[x.jsx("button",{onClick:()=>fe.getState().setActiveSidePanel("agents"),className:`px-4 py-1.5 text-[10px] font-black uppercase tracking-widest rounded-md transition-all ${fe(o=>o.activeSidePanel!=="brain")?"bg-indigo-500/20 text-indigo-400 border border-indigo-500/30":"text-slate-500 hover:text-slate-300"}`,children:"The Hub"}),x.jsx("button",{onClick:()=>fe.getState().setActiveSidePanel("brain"),className:`px-4 py-1.5 text-[10px] font-black uppercase tracking-widest rounded-md transition-all ${fe(o=>o.activeSidePanel==="brain")?"bg-indigo-500/20 text-indigo-400 border border-indigo-500/30":"text-slate-500 hover:text-slate-300"}`,children:"The Brain"})]})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs("button",{onClick:()=>n(),className:"hidden sm:inline-flex items-center gap-2 px-3 py-1.5 text-[10px] font-black uppercase tracking-widest text-slate-400 bg-white/5 hover:bg-white/10 border border-white/5 rounded-md transition-all duration-200",children:[x.jsx(c$,{className:"w-3 h-3"}),"Flush Cache"]}),x.jsx("button",{onClick:()=>t(!0),className:"p-2 text-slate-400 bg-white/5 hover:bg-white/10 border border-white/5 rounded-md transition-all duration-200",children:x.jsx(p$,{className:"w-4 h-4"})})]})]})}),x.jsx(oC,{isOpen:e,onClose:()=>t(!1)})]})},aa=({title:e,subtitle:t,value:r,icon:n,unit:i,color:o,loading:a,tooltip:s})=>{const l={blue:"from-blue-500/20 to-blue-600/5 border-blue-500/30 hover:border-blue-400 hover:shadow-[0_0_15px_rgba(59,130,246,0.3)]",green:"from-emerald-500/20 to-emerald-600/5 border-emerald-500/30 hover:border-emerald-400 hover:shadow-[0_0_15px_rgba(16,185,129,0.3)]",purple:"from-violet-500/20 to-violet-600/5 border-violet-500/30 hover:border-violet-400 hover:shadow-[0_0_15px_rgba(139,92,246,0.3)]",orange:"from-amber-500/20 to-amber-600/5 border-amber-500/30 hover:border-amber-400 hover:shadow-[0_0_15px_rgba(245,158,11,0.3)]"},u={blue:"from-blue-500 to-blue-600",green:"from-emerald-500 to-emerald-600",purple:"from-violet-500 to-violet-600",orange:"from-amber-500 to-amber-600"},f={blue:"text-blue-400",green:"text-emerald-400",purple:"text-violet-400",orange:"text-amber-400"};return x.jsx("div",{className:`bg-slate-900/40 ${l[o]} border rounded-2xl p-4 backdrop-blur-md transition-all duration-300 group relative overflow-hidden`,title:s,children:x.jsxs("div",{className:"flex items-center justify-between relative gap-3",children:[x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest truncate",children:e}),a?x.jsx("div",{className:"mt-1.5 space-y-1.5",children:x.jsx("div",{className:"h-6 w-16 bg-white/5 rounded animate-pulse"})}):x.jsxs(x.Fragment,{children:[x.jsxs("p",{className:`text-2xl font-black ${f[o]} mt-1 leading-none tracking-tight`,children:[r,i&&x.jsx("span",{className:"text-xs font-semibold text-slate-500 ml-1",children:i})]}),x.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-tight truncate uppercase font-medium",children:t})]})]}),x.jsx("div",{className:`bg-gradient-to-br ${u[o]} p-2 rounded-lg shadow-lg flex-shrink-0 opacity-80 group-hover:opacity-100 transition-opacity`,children:x.jsx("div",{className:"text-white",children:n})})]})})},lC=()=>{const e=fe(l=>l.metrics),t=fe(l=>l.isLoadingMetrics),[r,n]=j.useState(0);if(j.useEffect(()=>{n(0);const l=setInterval(()=>n(u=>u+1),1e3);return()=>clearInterval(l)},[e]),!e)return x.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(l=>x.jsx(aa,{title:"Syncing...",subtitle:"Secure bridge active",value:"-",icon:x.jsx(b$,{className:"w-4 h-4"}),color:"blue",loading:!0},l))});const i=e.hitRate*100,o=!e.secretsMasked||e.secretsMasked===0,a=e.tokensSaved>=1e3?`${(e.tokensSaved/1e3).toFixed(1)}k`:e.tokensSaved.toLocaleString(),s=e.averageLatency>0?(2500/e.averageLatency).toFixed(0):"80";return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[x.jsx(aa,{title:"Privacy Shield",subtitle:o?"Zero leaks detected":"Secrets masked locally",value:o?"SECURE":e.secretsMasked??0,icon:x.jsx(h$,{className:"w-4 h-4"}),color:o?"green":"blue",loading:t,tooltip:"Lemma Privacy Firewall intercepts PII and secrets before they reach the cloud."}),x.jsx(aa,{title:"Budget Saved",subtitle:`Total Saved (All-Time) ~${a}`,value:e.costSaved<1?`$${e.costSaved.toFixed(4)}`:`$${e.costSaved.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,icon:x.jsx(r$,{className:"w-4 h-4"}),color:"green",loading:t,tooltip:"Every time a cached response is reused, the system avoids paying the AI provider."}),x.jsx(aa,{title:"Global Hit Rate",subtitle:"Semantic memory efficiency",value:`${i.toFixed(1)}`,unit:"%",icon:x.jsx(m$,{className:"w-4 h-4"}),color:"orange",loading:t,tooltip:"When an AI agent asks the same question again, the system returns the cached answer instantly."}),x.jsx(aa,{title:"Response Time",subtitle:`vs. 2.5s direct LLM (${s}x speed)`,value:e.averageLatency.toFixed(0),unit:"ms",icon:x.jsx(i$,{className:"w-4 h-4"}),color:"blue",loading:t,tooltip:"How quickly the system responds. Lower is faster. Cached hits respond in <10ms."})]}),x.jsx("p",{className:"text-right text-xs text-gray-400 mt-1 pr-0.5",children:t?"Updating…":`Updated ${r===0?"just now":`${r}s ago`}`})]})},x0={active:{label:"Active",description:"Currently working",dot:"bg-emerald-500",badge:"bg-emerald-50 text-emerald-700 border-emerald-200",icon:x.jsx(o0,{className:"w-3.5 h-3.5"}),ring:"ring-emerald-200"},online:{label:"Active",description:"Currently working",dot:"bg-emerald-500",badge:"bg-emerald-50 text-emerald-700 border-emerald-200",icon:x.jsx(o0,{className:"w-3.5 h-3.5"}),ring:"ring-emerald-200"},idle:{label:"Idle",description:"Waiting for tasks",dot:"bg-amber-400",badge:"bg-amber-400/10 text-amber-400 border-amber-400/20",icon:x.jsx(I_,{className:"w-3.5 h-3.5"}),ring:"ring-amber-200"},error:{label:"Error",description:"Needs attention",dot:"bg-red-500",badge:"bg-red-500/10 text-red-400 border-red-500/20",icon:x.jsx(g$,{className:"w-3.5 h-3.5"}),ring:"ring-red-200"}},uC={llm:"Language AI",cache:"Caching",search:"Search",embedding:"Embeddings",tools:"Tools",memory:"Memory",vision:"Vision",audio:"Audio"},cC=e=>uC[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),fC=e=>e.substring(0,8).toUpperCase(),dC=()=>{const e=fe(a=>a.agents),t=fe(a=>a.selectedAgentId),r=fe(a=>a.setSelectedAgent),n=e.filter(a=>a.status==="active").length,i=e.filter(a=>a.status==="idle").length,o=e.filter(a=>a.status==="error").length;return e.length===0?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full bg-transparent px-6 text-center",children:[x.jsx("div",{className:"w-16 h-16 bg-white/5 rounded-2xl flex items-center justify-center mb-4 border border-white/5",children:x.jsx(i0,{className:"w-8 h-8 text-slate-600"})}),x.jsx("p",{className:"text-white font-bold text-base",children:"No agents connected"}),x.jsx("p",{className:"text-slate-500 text-sm mt-2 leading-relaxed max-w-[180px]",children:"Start an AI agent to see it appear here and begin processing requests."})]}):x.jsxs("div",{className:"h-full flex flex-col bg-transparent",children:[x.jsxs("div",{className:"px-5 py-4 border-b border-white/5 bg-white/5 sticky top-0 z-10",children:[x.jsx("div",{className:"flex items-center justify-between mb-3",children:x.jsxs("div",{children:[x.jsxs("h2",{className:"text-sm font-bold text-white flex items-center gap-2",children:[x.jsx(i0,{className:"w-4 h-4 text-indigo-400"}),"AI Agents"]}),x.jsxs("p",{className:"text-xs text-slate-500 mt-0.5",children:[e.length," connected right now"]})]})}),x.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[n>0&&x.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-widest px-2.5 py-1 rounded-full bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),n," Working"]}),i>0&&x.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-widest px-2.5 py-1 rounded-full bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),i," Idle"]}),o>0&&x.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-widest px-2.5 py-1 rounded-full bg-red-500/10 text-red-400 border border-red-500/20",children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),o," Error"]})]})]}),x.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-2",children:e.map(a=>{const s=x0[a.status]||x0.idle,l=t===a.id,u=a.cacheHitRate,c=typeof u=="number"&&!isNaN(u)&&a.tasksCompleted>0?(u*100).toFixed(0):null;return x.jsxs("div",{onClick:()=>r(a.id),className:`p-4 rounded-xl border transition-all duration-200 cursor-pointer select-none ${l?"bg-indigo-600/10 border-indigo-500/40 shadow-[0_0_20px_rgba(79,70,229,0.15)]":"bg-white/5 border-white/5 hover:border-white/10 hover:bg-white/[0.08]"}`,children:[x.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x.jsxs("div",{className:"flex items-start gap-2.5 min-w-0",children:[x.jsx("div",{className:`w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-400 to-purple-500 flex items-center justify-center flex-shrink-0 text-white text-xs font-black ring-2 ${l?"ring-indigo-300":s.ring}`,children:a.name.charAt(0).toUpperCase()}),x.jsxs("div",{className:"min-w-0",children:[x.jsx("p",{className:"text-sm font-bold text-white truncate leading-tight",children:a.name}),x.jsxs("p",{className:"text-[10px] text-slate-500 font-mono truncate mt-0.5",children:["#",fC(a.id)]})]})]}),x.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-tighter px-2 py-0.5 rounded-full border flex-shrink-0 ${s.badge}`,children:[s.icon,s.label]})]}),x.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[x.jsxs("div",{className:"flex-1 bg-black/20 rounded-lg px-3 py-1.5 text-center border border-white/5",children:[x.jsx("p",{className:"text-sm font-black text-white",children:a.tasksCompleted}),x.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tighter",children:"Tasks done"})]}),x.jsxs("div",{className:"flex-1 bg-black/20 rounded-lg px-3 py-1.5 text-center border border-white/5",children:[x.jsx("p",{className:`text-sm font-black ${c===null?"text-slate-500":parseInt(c)>=50?"text-emerald-400":"text-amber-400"}`,children:c===null?"—":`${c}%`}),x.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tighter",children:"Agent Hit Rate"})]})]}),a.errorCount>0&&x.jsxs("div",{className:"mt-2.5 flex items-center gap-1.5 text-red-600 bg-red-50 px-3 py-1.5 rounded-lg border border-red-100",children:[x.jsx(Zj,{className:"w-3.5 h-3.5 flex-shrink-0"}),x.jsxs("span",{className:"text-xs font-semibold",children:[a.errorCount," error",a.errorCount!==1?"s":""," — needs review"]})]}),a.capabilities.length>0&&x.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2.5",children:[a.capabilities.slice(0,3).map(d=>x.jsx("span",{className:"text-[10px] font-black uppercase tracking-tighter bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 px-2 py-0.5 rounded-full",children:cC(d)},d)),a.capabilities.length>3&&x.jsxs("span",{className:"text-xs text-gray-400 font-medium self-center",children:["+",a.capabilities.length-3," more"]})]})]},a.id)})}),x.jsx("div",{className:"px-4 py-3 border-t border-white/5 bg-black/10",children:x.jsx("p",{className:"text-[10px] text-slate-600 text-center font-bold uppercase tracking-widest",children:"Tap an agent to focus its activity"})})]})};function uO(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=uO(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function se(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=uO(e))&&(n&&(n+=" "),n+=t);return n}var pC=Array.isArray,Ot=pC,hC=typeof il=="object"&&il&&il.Object===Object&&il,cO=hC,mC=cO,yC=typeof self=="object"&&self&&self.Object===Object&&self,vC=mC||yC||Function("return this")(),$r=vC,gC=$r,bC=gC.Symbol,Ks=bC,w0=Ks,fO=Object.prototype,xC=fO.hasOwnProperty,wC=fO.toString,sa=w0?w0.toStringTag:void 0;function SC(e){var t=xC.call(e,sa),r=e[sa];try{e[sa]=void 0;var n=!0}catch{}var i=wC.call(e);return n&&(t?e[sa]=r:delete e[sa]),i}var _C=SC,OC=Object.prototype,PC=OC.toString;function AC(e){return PC.call(e)}var EC=AC,S0=Ks,kC=_C,jC=EC,$C="[object Null]",TC="[object Undefined]",_0=S0?S0.toStringTag:void 0;function CC(e){return e==null?e===void 0?TC:$C:_0&&_0 in Object(e)?kC(e):jC(e)}var en=CC;function NC(e){return e!=null&&typeof e=="object"}var tn=NC,MC=en,IC=tn,DC="[object Symbol]";function RC(e){return typeof e=="symbol"||IC(e)&&MC(e)==DC}var Lo=RC,LC=Ot,BC=Lo,zC=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,FC=/^\w*$/;function UC(e,t){if(LC(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||BC(e)?!0:FC.test(e)||!zC.test(e)||t!=null&&e in Object(t)}var By=UC;function WC(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Nn=WC;const Bo=me(Nn);var HC=en,VC=Nn,qC="[object AsyncFunction]",KC="[object Function]",GC="[object GeneratorFunction]",XC="[object Proxy]";function YC(e){if(!VC(e))return!1;var t=HC(e);return t==KC||t==GC||t==qC||t==XC}var zy=YC;const J=me(zy);var QC=$r,ZC=QC["__core-js_shared__"],JC=ZC,Pd=JC,O0=function(){var e=/[^.]+$/.exec(Pd&&Pd.keys&&Pd.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function eN(e){return!!O0&&O0 in e}var tN=eN,rN=Function.prototype,nN=rN.toString;function iN(e){if(e!=null){try{return nN.call(e)}catch{}try{return e+""}catch{}}return""}var dO=iN,oN=zy,aN=tN,sN=Nn,lN=dO,uN=/[\\^$.*+?()[\]{}|]/g,cN=/^\[object .+?Constructor\]$/,fN=Function.prototype,dN=Object.prototype,pN=fN.toString,hN=dN.hasOwnProperty,mN=RegExp("^"+pN.call(hN).replace(uN,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yN(e){if(!sN(e)||aN(e))return!1;var t=oN(e)?mN:cN;return t.test(lN(e))}var vN=yN;function gN(e,t){return e==null?void 0:e[t]}var bN=gN,xN=vN,wN=bN;function SN(e,t){var r=wN(e,t);return xN(r)?r:void 0}var bi=SN,_N=bi,ON=_N(Object,"create"),of=ON,P0=of;function PN(){this.__data__=P0?P0(null):{},this.size=0}var AN=PN;function EN(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var kN=EN,jN=of,$N="__lodash_hash_undefined__",TN=Object.prototype,CN=TN.hasOwnProperty;function NN(e){var t=this.__data__;if(jN){var r=t[e];return r===$N?void 0:r}return CN.call(t,e)?t[e]:void 0}var MN=NN,IN=of,DN=Object.prototype,RN=DN.hasOwnProperty;function LN(e){var t=this.__data__;return IN?t[e]!==void 0:RN.call(t,e)}var BN=LN,zN=of,FN="__lodash_hash_undefined__";function UN(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=zN&&t===void 0?FN:t,this}var WN=UN,HN=AN,VN=kN,qN=MN,KN=BN,GN=WN;function zo(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}zo.prototype.clear=HN;zo.prototype.delete=VN;zo.prototype.get=qN;zo.prototype.has=KN;zo.prototype.set=GN;var XN=zo;function YN(){this.__data__=[],this.size=0}var QN=YN;function ZN(e,t){return e===t||e!==e&&t!==t}var Fy=ZN,JN=Fy;function eM(e,t){for(var r=e.length;r--;)if(JN(e[r][0],t))return r;return-1}var af=eM,tM=af,rM=Array.prototype,nM=rM.splice;function iM(e){var t=this.__data__,r=tM(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():nM.call(t,r,1),--this.size,!0}var oM=iM,aM=af;function sM(e){var t=this.__data__,r=aM(t,e);return r<0?void 0:t[r][1]}var lM=sM,uM=af;function cM(e){return uM(this.__data__,e)>-1}var fM=cM,dM=af;function pM(e,t){var r=this.__data__,n=dM(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var hM=pM,mM=QN,yM=oM,vM=lM,gM=fM,bM=hM;function Fo(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Fo.prototype.clear=mM;Fo.prototype.delete=yM;Fo.prototype.get=vM;Fo.prototype.has=gM;Fo.prototype.set=bM;var sf=Fo,xM=bi,wM=$r,SM=xM(wM,"Map"),Uy=SM,A0=XN,_M=sf,OM=Uy;function PM(){this.size=0,this.__data__={hash:new A0,map:new(OM||_M),string:new A0}}var AM=PM;function EM(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var kM=EM,jM=kM;function $M(e,t){var r=e.__data__;return jM(t)?r[typeof t=="string"?"string":"hash"]:r.map}var lf=$M,TM=lf;function CM(e){var t=TM(this,e).delete(e);return this.size-=t?1:0,t}var NM=CM,MM=lf;function IM(e){return MM(this,e).get(e)}var DM=IM,RM=lf;function LM(e){return RM(this,e).has(e)}var BM=LM,zM=lf;function FM(e,t){var r=zM(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var UM=FM,WM=AM,HM=NM,VM=DM,qM=BM,KM=UM;function Uo(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Uo.prototype.clear=WM;Uo.prototype.delete=HM;Uo.prototype.get=VM;Uo.prototype.has=qM;Uo.prototype.set=KM;var Wy=Uo,pO=Wy,GM="Expected a function";function Hy(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(GM);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(Hy.Cache||pO),r}Hy.Cache=pO;var hO=Hy;const XM=me(hO);var YM=hO,QM=500;function ZM(e){var t=YM(e,function(n){return r.size===QM&&r.clear(),n}),r=t.cache;return t}var JM=ZM,eI=JM,tI=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rI=/\\(\\)?/g,nI=eI(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(tI,function(r,n,i,o){t.push(i?o.replace(rI,"$1"):n||r)}),t}),iI=nI;function oI(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var Vy=oI,E0=Ks,aI=Vy,sI=Ot,lI=Lo,k0=E0?E0.prototype:void 0,j0=k0?k0.toString:void 0;function mO(e){if(typeof e=="string")return e;if(sI(e))return aI(e,mO)+"";if(lI(e))return j0?j0.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var uI=mO,cI=uI;function fI(e){return e==null?"":cI(e)}var yO=fI,dI=Ot,pI=By,hI=iI,mI=yO;function yI(e,t){return dI(e)?e:pI(e,t)?[e]:hI(mI(e))}var vO=yI,vI=Lo;function gI(e){if(typeof e=="string"||vI(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var uf=gI,bI=vO,xI=uf;function wI(e,t){t=bI(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[xI(t[r++])];return r&&r==n?e:void 0}var qy=wI,SI=qy;function _I(e,t,r){var n=e==null?void 0:SI(e,t);return n===void 0?r:n}var gO=_I;const Kt=me(gO);function OI(e){return e==null}var PI=OI;const ee=me(PI);var AI=en,EI=Ot,kI=tn,jI="[object String]";function $I(e){return typeof e=="string"||!EI(e)&&kI(e)&&AI(e)==jI}var TI=$I;const di=me(TI);var bO={exports:{}},pe={};/**
|
|
408
|
+
`),p=new Blob([d],{type:"text/csv"}),h=window.URL.createObjectURL(p),m=document.createElement("a");m.href=h,m.download=`lemma-metrics-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(m),m.click(),window.URL.revokeObjectURL(h),document.body.removeChild(m),ve.success("Metrics exported!")},c=()=>{l([]),ve.success("Event log cleared")};return e?x.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:x.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4",children:[x.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[x.jsx("h2",{className:"text-lg font-bold text-gray-900",children:"⚙️ Settings"}),x.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-100 rounded transition",children:x.jsx(R_,{size:20,className:"text-gray-600"})})]}),x.jsxs("div",{className:"p-6 space-y-6",children:[x.jsxs("div",{children:[x.jsx("label",{className:"block text-sm font-semibold text-gray-900 mb-3",children:"📊 Dashboard Refresh Interval"}),x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("input",{type:"range",min:"2",max:"30",value:o,onChange:d=>a(Number(d.target.value)),className:"flex-1"}),x.jsxs("span",{className:"text-sm font-semibold text-gray-600 w-16 text-right",children:[o,"s"]})]}),x.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"How often to fetch updated metrics from the server"})]}),x.jsx("hr",{className:"border-gray-200"}),x.jsxs("button",{onClick:f,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-blue-50 hover:bg-blue-100 text-blue-600 rounded-lg font-medium transition",children:[x.jsx(n$,{size:16}),"📥 Export Metrics as CSV"]}),x.jsxs("button",{onClick:c,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-red-50 hover:bg-red-100 text-red-600 rounded-lg font-medium transition",children:[x.jsx(v$,{size:16}),"🗑️ Clear Event Log (",s.length," events)"]}),x.jsx("hr",{className:"border-gray-200"}),x.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[x.jsx("h3",{className:"text-xs font-semibold text-gray-600 uppercase mb-2",children:"API Status"}),x.jsxs("div",{className:"space-y-1 text-xs text-gray-600",children:[x.jsxs("div",{children:["API: ",x.jsx("span",{className:"text-green-600 font-semibold",children:"http://localhost:3001"})]}),x.jsxs("div",{children:["WS: ",x.jsx("span",{className:"text-green-600 font-semibold",children:"ws://localhost:3001"})]}),x.jsxs("div",{children:["Dashboard: ",x.jsx("span",{className:"text-green-600 font-semibold",children:"localhost:5173"})]})]})]})]}),x.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 flex gap-3",children:[x.jsx("button",{onClick:t,className:"flex-1 px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-900 rounded font-medium transition",children:"Cancel"}),x.jsx("button",{onClick:u,className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded font-medium transition",children:"Save Settings"})]})]})}):null},aC={idle:{label:"Standby",description:"Waiting to connect",dot:"bg-gray-400",badge:"bg-gray-100/20 border-gray-400/30 text-gray-200",pulse:!1},connecting:{label:"Connecting",description:"Establishing connection…",dot:"bg-amber-400",badge:"bg-amber-400/20 border-amber-300/40 text-amber-200",pulse:!0},connected:{label:"Live",description:"System is running",dot:"bg-emerald-400",badge:"bg-emerald-400/20 border-emerald-300/40 text-emerald-200",pulse:!0},disconnected:{label:"Offline",description:"Connection lost",dot:"bg-red-400",badge:"bg-red-400/20 border-red-400/40 text-red-200",pulse:!1}},sC=()=>{const[e,t]=j.useState(!1),r=fe(o=>o.connectionStatus),{clearCache:n}=nf({enableSocket:!1}),i=aC[r];return x.jsxs(x.Fragment,{children:[x.jsx("header",{className:"bg-slate-900/60 backdrop-blur-xl px-6 py-3 border-b border-white/5 relative overflow-hidden flex-shrink-0",children:x.jsxs("div",{className:"flex items-center justify-between relative",children:[x.jsxs("div",{className:"flex items-center gap-4",children:[x.jsx("div",{className:"w-9 h-9 bg-indigo-600/20 backdrop-blur rounded-lg flex items-center justify-center border border-indigo-500/30",children:x.jsx(M_,{className:"w-5 h-5 text-indigo-400"})}),x.jsxs("div",{children:[x.jsxs("h1",{className:"text-lg font-black text-white tracking-tight leading-none uppercase italic",children:["Lemma ",x.jsx("span",{className:"text-indigo-500 font-bold not-italic text-sm ml-1",children:"v0.6.1"})]}),x.jsx("p",{className:"text-[10px] text-slate-500 mt-1 font-bold uppercase tracking-widest",children:"Semantic Cache & AI Orchestrator"})]}),x.jsx("div",{className:"hidden sm:block h-6 w-px bg-white/5 mx-2"}),x.jsxs("div",{className:`hidden sm:flex items-center gap-2 px-3 py-1 rounded-full border ${i.badge} backdrop-blur-sm`,children:[x.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${i.dot} ${i.pulse?"animate-pulse":""}`}),x.jsx("span",{className:"text-[10px] font-black tracking-widest uppercase",children:i.label})]}),x.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[x.jsx("button",{onClick:()=>fe.getState().setActiveSidePanel("agents"),className:`px-4 py-1.5 text-[10px] font-black uppercase tracking-widest rounded-md transition-all ${fe(o=>o.activeSidePanel!=="brain")?"bg-indigo-500/20 text-indigo-400 border border-indigo-500/30":"text-slate-500 hover:text-slate-300"}`,children:"The Hub"}),x.jsx("button",{onClick:()=>fe.getState().setActiveSidePanel("brain"),className:`px-4 py-1.5 text-[10px] font-black uppercase tracking-widest rounded-md transition-all ${fe(o=>o.activeSidePanel==="brain")?"bg-indigo-500/20 text-indigo-400 border border-indigo-500/30":"text-slate-500 hover:text-slate-300"}`,children:"The Brain"})]})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsxs("button",{onClick:()=>n(),className:"hidden sm:inline-flex items-center gap-2 px-3 py-1.5 text-[10px] font-black uppercase tracking-widest text-slate-400 bg-white/5 hover:bg-white/10 border border-white/5 rounded-md transition-all duration-200",children:[x.jsx(c$,{className:"w-3 h-3"}),"Flush Cache"]}),x.jsx("button",{onClick:()=>t(!0),className:"p-2 text-slate-400 bg-white/5 hover:bg-white/10 border border-white/5 rounded-md transition-all duration-200",children:x.jsx(p$,{className:"w-4 h-4"})})]})]})}),x.jsx(oC,{isOpen:e,onClose:()=>t(!1)})]})},aa=({title:e,subtitle:t,value:r,icon:n,unit:i,color:o,loading:a,tooltip:s})=>{const l={blue:"from-blue-500/20 to-blue-600/5 border-blue-500/30 hover:border-blue-400 hover:shadow-[0_0_15px_rgba(59,130,246,0.3)]",green:"from-emerald-500/20 to-emerald-600/5 border-emerald-500/30 hover:border-emerald-400 hover:shadow-[0_0_15px_rgba(16,185,129,0.3)]",purple:"from-violet-500/20 to-violet-600/5 border-violet-500/30 hover:border-violet-400 hover:shadow-[0_0_15px_rgba(139,92,246,0.3)]",orange:"from-amber-500/20 to-amber-600/5 border-amber-500/30 hover:border-amber-400 hover:shadow-[0_0_15px_rgba(245,158,11,0.3)]"},u={blue:"from-blue-500 to-blue-600",green:"from-emerald-500 to-emerald-600",purple:"from-violet-500 to-violet-600",orange:"from-amber-500 to-amber-600"},f={blue:"text-blue-400",green:"text-emerald-400",purple:"text-violet-400",orange:"text-amber-400"};return x.jsx("div",{className:`bg-slate-900/40 ${l[o]} border rounded-2xl p-4 backdrop-blur-md transition-all duration-300 group relative overflow-hidden`,title:s,children:x.jsxs("div",{className:"flex items-center justify-between relative gap-3",children:[x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest truncate",children:e}),a?x.jsx("div",{className:"mt-1.5 space-y-1.5",children:x.jsx("div",{className:"h-6 w-16 bg-white/5 rounded animate-pulse"})}):x.jsxs(x.Fragment,{children:[x.jsxs("p",{className:`text-2xl font-black ${f[o]} mt-1 leading-none tracking-tight`,children:[r,i&&x.jsx("span",{className:"text-xs font-semibold text-slate-500 ml-1",children:i})]}),x.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-tight truncate uppercase font-medium",children:t})]})]}),x.jsx("div",{className:`bg-gradient-to-br ${u[o]} p-2 rounded-lg shadow-lg flex-shrink-0 opacity-80 group-hover:opacity-100 transition-opacity`,children:x.jsx("div",{className:"text-white",children:n})})]})})},lC=()=>{const e=fe(l=>l.metrics),t=fe(l=>l.isLoadingMetrics),[r,n]=j.useState(0);if(j.useEffect(()=>{n(0);const l=setInterval(()=>n(u=>u+1),1e3);return()=>clearInterval(l)},[e]),!e)return x.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(l=>x.jsx(aa,{title:"Syncing...",subtitle:"Secure bridge active",value:"-",icon:x.jsx(b$,{className:"w-4 h-4"}),color:"blue",loading:!0},l))});const i=e.hitRate*100,o=!e.secretsMasked||e.secretsMasked===0,a=e.tokensSaved>=1e3?`${(e.tokensSaved/1e3).toFixed(1)}k`:e.tokensSaved.toLocaleString(),s=e.averageLatency>0?(2500/e.averageLatency).toFixed(0):"80";return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[x.jsx(aa,{title:"Privacy Shield",subtitle:o?"Zero leaks detected":"Secrets masked locally",value:o?"SECURE":e.secretsMasked??0,icon:x.jsx(h$,{className:"w-4 h-4"}),color:o?"green":"blue",loading:t,tooltip:"Lemma Privacy Firewall intercepts PII and secrets before they reach the cloud."}),x.jsx(aa,{title:"Budget Saved",subtitle:`Total Saved (All-Time) ~${a}`,value:e.costSaved<1?`$${e.costSaved.toFixed(4)}`:`$${e.costSaved.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,icon:x.jsx(r$,{className:"w-4 h-4"}),color:"green",loading:t,tooltip:"Every time a cached response is reused, the system avoids paying the AI provider."}),x.jsx(aa,{title:"Global Hit Rate",subtitle:"Semantic memory efficiency",value:`${i.toFixed(1)}`,unit:"%",icon:x.jsx(m$,{className:"w-4 h-4"}),color:"orange",loading:t,tooltip:"When an AI agent asks the same question again, the system returns the cached answer instantly."}),x.jsx(aa,{title:"Response Time",subtitle:`vs. 2.5s direct LLM (${s}x speed)`,value:e.averageLatency.toFixed(0),unit:"ms",icon:x.jsx(i$,{className:"w-4 h-4"}),color:"blue",loading:t,tooltip:"How quickly the system responds. Lower is faster. Cached hits respond in <10ms."})]}),x.jsx("p",{className:"text-right text-xs text-gray-400 mt-1 pr-0.5",children:t?"Updating…":`Updated ${r===0?"just now":`${r}s ago`}`})]})},x0={active:{label:"Active",description:"Currently working",dot:"bg-emerald-500",badge:"bg-emerald-50 text-emerald-700 border-emerald-200",icon:x.jsx(o0,{className:"w-3.5 h-3.5"}),ring:"ring-emerald-200"},online:{label:"Active",description:"Currently working",dot:"bg-emerald-500",badge:"bg-emerald-50 text-emerald-700 border-emerald-200",icon:x.jsx(o0,{className:"w-3.5 h-3.5"}),ring:"ring-emerald-200"},idle:{label:"Idle",description:"Waiting for tasks",dot:"bg-amber-400",badge:"bg-amber-400/10 text-amber-400 border-amber-400/20",icon:x.jsx(I_,{className:"w-3.5 h-3.5"}),ring:"ring-amber-200"},error:{label:"Error",description:"Needs attention",dot:"bg-red-500",badge:"bg-red-500/10 text-red-400 border-red-500/20",icon:x.jsx(g$,{className:"w-3.5 h-3.5"}),ring:"ring-red-200"}},uC={llm:"Language AI",cache:"Caching",search:"Search",embedding:"Embeddings",tools:"Tools",memory:"Memory",vision:"Vision",audio:"Audio"},cC=e=>uC[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),fC=e=>e.substring(0,8).toUpperCase(),dC=()=>{const e=fe(a=>a.agents),t=fe(a=>a.selectedAgentId),r=fe(a=>a.setSelectedAgent),n=e.filter(a=>a.status==="active").length,i=e.filter(a=>a.status==="idle").length,o=e.filter(a=>a.status==="error").length;return e.length===0?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full bg-transparent px-6 text-center",children:[x.jsx("div",{className:"w-16 h-16 bg-white/5 rounded-2xl flex items-center justify-center mb-4 border border-white/5",children:x.jsx(i0,{className:"w-8 h-8 text-slate-600"})}),x.jsx("p",{className:"text-white font-bold text-base",children:"No agents connected"}),x.jsx("p",{className:"text-slate-500 text-sm mt-2 leading-relaxed max-w-[180px]",children:"Start an AI agent to see it appear here and begin processing requests."})]}):x.jsxs("div",{className:"h-full flex flex-col bg-transparent",children:[x.jsxs("div",{className:"px-5 py-4 border-b border-white/5 bg-white/5 sticky top-0 z-10",children:[x.jsx("div",{className:"flex items-center justify-between mb-3",children:x.jsxs("div",{children:[x.jsxs("h2",{className:"text-sm font-bold text-white flex items-center gap-2",children:[x.jsx(i0,{className:"w-4 h-4 text-indigo-400"}),"AI Agents"]}),x.jsxs("p",{className:"text-xs text-slate-500 mt-0.5",children:[e.length," connected right now"]})]})}),x.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[n>0&&x.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-widest px-2.5 py-1 rounded-full bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),n," Working"]}),i>0&&x.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-widest px-2.5 py-1 rounded-full bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),i," Idle"]}),o>0&&x.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-widest px-2.5 py-1 rounded-full bg-red-500/10 text-red-400 border border-red-500/20",children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),o," Error"]})]})]}),x.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-2",children:e.map(a=>{const s=x0[a.status]||x0.idle,l=t===a.id,u=a.cacheHitRate,c=typeof u=="number"&&!isNaN(u)&&a.tasksCompleted>0?(u*100).toFixed(0):null;return x.jsxs("div",{onClick:()=>r(a.id),className:`p-4 rounded-xl border transition-all duration-200 cursor-pointer select-none ${l?"bg-indigo-600/10 border-indigo-500/40 shadow-[0_0_20px_rgba(79,70,229,0.15)]":"bg-white/5 border-white/5 hover:border-white/10 hover:bg-white/[0.08]"}`,children:[x.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x.jsxs("div",{className:"flex items-start gap-2.5 min-w-0",children:[x.jsx("div",{className:`w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-400 to-purple-500 flex items-center justify-center flex-shrink-0 text-white text-xs font-black ring-2 ${l?"ring-indigo-300":s.ring}`,children:a.name.charAt(0).toUpperCase()}),x.jsxs("div",{className:"min-w-0",children:[x.jsx("p",{className:"text-sm font-bold text-white truncate leading-tight",children:a.name}),x.jsxs("p",{className:"text-[10px] text-slate-500 font-mono truncate mt-0.5",children:["#",fC(a.id)]})]})]}),x.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-black uppercase tracking-tighter px-2 py-0.5 rounded-full border flex-shrink-0 ${s.badge}`,children:[s.icon,s.label]})]}),x.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[x.jsxs("div",{className:"flex-1 bg-black/20 rounded-lg px-3 py-1.5 text-center border border-white/5",children:[x.jsx("p",{className:"text-sm font-black text-white",children:a.tasksCompleted}),x.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tighter",children:"Tasks done"})]}),x.jsxs("div",{className:"flex-1 bg-black/20 rounded-lg px-3 py-1.5 text-center border border-white/5",children:[x.jsx("p",{className:`text-sm font-black ${c===null?"text-slate-500":parseInt(c)>=50?"text-emerald-400":"text-amber-400"}`,children:c===null?"—":`${c}%`}),x.jsx("p",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tighter",children:"Agent Hit Rate"})]})]}),a.errorCount>0&&x.jsxs("div",{className:"mt-2.5 flex items-center gap-1.5 text-red-600 bg-red-50 px-3 py-1.5 rounded-lg border border-red-100",children:[x.jsx(Zj,{className:"w-3.5 h-3.5 flex-shrink-0"}),x.jsxs("span",{className:"text-xs font-semibold",children:[a.errorCount," error",a.errorCount!==1?"s":""," — needs review"]})]}),a.capabilities.length>0&&x.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2.5",children:[a.capabilities.slice(0,3).map(d=>x.jsx("span",{className:"text-[10px] font-black uppercase tracking-tighter bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 px-2 py-0.5 rounded-full",children:cC(d)},d)),a.capabilities.length>3&&x.jsxs("span",{className:"text-xs text-gray-400 font-medium self-center",children:["+",a.capabilities.length-3," more"]})]})]},a.id)})}),x.jsx("div",{className:"px-4 py-3 border-t border-white/5 bg-black/10",children:x.jsx("p",{className:"text-[10px] text-slate-600 text-center font-bold uppercase tracking-widest",children:"Tap an agent to focus its activity"})})]})};function uO(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=uO(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function se(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=uO(e))&&(n&&(n+=" "),n+=t);return n}var pC=Array.isArray,Ot=pC,hC=typeof il=="object"&&il&&il.Object===Object&&il,cO=hC,mC=cO,yC=typeof self=="object"&&self&&self.Object===Object&&self,vC=mC||yC||Function("return this")(),$r=vC,gC=$r,bC=gC.Symbol,Ks=bC,w0=Ks,fO=Object.prototype,xC=fO.hasOwnProperty,wC=fO.toString,sa=w0?w0.toStringTag:void 0;function SC(e){var t=xC.call(e,sa),r=e[sa];try{e[sa]=void 0;var n=!0}catch{}var i=wC.call(e);return n&&(t?e[sa]=r:delete e[sa]),i}var _C=SC,OC=Object.prototype,PC=OC.toString;function AC(e){return PC.call(e)}var EC=AC,S0=Ks,kC=_C,jC=EC,$C="[object Null]",TC="[object Undefined]",_0=S0?S0.toStringTag:void 0;function CC(e){return e==null?e===void 0?TC:$C:_0&&_0 in Object(e)?kC(e):jC(e)}var en=CC;function NC(e){return e!=null&&typeof e=="object"}var tn=NC,MC=en,IC=tn,DC="[object Symbol]";function RC(e){return typeof e=="symbol"||IC(e)&&MC(e)==DC}var Lo=RC,LC=Ot,BC=Lo,zC=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,FC=/^\w*$/;function UC(e,t){if(LC(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||BC(e)?!0:FC.test(e)||!zC.test(e)||t!=null&&e in Object(t)}var By=UC;function WC(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Nn=WC;const Bo=me(Nn);var HC=en,VC=Nn,qC="[object AsyncFunction]",KC="[object Function]",GC="[object GeneratorFunction]",XC="[object Proxy]";function YC(e){if(!VC(e))return!1;var t=HC(e);return t==KC||t==GC||t==qC||t==XC}var zy=YC;const J=me(zy);var QC=$r,ZC=QC["__core-js_shared__"],JC=ZC,Pd=JC,O0=function(){var e=/[^.]+$/.exec(Pd&&Pd.keys&&Pd.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function eN(e){return!!O0&&O0 in e}var tN=eN,rN=Function.prototype,nN=rN.toString;function iN(e){if(e!=null){try{return nN.call(e)}catch{}try{return e+""}catch{}}return""}var dO=iN,oN=zy,aN=tN,sN=Nn,lN=dO,uN=/[\\^$.*+?()[\]{}|]/g,cN=/^\[object .+?Constructor\]$/,fN=Function.prototype,dN=Object.prototype,pN=fN.toString,hN=dN.hasOwnProperty,mN=RegExp("^"+pN.call(hN).replace(uN,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yN(e){if(!sN(e)||aN(e))return!1;var t=oN(e)?mN:cN;return t.test(lN(e))}var vN=yN;function gN(e,t){return e==null?void 0:e[t]}var bN=gN,xN=vN,wN=bN;function SN(e,t){var r=wN(e,t);return xN(r)?r:void 0}var bi=SN,_N=bi,ON=_N(Object,"create"),of=ON,P0=of;function PN(){this.__data__=P0?P0(null):{},this.size=0}var AN=PN;function EN(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var kN=EN,jN=of,$N="__lodash_hash_undefined__",TN=Object.prototype,CN=TN.hasOwnProperty;function NN(e){var t=this.__data__;if(jN){var r=t[e];return r===$N?void 0:r}return CN.call(t,e)?t[e]:void 0}var MN=NN,IN=of,DN=Object.prototype,RN=DN.hasOwnProperty;function LN(e){var t=this.__data__;return IN?t[e]!==void 0:RN.call(t,e)}var BN=LN,zN=of,FN="__lodash_hash_undefined__";function UN(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=zN&&t===void 0?FN:t,this}var WN=UN,HN=AN,VN=kN,qN=MN,KN=BN,GN=WN;function zo(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}zo.prototype.clear=HN;zo.prototype.delete=VN;zo.prototype.get=qN;zo.prototype.has=KN;zo.prototype.set=GN;var XN=zo;function YN(){this.__data__=[],this.size=0}var QN=YN;function ZN(e,t){return e===t||e!==e&&t!==t}var Fy=ZN,JN=Fy;function eM(e,t){for(var r=e.length;r--;)if(JN(e[r][0],t))return r;return-1}var af=eM,tM=af,rM=Array.prototype,nM=rM.splice;function iM(e){var t=this.__data__,r=tM(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():nM.call(t,r,1),--this.size,!0}var oM=iM,aM=af;function sM(e){var t=this.__data__,r=aM(t,e);return r<0?void 0:t[r][1]}var lM=sM,uM=af;function cM(e){return uM(this.__data__,e)>-1}var fM=cM,dM=af;function pM(e,t){var r=this.__data__,n=dM(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var hM=pM,mM=QN,yM=oM,vM=lM,gM=fM,bM=hM;function Fo(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Fo.prototype.clear=mM;Fo.prototype.delete=yM;Fo.prototype.get=vM;Fo.prototype.has=gM;Fo.prototype.set=bM;var sf=Fo,xM=bi,wM=$r,SM=xM(wM,"Map"),Uy=SM,A0=XN,_M=sf,OM=Uy;function PM(){this.size=0,this.__data__={hash:new A0,map:new(OM||_M),string:new A0}}var AM=PM;function EM(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var kM=EM,jM=kM;function $M(e,t){var r=e.__data__;return jM(t)?r[typeof t=="string"?"string":"hash"]:r.map}var lf=$M,TM=lf;function CM(e){var t=TM(this,e).delete(e);return this.size-=t?1:0,t}var NM=CM,MM=lf;function IM(e){return MM(this,e).get(e)}var DM=IM,RM=lf;function LM(e){return RM(this,e).has(e)}var BM=LM,zM=lf;function FM(e,t){var r=zM(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var UM=FM,WM=AM,HM=NM,VM=DM,qM=BM,KM=UM;function Uo(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Uo.prototype.clear=WM;Uo.prototype.delete=HM;Uo.prototype.get=VM;Uo.prototype.has=qM;Uo.prototype.set=KM;var Wy=Uo,pO=Wy,GM="Expected a function";function Hy(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(GM);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=e.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(Hy.Cache||pO),r}Hy.Cache=pO;var hO=Hy;const XM=me(hO);var YM=hO,QM=500;function ZM(e){var t=YM(e,function(n){return r.size===QM&&r.clear(),n}),r=t.cache;return t}var JM=ZM,eI=JM,tI=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rI=/\\(\\)?/g,nI=eI(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(tI,function(r,n,i,o){t.push(i?o.replace(rI,"$1"):n||r)}),t}),iI=nI;function oI(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var Vy=oI,E0=Ks,aI=Vy,sI=Ot,lI=Lo,k0=E0?E0.prototype:void 0,j0=k0?k0.toString:void 0;function mO(e){if(typeof e=="string")return e;if(sI(e))return aI(e,mO)+"";if(lI(e))return j0?j0.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var uI=mO,cI=uI;function fI(e){return e==null?"":cI(e)}var yO=fI,dI=Ot,pI=By,hI=iI,mI=yO;function yI(e,t){return dI(e)?e:pI(e,t)?[e]:hI(mI(e))}var vO=yI,vI=Lo;function gI(e){if(typeof e=="string"||vI(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var uf=gI,bI=vO,xI=uf;function wI(e,t){t=bI(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[xI(t[r++])];return r&&r==n?e:void 0}var qy=wI,SI=qy;function _I(e,t,r){var n=e==null?void 0:SI(e,t);return n===void 0?r:n}var gO=_I;const Kt=me(gO);function OI(e){return e==null}var PI=OI;const ee=me(PI);var AI=en,EI=Ot,kI=tn,jI="[object String]";function $I(e){return typeof e=="string"||!EI(e)&&kI(e)&&AI(e)==jI}var TI=$I;const di=me(TI);var bO={exports:{}},pe={};/**
|
|
409
409
|
* @license React
|
|
410
410
|
* react-is.production.min.js
|
|
411
411
|
*
|
|
@@ -478,4 +478,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
478
478
|
`+(typeof l.response=="string"?l.response:JSON.stringify(l.response))),className:"p-2 hover:bg-white/5 rounded-lg text-slate-500 hover:text-white transition-colors",title:"Copy full interaction",children:x.jsx(Ty,{className:"w-4 h-4"})})]})]}),x.jsxs("div",{className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("h4",{className:"text-[10px] font-black text-slate-600 uppercase tracking-widest mb-2",children:"Prompt"}),x.jsx("div",{className:"bg-black/20 rounded-xl p-4 text-sm text-slate-300 font-medium border border-white/5 line-clamp-3 group-hover:line-clamp-none transition-all",children:l.prompt})]}),x.jsxs("div",{children:[x.jsx("h4",{className:"text-[10px] font-black text-slate-600 uppercase tracking-widest mb-2",children:"Response"}),x.jsx("div",{className:"bg-indigo-500/5 rounded-xl p-4 text-sm text-slate-200 border border-indigo-500/10 font-mono whitespace-pre-wrap",children:typeof l.response=="string"?l.response:((c=(f=(u=l.response)==null?void 0:u.content)==null?void 0:f[0])==null?void 0:c.text)||JSON.stringify(l.response,null,2)})]})]}),x.jsx("div",{className:"mt-4 pt-4 border-t border-white/5 flex justify-end",children:x.jsxs("button",{className:"flex items-center gap-1 text-[10px] font-black text-indigo-400 uppercase tracking-widest hover:text-indigo-300 transition-colors",children:["View Full Thread",x.jsx($y,{className:"w-3 h-3"})]})})]})},l.id)})})})]})},dJ=[{key:"clipboard",label:"Prompt Compression",emoji:"📋",color:"#22d3ee",bgColor:"rgba(34,211,238,0.1)"},{key:"contextSqueeze",label:"Context Optimization",emoji:"🗜️",color:"#a78bfa",bgColor:"rgba(167,139,250,0.1)"},{key:"historyPrune",label:"Memory Optimization",emoji:"📜",color:"#fb923c",bgColor:"rgba(251,146,60,0.1)"},{key:"complexityRouting",label:"Smart Model Routing",emoji:"🔀",color:"#34d399",bgColor:"rgba(52,211,153,0.1)"},{key:"cache",label:"Semantic Caching",emoji:"⚡",color:"#fbbf24",bgColor:"rgba(251,191,36,0.1)"}];function IA(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function pJ(e){return e===0?"$0.0000":e<1e-4?"<$0.0001":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:4}).format(e)}function hJ({stats:e,maxTokens:t,color:r,bgColor:n,label:i,emoji:o}){const a=t>0?Math.min(100,e.tokensSaved/t*100):0,s=e.tokensSaved>0;return x.jsxs("div",{style:{padding:"8px 10px",borderRadius:"8px",backgroundColor:s?n:"rgba(255,255,255,0.02)",border:`1px solid ${s?r+"30":"rgba(255,255,255,0.04)"}`,marginBottom:"6px",transition:"all 0.3s ease"},children:[x.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"4px"},children:[x.jsxs("span",{style:{fontSize:"11px",fontWeight:600,color:s?r:"#64748b",display:"flex",alignItems:"center",gap:"5px"},children:[x.jsx("span",{children:o}),x.jsx("span",{children:i})]}),x.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:s?r:"rgba(16,185,129,0.6)",letterSpacing:s?"normal":"0.05em",textTransform:s?"none":"uppercase"},children:s?`${IA(e.tokensSaved)} tkns`:"Monitoring"})]}),x.jsx("div",{style:{height:"3px",borderRadius:"2px",backgroundColor:"rgba(255,255,255,0.06)",overflow:"hidden"},children:x.jsx("div",{style:{height:"100%",width:`${a}%`,backgroundColor:r,borderRadius:"2px",transition:"width 0.6s ease",boxShadow:s?`0 0 6px ${r}80`:"none"}})})]})}function mJ(){const e=fe(o=>o.savingsBreakdown),t=fe(o=>o.metrics),r=j.useMemo(()=>{if(!e)return null;if(e.total.tokensSaved===0&&t&&t.tokensSaved>0){const o=JSON.parse(JSON.stringify(e));return o.cache.tokensSaved=t.tokensSaved,o.cache.costSaved=t.costSaved,o.total.tokensSaved=t.tokensSaved,o.total.costSaved=t.costSaved,o}return e},[e,t]);if(!r)return x.jsxs("div",{style:{padding:"14px 16px"},children:[x.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#94a3b8",letterSpacing:"0.08em",marginBottom:"10px",textTransform:"uppercase"},children:"💰 Savings Breakdown"}),x.jsx("div",{style:{fontSize:"11px",color:"#475569",textAlign:"center",padding:"16px 0"},children:"Waiting for first request…"})]});const n=r.total,i=Math.max(r.clipboard.tokensSaved,r.contextSqueeze.tokensSaved,r.historyPrune.tokensSaved,r.complexityRouting.tokensSaved,r.cache.tokensSaved,1);return x.jsxs("div",{style:{padding:"14px 16px"},children:[x.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"12px"},children:[x.jsxs("div",{children:[x.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#94a3b8",letterSpacing:"0.08em",textTransform:"uppercase"},children:"💰 Savings Breakdown"}),x.jsx("div",{style:{fontSize:"10px",color:"#10b981",fontWeight:"bold",marginTop:"1px"},children:"Lifetime Savings · Synced"})]}),x.jsxs("div",{style:{textAlign:"right"},children:[x.jsx("div",{style:{fontSize:"16px",fontWeight:800,color:n.tokensSaved>0?"#22d3ee":"#475569",lineHeight:1,textShadow:n.tokensSaved>0?"0 0 12px rgba(34,211,238,0.4)":"none"},children:pJ(n.costSaved)}),x.jsxs("div",{style:{fontSize:"10px",color:"#64748b",marginTop:"2px"},children:[IA(n.tokensSaved)," total tokens"]})]})]}),x.jsx("div",{children:dJ.map(({key:o,label:a,emoji:s,color:l,bgColor:u})=>x.jsx(hJ,{stats:r[o],maxTokens:i,label:a,emoji:s,color:l,bgColor:u},o))}),n.events>0&&x.jsxs("div",{style:{fontSize:"10px",color:"#475569",textAlign:"center",marginTop:"6px"},children:[n.events," savings event",n.events!==1?"s":""," recorded"]})]})}const yJ=()=>{const{fetchMetrics:e,fetchAgents:t,fetchEvents:r,fetchCacheStats:n,fetchSavingsBreakdown:i}=nf({enableSocket:!0}),o=fe(s=>s.refreshIntervalSeconds);j.useEffect(()=>{(async()=>{await Promise.all([e(),t(),r(),n(),i()])})();const l=o*1e3,u=setInterval(()=>{e(),t(),r(),n(),i()},l);return()=>{clearInterval(u)}},[e,t,r,n,i,o]);const a=fe(s=>s.activeSidePanel);return x.jsxs("div",{className:"h-screen bg-transparent flex flex-col overflow-hidden text-slate-200",children:[x.jsx(sC,{}),x.jsx("div",{className:"px-5 py-3 bg-slate-900/20 backdrop-blur-md border-b border-white/5 flex-shrink-0",children:x.jsx(lC,{})}),x.jsx("div",{className:"flex-1 overflow-hidden flex gap-4 p-4 min-h-0",children:a==="brain"?x.jsx("div",{className:"flex-1 panel-card overflow-hidden",children:x.jsx(fJ,{})}):x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"w-72 flex-shrink-0 overflow-hidden panel-card",children:x.jsx(dC,{})}),x.jsx("div",{className:"flex-1 overflow-y-auto space-y-4 pb-2 pr-0.5 min-h-0",children:x.jsx(oJ,{})}),x.jsxs("div",{className:"flex-shrink-0 flex flex-col gap-4 min-h-0",style:{width:"360px"},children:[x.jsx("div",{className:"panel-card flex-shrink-0",children:x.jsx(mJ,{})}),x.jsx("div",{className:"panel-card",style:{height:"30%"},children:x.jsx(sJ,{})}),x.jsx("div",{className:"flex-1 panel-card",children:x.jsx(uJ,{})})]})]})}),x.jsx(cJ,{}),x.jsx(Xj,{position:"top-right",toastOptions:{style:{background:"#1e293b",color:"#f1f5f9",borderRadius:"12px",border:"1px solid rgba(255,255,255,0.08)",fontSize:"13px",fontWeight:"600"},success:{iconTheme:{primary:"#10b981",secondary:"#fff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#fff"}}}})]})};class vJ extends E.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){console.error("Dashboard Error:",t,r)}render(){var t,r;return this.state.hasError?x.jsxs("div",{style:{width:"100vw",height:"100vh",background:"#0a0a0a",color:"white",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",fontFamily:"monospace",padding:"40px"},children:[x.jsx("h1",{style:{fontSize:"32px",marginBottom:"20px",color:"#ef4444"},children:"⚠️ Dashboard Error"}),x.jsxs("pre",{style:{background:"#1a1a1a",padding:"20px",borderRadius:"8px",maxWidth:"800px",overflow:"auto",fontSize:"14px",color:"#888"},children:[(t=this.state.error)==null?void 0:t.toString(),`
|
|
479
479
|
|
|
480
480
|
`,(r=this.state.error)==null?void 0:r.stack]})]}):this.props.children}}ep.createRoot(document.getElementById("root")).render(x.jsx(E.StrictMode,{children:x.jsx(vJ,{children:x.jsx(yJ,{})})}));
|
|
481
|
-
//# sourceMappingURL=index-
|
|
481
|
+
//# sourceMappingURL=index-BJzMIGrT.js.map
|