openfox 1.6.78 → 1.6.79

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.
@@ -2,7 +2,7 @@ import {
2
2
  maybeAutoCompactContext,
3
3
  performManualContextCompaction,
4
4
  resolveCompactionStatsIdentity
5
- } from "./chunk-GLVNO4DS.js";
5
+ } from "./chunk-UCZSBKG7.js";
6
6
  import "./chunk-OXI26S7U.js";
7
7
  import "./chunk-CMQCO27Y.js";
8
8
  import "./chunk-DL6ZILAF.js";
@@ -24,4 +24,4 @@ export {
24
24
  performManualContextCompaction,
25
25
  resolveCompactionStatsIdentity
26
26
  };
27
- //# sourceMappingURL=auto-compaction-AN3U2AD5.js.map
27
+ //# sourceMappingURL=auto-compaction-KTA6H4HP.js.map
@@ -8,8 +8,8 @@ import {
8
8
  } from "./chunk-2IZMUXMP.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-NWXLRRDD.js";
12
- import "./chunk-GLVNO4DS.js";
11
+ } from "./chunk-BG7QCFGG.js";
12
+ import "./chunk-UCZSBKG7.js";
13
13
  import "./chunk-OXI26S7U.js";
14
14
  import "./chunk-CMQCO27Y.js";
15
15
  import "./chunk-DL6ZILAF.js";
