@adhdev/daemon-standalone 1.0.6 → 1.0.7-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "1.0.6",
3
+ "version": "1.0.7-rc.1",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -37,7 +37,7 @@
37
37
  "license": "AGPL-3.0-or-later",
38
38
  "dependencies": {
39
39
  "@adhdev/ghostty-vt-node": "*",
40
- "@adhdev/session-host-core": "*",
40
+ "@adhdev/session-host-core": "1.0.7-rc.1",
41
41
  "@xterm/addon-serialize": "^0.14.0",
42
42
  "@xterm/xterm": "^6.0.0",
43
43
  "chalk": "^5.3.0",
@@ -1,11 +1,11 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-BZj_X5zy.js","assets/vendor-cL4V2vaO.js","assets/terminal-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
- var vh=Object.defineProperty;var yh=(e,t,n)=>t in e?vh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var st=(e,t,n)=>yh(e,typeof t!="symbol"?t+"":t,n);import{r as l,j as s,u as Ne,M as wi,a as wh,b as kh,c as Sh,t as Ch,d as jh,i as wt,e as Nh,f as fn,R as Rt,T as Ho,g as mr,h as Bo,k as Fo,D as Ah,E as Mh,l as Ih,C as Th,m as Ph,B as Dh,n as Lh,o as Rh,p as Eh,H as yr,P as Cs,q as _h,s as $h,v as Hh,w as Sl,x as Bh,y as Fh,z as ki,A as Oh,F as Wh,G as Uh,I as Gh,J as js,N as Oo,K as qh}from"./vendor-cL4V2vaO.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function zh(e={}){const t=Math.max(1,Math.floor(e.capacity||200)),n=[];return{record(r){const a={id:`webdbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,ts:Date.now(),...r,payload:r.payload?{...r.payload}:{}};return n.push(a),n.length>t&&n.splice(0,n.length-t),a},list(r={}){const a=Math.max(1,Math.floor(r.limit||100));return n.filter(o=>!r.interactionId||o.interactionId===r.interactionId).filter(o=>!r.topic||o.topic===r.topic).filter(o=>!r.kind||o.kind===r.kind).slice(-a).map(o=>({...o,payload:o.payload?{...o.payload}:{}}))},clear(){n.splice(0,n.length)}}}const bn=zh();function Cl(e){const t={};for(const n of e)n.transport&&(t[n.transport]=(t[n.transport]||0)+1);return{count:e.length,ids:e.map(n=>n.id),statuses:e.map(n=>String(n.status||"unknown")),transports:t}}function Kh(e,t){return typeof e=="string"&&e.trim().length>0&&e!==t}function jl(e){return Array.isArray(e)?[...e]:[]}function Ld(e,t){if(!e)return t??null;const n=Object.prototype.hasOwnProperty.call(e,"messages"),r=Object.prototype.hasOwnProperty.call(e,"activeModal"),a=typeof e.id=="string"?e.id.trim():"",o=typeof(t==null?void 0:t.id)=="string"?t.id.trim():"",i=!!a&&!!o&&a!==o;return t?{...t,...e,messages:n?jl(e.messages):i?[]:t.messages,activeModal:r?e.activeModal??null:t.activeModal,inputContent:e.inputContent??t.inputContent}:{...e,...n?{messages:jl(e.messages)}:{},...r?{activeModal:e.activeModal??null}:{}}}function zn(e,t){const n=Kh(e.providerName,e.providerType)?e.providerName:void 0;return{...e,parentId:e.parentId??(t==null?void 0:t.parentSessionId)??null,providerSessionId:e.providerSessionId??(t==null?void 0:t.providerSessionId),providerName:n??(t==null?void 0:t.providerName)??(t==null?void 0:t.cliName)??(t==null?void 0:t.type)??e.providerName??e.providerType,title:e.title??(t==null?void 0:t.title)??n??(t==null?void 0:t.providerName)??e.providerName??e.providerType,workspace:e.workspace??(t==null?void 0:t.workspace)??null,mode:e.mode??(t==null?void 0:t.mode),capabilities:e.capabilities??(t==null?void 0:t.sessionCapabilities)??(t==null?void 0:t.capabilities)??[],cdpConnected:e.cdpConnected??(t==null?void 0:t.cdpConnected),activeChat:Ld(e.activeChat,t==null?void 0:t.activeChat),activeInteractivePrompt:Object.prototype.hasOwnProperty.call(e,"activeInteractivePrompt")?e.activeInteractivePrompt??null:(t==null?void 0:t.activeInteractivePrompt)??null,controlValues:e.controlValues??(t==null?void 0:t.controlValues),providerControls:e.providerControls??(t==null?void 0:t.providerControls),summaryMetadata:e.summaryMetadata??(t==null?void 0:t.summaryMetadata),runtimeWriteOwner:e.runtimeWriteOwner??(t==null?void 0:t.runtimeWriteOwner),runtimeAttachedClients:e.runtimeAttachedClients??(t==null?void 0:t.runtimeAttachedClients),lastMessagePreview:e.lastMessagePreview??(t==null?void 0:t.lastMessagePreview),lastMessageRole:e.lastMessageRole??(t==null?void 0:t.lastMessageRole),lastMessageAt:e.lastMessageAt??(t==null?void 0:t.lastMessageAt),lastMessageHash:e.lastMessageHash??(t==null?void 0:t.lastMessageHash),unread:e.unread??(t==null?void 0:t.unread),lastSeenAt:e.lastSeenAt??(t==null?void 0:t.lastSeenAt),inboxBucket:e.inboxBucket??(t==null?void 0:t.inboxBucket),completionMarker:e.completionMarker??(t==null?void 0:t.completionMarker),seenCompletionMarker:e.seenCompletionMarker??(t==null?void 0:t.seenCompletionMarker),surfaceHidden:e.surfaceHidden??(t==null?void 0:t.surfaceHidden),muted:e.muted??(t==null?void 0:t.muted),resume:e.resume??(t==null?void 0:t.resume),runtimeKey:e.runtimeKey??(t==null?void 0:t.runtimeKey),runtimeDisplayName:e.runtimeDisplayName??(t==null?void 0:t.runtimeDisplayName),runtimeWorkspaceLabel:e.runtimeWorkspaceLabel??(t==null?void 0:t.runtimeWorkspaceLabel),settings:e.settings??(t==null?void 0:t.settings)}}function Rd(e,t,n){if(!(t!=null&&t.length))return(n==null?void 0:n.preserveMissing)===!1&&Array.isArray(t)?t:e;if(!(e!=null&&e.length))return t;const r=t.map(a=>{const o=e.find(i=>i.id===a.id);return o?zn(a,o):a});if((n==null?void 0:n.preserveMissing)!==!1){const a=new Set(t.map(o=>o.id));for(const o of e)a.has(o.id)||r.push(o)}return r}function Nl(e){return!!e&&typeof e=="object"&&"text"in e}function Si(e,t){const n=(t==null?void 0:t.joiner)??" ",r=(t==null?void 0:t.normalizeWhitespace)??!1;let a="";return typeof e=="string"?a=e:Array.isArray(e)?a=e.map(o=>typeof o=="string"?o:Nl(o)?String(o.text||""):"").join(n):Nl(e)?a=String(e.text||""):a=String(e||""),r?a.replace(/\s+/g," ").trim():a}function gn(e){return Si(e,{normalizeWhitespace:!0})}function Vh(e){let t="";for(let n=0;n<e.length;n++){const r=e[n],a=e.charCodeAt(n);if(!(a<=31&&r!==`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-DiXj2eIR.js","assets/vendor-DyCWA2YZ.js","assets/terminal-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
+ var vh=Object.defineProperty;var yh=(e,t,n)=>t in e?vh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var st=(e,t,n)=>yh(e,typeof t!="symbol"?t+"":t,n);import{r as l,j as s,u as Ne,M as wi,a as wh,b as kh,c as Sh,t as Ch,d as jh,i as wt,e as Nh,f as fn,R as Rt,T as Ho,g as mr,h as Bo,k as Fo,D as Ah,E as Mh,l as Ih,C as Th,m as Ph,B as Dh,n as Lh,o as Rh,p as Eh,H as yr,P as Cs,q as _h,s as $h,v as Hh,w as Sl,x as Bh,y as Fh,z as ki,A as Oh,F as Wh,G as Uh,I as Gh,J as js,N as Oo,K as qh}from"./vendor-DyCWA2YZ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function zh(e={}){const t=Math.max(1,Math.floor(e.capacity||200)),n=[];return{record(r){const a={id:`webdbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,ts:Date.now(),...r,payload:r.payload?{...r.payload}:{}};return n.push(a),n.length>t&&n.splice(0,n.length-t),a},list(r={}){const a=Math.max(1,Math.floor(r.limit||100));return n.filter(o=>!r.interactionId||o.interactionId===r.interactionId).filter(o=>!r.topic||o.topic===r.topic).filter(o=>!r.kind||o.kind===r.kind).slice(-a).map(o=>({...o,payload:o.payload?{...o.payload}:{}}))},clear(){n.splice(0,n.length)}}}const bn=zh();function Cl(e){const t={};for(const n of e)n.transport&&(t[n.transport]=(t[n.transport]||0)+1);return{count:e.length,ids:e.map(n=>n.id),statuses:e.map(n=>String(n.status||"unknown")),transports:t}}function Kh(e,t){return typeof e=="string"&&e.trim().length>0&&e!==t}function jl(e){return Array.isArray(e)?[...e]:[]}function Ld(e,t){if(!e)return t??null;const n=Object.prototype.hasOwnProperty.call(e,"messages"),r=Object.prototype.hasOwnProperty.call(e,"activeModal"),a=typeof e.id=="string"?e.id.trim():"",o=typeof(t==null?void 0:t.id)=="string"?t.id.trim():"",i=!!a&&!!o&&a!==o;return t?{...t,...e,messages:n?jl(e.messages):i?[]:t.messages,activeModal:r?e.activeModal??null:t.activeModal,inputContent:e.inputContent??t.inputContent}:{...e,...n?{messages:jl(e.messages)}:{},...r?{activeModal:e.activeModal??null}:{}}}function zn(e,t){const n=Kh(e.providerName,e.providerType)?e.providerName:void 0;return{...e,parentId:e.parentId??(t==null?void 0:t.parentSessionId)??null,providerSessionId:e.providerSessionId??(t==null?void 0:t.providerSessionId),providerName:n??(t==null?void 0:t.providerName)??(t==null?void 0:t.cliName)??(t==null?void 0:t.type)??e.providerName??e.providerType,title:e.title??(t==null?void 0:t.title)??n??(t==null?void 0:t.providerName)??e.providerName??e.providerType,workspace:e.workspace??(t==null?void 0:t.workspace)??null,mode:e.mode??(t==null?void 0:t.mode),capabilities:e.capabilities??(t==null?void 0:t.sessionCapabilities)??(t==null?void 0:t.capabilities)??[],cdpConnected:e.cdpConnected??(t==null?void 0:t.cdpConnected),activeChat:Ld(e.activeChat,t==null?void 0:t.activeChat),activeInteractivePrompt:Object.prototype.hasOwnProperty.call(e,"activeInteractivePrompt")?e.activeInteractivePrompt??null:(t==null?void 0:t.activeInteractivePrompt)??null,controlValues:e.controlValues??(t==null?void 0:t.controlValues),providerControls:e.providerControls??(t==null?void 0:t.providerControls),summaryMetadata:e.summaryMetadata??(t==null?void 0:t.summaryMetadata),runtimeWriteOwner:e.runtimeWriteOwner??(t==null?void 0:t.runtimeWriteOwner),runtimeAttachedClients:e.runtimeAttachedClients??(t==null?void 0:t.runtimeAttachedClients),lastMessagePreview:e.lastMessagePreview??(t==null?void 0:t.lastMessagePreview),lastMessageRole:e.lastMessageRole??(t==null?void 0:t.lastMessageRole),lastMessageAt:e.lastMessageAt??(t==null?void 0:t.lastMessageAt),lastMessageHash:e.lastMessageHash??(t==null?void 0:t.lastMessageHash),unread:e.unread??(t==null?void 0:t.unread),lastSeenAt:e.lastSeenAt??(t==null?void 0:t.lastSeenAt),inboxBucket:e.inboxBucket??(t==null?void 0:t.inboxBucket),completionMarker:e.completionMarker??(t==null?void 0:t.completionMarker),seenCompletionMarker:e.seenCompletionMarker??(t==null?void 0:t.seenCompletionMarker),surfaceHidden:e.surfaceHidden??(t==null?void 0:t.surfaceHidden),muted:e.muted??(t==null?void 0:t.muted),resume:e.resume??(t==null?void 0:t.resume),runtimeKey:e.runtimeKey??(t==null?void 0:t.runtimeKey),runtimeDisplayName:e.runtimeDisplayName??(t==null?void 0:t.runtimeDisplayName),runtimeWorkspaceLabel:e.runtimeWorkspaceLabel??(t==null?void 0:t.runtimeWorkspaceLabel),settings:e.settings??(t==null?void 0:t.settings)}}function Rd(e,t,n){if(!(t!=null&&t.length))return(n==null?void 0:n.preserveMissing)===!1&&Array.isArray(t)?t:e;if(!(e!=null&&e.length))return t;const r=t.map(a=>{const o=e.find(i=>i.id===a.id);return o?zn(a,o):a});if((n==null?void 0:n.preserveMissing)!==!1){const a=new Set(t.map(o=>o.id));for(const o of e)a.has(o.id)||r.push(o)}return r}function Nl(e){return!!e&&typeof e=="object"&&"text"in e}function Si(e,t){const n=(t==null?void 0:t.joiner)??" ",r=(t==null?void 0:t.normalizeWhitespace)??!1;let a="";return typeof e=="string"?a=e:Array.isArray(e)?a=e.map(o=>typeof o=="string"?o:Nl(o)?String(o.text||""):"").join(n):Nl(e)?a=String(e.text||""):a=String(e||""),r?a.replace(/\s+/g," ").trim():a}function gn(e){return Si(e,{normalizeWhitespace:!0})}function Vh(e){let t="";for(let n=0;n<e.length;n++){const r=e[n],a=e.charCodeAt(n);if(!(a<=31&&r!==`
3
3
  `&&r!==" ")&&!(a>=127&&a<=159)&&!(a>=8203&&a<=8207||a>=8234&&a<=8238||a===8288||a===65279)&&a!==65533){if(a===65038||a===65039){const o=t.length>0?t[t.length-1]:"";if(!o||o===`
4
4
  `||o===" "||o===" ")continue}t+=r}}return t}function Al(e){var n,r;let t=0;return e.activeChat!==void 0&&(t+=4),e.activeInteractivePrompt!==void 0&&(t+=2),(n=e.childSessions)!=null&&n.length&&(t+=2),e.workspace&&(t+=1),e.machine&&(t+=1),(r=e.agents)!=null&&r.length&&(t+=1),t}function Ed(e,t,n){if(n.type!=="adhdev-daemon")return n;const r={...n},a=t.version??n.version??e.version,o=t.serverVersion??e.serverVersion??n.serverVersion,i=t.versionMismatch===!0||e.versionMismatch===!0,c=t.versionUpdateRequired===!0||e.versionUpdateRequired===!0,d=t.versionUpdateReason??e.versionUpdateReason??n.versionUpdateReason;return a&&(r.version=a),o&&(r.serverVersion=o),d&&(r.versionUpdateReason=d),a&&o&&a===o?(delete r.versionMismatch,delete r.serverVersion,delete r.versionUpdateRequired,delete r.versionUpdateReason,r):((t.versionMismatch===!0||i&&a&&o&&a!==o)&&(r.versionMismatch=!0),c&&(r.versionUpdateRequired=!0),r)}function Yh(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function Wa(e){if(!e||typeof e!="object")return"";const t=e,n=Yh(gn(t.content).slice(0,512));return[String(t.id||""),String(t._localId||""),String(t._turnKey||""),String(t.index??""),String(t.role||""),String(t.receivedAt??t.timestamp??""),n].join(":")}function Jh(e,t){if(!Array.isArray(e))return e;if(t!=null&&t.has(e))return{count:e.length,sharedRef:!0};let n=2166136261;for(const r of e){const a=Wa(r);for(let o=0;o<a.length;o+=1)n^=a.charCodeAt(o),n=Math.imul(n,16777619)>>>0}return{count:e.length,hash:n.toString(16).padStart(8,"0"),first:Wa(e[0]),last:Wa(e[e.length-1])}}function Wo(e){return!!e&&typeof e=="object"&&"messages"in e&&("activeModal"in e||"inputContent"in e||"status"in e)}function Uo(e,t,n){if(!e||!t||typeof e!="object"||typeof t!="object")return;if(Wo(e)&&Wo(t)){const i=e.messages;Array.isArray(i)&&i===t.messages&&n.add(i)}if(Array.isArray(e)&&Array.isArray(t)){const i=Math.min(e.length,t.length);for(let c=0;c<i;c+=1)Uo(e[c],t[c],n);return}const r=e,a=t,o=new Set([...Object.keys(r),...Object.keys(a)]);for(const i of o)i!=="messages"&&Uo(r[i],a[i],n)}function Jn(e,t){return Array.isArray(e)?e.map(n=>Jn(n,t)):!e||typeof e!="object"?e:Wo(e)?Object.fromEntries(Object.entries(e).filter(([r])=>r!=="timestamp"&&r!=="_lastUpdate").sort(([r],[a])=>r.localeCompare(a)).map(([r,a])=>[r,r==="messages"?Jh(a,t):Jn(a,t)])):Object.fromEntries(Object.entries(e).filter(([n])=>n!=="timestamp"&&n!=="_lastUpdate").sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,Jn(r,t)]))}function Qh(e,t){try{const n=new WeakSet;return Uo(e,t,n),JSON.stringify(Jn(e,n))===JSON.stringify(Jn(t,n))}catch{return!1}}function Go(e,t,n){return Qh(e,t)?(e._lastUpdate=n,typeof t.timestamp=="number"&&(e.timestamp=t.timestamp),e):t}function _d(e){var t;return e.daemonId||((t=e.id)==null?void 0:t.split(":")[0])||e.id}function Xh(e,t,n){t[n]!==void 0&&(e[n]=t[n])}function Ml(e,t,n,r){var d;const a=(d=t.chats)!=null&&d.length?t.chats:e.chats,o=Rd(e.childSessions,t.childSessions,{preserveMissing:r}),i=Ld(t.activeChat,e.activeChat),c=t.workspace||e.workspace;return Ed(e,t,{...e,...t,chats:a,childSessions:o,activeChat:i,workspace:c,_lastUpdate:n})}function Zh(e,t,n){var a,o;const r={};t.status&&t.status!==e.status&&(r.status=t.status),t.cdpConnected!==void 0&&(r.cdpConnected=t.cdpConnected),t.childSessions!==void 0&&(r.childSessions=Rd(e.childSessions,t.childSessions,{preserveMissing:n})),(a=t.chats)!=null&&a.length&&!((o=e.chats)!=null&&o.length)&&(r.chats=t.chats),t.workspace&&(r.workspace=t.workspace);for(const i of["title","providerSessionId","parentSessionId","sessionKind","sessionCapabilities","controlValues","providerControls","summaryMetadata","activeInteractivePrompt","lastMessagePreview","lastMessageRole","lastMessageAt","lastMessageHash","lastUpdated","unread","lastSeenAt","inboxBucket","completionMarker","seenCompletionMarker","surfaceHidden","muted","runtimeKey","runtimeDisplayName","runtimeWorkspaceLabel","runtimeWriteOwner","runtimeAttachedClients","version","serverVersion","versionUpdateReason","versionUpdateRequired","updateCommand","updatePolicy","updateChannel","releaseChannel"])Xh(r,t,i);return t.machineNickname!==void 0&&t.machineNickname!==e.machineNickname&&(r.machineNickname=t.machineNickname),t.versionMismatch===!0&&(r.versionMismatch=!0),r}function ef(e,t,n,r){const a=Zh(e,t,r),o=Object.keys(a).length>0?Ed(e,t,{...e,...a,_lastUpdate:n}):{...e,_lastUpdate:n};return Go(e,o,n)}function tf(e){const t=new Set(e.map(o=>o.id)),n=new Set,r=new Set,a=new Set;for(const o of e){const i=_d(o);i&&n.add(i),i&&o.type!=="adhdev-daemon"&&r.add(i),i&&o.type==="adhdev-daemon"&&o._sessionListAuthoritative&&a.add(i)}return{incomingIds:t,incomingDaemonIds:n,daemonIdsWithSessionEntries:r,daemonIdsWithAuthoritativeSessionList:a}}function sf(e,t,n,r,a,o){return!a.has(t)||!o.has(t)||r.has(e.id)?!1:e.transport==="pty"||e.transport==="acp"?n>1e4:e.transport==="cdp-page"?n>3e4:!1}function nf(e,t,n,r,a){return e.transport?n.has(t)&&!r.has(t)?!0:a.has(t):!1}function rf(e,t,n){var u,m;const r=Date.now(),a=new Set((n==null?void 0:n.authoritativeDaemonIds)||[]);if(t.length===0)return e.map(f=>({...f,_lastUpdate:r}));const o=new Map;for(const f of t)o.set(f.id,f);const{incomingIds:i,incomingDaemonIds:c,daemonIdsWithSessionEntries:d,daemonIdsWithAuthoritativeSessionList:p}=tf(e);for(const f of e){const g=o.get(f.id);if(!g){o.set(f.id,{...f,_lastUpdate:r});continue}const j=Al(f),h=Al(g),x=_d(f),w=!a.has(x);if(j>h){const S=Ml(g,f,r,w);o.set(f.id,Go(g,S,r));continue}if(j<h){o.set(f.id,ef(g,f,r,w));continue}const b=f.timestamp||r,C=g._lastUpdate||g.timestamp||0;if(b>=C){const S=Ml(g,f,r,w);o.set(f.id,Go(g,S,r));continue}(u=f.chats)!=null&&u.length&&!((m=g.chats)!=null&&m.length)&&o.set(f.id,{...g,chats:f.chats})}for(const[f,g]of o){const j=g.daemonId||f.split(":")[0];if(!c.has(j))continue;if(a.has(j)&&p.has(j)&&!i.has(f)){o.delete(f);continue}const h=r-(g._lastUpdate||g.timestamp||0);sf(g,j,h,i,a,d)&&o.delete(f)}for(const[f,g]of o){const j=g.daemonId||f.split(":")[0];if(nf(g,j,c,d,o))continue;r-(g._lastUpdate||g.timestamp||0)>3e5&&g.status!=="online"&&o.delete(f)}return Array.from(o.values())}function af(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}const $d=l.createContext({ides:[],updateRouteChats:()=>{},initialLoaded:!1,toasts:[],setToasts:()=>{},wsStatus:"connected",isConnected:!0,connectionStates:{},connectionTransports:{},showReconnected:!1,userName:void 0,setUserName:()=>{},isP2PActive:!1,p2pStates:{},userRole:void 0,connectionRetryStatuses:void 0}),Hd=l.createContext({injectEntries:()=>{},markLoaded:()=>{},getIdes:()=>[]});function of({children:e,connectionOverrides:t}){const[n,r]=l.useState([]),[a,o]=l.useState(!1),[i,c]=l.useState([]),[d,p]=l.useState(void 0),u=l.useRef(n);l.useEffect(()=>{u.current=n},[n]);const m=l.useCallback((w,b)=>{r(C=>{let S=!1;const k=C.map(v=>v.id!==w||v.chats===b?v:(S=!0,{...v,chats:b}));return S?k:C})},[]),f=l.useCallback((w,b)=>{r(C=>{const S=C.length===0?w:rf(w,C,b),k=!af(C,S);return k&&bn.record({kind:"dashboard.entries_applied",payload:{incoming:Cl(w),next:Cl(S)}}),k?S:C})},[]),g=l.useCallback(()=>o(!0),[]),j=l.useMemo(()=>({injectEntries:f,markLoaded:g,getIdes:()=>u.current}),[f,g]),h=t,x=l.useMemo(()=>({ides:n,updateRouteChats:m,initialLoaded:a,toasts:i,setToasts:c,wsStatus:(h==null?void 0:h.wsStatus)??"connected",isConnected:(h==null?void 0:h.isConnected)??!0,connectionStates:(h==null?void 0:h.connectionStates)??{},connectionTransports:(h==null?void 0:h.connectionTransports)??{},showReconnected:(h==null?void 0:h.showReconnected)??!1,retryConnection:h==null?void 0:h.retryConnection,retryServerConnection:h==null?void 0:h.retryServerConnection,connectionLoginUrl:h==null?void 0:h.connectionLoginUrl,isP2PActive:(h==null?void 0:h.isP2PActive)??!1,p2pStates:(h==null?void 0:h.p2pStates)??{},userRole:h==null?void 0:h.userRole,connectionRetryStatuses:h==null?void 0:h.connectionRetryStatuses,userName:d,setUserName:p}),[n,m,a,i,h==null?void 0:h.wsStatus,h==null?void 0:h.isConnected,h==null?void 0:h.connectionStates,h==null?void 0:h.connectionTransports,h==null?void 0:h.showReconnected,h==null?void 0:h.retryConnection,h==null?void 0:h.retryServerConnection,h==null?void 0:h.connectionLoginUrl,h==null?void 0:h.isP2PActive,h==null?void 0:h.p2pStates,h==null?void 0:h.userRole,h==null?void 0:h.connectionRetryStatuses,d]);return s.jsx(Hd.Provider,{value:j,children:s.jsx($d.Provider,{value:x,children:e})})}function gs(){return l.useContext($d)}function ar(){return l.useContext(Hd)}function Bd(e){const{baseUrl:t,getToken:n,onUnauthorized:r}=e;function a(c){return c.startsWith("http")?c:`${t}${c.startsWith("/")?"":"/"}${c}`}function o(c){const d=n==null?void 0:n(),p=a(c),u=c.startsWith("http")?new URL(p):new URL(p,typeof window<"u"?window.location.origin:"http://localhost");return d&&u.searchParams.set("token",d),!c.startsWith("http")&&!t?`${u.pathname}${u.search}${u.hash}`:u.toString()}async function i(c,d={}){const p={"Content-Type":"application/json",...d.headers||{}},u=n==null?void 0:n();u&&(p.Authorization=`Bearer ${u}`);const m=a(c),f=new AbortController,g=setTimeout(()=>f.abort(),15e3);try{const j=await fetch(m,{...d,headers:p,signal:f.signal});if(j.status===401)throw r==null||r(),new Error("Unauthorized");if(!j.ok){const h=await j.json().catch(()=>({error:j.statusText}));throw new Error(h.error||`API Error: ${j.status}`)}return j.json()}finally{clearTimeout(g)}}return{getDaemons:()=>i("/api/v1/daemons"),getDaemonStatus:c=>i(`/api/v1/daemons/${c}/status`),sendCommand:(c,d,p={})=>i(`/api/v1/daemons/${c}/command`,{method:"POST",body:JSON.stringify({type:d,payload:p})}),execTerminal:(c,d,p)=>i(`/api/v1/daemons/${c}/terminal`,{method:"POST",body:JSON.stringify({command:d,name:p})}),sendAgentMessage:(c,d,p)=>i(`/api/v1/shortcuts/${c}/chat`,{method:"POST",body:JSON.stringify({agentType:d,message:p})}),getAgentStatus:c=>i(`/api/v1/shortcuts/${c}/status`),approveAgent:(c,d,p)=>i(`/api/v1/shortcuts/${c}/approve`,{method:"POST",body:JSON.stringify({agentType:d,action:p?"approve":"reject"})}),getMuxState:c=>i(`/api/v1/mux/${encodeURIComponent(c)}/state`),getMuxSocketInfo:c=>i(`/api/v1/mux/${encodeURIComponent(c)}/socket-info`),controlMux:(c,d,p={})=>i(`/api/v1/mux/${encodeURIComponent(c)}/control`,{method:"POST",body:JSON.stringify({type:d,payload:p})}),getMuxEventsUrl:c=>o(`/api/v1/mux/${encodeURIComponent(c)}/events`),getRuntimeEventsUrl:c=>o(`/api/v1/runtime/${encodeURIComponent(c)}/events`),request:i}}const lf=Bd({baseUrl:"http://localhost:3847"}),cf=l.createContext(lf);function df({client:e,children:t}){return s.jsx(cf.Provider,{value:e,children:t})}const uf={sendCommand:async()=>{throw new Error("TransportContext not initialized")}},Fd=l.createContext(uf);function pf({value:e,children:t}){return s.jsx(Fd.Provider,{value:e,children:t})}function vt(){return l.useContext(Fd)}function Od(e){return e&&typeof e=="object"&&e.result&&typeof e.result=="object"?e.result:e}function mf(e){const t=Od(e);if(!t||t.error!=="untrusted_external_provider")return null;const n=t.provider&&typeof t.provider=="object"?t.provider:null;return{providerType:typeof(n==null?void 0:n.type)=="string"?n.type:null,sourceName:typeof(n==null?void 0:n.sourceName)=="string"?n.sourceName:null,description:typeof t.hint=="string"?t.hint:void 0}}function hf(e){const[t,n]=l.useState(null),r=l.useCallback(async(i,c)=>{const d=m=>e(i,"launch_cli",{...c,...m}),p=await d({}),u=mf(p);return u?new Promise(m=>{n({providerType:u.providerType||String(c.cliType??"?"),sourceName:u.sourceName,description:u.description,retry:()=>d({confirmExternalUntrusted:!0}),resolve:f=>{f.cancelled?m({success:!1,error:"user_cancelled_untrusted_launch"}):m(f.response)}})}):p},[e]),a=l.useCallback(async()=>{const i=t;if(i){n(null);try{const c=await i.retry(),d=Od(c);d!=null&&d.success?i.resolve({ok:!0,response:c}):i.resolve({ok:!1,error:(d==null?void 0:d.error)||"launch failed after confirm",response:c})}catch(c){i.resolve({ok:!1,error:(c==null?void 0:c.message)||String(c)})}}},[t]),o=l.useCallback(()=>{const i=t;i&&(n(null),i.resolve({ok:!1,cancelled:!0}))},[t]);return{launchCli:r,pending:t,confirm:a,cancel:o}}function ff({providerType:e,sourceName:t,description:n,onConfirm:r,onCancel:a}){const{t:o}=Ne("common"),i=l.useRef(null);return l.useEffect(()=>{var c;(c=i.current)==null||c.focus()},[]),l.useEffect(()=>{const c=d=>{d.key==="Escape"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),s.jsx("div",{role:"dialog","aria-modal":"true","aria-label":o("machine.confirmExternal.dialogAria"),className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:a,style:{pointerEvents:"auto"},children:s.jsxs("div",{className:"bg-[var(--surface-primary)] text-text-primary border border-amber-500/40 rounded-lg shadow-xl max-w-lg w-full",onClick:c=>c.stopPropagation(),children:[s.jsxs("div",{className:"px-4 py-3 border-b border-border-subtle flex items-center gap-2",children:[s.jsx("span",{"aria-hidden":!0,className:"text-amber-400 text-base",children:"⚠"}),s.jsx("h2",{className:"text-sm font-semibold",children:o("machine.confirmExternal.title")})]}),s.jsxs("div",{className:"px-4 py-3 text-[12px] flex flex-col gap-3",children:[s.jsxs("p",{children:["You're about to activate ",s.jsx("span",{className:"font-mono",children:e}),t?s.jsxs(s.Fragment,{children:[" from ",s.jsx("span",{className:"font-mono",children:t})]}):null,"."]}),s.jsx("p",{className:"text-text-secondary",children:n??o("machine.confirmExternal.description")}),s.jsx("p",{className:"text-text-secondary",children:o("machine.confirmExternal.proceedWarning")})]}),s.jsxs("div",{className:"px-4 py-2 border-t border-border-subtle flex justify-end gap-2",children:[s.jsx("button",{ref:i,type:"button",onClick:a,className:"px-3 py-1 text-sm rounded border border-border-default hover:bg-surface-secondary",children:o("machine.confirmExternal.cancel")}),s.jsx("button",{type:"button",onClick:r,className:"px-3 py-1 text-sm rounded bg-amber-500 text-black font-semibold hover:opacity-90",children:o("machine.confirmExternal.activate")})]})]})})}const Wd=l.createContext(null);function bf({sendDaemonCommand:e,children:t}){const n=hf(e),r=l.useMemo(()=>({launchCli:n.launchCli}),[n.launchCli]);return s.jsxs(Wd.Provider,{value:r,children:[t,n.pending&&s.jsx(ff,{providerType:n.pending.providerType,sourceName:n.pending.sourceName,description:n.pending.description,onConfirm:n.confirm,onCancel:n.cancel})]})}function wa(){const e=l.useContext(Wd);return e||{launchCli:async()=>{throw new Error("useLaunchCli must be used inside <LaunchCliProvider>")}}}function Ud(e){return e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):""}function gf(e,t,n){return Number(e.receivedAt||n[ta(e)]||0)||0}function Gd(e){return/[`*_#[\]()>-]|https?:\/\/|\n\s*[-*]\s|\n\s*\d+\.\s|\|/.test(e)}function xf(e){return Array.isArray(e)&&e.some(t=>!!t&&typeof t=="object"&&"type"in t)}function Dn(e,t){if(!e)return t;try{return(e.startsWith("file://")?new URL(e).pathname:e).split(/[\\/]/).filter(Boolean).pop()||t}catch{return e.split(/[\\/]/).filter(Boolean).pop()||t}}function Ua(e){if(typeof e.uri=="string"&&e.uri)return e.uri;if(typeof e.data=="string"&&e.data&&typeof e.mimeType=="string"&&e.mimeType)return`data:${e.mimeType};base64,${e.data}`}function vf(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n),t|=0;return(t>>>0).toString(36)}function ta(e,t){const n=e,r=Si(e.content,{joiner:`
5
5
  `}),a=[e.id?`id:${e.id}`:"",n._localId?`local:${n._localId}`:"",n._turnKey?`turn:${n._turnKey}`:"",e.bubbleId?`bubble:${e.bubbleId}`:"",e.providerUnitKey?`unit:${e.providerUnitKey}`:"",typeof e.index=="number"?`msgIndex:${e.index}`:"",typeof e.sequence=="number"?`seq:${e.sequence}`:""].filter(Boolean);if(a.length>0)return a.join("|");const o=e.receivedAt||e.timestamp||0;return[e.role?`role:${e.role}`:"role:",`chash:${vf(r)}`,o?`ts:${o}`:""].filter(Boolean).join("|")}function yf(e){let t=2166136261;for(const n of e){const r=String(n||"");for(let a=0;a<r.length;a+=1)t^=r.charCodeAt(a),t=Math.imul(t,16777619)>>>0;t^=255,t=Math.imul(t,16777619)>>>0}return t.toString(16).padStart(8,"0")}function wf(e){try{return JSON.stringify(e??"")}catch{return String(e??"")}}function qd(e){return e?yf([String(e.id||""),String(e.index??""),String(e.role||""),String(e.receivedAt??e.timestamp??""),wf(e.content)]):""}const Ci=200,kf=80,Il=650,Ln=new Map;function sa(e,t){if(!e)return!1;const n=String(e.messageFingerprint||"");return n?n===String(t||""):!0}function Sf(e,t){if(!Array.isArray(e)||e.length===0)return"0:empty";const n=String(t||"").trim();if(n)return`${e.length}:${n}`;const r=e[e.length-1];return`${e.length}:${qd(r)}`}function Cf(e,t,n,r){return e||!t?!1:sa(n,r)}function jf({scrollTop:e,scrollHeight:t,clientHeight:n,topThresholdPx:r=kf,bottomThresholdPx:a=Ci}){const o=Math.max(0,Number(e)||0),i=Math.max(0,Number(t)||0),c=Math.max(0,Number(n)||0);return Math.max(0,i-c)<=0?{showTop:!1,showBottom:!1}:{showTop:o>r,showBottom:Math.max(0,i-o-c)>a}}function Nf(e){return jf({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})}function Kn(e,t=Ci){return!!e&&e.fromBottom>=t}function Af(e,t){return sa(e,t)?!Kn(e):!0}function Mf({hasSelection:e,userScrolledUp:t,hasChatContentChanged:n=!0}){return!(e||t||!n)}function If({hasSelection:e,userScrolledUp:t,contextAutoScrollActive:n}){return e?!1:n||!t}function Ga(e,t){const n=Math.max(0,e.scrollHeight-e.clientHeight-t.fromBottom);e.scrollTop=Number.isFinite(n)?n:t.top}const Je={size:18};function zd({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}function ji({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("polyline",{points:"15 18 9 12 15 6"})})}function Is({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2"}),s.jsx("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2"}),s.jsx("circle",{cx:"6",cy:"6",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"6",cy:"18",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"10",y1:"6",x2:"18",y2:"6"}),s.jsx("line",{x1:"10",y1:"18",x2:"18",y2:"18"})]})}function Kd({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"9",cy:"7",r:"4"}),s.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),s.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function Tf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}function Pf({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})})}function Vd({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),s.jsx("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"}),s.jsx("line",{x1:"9",y1:"7",x2:"16",y2:"7"}),s.jsx("line",{x1:"9",y1:"11",x2:"14",y2:"11"})]})}function Yd({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),s.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"14",y2:"14"}),s.jsx("line",{x1:"8",y1:"18",x2:"12",y2:"18"})]})}function Jd({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}function ka({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function Ni({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function Df({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),s.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function Lf({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})})}function Xs({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function us({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function Ai({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),s.jsx("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]})}function xn({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function Sa({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}function Vs({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),s.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),s.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function or({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M12 22v-5"}),s.jsx("path",{d:"M9 8V2"}),s.jsx("path",{d:"M15 8V2"}),s.jsx("path",{d:"M18 8v5a6 6 0 0 1-12 0V8z"})]})}function es({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("circle",{cx:"5",cy:"19",r:"2"}),s.jsx("circle",{cx:"19",cy:"19",r:"2"}),s.jsx("line",{x1:"12",y1:"7",x2:"5",y2:"17"}),s.jsx("line",{x1:"12",y1:"7",x2:"19",y2:"17"}),s.jsx("line",{x1:"5",y1:"19",x2:"19",y2:"19"})]})}function Rf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),s.jsx("polyline",{points:"2 12 12 17 22 12"}),s.jsx("polyline",{points:"2 17 12 22 22 17"})]})}function Qd({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Mi({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 20C5 20 1 12 1 12a21.8 21.8 0 0 1 5.06-5.94"}),s.jsx("path",{d:"M9.9 4.24A10.93 10.93 0 0 1 12 4c7 0 11 8 11 8a21.77 21.77 0 0 1-2.16 3.19"}),s.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),s.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Xd({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]})}function Ef({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),s.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),s.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function Ii({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function _f({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})]})}function Zd({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})}function Ti({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function At({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function $f({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),s.jsx("path",{d:"M12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),s.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),s.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function Hf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"8",width:"18",height:"12",rx:"2"}),s.jsx("path",{d:"M12 2v6"}),s.jsx("circle",{cx:"8.5",cy:"14",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15.5",cy:"14",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Bf({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})})}function Ff({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"9",y:"10",width:"6",height:"12",rx:"1"}),s.jsx("path",{d:"M12 2c-1.5 2-3 3.5-3 5a3 3 0 0 0 6 0c0-1.5-1.5-3-3-5z"})]})}function Nn({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}function eu({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M8.7 3A6 6 0 0 1 18 8c0 3 .6 5 1.4 6.5"}),s.jsx("path",{d:"M17 17H3s3-2 3-9a5.98 5.98 0 0 1 .6-2.6"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]})}function Of({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"5"}),s.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),s.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),s.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),s.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),s.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),s.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),s.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),s.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})}function Wf({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}function Uf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function tu({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),s.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}function Gf({size:e=Je.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}function qf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),s.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"})]})}function zf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M14.5 10c-.83 0-1.5-.89-1.5-2s.67-2 1.5-2 1.5.89 1.5 2-.67 2-1.5 2z"}),s.jsx("path",{d:"M9.5 10c-.83 0-1.5-.89-1.5-2s.67-2 1.5-2 1.5.89 1.5 2-.67 2-1.5 2z"}),s.jsx("path",{d:"M19.35 6.07A16.03 16.03 0 0 0 15 4a.84.84 0 0 0-.46.33 11 11 0 0 0-.74 1.5 15.68 15.68 0 0 0-3.6 0 11.23 11.23 0 0 0-.74-1.5A.84.84 0 0 0 9 4a16.03 16.03 0 0 0-4.35 2.07A16.8 16.8 0 0 0 2 15a16.22 16.22 0 0 0 4 3c.12.08.27.06.37-.04a11.14 11.14 0 0 0 1.2-1.92.35.35 0 0 0-.18-.46 10.4 10.4 0 0 1-1.63-.78.36.36 0 0 1 .03-.6 6.8 6.8 0 0 0 .32-.24.36.36 0 0 1 .37-.04c2.2.98 4.6.98 6.8 0a.36.36 0 0 1 .37.04c.1.08.21.16.32.24a.36.36 0 0 1 .03.6 10.4 10.4 0 0 1-1.63.78.35.35 0 0 0-.18.46c.39.67.8 1.3 1.2 1.92a.37.37 0 0 0 .37.04 16.22 16.22 0 0 0 4-3 16.8 16.8 0 0 0-2.65-8.93z"})]})}function Kf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"7",width:"15",height:"14",rx:"2"}),s.jsx("path",{d:"M13 2h9v9"}),s.jsx("path",{d:"M22 2L13 11"})]})}function Vf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polyline",{points:"9 14 4 9 9 4"}),s.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]})}function Yf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),s.jsx("line",{x1:"6",y1:"8",x2:"6.01",y2:"8"}),s.jsx("line",{x1:"10",y1:"8",x2:"10.01",y2:"8"}),s.jsx("line",{x1:"14",y1:"8",x2:"14.01",y2:"8"}),s.jsx("line",{x1:"18",y1:"8",x2:"18.01",y2:"8"}),s.jsx("line",{x1:"6",y1:"12",x2:"6.01",y2:"12"}),s.jsx("line",{x1:"10",y1:"12",x2:"10.01",y2:"12"}),s.jsx("line",{x1:"14",y1:"12",x2:"14.01",y2:"12"}),s.jsx("line",{x1:"18",y1:"12",x2:"18.01",y2:"12"}),s.jsx("line",{x1:"7",y1:"16",x2:"17",y2:"16"})]})}function Jf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"6",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2"})]})}function Qf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"}),s.jsx("line",{x1:"3",y1:"12",x2:"12",y2:"12"})]})}function Xf({size:e=Je.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}const su="adhdev_chat_activity_visible",Tl=new Set(["hidden","debug","internal"]),Pl=new Set(["visible","user","chat"]),Zf=new Set(["debug","trace","internal"]),eb=new Set(["tool_call","terminal_command","runtime_activity"]),tb=new Set(["runtime_status","provider_chrome","control"]),sb=new Set(["thought","tool","terminal"]);function nu(e){const t=e.meta;return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function rn(e){return typeof e=="string"?e.trim().toLowerCase():""}function qa(e,t,n){return e[n]??(t==null?void 0:t[n])}function Dl(e,t,n){const r=e;return n.some(a=>r[a]===!0||(t==null?void 0:t[a])===!0)}function nb(e,t){const n=rn(e.kind);return n||(t==="tool"?"tool":"standard")}function za(e,t,n){const r=nu(e),a=typeof(r==null?void 0:r.label)=="string"?r.label.trim():"";return a||(t==="terminal"||n==="terminal_command"?"Terminal":t==="tool"||n==="tool_call"?"Tool":t==="thought"?"Thought":n==="runtime_activity"?"Runtime":"Activity")}function rb(e){const t=e.content;return Array.isArray(t)&&t.some(n=>!!n&&typeof n=="object"&&n.type!=="text")}function Pi(e){if(!e)return{surface:"internal",isUserFacing:!1,isActivityFacing:!1,isInternal:!0,role:"",kind:"standard",label:"Internal"};const t=nu(e),n=rn(e.role),r=nb(e,n),a=rn(qa(e,t,"visibility")),o=rn(e.transcriptVisibility??(t==null?void 0:t.transcriptVisibility)??a),i=rn(qa(e,t,"audience")),c=rn(qa(e,t,"source")),d=Tl.has(a)||Tl.has(o)||Zf.has(i)||Dl(e,t,["internal","isInternal","debug","statusOnly","controlOnly"]),p=Pl.has(a)||Pl.has(o)||i==="chat"||Dl(e,t,["userFacing"]),u=sb.has(r)||eb.has(c);if(d)return{surface:u?"activity":"internal",isUserFacing:!1,isActivityFacing:u,isInternal:!u,role:n,kind:r,label:za(e,r,c)};if(p)return{surface:"chat",isUserFacing:!0,isActivityFacing:!1,isInternal:!1,role:n,kind:r,label:za(e,r,c)};if((n==="system"||r==="system")&&rb(e))return{surface:"chat",isUserFacing:!0,isActivityFacing:!1,isInternal:!1,role:n,kind:r,label:"Chat"};if(tb.has(c)||n==="system"||r==="system")return{surface:"internal",isUserFacing:!1,isActivityFacing:!1,isInternal:!0,role:n,kind:r,label:"Internal"};if(u)return{surface:"activity",isUserFacing:!1,isActivityFacing:!0,isInternal:!1,role:n,kind:r,label:za(e,r,c)};const m=(n==="user"||n==="human"||n==="assistant")&&(r==="standard"||r==="");return{surface:m?"chat":"internal",isUserFacing:m,isActivityFacing:!1,isInternal:!m,role:n,kind:r,label:m?"Chat":"Internal"}}function ab(e){return(Array.isArray(e)?e:[]).filter(t=>Pi(t).isUserFacing)}function ru(e){return(Array.isArray(e)?e:[]).filter(t=>Pi(t).isActivityFacing)}function au(e){const t=e.content;return typeof t=="string"?t:(()=>{try{return JSON.stringify(t??"")}catch{return String(t??"")}})()}function ob(e){return`${String(e.role||"")}::${au(e)}`}function ib(e){if(e.length<2)return e;const t=[];let n="";for(const r of e){const a=ob(r);au(r).trim().length>0&&a===n||(t.push(r),n=a)}return t}function lb(e,t,n){return!n||t.length===0?e:[...e,...t].sort((r,a)=>{const o=Number(r.receivedAt??r.timestamp??0)||0,i=Number(a.receivedAt??a.timestamp??0)||0;if(o!==i)return o-i;const c=Number(r.index??0)||0,d=Number(a.index??0)||0;return c-d})}function Ll(e=typeof localStorage<"u"?localStorage:void 0){try{return(e==null?void 0:e.getItem(su))==="1"}catch{return!1}}function cb({text:e}){const{t}=Ne("common"),[n,r]=l.useState(!1),a=l.useCallback(()=>{navigator.clipboard.writeText(e).catch(()=>{}),r(!0),setTimeout(()=>r(!1),1500)},[e]);return s.jsx("button",{type:"button",onClick:a,"aria-label":t("chat.copyMessage"),className:"chat-copy-btn",children:n?s.jsx(Jd,{size:11}):s.jsx(Yd,{size:11})})}const ou=[wh,{singleTilde:!1}],iu=[ou,kh,Sh],db=[ou];function wr(e,t,n){return s.jsxs("div",{className:"rounded-md border border-border-subtle p-2 text-sm",role:"note",children:[s.jsx("span",{className:"font-medium",children:e}),t?s.jsx("span",{className:"ml-1 break-all",children:t}):null,n?s.jsx("div",{className:"mt-1 opacity-80",style:{whiteSpace:"pre-wrap"},children:n}):null]})}function Rl(e,t){return e?t?s.jsx("pre",{className:"chat-preformatted",children:e}):Gd(e)?s.jsx(wi,{remarkPlugins:iu,children:e}):s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:e}):null}const ub=l.memo(function({content:t,renderAsPreformatted:n,renderAsMarkdown:r}){return n?s.jsx("pre",{className:"chat-preformatted",children:t}):r?s.jsx(wi,{remarkPlugins:iu,children:t}):s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:t})});function Rn({parts:e,renderAsPreformatted:t}){return s.jsx("div",{className:"flex flex-col gap-2",children:e.map((n,r)=>{if(n.type==="text")return s.jsx("div",{children:Rl(String(n.text||""),t)},`text-${r}`);if(n.type==="image"){const a=Ua(n),o=n.alt||n.description||Dn(n.uri,"image");return a?s.jsx("img",{src:a,alt:o,className:"max-w-full rounded-md border border-border-subtle"},`image-${r}`):s.jsx("div",{children:wr("Image",o,n.mimeType)},`image-fallback-${r}`)}if(n.type==="audio"){const a=Ua(n);return a?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("audio",{controls:!0,src:a,className:"max-w-full"}),n.transcript?s.jsx("div",{className:"text-sm opacity-80",style:{whiteSpace:"pre-wrap"},children:n.transcript}):null]},`audio-${r}`):s.jsx("div",{children:wr("Audio",Dn(n.uri,"audio"),n.transcript||n.mimeType)},`audio-fallback-${r}`)}if(n.type==="video"){const a=Ua(n),o=n.title||n.name||n.alt||Dn(n.uri,"video"),i=[n.transcript,n.description,n.mimeType].filter(Boolean).join(`
6
6
  `);return s.jsxs("div",{className:"flex flex-col gap-1",children:[a?s.jsx("video",{controls:!0,src:a,poster:n.posterUri,className:"max-w-full rounded-md border border-border-subtle"}):wr("Video",o,i),a&&i?s.jsx("div",{className:"text-sm opacity-80",style:{whiteSpace:"pre-wrap"},children:i}):null]},`video-${r}`)}if(n.type==="resource_link"){const a=n.title||n.name||Dn(n.uri,"resource"),o=[n.description,n.mimeType].filter(Boolean).join(`
7
7
  `);return s.jsxs("div",{className:"flex flex-col gap-1",children:[n.uri?s.jsx("a",{href:n.uri,target:"_blank",rel:"noreferrer",download:!0,className:"underline break-all",children:a}):wr("Resource",a,o),n.uri&&o?s.jsx("div",{className:"text-sm opacity-80",style:{whiteSpace:"pre-wrap"},children:o}):null]},`resource-link-${r}`)}if(n.type==="resource"&&n.resource){const a=Dn(n.resource.uri,"resource");if(n.resource.text)return s.jsxs("div",{className:"rounded-md border border-border-subtle p-2",children:[s.jsx("div",{className:"text-[11px] opacity-70 mb-1",children:a}),Rl(n.resource.text,!0)]},`resource-${r}`);if(n.resource.uri)return s.jsx("a",{href:n.resource.uri,target:"_blank",rel:"noreferrer",className:"underline break-all",children:a},`resource-uri-${r}`)}return null})})}const pb=l.memo(function({log:t}){return s.jsxs("div",{className:"self-center chat-msg-action",children:[s.jsx(wi,{remarkPlugins:db,children:t.text}),s.jsx("span",{className:"action-time",children:Ud(t.timestamp)})]})},(e,t)=>e.log===t.log);function El(e){const t=e.meta;return[qd(e),e.kind||"",e.senderName||"",e.bubbleId||"",e.bubbleState||"",e.visibility||"",e.transcriptVisibility||"",e.audience||"",e.source||"",e.userFacing===void 0?"":String(e.userFacing),e.internal===void 0?"":String(e.internal),e.isInternal===void 0?"":String(e.isInternal),e.debug===void 0?"":String(e.debug),t?String(t.label??""):"",t?String(t.isRunning??""):"",t?String(t.renderMode??""):""].join("")}const mb=l.memo(function({message:t,receivedAt:n,agentName:r,userName:a,isCliMode:o,isTextExpanded:i,onToggleTextExpanded:c}){var y,A,M;const d=(t.role||"").toLowerCase(),p=d==="user"||d==="human",u=t.kind||(d==="tool"?"tool":"standard"),m=Pi(t),f=xf(t.content)?t.content:null,g=!!(f!=null&&f.some(T=>T.type!=="text")),j=Si(t.content,{joiner:`
8
- `});if(m.isActivityFacing&&u!=="thought"&&u!=="tool"&&u!=="terminal"){const T=m.label||"Activity";return s.jsxs("div",{className:"self-start chat-msg-activity","data-chat-activity-row":"true",children:[s.jsxs("div",{className:"chat-msg-activity-meta","aria-label":"Activity message",children:[s.jsx("span",{className:"activity-dot"}),s.jsx("span",{children:T})]}),g&&f?s.jsx("div",{className:"chat-msg-activity-body",children:s.jsx(Rn,{parts:f,renderAsPreformatted:!1})}):s.jsx("div",{className:"chat-msg-activity-body",style:{whiteSpace:"pre-wrap"},children:j})]})}if(u==="thought"){const T=typeof((y=t.meta)==null?void 0:y.label)=="string"?t.meta.label:"Thought";return s.jsxs("div",{className:"self-start chat-msg-thought","data-chat-activity-row":m.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx(Bf,{size:13}),s.jsx("span",{children:T})]}),s.jsx("div",{className:"chat-msg-body",children:j})]})}if(u==="tool")return s.jsxs("div",{className:"self-start chat-msg-tool","data-chat-activity-row":m.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-tool-meta","aria-label":"Tool message",children:[s.jsx("span",{className:"tool-icon",children:"⏺"}),s.jsx("span",{className:"tool-label",children:"Tool"})]}),g&&f?s.jsx("div",{className:"tool-text w-full",children:s.jsx(Rn,{parts:f,renderAsPreformatted:!1})}):s.jsx("div",{className:"tool-text w-full",style:{whiteSpace:"pre-wrap"},children:j})]});if(u==="terminal"){const T=(A=t.meta)!=null&&A.isRunning?"⏳":"✅",D=typeof((M=t.meta)==null?void 0:M.label)=="string"?t.meta.label:"Ran command";return s.jsxs("div",{className:"self-start chat-msg-terminal","data-chat-activity-row":m.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx("span",{children:T}),s.jsx("span",{children:D})]}),g&&f?s.jsx("div",{className:"chat-msg-body",children:s.jsx(Rn,{parts:f,renderAsPreformatted:!0})}):s.jsx("pre",{className:"chat-msg-body",children:j})]})}if(u==="system")return s.jsx("div",{className:"self-center chat-msg-system",children:g&&f?s.jsx(Rn,{parts:f,renderAsPreformatted:!1}):j.slice(0,100)});const h=t.meta,w=(typeof(h==null?void 0:h.renderMode)=="string"?h.renderMode.trim():"")==="preformatted",b=j,C=!1,S=b,k=w,v=!p&&!k&&Gd(S),N=["chat-message-row",p?"chat-message-row-user self-end":"chat-message-row-assistant self-start"].join(" ");return s.jsx("div",{className:N,children:(b||g||p)&&s.jsxs("div",{className:`chat-bubble ${p?"chat-bubble-user":"chat-bubble-assistant"}`,children:[s.jsxs("div",{className:`chat-bubble-header ${b||g?"mb-1.5":"mb-0"}`,children:[s.jsx("span",{className:"chat-sender",children:p?a||"You":t.senderName||r}),s.jsxs("span",{className:"chat-bubble-header-end",children:[(b||g)&&s.jsx(cb,{text:j}),n!=null&&s.jsx("span",{className:"chat-time",children:Ud(n)})]})]}),(b||g)&&s.jsx("div",{className:"chat-markdown",children:g&&f?s.jsx(Rn,{parts:f,renderAsPreformatted:k}):s.jsx(ub,{content:S,renderAsPreformatted:k,renderAsMarkdown:v})}),C]})})},(e,t)=>(e.message===t.message||El(e.message)===El(t.message))&&e.receivedAt===t.receivedAt&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isTextExpanded===t.isTextExpanded),hb=l.forwardRef(function({messages:t,actionLogs:n,agentName:r="Agent",userName:a,isCliMode:o=!1,isWorking:i=!1,contextKey:c="",receivedAtMap:d={},lastMessageHash:p,showActivityMessages:u=!1,emptyState:m,onLoadMore:f,isLoadingMore:g,hasMoreHistory:j,hiddenLiveCount:h=0,loadError:x,scrollToBottomRequestNonce:w,isVisible:b=!0},C){const{t:S}=Ne("common"),k=l.useRef(null),v=l.useRef(null),N=l.useRef(null),y=l.useRef(0),A=l.useRef(""),M=l.useRef(""),T=l.useRef(!1),D=l.useRef(null),L=l.useRef(!1),_=l.useRef(null),q=l.useRef(!1),[B,E]=l.useState(new Set),[K,R]=l.useState({showTop:!1,showBottom:!1}),I=l.useRef(!1),H=l.useRef(!1),P=l.useRef(b),W=l.useRef(b),J=l.useRef(null);W.current=b;const re=()=>{const ce=k.current;return ce?ce.scrollHeight-ce.scrollTop-ce.clientHeight<Ci:!0},Y=l.useCallback(()=>{const ce=k.current,$=ce?Nf(ce):{showTop:!1,showBottom:!1};R(pe=>pe.showTop===$.showTop&&pe.showBottom===$.showBottom?pe:$)},[]),X=l.useCallback((ce="auto")=>{var pe;const $=k.current;$&&($.scrollTo({top:$.scrollHeight,behavior:ce}),(pe=$.ownerDocument.defaultView)==null||pe.requestAnimationFrame(()=>Y()))},[Y]),de=l.useCallback((ce="auto")=>{var pe;const $=k.current;$&&($.scrollTo({top:0,behavior:ce}),(pe=$.ownerDocument.defaultView)==null||pe.requestAnimationFrame(()=>Y()))},[Y]),ne=l.useCallback(()=>{var F;const ce=k.current,$=(F=window.getSelection)==null?void 0:F.call(window);if(!ce||!$||$.rangeCount===0||$.isCollapsed){q.current=!1;return}const pe=$.anchorNode,le=$.focusNode;q.current=!!(pe&&le&&ce.contains(pe)&&ce.contains(le))},[]),O=l.useMemo(()=>{const ce=ab(t),$=ru(t);return ib(lb(ce,$,u))},[t,u]),ie=O.length===t.length?p:void 0,z=Sf(O,ie),ae=l.useCallback(()=>{const ce=k.current;if(!ce||!c||!W.current)return;const $={top:ce.scrollTop,fromBottom:Math.max(0,ce.scrollHeight-ce.scrollTop-ce.clientHeight),messageFingerprint:z};J.current={contextKey:c,snapshot:$},Ln.set(c,$)},[c,z]),Ce=l.useCallback((ce="auto")=>{D.current!=null&&cancelAnimationFrame(D.current),D.current=requestAnimationFrame(()=>{D.current=null,X(ce)})},[X]),ye=l.useCallback(()=>{I.current=!1,L.current=!0,H.current=!0,_.current!=null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{L.current=!1,_.current=null},Il)},[]);l.useEffect(()=>{const ce=!T.current,$=M.current!==c;if(M.current=c,ce||$){T.current=!0;const le=c?Ln.get(c):null,F=!!le&&sa(le,z);I.current=F?Kn(le):!1,L.current=Af(le,z),q.current||(F?requestAnimationFrame(()=>{const be=k.current;be&&(Ga(be,le),I.current=Kn(le),Y(),H.current=!0)}):Ce("auto")),y.current=O.length,A.current=z;return}O.length>y.current;const pe=z!==A.current;Mf({hasSelection:q.current,userScrolledUp:I.current,hasChatContentChanged:pe})&&Ce("auto"),y.current=O.length,A.current=z},[z,c,O.length,Ce,Y]),l.useEffect(()=>{w&&(ye(),q.current||Ce("auto"))},[ye,Ce,w]),l.useEffect(()=>{const ce=P.current;ce&&!b&&ae(),W.current=b,P.current=b;const $=c?Ln.get(c):null;if(Cf(ce,b,$,z)){if(!$)return;I.current=Kn($),L.current=!1,q.current||requestAnimationFrame(()=>{const pe=k.current;pe&&(Ga(pe,$),Y())});return}},[b,c,z,ye,ae,Ce,Y]),l.useEffect(()=>()=>{const ce=J.current;ce&&Ln.set(ce.contextKey,ce.snapshot),D.current!=null&&cancelAnimationFrame(D.current),_.current!=null&&window.clearTimeout(_.current)},[]),l.useEffect(()=>{const ce=v.current,$=k.current;if(!ce||!$)return;const pe=()=>{_.current!=null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{L.current=!1,_.current=null},Il)},le=new ResizeObserver(()=>{Y();const F=L.current;If({hasSelection:q.current,userScrolledUp:I.current,contextAutoScrollActive:F})&&(Ce("auto"),F&&pe())});return le.observe(ce),$!==ce&&le.observe($),()=>{le.disconnect(),_.current!=null&&(window.clearTimeout(_.current),_.current=null)}},[Ce,c,Y]),l.useImperativeHandle(C,()=>({scrollToBottom:(ce="smooth")=>{X(ce)}}),[X]),l.useEffect(()=>{const ce=k.current;if(!ce)return;let $;const pe=()=>{ae(),clearTimeout($),$=setTimeout(()=>{I.current=!re(),Y()},50)};return ce.addEventListener("scroll",pe,{passive:!0}),()=>{ce.removeEventListener("scroll",pe),clearTimeout($)}},[ae,Y]),l.useEffect(()=>(document.addEventListener("selectionchange",ne),()=>document.removeEventListener("selectionchange",ne)),[ne]);const ke=l.useRef(0),me=l.useRef(!1);l.useEffect(()=>{const ce=k.current;if(!ce||!me.current||ke.current===0)return;const $=ce.scrollHeight-ke.current;$>0&&(ce.scrollTop=$),Y(),ae(),ke.current=0,me.current=!1},[O.length,ae,Y]),l.useEffect(()=>{if(H.current||!c)return;const ce=Ln.get(c),$=k.current;if(!(!ce||!$)){if(!sa(ce,z)){X("auto"),H.current=!0;return}Ga($,ce),I.current=Kn(ce),Y(),H.current=!0}},[c,z,O.length,X,Y]);const G=()=>{const ce=k.current;ce&&(ke.current=ce.scrollHeight),me.current=!0,f==null||f()},U=()=>{I.current=!0,de("smooth"),ae()},Z=()=>{ye(),X("smooth"),ae()},V=l.useMemo(()=>{const ce=O.map((F,be)=>({type:"message",data:F,index:be,ts:gf(F,be,d)}));if(!n||n.length===0)return ce;const $=[...n].sort((F,be)=>F.timestamp-be.timestamp).map((F,be)=>({type:"action",data:F,index:be,ts:F.timestamp})),pe=[];let le=0;for(const F of ce){for(;le<$.length&&F.ts>0&&$[le].ts<F.ts;)pe.push($[le++]);pe.push(F)}for(;le<$.length;)pe.push($[le++]);return pe},[O,n,d]),fe=h>0||!!j,Ie=h>0?h>80?S("chatList.showEarlierMessagesHidden",{count:Math.min(h,80),total:h}):S("chatList.showEarlierMessages",{count:Math.min(h,80)}):x?S("chatList.loadErrorRetry",{error:x}):S("chatList.loadOlderMessages");return s.jsxs("div",{className:"chat-scroll-frame",children:[s.jsx("div",{ref:k,"data-chat-scroll":!0,className:"chat-container",children:s.jsxs("div",{ref:v,className:"chat-container-content",children:[g&&s.jsx("div",{className:"text-center py-3 text-text-muted text-xs opacity-60 animate-pulse",children:S("chatList.loadingOlderMessages")}),fe&&!g&&s.jsx("div",{className:"text-center py-2",children:s.jsx("button",{type:"button",onClick:G,className:`text-[11px] rounded-xl px-4 py-1.5 cursor-pointer border transition-all ${x&&h===0?"bg-transparent border-yellow-500/30 text-yellow-400 opacity-80 hover:opacity-100":"bg-transparent border-border-subtle text-text-muted opacity-70 hover:opacity-100 hover:border-accent/40"}`,children:Ie})}),V.length===0&&!fe&&(m||s.jsx("div",{className:"text-center mt-16 opacity-20 text-[13px]",children:S("chatList.waitingForMessages")})),V.map(ce=>{if(ce.type==="action"){const je=ce.data;return s.jsx(pb,{log:je},`action-${ce.index}`)}const $=ce.data;ce.index;const pe=ta($),le=$.receivedAt||d[pe],F=`${c}-${pe}`,be=B.has(F);return s.jsx(mb,{message:$,receivedAt:le,agentName:r,userName:a,isCliMode:o,isTextExpanded:be,onToggleTextExpanded:()=>E(je=>{const Se=new Set(je);return be?Se.delete(F):Se.add(F),Se})},`msg-${pe}`)}),i&&s.jsx("div",{className:"self-start chat-typing-wrapper",children:s.jsxs("div",{className:"typing-indicator",children:[s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("span",{className:"text-[11px] text-text-muted ml-1",children:S("chatList.agentGenerating")})]})}),s.jsx("div",{className:"min-h-10",ref:N})]})}),(K.showTop||K.showBottom)&&s.jsxs("div",{className:"chat-scroll-jump-controls","aria-label":S("chatList.jumpToTop"),children:[K.showTop&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button",onClick:U,"aria-label":S("chatList.jumpToOldestMessages"),title:S("chatList.jumpToTop"),children:S("chatList.top")}),K.showBottom&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button chat-scroll-jump-button-primary",onClick:Z,"aria-label":S("chatList.jumpToLatestMessages"),title:S("chatList.jumpToBottom"),children:S("chatList.latest")})]})]})}),fb=l.memo(hb,(e,t)=>e.messages===t.messages&&e.actionLogs===t.actionLogs&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isWorking===t.isWorking&&e.contextKey===t.contextKey&&e.receivedAtMap===t.receivedAtMap&&e.lastMessageHash===t.lastMessageHash&&e.showActivityMessages===t.showActivityMessages&&e.emptyState===t.emptyState&&e.onLoadMore===t.onLoadMore&&e.isLoadingMore===t.isLoadingMore&&e.hasMoreHistory===t.hasMoreHistory&&e.hiddenLiveCount===t.hiddenLiveCount&&e.loadError===t.loadError&&e.scrollToBottomRequestNonce===t.scrollToBottomRequestNonce&&e.isVisible===t.isVisible),bb="modulepreload",gb=function(e){return"/"+e},_l={},xb=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));a=Promise.allSettled(n.map(d=>{if(d=gb(d),d in _l)return;_l[d]=!0;const p=d.endsWith(".css"),u=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const m=document.createElement("link");if(m.rel=p?"stylesheet":bb,p||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),p)return new Promise((f,g)=>{m.addEventListener("load",f),m.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})};let $l=!1;const lu=l.forwardRef(({onInput:e,onViewportMetrics:t,onScrollMetrics:n,fontSize:r=13,readOnly:a=!1,sizingMode:o="measured"},i)=>{const c=l.useRef(null),[d,p]=l.useState(null),u=l.useRef([]),m=l.useRef(!1),f=l.useRef(!1),g=l.useRef(!1),j=l.useRef(!1),h=()=>{const x=c.current;if(x){m.current&&(x.clear(),m.current=!1);for(const w of u.current)x.write(w.data,w.onProcessed);u.current=[],f.current&&(x.fit(),f.current=!1),g.current&&(x.bumpResize(),g.current=!1),j.current&&(x.scrollToTop(),j.current=!1)}};return l.useImperativeHandle(i,()=>({write:(x,w)=>{c.current?c.current.write(x,w):u.current.push({data:x,onProcessed:w})},clear:()=>{c.current?c.current.clear():(u.current=[],m.current=!0)},reset:()=>{c.current&&typeof c.current.reset=="function"?c.current.reset():(u.current=[],m.current=!0)},resize:(x,w)=>{c.current&&typeof c.current.resize=="function"&&c.current.resize(x,w)},fit:()=>{c.current?c.current.fit():f.current=!0},bumpResize:()=>{c.current?c.current.bumpResize():g.current=!0},scrollToTop:()=>{c.current?c.current.scrollToTop():j.current=!0},getSelection:()=>{var x,w;return((w=(x=c.current)==null?void 0:x.getSelection)==null?void 0:w.call(x))||""},getVisibleText:()=>{var x,w;return((w=(x=c.current)==null?void 0:x.getVisibleText)==null?void 0:w.call(x))||""}}),[]),l.useEffect(()=>{d&&h()},[d]),l.useEffect(()=>{let x=!1;return xb(()=>import("./terminal-BZj_X5zy.js"),__vite__mapDeps([0,1,2])).then(w=>{$l||($l=!0,console.info("[CliTerminal] renderer module loaded: terminal-render-web")),x||p(()=>w.GhosttyTerminalView)}).catch(w=>{console.error("[CliTerminal] failed to load terminal renderer",w)}),()=>{x=!0}},[]),d?s.jsx(d,{ref:c,onInput:e,onViewportMetrics:t,onScrollMetrics:n,fontSize:r,readOnly:a,sizingMode:o,className:"w-full h-full rounded-lg overflow-hidden"}):s.jsx("div",{className:"w-full h-full rounded-lg overflow-hidden animate-pulse",style:{background:"#0f1117"}})});lu.displayName="CliTerminal";function Ft(...e){return Ch(jh(e))}const vb={lg:"rounded-lg",xl:"rounded-xl","2xl":"rounded-2xl"},yb={none:"",sm:"p-3",md:"px-4 py-3.5",lg:"px-5 py-4"},Ss=l.forwardRef(function({radius:t="xl",padding:n="md",className:r,...a},o){return s.jsx("div",{ref:o,className:Ft("border border-border-subtle bg-bg-secondary",vb[t],yb[n],r),...a})});function kr({label:e,value:t,sub:n,icon:r}){return s.jsxs(Ss,{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base flex items-center",children:r}),s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),s.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),n&&s.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:n})]})}function Hl({value:e,max:t,label:n,color:r="#8b5cf6",detail:a,compact:o=!1}){const i=t>0?Math.min(Math.round(e/t*100),100):0,c=i>85?"#ef4444":i>60?"var(--status-warning)":r;return o?s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:n}),s.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[i,"%"]})]}),s.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${i}%`,background:c}})})]}):s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:n}),s.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[i,"%"]})]}),s.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${i}%`,background:`linear-gradient(90deg, ${c}, ${c}cc)`}})}),a&&s.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:a})]})}function wb({cursorPos:e,viewportRef:t,imgRef:n}){var b;if(!e||!n.current)return null;const r=n.current,a=r.getBoundingClientRect(),o=(b=t.current)==null?void 0:b.getBoundingClientRect();if(!o)return null;const i=r.naturalWidth||a.width,c=r.naturalHeight||a.height,d=i/c,p=a.width/a.height;let u,m,f,g;d>p?(u=a.width,m=a.width/d,f=0,g=(a.height-m)/2):(m=a.height,u=a.height*d,f=(a.width-u)/2,g=0);const j=a.left-o.left+f+u*e.nx,h=a.top-o.top+g+m*e.ny,x=Math.max(8,Math.min(o.width-8,j)),w=Math.max(8,Math.min(o.height-8,h));return s.jsxs("div",{style:{position:"absolute",left:x-8,top:w-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[s.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})}function kb({inputMode:e,onToggleInputMode:t,isImeOpen:n,setIsImeOpen:r,isMenuOpen:a,setIsMenuOpen:o,imeText:i,setImeText:c,handleImeSubmit:d,isConnActive:p,zoom:u,isMobile:m,mobileFillZoom:f,onZoomOut:g,onZoomReset:j,onZoomIn:h,transportType:x,screenshotUsage:w,lastActionStatus:b}){const{t:C}=Ne("common");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{onTouchStart:S=>S.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-20 flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[s.jsxs("div",{onClick:t,className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${e==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[s.jsx("span",{className:"text-sm",children:e==="mouse"?"🖱️":"👆"}),s.jsx("span",{className:`text-[10px] font-bold ${e==="mouse"?"text-blue-400":"text-slate-400"}`,children:C(e==="mouse"?"remote.mouse":"remote.touch")})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>{r(S=>!S),o(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${n?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⌨️"})}),n&&s.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-20",style:{animation:"slideUp 0.15s ease-out"},children:s.jsx("input",{type:"text",placeholder:C("remote.typeAndEnter"),value:i,autoFocus:!0,onTouchStart:S=>S.stopPropagation(),onChange:S=>c(S.target.value),onKeyDown:S=>{d(S)},className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),s.jsx("div",{className:"relative",children:s.jsx("div",{onClick:()=>{o(S=>!S),r(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${a?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⚙️"})})}),s.jsx("div",{className:"w-px h-[18px] bg-white/10"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:p?"rgba(34,197,94,0.12)":"rgba(234,179,8,0.12)"},children:[s.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:p?"#22c55e":"#eab308",boxShadow:p?"0 0 4px #22c55e80":"0 0 4px #eab30880"}}),s.jsx("span",{className:"text-[8px] font-extrabold",style:{color:p?"#22c55e":"#eab308"},children:C(p?"remote.connected":"remote.ws")})]}),u>1&&s.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(u*100),"%"]}),x==="direct"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"#22c55e",background:"rgba(34,197,94,0.12)"},title:C("remote.directP2PTitle"),children:C("remote.direct")}),x==="relay"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"var(--status-warning)",background:"color-mix(in srgb, var(--status-warning) 12%, transparent)"},title:C("remote.turnRelayTitle"),children:C("remote.relay")}),w&&w.dailyBudgetMinutes>0&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:w.budgetExhausted?"#ef4444":"#c4b5fd",background:w.budgetExhausted?"rgba(239,68,68,0.1)":"rgba(139,92,246,0.14)"},title:C("remote.dailyTurnTitle"),children:w.budgetExhausted?C("remote.turnBlocked"):C("remote.turnUsage",{used:w.dailyUsedMinutes,budget:w.dailyBudgetMinutes})}),b&&s.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:b})]})]}),a&&s.jsxs("div",{onTouchStart:S=>S.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:20,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[s.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:C("remote.settings")}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:[C("remote.zoom")," ",u<=(m?f:1)+.01?C(m?"remote.fill":"remote.fit"):`${Math.round(u*100)}%`]}),s.jsxs("div",{style:{display:"flex",gap:4},children:[s.jsx("button",{onClick:S=>{S.stopPropagation(),g()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),s.jsx("button",{onClick:S=>{S.stopPropagation(),j()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:C(m?"remote.fill":"remote.fit")}),s.jsx("button",{onClick:S=>{S.stopPropagation(),h()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]})]})]})}function Sb({waitingLabel:e,waitingHint:t,transportType:n}){const{t:r}=Ne("common");return s.jsxs("div",{className:"text-center flex flex-col items-center gap-3 px-6",children:[s.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center border border-white/10 bg-white/[0.04] shadow-[0_10px_30px_rgba(0,0,0,0.35)]",style:{animation:"remote-float 2.8s ease-in-out infinite"},children:s.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-8 h-8 opacity-90"})}),s.jsx("div",{className:"text-white/85 text-[13px] font-semibold tracking-wide",children:e}),s.jsx("div",{className:"text-[11px] text-white/40",children:t}),n==="relay"&&s.jsx("div",{className:"text-[10px] font-medium",style:{color:"var(--status-warning)",opacity:.8},children:r("remote.waitingState.turnRelayActive")})]})}function Cb(){if(typeof window>"u")return!1;try{return window.__ADHDEV_DEBUG_RENDERS__===!0||window.localStorage.getItem("adhdev_debug_renders")==="1"}catch{return window.__ADHDEV_DEBUG_RENDERS__===!0}}function Bl(e){return e==null||typeof e=="number"||typeof e=="boolean"?e:typeof e=="string"?e.length>64?`${e.slice(0,61)}...`:e:Array.isArray(e)?`Array(${e.length})`:typeof e=="object"?"Object":typeof e}function hr(e,t){const n=l.useRef(null),r=l.useRef(0);l.useEffect(()=>{if(!Cb())return;r.current+=1;const a=n.current;if(!a){console.debug(`[render-trace] ${e}#${r.current}`,{changed:["mount"],snapshot:Object.fromEntries(Object.entries(t).map(([i,c])=>[i,Bl(c)]))}),n.current=t;return}const o=Object.keys({...a,...t}).filter(i=>!Object.is(a[i],t[i]));o.length>0&&console.debug(`[render-trace] ${e}#${r.current}`,{changed:o,snapshot:Object.fromEntries(o.map(i=>[i,Bl(t[i])]))}),n.current=t})}function jb({containerRef:e,viewportRef:t,imgRef:n,inputMode:r,setInputMode:a,minZoom:o,zoomRef:i,panXRef:c,panYRef:d,setPanX:p,setPanY:u,setZoom:m,lastWheelTimeRef:f,onAction:g,setLastActionStatus:j,spawnRippleFromNormalized:h,clampPan:x,isMobile:w,mobileFillZoom:b}){const[C,S]=l.useState(null),k=l.useRef(null),v=l.useRef(null),N=l.useRef(null),y=l.useRef(!1),A=l.useRef(null),M=l.useRef(0),T=l.useRef(null),D=l.useRef(1),L=l.useRef({x:0,y:0}),_=l.useRef(!1),q=l.useRef(r),B=l.useRef(g),E=30,K=550,R=18,I=60,H=400,P=12,W=()=>{if(k.current)return;const Y={nx:.5,ny:.5};k.current=Y,S(Y)};return l.useEffect(()=>{q.current=r,r==="mouse"&&W()},[r]),l.useEffect(()=>{B.current=g},[g]),l.useEffect(()=>{const Y=e.current;if(!Y)return;const X=ae=>{if(!n.current)return null;const Ce=n.current.getBoundingClientRect();return!Ce.width||!Ce.height?null:{nx:Math.max(0,Math.min(1,(ae.clientX-Ce.left)/Ce.width)),ny:Math.max(0,Math.min(1,(ae.clientY-Ce.top)/Ce.height))}},de=(ae,Ce)=>{if(!n.current)return{dnx:0,dny:0};const ye=n.current,ke=ye.getBoundingClientRect(),me=ye.naturalWidth||ke.width,G=ye.naturalHeight||ke.height,U=me/G,Z=ke.width/ke.height;let V,fe;return U>Z?(V=ke.width,fe=ke.width/U):(fe=ke.height,V=ke.height*U),{dnx:ae/V,dny:Ce/fe}},ne=(ae,Ce,ye)=>{if(ye<=1.05)return;const ke=-(ae-.5)*100,me=-(Ce-.5)*100,G=x(ke,me,ye);(Math.abs(G.x-c.current)>.1||Math.abs(G.y-d.current)>.1)&&(p(G.x),u(G.y),c.current=G.x,d.current=G.y)},O=ae=>{const Ce=t.current;if(Ce&&ae.target instanceof Node&&Ce.contains(ae.target))ae.preventDefault();else return;if(ae.touches.length===1){const ye=ae.touches[0];v.current={x:ye.clientX,y:ye.clientY,time:Date.now()},N.current={x:ye.clientX,y:ye.clientY},_.current||(y.current=!1),A.current=setTimeout(()=>{if(!y.current&&!_.current)if(y.current=!0,q.current==="mouse"){const ke=k.current||{nx:.5,ny:.5};j("Right Click"),h(ke.nx,ke.ny,"right"),B.current("input_click",{...ke,button:"right"}).catch(()=>{})}else{const ke=X(ye);ke&&(j("Right Click"),h(ke.nx,ke.ny,"right"),B.current("input_click",{...ke,button:"right"}).catch(()=>{}))}},500);return}if(ae.touches.length===2){A.current&&clearTimeout(A.current),y.current=!0,_.current=!0;const ye=ae.touches[1].clientX-ae.touches[0].clientX,ke=ae.touches[1].clientY-ae.touches[0].clientY;T.current=Math.sqrt(ye*ye+ke*ke),D.current=i.current,L.current={x:(ae.touches[0].clientX+ae.touches[1].clientX)/2,y:(ae.touches[0].clientY+ae.touches[1].clientY)/2}}},ie=ae=>{const Ce=t.current;if(Ce&&ae.target instanceof Node&&Ce.contains(ae.target)&&ae.preventDefault(),ae.touches.length===1&&N.current){const ye=ae.touches[0],ke=ye.clientX-N.current.x,me=ye.clientY-N.current.y;if(!y.current&&v.current){const G=ye.clientX-v.current.x,U=ye.clientY-v.current.y;Math.sqrt(G*G+U*U)>8&&(y.current=!0,A.current&&clearTimeout(A.current))}if(y.current)if(q.current==="mouse"){const G=de(ke,me),U=k.current||{nx:.5,ny:.5},Z=Math.max(0,Math.min(1,U.nx+G.dnx)),V=Math.max(0,Math.min(1,U.ny+G.dny));k.current={nx:Z,ny:V},S({nx:Z,ny:V}),j(`Cursor: ${Math.round(Z*100)}%, ${Math.round(V*100)}%`),ne(Z,V,i.current);const fe=Date.now();fe-f.current>=30&&(f.current=fe,B.current("input_mouseMoved",{nx:Z,ny:V}).catch(()=>{}))}else if(i.current>1){const G=t.current;if(G){const U=G.clientWidth,Z=G.clientHeight,V=c.current+ke/U*100,fe=d.current+me/Z*100,Ie=x(V,fe,i.current);p(Ie.x),u(Ie.y),c.current=Ie.x,d.current=Ie.y}}else{const G=X(ye);if(G){const U=Date.now();U-f.current>=40&&(f.current=U,j("Scroll"),B.current("input_wheel",{nx:G.nx,ny:G.ny,deltaX:Math.round(-ke*2.5),deltaY:Math.round(-me*2.5)}).catch(()=>{}))}}N.current={x:ye.clientX,y:ye.clientY};return}if(ae.touches.length===2&&T.current!==null){const ye=ae.touches[1].clientX-ae.touches[0].clientX,ke=ae.touches[1].clientY-ae.touches[0].clientY,G=Math.sqrt(ye*ye+ke*ke)/T.current,U=(ae.touches[0].clientX+ae.touches[1].clientX)/2,Z=(ae.touches[0].clientY+ae.touches[1].clientY)/2,V=U-L.current.x,fe=Z-L.current.y,Ie=Math.abs(G-1)>.03;if(q.current==="mouse"){if(Ie){const ce=Math.max(o,Math.min(5,D.current*G));m(ce),i.current=ce}else if(Math.abs(V)>2||Math.abs(fe)>2){const ce=k.current||{nx:.5,ny:.5},$=Date.now();$-f.current>=30&&(f.current=$,j("Scroll"),B.current("input_wheel",{nx:ce.nx,ny:ce.ny,deltaX:Math.round(-V*3),deltaY:Math.round(-fe*3)}).catch(()=>{}))}}else{const ce=Math.max(o,Math.min(5,D.current*G));m(ce),i.current=ce;const $=t.current;if($&&ce>1){const pe=$.clientWidth,le=$.clientHeight,F=c.current+V/pe*100,be=d.current+fe/le*100,je=x(F,be,ce);p(je.x),u(je.y),c.current=je.x,d.current=je.y}}L.current={x:U,y:Z}}},z=ae=>{var Ce;if(A.current&&clearTimeout(A.current),T.current=null,ae.touches.length===1&&_.current){const ye=ae.touches[0];v.current={x:ye.clientX,y:ye.clientY,time:Date.now()},N.current={x:ye.clientX,y:ye.clientY},y.current=!0;return}if(ae.touches.length===0){if(_.current){_.current=!1,y.current=!1;return}if(ae.changedTouches.length===1){const ye=ae.changedTouches[0],ke=Date.now(),me=ke-(((Ce=v.current)==null?void 0:Ce.time)||0),G=v.current?ye.clientX-v.current.x:0,U=v.current?ye.clientY-v.current.y:0,Z=Math.sqrt(G*G+U*U);if(q.current==="mouse"){if(me<E||me>K||Z>R){y.current=!1;return}const V=k.current||X(ye);V&&(j(`Click: ${Math.round(V.nx*100)}%, ${Math.round(V.ny*100)}%`),h(V.nx,V.ny,"left"),B.current("input_click",{...V}).catch(()=>{}))}else{if(y.current){y.current=!1;return}if(me<I||me>H||Z>P){y.current=!1;return}const V=X(ye);if(!V)return;ke-M.current<300?(j("Double tap"),h(V.nx,V.ny,"double"),B.current("input_click",{...V,clickCount:2}).catch(()=>{}),M.current=0):(j(`Tap: ${Math.round(V.nx*100)}%, ${Math.round(V.ny*100)}%`),h(V.nx,V.ny,"left"),B.current("input_click",{...V}).catch(()=>{}),M.current=ke)}}y.current=!1}};return Y.addEventListener("touchstart",O,{passive:!1}),Y.addEventListener("touchmove",ie,{passive:!1}),Y.addEventListener("touchend",z,{passive:!1}),()=>{Y.removeEventListener("touchstart",O),Y.removeEventListener("touchmove",ie),Y.removeEventListener("touchend",z),A.current&&clearTimeout(A.current)}},[e,t,n,o,i,c,d,p,u,m,f,j,h,x]),{cursorPos:C,cursorPosRef:k,handleToggleInputMode:()=>{a(Y=>{const X=Y==="touch"?"mouse":"touch";return X==="mouse"&&W(),X})},handleZoomReset:()=>{const Y=w?b:1;m(Y),i.current=Y,p(0),u(0),c.current=0,d.current=0}}}function cu({onAction:e,addLog:t,connState:n,connScreenshot:r,screenshotUsage:a,transportType:o}){const i=l.useRef(null),c=l.useRef(null),d=l.useRef(null),[p,u]=l.useState(null),[m,f]=l.useState(""),[,g]=l.useState(!1),[j,h]=l.useState([]),x=l.useRef(0),[w,b]=l.useState(!1),[C,S]=l.useState(!1),k=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[v,N]=l.useState(k?"mouse":"touch"),[y,A]=l.useState(1),M=l.useRef(!1),[T,D]=l.useState(1),[L,_]=l.useState(0),[q,B]=l.useState(0);hr("RemoteView",{connState:n,hasScreenshot:!!r,inputMode:v,zoom:T,panX:L,panY:q,isMenuOpen:w,isImeOpen:C});const E=l.useRef(0),K=l.useRef(T),R=l.useRef(L),I=l.useRef(q);l.useEffect(()=>{K.current=T},[T]),l.useEffect(()=>{R.current=L},[L]),l.useEffect(()=>{I.current=q},[q]),l.useEffect(()=>{var me;(me=i.current)==null||me.focus()},[]);const H=n==="connected",P=r,W=H?"Connected. Waiting for first frame...":n==="connecting"?"Connecting to Host...":"Reconnecting to Host...",J=H?"The remote stream is warming up":"Waiting for the remote stream to catch up";l.useEffect(()=>{if(!k||M.current||!P)return;const me=d.current,G=c.current;if(!me||!G)return;const U=()=>{const Z=G.clientWidth,V=G.clientHeight,fe=me.naturalWidth,Ie=me.naturalHeight;if(!fe||!Ie||!Z||!V)return;const ce=Math.min(Z/fe,V/Ie),pe=Math.max(Z/fe,V/Ie)/ce;pe>1.01&&(A(pe),D(pe),K.current=pe),M.current=!0};me.complete&&me.naturalWidth?U():me.addEventListener("load",U,{once:!0})},[P,k]);const re=.5;l.useEffect(()=>{T<=re&&(_(0),B(0))},[T,re]);const Y=(me,G,U)=>{if(U<=re)return{x:0,y:0};const Z=(U-1)/(2*U)*100,V=(U-1)/(2*U)*100;return{x:Math.max(-Z,Math.min(Z,me)),y:Math.max(-V,Math.min(V,G))}},X=(me,G)=>{if(!d.current)return null;const U=d.current.getBoundingClientRect();return!U.width||!U.height?null:{nx:Math.max(0,Math.min(1,(me-U.left)/U.width)),ny:Math.max(0,Math.min(1,(G-U.top)/U.height))}},de=(me,G,U)=>{const Z=c.current;if(!Z)return;const V=Z.getBoundingClientRect(),fe=++x.current;h(Ie=>[...Ie,{id:fe,x:me-V.left,y:G-V.top,type:U}]),setTimeout(()=>h(Ie=>Ie.filter(ce=>ce.id!==fe)),600)},ne=(me,G,U)=>{const Z=d.current,V=c.current;if(!Z||!V)return;const fe=Z.getBoundingClientRect(),Ie=V.getBoundingClientRect(),ce=Z.naturalWidth||fe.width,$=Z.naturalHeight||fe.height,pe=ce/$,le=fe.width/fe.height;let F,be,je,Se;pe>le?(F=fe.width,be=fe.width/pe,je=0,Se=(fe.height-be)/2):(be=fe.height,F=fe.height*pe,je=(fe.width-F)/2,Se=0);const He=fe.left-Ie.left+je+F*me,Xe=fe.top-Ie.top+Se+be*G,dt=++x.current;h(it=>[...it,{id:dt,x:He,y:Xe,type:U}]),setTimeout(()=>h(it=>it.filter(he=>he.id!==dt)),600)},O=async me=>{var U;const G=X(me.clientX,me.clientY);if(G){u(`Click: ${Math.round(G.nx*100)}%, ${Math.round(G.ny*100)}%`),de(me.clientX,me.clientY,"left"),(U=i.current)==null||U.focus();try{const Z=await e("input_click",{nx:G.nx,ny:G.ny});Z!=null&&Z.success||t(`❌ Click failed: ${Z==null?void 0:Z.error}`)}catch(Z){t(`❌ Click error: ${Z.message||Z}`)}}},ie=async(me,G,U,Z=0)=>{try{await e("input_key",{type:U?"char":"keyDown",key:me,code:G,text:U?me:void 0,unmodifiedText:U?me:void 0,modifiers:Z})}catch(V){t(`❌ Key error: ${V.message||V}`)}},z=async me=>{if(me.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(me.key)&&me.preventDefault();let U=0;me.altKey&&(U|=1),me.ctrlKey&&(U|=2),me.metaKey&&(U|=4),me.shiftKey&&(U|=8),u(`Key: ${me.key}`),await ie(me.key,me.code,me.key.length===1,U)},ae=async me=>{if(me.key==="Enter"){if(me.nativeEvent.isComposing)return;if(m){const G=m;f(""),u(`IME Sent: ${G}`);try{const U=await e("input_type",{text:G});U!=null&&U.success||t(`❌ IME error: ${U==null?void 0:U.error}`)}catch(U){t(`❌ IME error: ${U.message}`)}}else u("Key: Enter"),await ie("Enter","Enter",!1)}};l.useEffect(()=>{const me=i.current;if(!me)return;const G=U=>{var Z;if((Z=d.current)!=null&&Z.contains(U.target)){U.preventDefault();const V=Date.now();if(V-E.current<40)return;E.current=V;const fe=X(U.clientX,U.clientY);if(!fe)return;u(`Scroll: ${Math.round(U.deltaY)}`),e("input_wheel",{nx:fe.nx,ny:fe.ny,deltaX:Math.round(U.deltaX),deltaY:Math.round(U.deltaY)}).catch(()=>{})}};return me.addEventListener("wheel",G,{passive:!1}),()=>me.removeEventListener("wheel",G)},[e]);const{cursorPos:Ce,handleToggleInputMode:ye,handleZoomReset:ke}=jb({containerRef:i,viewportRef:c,imgRef:d,inputMode:v,setInputMode:N,minZoom:re,zoomRef:K,panXRef:R,panYRef:I,setPanX:_,setPanY:B,setZoom:D,lastWheelTimeRef:E,onAction:e,setLastActionStatus:u,spawnRippleFromNormalized:ne,clampPan:Y,isMobile:k,mobileFillZoom:y});return s.jsxs("div",{ref:i,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:z,onContextMenu:me=>me.preventDefault(),onFocus:()=>g(!0),onBlur:()=>g(!1),tabIndex:0,children:[s.jsxs("div",{ref:c,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[P?s.jsx("img",{ref:d,src:P,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${T}) translate(${L}%, ${q}%)`,transformOrigin:"center center",cursor:v==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:O,onContextMenu:me=>me.preventDefault(),onDragStart:me=>me.preventDefault()}):s.jsx(Sb,{waitingLabel:W,waitingHint:J,transportType:o}),v==="mouse"&&P&&s.jsx(wb,{cursorPos:Ce,viewportRef:c,imgRef:d}),j.map(me=>{const U={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[me.type];return s.jsxs("div",{style:{position:"absolute",left:me.x,top:me.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[s.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${U}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),s.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${U}, 0.9)`,boxShadow:`0 0 12px rgba(${U}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},me.id)})]}),s.jsx(kb,{inputMode:v,onToggleInputMode:ye,isImeOpen:C,setIsImeOpen:S,isMenuOpen:w,setIsMenuOpen:b,imeText:m,setImeText:f,handleImeSubmit:ae,isConnActive:H,zoom:T,isMobile:k,mobileFillZoom:y,onZoomOut:()=>D(me=>Math.max(.5,me-.25)),onZoomReset:ke,onZoomIn:()=>D(me=>Math.min(5,me+.25)),transportType:o,screenshotUsage:a,lastActionStatus:p}),s.jsx("style",{children:`
8
+ `});if(m.isActivityFacing&&u!=="thought"&&u!=="tool"&&u!=="terminal"){const T=m.label||"Activity";return s.jsxs("div",{className:"self-start chat-msg-activity","data-chat-activity-row":"true",children:[s.jsxs("div",{className:"chat-msg-activity-meta","aria-label":"Activity message",children:[s.jsx("span",{className:"activity-dot"}),s.jsx("span",{children:T})]}),g&&f?s.jsx("div",{className:"chat-msg-activity-body",children:s.jsx(Rn,{parts:f,renderAsPreformatted:!1})}):s.jsx("div",{className:"chat-msg-activity-body",style:{whiteSpace:"pre-wrap"},children:j})]})}if(u==="thought"){const T=typeof((y=t.meta)==null?void 0:y.label)=="string"?t.meta.label:"Thought";return s.jsxs("div",{className:"self-start chat-msg-thought","data-chat-activity-row":m.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx(Bf,{size:13}),s.jsx("span",{children:T})]}),s.jsx("div",{className:"chat-msg-body",children:j})]})}if(u==="tool")return s.jsxs("div",{className:"self-start chat-msg-tool","data-chat-activity-row":m.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-tool-meta","aria-label":"Tool message",children:[s.jsx("span",{className:"tool-icon",children:"⏺"}),s.jsx("span",{className:"tool-label",children:"Tool"})]}),g&&f?s.jsx("div",{className:"tool-text w-full",children:s.jsx(Rn,{parts:f,renderAsPreformatted:!1})}):s.jsx("div",{className:"tool-text w-full",style:{whiteSpace:"pre-wrap"},children:j})]});if(u==="terminal"){const T=(A=t.meta)!=null&&A.isRunning?"⏳":"✅",D=typeof((M=t.meta)==null?void 0:M.label)=="string"?t.meta.label:"Ran command";return s.jsxs("div",{className:"self-start chat-msg-terminal","data-chat-activity-row":m.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx("span",{children:T}),s.jsx("span",{children:D})]}),g&&f?s.jsx("div",{className:"chat-msg-body",children:s.jsx(Rn,{parts:f,renderAsPreformatted:!0})}):s.jsx("pre",{className:"chat-msg-body",children:j})]})}if(u==="system")return s.jsx("div",{className:"self-center chat-msg-system",children:g&&f?s.jsx(Rn,{parts:f,renderAsPreformatted:!1}):j.slice(0,100)});const h=t.meta,w=(typeof(h==null?void 0:h.renderMode)=="string"?h.renderMode.trim():"")==="preformatted",b=j,C=!1,S=b,k=w,v=!p&&!k&&Gd(S),N=["chat-message-row",p?"chat-message-row-user self-end":"chat-message-row-assistant self-start"].join(" ");return s.jsx("div",{className:N,children:(b||g||p)&&s.jsxs("div",{className:`chat-bubble ${p?"chat-bubble-user":"chat-bubble-assistant"}`,children:[s.jsxs("div",{className:`chat-bubble-header ${b||g?"mb-1.5":"mb-0"}`,children:[s.jsx("span",{className:"chat-sender",children:p?a||"You":t.senderName||r}),s.jsxs("span",{className:"chat-bubble-header-end",children:[(b||g)&&s.jsx(cb,{text:j}),n!=null&&s.jsx("span",{className:"chat-time",children:Ud(n)})]})]}),(b||g)&&s.jsx("div",{className:"chat-markdown",children:g&&f?s.jsx(Rn,{parts:f,renderAsPreformatted:k}):s.jsx(ub,{content:S,renderAsPreformatted:k,renderAsMarkdown:v})}),C]})})},(e,t)=>(e.message===t.message||El(e.message)===El(t.message))&&e.receivedAt===t.receivedAt&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isTextExpanded===t.isTextExpanded),hb=l.forwardRef(function({messages:t,actionLogs:n,agentName:r="Agent",userName:a,isCliMode:o=!1,isWorking:i=!1,contextKey:c="",receivedAtMap:d={},lastMessageHash:p,showActivityMessages:u=!1,emptyState:m,onLoadMore:f,isLoadingMore:g,hasMoreHistory:j,hiddenLiveCount:h=0,loadError:x,scrollToBottomRequestNonce:w,isVisible:b=!0},C){const{t:S}=Ne("common"),k=l.useRef(null),v=l.useRef(null),N=l.useRef(null),y=l.useRef(0),A=l.useRef(""),M=l.useRef(""),T=l.useRef(!1),D=l.useRef(null),L=l.useRef(!1),_=l.useRef(null),q=l.useRef(!1),[B,E]=l.useState(new Set),[K,R]=l.useState({showTop:!1,showBottom:!1}),I=l.useRef(!1),H=l.useRef(!1),P=l.useRef(b),W=l.useRef(b),J=l.useRef(null);W.current=b;const re=()=>{const ce=k.current;return ce?ce.scrollHeight-ce.scrollTop-ce.clientHeight<Ci:!0},Y=l.useCallback(()=>{const ce=k.current,$=ce?Nf(ce):{showTop:!1,showBottom:!1};R(pe=>pe.showTop===$.showTop&&pe.showBottom===$.showBottom?pe:$)},[]),X=l.useCallback((ce="auto")=>{var pe;const $=k.current;$&&($.scrollTo({top:$.scrollHeight,behavior:ce}),(pe=$.ownerDocument.defaultView)==null||pe.requestAnimationFrame(()=>Y()))},[Y]),de=l.useCallback((ce="auto")=>{var pe;const $=k.current;$&&($.scrollTo({top:0,behavior:ce}),(pe=$.ownerDocument.defaultView)==null||pe.requestAnimationFrame(()=>Y()))},[Y]),ne=l.useCallback(()=>{var F;const ce=k.current,$=(F=window.getSelection)==null?void 0:F.call(window);if(!ce||!$||$.rangeCount===0||$.isCollapsed){q.current=!1;return}const pe=$.anchorNode,le=$.focusNode;q.current=!!(pe&&le&&ce.contains(pe)&&ce.contains(le))},[]),O=l.useMemo(()=>{const ce=ab(t),$=ru(t);return ib(lb(ce,$,u))},[t,u]),ie=O.length===t.length?p:void 0,z=Sf(O,ie),ae=l.useCallback(()=>{const ce=k.current;if(!ce||!c||!W.current)return;const $={top:ce.scrollTop,fromBottom:Math.max(0,ce.scrollHeight-ce.scrollTop-ce.clientHeight),messageFingerprint:z};J.current={contextKey:c,snapshot:$},Ln.set(c,$)},[c,z]),Ce=l.useCallback((ce="auto")=>{D.current!=null&&cancelAnimationFrame(D.current),D.current=requestAnimationFrame(()=>{D.current=null,X(ce)})},[X]),ye=l.useCallback(()=>{I.current=!1,L.current=!0,H.current=!0,_.current!=null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{L.current=!1,_.current=null},Il)},[]);l.useEffect(()=>{const ce=!T.current,$=M.current!==c;if(M.current=c,ce||$){T.current=!0;const le=c?Ln.get(c):null,F=!!le&&sa(le,z);I.current=F?Kn(le):!1,L.current=Af(le,z),q.current||(F?requestAnimationFrame(()=>{const be=k.current;be&&(Ga(be,le),I.current=Kn(le),Y(),H.current=!0)}):Ce("auto")),y.current=O.length,A.current=z;return}O.length>y.current;const pe=z!==A.current;Mf({hasSelection:q.current,userScrolledUp:I.current,hasChatContentChanged:pe})&&Ce("auto"),y.current=O.length,A.current=z},[z,c,O.length,Ce,Y]),l.useEffect(()=>{w&&(ye(),q.current||Ce("auto"))},[ye,Ce,w]),l.useEffect(()=>{const ce=P.current;ce&&!b&&ae(),W.current=b,P.current=b;const $=c?Ln.get(c):null;if(Cf(ce,b,$,z)){if(!$)return;I.current=Kn($),L.current=!1,q.current||requestAnimationFrame(()=>{const pe=k.current;pe&&(Ga(pe,$),Y())});return}},[b,c,z,ye,ae,Ce,Y]),l.useEffect(()=>()=>{const ce=J.current;ce&&Ln.set(ce.contextKey,ce.snapshot),D.current!=null&&cancelAnimationFrame(D.current),_.current!=null&&window.clearTimeout(_.current)},[]),l.useEffect(()=>{const ce=v.current,$=k.current;if(!ce||!$)return;const pe=()=>{_.current!=null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{L.current=!1,_.current=null},Il)},le=new ResizeObserver(()=>{Y();const F=L.current;If({hasSelection:q.current,userScrolledUp:I.current,contextAutoScrollActive:F})&&(Ce("auto"),F&&pe())});return le.observe(ce),$!==ce&&le.observe($),()=>{le.disconnect(),_.current!=null&&(window.clearTimeout(_.current),_.current=null)}},[Ce,c,Y]),l.useImperativeHandle(C,()=>({scrollToBottom:(ce="smooth")=>{X(ce)}}),[X]),l.useEffect(()=>{const ce=k.current;if(!ce)return;let $;const pe=()=>{ae(),clearTimeout($),$=setTimeout(()=>{I.current=!re(),Y()},50)};return ce.addEventListener("scroll",pe,{passive:!0}),()=>{ce.removeEventListener("scroll",pe),clearTimeout($)}},[ae,Y]),l.useEffect(()=>(document.addEventListener("selectionchange",ne),()=>document.removeEventListener("selectionchange",ne)),[ne]);const ke=l.useRef(0),me=l.useRef(!1);l.useEffect(()=>{const ce=k.current;if(!ce||!me.current||ke.current===0)return;const $=ce.scrollHeight-ke.current;$>0&&(ce.scrollTop=$),Y(),ae(),ke.current=0,me.current=!1},[O.length,ae,Y]),l.useEffect(()=>{if(H.current||!c)return;const ce=Ln.get(c),$=k.current;if(!(!ce||!$)){if(!sa(ce,z)){X("auto"),H.current=!0;return}Ga($,ce),I.current=Kn(ce),Y(),H.current=!0}},[c,z,O.length,X,Y]);const G=()=>{const ce=k.current;ce&&(ke.current=ce.scrollHeight),me.current=!0,f==null||f()},U=()=>{I.current=!0,de("smooth"),ae()},Z=()=>{ye(),X("smooth"),ae()},V=l.useMemo(()=>{const ce=O.map((F,be)=>({type:"message",data:F,index:be,ts:gf(F,be,d)}));if(!n||n.length===0)return ce;const $=[...n].sort((F,be)=>F.timestamp-be.timestamp).map((F,be)=>({type:"action",data:F,index:be,ts:F.timestamp})),pe=[];let le=0;for(const F of ce){for(;le<$.length&&F.ts>0&&$[le].ts<F.ts;)pe.push($[le++]);pe.push(F)}for(;le<$.length;)pe.push($[le++]);return pe},[O,n,d]),fe=h>0||!!j,Ie=h>0?h>80?S("chatList.showEarlierMessagesHidden",{count:Math.min(h,80),total:h}):S("chatList.showEarlierMessages",{count:Math.min(h,80)}):x?S("chatList.loadErrorRetry",{error:x}):S("chatList.loadOlderMessages");return s.jsxs("div",{className:"chat-scroll-frame",children:[s.jsx("div",{ref:k,"data-chat-scroll":!0,className:"chat-container",children:s.jsxs("div",{ref:v,className:"chat-container-content",children:[g&&s.jsx("div",{className:"text-center py-3 text-text-muted text-xs opacity-60 animate-pulse",children:S("chatList.loadingOlderMessages")}),fe&&!g&&s.jsx("div",{className:"text-center py-2",children:s.jsx("button",{type:"button",onClick:G,className:`text-[11px] rounded-xl px-4 py-1.5 cursor-pointer border transition-all ${x&&h===0?"bg-transparent border-yellow-500/30 text-yellow-400 opacity-80 hover:opacity-100":"bg-transparent border-border-subtle text-text-muted opacity-70 hover:opacity-100 hover:border-accent/40"}`,children:Ie})}),V.length===0&&!fe&&(m||s.jsx("div",{className:"text-center mt-16 opacity-20 text-[13px]",children:S("chatList.waitingForMessages")})),V.map(ce=>{if(ce.type==="action"){const je=ce.data;return s.jsx(pb,{log:je},`action-${ce.index}`)}const $=ce.data;ce.index;const pe=ta($),le=$.receivedAt||d[pe],F=`${c}-${pe}`,be=B.has(F);return s.jsx(mb,{message:$,receivedAt:le,agentName:r,userName:a,isCliMode:o,isTextExpanded:be,onToggleTextExpanded:()=>E(je=>{const Se=new Set(je);return be?Se.delete(F):Se.add(F),Se})},`msg-${pe}`)}),i&&s.jsx("div",{className:"self-start chat-typing-wrapper",children:s.jsxs("div",{className:"typing-indicator",children:[s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("span",{className:"text-[11px] text-text-muted ml-1",children:S("chatList.agentGenerating")})]})}),s.jsx("div",{className:"min-h-10",ref:N})]})}),(K.showTop||K.showBottom)&&s.jsxs("div",{className:"chat-scroll-jump-controls","aria-label":S("chatList.jumpToTop"),children:[K.showTop&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button",onClick:U,"aria-label":S("chatList.jumpToOldestMessages"),title:S("chatList.jumpToTop"),children:S("chatList.top")}),K.showBottom&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button chat-scroll-jump-button-primary",onClick:Z,"aria-label":S("chatList.jumpToLatestMessages"),title:S("chatList.jumpToBottom"),children:S("chatList.latest")})]})]})}),fb=l.memo(hb,(e,t)=>e.messages===t.messages&&e.actionLogs===t.actionLogs&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isWorking===t.isWorking&&e.contextKey===t.contextKey&&e.receivedAtMap===t.receivedAtMap&&e.lastMessageHash===t.lastMessageHash&&e.showActivityMessages===t.showActivityMessages&&e.emptyState===t.emptyState&&e.onLoadMore===t.onLoadMore&&e.isLoadingMore===t.isLoadingMore&&e.hasMoreHistory===t.hasMoreHistory&&e.hiddenLiveCount===t.hiddenLiveCount&&e.loadError===t.loadError&&e.scrollToBottomRequestNonce===t.scrollToBottomRequestNonce&&e.isVisible===t.isVisible),bb="modulepreload",gb=function(e){return"/"+e},_l={},xb=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));a=Promise.allSettled(n.map(d=>{if(d=gb(d),d in _l)return;_l[d]=!0;const p=d.endsWith(".css"),u=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const m=document.createElement("link");if(m.rel=p?"stylesheet":bb,p||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),p)return new Promise((f,g)=>{m.addEventListener("load",f),m.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})};let $l=!1;const lu=l.forwardRef(({onInput:e,onViewportMetrics:t,onScrollMetrics:n,fontSize:r=13,readOnly:a=!1,sizingMode:o="measured"},i)=>{const c=l.useRef(null),[d,p]=l.useState(null),u=l.useRef([]),m=l.useRef(!1),f=l.useRef(!1),g=l.useRef(!1),j=l.useRef(!1),h=()=>{const x=c.current;if(x){m.current&&(x.clear(),m.current=!1);for(const w of u.current)x.write(w.data,w.onProcessed);u.current=[],f.current&&(x.fit(),f.current=!1),g.current&&(x.bumpResize(),g.current=!1),j.current&&(x.scrollToTop(),j.current=!1)}};return l.useImperativeHandle(i,()=>({write:(x,w)=>{c.current?c.current.write(x,w):u.current.push({data:x,onProcessed:w})},clear:()=>{c.current?c.current.clear():(u.current=[],m.current=!0)},reset:()=>{c.current&&typeof c.current.reset=="function"?c.current.reset():(u.current=[],m.current=!0)},resize:(x,w)=>{c.current&&typeof c.current.resize=="function"&&c.current.resize(x,w)},fit:()=>{c.current?c.current.fit():f.current=!0},bumpResize:()=>{c.current?c.current.bumpResize():g.current=!0},scrollToTop:()=>{c.current?c.current.scrollToTop():j.current=!0},getSelection:()=>{var x,w;return((w=(x=c.current)==null?void 0:x.getSelection)==null?void 0:w.call(x))||""},getVisibleText:()=>{var x,w;return((w=(x=c.current)==null?void 0:x.getVisibleText)==null?void 0:w.call(x))||""}}),[]),l.useEffect(()=>{d&&h()},[d]),l.useEffect(()=>{let x=!1;return xb(()=>import("./terminal-DiXj2eIR.js"),__vite__mapDeps([0,1,2])).then(w=>{$l||($l=!0,console.info("[CliTerminal] renderer module loaded: terminal-render-web")),x||p(()=>w.GhosttyTerminalView)}).catch(w=>{console.error("[CliTerminal] failed to load terminal renderer",w)}),()=>{x=!0}},[]),d?s.jsx(d,{ref:c,onInput:e,onViewportMetrics:t,onScrollMetrics:n,fontSize:r,readOnly:a,sizingMode:o,className:"w-full h-full rounded-lg overflow-hidden"}):s.jsx("div",{className:"w-full h-full rounded-lg overflow-hidden animate-pulse",style:{background:"#0f1117"}})});lu.displayName="CliTerminal";function Ft(...e){return Ch(jh(e))}const vb={lg:"rounded-lg",xl:"rounded-xl","2xl":"rounded-2xl"},yb={none:"",sm:"p-3",md:"px-4 py-3.5",lg:"px-5 py-4"},Ss=l.forwardRef(function({radius:t="xl",padding:n="md",className:r,...a},o){return s.jsx("div",{ref:o,className:Ft("border border-border-subtle bg-bg-secondary",vb[t],yb[n],r),...a})});function kr({label:e,value:t,sub:n,icon:r}){return s.jsxs(Ss,{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base flex items-center",children:r}),s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),s.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),n&&s.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:n})]})}function Hl({value:e,max:t,label:n,color:r="#8b5cf6",detail:a,compact:o=!1}){const i=t>0?Math.min(Math.round(e/t*100),100):0,c=i>85?"#ef4444":i>60?"var(--status-warning)":r;return o?s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:n}),s.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[i,"%"]})]}),s.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${i}%`,background:c}})})]}):s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:n}),s.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[i,"%"]})]}),s.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${i}%`,background:`linear-gradient(90deg, ${c}, ${c}cc)`}})}),a&&s.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:a})]})}function wb({cursorPos:e,viewportRef:t,imgRef:n}){var b;if(!e||!n.current)return null;const r=n.current,a=r.getBoundingClientRect(),o=(b=t.current)==null?void 0:b.getBoundingClientRect();if(!o)return null;const i=r.naturalWidth||a.width,c=r.naturalHeight||a.height,d=i/c,p=a.width/a.height;let u,m,f,g;d>p?(u=a.width,m=a.width/d,f=0,g=(a.height-m)/2):(m=a.height,u=a.height*d,f=(a.width-u)/2,g=0);const j=a.left-o.left+f+u*e.nx,h=a.top-o.top+g+m*e.ny,x=Math.max(8,Math.min(o.width-8,j)),w=Math.max(8,Math.min(o.height-8,h));return s.jsxs("div",{style:{position:"absolute",left:x-8,top:w-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[s.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})}function kb({inputMode:e,onToggleInputMode:t,isImeOpen:n,setIsImeOpen:r,isMenuOpen:a,setIsMenuOpen:o,imeText:i,setImeText:c,handleImeSubmit:d,isConnActive:p,zoom:u,isMobile:m,mobileFillZoom:f,onZoomOut:g,onZoomReset:j,onZoomIn:h,transportType:x,screenshotUsage:w,lastActionStatus:b}){const{t:C}=Ne("common");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{onTouchStart:S=>S.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-20 flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[s.jsxs("div",{onClick:t,className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${e==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[s.jsx("span",{className:"text-sm",children:e==="mouse"?"🖱️":"👆"}),s.jsx("span",{className:`text-[10px] font-bold ${e==="mouse"?"text-blue-400":"text-slate-400"}`,children:C(e==="mouse"?"remote.mouse":"remote.touch")})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>{r(S=>!S),o(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${n?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⌨️"})}),n&&s.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-20",style:{animation:"slideUp 0.15s ease-out"},children:s.jsx("input",{type:"text",placeholder:C("remote.typeAndEnter"),value:i,autoFocus:!0,onTouchStart:S=>S.stopPropagation(),onChange:S=>c(S.target.value),onKeyDown:S=>{d(S)},className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),s.jsx("div",{className:"relative",children:s.jsx("div",{onClick:()=>{o(S=>!S),r(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${a?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⚙️"})})}),s.jsx("div",{className:"w-px h-[18px] bg-white/10"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:p?"rgba(34,197,94,0.12)":"rgba(234,179,8,0.12)"},children:[s.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:p?"#22c55e":"#eab308",boxShadow:p?"0 0 4px #22c55e80":"0 0 4px #eab30880"}}),s.jsx("span",{className:"text-[8px] font-extrabold",style:{color:p?"#22c55e":"#eab308"},children:C(p?"remote.connected":"remote.ws")})]}),u>1&&s.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(u*100),"%"]}),x==="direct"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"#22c55e",background:"rgba(34,197,94,0.12)"},title:C("remote.directP2PTitle"),children:C("remote.direct")}),x==="relay"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"var(--status-warning)",background:"color-mix(in srgb, var(--status-warning) 12%, transparent)"},title:C("remote.turnRelayTitle"),children:C("remote.relay")}),w&&w.dailyBudgetMinutes>0&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:w.budgetExhausted?"#ef4444":"#c4b5fd",background:w.budgetExhausted?"rgba(239,68,68,0.1)":"rgba(139,92,246,0.14)"},title:C("remote.dailyTurnTitle"),children:w.budgetExhausted?C("remote.turnBlocked"):C("remote.turnUsage",{used:w.dailyUsedMinutes,budget:w.dailyBudgetMinutes})}),b&&s.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:b})]})]}),a&&s.jsxs("div",{onTouchStart:S=>S.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:20,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[s.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:C("remote.settings")}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:[C("remote.zoom")," ",u<=(m?f:1)+.01?C(m?"remote.fill":"remote.fit"):`${Math.round(u*100)}%`]}),s.jsxs("div",{style:{display:"flex",gap:4},children:[s.jsx("button",{onClick:S=>{S.stopPropagation(),g()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),s.jsx("button",{onClick:S=>{S.stopPropagation(),j()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:C(m?"remote.fill":"remote.fit")}),s.jsx("button",{onClick:S=>{S.stopPropagation(),h()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]})]})]})}function Sb({waitingLabel:e,waitingHint:t,transportType:n}){const{t:r}=Ne("common");return s.jsxs("div",{className:"text-center flex flex-col items-center gap-3 px-6",children:[s.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center border border-white/10 bg-white/[0.04] shadow-[0_10px_30px_rgba(0,0,0,0.35)]",style:{animation:"remote-float 2.8s ease-in-out infinite"},children:s.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-8 h-8 opacity-90"})}),s.jsx("div",{className:"text-white/85 text-[13px] font-semibold tracking-wide",children:e}),s.jsx("div",{className:"text-[11px] text-white/40",children:t}),n==="relay"&&s.jsx("div",{className:"text-[10px] font-medium",style:{color:"var(--status-warning)",opacity:.8},children:r("remote.waitingState.turnRelayActive")})]})}function Cb(){if(typeof window>"u")return!1;try{return window.__ADHDEV_DEBUG_RENDERS__===!0||window.localStorage.getItem("adhdev_debug_renders")==="1"}catch{return window.__ADHDEV_DEBUG_RENDERS__===!0}}function Bl(e){return e==null||typeof e=="number"||typeof e=="boolean"?e:typeof e=="string"?e.length>64?`${e.slice(0,61)}...`:e:Array.isArray(e)?`Array(${e.length})`:typeof e=="object"?"Object":typeof e}function hr(e,t){const n=l.useRef(null),r=l.useRef(0);l.useEffect(()=>{if(!Cb())return;r.current+=1;const a=n.current;if(!a){console.debug(`[render-trace] ${e}#${r.current}`,{changed:["mount"],snapshot:Object.fromEntries(Object.entries(t).map(([i,c])=>[i,Bl(c)]))}),n.current=t;return}const o=Object.keys({...a,...t}).filter(i=>!Object.is(a[i],t[i]));o.length>0&&console.debug(`[render-trace] ${e}#${r.current}`,{changed:o,snapshot:Object.fromEntries(o.map(i=>[i,Bl(t[i])]))}),n.current=t})}function jb({containerRef:e,viewportRef:t,imgRef:n,inputMode:r,setInputMode:a,minZoom:o,zoomRef:i,panXRef:c,panYRef:d,setPanX:p,setPanY:u,setZoom:m,lastWheelTimeRef:f,onAction:g,setLastActionStatus:j,spawnRippleFromNormalized:h,clampPan:x,isMobile:w,mobileFillZoom:b}){const[C,S]=l.useState(null),k=l.useRef(null),v=l.useRef(null),N=l.useRef(null),y=l.useRef(!1),A=l.useRef(null),M=l.useRef(0),T=l.useRef(null),D=l.useRef(1),L=l.useRef({x:0,y:0}),_=l.useRef(!1),q=l.useRef(r),B=l.useRef(g),E=30,K=550,R=18,I=60,H=400,P=12,W=()=>{if(k.current)return;const Y={nx:.5,ny:.5};k.current=Y,S(Y)};return l.useEffect(()=>{q.current=r,r==="mouse"&&W()},[r]),l.useEffect(()=>{B.current=g},[g]),l.useEffect(()=>{const Y=e.current;if(!Y)return;const X=ae=>{if(!n.current)return null;const Ce=n.current.getBoundingClientRect();return!Ce.width||!Ce.height?null:{nx:Math.max(0,Math.min(1,(ae.clientX-Ce.left)/Ce.width)),ny:Math.max(0,Math.min(1,(ae.clientY-Ce.top)/Ce.height))}},de=(ae,Ce)=>{if(!n.current)return{dnx:0,dny:0};const ye=n.current,ke=ye.getBoundingClientRect(),me=ye.naturalWidth||ke.width,G=ye.naturalHeight||ke.height,U=me/G,Z=ke.width/ke.height;let V,fe;return U>Z?(V=ke.width,fe=ke.width/U):(fe=ke.height,V=ke.height*U),{dnx:ae/V,dny:Ce/fe}},ne=(ae,Ce,ye)=>{if(ye<=1.05)return;const ke=-(ae-.5)*100,me=-(Ce-.5)*100,G=x(ke,me,ye);(Math.abs(G.x-c.current)>.1||Math.abs(G.y-d.current)>.1)&&(p(G.x),u(G.y),c.current=G.x,d.current=G.y)},O=ae=>{const Ce=t.current;if(Ce&&ae.target instanceof Node&&Ce.contains(ae.target))ae.preventDefault();else return;if(ae.touches.length===1){const ye=ae.touches[0];v.current={x:ye.clientX,y:ye.clientY,time:Date.now()},N.current={x:ye.clientX,y:ye.clientY},_.current||(y.current=!1),A.current=setTimeout(()=>{if(!y.current&&!_.current)if(y.current=!0,q.current==="mouse"){const ke=k.current||{nx:.5,ny:.5};j("Right Click"),h(ke.nx,ke.ny,"right"),B.current("input_click",{...ke,button:"right"}).catch(()=>{})}else{const ke=X(ye);ke&&(j("Right Click"),h(ke.nx,ke.ny,"right"),B.current("input_click",{...ke,button:"right"}).catch(()=>{}))}},500);return}if(ae.touches.length===2){A.current&&clearTimeout(A.current),y.current=!0,_.current=!0;const ye=ae.touches[1].clientX-ae.touches[0].clientX,ke=ae.touches[1].clientY-ae.touches[0].clientY;T.current=Math.sqrt(ye*ye+ke*ke),D.current=i.current,L.current={x:(ae.touches[0].clientX+ae.touches[1].clientX)/2,y:(ae.touches[0].clientY+ae.touches[1].clientY)/2}}},ie=ae=>{const Ce=t.current;if(Ce&&ae.target instanceof Node&&Ce.contains(ae.target)&&ae.preventDefault(),ae.touches.length===1&&N.current){const ye=ae.touches[0],ke=ye.clientX-N.current.x,me=ye.clientY-N.current.y;if(!y.current&&v.current){const G=ye.clientX-v.current.x,U=ye.clientY-v.current.y;Math.sqrt(G*G+U*U)>8&&(y.current=!0,A.current&&clearTimeout(A.current))}if(y.current)if(q.current==="mouse"){const G=de(ke,me),U=k.current||{nx:.5,ny:.5},Z=Math.max(0,Math.min(1,U.nx+G.dnx)),V=Math.max(0,Math.min(1,U.ny+G.dny));k.current={nx:Z,ny:V},S({nx:Z,ny:V}),j(`Cursor: ${Math.round(Z*100)}%, ${Math.round(V*100)}%`),ne(Z,V,i.current);const fe=Date.now();fe-f.current>=30&&(f.current=fe,B.current("input_mouseMoved",{nx:Z,ny:V}).catch(()=>{}))}else if(i.current>1){const G=t.current;if(G){const U=G.clientWidth,Z=G.clientHeight,V=c.current+ke/U*100,fe=d.current+me/Z*100,Ie=x(V,fe,i.current);p(Ie.x),u(Ie.y),c.current=Ie.x,d.current=Ie.y}}else{const G=X(ye);if(G){const U=Date.now();U-f.current>=40&&(f.current=U,j("Scroll"),B.current("input_wheel",{nx:G.nx,ny:G.ny,deltaX:Math.round(-ke*2.5),deltaY:Math.round(-me*2.5)}).catch(()=>{}))}}N.current={x:ye.clientX,y:ye.clientY};return}if(ae.touches.length===2&&T.current!==null){const ye=ae.touches[1].clientX-ae.touches[0].clientX,ke=ae.touches[1].clientY-ae.touches[0].clientY,G=Math.sqrt(ye*ye+ke*ke)/T.current,U=(ae.touches[0].clientX+ae.touches[1].clientX)/2,Z=(ae.touches[0].clientY+ae.touches[1].clientY)/2,V=U-L.current.x,fe=Z-L.current.y,Ie=Math.abs(G-1)>.03;if(q.current==="mouse"){if(Ie){const ce=Math.max(o,Math.min(5,D.current*G));m(ce),i.current=ce}else if(Math.abs(V)>2||Math.abs(fe)>2){const ce=k.current||{nx:.5,ny:.5},$=Date.now();$-f.current>=30&&(f.current=$,j("Scroll"),B.current("input_wheel",{nx:ce.nx,ny:ce.ny,deltaX:Math.round(-V*3),deltaY:Math.round(-fe*3)}).catch(()=>{}))}}else{const ce=Math.max(o,Math.min(5,D.current*G));m(ce),i.current=ce;const $=t.current;if($&&ce>1){const pe=$.clientWidth,le=$.clientHeight,F=c.current+V/pe*100,be=d.current+fe/le*100,je=x(F,be,ce);p(je.x),u(je.y),c.current=je.x,d.current=je.y}}L.current={x:U,y:Z}}},z=ae=>{var Ce;if(A.current&&clearTimeout(A.current),T.current=null,ae.touches.length===1&&_.current){const ye=ae.touches[0];v.current={x:ye.clientX,y:ye.clientY,time:Date.now()},N.current={x:ye.clientX,y:ye.clientY},y.current=!0;return}if(ae.touches.length===0){if(_.current){_.current=!1,y.current=!1;return}if(ae.changedTouches.length===1){const ye=ae.changedTouches[0],ke=Date.now(),me=ke-(((Ce=v.current)==null?void 0:Ce.time)||0),G=v.current?ye.clientX-v.current.x:0,U=v.current?ye.clientY-v.current.y:0,Z=Math.sqrt(G*G+U*U);if(q.current==="mouse"){if(me<E||me>K||Z>R){y.current=!1;return}const V=k.current||X(ye);V&&(j(`Click: ${Math.round(V.nx*100)}%, ${Math.round(V.ny*100)}%`),h(V.nx,V.ny,"left"),B.current("input_click",{...V}).catch(()=>{}))}else{if(y.current){y.current=!1;return}if(me<I||me>H||Z>P){y.current=!1;return}const V=X(ye);if(!V)return;ke-M.current<300?(j("Double tap"),h(V.nx,V.ny,"double"),B.current("input_click",{...V,clickCount:2}).catch(()=>{}),M.current=0):(j(`Tap: ${Math.round(V.nx*100)}%, ${Math.round(V.ny*100)}%`),h(V.nx,V.ny,"left"),B.current("input_click",{...V}).catch(()=>{}),M.current=ke)}}y.current=!1}};return Y.addEventListener("touchstart",O,{passive:!1}),Y.addEventListener("touchmove",ie,{passive:!1}),Y.addEventListener("touchend",z,{passive:!1}),()=>{Y.removeEventListener("touchstart",O),Y.removeEventListener("touchmove",ie),Y.removeEventListener("touchend",z),A.current&&clearTimeout(A.current)}},[e,t,n,o,i,c,d,p,u,m,f,j,h,x]),{cursorPos:C,cursorPosRef:k,handleToggleInputMode:()=>{a(Y=>{const X=Y==="touch"?"mouse":"touch";return X==="mouse"&&W(),X})},handleZoomReset:()=>{const Y=w?b:1;m(Y),i.current=Y,p(0),u(0),c.current=0,d.current=0}}}function cu({onAction:e,addLog:t,connState:n,connScreenshot:r,screenshotUsage:a,transportType:o}){const i=l.useRef(null),c=l.useRef(null),d=l.useRef(null),[p,u]=l.useState(null),[m,f]=l.useState(""),[,g]=l.useState(!1),[j,h]=l.useState([]),x=l.useRef(0),[w,b]=l.useState(!1),[C,S]=l.useState(!1),k=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[v,N]=l.useState(k?"mouse":"touch"),[y,A]=l.useState(1),M=l.useRef(!1),[T,D]=l.useState(1),[L,_]=l.useState(0),[q,B]=l.useState(0);hr("RemoteView",{connState:n,hasScreenshot:!!r,inputMode:v,zoom:T,panX:L,panY:q,isMenuOpen:w,isImeOpen:C});const E=l.useRef(0),K=l.useRef(T),R=l.useRef(L),I=l.useRef(q);l.useEffect(()=>{K.current=T},[T]),l.useEffect(()=>{R.current=L},[L]),l.useEffect(()=>{I.current=q},[q]),l.useEffect(()=>{var me;(me=i.current)==null||me.focus()},[]);const H=n==="connected",P=r,W=H?"Connected. Waiting for first frame...":n==="connecting"?"Connecting to Host...":"Reconnecting to Host...",J=H?"The remote stream is warming up":"Waiting for the remote stream to catch up";l.useEffect(()=>{if(!k||M.current||!P)return;const me=d.current,G=c.current;if(!me||!G)return;const U=()=>{const Z=G.clientWidth,V=G.clientHeight,fe=me.naturalWidth,Ie=me.naturalHeight;if(!fe||!Ie||!Z||!V)return;const ce=Math.min(Z/fe,V/Ie),pe=Math.max(Z/fe,V/Ie)/ce;pe>1.01&&(A(pe),D(pe),K.current=pe),M.current=!0};me.complete&&me.naturalWidth?U():me.addEventListener("load",U,{once:!0})},[P,k]);const re=.5;l.useEffect(()=>{T<=re&&(_(0),B(0))},[T,re]);const Y=(me,G,U)=>{if(U<=re)return{x:0,y:0};const Z=(U-1)/(2*U)*100,V=(U-1)/(2*U)*100;return{x:Math.max(-Z,Math.min(Z,me)),y:Math.max(-V,Math.min(V,G))}},X=(me,G)=>{if(!d.current)return null;const U=d.current.getBoundingClientRect();return!U.width||!U.height?null:{nx:Math.max(0,Math.min(1,(me-U.left)/U.width)),ny:Math.max(0,Math.min(1,(G-U.top)/U.height))}},de=(me,G,U)=>{const Z=c.current;if(!Z)return;const V=Z.getBoundingClientRect(),fe=++x.current;h(Ie=>[...Ie,{id:fe,x:me-V.left,y:G-V.top,type:U}]),setTimeout(()=>h(Ie=>Ie.filter(ce=>ce.id!==fe)),600)},ne=(me,G,U)=>{const Z=d.current,V=c.current;if(!Z||!V)return;const fe=Z.getBoundingClientRect(),Ie=V.getBoundingClientRect(),ce=Z.naturalWidth||fe.width,$=Z.naturalHeight||fe.height,pe=ce/$,le=fe.width/fe.height;let F,be,je,Se;pe>le?(F=fe.width,be=fe.width/pe,je=0,Se=(fe.height-be)/2):(be=fe.height,F=fe.height*pe,je=(fe.width-F)/2,Se=0);const He=fe.left-Ie.left+je+F*me,Xe=fe.top-Ie.top+Se+be*G,dt=++x.current;h(it=>[...it,{id:dt,x:He,y:Xe,type:U}]),setTimeout(()=>h(it=>it.filter(he=>he.id!==dt)),600)},O=async me=>{var U;const G=X(me.clientX,me.clientY);if(G){u(`Click: ${Math.round(G.nx*100)}%, ${Math.round(G.ny*100)}%`),de(me.clientX,me.clientY,"left"),(U=i.current)==null||U.focus();try{const Z=await e("input_click",{nx:G.nx,ny:G.ny});Z!=null&&Z.success||t(`❌ Click failed: ${Z==null?void 0:Z.error}`)}catch(Z){t(`❌ Click error: ${Z.message||Z}`)}}},ie=async(me,G,U,Z=0)=>{try{await e("input_key",{type:U?"char":"keyDown",key:me,code:G,text:U?me:void 0,unmodifiedText:U?me:void 0,modifiers:Z})}catch(V){t(`❌ Key error: ${V.message||V}`)}},z=async me=>{if(me.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(me.key)&&me.preventDefault();let U=0;me.altKey&&(U|=1),me.ctrlKey&&(U|=2),me.metaKey&&(U|=4),me.shiftKey&&(U|=8),u(`Key: ${me.key}`),await ie(me.key,me.code,me.key.length===1,U)},ae=async me=>{if(me.key==="Enter"){if(me.nativeEvent.isComposing)return;if(m){const G=m;f(""),u(`IME Sent: ${G}`);try{const U=await e("input_type",{text:G});U!=null&&U.success||t(`❌ IME error: ${U==null?void 0:U.error}`)}catch(U){t(`❌ IME error: ${U.message}`)}}else u("Key: Enter"),await ie("Enter","Enter",!1)}};l.useEffect(()=>{const me=i.current;if(!me)return;const G=U=>{var Z;if((Z=d.current)!=null&&Z.contains(U.target)){U.preventDefault();const V=Date.now();if(V-E.current<40)return;E.current=V;const fe=X(U.clientX,U.clientY);if(!fe)return;u(`Scroll: ${Math.round(U.deltaY)}`),e("input_wheel",{nx:fe.nx,ny:fe.ny,deltaX:Math.round(U.deltaX),deltaY:Math.round(U.deltaY)}).catch(()=>{})}};return me.addEventListener("wheel",G,{passive:!1}),()=>me.removeEventListener("wheel",G)},[e]);const{cursorPos:Ce,handleToggleInputMode:ye,handleZoomReset:ke}=jb({containerRef:i,viewportRef:c,imgRef:d,inputMode:v,setInputMode:N,minZoom:re,zoomRef:K,panXRef:R,panYRef:I,setPanX:_,setPanY:B,setZoom:D,lastWheelTimeRef:E,onAction:e,setLastActionStatus:u,spawnRippleFromNormalized:ne,clampPan:Y,isMobile:k,mobileFillZoom:y});return s.jsxs("div",{ref:i,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:z,onContextMenu:me=>me.preventDefault(),onFocus:()=>g(!0),onBlur:()=>g(!1),tabIndex:0,children:[s.jsxs("div",{ref:c,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[P?s.jsx("img",{ref:d,src:P,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${T}) translate(${L}%, ${q}%)`,transformOrigin:"center center",cursor:v==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:O,onContextMenu:me=>me.preventDefault(),onDragStart:me=>me.preventDefault()}):s.jsx(Sb,{waitingLabel:W,waitingHint:J,transportType:o}),v==="mouse"&&P&&s.jsx(wb,{cursorPos:Ce,viewportRef:c,imgRef:d}),j.map(me=>{const U={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[me.type];return s.jsxs("div",{style:{position:"absolute",left:me.x,top:me.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[s.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${U}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),s.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${U}, 0.9)`,boxShadow:`0 0 12px rgba(${U}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},me.id)})]}),s.jsx(kb,{inputMode:v,onToggleInputMode:ye,isImeOpen:C,setIsImeOpen:S,isMenuOpen:w,setIsMenuOpen:b,imeText:m,setImeText:f,handleImeSubmit:ae,isConnActive:H,zoom:T,isMobile:k,mobileFillZoom:y,onZoomOut:()=>D(me=>Math.max(.5,me-.25)),onZoomReset:ke,onZoomIn:()=>D(me=>Math.min(5,me+.25)),transportType:o,screenshotUsage:a,lastActionStatus:p}),s.jsx("style",{children:`
9
9
  @keyframes slideUp {
10
10
  from { opacity: 0; transform: translateY(6px); }
11
11
  to { opacity: 1; transform: translateY(0); }
@@ -1,4 +1,4 @@
1
- import{r as Z,j as ui}from"./vendor-cL4V2vaO.js";/**
1
+ import{r as Z,j as ui}from"./vendor-DyCWA2YZ.js";/**
2
2
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  *