@@ -61,7 +61,7 @@ async function startChatSession(sessionId, content, deps, options) {
61
61
  sessionManager.setRunning(sessionId, true);
62
62
  broadcastForSession(sessionId, createSessionRunningMessage(true));
63
63
  try {
64
- const { maybeAutoCompactContext } = await import("./auto-compaction-AN3U2AD5.js");
64
+ const { maybeAutoCompactContext } = await import("./auto-compaction-KTA6H4HP.js");
65
65
  await maybeAutoCompactContext({
66
66
  sessionManager,
67
67
  sessionId,
@@ -172,4 +172,4 @@ export {
172
172
  startChatSession,
173
173
  stopSessionExecution
174
174
  };
175
- //# sourceMappingURL=chat-handler-AIBOSHAQ.js.map
175
+ //# sourceMappingURL=chat-handler-EKAO6CIB.js.map
@@ -2,7 +2,7 @@ import {
2
2
  createVerifierNudgeConfig,
3
3
  runBuilderTurn,
4
4
  runChatTurn
5
- } from "./chunk-NWXLRRDD.js";
5
+ } from "./chunk-BG7QCFGG.js";
6
6
  import {
7
7
  TurnMetrics,
8
8
  agentExists,
@@ -37,7 +37,7 @@ import {
37
37
  setSkillEnabled,
38
38
  skillExists,
39
39
  spawnShellProcess
40
- } from "./chunk-GLVNO4DS.js";
40
+ } from "./chunk-UCZSBKG7.js";
41
41
  import {
42
42
  getProject
43
43
  } from "./chunk-CMQCO27Y.js";
@@ -5242,7 +5242,7 @@ function createTerminalRoutes() {
5242
5242
  }
5243
5243
 
5244
5244
  // src/constants.ts
5245
- var VERSION = "1.6.78";
5245
+ var VERSION = "1.6.79";
5246
5246
 
5247
5247
  // src/server/index.ts
5248
5248
  var __dirname2 = dirname5(fileURLToPath4(import.meta.url));
@@ -5559,7 +5559,7 @@ async function createServerHandle(config) {
5559
5559
  if (!callId || approved === void 0) {
5560
5560
  return res.status(400).json({ error: "callId and approved are required" });
5561
5561
  }
5562
- const { providePathConfirmation } = await import("./tools-6DXPHBUV.js");
5562
+ const { providePathConfirmation } = await import("./tools-W6OPDFQV.js");
5563
5563
  const result = providePathConfirmation(callId, approved, alwaysAllow);
5564
5564
  if (!result.found) {
5565
5565
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
@@ -5583,7 +5583,7 @@ async function createServerHandle(config) {
5583
5583
  if (!callId || !answer) {
5584
5584
  return res.status(400).json({ error: "callId and answer are required" });
5585
5585
  }
5586
- const { provideAnswer: provideAnswer2 } = await import("./tools-6DXPHBUV.js");
5586
+ const { provideAnswer: provideAnswer2 } = await import("./tools-W6OPDFQV.js");
5587
5587
  const found = provideAnswer2(callId, answer);
5588
5588
  if (!found) {
5589
5589
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -5619,8 +5619,8 @@ async function createServerHandle(config) {
5619
5619
  if (!session) {
5620
5620
  return res.status(404).json({ error: "Session not found" });
5621
5621
  }
5622
- const { stopSessionExecution } = await import("./chat-handler-AIBOSHAQ.js");
5623
- const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-6DXPHBUV.js");
5622
+ const { stopSessionExecution } = await import("./chat-handler-EKAO6CIB.js");
5623
+ const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-W6OPDFQV.js");
5624
5624
  stopSessionExecution(sessionId, sessionManager);
5625
5625
  abortSession(sessionId);
5626
5626
  cancelQuestionsForSession(sessionId, "Session stopped by user");
@@ -6108,7 +6108,7 @@ async function createServerHandle(config) {
6108
6108
  providerManager
6109
6109
  );
6110
6110
  const wss = wssExports.wss;
6111
- const { QueueProcessor } = await import("./processor-PV446N55.js");
6111
+ const { QueueProcessor } = await import("./processor-O35Q3EZT.js");
6112
6112
  const queueProcessor = new QueueProcessor({
6113
6113
  sessionManager,
6114
6114
  providerManager,
@@ -6183,4 +6183,4 @@ export {
6183
6183
  createServerHandle,
6184
6184
  createServer
6185
6185
  };
6186
- //# sourceMappingURL=chunk-DKKDNJT7.js.map
6186
+ //# sourceMappingURL=chunk-3JU4NOQD.js.map
@@ -13,7 +13,7 @@ import {
13
13
  getToolRegistryForAgent,
14
14
  loadAllAgentsDefault,
15
15
  runTopLevelAgentLoop
16
- } from "./chunk-GLVNO4DS.js";
16
+ } from "./chunk-UCZSBKG7.js";
17
17
  import {
18
18
  getCurrentContextWindowId,
19
19
  getEventStore
@@ -327,4 +327,4 @@ export {
327
327
  runBuilderTurn,
328
328
  runVerifierTurn
329
329
  };
330
- //# sourceMappingURL=chunk-NWXLRRDD.js.map
330
+ //# sourceMappingURL=chunk-BG7QCFGG.js.map
@@ -190,7 +190,7 @@ async function runCli(options) {
190
190
  if (!configExists) {
191
191
  await runNetworkSetup(mode);
192
192
  }
193
- const { runServe } = await import("./serve-6ME66XOO.js");
193
+ const { runServe } = await import("./serve-55GF3KJW.js");
194
194
  const serveOptions = { mode };
195
195
  if (values.port) serveOptions.port = parseInt(values.port);
196
196
  if (values["no-browser"] === true) serveOptions.openBrowser = false;
@@ -202,4 +202,4 @@ async function runCli(options) {
202
202
  export {
203
203
  runCli
204
204
  };
205
- //# sourceMappingURL=chunk-VSYJIPRI.js.map
205
+ //# sourceMappingURL=chunk-HOD7GVQ5.js.map
@@ -3250,6 +3250,15 @@ async function runTopLevelAgentLoop(config, turnMetrics) {
3250
3250
  })
3251
3251
  );
3252
3252
  eventStore.append(sessionId, { type: "message.done", data: { messageId: asapMsgId } });
3253
+ const message = {
3254
+ id: asapMsgId,
3255
+ role: "user",
3256
+ content: asap.content,
3257
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3258
+ ...asap.attachments ? { attachments: asap.attachments } : {}
3259
+ };
3260
+ onMessage?.(createChatMessageMessage(message));
3261
+ onMessage?.(createChatDoneMessage(asapMsgId, "complete"));
3253
3262
  }
3254
3263
  if (asapMessages.length > 0) {
3255
3264
  onMessage?.(createQueueStateMessage(sessionManager.getQueueState(sessionId)));
@@ -3675,7 +3684,7 @@ var callSubAgentTool = {
3675
3684
  };
3676
3685
  }
3677
3686
  try {
3678
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-6DXPHBUV.js");
3687
+ const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-W6OPDFQV.js");
3679
3688
  const toolRegistry = getToolRegistryForAgent2(agentDef);
3680
3689
  const turnMetrics = new TurnMetrics();
3681
3690
  const result = await executeSubAgent({
@@ -4864,4 +4873,4 @@ export {
4864
4873
  getToolRegistryForAgent,
4865
4874
  createToolRegistry
4866
4875
  };
4867
- //# sourceMappingURL=chunk-GLVNO4DS.js.map
4876
+ //# sourceMappingURL=chunk-UCZSBKG7.js.map
package/dist/cli/dev.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-VSYJIPRI.js";
4
+ } from "../chunk-HOD7GVQ5.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-K44MW7JJ.js";
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-VSYJIPRI.js";
4
+ } from "../chunk-HOD7GVQ5.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-K44MW7JJ.js";
@@ -3,7 +3,7 @@ import {
3
3
  runBuilderTurn,
4
4
  runChatTurn,
5
5
  runVerifierTurn
6
- } from "./chunk-NWXLRRDD.js";
6
+ } from "./chunk-BG7QCFGG.js";
7
7
  import {
8
8
  TurnMetrics,
9
9
  createChatDoneEvent,
@@ -11,7 +11,7 @@ import {
11
11
  createMessageStartEvent,
12
12
  createToolCallEvent,
13
13
  createToolResultEvent
14
- } from "./chunk-GLVNO4DS.js";
14
+ } from "./chunk-UCZSBKG7.js";
15
15
  import "./chunk-OXI26S7U.js";
16
16
  import "./chunk-CMQCO27Y.js";
17
17
  import "./chunk-DL6ZILAF.js";
@@ -40,4 +40,4 @@ export {
40
40
  runChatTurn,
41
41
  runVerifierTurn
42
42
  };
43
- //# sourceMappingURL=orchestrator-5BY2MH72.js.map
43
+ //# sourceMappingURL=orchestrator-5U4O4K7V.js.map
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfox",
3
- "version": "1.6.78",
3
+ "version": "1.6.79",
4
4
  "description": "Local-LLM-first agentic coding assistant",
5
5
  "type": "module",
6
6
  "bin": {
@@ -177,7 +177,7 @@ var QueueProcessor = class {
177
177
  backend: provider?.backend ?? llmClient.getBackend(),
178
178
  model: llmClient.getModel()
179
179
  };
180
- const { runChatTurn } = await import("./orchestrator-5BY2MH72.js");
180
+ const { runChatTurn } = await import("./orchestrator-5U4O4K7V.js");
181
181
  const runChatTurnParams = buildRunChatTurnParams({
182
182
  sessionManager,
183
183
  sessionId,
@@ -214,4 +214,4 @@ var QueueProcessor = class {
214
214
  export {
215
215
  QueueProcessor
216
216
  };
217
- //# sourceMappingURL=processor-PV446N55.js.map
217
+ //# sourceMappingURL=processor-O35Q3EZT.js.map
@@ -6,9 +6,9 @@ import {
6
6
  import {
7
7
  VERSION,
8
8
  createServer
9
- } from "./chunk-DKKDNJT7.js";
10
- import "./chunk-NWXLRRDD.js";
11
- import "./chunk-GLVNO4DS.js";
9
+ } from "./chunk-3JU4NOQD.js";
10
+ import "./chunk-BG7QCFGG.js";
11
+ import "./chunk-UCZSBKG7.js";
12
12
  import "./chunk-OXI26S7U.js";
13
13
  import "./chunk-CMQCO27Y.js";
14
14
  import "./chunk-DL6ZILAF.js";
@@ -190,4 +190,4 @@ async function runServe(options) {
190
190
  export {
191
191
  runServe
192
192
  };
193
- //# sourceMappingURL=serve-6ME66XOO.js.map
193
+ //# sourceMappingURL=serve-55GF3KJW.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createServer,
3
3
  createServerHandle
4
- } from "../chunk-DKKDNJT7.js";
5
- import "../chunk-NWXLRRDD.js";
6
- import "../chunk-GLVNO4DS.js";
4
+ } from "../chunk-3JU4NOQD.js";
5
+ import "../chunk-BG7QCFGG.js";
6
+ import "../chunk-UCZSBKG7.js";
7
7
  import "../chunk-OXI26S7U.js";
8
8
  import "../chunk-CMQCO27Y.js";
9
9
  import "../chunk-DL6ZILAF.js";
@@ -11,7 +11,7 @@ import {
11
11
  requestPathAccess,
12
12
  stepDoneTool,
13
13
  validateToolAction
14
- } from "./chunk-GLVNO4DS.js";
14
+ } from "./chunk-UCZSBKG7.js";
15
15
  import "./chunk-OXI26S7U.js";
16
16
  import "./chunk-CMQCO27Y.js";
17
17
  import "./chunk-DL6ZILAF.js";
@@ -49,4 +49,4 @@ export {
49
49
  stepDoneTool,
50
50
  validateToolAction
51
51
  };
52
- //# sourceMappingURL=tools-6DXPHBUV.js.map
52
+ //# sourceMappingURL=tools-W6OPDFQV.js.map
@@ -54,7 +54,7 @@ Error generating stack: `+p.message+`
54
54
  *
55
55
  * This source code is licensed under the MIT license found in the
56
56
  * LICENSE file in the root directory of this source tree.
57
- */var zx;function k1(){if(zx)return Hd;zx=1;var e=ac();function r(m,v){return m===v&&(m!==0||1/m===1/v)||m!==m&&v!==v}var s=typeof Object.is=="function"?Object.is:r,i=e.useState,l=e.useEffect,u=e.useLayoutEffect,h=e.useDebugValue;function c(m,v){var S=v(),k=i({inst:{value:S,getSnapshot:v}}),C=k[0].inst,y=k[1];return u(function(){C.value=S,C.getSnapshot=v,d(C)&&y({inst:C})},[m,S,v]),l(function(){return d(C)&&y({inst:C}),m(function(){d(C)&&y({inst:C})})},[m]),h(S),S}function d(m){var v=m.getSnapshot;m=m.value;try{var S=v();return!s(m,S)}catch{return!0}}function f(m,v){return v()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Hd.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Hd}var Px;function E1(){return Px||(Px=1,Pd.exports=k1()),Pd.exports}var j1=E1();const N1=d1.useInsertionEffect,T1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",A1=T1?P.useLayoutEffect:P.useEffect,D1=N1||A1,Dv=e=>{const r=P.useRef([e,(...s)=>r[0](...s)]).current;return D1(()=>{r[0]=e}),r[1]},R1="popstate",Oh="pushState",Mh="replaceState",L1="hashchange",Hx=[R1,Oh,Mh,L1],O1=e=>{for(const r of Hx)addEventListener(r,e);return()=>{for(const r of Hx)removeEventListener(r,e)}},Rv=(e,r)=>j1.useSyncExternalStore(O1,e,r),Fx=()=>location.search,M1=({ssrSearch:e}={})=>Rv(Fx,e!=null?()=>e:Fx),Ux=()=>location.pathname,I1=({ssrPath:e}={})=>Rv(Ux,e!=null?()=>e:Ux),B1=(e,{replace:r=!1,state:s=null}={})=>history[r?Mh:Oh](s,"",e),z1=(e={})=>[I1(e),B1],$x=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[$x]>"u"){for(const e of[Oh,Mh]){const r=history[e];history[e]=function(){const s=r.apply(this,arguments),i=new Event(e);return i.arguments=arguments,dispatchEvent(i),s}}Object.defineProperty(window,$x,{value:!0})}const P1=(e,r)=>r.toLowerCase().indexOf(e.toLowerCase())?"~"+r:r.slice(e.length)||"/",Lv=(e="")=>e==="/"?"":e,H1=(e,r)=>e[0]==="~"?e.slice(1):Lv(r)+e,F1=(e="",r)=>P1(qx(Lv(e)),qx(r)),qx=e=>{try{return decodeURI(e)}catch{return e}},Ov={hook:z1,searchHook:M1,parser:C1,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,r,s)=>e(r,s)},Mv=P.createContext(Ov),Gi=()=>P.useContext(Mv),Iv={},Bv=P.createContext(Iv),U1=()=>P.useContext(Bv),oc=e=>{const[r,s]=e.hook(e);return[F1(e.base,r),Dv((i,l)=>e.aroundNav(s,H1(i,e.base),l))]},lr=()=>oc(Gi()),Ih=(e,r,s,i)=>{const{pattern:l,keys:u}=r instanceof RegExp?{keys:!1,pattern:r}:e(r||"*",i),h=l.exec(s)||[],[c,...d]=h;return c!==void 0?[!0,(()=>{const f=u!==!1?Object.fromEntries(u.map((m,v)=>[m,d[v]])):h.groups;let g={...d};return f&&Object.assign(g,f),g})(),...i?[c]:[]]:[!1,null]},Bh=e=>Ih(Gi().parser,e,lr()[0]),$1=({children:e,...r})=>{var g,m,v;const s=Gi(),i=r.hook?Ov:s;let l=i;const[u,h=r.ssrSearch??""]=((g=r.ssrPath)==null?void 0:g.split("?"))??[];u&&(r.ssrSearch=h,r.ssrPath=u),r.hrefs=r.hrefs??((m=r.hook)==null?void 0:m.hrefs),r.searchHook=r.searchHook??((v=r.hook)==null?void 0:v.searchHook);let c=P.useRef({}),d=c.current,f=d;for(let S in i){const k=S==="base"?i[S]+(r[S]??""):r[S]??i[S];d===f&&k!==f[S]&&(c.current=f={...f}),f[S]=k,(k!==i[S]||k!==l[S])&&(l=f)}return P.createElement(Mv.Provider,{value:l,children:e})},Wx=({children:e,component:r},s)=>r?P.createElement(r,{params:s}):typeof e=="function"?e(s):e,q1=e=>{let r=P.useRef(Iv);const s=r.current;return r.current=Object.keys(e).length!==Object.keys(s).length||Object.entries(e).some(([i,l])=>l!==s[i])?e:s},$a=({path:e,nest:r,match:s,...i})=>{const l=Gi(),[u]=oc(l),[h,c,d]=s??Ih(l.parser,e,u,r),f=q1({...U1(),...c});if(!h)return null;const g=d?P.createElement($1,{base:d},Wx(i,f)):Wx(i,f);return P.createElement(Bv.Provider,{value:f,children:g})},Fn=P.forwardRef((e,r)=>{const s=Gi(),[i,l]=oc(s),{to:u="",href:h=u,onClick:c,asChild:d,children:f,className:g,replace:m,state:v,transition:S,...k}=e,C=Dv(b=>{b.ctrlKey||b.metaKey||b.altKey||b.shiftKey||b.button!==0||(c==null||c(b),b.defaultPrevented||(b.preventDefault(),l(h,e)))}),y=s.hrefs(h[0]==="~"?h.slice(1):s.base+h,s);return d&&P.isValidElement(f)?P.cloneElement(f,{onClick:C,href:y}):P.createElement("a",{...k,onClick:C,href:y,className:g!=null&&g.call?g(i===h):g,children:f,ref:r})}),zv=e=>Array.isArray(e)?e.flatMap(r=>zv(r&&r.type===P.Fragment?r.props.children:r)):[e],W1=({children:e,location:r})=>{const s=Gi(),[i]=oc(s);for(const l of zv(e)){let u=0;if(P.isValidElement(l)&&(u=Ih(s.parser,l.props.path,r||i,l.props.nest))[0])return P.cloneElement(l,{match:u})}return null};function V1(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Pv(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}class G1{constructor(r){fr(this,"ws",null);fr(this,"handlers",new Set);fr(this,"statusHandler",null);fr(this,"baseUrl");fr(this,"isReconnecting",!1);fr(this,"connectingPromise",null);fr(this,"lastCloseCode",0);fr(this,"reconnectAttempts",0);fr(this,"manualReconnectScheduled",!1);this.baseUrl=r}getUrl(){const r=localStorage.getItem("openfox_token");if(r){const s=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${s}token=${encodeURIComponent(r)}`}return this.baseUrl}setToken(r){localStorage.setItem("openfox_token",r)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(r){this.statusHandler=r}connect(){var r,s;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((s=this.ws)==null?void 0:s.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.connectingPromise=new Promise((i,l)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const h=setTimeout(()=>{var c;((c=this.ws)==null?void 0:c.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var c;clearTimeout(h),this.isReconnecting=!1,this.connectingPromise=null,(c=this.statusHandler)==null||c.call(this,"connected"),i()},this.ws.onclose=c=>{var d,f,g;clearTimeout(h),this.lastCloseCode=c.code,((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),l(new Error(`Connection closed: ${c.code}`))):(this.connectingPromise=null,(g=this.statusHandler)==null||g.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=c=>{clearTimeout(h),console.error("WebSocket error:",c),this.connectingPromise=null,l(c)},this.ws.onmessage=c=>{try{const d=JSON.parse(c.data);V1(d)&&this.handlers.forEach(f=>f(d))}catch(d){console.error("Failed to parse WebSocket message:",d)}}}catch(u){this.connectingPromise=null,l(u)}}),this.connectingPromise))}attemptReconnect(){var l;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.log("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(l=this.statusHandler)==null||l.call(this,"reconnecting");const i=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{})},i)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(r,s){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const i=Pv(),l={id:i,type:r,payload:s};return this.ws.send(JSON.stringify(l)),i}subscribe(r){return this.handlers.add(r),()=>this.handlers.delete(r)}get isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}}const K1=window.location.protocol==="https:"?"wss:":"ws:";let fh=window.location.port;fh||(fh=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const Y1=`${K1}//${window.location.hostname}:${fh}/ws`,Gt=new G1(Y1),xs=async(e,r,s)=>{try{const i=await ke(r,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return i.ok?{success:!0}:{success:!1,error:(await i.json()).error}}catch{return{success:!1,error:"Network error"}}};function Hv(e){let r=null;function s(){r===null&&(r=requestAnimationFrame(()=>{r=null,e()}))}return s}let Il=[];const gr=$n()((e,r)=>{function s(){if(Il.length===0)return;const l=Il;Il=[],e(u=>({logs:[...u.logs,...l]}))}const i=Hv(s);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:l=>{r().workdir!==l&&(e({workdir:l,status:null,logs:[],config:null,loading:!0}),l&&(r().fetchStatus(),r().fetchConfig()))},fetchStatus:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server?workdir=${encodeURIComponent(l)}`)).json();e({status:h,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`)).json();e({config:h.config??null})}catch{}},fetchLogs:async()=>{const l=r().workdir;if(l)try{const c=(await(await ke(`/api/dev-server/logs?workdir=${encodeURIComponent(l)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content}));e({logs:c})}catch{}},start:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/start?workdir=${encodeURIComponent(l)}`,{method:"POST"})).json();e({status:h,logs:[]})}catch{}},stop:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/stop?workdir=${encodeURIComponent(l)}`,{method:"POST"})).json();e({status:h})}catch{}},restart:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/restart?workdir=${encodeURIComponent(l)}`,{method:"POST"})).json();e({status:h,logs:[]})}catch{}},saveConfig:async l=>{const u=r().workdir;if(u)try{const c=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(u)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})).json();e({config:c.config??l}),r().fetchStatus()}catch{}},handleMessage:l=>{const u=r().workdir;if(u)switch(l.type){case"devServer.output":{const h=l.payload;if(h.workdir!==u)return;Il.push({stream:h.stream,content:h.content}),i();break}case"devServer.state":{const h=l.payload;if(h.workdir!==u)return;e(c=>({status:c.status?{...c.status,state:h.state,errorMessage:h.errorMessage}:c.status}));break}}}}});function X1(e){return{...e.temperature!=null&&{temperature:e.temperature},...e.topP!=null&&{topP:e.topP},...e.topK!=null&&{topK:e.topK},...e.maxTokens!=null&&{maxTokens:e.maxTokens}}}async function Vx(e,r,s){const i=await ke(`/api/providers/${e}/models/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok){const l=await i.json();throw new Error(l.error??"Failed to update model")}return i.json()}function Gx(e,r,s,i){return e.map(l=>l.id===r?{...l,models:l.models.map(u=>u.id===s?{...u,...i,source:"user"}:u)}:l)}const Z1=3e4;function Q1(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return""}}const Rt=$n((e,r)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const s=await ke("/api/config");if(!s.ok)throw new Error("Failed to fetch config");const i=await s.json();e({version:i.version,model:i.model,maxContext:i.maxContext,llmUrl:i.llmUrl,llmStatus:i.llmStatus,backend:i.backend,providers:i.providers??[],activeProviderId:i.activeProviderId??null,defaultModelSelection:i.defaultModelSelection??null,loading:!1})}catch(s){e({error:s instanceof Error?s.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const s=await ke("/api/model/refresh",{method:"POST"});if(!s.ok)throw new Error("Failed to refresh model");const i=await s.json(),u=we.getState().currentSession;if(u!=null&&u.providerId&&u.providerModel){e({llmStatus:i.llmStatus,backend:i.backend});return}e({model:i.model,llmStatus:i.llmStatus,backend:i.backend})}catch(s){console.error("Failed to refresh model:",s)}},activateProvider:async s=>{const{activeProviderId:i,providers:l}=r();if(s===i)return!0;e({activating:!0,error:null});try{const u=await ke(`/api/providers/${s}/activate`,{method:"POST"});if(!u.ok){const c=await u.json();throw new Error(c.error??"Failed to activate provider")}const h=await u.json();return e({activeProviderId:h.activeProviderId,model:h.model,backend:h.backend,providers:l.map(c=>({...c,isActive:c.id===h.activeProviderId})),activating:!1}),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(s,i)=>{const{providers:l}=r();e({activeProviderId:s,model:i,defaultModelSelection:`${s}/${i}`,providers:l.map(u=>({...u,isActive:u.id===s}))})},updateModelContext:async(s,i,l)=>{e({activating:!0,error:null});try{const u=await Vx(s,i,{contextWindow:l}),{providers:h}=r();return e({providers:Gx(h,s,i,{contextWindow:l}),activating:!1}),u.contextState&&we.getState().updateContextState(u.contextState),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(s,i,l)=>{e({activating:!0,error:null});try{const u=await Vx(s,i,l),{providers:h}=r(),c={...l.contextWindow!==void 0&&{contextWindow:l.contextWindow},...X1({temperature:l.temperature??void 0,topP:l.topP??void 0,topK:l.topK??void 0,maxTokens:l.maxTokens??void 0}),...l.supportsVision!==void 0&&{supportsVision:l.supportsVision}};return e({providers:Gx(h,s,i,c),activating:!1}),u.contextState&&we.getState().updateContextState(u.contextState),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async s=>{e({activating:!0,error:null});try{const i=await ke(`/api/providers/${s}/refresh`,{method:"POST"});if(!i.ok){const h=await i.json();throw new Error(h.error??"Failed to refresh models")}const l=await i.json(),{providers:u}=r();return e({providers:u.map(h=>h.id===s?{...h,models:l.models}:h),activating:!1}),!0}catch(i){return e({error:i instanceof Error?i.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:s,refreshModel:i}=r();if(s)return;const l=setInterval(()=>{i()},Z1);e({autoRefreshInterval:l})},stopAutoRefresh:()=>{const{autoRefreshInterval:s}=r();s&&(clearInterval(s),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:s,activeProviderId:i}=r();return s.find(l=>l.id===i)},getModelContext:s=>{const{providers:i,activeProviderId:l}=r(),u=i.find(c=>c.id===l);if(!u)return 2e5;const h=u.models.find(c=>c.id===s);return(h==null?void 0:h.contextWindow)??2e5}})),Ft=$n((e,r)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const i=await(await ke("/api/projects")).json();e({projects:i.projects??[],loading:!1})}catch(s){console.error("Failed to load projects:",s),e({loading:!1})}},createProject:async(s,i)=>{try{const l=await ke("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,workdir:i})});if(!l.ok)return null;const u=await l.json();return await r().listProjects(),u.project}catch{return null}},loadProject:async s=>{try{const i=await ke(`/api/projects/${s}`);if(!i.ok)return null;const l=await i.json();return e({currentProject:l.project}),r().projects.length===0&&await r().listProjects(),l.project}catch{return null}},updateProject:async(s,i)=>{var l;try{const u=await ke(`/api/projects/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!u.ok)return null;const h=await u.json();return((l=r().currentProject)==null?void 0:l.id)===s&&e({currentProject:h.project}),await r().listProjects(),h.project}catch{return null}},deleteProject:async s=>{var i;try{return(await ke(`/api/projects/${s}`,{method:"DELETE"})).ok?(await r().listProjects(),((i=r().currentProject)==null?void 0:i.id)===s&&e({currentProject:null}),!0):!1}catch{return!1}},clearProject:()=>{e({currentProject:null})}}));let Bl=[];const no=$n()((e,r)=>{function s(){if(Bl.length===0)return;const l=Bl;Bl=[],e(u=>{const h={...u.logs};for(const c of l){const d=h[c.processId]??[];h[c.processId]=[...d,{offset:d.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:h}})}const i=Hv(s);return{processes:[],logs:{},loading:!1,setProcesses:l=>e({processes:l}),addProcess:l=>e(u=>({processes:[...u.processes,l]})),updateProcess:(l,u)=>e(h=>({processes:h.processes.map(c=>c.id===l?{...c,...u}:c)})),removeProcess:l=>e(u=>({processes:u.processes.filter(h=>h.id!==l),logs:Object.fromEntries(Object.entries(u.logs).filter(([h])=>h!==l))})),stopProcess:async(l,u)=>{try{(await ke(`/api/sessions/${u}/background-process/${l}/stop`,{method:"POST"})).ok&&r().removeProcess(l)}catch{}},appendLog:(l,u,h)=>{Bl.push({processId:l,stream:u,content:h}),i()},setLogs:(l,u)=>e(h=>({logs:{...h.logs,[l]:u}})),clearLogs:l=>e(u=>({logs:{...u.logs,[l]:[]}})),handleMessage:(l,u)=>{switch(l){case"backgroundProcess.started":{const{processId:h,name:c,pid:d,status:f}=u;e(g=>({processes:[...g.processes,{id:h,sessionId:"",name:c,command:"",cwd:"",pid:d,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const h=u.processId,c=u.stream,d=u.content;r().appendLog(h,c,d);break}case"backgroundProcess.exited":{const h=u.processId,c=u.exitCode;e(d=>({processes:d.processes.map(f=>f.id===h?{...f,status:"exited",exitCode:c}:f)}));break}case"backgroundProcess.removed":{const h=u.processId;r().removeProcess(h);break}}}}}),J1=[{key:"complete",label:"Task Complete",description:"When an agent finishes its work"},{key:"waiting_for_user",label:"Waiting for Input",description:"When the agent needs your input"},{key:"phase_done",label:"Phase Done",description:"When a build phase completes successfully"},{key:"phase_blocked",label:"Phase Blocked",description:"When a build phase is blocked and needs intervention"},{key:"new_message",label:"New Message",description:"When a new assistant message starts arriving"}],ew=[{url:"/sounds/notification.mp3",label:"Notification"},{url:"/sounds/waiting-for-user.mp3",label:"Waiting for User"},{url:"/sounds/achievement.mp3",label:"Achievement"},{url:"/sounds/intervention.mp3",label:"Intervention"},{url:"/sounds/typing.mp3",label:"Typing"}],Fv={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},ms={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Uv={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},ph={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...ms},waiting_for_user:{...ms},phase_done:{...ms},phase_blocked:{...ms},new_message:{...Uv}},agentOverrides:{}};function $v(e,r,s){var u;const i=e.events[r];if(!s)return i;const l=(u=e.agentOverrides[s])==null?void 0:u[r];return l?{soundEnabled:l.soundEnabled??i.soundEnabled,browserNotification:l.browserNotification??i.browserNotification,customSoundUrl:l.customSoundUrl!==void 0?l.customSoundUrl:i.customSoundUrl}:i}const Fs=$n((e,r)=>({settings:ph,loaded:!1,load:()=>{gn.getState().getSetting(ot.NOTIFICATION_SETTINGS);const i=gn.subscribe(u=>{const h=u.settings[ot.NOTIFICATION_SETTINGS];if(h!==void 0)try{const c=JSON.parse(h);e({settings:Kx(c),loaded:!0})}catch{e({loaded:!0})}}),l=gn.getState().settings[ot.NOTIFICATION_SETTINGS];if(l)try{const u=JSON.parse(l);e({settings:Kx(u),loaded:!0})}catch{e({loaded:!0})}return i},update:s=>{e({settings:s}),Fd(s)},updateEvent:(s,i)=>{const l=r().settings,u={...l,events:{...l.events,[s]:{...l.events[s],...i}}};e({settings:u}),Fd(u)},updateAgentOverride:(s,i,l)=>{var d;const u=r().settings,h={...u.agentOverrides};if(l===null){if(h[s]){const f={...h[s]};delete f[i],Object.keys(f).length===0?delete h[s]:h[s]=f}}else h[s]={...h[s],[i]:{...((d=h[s])==null?void 0:d[i])??{},...l}};const c={...u,agentOverrides:h};e({settings:c}),Fd(c)}}));function Fd(e){gn.getState().setSetting(ot.NOTIFICATION_SETTINGS,JSON.stringify(e))}function Kx(e){var r,s,i,l,u;return{soundEnabled:e.soundEnabled??ph.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??ph.browserNotificationEnabled,events:{complete:{...ms,...(r=e.events)==null?void 0:r.complete},waiting_for_user:{...ms,...(s=e.events)==null?void 0:s.waiting_for_user},phase_done:{...ms,...(i=e.events)==null?void 0:i.phase_done},phase_blocked:{...ms,...(l=e.events)==null?void 0:l.phase_blocked},new_message:{...Uv,...(u=e.events)==null?void 0:u.new_message}},agentOverrides:e.agentOverrides??{}}}const Yx=new Map;function tw(e){let r=Yx.get(e);return r||(r=new Audio(e),r.volume=.5,Yx.set(e,r)),r}let qv=typeof Notification<"u"?Notification.permission:"denied";function nw(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(qv=e,e))}const rw={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},sw={complete:"The agent has finished its work.",waiting_for_user:"The agent needs your input to continue.",phase_done:"The build phase completed successfully.",phase_blocked:"The build phase is blocked and needs intervention.",new_message:"A new assistant message is arriving."};function iw(e){typeof Notification>"u"||qv==="granted"&&(document.hasFocus()||new Notification(rw[e],{body:sw[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function go(e,r){const{settings:s}=Fs.getState(),i=$v(s,e,r);if(s.soundEnabled&&i.soundEnabled){const l=i.customSoundUrl??Fv[e],u=tw(l);u.currentTime=0,u.play().catch(()=>{})}s.browserNotificationEnabled&&i.browserNotification&&iw(e)}const aw=e=>go("complete",e),ow=e=>go("phase_done",e),lw=e=>go("phase_blocked",e),Xx=e=>go("waiting_for_user",e),cw=e=>go("new_message",e);let qa=!1,pr=null;const Ud=new Set,Vt={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Ui=null,pn=null;function $d(){Ui===null&&(Ui=requestAnimationFrame(()=>{Ui=null,pn==null||pn()}))}function Is(){Ui!==null&&(cancelAnimationFrame(Ui),Ui=null)}function Ht(e,r){return r!==null&&e.sessionId===r}function uw(e,r,s){return e.id!==void 0||Ht(e,r)||s===!0&&e.sessionId!==void 0}function dw(e,r){return e.includes(r)?e:[...e,r]}function Wa(e,r){return e.filter(s=>s!==r)}function hw(e,r){const s=e.find(l=>l.id===r.id),i=s?{...s,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,messageCount:r.messages.length,criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(l=>l.status.type==="passed").length}:{id:r.id,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,createdAt:"",updatedAt:"",criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(l=>l.status.type==="passed").length,messageCount:r.messages.length};return s?e.map(l=>l.id===r.id?i:l):[i,...e]}function Zx(e,r,s){return e.map(i=>{const l=(s==null?void 0:s.id)===i.id?s:null,u=r.find(h=>h.id===i.id);return{...i,title:i.title??(u==null?void 0:u.title),mode:(l==null?void 0:l.mode)??(u==null?void 0:u.mode)??i.mode,phase:(l==null?void 0:l.phase)??(u==null?void 0:u.phase)??i.phase,isRunning:i.isRunning&&(u==null?void 0:u.isRunning)!==!1,messageCount:i.messageCount,recentUserPrompts:i.recentUserPrompts}})}const Qx=new Map;function eo(e,r){var u;const s=r===((u=e.currentSession)==null?void 0:u.id)?e.currentSession:null,i=e.sessions.find(h=>h.id===r),l=(s==null?void 0:s.mode)??(i==null?void 0:i.mode);return l==="planner"?"planner":l==="builder"?"build":"planner"}function fw(e,r){if(e.type==="chat.done"){const s=e.payload,i=eo(r,e.sessionId),l=s.agentType??i;s.reason==="complete"&&aw(l),s.reason==="waiting_for_user"&&Xx(l);return}if(e.type==="chat.path_confirmation"){const s=eo(r,e.sessionId);Xx(s);return}if(e.type==="task.completed"){const s=eo(r,e.sessionId);ow(s);return}if(e.type==="phase.changed"&&e.sessionId){const s=e.payload,i=Qx.get(e.sessionId)??null;if(Qx.set(e.sessionId,s.phase),i===s.phase)return;const l=eo(r,e.sessionId);s.phase==="blocked"&&lw(l)}}const we=$n((e,r)=>(pn=()=>{const s=Vt;if(!s.messageId)return;const i=s.deltaContent.length>0,l=s.thinkingContent.length>0,u=s.toolOutput.length>0;if(!i&&!l&&!u)return;const h=s.deltaContent,c=s.thinkingContent,d=s.toolOutput;s.deltaContent="",s.thinkingContent="",s.toolOutput=[],e(f=>{var m;const g=f.streamingMessage;if(g&&g.id===s.messageId){let v={...g};if(i&&(v.content=v.content+h),l&&(v.thinkingContent=(v.thinkingContent??"")+c),u){const S=new Set;v.toolCalls=(m=v.toolCalls)==null?void 0:m.map(C=>{const y=d.filter(b=>b.callId===C.id);return y.length===0?C:(S.add(C.id),{...C,streamingOutput:[...C.streamingOutput??[],...y.map(b=>({stream:b.stream,content:b.content,timestamp:Date.now()}))]})});const k=d.filter(C=>!S.has(C.callId));k.length>0&&Vt.toolOutput.push(...k)}return{streamingMessage:v}}if(u){const v=new Set,S=f.messages.map(C=>{var b;if(C.id!==s.messageId)return C;const y=(b=C.toolCalls)==null?void 0:b.map(x=>{const _=d.filter(j=>j.callId===x.id);return _.length===0?x:(v.add(x.id),{...x,streamingOutput:[...x.streamingOutput??[],..._.map(j=>({stream:j.stream,content:j.content,timestamp:Date.now()}))]})});return{...C,toolCalls:y}}),k=d.filter(C=>!v.has(C.callId));return k.length>0&&Vt.toolOutput.push(...k),{messages:S}}return f})},{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmation:null,pendingQuestion:null,visionFallbackByMessage:{},queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(r().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let i=!1;try{i=(await(await ke("/api/auth")).json()).requiresAuth}catch{}if(i&&!Gt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Gt.onStatusChange(l=>{var u;if(e({connectionStatus:l}),l==="connected"){r().listSessions(void 0),Ft.getState().listProjects();const h=(u=r().currentSession)==null?void 0:u.id;h&&r().loadSession(h)}});try{if(await Gt.connect(),!qa){qa=!0;const l=r().handleServerMessage;pr=Gt.subscribe(l)}}catch(l){console.error("Failed to connect:",l);const u=Gt.getLastCloseCode();if(!Gt.hasToken()&&(u===1006||u===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}pr&&(pr(),pr=null),qa=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Gt.disconnect(),pr&&(pr(),pr=null),qa=!1,e({connectionStatus:"disconnected"}),r().connect()},disconnect:()=>{Gt.disconnect(),pr&&(pr(),pr=null),qa=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async s=>{try{const i=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:s})});if(!i.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:l}=await i.json();Gt.setToken(l),e({showPasswordModal:!1}),r().connect();const{listProjects:u}=Ft.getState(),{fetchConfig:h}=Rt.getState();u(),h(),r().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Gt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(s,i)=>{if(r().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const u=await ke("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:s,title:i})});if(!u.ok)return e({pendingSessionCreate:!1}),null;const h=await u.json();return Gt.send("session.load",{sessionId:h.session.id}),h.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async s=>{try{const i=r().currentSession;!i||i.id!==s?(Is(),e({currentSession:null,unreadSessionIds:Wa(r().unreadSessionIds,s),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmation:null,queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1})):e({unreadSessionIds:Wa(r().unreadSessionIds,s)});const l=await ke(`/api/sessions/${s}`);if(!l.ok)return;const u=await l.json();e({currentSession:u.session,messages:u.messages??[],contextState:u.contextState,queuedMessages:u.queueState??[]}),Gt.send("session.load",{sessionId:s});try{const h=await ke(`/api/sessions/${s}/background-processes`);if(h.ok){const c=await h.json();no.getState().setProcesses(c.processes??[])}}catch{}}catch{}},listSessions:async(s,i=20)=>{try{const l=new URLSearchParams;l.set("limit",String(i)),s&&l.set("projectId",s);const h=await(await ke(`/api/sessions?${l.toString()}`)).json(),c=h.sessions??[];e(d=>({sessions:Zx(c,d.sessions,d.currentSession),sessionsHasMore:s?h.hasMore??!1:!0}))}catch{}},loadMoreSessions:async s=>{const i=r();if(!(i.sessionsPaginationLoading||!i.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const l=new URLSearchParams;l.set("limit","20"),l.set("offset",String(i.sessions.length)),l.set("projectId",s);const h=await(await ke(`/api/sessions?${l.toString()}`)).json(),c=h.sessions??[];e(d=>({sessions:[...d.sessions,...c.map(f=>{const g=d.sessions.find(m=>m.id===f.id);return(g==null?void 0:g.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:h.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async s=>{var i;try{return(await ke(`/api/sessions/${s}`,{method:"DELETE"})).ok?(await r().listSessions(),((i=r().currentSession)==null?void 0:i.id)===s&&r().clearSession(),!0):!1}catch{return!1}},renameSession:async(s,i)=>{var l;try{const u=await ke(`/api/sessions/${s}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:i})});if(!u.ok)return!1;if(await r().listSessions(),((l=r().currentSession)==null?void 0:l.id)===s){const c=await u.json();c.session&&e({currentSession:c.session})}return!0}catch{return!1}},deleteAllSessions:async s=>{try{return(await ke(`/api/projects/${s}/sessions`,{method:"DELETE"})).ok?(await r().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Is(),e(s=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:s.currentSession?Wa(s.unreadSessionIds,s.currentSession.id):s.unreadSessionIds}))},sendMessage:async(s,i,l)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u){e({streamingMessageId:null});try{const d=await(await ke(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s,attachments:i,messageKind:l==null?void 0:l.messageKind})})).json();d.queueState&&e({queuedMessages:d.queueState})}catch(c){console.error("Error sending message:",c)}}},stopGeneration:async()=>{var i;const s=(i=r().currentSession)==null?void 0:i.id;if(s&&!r().abortInProgress){Is(),pn==null||pn(),e({abortInProgress:!0});try{await ke(`/api/sessions/${s}/stop`,{method:"POST"})}catch(l){console.error("Error stopping generation:",l)}}},continueGeneration:async()=>{var i;const s=(i=r().currentSession)==null?void 0:i.id;if(s){e({streamingMessageId:null});try{await ke(`/api/sessions/${s}/continue`,{method:"POST"})}catch(l){console.error("Error continuing generation:",l)}}},launchRunner:(s,i,l)=>{e({streamingMessageId:null});const u={};s!=null&&s.trim()&&(u.content=s),i&&i.length>0&&(u.attachments=i),l&&(u.workflowId=l),Gt.send("runner.launch",u)},switchMode:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const u=await ke(`/api/sessions/${i}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:s})});if(!u.ok){console.error("Failed to switch mode:",await u.json());return}const h=await u.json();h.session&&e({currentSession:h.session})}catch(u){console.error("Error switching mode:",u)}},switchDangerLevel:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const u=await ke(`/api/sessions/${i}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:s})});if(!u.ok){console.error("Failed to switch danger level:",await u.json());return}const h=await u.json();h.session&&e({currentSession:h.session})}catch(u){console.error("Error switching danger level:",u)}},acceptAndBuild:(s,i,l)=>{var c;e({streamingMessageId:null});const u={};s&&(u.workflowId=s),i!=null&&i.trim()&&(u.content=i),l&&l.length>0&&(u.attachments=l);const h=(c=r().currentSession)==null?void 0:c.id;h&&ke(`/api/sessions/${h}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{Gt.send("runner.launch",u)})},editCriteria:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const u=await ke(`/api/sessions/${i}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:s})});u.ok||console.error("Failed to update criteria:",await u.json())}catch(u){console.error("Error updating criteria:",u)}},compactContext:()=>{Gt.send("context.compact",{})},setSessionProvider:async(s,i)=>{var l;try{const u=(l=r().currentSession)==null?void 0:l.id;if(!u)return null;const h=await ke(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:s,...i?{model:i}:{}})});if(!h.ok)return null;const c=await h.json();return e({currentSession:c.session,messages:c.messages??[],contextState:c.contextState}),c.session}catch{return null}},updateContextState:s=>{e({contextState:s})},updateSubAgentContextState:(s,i)=>{e(l=>({subAgentContextStates:{...l.subAgentContextStates,[s]:i}}))},clearSubAgentContextState:s=>{e(i=>{const l={...i.subAgentContextStates};return delete l[s],{subAgentContextStates:l}})},confirmPath:async(s,i,l=!1)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u)try{await ke(`/api/sessions/${u}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:s,approved:i,alwaysAllow:l})})}catch(c){console.error("Error confirming path:",c)}},answerQuestion:async(s,i)=>{var u;const l=(u=r().currentSession)==null?void 0:u.id;if(l){try{await ke(`/api/sessions/${l}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:s,answer:i})})}catch(h){console.error("Error answering question:",h)}e({pendingQuestion:null})}},queueAsap:async(s,i,l)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u)try{const d=await(await ke(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s,attachments:i,messageKind:l})})).json();d.queueState&&e({queuedMessages:d.queueState})}catch(c){console.error("Error queueing ASAP message:",c)}},queueCompletion:async(s,i,l)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u)try{const d=await(await ke(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s,attachments:i,messageKind:l})})).json();d.queueState&&e({queuedMessages:d.queueState})}catch(c){console.error("Error queueing completion message:",c)}},cancelQueued:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const h=await(await ke(`/api/sessions/${i}/queue/${s}`,{method:"DELETE"})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(u){console.error("Error canceling queued message:",u)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:s=>{var h,c,d,f,g,m,v,S,k,C,y,b,x,_,j,T,N,D,A,z,O,q,G,W;const i=r();fw(s,i);const l=((h=i.currentSession)==null?void 0:h.id)??null,u=()=>{const M=s.sessionId;!M||M===l||e($=>({unreadSessionIds:dw($.unreadSessionIds,M)}))};switch(s.type){case"session.state":{const M=s.payload;if(!uw(s,l,i.pendingSessionCreate))break;Is();const $=M.messages.find(R=>R.isStreaming)??null,B=r().pendingSessionCreate===!0,X=M.pendingConfirmations??[],H=i.pendingPathConfirmation??(X.length>0?X[0]??null:null);if(e({currentSession:M.session,sessions:hw(r().sessions,M.session),unreadSessionIds:Wa(r().unreadSessionIds,M.session.id),messages:M.messages,streamingMessageId:($==null?void 0:$.id)??null,streamingMessage:$,currentTodos:[],pendingPathConfirmation:H,error:null,...B?{pendingSessionCreate:M.session.id}:{}}),M.session.providerId&&M.session.providerModel){const R=Rt.getState();R.providers.find(F=>F.id===M.session.providerId)&&R.syncFromSession(M.session.providerId,M.session.providerModel)}break}case"session.list":{const M=s.payload;e($=>({sessions:Zx(M.sessions,$.sessions,$.currentSession)}));break}case"session.deleted":{const M=s.payload;e($=>({unreadSessionIds:Wa($.unreadSessionIds,M.sessionId)})),r().listSessions();break}case"session.deletedAll":{r().listSessions();break}case"session.running":{const M=s.payload,$=s.sessionId,B=(c=r().currentSession)==null?void 0:c.id,X=$&&$!==B;e(Q=>({sessions:Q.sessions.map(H=>H.id===$?{...H,isRunning:M.isRunning}:H)})),X||e(Q=>({currentSession:Q.currentSession?{...Q.currentSession,isRunning:M.isRunning}:null,...M.isRunning?{}:{abortInProgress:!1,queuedMessages:[]}}));break}case"chat.message":{if(!Ht(s,((d=r().currentSession)==null?void 0:d.id)??null)){u();break}const M=s.payload;e($=>$.messages.some(B=>B.id===M.message.id)?$:{messages:[...$.messages,M.message],streamingMessageId:M.message.isStreaming?M.message.id:$.streamingMessageId,streamingMessage:M.message.isStreaming?M.message:$.streamingMessage});break}case"chat.message_updated":{if(!Ht(s,((f=r().currentSession)==null?void 0:f.id)??null)){u();break}const M=s.payload,$=M.updates.isStreaming===!1&&r().streamingMessageId===M.messageId;$&&(Is(),pn==null||pn()),e(B=>{const X=B.streamingMessage,Q=$;if(X&&X.id===M.messageId){const H={...X,...M.updates};return{messages:B.messages.map(R=>R.id===M.messageId?H:R),streamingMessageId:Q?null:B.streamingMessageId,streamingMessage:Q?null:{...X,...M.updates}}}return{messages:B.messages.map(H=>H.id===M.messageId?{...H,...M.updates}:H),streamingMessageId:Q?null:B.streamingMessageId}});break}case"chat.delta":{if(!Ht(s,((g=r().currentSession)==null?void 0:g.id)??null)){u();break}const M=s.payload;if(!Ud.has(M.messageId)){Ud.add(M.messageId);const $=eo(r(),s.sessionId);cw($)}Vt.messageId=M.messageId,Vt.deltaContent+=M.content,$d();break}case"chat.thinking":{if(!Ht(s,((m=r().currentSession)==null?void 0:m.id)??null)){u();break}const M=s.payload;Vt.messageId=M.messageId,Vt.thinkingContent+=M.content,$d();break}case"chat.tool_preparing":{if(!Ht(s,((v=r().currentSession)==null?void 0:v.id)??null)){u();break}const M=s.payload,$=(B,X)=>B?B.some(Q=>Q.name===X):!1;e(B=>{const X=B.streamingMessage;if(X&&X.id===M.messageId){if($(X.toolCalls,M.name))return B;const Q=X.preparingToolCalls??[],H=Q.findIndex(L=>L.index===M.index);let R;return H>=0?R=Q.map((L,F)=>F===H?{...L,arguments:M.arguments}:L):R=[...Q,{index:M.index,name:M.name,...M.arguments?{arguments:M.arguments}:{}}],{streamingMessage:{...X,preparingToolCalls:R}}}return{messages:B.messages.map(Q=>Q.id!==M.messageId||$(Q.toolCalls,M.name)?Q:{...Q,preparingToolCalls:(()=>{const H=Q.preparingToolCalls??[],R=H.findIndex(L=>L.index===M.index);return R>=0?H.map((L,F)=>F===R?{...L,arguments:M.arguments}:L):[...H,{index:M.index,name:M.name,...M.arguments?{arguments:M.arguments}:{}}]})()})}});break}case"chat.tool_call":{if(!Ht(s,((S=r().currentSession)==null?void 0:S.id)??null)){u();break}const M=s.payload,$=B=>{var H;const X=(H=B.preparingToolCalls)==null?void 0:H.filter((R,L)=>{var F;return R.name===M.tool?(F=B.preparingToolCalls)==null?void 0:F.slice(0,L).some(ne=>ne.name===M.tool):!0}),Q=Vt.toolOutput.filter(R=>R.callId===M.callId);return Q.length>0&&(Vt.toolOutput=Vt.toolOutput.filter(R=>R.callId!==M.callId)),{...B,toolCalls:[...B.toolCalls??[],{id:M.callId,name:M.tool,arguments:M.args,startedAt:Date.now(),...Q.length>0?{streamingOutput:Q.map(R=>({stream:R.stream,content:R.content,timestamp:Date.now()}))}:{}}],...X&&X.length>0?{preparingToolCalls:X}:{preparingToolCalls:void 0}}};e(B=>{const X=B.streamingMessage;return X&&X.id===M.messageId?{streamingMessage:$(X)}:{messages:B.messages.map(Q=>Q.id===M.messageId?$(Q):Q)}});break}case"chat.tool_output":{if(!Ht(s,((k=r().currentSession)==null?void 0:k.id)??null)){u();break}const M=s.payload;Vt.messageId=M.messageId,Vt.toolOutput.push({messageId:M.messageId,callId:M.callId,stream:M.stream,content:M.output}),$d();break}case"chat.tool_result":{if(!Ht(s,((C=r().currentSession)==null?void 0:C.id)??null)){u();break}const M=s.payload,$=B=>{var Q;const X=(Q=B.toolCalls)==null?void 0:Q.map(H=>H.id===M.callId?{...H,result:M.result}:H);return{...B,toolCalls:X}};e(B=>{const X=B.streamingMessage;return X&&X.id===M.messageId?{streamingMessage:$(X)}:{messages:B.messages.map(Q=>Q.id===M.messageId?$(Q):Q)}});break}case"chat.vision_fallback":{if(!Ht(s,((y=r().currentSession)==null?void 0:y.id)??null)){u();break}const M=s.payload;e($=>{const B=`${M.messageId}-${M.attachmentId}`,X={...$.visionFallbackByMessage};return X[B]={type:M.type,attachmentId:M.attachmentId,filename:M.filename,description:M.description},{visionFallbackByMessage:X}});break}case"chat.todo":{if(!Ht(s,((b=r().currentSession)==null?void 0:b.id)??null)){u();break}const M=s.payload;e({currentTodos:M.todos});break}case"chat.summary":{if(!Ht(s,((x=r().currentSession)==null?void 0:x.id)??null)){u();break}const M=s.payload;e($=>({currentSession:$.currentSession?{...$.currentSession,summary:M.summary}:null}));break}case"chat.progress":{if(!Ht(s,((_=r().currentSession)==null?void 0:_.id)??null)){u();break}const M=s.payload;console.log("Progress:",M.message,M.phase);break}case"chat.format_retry":{if(!Ht(s,((j=r().currentSession)==null?void 0:j.id)??null)){u();break}const M=s.payload;console.log("Format retry:",M.attempt,"/",M.maxAttempts);break}case"chat.done":{if(!Ht(s,((T=r().currentSession)==null?void 0:T.id)??null)){u();break}Is(),pn==null||pn();const M=s.payload,$=M.stats;Vt.messageId=null,Vt.deltaContent="",Vt.thinkingContent="",Vt.toolOutput=[],Ud.delete(M.messageId),e(B=>{const X=B.streamingMessage,Q=X&&X.id===M.messageId?{...X,isStreaming:!1,stats:$??X.stats}:null;return{messages:B.messages.map(H=>H.id===M.messageId?Q??{...H,isStreaming:!1,stats:$??H.stats}:H),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Ht(s,((N=r().currentSession)==null?void 0:N.id)??null)){u();break}Is(),pn==null||pn();const M=s.payload;console.error("Chat error:",M.error,"recoverable:",M.recoverable),M.recoverable||(Vt.messageId=null,Vt.deltaContent="",Vt.thinkingContent="",Vt.toolOutput=[]),e($=>({error:{code:"CHAT_ERROR",message:M.error},streamingMessageId:M.recoverable?$.streamingMessageId:null,...M.recoverable?{}:{messages:$.streamingMessage?$.messages.map(B=>B.id===$.streamingMessage.id?$.streamingMessage:B):$.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Ht(s,((D=r().currentSession)==null?void 0:D.id)??null)){u();break}const M=s.payload;e({pendingPathConfirmation:{callId:M.callId,tool:M.tool,paths:M.paths,workdir:M.workdir,reason:M.reason}});break}case"chat.ask_user":{if(!Ht(s,((A=r().currentSession)==null?void 0:A.id)??null)){u();return}const M=s.payload;e({pendingQuestion:{callId:M.callId,question:M.question}});break}case"mode.changed":{if(!Ht(s,((z=r().currentSession)==null?void 0:z.id)??null)){u();break}const M=s.payload;e($=>({currentSession:$.currentSession?{...$.currentSession,mode:M.mode}:null}));break}case"phase.changed":{const M=s.payload,$=s.sessionId,B=(O=r().currentSession)==null?void 0:O.id,X=$&&$!==B;e(Q=>({sessions:Q.sessions.map(H=>H.id===$?{...H,phase:M.phase}:H)})),X||e(Q=>({currentSession:Q.currentSession?{...Q.currentSession,phase:M.phase}:null}));break}case"criteria.updated":{if(!Ht(s,((q=r().currentSession)==null?void 0:q.id)??null)){u();break}const M=s.payload;e($=>({currentSession:$.currentSession?{...$.currentSession,criteria:M.criteria}:null}));break}case"context.state":{const M=s.payload,$=Ht(s,((G=r().currentSession)==null?void 0:G.id)??null);M.subAgentId?$&&r().updateSubAgentContextState(M.subAgentId,M.context):$?e({contextState:M.context}):u();break}case"session.name_generated":{const M=s.payload,$=s.sessionId,B=(W=r().currentSession)==null?void 0:W.id;e(X=>{const Q=X.sessions.map(R=>R.id===$?{...R,title:M.name,updatedAt:new Date().toISOString()}:R),H=B===$?X.currentSession?{...X.currentSession,title:M.name,updatedAt:new Date().toISOString()}:null:X.currentSession;return{sessions:Q,currentSession:H}});break}case"queue.state":{const M=s.payload;e({queuedMessages:M.messages??[]});break}case"devServer.output":case"devServer.state":{gr.getState().handleMessage(s);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{no.getState().handleMessage(s.type,s.payload);break}case"error":{const M=s.payload;console.error("Server error:",M),e({error:{code:M.code,message:M.message},streamingMessageId:null});break}}}}));function Wv(){return we(e=>{var r;return((r=e.currentSession)==null?void 0:r.isRunning)??!1})}function pw(){return we(e=>e.queuedMessages)}function mw(){return we(e=>e.abortInProgress)}function gw(){const e=we(i=>i.connect),r=we(i=>i.connectionStatus),s=Fs(i=>i.load);return P.useEffect(()=>{e()},[e]),P.useEffect(()=>{r==="connected"&&s()},[r,s]),{connectionStatus:r}}const xw="modulepreload",bw=function(e){return"/"+e},Jx={},mh=function(r,s,i){let l=Promise.resolve();if(s&&s.length>0){let h=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));l=h(s.map(f=>{if(f=bw(f),f in Jx)return;Jx[f]=!0;const g=f.endsWith(".css"),m=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const v=document.createElement("link");if(v.rel=g?"stylesheet":xw,g||(v.as="script"),v.crossOrigin="",v.href=f,d&&v.setAttribute("nonce",d),document.head.appendChild(v),g)return new Promise((S,k)=>{v.addEventListener("load",S),v.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function u(h){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=h,window.dispatchEvent(c),!c.defaultPrevented)throw h}return l.then(h=>{for(const c of h||[])c.status==="rejected"&&u(c.reason);return r().catch(u)})},Vv=[{key:"color-bg-primary",category:"background",label:"Primary Background",defaultValue:"13 17 23"},{key:"color-bg-secondary",category:"background",label:"Secondary Background",defaultValue:"22 27 34"},{key:"color-bg-tertiary",category:"background",label:"Tertiary Background",defaultValue:"33 38 45"},{key:"color-primary",category:"surface",label:"Primary Surface",defaultValue:"10 10 10"},{key:"color-secondary",category:"surface",label:"Secondary Surface",defaultValue:"20 20 20"},{key:"color-text-primary",category:"text",label:"Primary Text",defaultValue:"139 148 158"},{key:"color-text-secondary",category:"text",label:"Secondary Text",defaultValue:"139 148 158"},{key:"color-text-muted",category:"text",label:"Muted Text",defaultValue:"72 79 88"},{key:"color-accent-primary",category:"accent",label:"Primary Accent",defaultValue:"88 166 255"},{key:"color-accent-success",category:"accent",label:"Success Accent",defaultValue:"63 185 80"},{key:"color-accent-warning",category:"accent",label:"Warning Accent",defaultValue:"210 153 34"},{key:"color-accent-error",category:"accent",label:"Error Accent",defaultValue:"248 81 73"},{key:"color-border",category:"border",label:"Border",defaultValue:"48 53 60"}],xr=[{id:"dark",name:"Dark",tokens:{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60"}},{id:"light",name:"Light",tokens:{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225"}},{id:"monokai",name:"Monokai",tokens:{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62"}},{id:"dracula",name:"Dracula",tokens:{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90"}},{id:"nord",name:"Nord",tokens:{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"76 86 106","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"76 86 106"}}];function eb(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const rn=$n((e,r)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:eb(),applySavedTheme:()=>{const{getSavedTheme:s,applyPreset:i,applyTokens:l}=r(),u=s();if(u)try{const h=JSON.parse(u);h.preset&&h.tokens?(i(h.preset),e({basePreset:h.preset}),l(h.tokens)):h.preset?i(h.preset):h.tokens&&l(h.tokens)}catch{i("dark")}else i("dark")},applyPreset:s=>{xr.find(l=>l.id===s)&&(e({currentPreset:s,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1}),r().applyTheme())},startCustomizing:()=>{var l;const{currentPreset:s}=r(),i=((l=xr.find(u=>u.id===s))==null?void 0:l.tokens)??{};e({basePreset:s,customTokens:{...i},isCustom:!0,isCustomizing:!0})},setCustomToken:(s,i)=>{e(l=>({customTokens:{...l.customTokens,[s]:i}})),r().applyTheme()},cancelCustomizing:()=>{r().applyPreset(r().basePreset||r().currentPreset)},saveCustomTheme:()=>{const{customTokens:s}=r();r().saveTheme(JSON.stringify({tokens:s})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:s=>{e({customTokens:s,isCustom:!0,isCustomizing:!1}),r().applyTheme()},getActiveTheme:()=>{var h,c;const{basePreset:s,customTokens:i,isCustom:l}=r();if(l&&s)return{...((h=xr.find(f=>f.id===s))==null?void 0:h.tokens)??{},...i};if(l)return{...Vv.reduce((d,f)=>({...d,[f.key]:f.defaultValue}),{}),...i};const u=xr.find(d=>d.id===r().currentPreset);return(u==null?void 0:u.tokens)??((c=xr[0])==null?void 0:c.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const s=r().getActiveTheme(),i=document.documentElement;Object.entries(s).forEach(([l,u])=>{i.style.setProperty(`--${l}`,u)})},getSavedTheme:()=>{try{const s=localStorage.getItem("openfox:theme");if(!s)return null;if(s[0]!=="{")return JSON.stringify({preset:s});const i=JSON.parse(s);if(i.preset)return JSON.stringify({preset:i.preset});if(i.tokens)return JSON.stringify({tokens:i.tokens})}catch{return null}return null},saveTheme:async s=>{localStorage.setItem("openfox:theme",s);const{useSettingsStore:i}=await mh(async()=>{const{useSettingsStore:l}=await Promise.resolve().then(()=>Bx);return{useSettingsStore:l}},void 0);await i.getState().setSetting(ot.DISPLAY_THEME,s)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[]})},addUserPreset:s=>{const{basePreset:i,customTokens:l,currentPreset:u}=r(),h={id:"custom-"+Date.now(),name:s,basePreset:i||u,tokens:{...l}},c=[...r().userPresets,h];e({userPresets:c}),r().saveUserPresets()},applyUserPreset:s=>{const i=r().userPresets[s];i&&(e({currentPreset:i.basePreset,basePreset:i.basePreset,customTokens:{...i.tokens},isCustom:!0,isCustomizing:!1}),r().applyTheme(),r().saveTheme(JSON.stringify({preset:i.basePreset,tokens:i.tokens})).catch(()=>{}))},deleteUserPreset:s=>{const i=r().userPresets.filter((l,u)=>u!==s);e({userPresets:i}),r().saveUserPresets()},loadUserPresets:()=>{e({userPresets:eb()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(r().userPresets)),mh(async()=>{const{useSettingsStore:s}=await Promise.resolve().then(()=>Bx);return{useSettingsStore:s}},void 0).then(({useSettingsStore:s})=>{s.getState().setSetting(ot.DISPLAY_USER_PRESETS,JSON.stringify(r().userPresets)).catch(()=>{})})}}));function vw({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Gv({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function yw({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function _w({className:e="w-3 h-3 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function Sw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function Ur({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function br({className:e="w-3 h-3 text-text-muted",rotate:r}){return o.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:r!==void 0?{transform:`rotate(${r}deg)`}:void 0,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function ww({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function zh({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function Cw({className:e="w-3 h-3"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function Ph({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"}),o.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function lc({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function Hh({className:e="w-5 h-5 text-accent-primary"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function kw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})})}function Ew({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function jw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function Nw({className:e="w-3 h-3"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Tw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function tb({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function Kv({className:e="w-[18px] h-[18px]"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Aw({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),o.jsx("path",{d:"M9.5 2h4.5v4.5"}),o.jsx("path",{d:"M14 2L7.5 8.5"})]})}function Dw({className:e="w-3 h-3",color:r}){return o.jsx("svg",{className:e,fill:r??"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M8 5v14l11-7z"})})}function qi({className:e="w-3 h-3 text-accent-primary"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Rw({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function Lw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function Ow({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function Mw({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return o.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[o.jsx("title",{children:"Running"}),o.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Yv({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function Iw({className:e="w-3.5 h-3.5 shrink-0",color:r}){return o.jsx("svg",{className:e,fill:"none",stroke:r,viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Bw({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function cc({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function Fh(){return o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function zw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Xv({className:e="w-2.5 h-2.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Uh({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function Pw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function gh(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}function nb(e,r){const s=Gt.ws;!s||s.readyState!==WebSocket.OPEN||s.send(JSON.stringify({id:gh(),type:e,payload:r}))}const ir=$n((e,r)=>({isOpen:!1,sessions:[],workdir:null,setOpen:s=>e({isOpen:s}),toggleOpen:()=>e(s=>({isOpen:!s.isOpen})),setWorkdir:s=>e({workdir:s}),fetchSessions:async s=>{if(!s){e({sessions:[]});return}try{const i=await ke(`/api/terminals?projectId=${encodeURIComponent(s)}`);if(i.ok){const l=await i.json();e({sessions:l});const u=Gt.ws;if(u&&u.readyState===WebSocket.OPEN)for(const h of l)u.send(JSON.stringify({id:gh(),type:"terminal.subscribe",payload:{sessionId:h.id}}))}}catch(i){console.error("Failed to fetch terminals:",i)}},createSession:async(s,i)=>{try{const l=await ke("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:s??r().workdir??void 0,projectId:i})});if(l.ok){const u=await l.json();e(c=>({sessions:[...c.sessions,u]}));const h=Gt.ws;h&&h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({id:gh(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(l){console.error("Failed to create terminal:",l)}},writeSession:(s,i)=>{nb("terminal.write",{sessionId:s,data:i})},resizeSession:(s,i,l)=>{nb("terminal.resize",{sessionId:s,cols:i,rows:l})},killSession:async s=>{try{(await ke(`/api/terminals/${s}`,{method:"DELETE"})).ok&&e(l=>({sessions:l.sessions.filter(u=>u.id!==s)}))}catch(i){console.error("Failed to kill terminal:",i)}},handleMessage:s=>{switch(s.type){case"terminal.exit":{const{sessionId:i}=s.payload||{};i&&e(l=>{const u=l.sessions.filter(h=>h.id!==i);return u.length===0&&l.isOpen?{sessions:[],isOpen:!1}:{sessions:u}});break}}}}));Gt.subscribe(e=>{var r;(r=e.type)!=null&&r.startsWith("terminal.")&&ir.getState().handleMessage(e)});var Ki=Tv();const uc=P.forwardRef(({icon:e,iconSize:r="w-3.5 h-3.5",className:s="",...i},l)=>o.jsx("button",{ref:l,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${s}`,...i,children:o.jsx("svg",{className:r,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));uc.displayName="IconButton";const Hw="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",Wi=P.forwardRef((e,r)=>o.jsx(uc,{ref:r,icon:Hw,title:"Edit",...e}));Wi.displayName="EditButton";const Fw="M6 18L18 6M6 6l12 12",$h=P.forwardRef((e,r)=>o.jsx(uc,{ref:r,icon:Fw,...e}));$h.displayName="CloseButton";const Uw={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[90vh] flex-1"};function At({label:e,title:r,size:s="md",minHeight:i,children:l,footer:u,className:h,onClose:c,isOpen:d,closeOnBackdropClick:f=!0,closeOnEscape:g=!0,showCloseButton:m=!0}){const[v,S]=P.useState(!1),k=d!==void 0,C=k?d:v,y=P.useCallback(()=>{k||S(!0)},[k]),b=P.useCallback(()=>{k||S(!1),c==null||c()},[k,c]);P.useEffect(()=>{if(!C||!g)return;const _=j=>{j.key==="Escape"&&b()};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[C,b,g]);const x=e&&(typeof e=="string"?o.jsx("button",{type:"button",onClick:y,className:h,children:e}):o.jsx("span",{onClick:y,className:h,style:{cursor:"pointer"},children:e}));return o.jsxs(o.Fragment,{children:[x,C&&(typeof document<"u"?Ki.createPortal(o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:f?b:void 0}),o.jsxs("div",{className:`relative w-full ${Uw[s]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(r||m)&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r&&o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:r}),m&&o.jsx($h,{onClick:b,className:"ml-auto","aria-label":"Close"})]}),o.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:i?{minHeight:i}:void 0,children:l}),u&&o.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}const nt=P.forwardRef(({variant:e="secondary",size:r="md",className:s="",children:i,...l},u)=>{const h="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},d={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return o.jsx("button",{ref:u,className:`${h} ${c[e]} ${d[r]} ${s}`,...l,children:i})});nt.displayName="Button";function $w({value:e,defaultUrl:r,disabled:s,onChange:i}){const l=e??r;return o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:l,disabled:s,onChange:u=>{const h=u.target.value;i(h===r?null:h)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:ew.map(({url:u,label:h})=>o.jsx("option",{value:u,title:h,children:h.split(" ")[0]},u))}),o.jsx(br,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const rb=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function qw(){const e=Fs(d=>d.settings),r=Fs(d=>d.update),s=Fs(d=>d.updateEvent),i=Fs(d=>d.updateAgentOverride),l=Fs(d=>d.load);P.useEffect(()=>{l()},[l]);const u=async()=>{await nw()==="granted"&&r({...e,browserNotificationEnabled:!0})},h=(d,f,g,m)=>{d==="general"?s(f,{[g]:m}):i(d,f,{[g]:m})},c=(d,f,g)=>{d==="general"?s(f,{customSoundUrl:g}):i(d,f,{customSoundUrl:g})};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),o.jsx(sb,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>r({...e,soundEnabled:d})}),o.jsx(sb,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:d=>{d&&typeof Notification<"u"&&Notification.permission!=="granted"?u():r({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&o.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),o.jsx("div",{className:"border border-border rounded overflow-hidden",children:o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:o.jsxs("tr",{className:"border-b border-border",children:[o.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),rb.map(d=>o.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),o.jsx("tbody",{children:J1.map(d=>o.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[o.jsx("td",{className:"px-3 py-2",children:o.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),rb.map(f=>{const g=$v(e,d.key,f.key==="general"?void 0:f.key),m=Fv[d.key];return o.jsx("td",{className:"px-2 py-2 align-top",children:o.jsxs("div",{className:"flex flex-col items-center gap-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:o.jsx("input",{type:"checkbox",checked:g.soundEnabled,onChange:v=>h(f.key,d.key,"soundEnabled",v.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),o.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:o.jsx("input",{type:"checkbox",checked:g.browserNotification,onChange:v=>h(f.key,d.key,"browserNotification",v.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),g.soundEnabled&&e.soundEnabled&&o.jsx($w,{value:g.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:v=>c(f.key,d.key,v)})]})},f.key)})]},d.key))})]})})]})]})}function sb({label:e,description:r,checked:s,onChange:i}){return o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[o.jsx("div",{className:"pt-0.5",children:o.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${s?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:l=>{l.preventDefault(),i(!s)},children:o.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${s?"translate-x-4":"translate-x-0.5"}`})})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),o.jsx("div",{className:"text-xs text-text-muted",children:r})]})]})}async function qh(e,r){r({loading:!0});try{const i=await(await ke(e)).json();r({defaults:i.defaults??[],userItems:i.userItems??[],loading:!1})}catch{r({loading:!1})}}const Pr=$n((e,r)=>({defaults:[],userItems:[],loading:!1,fetchSkills:async()=>{await qh("/api/skills",e)},toggleSkill:async s=>{try{const l=await(await ke(`/api/skills/${s}/toggle`,{method:"POST"})).json();e(u=>({defaults:u.defaults.map(h=>h.id===s?{...h,enabled:l.enabled}:h),userItems:u.userItems.map(h=>h.id===s?{...h,enabled:l.enabled}:h)}))}catch{}},fetchSkill:async s=>{try{const i=await ke(`/api/skills/${s}`);return i.ok?await i.json():null}catch{return null}},fetchDefaultContent:async s=>{try{const i=await ke(`/api/skills/defaults/${s}`);return i.ok?await i.json():null}catch{return null}},createSkill:async s=>{const i=await xs("POST","/api/skills",s);return i.success&&await r().fetchSkills(),i},updateSkill:async(s,i)=>{const l=await xs("PUT",`/api/skills/${s}`,i);return l.success&&await r().fetchSkills(),l},deleteSkill:async s=>{try{const i=await ke(`/api/skills/${s}`,{method:"DELETE"}),l=await i.json();return i.ok?(e(u=>({userItems:u.userItems.filter(h=>h.id!==s)})),{success:!0}):{success:!1,error:l.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async s=>{try{const i=await ke(`/api/skills/${s}/duplicate`,{method:"POST"}),l=await i.json();return i.ok?(await r().fetchSkills(),{success:!0}):{success:!1,error:l.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}}}));function Wh(){const[e,r]=P.useState({id:null,type:null}),s=P.useCallback(u=>r({id:u,type:"delete"}),[]),i=P.useCallback(()=>r({id:null,type:null}),[]),l=P.useCallback((u,h)=>e.id===u&&e.type===h,[e.id,e.type]);return{requestDelete:s,clearConfirm:i,isConfirming:l}}function Vh({onConfirm:e,onCancel:r}){return o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),o.jsx("button",{onClick:r,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function Gh({onClick:e}){return o.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:o.jsx(cc,{})})}function oo({onClick:e}){return o.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:o.jsx(zh,{})})}function Us({label:e,value:r,onChange:s,placeholder:i,readOnly:l,hint:u,mono:h}){return o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,u&&o.jsx("span",{className:"text-text-muted ml-1",children:u})]}),o.jsx("input",{value:r,onChange:c=>s(c.target.value),readOnly:l,placeholder:i,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"font-mono":""} ${l?"opacity-60":""}`})]})}function Ww({onCancel:e,onSave:r,saving:s,saveDisabled:i}){return o.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[o.jsx(nt,{variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(nt,{variant:"primary",onClick:r,disabled:s||i,children:s?"Saving...":"Save"})]})}function Kh({message:e}){return o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function Zv({label:e="Custom",children:r}){return o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),o.jsx("div",{className:"space-y-2",children:r})]})}function Qv({description:e,onNew:r,newLabel:s="+ New"}){return o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:e}),o.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:o.jsx(nt,{variant:"primary",size:"sm",onClick:r,children:s})})]})}function Jv({isBuiltIn:e,isConfirmingDelete:r,onView:s,onEdit:i,onDuplicate:l,onDelete:u,children:h}){return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsx("div",{className:"min-w-0 flex-1 mr-3",children:h}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&s&&o.jsx("button",{onClick:s,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:o.jsx(lc,{})}),o.jsx(oo,{onClick:l}),!e&&i&&o.jsx(Wi,{onClick:i}),!e&&(r?o.jsx(Vh,{onConfirm:()=>{u==null||u()},onCancel:()=>{}}):o.jsx(Gh,{onClick:()=>u==null?void 0:u()}))]})]})}function Vw({id:e,name:r,description:s,isBuiltIn:i,isConfirmingDelete:l,onView:u,onEdit:h,onDuplicate:c,onDelete:d}){return o.jsxs(Jv,{isBuiltIn:i,isConfirmingDelete:l,onView:u,onEdit:h,onDuplicate:c,onDelete:d,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:r}),o.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),s&&o.jsx("p",{className:"text-text-muted text-xs truncate",children:s})]})}function ey({loading:e,hasItems:r,loadingLabel:s,emptyLabel:i,children:l}){return e&&!r?o.jsx("div",{className:"text-text-muted text-sm",children:s}):r?o.jsx("div",{className:"space-y-4",children:l}):i?o.jsx("div",{className:"text-text-muted text-sm",children:i}):null}function ty({name:e,id:r,nameLabel:s="Name",idLabel:i="ID",namePlaceholder:l="My Item",idPlaceholder:u="my-item",nameHint:h,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:f,onIdChange:g}){return o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(Us,{label:s,value:e,onChange:f,placeholder:l,hint:h}),o.jsx(Us,{label:i,value:r,onChange:g,readOnly:c,placeholder:u,hint:c?d:void 0,mono:!0})]})}function ny(e={}){const{initialData:r={}}=e,[s,i]=P.useState("list"),[l,u]=P.useState(null),[h,c]=P.useState(""),[d,f]=P.useState(!1),[g,m]=P.useState(r),v=P.useCallback(()=>{m(r),c(""),u(null)},[r]),S=P.useCallback(b=>{i(b),b==="list"&&v()},[v]),k=P.useCallback(b=>{m(x=>typeof b=="function"?b(x):b)},[]),C=P.useCallback((b,x={})=>{u(b),i("edit"),m({...x}),c("")},[]),y=P.useCallback(()=>{u(null),i("edit"),m(r),c("")},[r]);return{view:s,editingId:l,formError:h,saving:d,formData:g,setView:S,setEditingId:u,setFormError:c,setFormData:k,setSaving:f,resetForm:v,startEditing:C,startNew:y}}function Yh(){return o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 mt-3 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[o.jsx("span",{children:"⚠️"}),o.jsx("p",{className:"text-text-secondary",children:"Editing this value now will have the side-effect of invalidating KV-cache, causing your next message in current sessions to take a long time to process. Consider doing this between sessions."})]})}function ib({skill:e,isBuiltIn:r,isConfirmingDelete:s,onView:i,onEdit:l,onDuplicate:u,onDelete:h}){return o.jsx(Vw,{id:e.id,name:e.name,description:e.description,isBuiltIn:r,isConfirmingDelete:s,onView:i,onEdit:l,onDuplicate:u,onDelete:h})}function Gw({isOpen:e}){const r=Pr(M=>M.defaults),s=Pr(M=>M.userItems),i=Pr(M=>M.loading),l=Pr(M=>M.fetchSkills),u=Pr(M=>M.fetchSkill),h=Pr(M=>M.fetchDefaultContent),c=Pr(M=>M.createSkill),d=Pr(M=>M.updateSkill),f=Pr(M=>M.deleteSkill),{view:g,editingId:m,formError:v,saving:S,formData:k,setView:C,setEditingId:y,setFormError:b,setFormData:x,setSaving:_}=ny(),{clearConfirm:j}=Wh();P.useEffect(()=>{e&&(l(),C("list"),y(null),j())},[e,l,j]);const T=(M,$,B,X)=>{x({name:X??M.metadata.name,id:B??M.metadata.id,description:M.metadata.description??"",version:M.metadata.version??"1.0.0",prompt:M.prompt,isReadOnly:$})},N=async M=>{if(r.some(B=>B.id===M)){const B=await h(M);if(!B)return;T(B,!0),y(M),b(""),C("edit")}else{const B=await u(M);if(!B)return;T(B,!0),y(M),b(""),C("edit")}},D=async M=>{const B=r.some(Q=>Q.id===M)?await h(M):await u(M);if(!B)return;const X=`${M}-copy-${Date.now()}`;T(B,!1,X,`${B.metadata.name} (copy)`),y(null),b(""),C("edit")},A=()=>{x({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1}),C("edit")},z=async M=>{const $=await u(M);$&&(T($,!1),y(M),b(""),C("edit"))},O=async M=>{await f(M),j()},q=async()=>{const M=m??k.id;if(!M||!k.name||!k.prompt){b("Name, ID, and prompt are required.");return}_(!0),b("");const $={metadata:{id:M,name:k.name,description:k.description,version:k.version},prompt:k.prompt},B=m?await d(m,$):await c($);if(_(!1),!B.success){b(B.error??"Failed to save skill.");return}C("list")},G=M=>{x($=>({...$,name:M})),m||x($=>({...$,id:M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},W=k.isReadOnly;return g==="edit"?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex justify-between items-center mb-3",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:W?k.name:m?"Edit Skill":"New Skill"}),o.jsx("button",{onClick:()=>C("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),v&&o.jsx(Kh,{message:v}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(ty,{name:k.name,id:k.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:G,onIdChange:()=>{}}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(Us,{label:"Description",value:k.description,onChange:M=>x($=>({...$,description:M})),placeholder:"What this skill does...",readOnly:W}),o.jsx(Us,{label:"Version",value:k.version,onChange:M=>x($=>({...$,version:M})),placeholder:"1.0.0",readOnly:W})]})]}),o.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),o.jsx("textarea",{value:k.prompt,onChange:M=>x($=>({...$,prompt:M.target.value})),readOnly:W,placeholder:"The system prompt for this skill...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsx(Yh,{}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[o.jsx(nt,{variant:"secondary",onClick:()=>C("list"),children:"Cancel"}),W?o.jsx(nt,{variant:"primary",onClick:()=>{x(M=>({...M,name:M.name+" (copy)",id:`${m}-copy-${Date.now()}`,isReadOnly:!1})),y(null)},children:"Duplicate & Customize"}):o.jsx(nt,{variant:"primary",onClick:q,disabled:S||!k.name||!k.id||!k.prompt,children:S?"Saving...":"Save"})]})]}):o.jsxs("div",{children:[o.jsx(Qv,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:A}),o.jsxs(ey,{loading:i,hasItems:r.length>0||s.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[r.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),o.jsx("div",{className:"space-y-2",children:r.map(M=>o.jsx(ib,{skill:M,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>N(M.id),onDuplicate:()=>D(M.id)},M.id))})]}),s.length>0&&o.jsx(Zv,{children:s.map(M=>o.jsx(ib,{skill:M,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>N(M.id),onEdit:()=>z(M.id),onDuplicate:()=>D(M.id),onDelete:()=>O(M.id)},M.id))})]})]})}function Kw(e){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r){const s=parseInt(r[1]??"0",16),i=parseInt(r[2]??"0",16),l=parseInt(r[3]??"0",16);return`${s} ${i} ${l}`}return e}function Hs(e){const r=e.split(" ").map(s=>parseInt(s,10));return r.length===3&&r.every(s=>!isNaN(s))?`#${r.map(s=>(s??0).toString(16).padStart(2,"0")).join("")}`:e}function Yw({isOpen:e,isNew:r,basePresetId:s,presetName:i,initialTokens:l,onClose:u,onSave:h}){const[c,d]=P.useState(l),[f,g]=P.useState(i);P.useEffect(()=>{d(l),g(i)},[l,i]);const m=(y,b)=>{const x=b.startsWith("#")?Kw(b):b;d(_=>({..._,[y]:x}))},v=()=>{h(f.trim()||"Untitled",{...c})},S=Vv.reduce((y,b)=>{const x=b.category;return y[x]||(y[x]=[]),y[x].push(b),y},{}),k={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},C=xr.find(y=>y.id===s);return o.jsx(At,{isOpen:e,onClose:u,size:"lg",title:r?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:o.jsxs("div",{className:"flex gap-2 justify-end",children:[o.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),o.jsx("button",{type:"button",onClick:v,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),o.jsx("input",{type:"text",value:f,onChange:y=>g(y.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!r&&o.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",o.jsx("span",{className:"text-text-primary",children:C==null?void 0:C.name})]}),Object.entries(S).map(([y,b])=>o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:k[y]??y}),o.jsx("div",{className:"grid grid-cols-2 gap-3",children:b.map(x=>o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("label",{htmlFor:x.key,className:"text-xs text-text-muted",children:x.label}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"color",id:x.key,value:Hs(c[x.key]??x.defaultValue),onChange:_=>m(x.key,_.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent"}),o.jsx("input",{type:"text",value:c[x.key]??x.defaultValue,onChange:_=>m(x.key,_.target.value),className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},x.key))})]},y))]})})}function Xw(){const[e,r]=P.useState(null),s=rn(x=>x.currentPreset),i=rn(x=>x.isCustom),l=rn(x=>x.basePreset),u=rn(x=>x.userPresets),h=rn(x=>x.applyPreset),c=rn(x=>x.applyUserPreset),d=rn(x=>x.deleteUserPreset),f=rn(x=>x.saveTheme),g=x=>{h(x),f(JSON.stringify({preset:x})).catch(()=>{})},m=x=>{c(x)},v=x=>{const _=xr.find(j=>j.id===x);_&&r({type:"new",presetIndex:u.length,basePresetId:x,presetName:_.name+" Copy",tokens:{..._.tokens}})},S=x=>{const _=u[x];if(!_)return;const j=xr.find(N=>N.id===_.basePreset),T=j?{...j.tokens,..._.tokens}:_.tokens;r({type:"edit",presetIndex:x,basePresetId:_.basePreset,presetName:_.name,tokens:T})},k=(x,_)=>{if(!e)return;const j=[...u];if(e.type==="new"){const T={id:"custom-"+Date.now(),name:x,basePreset:e.basePresetId,tokens:_};j.push(T);const N=j.length-1;rn.setState({userPresets:j}),rn.getState().saveUserPresets(),rn.getState().applyUserPreset(N)}else{const T=j[e.presetIndex];T&&(j[e.presetIndex]={...T,name:x,tokens:_}),rn.setState({userPresets:j}),rn.getState().saveUserPresets(),rn.getState().applyUserPreset(e.presetIndex)}r(null)},C=()=>{r(null)},y=(x,_)=>{x.stopPropagation(),d(_)},b=i?l:s;return o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),o.jsx("div",{className:"grid grid-cols-5 gap-2",children:xr.map(x=>o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>g(x.id),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${b===x.id&&!i?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[o.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:Hs(x.tokens["color-bg-primary"]??"#000"),borderColor:Hs(x.tokens["color-border"]??"#000")},children:o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Hs(x.tokens["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs",children:x.name})]}),o.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),v(x.id)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:o.jsx("span",{className:"text-xs",children:"✎"})})]},x.id))}),u.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),o.jsx("div",{className:"grid grid-cols-5 gap-2",children:u.map((x,_)=>{const j=xr.find(N=>N.id===x.basePreset),T=j?{...j.tokens,...x.tokens}:x.tokens;return o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>m(_),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${i&&l===x.basePreset&&b===x.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[o.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:Hs(T["color-bg-primary"]??"#000"),borderColor:Hs(T["color-border"]??"#000")},children:o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Hs(T["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs truncate w-full text-center",children:x.name})]}),o.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S(_)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:o.jsx("span",{className:"text-xs",children:"✎"})}),o.jsx("button",{type:"button",onClick:N=>y(N,_),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:o.jsx(Uh,{className:"w-3 h-3"})})]},x.id)})})]}),e&&o.jsx(Yw,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:C,onSave:k})]})}function ry(){const e=gn(l=>l.settings),r=gn(l=>l.loading),s=gn(l=>l.getSetting),i=gn(l=>l.setSetting);return{settings:e,loading:r,getSetting:s,setSetting:i}}function Zw({isOpen:e,onClose:r}){const[s,i]=P.useState("instructions");return o.jsx(At,{isOpen:e,onClose:r,title:"Settings",size:"xl",minHeight:"500px",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[o.jsx(Va,{label:"Instructions",active:s==="instructions",onClick:()=>i("instructions")}),o.jsx(Va,{label:"Skills",active:s==="skills",onClick:()=>i("skills")}),o.jsx(Va,{label:"Notifications",active:s==="notifications",onClick:()=>i("notifications")}),o.jsx(Va,{label:"Display",active:s==="display",onClick:()=>i("display")}),o.jsx(Va,{label:"Advanced",active:s==="advanced",onClick:()=>i("advanced")})]}),s==="instructions"&&o.jsx(tC,{isOpen:e}),s==="skills"&&o.jsx(Gw,{isOpen:e}),s==="notifications"&&o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(qw,{})}),s==="display"&&o.jsx(eC,{}),s==="advanced"&&o.jsx(Qw,{onClose:r})]})})}function Qw({onClose:e}){const[,r]=lr();function s(){e(),r("/onboarding")}return o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),o.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),o.jsx(nt,{variant:"secondary",onClick:s,children:"Launch Onboarding"})]})})}function Jw(){return o.jsx(Xw,{})}function eC(){const{settings:e,loading:r,getSetting:s,setSetting:i}=ry(),l=r[ot.DISPLAY_SHOW_THINKING]??!1,u=[{key:ot.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:ot.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:ot.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:ot.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:ot.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],h=Object.fromEntries(u.map(g=>[g.key,e[g.key]??"true"])),[c,d]=P.useState(()=>Object.fromEntries(u.map(g=>[g.key,h[g.key]==="true"])));P.useEffect(()=>{u.forEach(g=>s(g.key))},[s]),P.useEffect(()=>{d(Object.fromEntries(u.map(g=>[g.key,h[g.key]==="true"])))},[JSON.stringify(h)]);const f=async g=>{const m=String(!c[g]);d(v=>({...v,[g]:!v[g]})),await i(g,m)};return l?o.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):o.jsxs("div",{className:"space-y-6",children:[o.jsx(Jw,{}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),o.jsx("div",{className:"space-y-4",children:u.map(({key:g,label:m,description:v})=>o.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary",children:m}),o.jsx("div",{className:"text-xs text-text-muted",children:v})]}),o.jsx("button",{type:"button",onClick:()=>f(g),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${c[g]?"bg-accent-primary":"bg-bg-tertiary"}`,children:o.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${c[g]?"translate-x-6":"translate-x-1"}`})})]},g))})]})]})}function Va({label:e,active:r,onClick:s}){return o.jsx("button",{onClick:s,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${r?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function tC({isOpen:e}){const{settings:r,loading:s,getSetting:i,setSetting:l}=ry(),u=r[ot.GLOBAL_INSTRUCTIONS]??"",h=s[ot.GLOBAL_INSTRUCTIONS]??!1,[c,d]=P.useState(u),[f,g]=P.useState(!1),[m,v]=P.useState(!1);P.useEffect(()=>{e&&i(ot.GLOBAL_INSTRUCTIONS)},[e,i]),P.useEffect(()=>{d(u),g(!1)},[u]);const S=async()=>{v(!0),await l(ot.GLOBAL_INSTRUCTIONS,c),v(!1),g(!1)},k=()=>{d(u),g(!1)},C=h||m;return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),o.jsx("textarea",{value:c,onChange:y=>{d(y.target.value),g(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),f&&o.jsx(Yh,{}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(nt,{variant:"secondary",onClick:k,disabled:!f,children:"Discard"}),o.jsx(nt,{variant:"primary",onClick:S,disabled:!f||C,children:m?"Saving...":"Save"})]})]})}var qd={exports:{}},ab;function nC(){return ab||(ab=1,(function(e,r){(function(s,i){e.exports=i()})(globalThis,(()=>(()=>{var s={4567:function(h,c,d){var f=this&&this.__decorate||function(x,_,j,T){var N,D=arguments.length,A=D<3?_:T===null?T=Object.getOwnPropertyDescriptor(_,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(x,_,j,T);else for(var z=x.length-1;z>=0;z--)(N=x[z])&&(A=(D<3?N(A):D>3?N(_,j,A):N(_,j))||A);return D>3&&A&&Object.defineProperty(_,j,A),A},g=this&&this.__param||function(x,_){return function(j,T){_(j,T,x)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),v=d(9924),S=d(844),k=d(4725),C=d(2585),y=d(3656);let b=c.AccessibilityManager=class extends S.Disposable{constructor(x,_,j,T){super(),this._terminal=x,this._coreBrowserService=j,this._renderService=T,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new v.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
57
+ */var zx;function k1(){if(zx)return Hd;zx=1;var e=ac();function r(m,v){return m===v&&(m!==0||1/m===1/v)||m!==m&&v!==v}var s=typeof Object.is=="function"?Object.is:r,i=e.useState,l=e.useEffect,u=e.useLayoutEffect,h=e.useDebugValue;function c(m,v){var S=v(),k=i({inst:{value:S,getSnapshot:v}}),C=k[0].inst,y=k[1];return u(function(){C.value=S,C.getSnapshot=v,d(C)&&y({inst:C})},[m,S,v]),l(function(){return d(C)&&y({inst:C}),m(function(){d(C)&&y({inst:C})})},[m]),h(S),S}function d(m){var v=m.getSnapshot;m=m.value;try{var S=v();return!s(m,S)}catch{return!0}}function f(m,v){return v()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Hd.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Hd}var Px;function E1(){return Px||(Px=1,Pd.exports=k1()),Pd.exports}var j1=E1();const N1=d1.useInsertionEffect,T1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",A1=T1?P.useLayoutEffect:P.useEffect,D1=N1||A1,Dv=e=>{const r=P.useRef([e,(...s)=>r[0](...s)]).current;return D1(()=>{r[0]=e}),r[1]},R1="popstate",Oh="pushState",Mh="replaceState",L1="hashchange",Hx=[R1,Oh,Mh,L1],O1=e=>{for(const r of Hx)addEventListener(r,e);return()=>{for(const r of Hx)removeEventListener(r,e)}},Rv=(e,r)=>j1.useSyncExternalStore(O1,e,r),Fx=()=>location.search,M1=({ssrSearch:e}={})=>Rv(Fx,e!=null?()=>e:Fx),Ux=()=>location.pathname,I1=({ssrPath:e}={})=>Rv(Ux,e!=null?()=>e:Ux),B1=(e,{replace:r=!1,state:s=null}={})=>history[r?Mh:Oh](s,"",e),z1=(e={})=>[I1(e),B1],$x=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[$x]>"u"){for(const e of[Oh,Mh]){const r=history[e];history[e]=function(){const s=r.apply(this,arguments),i=new Event(e);return i.arguments=arguments,dispatchEvent(i),s}}Object.defineProperty(window,$x,{value:!0})}const P1=(e,r)=>r.toLowerCase().indexOf(e.toLowerCase())?"~"+r:r.slice(e.length)||"/",Lv=(e="")=>e==="/"?"":e,H1=(e,r)=>e[0]==="~"?e.slice(1):Lv(r)+e,F1=(e="",r)=>P1(qx(Lv(e)),qx(r)),qx=e=>{try{return decodeURI(e)}catch{return e}},Ov={hook:z1,searchHook:M1,parser:C1,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,r,s)=>e(r,s)},Mv=P.createContext(Ov),Gi=()=>P.useContext(Mv),Iv={},Bv=P.createContext(Iv),U1=()=>P.useContext(Bv),oc=e=>{const[r,s]=e.hook(e);return[F1(e.base,r),Dv((i,l)=>e.aroundNav(s,H1(i,e.base),l))]},lr=()=>oc(Gi()),Ih=(e,r,s,i)=>{const{pattern:l,keys:u}=r instanceof RegExp?{keys:!1,pattern:r}:e(r||"*",i),h=l.exec(s)||[],[c,...d]=h;return c!==void 0?[!0,(()=>{const f=u!==!1?Object.fromEntries(u.map((m,v)=>[m,d[v]])):h.groups;let g={...d};return f&&Object.assign(g,f),g})(),...i?[c]:[]]:[!1,null]},Bh=e=>Ih(Gi().parser,e,lr()[0]),$1=({children:e,...r})=>{var g,m,v;const s=Gi(),i=r.hook?Ov:s;let l=i;const[u,h=r.ssrSearch??""]=((g=r.ssrPath)==null?void 0:g.split("?"))??[];u&&(r.ssrSearch=h,r.ssrPath=u),r.hrefs=r.hrefs??((m=r.hook)==null?void 0:m.hrefs),r.searchHook=r.searchHook??((v=r.hook)==null?void 0:v.searchHook);let c=P.useRef({}),d=c.current,f=d;for(let S in i){const k=S==="base"?i[S]+(r[S]??""):r[S]??i[S];d===f&&k!==f[S]&&(c.current=f={...f}),f[S]=k,(k!==i[S]||k!==l[S])&&(l=f)}return P.createElement(Mv.Provider,{value:l,children:e})},Wx=({children:e,component:r},s)=>r?P.createElement(r,{params:s}):typeof e=="function"?e(s):e,q1=e=>{let r=P.useRef(Iv);const s=r.current;return r.current=Object.keys(e).length!==Object.keys(s).length||Object.entries(e).some(([i,l])=>l!==s[i])?e:s},$a=({path:e,nest:r,match:s,...i})=>{const l=Gi(),[u]=oc(l),[h,c,d]=s??Ih(l.parser,e,u,r),f=q1({...U1(),...c});if(!h)return null;const g=d?P.createElement($1,{base:d},Wx(i,f)):Wx(i,f);return P.createElement(Bv.Provider,{value:f,children:g})},Fn=P.forwardRef((e,r)=>{const s=Gi(),[i,l]=oc(s),{to:u="",href:h=u,onClick:c,asChild:d,children:f,className:g,replace:m,state:v,transition:S,...k}=e,C=Dv(b=>{b.ctrlKey||b.metaKey||b.altKey||b.shiftKey||b.button!==0||(c==null||c(b),b.defaultPrevented||(b.preventDefault(),l(h,e)))}),y=s.hrefs(h[0]==="~"?h.slice(1):s.base+h,s);return d&&P.isValidElement(f)?P.cloneElement(f,{onClick:C,href:y}):P.createElement("a",{...k,onClick:C,href:y,className:g!=null&&g.call?g(i===h):g,children:f,ref:r})}),zv=e=>Array.isArray(e)?e.flatMap(r=>zv(r&&r.type===P.Fragment?r.props.children:r)):[e],W1=({children:e,location:r})=>{const s=Gi(),[i]=oc(s);for(const l of zv(e)){let u=0;if(P.isValidElement(l)&&(u=Ih(s.parser,l.props.path,r||i,l.props.nest))[0])return P.cloneElement(l,{match:u})}return null};function V1(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function Pv(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}class G1{constructor(r){fr(this,"ws",null);fr(this,"handlers",new Set);fr(this,"statusHandler",null);fr(this,"baseUrl");fr(this,"isReconnecting",!1);fr(this,"connectingPromise",null);fr(this,"lastCloseCode",0);fr(this,"reconnectAttempts",0);fr(this,"manualReconnectScheduled",!1);this.baseUrl=r}getUrl(){const r=localStorage.getItem("openfox_token");if(r){const s=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${s}token=${encodeURIComponent(r)}`}return this.baseUrl}setToken(r){localStorage.setItem("openfox_token",r)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(r){this.statusHandler=r}connect(){var r,s;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((s=this.ws)==null?void 0:s.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.connectingPromise=new Promise((i,l)=>{try{const u=this.getUrl();this.ws=new WebSocket(u);const h=setTimeout(()=>{var c;((c=this.ws)==null?void 0:c.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var c;clearTimeout(h),this.isReconnecting=!1,this.connectingPromise=null,(c=this.statusHandler)==null||c.call(this,"connected"),i()},this.ws.onclose=c=>{var d,f,g;clearTimeout(h),this.lastCloseCode=c.code,((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(f=this.statusHandler)==null||f.call(this,"disconnected"),l(new Error(`Connection closed: ${c.code}`))):(this.connectingPromise=null,(g=this.statusHandler)==null||g.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=c=>{clearTimeout(h),console.error("WebSocket error:",c),this.connectingPromise=null,l(c)},this.ws.onmessage=c=>{try{const d=JSON.parse(c.data);V1(d)&&this.handlers.forEach(f=>f(d))}catch(d){console.error("Failed to parse WebSocket message:",d)}}}catch(u){this.connectingPromise=null,l(u)}}),this.connectingPromise))}attemptReconnect(){var l;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.log("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(l=this.statusHandler)==null||l.call(this,"reconnecting");const i=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{})},i)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(r,s){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const i=Pv(),l={id:i,type:r,payload:s};return this.ws.send(JSON.stringify(l)),i}subscribe(r){return this.handlers.add(r),()=>this.handlers.delete(r)}get isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}}const K1=window.location.protocol==="https:"?"wss:":"ws:";let fh=window.location.port;fh||(fh=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const Y1=`${K1}//${window.location.hostname}:${fh}/ws`,Gt=new G1(Y1),xs=async(e,r,s)=>{try{const i=await ke(r,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});return i.ok?{success:!0}:{success:!1,error:(await i.json()).error}}catch{return{success:!1,error:"Network error"}}};function Hv(e){let r=null;function s(){r===null&&(r=requestAnimationFrame(()=>{r=null,e()}))}return s}let Il=[];const gr=$n()((e,r)=>{function s(){if(Il.length===0)return;const l=Il;Il=[],e(u=>({logs:[...u.logs,...l]}))}const i=Hv(s);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:l=>{r().workdir!==l&&(e({workdir:l,status:null,logs:[],config:null,loading:!0}),l&&(r().fetchStatus(),r().fetchConfig()))},fetchStatus:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server?workdir=${encodeURIComponent(l)}`)).json();e({status:h,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(l)}`)).json();e({config:h.config??null})}catch{}},fetchLogs:async()=>{const l=r().workdir;if(l)try{const c=(await(await ke(`/api/dev-server/logs?workdir=${encodeURIComponent(l)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content}));e({logs:c})}catch{}},start:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/start?workdir=${encodeURIComponent(l)}`,{method:"POST"})).json();e({status:h,logs:[]})}catch{}},stop:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/stop?workdir=${encodeURIComponent(l)}`,{method:"POST"})).json();e({status:h})}catch{}},restart:async()=>{const l=r().workdir;if(l)try{const h=await(await ke(`/api/dev-server/restart?workdir=${encodeURIComponent(l)}`,{method:"POST"})).json();e({status:h,logs:[]})}catch{}},saveConfig:async l=>{const u=r().workdir;if(u)try{const c=await(await ke(`/api/dev-server/config?workdir=${encodeURIComponent(u)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})).json();e({config:c.config??l}),r().fetchStatus()}catch{}},handleMessage:l=>{const u=r().workdir;if(u)switch(l.type){case"devServer.output":{const h=l.payload;if(h.workdir!==u)return;Il.push({stream:h.stream,content:h.content}),i();break}case"devServer.state":{const h=l.payload;if(h.workdir!==u)return;e(c=>({status:c.status?{...c.status,state:h.state,errorMessage:h.errorMessage}:c.status}));break}}}}});function X1(e){return{...e.temperature!=null&&{temperature:e.temperature},...e.topP!=null&&{topP:e.topP},...e.topK!=null&&{topK:e.topK},...e.maxTokens!=null&&{maxTokens:e.maxTokens}}}async function Vx(e,r,s){const i=await ke(`/api/providers/${e}/models/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok){const l=await i.json();throw new Error(l.error??"Failed to update model")}return i.json()}function Gx(e,r,s,i){return e.map(l=>l.id===r?{...l,models:l.models.map(u=>u.id===s?{...u,...i,source:"user"}:u)}:l)}const Z1=3e4;function Q1(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"auto":return"Auto";case"unknown":return""}}const Rt=$n((e,r)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>{e({loading:!0,error:null});try{const s=await ke("/api/config");if(!s.ok)throw new Error("Failed to fetch config");const i=await s.json();e({version:i.version,model:i.model,maxContext:i.maxContext,llmUrl:i.llmUrl,llmStatus:i.llmStatus,backend:i.backend,providers:i.providers??[],activeProviderId:i.activeProviderId??null,defaultModelSelection:i.defaultModelSelection??null,loading:!1})}catch(s){e({error:s instanceof Error?s.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const s=await ke("/api/model/refresh",{method:"POST"});if(!s.ok)throw new Error("Failed to refresh model");const i=await s.json(),u=we.getState().currentSession;if(u!=null&&u.providerId&&u.providerModel){e({llmStatus:i.llmStatus,backend:i.backend});return}e({model:i.model,llmStatus:i.llmStatus,backend:i.backend})}catch(s){console.error("Failed to refresh model:",s)}},activateProvider:async s=>{const{activeProviderId:i,providers:l}=r();if(s===i)return!0;e({activating:!0,error:null});try{const u=await ke(`/api/providers/${s}/activate`,{method:"POST"});if(!u.ok){const c=await u.json();throw new Error(c.error??"Failed to activate provider")}const h=await u.json();return e({activeProviderId:h.activeProviderId,model:h.model,backend:h.backend,providers:l.map(c=>({...c,isActive:c.id===h.activeProviderId})),activating:!1}),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(s,i)=>{const{providers:l}=r();e({activeProviderId:s,model:i,defaultModelSelection:`${s}/${i}`,providers:l.map(u=>({...u,isActive:u.id===s}))})},updateModelContext:async(s,i,l)=>{e({activating:!0,error:null});try{const u=await Vx(s,i,{contextWindow:l}),{providers:h}=r();return e({providers:Gx(h,s,i,{contextWindow:l}),activating:!1}),u.contextState&&we.getState().updateContextState(u.contextState),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(s,i,l)=>{e({activating:!0,error:null});try{const u=await Vx(s,i,l),{providers:h}=r(),c={...l.contextWindow!==void 0&&{contextWindow:l.contextWindow},...X1({temperature:l.temperature??void 0,topP:l.topP??void 0,topK:l.topK??void 0,maxTokens:l.maxTokens??void 0}),...l.supportsVision!==void 0&&{supportsVision:l.supportsVision}};return e({providers:Gx(h,s,i,c),activating:!1}),u.contextState&&we.getState().updateContextState(u.contextState),!0}catch(u){return e({error:u instanceof Error?u.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async s=>{e({activating:!0,error:null});try{const i=await ke(`/api/providers/${s}/refresh`,{method:"POST"});if(!i.ok){const h=await i.json();throw new Error(h.error??"Failed to refresh models")}const l=await i.json(),{providers:u}=r();return e({providers:u.map(h=>h.id===s?{...h,models:l.models}:h),activating:!1}),!0}catch(i){return e({error:i instanceof Error?i.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:s,refreshModel:i}=r();if(s)return;const l=setInterval(()=>{i()},Z1);e({autoRefreshInterval:l})},stopAutoRefresh:()=>{const{autoRefreshInterval:s}=r();s&&(clearInterval(s),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:s,activeProviderId:i}=r();return s.find(l=>l.id===i)},getModelContext:s=>{const{providers:i,activeProviderId:l}=r(),u=i.find(c=>c.id===l);if(!u)return 2e5;const h=u.models.find(c=>c.id===s);return(h==null?void 0:h.contextWindow)??2e5}})),Ft=$n((e,r)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const i=await(await ke("/api/projects")).json();e({projects:i.projects??[],loading:!1})}catch(s){console.error("Failed to load projects:",s),e({loading:!1})}},createProject:async(s,i)=>{try{const l=await ke("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,workdir:i})});if(!l.ok)return null;const u=await l.json();return await r().listProjects(),u.project}catch{return null}},loadProject:async s=>{try{const i=await ke(`/api/projects/${s}`);if(!i.ok)return null;const l=await i.json();return e({currentProject:l.project}),r().projects.length===0&&await r().listProjects(),l.project}catch{return null}},updateProject:async(s,i)=>{var l;try{const u=await ke(`/api/projects/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!u.ok)return null;const h=await u.json();return((l=r().currentProject)==null?void 0:l.id)===s&&e({currentProject:h.project}),await r().listProjects(),h.project}catch{return null}},deleteProject:async s=>{var i;try{return(await ke(`/api/projects/${s}`,{method:"DELETE"})).ok?(await r().listProjects(),((i=r().currentProject)==null?void 0:i.id)===s&&e({currentProject:null}),!0):!1}catch{return!1}},clearProject:()=>{e({currentProject:null})}}));let Bl=[];const no=$n()((e,r)=>{function s(){if(Bl.length===0)return;const l=Bl;Bl=[],e(u=>{const h={...u.logs};for(const c of l){const d=h[c.processId]??[];h[c.processId]=[...d,{offset:d.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:h}})}const i=Hv(s);return{processes:[],logs:{},loading:!1,setProcesses:l=>e({processes:l}),addProcess:l=>e(u=>({processes:[...u.processes,l]})),updateProcess:(l,u)=>e(h=>({processes:h.processes.map(c=>c.id===l?{...c,...u}:c)})),removeProcess:l=>e(u=>({processes:u.processes.filter(h=>h.id!==l),logs:Object.fromEntries(Object.entries(u.logs).filter(([h])=>h!==l))})),stopProcess:async(l,u)=>{try{(await ke(`/api/sessions/${u}/background-process/${l}/stop`,{method:"POST"})).ok&&r().removeProcess(l)}catch{}},appendLog:(l,u,h)=>{Bl.push({processId:l,stream:u,content:h}),i()},setLogs:(l,u)=>e(h=>({logs:{...h.logs,[l]:u}})),clearLogs:l=>e(u=>({logs:{...u.logs,[l]:[]}})),handleMessage:(l,u)=>{switch(l){case"backgroundProcess.started":{const{processId:h,name:c,pid:d,status:f}=u;e(g=>({processes:[...g.processes,{id:h,sessionId:"",name:c,command:"",cwd:"",pid:d,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const h=u.processId,c=u.stream,d=u.content;r().appendLog(h,c,d);break}case"backgroundProcess.exited":{const h=u.processId,c=u.exitCode;e(d=>({processes:d.processes.map(f=>f.id===h?{...f,status:"exited",exitCode:c}:f)}));break}case"backgroundProcess.removed":{const h=u.processId;r().removeProcess(h);break}}}}}),J1=[{key:"complete",label:"Task Complete",description:"When an agent finishes its work"},{key:"waiting_for_user",label:"Waiting for Input",description:"When the agent needs your input"},{key:"phase_done",label:"Phase Done",description:"When a build phase completes successfully"},{key:"phase_blocked",label:"Phase Blocked",description:"When a build phase is blocked and needs intervention"},{key:"new_message",label:"New Message",description:"When a new assistant message starts arriving"}],ew=[{url:"/sounds/notification.mp3",label:"Notification"},{url:"/sounds/waiting-for-user.mp3",label:"Waiting for User"},{url:"/sounds/achievement.mp3",label:"Achievement"},{url:"/sounds/intervention.mp3",label:"Intervention"},{url:"/sounds/typing.mp3",label:"Typing"}],Fv={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},ms={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Uv={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},ph={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...ms},waiting_for_user:{...ms},phase_done:{...ms},phase_blocked:{...ms},new_message:{...Uv}},agentOverrides:{}};function $v(e,r,s){var u;const i=e.events[r];if(!s)return i;const l=(u=e.agentOverrides[s])==null?void 0:u[r];return l?{soundEnabled:l.soundEnabled??i.soundEnabled,browserNotification:l.browserNotification??i.browserNotification,customSoundUrl:l.customSoundUrl!==void 0?l.customSoundUrl:i.customSoundUrl}:i}const Fs=$n((e,r)=>({settings:ph,loaded:!1,load:()=>{gn.getState().getSetting(ot.NOTIFICATION_SETTINGS);const i=gn.subscribe(u=>{const h=u.settings[ot.NOTIFICATION_SETTINGS];if(h!==void 0)try{const c=JSON.parse(h);e({settings:Kx(c),loaded:!0})}catch{e({loaded:!0})}}),l=gn.getState().settings[ot.NOTIFICATION_SETTINGS];if(l)try{const u=JSON.parse(l);e({settings:Kx(u),loaded:!0})}catch{e({loaded:!0})}return i},update:s=>{e({settings:s}),Fd(s)},updateEvent:(s,i)=>{const l=r().settings,u={...l,events:{...l.events,[s]:{...l.events[s],...i}}};e({settings:u}),Fd(u)},updateAgentOverride:(s,i,l)=>{var d;const u=r().settings,h={...u.agentOverrides};if(l===null){if(h[s]){const f={...h[s]};delete f[i],Object.keys(f).length===0?delete h[s]:h[s]=f}}else h[s]={...h[s],[i]:{...((d=h[s])==null?void 0:d[i])??{},...l}};const c={...u,agentOverrides:h};e({settings:c}),Fd(c)}}));function Fd(e){gn.getState().setSetting(ot.NOTIFICATION_SETTINGS,JSON.stringify(e))}function Kx(e){var r,s,i,l,u;return{soundEnabled:e.soundEnabled??ph.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??ph.browserNotificationEnabled,events:{complete:{...ms,...(r=e.events)==null?void 0:r.complete},waiting_for_user:{...ms,...(s=e.events)==null?void 0:s.waiting_for_user},phase_done:{...ms,...(i=e.events)==null?void 0:i.phase_done},phase_blocked:{...ms,...(l=e.events)==null?void 0:l.phase_blocked},new_message:{...Uv,...(u=e.events)==null?void 0:u.new_message}},agentOverrides:e.agentOverrides??{}}}const Yx=new Map;function tw(e){let r=Yx.get(e);return r||(r=new Audio(e),r.volume=.5,Yx.set(e,r)),r}let qv=typeof Notification<"u"?Notification.permission:"denied";function nw(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(qv=e,e))}const rw={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},sw={complete:"The agent has finished its work.",waiting_for_user:"The agent needs your input to continue.",phase_done:"The build phase completed successfully.",phase_blocked:"The build phase is blocked and needs intervention.",new_message:"A new assistant message is arriving."};function iw(e){typeof Notification>"u"||qv==="granted"&&(document.hasFocus()||new Notification(rw[e],{body:sw[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function go(e,r){const{settings:s}=Fs.getState(),i=$v(s,e,r);if(s.soundEnabled&&i.soundEnabled){const l=i.customSoundUrl??Fv[e],u=tw(l);u.currentTime=0,u.play().catch(()=>{})}s.browserNotificationEnabled&&i.browserNotification&&iw(e)}const aw=e=>go("complete",e),ow=e=>go("phase_done",e),lw=e=>go("phase_blocked",e),Xx=e=>go("waiting_for_user",e),cw=e=>go("new_message",e);let qa=!1,pr=null;const Ud=new Set,Vt={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Ui=null,pn=null;function $d(){Ui===null&&(Ui=requestAnimationFrame(()=>{Ui=null,pn==null||pn()}))}function Is(){Ui!==null&&(cancelAnimationFrame(Ui),Ui=null)}function Ht(e,r){return r!==null&&e.sessionId===r}function uw(e,r,s){return e.id!==void 0||Ht(e,r)||s===!0&&e.sessionId!==void 0}function dw(e,r){return e.includes(r)?e:[...e,r]}function Wa(e,r){return e.filter(s=>s!==r)}function hw(e,r){const s=e.find(l=>l.id===r.id),i=s?{...s,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,messageCount:r.messages.length,criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(l=>l.status.type==="passed").length}:{id:r.id,projectId:r.projectId,workdir:r.workdir,mode:r.mode,phase:r.phase,isRunning:r.isRunning,createdAt:"",updatedAt:"",criteriaCount:r.criteria.length,criteriaCompleted:r.criteria.filter(l=>l.status.type==="passed").length,messageCount:r.messages.length};return s?e.map(l=>l.id===r.id?i:l):[i,...e]}function Zx(e,r,s){return e.map(i=>{const l=(s==null?void 0:s.id)===i.id?s:null,u=r.find(h=>h.id===i.id);return{...i,title:i.title??(u==null?void 0:u.title),mode:(l==null?void 0:l.mode)??(u==null?void 0:u.mode)??i.mode,phase:(l==null?void 0:l.phase)??(u==null?void 0:u.phase)??i.phase,isRunning:i.isRunning&&(u==null?void 0:u.isRunning)!==!1,messageCount:i.messageCount,recentUserPrompts:i.recentUserPrompts}})}const Qx=new Map;function eo(e,r){var u;const s=r===((u=e.currentSession)==null?void 0:u.id)?e.currentSession:null,i=e.sessions.find(h=>h.id===r),l=(s==null?void 0:s.mode)??(i==null?void 0:i.mode);return l==="planner"?"planner":l==="builder"?"build":"planner"}function fw(e,r){if(e.type==="chat.done"){const s=e.payload,i=eo(r,e.sessionId),l=s.agentType??i;s.reason==="complete"&&aw(l),s.reason==="waiting_for_user"&&Xx(l);return}if(e.type==="chat.path_confirmation"){const s=eo(r,e.sessionId);Xx(s);return}if(e.type==="task.completed"){const s=eo(r,e.sessionId);ow(s);return}if(e.type==="phase.changed"&&e.sessionId){const s=e.payload,i=Qx.get(e.sessionId)??null;if(Qx.set(e.sessionId,s.phase),i===s.phase)return;const l=eo(r,e.sessionId);s.phase==="blocked"&&lw(l)}}const we=$n((e,r)=>(pn=()=>{const s=Vt;if(!s.messageId)return;const i=s.deltaContent.length>0,l=s.thinkingContent.length>0,u=s.toolOutput.length>0;if(!i&&!l&&!u)return;const h=s.deltaContent,c=s.thinkingContent,d=s.toolOutput;s.deltaContent="",s.thinkingContent="",s.toolOutput=[],e(f=>{var m;const g=f.streamingMessage;if(g&&g.id===s.messageId){let v={...g};if(i&&(v.content=v.content+h),l&&(v.thinkingContent=(v.thinkingContent??"")+c),u){const S=new Set;v.toolCalls=(m=v.toolCalls)==null?void 0:m.map(C=>{const y=d.filter(b=>b.callId===C.id);return y.length===0?C:(S.add(C.id),{...C,streamingOutput:[...C.streamingOutput??[],...y.map(b=>({stream:b.stream,content:b.content,timestamp:Date.now()}))]})});const k=d.filter(C=>!S.has(C.callId));k.length>0&&Vt.toolOutput.push(...k)}return{streamingMessage:v}}if(u){const v=new Set,S=f.messages.map(C=>{var b;if(C.id!==s.messageId)return C;const y=(b=C.toolCalls)==null?void 0:b.map(x=>{const _=d.filter(j=>j.callId===x.id);return _.length===0?x:(v.add(x.id),{...x,streamingOutput:[...x.streamingOutput??[],..._.map(j=>({stream:j.stream,content:j.content,timestamp:Date.now()}))]})});return{...C,toolCalls:y}}),k=d.filter(C=>!v.has(C.callId));return k.length>0&&Vt.toolOutput.push(...k),{messages:S}}return f})},{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmation:null,pendingQuestion:null,visionFallbackByMessage:{},queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(r().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let i=!1;try{i=(await(await ke("/api/auth")).json()).requiresAuth}catch{}if(i&&!Gt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Gt.onStatusChange(l=>{var u;if(e({connectionStatus:l}),l==="connected"){r().listSessions(void 0),Ft.getState().listProjects();const h=(u=r().currentSession)==null?void 0:u.id;h&&r().loadSession(h)}});try{if(await Gt.connect(),!qa){qa=!0;const l=r().handleServerMessage;pr=Gt.subscribe(l)}}catch(l){console.error("Failed to connect:",l);const u=Gt.getLastCloseCode();if(!Gt.hasToken()&&(u===1006||u===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}pr&&(pr(),pr=null),qa=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Gt.disconnect(),pr&&(pr(),pr=null),qa=!1,e({connectionStatus:"disconnected"}),r().connect()},disconnect:()=>{Gt.disconnect(),pr&&(pr(),pr=null),qa=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async s=>{try{const i=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:s})});if(!i.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:l}=await i.json();Gt.setToken(l),e({showPasswordModal:!1}),r().connect();const{listProjects:u}=Ft.getState(),{fetchConfig:h}=Rt.getState();u(),h(),r().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Gt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(s,i)=>{if(r().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const u=await ke("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:s,title:i})});if(!u.ok)return e({pendingSessionCreate:!1}),null;const h=await u.json();return Gt.send("session.load",{sessionId:h.session.id}),h.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async s=>{try{const i=r().currentSession;!i||i.id!==s?(Is(),e({currentSession:null,unreadSessionIds:Wa(r().unreadSessionIds,s),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmation:null,queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1})):e({unreadSessionIds:Wa(r().unreadSessionIds,s)});const l=await ke(`/api/sessions/${s}`);if(!l.ok)return;const u=await l.json();e({currentSession:u.session,messages:u.messages??[],contextState:u.contextState,queuedMessages:u.queueState??[]}),Gt.send("session.load",{sessionId:s});try{const h=await ke(`/api/sessions/${s}/background-processes`);if(h.ok){const c=await h.json();no.getState().setProcesses(c.processes??[])}}catch{}}catch{}},listSessions:async(s,i=20)=>{try{const l=new URLSearchParams;l.set("limit",String(i)),s&&l.set("projectId",s);const h=await(await ke(`/api/sessions?${l.toString()}`)).json(),c=h.sessions??[];e(d=>({sessions:Zx(c,d.sessions,d.currentSession),sessionsHasMore:s?h.hasMore??!1:!0}))}catch{}},loadMoreSessions:async s=>{const i=r();if(!(i.sessionsPaginationLoading||!i.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const l=new URLSearchParams;l.set("limit","20"),l.set("offset",String(i.sessions.length)),l.set("projectId",s);const h=await(await ke(`/api/sessions?${l.toString()}`)).json(),c=h.sessions??[];e(d=>({sessions:[...d.sessions,...c.map(f=>{const g=d.sessions.find(m=>m.id===f.id);return(g==null?void 0:g.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:h.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async s=>{var i;try{return(await ke(`/api/sessions/${s}`,{method:"DELETE"})).ok?(await r().listSessions(),((i=r().currentSession)==null?void 0:i.id)===s&&r().clearSession(),!0):!1}catch{return!1}},renameSession:async(s,i)=>{var l;try{const u=await ke(`/api/sessions/${s}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:i})});if(!u.ok)return!1;if(await r().listSessions(),((l=r().currentSession)==null?void 0:l.id)===s){const c=await u.json();c.session&&e({currentSession:c.session})}return!0}catch{return!1}},deleteAllSessions:async s=>{try{return(await ke(`/api/projects/${s}/sessions`,{method:"DELETE"})).ok?(await r().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Is(),e(s=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:s.currentSession?Wa(s.unreadSessionIds,s.currentSession.id):s.unreadSessionIds}))},sendMessage:async(s,i,l)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u){e({streamingMessageId:null});try{const d=await(await ke(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s,attachments:i,messageKind:l==null?void 0:l.messageKind})})).json();d.queueState&&e({queuedMessages:d.queueState})}catch(c){console.error("Error sending message:",c)}}},stopGeneration:async()=>{var i;const s=(i=r().currentSession)==null?void 0:i.id;if(s&&!r().abortInProgress){Is(),pn==null||pn(),e({abortInProgress:!0});try{await ke(`/api/sessions/${s}/stop`,{method:"POST"})}catch(l){console.error("Error stopping generation:",l)}}},continueGeneration:async()=>{var i;const s=(i=r().currentSession)==null?void 0:i.id;if(s){e({streamingMessageId:null});try{await ke(`/api/sessions/${s}/continue`,{method:"POST"})}catch(l){console.error("Error continuing generation:",l)}}},launchRunner:(s,i,l)=>{e({streamingMessageId:null});const u={};s!=null&&s.trim()&&(u.content=s),i&&i.length>0&&(u.attachments=i),l&&(u.workflowId=l),Gt.send("runner.launch",u)},switchMode:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const u=await ke(`/api/sessions/${i}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:s})});if(!u.ok){console.error("Failed to switch mode:",await u.json());return}const h=await u.json();h.session&&e({currentSession:h.session})}catch(u){console.error("Error switching mode:",u)}},switchDangerLevel:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const u=await ke(`/api/sessions/${i}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:s})});if(!u.ok){console.error("Failed to switch danger level:",await u.json());return}const h=await u.json();h.session&&e({currentSession:h.session})}catch(u){console.error("Error switching danger level:",u)}},acceptAndBuild:(s,i,l)=>{var c;e({streamingMessageId:null});const u={};s&&(u.workflowId=s),i!=null&&i.trim()&&(u.content=i),l&&l.length>0&&(u.attachments=l);const h=(c=r().currentSession)==null?void 0:c.id;h&&ke(`/api/sessions/${h}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{Gt.send("runner.launch",u)})},editCriteria:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const u=await ke(`/api/sessions/${i}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:s})});u.ok||console.error("Failed to update criteria:",await u.json())}catch(u){console.error("Error updating criteria:",u)}},compactContext:()=>{Gt.send("context.compact",{})},setSessionProvider:async(s,i)=>{var l;try{const u=(l=r().currentSession)==null?void 0:l.id;if(!u)return null;const h=await ke(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:s,...i?{model:i}:{}})});if(!h.ok)return null;const c=await h.json();return e({currentSession:c.session,messages:c.messages??[],contextState:c.contextState}),c.session}catch{return null}},updateContextState:s=>{e({contextState:s})},updateSubAgentContextState:(s,i)=>{e(l=>({subAgentContextStates:{...l.subAgentContextStates,[s]:i}}))},clearSubAgentContextState:s=>{e(i=>{const l={...i.subAgentContextStates};return delete l[s],{subAgentContextStates:l}})},confirmPath:async(s,i,l=!1)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u)try{await ke(`/api/sessions/${u}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:s,approved:i,alwaysAllow:l})})}catch(c){console.error("Error confirming path:",c)}},answerQuestion:async(s,i)=>{var u;const l=(u=r().currentSession)==null?void 0:u.id;if(l){try{await ke(`/api/sessions/${l}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:s,answer:i})})}catch(h){console.error("Error answering question:",h)}e({pendingQuestion:null})}},queueAsap:async(s,i,l)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u)try{const d=await(await ke(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s,attachments:i,messageKind:l})})).json();d.queueState&&e({queuedMessages:d.queueState})}catch(c){console.error("Error queueing ASAP message:",c)}},queueCompletion:async(s,i,l)=>{var h;const u=(h=r().currentSession)==null?void 0:h.id;if(u)try{const d=await(await ke(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s,attachments:i,messageKind:l})})).json();d.queueState&&e({queuedMessages:d.queueState})}catch(c){console.error("Error queueing completion message:",c)}},cancelQueued:async s=>{var l;const i=(l=r().currentSession)==null?void 0:l.id;if(i)try{const h=await(await ke(`/api/sessions/${i}/queue/${s}`,{method:"DELETE"})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(u){console.error("Error canceling queued message:",u)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:s=>{var h,c,d,f,g,m,v,S,k,C,y,b,x,_,j,T,N,D,A,z,O,q,G,W;const i=r();fw(s,i);const l=((h=i.currentSession)==null?void 0:h.id)??null,u=()=>{const M=s.sessionId;!M||M===l||e($=>({unreadSessionIds:dw($.unreadSessionIds,M)}))};switch(s.type){case"session.state":{const M=s.payload;if(!uw(s,l,i.pendingSessionCreate))break;Is();const $=M.messages.find(R=>R.isStreaming)??null,B=r().pendingSessionCreate===!0,X=M.pendingConfirmations??[],H=i.pendingPathConfirmation??(X.length>0?X[0]??null:null);if(e({currentSession:M.session,sessions:hw(r().sessions,M.session),unreadSessionIds:Wa(r().unreadSessionIds,M.session.id),messages:M.messages,streamingMessageId:($==null?void 0:$.id)??null,streamingMessage:$,currentTodos:[],pendingPathConfirmation:H,error:null,...B?{pendingSessionCreate:M.session.id}:{}}),M.session.providerId&&M.session.providerModel){const R=Rt.getState();R.providers.find(F=>F.id===M.session.providerId)&&R.syncFromSession(M.session.providerId,M.session.providerModel)}break}case"session.list":{const M=s.payload;e($=>({sessions:Zx(M.sessions,$.sessions,$.currentSession)}));break}case"session.deleted":{const M=s.payload;e($=>({unreadSessionIds:Wa($.unreadSessionIds,M.sessionId)})),r().listSessions();break}case"session.deletedAll":{r().listSessions();break}case"session.running":{const M=s.payload,$=s.sessionId,B=(c=r().currentSession)==null?void 0:c.id,X=$&&$!==B;e(Q=>({sessions:Q.sessions.map(H=>H.id===$?{...H,isRunning:M.isRunning}:H)})),X||e(Q=>({currentSession:Q.currentSession?{...Q.currentSession,isRunning:M.isRunning}:null,...M.isRunning?{}:{abortInProgress:!1,queuedMessages:[]}}));break}case"chat.message":{if(!Ht(s,((d=r().currentSession)==null?void 0:d.id)??null)){u();break}const M=s.payload;e($=>$.messages.some(B=>B.id===M.message.id)?$:{messages:[...$.messages,M.message],streamingMessageId:M.message.isStreaming?M.message.id:$.streamingMessageId,streamingMessage:M.message.isStreaming?M.message:$.streamingMessage});break}case"chat.message_updated":{if(!Ht(s,((f=r().currentSession)==null?void 0:f.id)??null)){u();break}const M=s.payload,$=M.updates.isStreaming===!1&&r().streamingMessageId===M.messageId;$&&(Is(),pn==null||pn()),e(B=>{const X=B.streamingMessage,Q=$;if(X&&X.id===M.messageId){const H={...X,...M.updates};return{messages:B.messages.map(R=>R.id===M.messageId?H:R),streamingMessageId:Q?null:B.streamingMessageId,streamingMessage:Q?null:{...X,...M.updates}}}return{messages:B.messages.map(H=>H.id===M.messageId?{...H,...M.updates}:H),streamingMessageId:Q?null:B.streamingMessageId}});break}case"chat.delta":{if(!Ht(s,((g=r().currentSession)==null?void 0:g.id)??null)){u();break}const M=s.payload;if(!Ud.has(M.messageId)){Ud.add(M.messageId);const $=eo(r(),s.sessionId);cw($)}Vt.messageId=M.messageId,Vt.deltaContent+=M.content,$d();break}case"chat.thinking":{if(!Ht(s,((m=r().currentSession)==null?void 0:m.id)??null)){u();break}const M=s.payload;Vt.messageId=M.messageId,Vt.thinkingContent+=M.content,$d();break}case"chat.tool_preparing":{if(!Ht(s,((v=r().currentSession)==null?void 0:v.id)??null)){u();break}const M=s.payload,$=(B,X,Q)=>B?B.some(H=>{const R=H;return R.name===Q&&R.index===X}):!1;e(B=>{const X=B.streamingMessage;if(X&&X.id===M.messageId){if($(X.toolCalls,M.index,M.name))return B;const Q=X.preparingToolCalls??[],H=Q.findIndex(L=>L.index===M.index);let R;return H>=0?R=Q.map((L,F)=>F===H?{...L,arguments:M.arguments}:L):R=[...Q,{index:M.index,name:M.name,...M.arguments?{arguments:M.arguments}:{}}],{streamingMessage:{...X,preparingToolCalls:R}}}return{messages:B.messages.map(Q=>Q.id!==M.messageId||$(Q.toolCalls,M.index,M.name)?Q:{...Q,preparingToolCalls:(()=>{const H=Q.preparingToolCalls??[],R=H.findIndex(L=>L.index===M.index);return R>=0?H.map((L,F)=>F===R?{...L,arguments:M.arguments}:L):[...H,{index:M.index,name:M.name,...M.arguments?{arguments:M.arguments}:{}}]})()})}});break}case"chat.tool_call":{if(!Ht(s,((S=r().currentSession)==null?void 0:S.id)??null)){u();break}const M=s.payload,$=B=>{var H;const X=(H=B.preparingToolCalls)==null?void 0:H.filter((R,L)=>{var F;return R.name===M.tool?(F=B.preparingToolCalls)==null?void 0:F.slice(0,L).some(ne=>ne.name===M.tool):!0}),Q=Vt.toolOutput.filter(R=>R.callId===M.callId);return Q.length>0&&(Vt.toolOutput=Vt.toolOutput.filter(R=>R.callId!==M.callId)),{...B,toolCalls:[...B.toolCalls??[],{id:M.callId,name:M.tool,arguments:M.args,startedAt:Date.now(),...Q.length>0?{streamingOutput:Q.map(R=>({stream:R.stream,content:R.content,timestamp:Date.now()}))}:{}}],...X&&X.length>0?{preparingToolCalls:X}:{preparingToolCalls:void 0}}};e(B=>{const X=B.streamingMessage;return X&&X.id===M.messageId?{streamingMessage:$(X)}:{messages:B.messages.map(Q=>Q.id===M.messageId?$(Q):Q)}});break}case"chat.tool_output":{if(!Ht(s,((k=r().currentSession)==null?void 0:k.id)??null)){u();break}const M=s.payload;Vt.messageId=M.messageId,Vt.toolOutput.push({messageId:M.messageId,callId:M.callId,stream:M.stream,content:M.output}),$d();break}case"chat.tool_result":{if(!Ht(s,((C=r().currentSession)==null?void 0:C.id)??null)){u();break}const M=s.payload,$=B=>{var Q;const X=(Q=B.toolCalls)==null?void 0:Q.map(H=>H.id===M.callId?{...H,result:M.result}:H);return{...B,toolCalls:X}};e(B=>{const X=B.streamingMessage;return X&&X.id===M.messageId?{streamingMessage:$(X)}:{messages:B.messages.map(Q=>Q.id===M.messageId?$(Q):Q)}});break}case"chat.vision_fallback":{if(!Ht(s,((y=r().currentSession)==null?void 0:y.id)??null)){u();break}const M=s.payload;e($=>{const B=`${M.messageId}-${M.attachmentId}`,X={...$.visionFallbackByMessage};return X[B]={type:M.type,attachmentId:M.attachmentId,filename:M.filename,description:M.description},{visionFallbackByMessage:X}});break}case"chat.todo":{if(!Ht(s,((b=r().currentSession)==null?void 0:b.id)??null)){u();break}const M=s.payload;e({currentTodos:M.todos});break}case"chat.summary":{if(!Ht(s,((x=r().currentSession)==null?void 0:x.id)??null)){u();break}const M=s.payload;e($=>({currentSession:$.currentSession?{...$.currentSession,summary:M.summary}:null}));break}case"chat.progress":{if(!Ht(s,((_=r().currentSession)==null?void 0:_.id)??null)){u();break}const M=s.payload;console.log("Progress:",M.message,M.phase);break}case"chat.format_retry":{if(!Ht(s,((j=r().currentSession)==null?void 0:j.id)??null)){u();break}const M=s.payload;console.log("Format retry:",M.attempt,"/",M.maxAttempts);break}case"chat.done":{if(!Ht(s,((T=r().currentSession)==null?void 0:T.id)??null)){u();break}Is(),pn==null||pn();const M=s.payload,$=M.stats;Vt.messageId=null,Vt.deltaContent="",Vt.thinkingContent="",Vt.toolOutput=[],Ud.delete(M.messageId),e(B=>{const X=B.streamingMessage,Q=X&&X.id===M.messageId?{...X,isStreaming:!1,stats:$??X.stats}:null;return{messages:B.messages.map(H=>H.id===M.messageId?Q??{...H,isStreaming:!1,stats:$??H.stats}:H),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Ht(s,((N=r().currentSession)==null?void 0:N.id)??null)){u();break}Is(),pn==null||pn();const M=s.payload;console.error("Chat error:",M.error,"recoverable:",M.recoverable),M.recoverable||(Vt.messageId=null,Vt.deltaContent="",Vt.thinkingContent="",Vt.toolOutput=[]),e($=>({error:{code:"CHAT_ERROR",message:M.error},streamingMessageId:M.recoverable?$.streamingMessageId:null,...M.recoverable?{}:{messages:$.streamingMessage?$.messages.map(B=>B.id===$.streamingMessage.id?$.streamingMessage:B):$.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Ht(s,((D=r().currentSession)==null?void 0:D.id)??null)){u();break}const M=s.payload;e({pendingPathConfirmation:{callId:M.callId,tool:M.tool,paths:M.paths,workdir:M.workdir,reason:M.reason}});break}case"chat.ask_user":{if(!Ht(s,((A=r().currentSession)==null?void 0:A.id)??null)){u();return}const M=s.payload;e({pendingQuestion:{callId:M.callId,question:M.question}});break}case"mode.changed":{if(!Ht(s,((z=r().currentSession)==null?void 0:z.id)??null)){u();break}const M=s.payload;e($=>({currentSession:$.currentSession?{...$.currentSession,mode:M.mode}:null}));break}case"phase.changed":{const M=s.payload,$=s.sessionId,B=(O=r().currentSession)==null?void 0:O.id,X=$&&$!==B;e(Q=>({sessions:Q.sessions.map(H=>H.id===$?{...H,phase:M.phase}:H)})),X||e(Q=>({currentSession:Q.currentSession?{...Q.currentSession,phase:M.phase}:null}));break}case"criteria.updated":{if(!Ht(s,((q=r().currentSession)==null?void 0:q.id)??null)){u();break}const M=s.payload;e($=>({currentSession:$.currentSession?{...$.currentSession,criteria:M.criteria}:null}));break}case"context.state":{const M=s.payload,$=Ht(s,((G=r().currentSession)==null?void 0:G.id)??null);M.subAgentId?$&&r().updateSubAgentContextState(M.subAgentId,M.context):$?e({contextState:M.context}):u();break}case"session.name_generated":{const M=s.payload,$=s.sessionId,B=(W=r().currentSession)==null?void 0:W.id;e(X=>{const Q=X.sessions.map(R=>R.id===$?{...R,title:M.name,updatedAt:new Date().toISOString()}:R),H=B===$?X.currentSession?{...X.currentSession,title:M.name,updatedAt:new Date().toISOString()}:null:X.currentSession;return{sessions:Q,currentSession:H}});break}case"queue.state":{const M=s.payload;e({queuedMessages:M.messages??[]});break}case"devServer.output":case"devServer.state":{gr.getState().handleMessage(s);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{no.getState().handleMessage(s.type,s.payload);break}case"error":{const M=s.payload;console.error("Server error:",M),e({error:{code:M.code,message:M.message},streamingMessageId:null});break}}}}));function Wv(){return we(e=>{var r;return((r=e.currentSession)==null?void 0:r.isRunning)??!1})}function pw(){return we(e=>e.queuedMessages)}function mw(){return we(e=>e.abortInProgress)}function gw(){const e=we(i=>i.connect),r=we(i=>i.connectionStatus),s=Fs(i=>i.load);return P.useEffect(()=>{e()},[e]),P.useEffect(()=>{r==="connected"&&s()},[r,s]),{connectionStatus:r}}const xw="modulepreload",bw=function(e){return"/"+e},Jx={},mh=function(r,s,i){let l=Promise.resolve();if(s&&s.length>0){let h=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));l=h(s.map(f=>{if(f=bw(f),f in Jx)return;Jx[f]=!0;const g=f.endsWith(".css"),m=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const v=document.createElement("link");if(v.rel=g?"stylesheet":xw,g||(v.as="script"),v.crossOrigin="",v.href=f,d&&v.setAttribute("nonce",d),document.head.appendChild(v),g)return new Promise((S,k)=>{v.addEventListener("load",S),v.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function u(h){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=h,window.dispatchEvent(c),!c.defaultPrevented)throw h}return l.then(h=>{for(const c of h||[])c.status==="rejected"&&u(c.reason);return r().catch(u)})},Vv=[{key:"color-bg-primary",category:"background",label:"Primary Background",defaultValue:"13 17 23"},{key:"color-bg-secondary",category:"background",label:"Secondary Background",defaultValue:"22 27 34"},{key:"color-bg-tertiary",category:"background",label:"Tertiary Background",defaultValue:"33 38 45"},{key:"color-primary",category:"surface",label:"Primary Surface",defaultValue:"10 10 10"},{key:"color-secondary",category:"surface",label:"Secondary Surface",defaultValue:"20 20 20"},{key:"color-text-primary",category:"text",label:"Primary Text",defaultValue:"139 148 158"},{key:"color-text-secondary",category:"text",label:"Secondary Text",defaultValue:"139 148 158"},{key:"color-text-muted",category:"text",label:"Muted Text",defaultValue:"72 79 88"},{key:"color-accent-primary",category:"accent",label:"Primary Accent",defaultValue:"88 166 255"},{key:"color-accent-success",category:"accent",label:"Success Accent",defaultValue:"63 185 80"},{key:"color-accent-warning",category:"accent",label:"Warning Accent",defaultValue:"210 153 34"},{key:"color-accent-error",category:"accent",label:"Error Accent",defaultValue:"248 81 73"},{key:"color-border",category:"border",label:"Border",defaultValue:"48 53 60"}],xr=[{id:"dark",name:"Dark",tokens:{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60"}},{id:"light",name:"Light",tokens:{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225"}},{id:"monokai",name:"Monokai",tokens:{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62"}},{id:"dracula",name:"Dracula",tokens:{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90"}},{id:"nord",name:"Nord",tokens:{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"76 86 106","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"76 86 106"}}];function eb(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const rn=$n((e,r)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:eb(),applySavedTheme:()=>{const{getSavedTheme:s,applyPreset:i,applyTokens:l}=r(),u=s();if(u)try{const h=JSON.parse(u);h.preset&&h.tokens?(i(h.preset),e({basePreset:h.preset}),l(h.tokens)):h.preset?i(h.preset):h.tokens&&l(h.tokens)}catch{i("dark")}else i("dark")},applyPreset:s=>{xr.find(l=>l.id===s)&&(e({currentPreset:s,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1}),r().applyTheme())},startCustomizing:()=>{var l;const{currentPreset:s}=r(),i=((l=xr.find(u=>u.id===s))==null?void 0:l.tokens)??{};e({basePreset:s,customTokens:{...i},isCustom:!0,isCustomizing:!0})},setCustomToken:(s,i)=>{e(l=>({customTokens:{...l.customTokens,[s]:i}})),r().applyTheme()},cancelCustomizing:()=>{r().applyPreset(r().basePreset||r().currentPreset)},saveCustomTheme:()=>{const{customTokens:s}=r();r().saveTheme(JSON.stringify({tokens:s})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:s=>{e({customTokens:s,isCustom:!0,isCustomizing:!1}),r().applyTheme()},getActiveTheme:()=>{var h,c;const{basePreset:s,customTokens:i,isCustom:l}=r();if(l&&s)return{...((h=xr.find(f=>f.id===s))==null?void 0:h.tokens)??{},...i};if(l)return{...Vv.reduce((d,f)=>({...d,[f.key]:f.defaultValue}),{}),...i};const u=xr.find(d=>d.id===r().currentPreset);return(u==null?void 0:u.tokens)??((c=xr[0])==null?void 0:c.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const s=r().getActiveTheme(),i=document.documentElement;Object.entries(s).forEach(([l,u])=>{i.style.setProperty(`--${l}`,u)})},getSavedTheme:()=>{try{const s=localStorage.getItem("openfox:theme");if(!s)return null;if(s[0]!=="{")return JSON.stringify({preset:s});const i=JSON.parse(s);if(i.preset)return JSON.stringify({preset:i.preset});if(i.tokens)return JSON.stringify({tokens:i.tokens})}catch{return null}return null},saveTheme:async s=>{localStorage.setItem("openfox:theme",s);const{useSettingsStore:i}=await mh(async()=>{const{useSettingsStore:l}=await Promise.resolve().then(()=>Bx);return{useSettingsStore:l}},void 0);await i.getState().setSetting(ot.DISPLAY_THEME,s)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[]})},addUserPreset:s=>{const{basePreset:i,customTokens:l,currentPreset:u}=r(),h={id:"custom-"+Date.now(),name:s,basePreset:i||u,tokens:{...l}},c=[...r().userPresets,h];e({userPresets:c}),r().saveUserPresets()},applyUserPreset:s=>{const i=r().userPresets[s];i&&(e({currentPreset:i.basePreset,basePreset:i.basePreset,customTokens:{...i.tokens},isCustom:!0,isCustomizing:!1}),r().applyTheme(),r().saveTheme(JSON.stringify({preset:i.basePreset,tokens:i.tokens})).catch(()=>{}))},deleteUserPreset:s=>{const i=r().userPresets.filter((l,u)=>u!==s);e({userPresets:i}),r().saveUserPresets()},loadUserPresets:()=>{e({userPresets:eb()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(r().userPresets)),mh(async()=>{const{useSettingsStore:s}=await Promise.resolve().then(()=>Bx);return{useSettingsStore:s}},void 0).then(({useSettingsStore:s})=>{s.getState().setSetting(ot.DISPLAY_USER_PRESETS,JSON.stringify(r().userPresets)).catch(()=>{})})}}));function vw({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Gv({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function yw({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function _w({className:e="w-3 h-3 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function Sw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function Ur({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function br({className:e="w-3 h-3 text-text-muted",rotate:r}){return o.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:r!==void 0?{transform:`rotate(${r}deg)`}:void 0,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function ww({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function zh({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function Cw({className:e="w-3 h-3"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function Ph({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("circle",{cx:"12",cy:"12",r:"2"}),o.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function lc({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function Hh({className:e="w-5 h-5 text-accent-primary"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function kw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})})}function Ew({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function jw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function Nw({className:e="w-3 h-3"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Tw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function tb({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function Kv({className:e="w-[18px] h-[18px]"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Aw({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),o.jsx("path",{d:"M9.5 2h4.5v4.5"}),o.jsx("path",{d:"M14 2L7.5 8.5"})]})}function Dw({className:e="w-3 h-3",color:r}){return o.jsx("svg",{className:e,fill:r??"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M8 5v14l11-7z"})})}function qi({className:e="w-3 h-3 text-accent-primary"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Rw({className:e="w-5 h-5"}){return o.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function Lw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function Ow({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function Mw({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return o.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[o.jsx("title",{children:"Running"}),o.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Yv({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function Iw({className:e="w-3.5 h-3.5 shrink-0",color:r}){return o.jsx("svg",{className:e,fill:"none",stroke:r,viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Bw({className:e="w-4 h-4"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function cc({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function Fh(){return o.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function zw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Xv({className:e="w-2.5 h-2.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Uh({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:o.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function Pw({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function gh(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}function nb(e,r){const s=Gt.ws;!s||s.readyState!==WebSocket.OPEN||s.send(JSON.stringify({id:gh(),type:e,payload:r}))}const ir=$n((e,r)=>({isOpen:!1,sessions:[],workdir:null,setOpen:s=>e({isOpen:s}),toggleOpen:()=>e(s=>({isOpen:!s.isOpen})),setWorkdir:s=>e({workdir:s}),fetchSessions:async s=>{if(!s){e({sessions:[]});return}try{const i=await ke(`/api/terminals?projectId=${encodeURIComponent(s)}`);if(i.ok){const l=await i.json();e({sessions:l});const u=Gt.ws;if(u&&u.readyState===WebSocket.OPEN)for(const h of l)u.send(JSON.stringify({id:gh(),type:"terminal.subscribe",payload:{sessionId:h.id}}))}}catch(i){console.error("Failed to fetch terminals:",i)}},createSession:async(s,i)=>{try{const l=await ke("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:s??r().workdir??void 0,projectId:i})});if(l.ok){const u=await l.json();e(c=>({sessions:[...c.sessions,u]}));const h=Gt.ws;h&&h.readyState===WebSocket.OPEN&&h.send(JSON.stringify({id:gh(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(l){console.error("Failed to create terminal:",l)}},writeSession:(s,i)=>{nb("terminal.write",{sessionId:s,data:i})},resizeSession:(s,i,l)=>{nb("terminal.resize",{sessionId:s,cols:i,rows:l})},killSession:async s=>{try{(await ke(`/api/terminals/${s}`,{method:"DELETE"})).ok&&e(l=>({sessions:l.sessions.filter(u=>u.id!==s)}))}catch(i){console.error("Failed to kill terminal:",i)}},handleMessage:s=>{switch(s.type){case"terminal.exit":{const{sessionId:i}=s.payload||{};i&&e(l=>{const u=l.sessions.filter(h=>h.id!==i);return u.length===0&&l.isOpen?{sessions:[],isOpen:!1}:{sessions:u}});break}}}}));Gt.subscribe(e=>{var r;(r=e.type)!=null&&r.startsWith("terminal.")&&ir.getState().handleMessage(e)});var Ki=Tv();const uc=P.forwardRef(({icon:e,iconSize:r="w-3.5 h-3.5",className:s="",...i},l)=>o.jsx("button",{ref:l,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${s}`,...i,children:o.jsx("svg",{className:r,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));uc.displayName="IconButton";const Hw="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",Wi=P.forwardRef((e,r)=>o.jsx(uc,{ref:r,icon:Hw,title:"Edit",...e}));Wi.displayName="EditButton";const Fw="M6 18L18 6M6 6l12 12",$h=P.forwardRef((e,r)=>o.jsx(uc,{ref:r,icon:Fw,...e}));$h.displayName="CloseButton";const Uw={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[90vh] flex-1"};function At({label:e,title:r,size:s="md",minHeight:i,children:l,footer:u,className:h,onClose:c,isOpen:d,closeOnBackdropClick:f=!0,closeOnEscape:g=!0,showCloseButton:m=!0}){const[v,S]=P.useState(!1),k=d!==void 0,C=k?d:v,y=P.useCallback(()=>{k||S(!0)},[k]),b=P.useCallback(()=>{k||S(!1),c==null||c()},[k,c]);P.useEffect(()=>{if(!C||!g)return;const _=j=>{j.key==="Escape"&&b()};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[C,b,g]);const x=e&&(typeof e=="string"?o.jsx("button",{type:"button",onClick:y,className:h,children:e}):o.jsx("span",{onClick:y,className:h,style:{cursor:"pointer"},children:e}));return o.jsxs(o.Fragment,{children:[x,C&&(typeof document<"u"?Ki.createPortal(o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:f?b:void 0}),o.jsxs("div",{className:`relative w-full ${Uw[s]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(r||m)&&o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r&&o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:r}),m&&o.jsx($h,{onClick:b,className:"ml-auto","aria-label":"Close"})]}),o.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:i?{minHeight:i}:void 0,children:l}),u&&o.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}const nt=P.forwardRef(({variant:e="secondary",size:r="md",className:s="",children:i,...l},u)=>{const h="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40",secondary:"bg-bg-tertiary text-text-primary hover:bg-border",danger:"bg-accent-error text-white hover:bg-accent-error/80"},d={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return o.jsx("button",{ref:u,className:`${h} ${c[e]} ${d[r]} ${s}`,...l,children:i})});nt.displayName="Button";function $w({value:e,defaultUrl:r,disabled:s,onChange:i}){const l=e??r;return o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:l,disabled:s,onChange:u=>{const h=u.target.value;i(h===r?null:h)},className:"appearance-none bg-bg-tertiary border border-border rounded px-1.5 pr-5 text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary disabled:opacity-40 cursor-pointer",style:{width:"60px"},children:ew.map(({url:u,label:h})=>o.jsx("option",{value:u,title:h,children:h.split(" ")[0]},u))}),o.jsx(br,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const rb=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function qw(){const e=Fs(d=>d.settings),r=Fs(d=>d.update),s=Fs(d=>d.updateEvent),i=Fs(d=>d.updateAgentOverride),l=Fs(d=>d.load);P.useEffect(()=>{l()},[l]);const u=async()=>{await nw()==="granted"&&r({...e,browserNotificationEnabled:!0})},h=(d,f,g,m)=>{d==="general"?s(f,{[g]:m}):i(d,f,{[g]:m})},c=(d,f,g)=>{d==="general"?s(f,{customSoundUrl:g}):i(d,f,{customSoundUrl:g})};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),o.jsx(sb,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>r({...e,soundEnabled:d})}),o.jsx(sb,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:d=>{d&&typeof Notification<"u"&&Notification.permission!=="granted"?u():r({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&o.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),o.jsx("div",{className:"border border-border rounded overflow-hidden",children:o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:o.jsxs("tr",{className:"border-b border-border",children:[o.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),rb.map(d=>o.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),o.jsx("tbody",{children:J1.map(d=>o.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[o.jsx("td",{className:"px-3 py-2",children:o.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),rb.map(f=>{const g=$v(e,d.key,f.key==="general"?void 0:f.key),m=Fv[d.key];return o.jsx("td",{className:"px-2 py-2 align-top",children:o.jsxs("div",{className:"flex flex-col items-center gap-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:o.jsx("input",{type:"checkbox",checked:g.soundEnabled,onChange:v=>h(f.key,d.key,"soundEnabled",v.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),o.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:o.jsx("input",{type:"checkbox",checked:g.browserNotification,onChange:v=>h(f.key,d.key,"browserNotification",v.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),g.soundEnabled&&e.soundEnabled&&o.jsx($w,{value:g.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:v=>c(f.key,d.key,v)})]})},f.key)})]},d.key))})]})})]})]})}function sb({label:e,description:r,checked:s,onChange:i}){return o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[o.jsx("div",{className:"pt-0.5",children:o.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${s?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:l=>{l.preventDefault(),i(!s)},children:o.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${s?"translate-x-4":"translate-x-0.5"}`})})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),o.jsx("div",{className:"text-xs text-text-muted",children:r})]})]})}async function qh(e,r){r({loading:!0});try{const i=await(await ke(e)).json();r({defaults:i.defaults??[],userItems:i.userItems??[],loading:!1})}catch{r({loading:!1})}}const Pr=$n((e,r)=>({defaults:[],userItems:[],loading:!1,fetchSkills:async()=>{await qh("/api/skills",e)},toggleSkill:async s=>{try{const l=await(await ke(`/api/skills/${s}/toggle`,{method:"POST"})).json();e(u=>({defaults:u.defaults.map(h=>h.id===s?{...h,enabled:l.enabled}:h),userItems:u.userItems.map(h=>h.id===s?{...h,enabled:l.enabled}:h)}))}catch{}},fetchSkill:async s=>{try{const i=await ke(`/api/skills/${s}`);return i.ok?await i.json():null}catch{return null}},fetchDefaultContent:async s=>{try{const i=await ke(`/api/skills/defaults/${s}`);return i.ok?await i.json():null}catch{return null}},createSkill:async s=>{const i=await xs("POST","/api/skills",s);return i.success&&await r().fetchSkills(),i},updateSkill:async(s,i)=>{const l=await xs("PUT",`/api/skills/${s}`,i);return l.success&&await r().fetchSkills(),l},deleteSkill:async s=>{try{const i=await ke(`/api/skills/${s}`,{method:"DELETE"}),l=await i.json();return i.ok?(e(u=>({userItems:u.userItems.filter(h=>h.id!==s)})),{success:!0}):{success:!1,error:l.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async s=>{try{const i=await ke(`/api/skills/${s}/duplicate`,{method:"POST"}),l=await i.json();return i.ok?(await r().fetchSkills(),{success:!0}):{success:!1,error:l.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}}}));function Wh(){const[e,r]=P.useState({id:null,type:null}),s=P.useCallback(u=>r({id:u,type:"delete"}),[]),i=P.useCallback(()=>r({id:null,type:null}),[]),l=P.useCallback((u,h)=>e.id===u&&e.type===h,[e.id,e.type]);return{requestDelete:s,clearConfirm:i,isConfirming:l}}function Vh({onConfirm:e,onCancel:r}){return o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),o.jsx("button",{onClick:r,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function Gh({onClick:e}){return o.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:o.jsx(cc,{})})}function oo({onClick:e}){return o.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:o.jsx(zh,{})})}function Us({label:e,value:r,onChange:s,placeholder:i,readOnly:l,hint:u,mono:h}){return o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,u&&o.jsx("span",{className:"text-text-muted ml-1",children:u})]}),o.jsx("input",{value:r,onChange:c=>s(c.target.value),readOnly:l,placeholder:i,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"font-mono":""} ${l?"opacity-60":""}`})]})}function Ww({onCancel:e,onSave:r,saving:s,saveDisabled:i}){return o.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[o.jsx(nt,{variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(nt,{variant:"primary",onClick:r,disabled:s||i,children:s?"Saving...":"Save"})]})}function Kh({message:e}){return o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function Zv({label:e="Custom",children:r}){return o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),o.jsx("div",{className:"space-y-2",children:r})]})}function Qv({description:e,onNew:r,newLabel:s="+ New"}){return o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("p",{className:"text-text-secondary text-sm",children:e}),o.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:o.jsx(nt,{variant:"primary",size:"sm",onClick:r,children:s})})]})}function Jv({isBuiltIn:e,isConfirmingDelete:r,onView:s,onEdit:i,onDuplicate:l,onDelete:u,children:h}){return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[o.jsx("div",{className:"min-w-0 flex-1 mr-3",children:h}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&s&&o.jsx("button",{onClick:s,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:o.jsx(lc,{})}),o.jsx(oo,{onClick:l}),!e&&i&&o.jsx(Wi,{onClick:i}),!e&&(r?o.jsx(Vh,{onConfirm:()=>{u==null||u()},onCancel:()=>{}}):o.jsx(Gh,{onClick:()=>u==null?void 0:u()}))]})]})}function Vw({id:e,name:r,description:s,isBuiltIn:i,isConfirmingDelete:l,onView:u,onEdit:h,onDuplicate:c,onDelete:d}){return o.jsxs(Jv,{isBuiltIn:i,isConfirmingDelete:l,onView:u,onEdit:h,onDuplicate:c,onDelete:d,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-text-primary text-sm font-medium",children:r}),o.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),s&&o.jsx("p",{className:"text-text-muted text-xs truncate",children:s})]})}function ey({loading:e,hasItems:r,loadingLabel:s,emptyLabel:i,children:l}){return e&&!r?o.jsx("div",{className:"text-text-muted text-sm",children:s}):r?o.jsx("div",{className:"space-y-4",children:l}):i?o.jsx("div",{className:"text-text-muted text-sm",children:i}):null}function ty({name:e,id:r,nameLabel:s="Name",idLabel:i="ID",namePlaceholder:l="My Item",idPlaceholder:u="my-item",nameHint:h,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:f,onIdChange:g}){return o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(Us,{label:s,value:e,onChange:f,placeholder:l,hint:h}),o.jsx(Us,{label:i,value:r,onChange:g,readOnly:c,placeholder:u,hint:c?d:void 0,mono:!0})]})}function ny(e={}){const{initialData:r={}}=e,[s,i]=P.useState("list"),[l,u]=P.useState(null),[h,c]=P.useState(""),[d,f]=P.useState(!1),[g,m]=P.useState(r),v=P.useCallback(()=>{m(r),c(""),u(null)},[r]),S=P.useCallback(b=>{i(b),b==="list"&&v()},[v]),k=P.useCallback(b=>{m(x=>typeof b=="function"?b(x):b)},[]),C=P.useCallback((b,x={})=>{u(b),i("edit"),m({...x}),c("")},[]),y=P.useCallback(()=>{u(null),i("edit"),m(r),c("")},[r]);return{view:s,editingId:l,formError:h,saving:d,formData:g,setView:S,setEditingId:u,setFormError:c,setFormData:k,setSaving:f,resetForm:v,startEditing:C,startNew:y}}function Yh(){return o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 mt-3 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[o.jsx("span",{children:"⚠️"}),o.jsx("p",{className:"text-text-secondary",children:"Editing this value now will have the side-effect of invalidating KV-cache, causing your next message in current sessions to take a long time to process. Consider doing this between sessions."})]})}function ib({skill:e,isBuiltIn:r,isConfirmingDelete:s,onView:i,onEdit:l,onDuplicate:u,onDelete:h}){return o.jsx(Vw,{id:e.id,name:e.name,description:e.description,isBuiltIn:r,isConfirmingDelete:s,onView:i,onEdit:l,onDuplicate:u,onDelete:h})}function Gw({isOpen:e}){const r=Pr(M=>M.defaults),s=Pr(M=>M.userItems),i=Pr(M=>M.loading),l=Pr(M=>M.fetchSkills),u=Pr(M=>M.fetchSkill),h=Pr(M=>M.fetchDefaultContent),c=Pr(M=>M.createSkill),d=Pr(M=>M.updateSkill),f=Pr(M=>M.deleteSkill),{view:g,editingId:m,formError:v,saving:S,formData:k,setView:C,setEditingId:y,setFormError:b,setFormData:x,setSaving:_}=ny(),{clearConfirm:j}=Wh();P.useEffect(()=>{e&&(l(),C("list"),y(null),j())},[e,l,j]);const T=(M,$,B,X)=>{x({name:X??M.metadata.name,id:B??M.metadata.id,description:M.metadata.description??"",version:M.metadata.version??"1.0.0",prompt:M.prompt,isReadOnly:$})},N=async M=>{if(r.some(B=>B.id===M)){const B=await h(M);if(!B)return;T(B,!0),y(M),b(""),C("edit")}else{const B=await u(M);if(!B)return;T(B,!0),y(M),b(""),C("edit")}},D=async M=>{const B=r.some(Q=>Q.id===M)?await h(M):await u(M);if(!B)return;const X=`${M}-copy-${Date.now()}`;T(B,!1,X,`${B.metadata.name} (copy)`),y(null),b(""),C("edit")},A=()=>{x({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1}),C("edit")},z=async M=>{const $=await u(M);$&&(T($,!1),y(M),b(""),C("edit"))},O=async M=>{await f(M),j()},q=async()=>{const M=m??k.id;if(!M||!k.name||!k.prompt){b("Name, ID, and prompt are required.");return}_(!0),b("");const $={metadata:{id:M,name:k.name,description:k.description,version:k.version},prompt:k.prompt},B=m?await d(m,$):await c($);if(_(!1),!B.success){b(B.error??"Failed to save skill.");return}C("list")},G=M=>{x($=>({...$,name:M})),m||x($=>({...$,id:M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},W=k.isReadOnly;return g==="edit"?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex justify-between items-center mb-3",children:[o.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:W?k.name:m?"Edit Skill":"New Skill"}),o.jsx("button",{onClick:()=>C("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),v&&o.jsx(Kh,{message:v}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(ty,{name:k.name,id:k.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:G,onIdChange:()=>{}}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(Us,{label:"Description",value:k.description,onChange:M=>x($=>({...$,description:M})),placeholder:"What this skill does...",readOnly:W}),o.jsx(Us,{label:"Version",value:k.version,onChange:M=>x($=>({...$,version:M})),placeholder:"1.0.0",readOnly:W})]})]}),o.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),o.jsx("textarea",{value:k.prompt,onChange:M=>x($=>({...$,prompt:M.target.value})),readOnly:W,placeholder:"The system prompt for this skill...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),o.jsx(Yh,{}),o.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[o.jsx(nt,{variant:"secondary",onClick:()=>C("list"),children:"Cancel"}),W?o.jsx(nt,{variant:"primary",onClick:()=>{x(M=>({...M,name:M.name+" (copy)",id:`${m}-copy-${Date.now()}`,isReadOnly:!1})),y(null)},children:"Duplicate & Customize"}):o.jsx(nt,{variant:"primary",onClick:q,disabled:S||!k.name||!k.id||!k.prompt,children:S?"Saving...":"Save"})]})]}):o.jsxs("div",{children:[o.jsx(Qv,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:A}),o.jsxs(ey,{loading:i,hasItems:r.length>0||s.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[r.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),o.jsx("div",{className:"space-y-2",children:r.map(M=>o.jsx(ib,{skill:M,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>N(M.id),onDuplicate:()=>D(M.id)},M.id))})]}),s.length>0&&o.jsx(Zv,{children:s.map(M=>o.jsx(ib,{skill:M,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>N(M.id),onEdit:()=>z(M.id),onDuplicate:()=>D(M.id),onDelete:()=>O(M.id)},M.id))})]})]})}function Kw(e){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r){const s=parseInt(r[1]??"0",16),i=parseInt(r[2]??"0",16),l=parseInt(r[3]??"0",16);return`${s} ${i} ${l}`}return e}function Hs(e){const r=e.split(" ").map(s=>parseInt(s,10));return r.length===3&&r.every(s=>!isNaN(s))?`#${r.map(s=>(s??0).toString(16).padStart(2,"0")).join("")}`:e}function Yw({isOpen:e,isNew:r,basePresetId:s,presetName:i,initialTokens:l,onClose:u,onSave:h}){const[c,d]=P.useState(l),[f,g]=P.useState(i);P.useEffect(()=>{d(l),g(i)},[l,i]);const m=(y,b)=>{const x=b.startsWith("#")?Kw(b):b;d(_=>({..._,[y]:x}))},v=()=>{h(f.trim()||"Untitled",{...c})},S=Vv.reduce((y,b)=>{const x=b.category;return y[x]||(y[x]=[]),y[x].push(b),y},{}),k={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},C=xr.find(y=>y.id===s);return o.jsx(At,{isOpen:e,onClose:u,size:"lg",title:r?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:o.jsxs("div",{className:"flex gap-2 justify-end",children:[o.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),o.jsx("button",{type:"button",onClick:v,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),o.jsx("input",{type:"text",value:f,onChange:y=>g(y.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!r&&o.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",o.jsx("span",{className:"text-text-primary",children:C==null?void 0:C.name})]}),Object.entries(S).map(([y,b])=>o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:k[y]??y}),o.jsx("div",{className:"grid grid-cols-2 gap-3",children:b.map(x=>o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("label",{htmlFor:x.key,className:"text-xs text-text-muted",children:x.label}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"color",id:x.key,value:Hs(c[x.key]??x.defaultValue),onChange:_=>m(x.key,_.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent"}),o.jsx("input",{type:"text",value:c[x.key]??x.defaultValue,onChange:_=>m(x.key,_.target.value),className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},x.key))})]},y))]})})}function Xw(){const[e,r]=P.useState(null),s=rn(x=>x.currentPreset),i=rn(x=>x.isCustom),l=rn(x=>x.basePreset),u=rn(x=>x.userPresets),h=rn(x=>x.applyPreset),c=rn(x=>x.applyUserPreset),d=rn(x=>x.deleteUserPreset),f=rn(x=>x.saveTheme),g=x=>{h(x),f(JSON.stringify({preset:x})).catch(()=>{})},m=x=>{c(x)},v=x=>{const _=xr.find(j=>j.id===x);_&&r({type:"new",presetIndex:u.length,basePresetId:x,presetName:_.name+" Copy",tokens:{..._.tokens}})},S=x=>{const _=u[x];if(!_)return;const j=xr.find(N=>N.id===_.basePreset),T=j?{...j.tokens,..._.tokens}:_.tokens;r({type:"edit",presetIndex:x,basePresetId:_.basePreset,presetName:_.name,tokens:T})},k=(x,_)=>{if(!e)return;const j=[...u];if(e.type==="new"){const T={id:"custom-"+Date.now(),name:x,basePreset:e.basePresetId,tokens:_};j.push(T);const N=j.length-1;rn.setState({userPresets:j}),rn.getState().saveUserPresets(),rn.getState().applyUserPreset(N)}else{const T=j[e.presetIndex];T&&(j[e.presetIndex]={...T,name:x,tokens:_}),rn.setState({userPresets:j}),rn.getState().saveUserPresets(),rn.getState().applyUserPreset(e.presetIndex)}r(null)},C=()=>{r(null)},y=(x,_)=>{x.stopPropagation(),d(_)},b=i?l:s;return o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),o.jsx("div",{className:"grid grid-cols-5 gap-2",children:xr.map(x=>o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>g(x.id),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${b===x.id&&!i?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[o.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:Hs(x.tokens["color-bg-primary"]??"#000"),borderColor:Hs(x.tokens["color-border"]??"#000")},children:o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Hs(x.tokens["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs",children:x.name})]}),o.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),v(x.id)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:o.jsx("span",{className:"text-xs",children:"✎"})})]},x.id))}),u.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),o.jsx("div",{className:"grid grid-cols-5 gap-2",children:u.map((x,_)=>{const j=xr.find(N=>N.id===x.basePreset),T=j?{...j.tokens,...x.tokens}:x.tokens;return o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>m(_),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${i&&l===x.basePreset&&b===x.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[o.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:Hs(T["color-bg-primary"]??"#000"),borderColor:Hs(T["color-border"]??"#000")},children:o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Hs(T["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs truncate w-full text-center",children:x.name})]}),o.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S(_)},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:o.jsx("span",{className:"text-xs",children:"✎"})}),o.jsx("button",{type:"button",onClick:N=>y(N,_),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:o.jsx(Uh,{className:"w-3 h-3"})})]},x.id)})})]}),e&&o.jsx(Yw,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:C,onSave:k})]})}function ry(){const e=gn(l=>l.settings),r=gn(l=>l.loading),s=gn(l=>l.getSetting),i=gn(l=>l.setSetting);return{settings:e,loading:r,getSetting:s,setSetting:i}}function Zw({isOpen:e,onClose:r}){const[s,i]=P.useState("instructions");return o.jsx(At,{isOpen:e,onClose:r,title:"Settings",size:"xl",minHeight:"500px",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[o.jsx(Va,{label:"Instructions",active:s==="instructions",onClick:()=>i("instructions")}),o.jsx(Va,{label:"Skills",active:s==="skills",onClick:()=>i("skills")}),o.jsx(Va,{label:"Notifications",active:s==="notifications",onClick:()=>i("notifications")}),o.jsx(Va,{label:"Display",active:s==="display",onClick:()=>i("display")}),o.jsx(Va,{label:"Advanced",active:s==="advanced",onClick:()=>i("advanced")})]}),s==="instructions"&&o.jsx(tC,{isOpen:e}),s==="skills"&&o.jsx(Gw,{isOpen:e}),s==="notifications"&&o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(qw,{})}),s==="display"&&o.jsx(eC,{}),s==="advanced"&&o.jsx(Qw,{onClose:r})]})})}function Qw({onClose:e}){const[,r]=lr();function s(){e(),r("/onboarding")}return o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),o.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),o.jsx(nt,{variant:"secondary",onClick:s,children:"Launch Onboarding"})]})})}function Jw(){return o.jsx(Xw,{})}function eC(){const{settings:e,loading:r,getSetting:s,setSetting:i}=ry(),l=r[ot.DISPLAY_SHOW_THINKING]??!1,u=[{key:ot.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:ot.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:ot.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:ot.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:ot.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],h=Object.fromEntries(u.map(g=>[g.key,e[g.key]??"true"])),[c,d]=P.useState(()=>Object.fromEntries(u.map(g=>[g.key,h[g.key]==="true"])));P.useEffect(()=>{u.forEach(g=>s(g.key))},[s]),P.useEffect(()=>{d(Object.fromEntries(u.map(g=>[g.key,h[g.key]==="true"])))},[JSON.stringify(h)]);const f=async g=>{const m=String(!c[g]);d(v=>({...v,[g]:!v[g]})),await i(g,m)};return l?o.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):o.jsxs("div",{className:"space-y-6",children:[o.jsx(Jw,{}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),o.jsx("div",{className:"space-y-4",children:u.map(({key:g,label:m,description:v})=>o.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm text-text-primary",children:m}),o.jsx("div",{className:"text-xs text-text-muted",children:v})]}),o.jsx("button",{type:"button",onClick:()=>f(g),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${c[g]?"bg-accent-primary":"bg-bg-tertiary"}`,children:o.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${c[g]?"translate-x-6":"translate-x-1"}`})})]},g))})]})]})}function Va({label:e,active:r,onClick:s}){return o.jsx("button",{onClick:s,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${r?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function tC({isOpen:e}){const{settings:r,loading:s,getSetting:i,setSetting:l}=ry(),u=r[ot.GLOBAL_INSTRUCTIONS]??"",h=s[ot.GLOBAL_INSTRUCTIONS]??!1,[c,d]=P.useState(u),[f,g]=P.useState(!1),[m,v]=P.useState(!1);P.useEffect(()=>{e&&i(ot.GLOBAL_INSTRUCTIONS)},[e,i]),P.useEffect(()=>{d(u),g(!1)},[u]);const S=async()=>{v(!0),await l(ot.GLOBAL_INSTRUCTIONS,c),v(!1),g(!1)},k=()=>{d(u),g(!1)},C=h||m;return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),o.jsx("textarea",{value:c,onChange:y=>{d(y.target.value),g(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),f&&o.jsx(Yh,{}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(nt,{variant:"secondary",onClick:k,disabled:!f,children:"Discard"}),o.jsx(nt,{variant:"primary",onClick:S,disabled:!f||C,children:m?"Saving...":"Save"})]})]})}var qd={exports:{}},ab;function nC(){return ab||(ab=1,(function(e,r){(function(s,i){e.exports=i()})(globalThis,(()=>(()=>{var s={4567:function(h,c,d){var f=this&&this.__decorate||function(x,_,j,T){var N,D=arguments.length,A=D<3?_:T===null?T=Object.getOwnPropertyDescriptor(_,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(x,_,j,T);else for(var z=x.length-1;z>=0;z--)(N=x[z])&&(A=(D<3?N(A):D>3?N(_,j,A):N(_,j))||A);return D>3&&A&&Object.defineProperty(_,j,A),A},g=this&&this.__param||function(x,_){return function(j,T){_(j,T,x)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),v=d(9924),S=d(844),k=d(4725),C=d(2585),y=d(3656);let b=c.AccessibilityManager=class extends S.Disposable{constructor(x,_,j,T){super(),this._terminal=x,this._coreBrowserService=j,this._renderService=T,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new v.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
58
58
  `)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,y.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(x){for(let _=0;_<x;_++)this._handleChar(" ")}_handleChar(x){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==x&&(this._charsToAnnounce+=x):this._charsToAnnounce+=x,x===`
59
59
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(x){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(x)||this._charsToConsume.push(x)}_refreshRows(x,_){this._liveRegionDebouncer.refresh(x,_,this._terminal.rows)}_renderRows(x,_){const j=this._terminal.buffer,T=j.lines.length.toString();for(let N=x;N<=_;N++){const D=j.lines.get(j.ydisp+N),A=[],z=(D==null?void 0:D.translateToString(!0,void 0,void 0,A))||"",O=(j.ydisp+N+1).toString(),q=this._rowElements[N];q&&(z.length===0?(q.innerText=" ",this._rowColumns.set(q,[0,1])):(q.textContent=z,this._rowColumns.set(q,A)),q.setAttribute("aria-posinset",O),q.setAttribute("aria-setsize",T))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(x,_){const j=x.target,T=this._rowElements[_===0?1:this._rowElements.length-2];if(j.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||x.relatedTarget!==T)return;let N,D;if(_===0?(N=j,D=this._rowElements.pop(),this._rowContainer.removeChild(D)):(N=this._rowElements.shift(),D=j,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),D.removeEventListener("focus",this._bottomBoundaryFocusListener),_===0){const A=this._createAccessibilityTreeNode();this._rowElements.unshift(A),this._rowContainer.insertAdjacentElement("afterbegin",A)}else{const A=this._createAccessibilityTreeNode();this._rowElements.push(A),this._rowContainer.appendChild(A)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),x.preventDefault(),x.stopImmediatePropagation()}_handleSelectionChange(){var z;if(this._rowElements.length===0)return;const x=document.getSelection();if(!x)return;if(x.isCollapsed)return void(this._rowContainer.contains(x.anchorNode)&&this._terminal.clearSelection());if(!x.anchorNode||!x.focusNode)return void console.error("anchorNode and/or focusNode are null");let _={node:x.anchorNode,offset:x.anchorOffset},j={node:x.focusNode,offset:x.focusOffset};if((_.node.compareDocumentPosition(j.node)&Node.DOCUMENT_POSITION_PRECEDING||_.node===j.node&&_.offset>j.offset)&&([_,j]=[j,_]),_.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(_={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(_.node))return;const T=this._rowElements.slice(-1)[0];if(j.node.compareDocumentPosition(T)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(j={node:T,offset:((z=T.textContent)==null?void 0:z.length)??0}),!this._rowContainer.contains(j.node))return;const N=({node:O,offset:q})=>{const G=O instanceof Text?O.parentNode:O;let W=parseInt(G==null?void 0:G.getAttribute("aria-posinset"),10)-1;if(isNaN(W))return console.warn("row is invalid. Race condition?"),null;const M=this._rowColumns.get(G);if(!M)return console.warn("columns is null. Race condition?"),null;let $=q<M.length?M[q]:M.slice(-1)[0]+1;return $>=this._terminal.cols&&(++W,$=0),{row:W,column:$}},D=N(_),A=N(j);if(D&&A){if(D.row>A.row||D.row===A.row&&D.column>=A.column)throw new Error("invalid range");this._terminal.select(D.column,D.row,(A.row-D.row)*this._terminal.cols-D.column+A.column)}}_handleResize(x){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>x;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const x=this._coreBrowserService.mainDocument.createElement("div");return x.setAttribute("role","listitem"),x.tabIndex=-1,this._refreshRowDimensions(x),x}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let x=0;x<this._terminal.rows;x++)this._refreshRowDimensions(this._rowElements[x])}}_refreshRowDimensions(x){x.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=b=f([g(1,C.IInstantiationService),g(2,k.ICoreBrowserService),g(3,k.IRenderService)],b)},3614:(h,c)=>{function d(v){return v.replace(/\r?\n/g,"\r")}function f(v,S){return S?"\x1B[200~"+v+"\x1B[201~":v}function g(v,S,k,C){v=f(v=d(v),k.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),k.triggerDataEvent(v,!0),S.value=""}function m(v,S,k){const C=k.getBoundingClientRect(),y=v.clientX-C.left-10,b=v.clientY-C.top-10;S.style.width="20px",S.style.height="20px",S.style.left=`${y}px`,S.style.top=`${b}px`,S.style.zIndex="1000",S.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=d,c.bracketTextForPaste=f,c.copyHandler=function(v,S){v.clipboardData&&v.clipboardData.setData("text/plain",S.selectionText),v.preventDefault()},c.handlePasteEvent=function(v,S,k,C){v.stopPropagation(),v.clipboardData&&g(v.clipboardData.getData("text/plain"),S,k,C)},c.paste=g,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(v,S,k,C,y){m(v,S,k),y&&C.rightClickSelect(v),S.value=C.selectionText,S.select()}},7239:(h,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const f=d(1505);c.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(g,m,v){this._css.set(g,m,v)}getCss(g,m){return this._css.get(g,m)}setColor(g,m,v){this._color.set(g,m,v)}getColor(g,m){return this._color.get(g,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(h,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(d,f,g,m){d.addEventListener(f,g,m);let v=!1;return{dispose:()=>{v||(v=!0,d.removeEventListener(f,g,m))}}}},3551:function(h,c,d){var f=this&&this.__decorate||function(b,x,_,j){var T,N=arguments.length,D=N<3?x:j===null?j=Object.getOwnPropertyDescriptor(x,_):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(b,x,_,j);else for(var A=b.length-1;A>=0;A--)(T=b[A])&&(D=(N<3?T(D):N>3?T(x,_,D):T(x,_))||D);return N>3&&D&&Object.defineProperty(x,_,D),D},g=this&&this.__param||function(b,x){return function(_,j){x(_,j,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const m=d(3656),v=d(8460),S=d(844),k=d(2585),C=d(4725);let y=c.Linkifier=class extends S.Disposable{get currentLink(){return this._currentLink}constructor(b,x,_,j,T){super(),this._element=b,this._mouseService=x,this._renderService=_,this._bufferService=j,this._linkProviderService=T,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new v.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new v.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,S.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,S.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(b){this._lastMouseEvent=b;const x=this._positionFromMouseEvent(b,this._element,this._mouseService);if(!x)return;this._isMouseOut=!1;const _=b.composedPath();for(let j=0;j<_.length;j++){const T=_[j];if(T.classList.contains("xterm"))break;if(T.classList.contains("xterm-hover"))return}this._lastBufferCell&&x.x===this._lastBufferCell.x&&x.y===this._lastBufferCell.y||(this._handleHover(x),this._lastBufferCell=x)}_handleHover(b){if(this._activeLine!==b.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(b,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,b)||(this._clearCurrentLink(),this._askForLink(b,!0))}_askForLink(b,x){var j,T;this._activeProviderReplies&&x||((j=this._activeProviderReplies)==null||j.forEach((N=>{N==null||N.forEach((D=>{D.link.dispose&&D.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=b.y);let _=!1;for(const[N,D]of this._linkProviderService.linkProviders.entries())x?(T=this._activeProviderReplies)!=null&&T.get(N)&&(_=this._checkLinkProviderResult(N,b,_)):D.provideLinks(b.y,(A=>{var O,q;if(this._isMouseOut)return;const z=A==null?void 0:A.map((G=>({link:G})));(O=this._activeProviderReplies)==null||O.set(N,z),_=this._checkLinkProviderResult(N,b,_),((q=this._activeProviderReplies)==null?void 0:q.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(b.y,this._activeProviderReplies)}))}_removeIntersectingLinks(b,x){const _=new Set;for(let j=0;j<x.size;j++){const T=x.get(j);if(T)for(let N=0;N<T.length;N++){const D=T[N],A=D.link.range.start.y<b?0:D.link.range.start.x,z=D.link.range.end.y>b?this._bufferService.cols:D.link.range.end.x;for(let O=A;O<=z;O++){if(_.has(O)){T.splice(N--,1);break}_.add(O)}}}}_checkLinkProviderResult(b,x,_){var N;if(!this._activeProviderReplies)return _;const j=this._activeProviderReplies.get(b);let T=!1;for(let D=0;D<b;D++)this._activeProviderReplies.has(D)&&!this._activeProviderReplies.get(D)||(T=!0);if(!T&&j){const D=j.find((A=>this._linkAtPosition(A.link,x)));D&&(_=!0,this._handleNewLink(D))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!_)for(let D=0;D<this._activeProviderReplies.size;D++){const A=(N=this._activeProviderReplies.get(D))==null?void 0:N.find((z=>this._linkAtPosition(z.link,x)));if(A){_=!0,this._handleNewLink(A);break}}return _}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(b){if(!this._currentLink)return;const x=this._positionFromMouseEvent(b,this._element,this._mouseService);x&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,x)&&this._currentLink.link.activate(b,this._currentLink.link.text)}_clearCurrentLink(b,x){this._currentLink&&this._lastMouseEvent&&(!b||!x||this._currentLink.link.range.start.y>=b&&this._currentLink.link.range.end.y<=x)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,S.disposeArray)(this._linkCacheDisposables))}_handleNewLink(b){if(!this._lastMouseEvent)return;const x=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);x&&this._linkAtPosition(b.link,x)&&(this._currentLink=b,this._currentLink.state={decorations:{underline:b.link.decorations===void 0||b.link.decorations.underline,pointerCursor:b.link.decorations===void 0||b.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,b.link,this._lastMouseEvent),b.link.decorations={},Object.defineProperties(b.link.decorations,{pointerCursor:{get:()=>{var _,j;return(j=(_=this._currentLink)==null?void 0:_.state)==null?void 0:j.decorations.pointerCursor},set:_=>{var j;(j=this._currentLink)!=null&&j.state&&this._currentLink.state.decorations.pointerCursor!==_&&(this._currentLink.state.decorations.pointerCursor=_,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",_))}},underline:{get:()=>{var _,j;return(j=(_=this._currentLink)==null?void 0:_.state)==null?void 0:j.decorations.underline},set:_=>{var j,T,N;(j=this._currentLink)!=null&&j.state&&((N=(T=this._currentLink)==null?void 0:T.state)==null?void 0:N.decorations.underline)!==_&&(this._currentLink.state.decorations.underline=_,this._currentLink.state.isHovered&&this._fireUnderlineEvent(b.link,_))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((_=>{if(!this._currentLink)return;const j=_.start===0?0:_.start+1+this._bufferService.buffer.ydisp,T=this._bufferService.buffer.ydisp+1+_.end;if(this._currentLink.link.range.start.y>=j&&this._currentLink.link.range.end.y<=T&&(this._clearCurrentLink(j,T),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(b,x,_){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(x,!0),this._currentLink.state.decorations.pointerCursor&&b.classList.add("xterm-cursor-pointer")),x.hover&&x.hover(_,x.text)}_fireUnderlineEvent(b,x){const _=b.range,j=this._bufferService.buffer.ydisp,T=this._createLinkUnderlineEvent(_.start.x-1,_.start.y-j-1,_.end.x,_.end.y-j-1,void 0);(x?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(T)}_linkLeave(b,x,_){var j;(j=this._currentLink)!=null&&j.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(x,!1),this._currentLink.state.decorations.pointerCursor&&b.classList.remove("xterm-cursor-pointer")),x.leave&&x.leave(_,x.text)}_linkAtPosition(b,x){const _=b.range.start.y*this._bufferService.cols+b.range.start.x,j=b.range.end.y*this._bufferService.cols+b.range.end.x,T=x.y*this._bufferService.cols+x.x;return _<=T&&T<=j}_positionFromMouseEvent(b,x,_){const j=_.getCoords(b,x,this._bufferService.cols,this._bufferService.rows);if(j)return{x:j[0],y:j[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(b,x,_,j,T){return{x1:b,y1:x,x2:_,y2:j,cols:this._bufferService.cols,fg:T}}};c.Linkifier=y=f([g(1,C.IMouseService),g(2,C.IRenderService),g(3,k.IBufferService),g(4,C.ILinkProviderService)],y)},9042:(h,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(h,c,d){var f=this&&this.__decorate||function(C,y,b,x){var _,j=arguments.length,T=j<3?y:x===null?x=Object.getOwnPropertyDescriptor(y,b):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(C,y,b,x);else for(var N=C.length-1;N>=0;N--)(_=C[N])&&(T=(j<3?_(T):j>3?_(y,b,T):_(y,b))||T);return j>3&&T&&Object.defineProperty(y,b,T),T},g=this&&this.__param||function(C,y){return function(b,x){y(b,x,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=d(511),v=d(2585);let S=c.OscLinkProvider=class{constructor(C,y,b){this._bufferService=C,this._optionsService=y,this._oscLinkService=b}provideLinks(C,y){var z;const b=this._bufferService.buffer.lines.get(C-1);if(!b)return void y(void 0);const x=[],_=this._optionsService.rawOptions.linkHandler,j=new m.CellData,T=b.getTrimmedLength();let N=-1,D=-1,A=!1;for(let O=0;O<T;O++)if(D!==-1||b.hasContent(O)){if(b.loadCell(O,j),j.hasExtendedAttrs()&&j.extended.urlId){if(D===-1){D=O,N=j.extended.urlId;continue}A=j.extended.urlId!==N}else D!==-1&&(A=!0);if(A||D!==-1&&O===T-1){const q=(z=this._oscLinkService.getLinkData(N))==null?void 0:z.uri;if(q){const G={start:{x:D+1,y:C},end:{x:O+(A||O!==T-1?0:1),y:C}};let W=!1;if(!(_!=null&&_.allowNonHttpProtocols))try{const M=new URL(q);["http:","https:"].includes(M.protocol)||(W=!0)}catch{W=!0}W||x.push({text:q,range:G,activate:(M,$)=>_?_.activate(M,$,G):k(0,$),hover:(M,$)=>{var B;return(B=_==null?void 0:_.hover)==null?void 0:B.call(_,M,$,G)},leave:(M,$)=>{var B;return(B=_==null?void 0:_.leave)==null?void 0:B.call(_,M,$,G)}})}A=!1,j.hasExtendedAttrs()&&j.extended.urlId?(D=O,N=j.extended.urlId):(D=-1,N=-1)}}y(x)}};function k(C,y){if(confirm(`Do you want to navigate to ${y}?
60
60
 
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/png" href="/assets/openfox.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0, height=device-height" />
7
7
  <title>OpenFox</title>
8
- <script type="module" crossorigin src="/assets/index-0igqGWob.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-BJtUJYiT.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-D4Si0Pmc.css">
10
10
  <link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
11
11
  <body class="bg-bg-primary text-text-primary font-mono">
package/dist/web/sw.js CHANGED
@@ -1 +1 @@
1
- if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const l=e=>i(e,t),c={module:{uri:t},exports:o,require:l};s[t]=Promise.all(n.map(e=>c[e]||l(e))).then(e=>(r(...e),o))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"a8195d955f4ef96de0255dcecda42a34"},{url:"__inspect__.js",revision:"878b477aaf1805c028895f3d3bb4af71"},{url:"assets/index-D4Si0Pmc.css",revision:null},{url:"assets/index-0igqGWob.js",revision:null},{url:"assets/html2canvas.esm-QH1iLAAe.js",revision:null},{url:"assets/openfox-192.png",revision:"79feeb86d692c274854e37959a7dae67"},{url:"assets/openfox-512.png",revision:"fee24b214220594b4f595a467e73036e"},{url:"manifest.webmanifest",revision:"c25f372c782e623ab1e768a8dfe350ca"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
1
+ if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const l=e=>i(e,t),f={module:{uri:t},exports:o,require:l};s[t]=Promise.all(n.map(e=>f[e]||l(e))).then(e=>(r(...e),o))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"40b4768ec98f247dd6d0bfc87f70ff95"},{url:"__inspect__.js",revision:"878b477aaf1805c028895f3d3bb4af71"},{url:"assets/index-D4Si0Pmc.css",revision:null},{url:"assets/index-BJtUJYiT.js",revision:null},{url:"assets/html2canvas.esm-QH1iLAAe.js",revision:null},{url:"assets/openfox-192.png",revision:"79feeb86d692c274854e37959a7dae67"},{url:"assets/openfox-512.png",revision:"fee24b214220594b4f595a467e73036e"},{url:"manifest.webmanifest",revision:"c25f372c782e623ab1e768a8dfe350ca"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfox",
3
- "version": "1.6.78",
3
+ "version": "1.6.79",
4
4
  "description": "Local-LLM-first agentic coding assistant",
5
5
  "type": "module",
6
6
  "bin": {