openfox 1.6.98 → 1.6.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-I2EVVAG4.js → chunk-6UBQ4BNN.js} +4 -4
- package/dist/{chunk-LC6HW727.js → chunk-QAMG73V3.js} +2 -2
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/package.json +1 -1
- package/dist/{serve-FD3A43KR.js → serve-65V7N6ZV.js} +2 -2
- package/dist/server/index.js +1 -1
- package/dist/{service-3CLVG2HV.js → service-EUOBAATS.js} +2 -1
- package/dist/web/assets/{index-BhmZRmbE.js → index-BEkw-EHs.js} +2 -2
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
|
@@ -156,7 +156,7 @@ async function runCli(options) {
|
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
158
158
|
case "service": {
|
|
159
|
-
const { runServiceCommand } = await import("./service-
|
|
159
|
+
const { runServiceCommand } = await import("./service-EUOBAATS.js");
|
|
160
160
|
const [, subcommand] = positionals;
|
|
161
161
|
if (subcommand === "--help" || subcommand === "-h" || values.help) {
|
|
162
162
|
runServiceCommand(mode, void 0);
|
|
@@ -178,7 +178,7 @@ async function runCli(options) {
|
|
|
178
178
|
case "update": {
|
|
179
179
|
const __filename = fileURLToPath(import.meta.url);
|
|
180
180
|
const __dirname = dirname(__filename);
|
|
181
|
-
const updateScriptPath = join(__dirname, "
|
|
181
|
+
const updateScriptPath = join(__dirname, "update.sh");
|
|
182
182
|
const result = spawnSync(updateScriptPath, [], { shell: true, stdio: "inherit" });
|
|
183
183
|
if (result.status !== 0) {
|
|
184
184
|
process.exit(result.status ?? 1);
|
|
@@ -191,7 +191,7 @@ async function runCli(options) {
|
|
|
191
191
|
if (!configExists) {
|
|
192
192
|
await runNetworkSetup(mode);
|
|
193
193
|
}
|
|
194
|
-
const { runServe } = await import("./serve-
|
|
194
|
+
const { runServe } = await import("./serve-65V7N6ZV.js");
|
|
195
195
|
const serveOptions = { mode };
|
|
196
196
|
if (values.port) serveOptions.port = parseInt(values.port);
|
|
197
197
|
if (values["no-browser"] === true) serveOptions.openBrowser = false;
|
|
@@ -203,4 +203,4 @@ async function runCli(options) {
|
|
|
203
203
|
export {
|
|
204
204
|
runCli
|
|
205
205
|
};
|
|
206
|
-
//# sourceMappingURL=chunk-
|
|
206
|
+
//# sourceMappingURL=chunk-6UBQ4BNN.js.map
|
|
@@ -5384,7 +5384,7 @@ import { Router as Router6 } from "express";
|
|
|
5384
5384
|
import { spawn as spawn4 } from "child_process";
|
|
5385
5385
|
|
|
5386
5386
|
// src/constants.ts
|
|
5387
|
-
var VERSION = "1.6.
|
|
5387
|
+
var VERSION = "1.6.99";
|
|
5388
5388
|
|
|
5389
5389
|
// src/server/routes/auto-update.ts
|
|
5390
5390
|
var updateInProgress = false;
|
|
@@ -6488,4 +6488,4 @@ export {
|
|
|
6488
6488
|
createServerHandle,
|
|
6489
6489
|
createServer
|
|
6490
6490
|
};
|
|
6491
|
-
//# sourceMappingURL=chunk-
|
|
6491
|
+
//# sourceMappingURL=chunk-QAMG73V3.js.map
|
package/dist/cli/dev.js
CHANGED
package/dist/cli/index.js
CHANGED
package/dist/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
VERSION,
|
|
8
8
|
createServer
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QAMG73V3.js";
|
|
10
10
|
import "./chunk-K7F73QLL.js";
|
|
11
11
|
import "./chunk-KR7N2ONG.js";
|
|
12
12
|
import "./chunk-ROWFVGB6.js";
|
|
@@ -190,4 +190,4 @@ async function runServe(options) {
|
|
|
190
190
|
export {
|
|
191
191
|
runServe
|
|
192
192
|
};
|
|
193
|
-
//# sourceMappingURL=serve-
|
|
193
|
+
//# sourceMappingURL=serve-65V7N6ZV.js.map
|
package/dist/server/index.js
CHANGED
|
@@ -113,6 +113,7 @@ Type=simple
|
|
|
113
113
|
ExecStart=${expandPath(RUN_SCRIPT_PATH)}
|
|
114
114
|
Restart=always
|
|
115
115
|
RestartSec=5
|
|
116
|
+
KillMode=process
|
|
116
117
|
|
|
117
118
|
[Install]
|
|
118
119
|
WantedBy=graphical-session.target
|
|
@@ -275,4 +276,4 @@ async function serviceUninstall() {
|
|
|
275
276
|
export {
|
|
276
277
|
runServiceCommand
|
|
277
278
|
};
|
|
278
|
-
//# sourceMappingURL=service-
|
|
279
|
+
//# sourceMappingURL=service-EUOBAATS.js.map
|
|
@@ -55,7 +55,7 @@ Error generating stack: `+g.message+`
|
|
|
55
55
|
*
|
|
56
56
|
* This source code is licensed under the MIT license found in the
|
|
57
57
|
* LICENSE file in the root directory of this source tree.
|
|
58
|
-
*/var ov;function e2(){if(ov)return vf;ov=1;var e=Su();function t(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function l(m,x){var _=x(),w=s({inst:{value:_,getSnapshot:x}}),k=w[0].inst,v=w[1];return o(function(){k.value=_,k.getSnapshot=x,h(k)&&v({inst:k})},[m,_,x]),a(function(){return h(k)&&v({inst:k}),m(function(){h(k)&&v({inst:k})})},[m]),c(_),_}function h(m){var x=m.getSnapshot;m=m.value;try{var _=x();return!n(m,_)}catch{return!0}}function f(m,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return vf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,vf}var lv;function t2(){return lv||(lv=1,yf.exports=e2()),yf.exports}var n2=t2();const r2=HE.useInsertionEffect,s2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",i2=s2?O.useLayoutEffect:O.useEffect,a2=r2||i2,H0=e=>{const t=O.useRef([e,(...n)=>t[0](...n)]).current;return a2(()=>{t[0]=e}),t[1]},o2="popstate",Gm="pushState",Wm="replaceState",l2="hashchange",cv=[o2,Gm,Wm,l2],c2=e=>{for(const t of cv)addEventListener(t,e);return()=>{for(const t of cv)removeEventListener(t,e)}},$0=(e,t)=>n2.useSyncExternalStore(c2,e,t),uv=()=>location.search,u2=({ssrSearch:e}={})=>$0(uv,e!=null?()=>e:uv),dv=()=>location.pathname,d2=({ssrPath:e}={})=>$0(dv,e!=null?()=>e:dv),h2=(e,{replace:t=!1,state:n=null}={})=>history[t?Wm:Gm](n,"",e),f2=(e={})=>[d2(e),h2],hv=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[hv]>"u"){for(const e of[Gm,Wm]){const t=history[e];history[e]=function(){const n=t.apply(this,arguments),s=new Event(e);return s.arguments=arguments,dispatchEvent(s),n}}Object.defineProperty(window,hv,{value:!0})}const m2=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",U0=(e="")=>e==="/"?"":e,p2=(e,t)=>e[0]==="~"?e.slice(1):U0(t)+e,g2=(e="",t)=>m2(fv(U0(e)),fv(t)),fv=e=>{try{return decodeURI(e)}catch{return e}},F0={hook:f2,searchHook:u2,parser:ZE,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},V0=O.createContext(F0),Ia=()=>O.useContext(V0),G0={},W0=O.createContext(G0),x2=()=>O.useContext(W0),Cu=e=>{const[t,n]=e.hook(e);return[g2(e.base,t),H0((s,a)=>e.aroundNav(n,p2(s,e.base),a))]},wr=()=>Cu(Ia()),qm=(e,t,n,s)=>{const{pattern:a,keys:o}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",s),c=a.exec(n)||[],[l,...h]=c;return l!==void 0?[!0,(()=>{const f=o!==!1?Object.fromEntries(o.map((m,x)=>[m,h[x]])):c.groups;let p={...h};return f&&Object.assign(p,f),p})(),...s?[l]:[]]:[!1,null]},Km=e=>qm(Ia().parser,e,wr()[0]),_2=({children:e,...t})=>{var p,m,x;const n=Ia(),s=t.hook?F0:n;let a=s;const[o,c=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];o&&(t.ssrSearch=c,t.ssrPath=o),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let l=O.useRef({}),h=l.current,f=h;for(let _ in s){const w=_==="base"?s[_]+(t[_]??""):t[_]??s[_];h===f&&w!==f[_]&&(l.current=f={...f}),f[_]=w,(w!==s[_]||w!==a[_])&&(a=f)}return O.createElement(V0.Provider,{value:a,children:e})},mv=({children:e,component:t},n)=>t?O.createElement(t,{params:n}):typeof e=="function"?e(n):e,y2=e=>{let t=O.useRef(G0);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([s,a])=>a!==n[s])?e:n},Mo=({path:e,nest:t,match:n,...s})=>{const a=Ia(),[o]=Cu(a),[c,l,h]=n??qm(a.parser,e,o,t),f=y2({...x2(),...l});if(!c)return null;const p=h?O.createElement(_2,{base:h},mv(s,f)):mv(s,f);return O.createElement(W0.Provider,{value:f,children:p})},Xn=O.forwardRef((e,t)=>{const n=Ia(),[s,a]=Cu(n),{to:o="",href:c=o,onClick:l,asChild:h,children:f,className:p,replace:m,state:x,transition:_,...w}=e,k=H0(b=>{b.ctrlKey||b.metaKey||b.altKey||b.shiftKey||b.button!==0||(l==null||l(b),b.defaultPrevented||(b.preventDefault(),a(c,e)))}),v=n.hrefs(c[0]==="~"?c.slice(1):n.base+c,n);return h&&O.isValidElement(f)?O.cloneElement(f,{onClick:k,href:v}):O.createElement("a",{...w,onClick:k,href:v,className:p!=null&&p.call?p(s===c):p,children:f,ref:t})}),q0=e=>Array.isArray(e)?e.flatMap(t=>q0(t&&t.type===O.Fragment?t.props.children:t)):[e],v2=({children:e,location:t})=>{const n=Ia(),[s]=Cu(n);for(const a of q0(e)){let o=0;if(O.isValidElement(a)&&(o=qm(n.parser,a.props.path,t||s,a.props.nest))[0])return O.cloneElement(a,{match:o})}return null};function b2(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function K0(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class S2{constructor(t){me(this,"ws",null);me(this,"handlers",new Set);me(this,"statusHandler",null);me(this,"baseUrl");me(this,"isReconnecting",!1);me(this,"connectingPromise",null);me(this,"lastCloseCode",0);me(this,"reconnectAttempts",0);me(this,"manualReconnectScheduled",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,s;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((s=this.ws)==null?void 0:s.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,o)=>{try{const c=this.getUrl();this.ws=new WebSocket(c);const l=setTimeout(()=>{var h;((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING&&(this.ws.close(),o(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var h;clearTimeout(l),this.isReconnecting=!1,this.connectingPromise=null,(h=this.statusHandler)==null||h.call(this,"connected"),a()},this.ws.onclose=h=>{var f,p,m;clearTimeout(l),this.lastCloseCode=h.code,((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),o(new Error(`Connection closed: ${h.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=h=>{clearTimeout(l),console.error("WebSocket error:",h),this.connectingPromise=null,o(h)},this.ws.onmessage=h=>{try{const f=JSON.parse(h.data);b2(f)&&this.handlers.forEach(p=>p(f))}catch(f){console.error("Failed to parse WebSocket message:",f)}}}catch(c){this.connectingPromise=null,o(c)}}),this.connectingPromise)))}attemptReconnect(){var a;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(a=this.statusHandler)==null||a.call(this,"reconnecting");const s=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(()=>{})},s)}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(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const s=K0(),a={id:s,type:t,payload:n};return this.ws.send(JSON.stringify(a)),s}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const w2=window.location.protocol==="https:"?"wss:":"ws:";let cm=window.location.port;cm||(cm=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const C2=`${w2}//${window.location.hostname}:${cm}/ws`,Zt=new S2(C2),Vs=async(e,t,n)=>{try{const s=await je(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return s.ok?{success:!0}:{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}},ku=async(e,t,n)=>{try{const s=await je(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await s.json();return s.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function Y0(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Rc=[];const Rr=Jn()((e,t)=>{function n(){if(Rc.length===0)return;const a=Rc;Rc=[],e(o=>({logs:[...o.logs,...a]}))}const s=Y0(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:a=>{t().workdir!==a&&(e({workdir:a,status:null,logs:[],config:null,loading:!0}),a&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:c,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:c.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const l=(await(await je(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(h=>({stream:h.stream,content:h.content}));e({logs:l})}catch{}},start:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},saveConfig:async a=>{const o=t().workdir;if(o)try{const l=await(await je(`/api/dev-server/config?workdir=${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:l.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const o=t().workdir;if(o)switch(a.type){case"devServer.output":{const c=a.payload;if(c.workdir!==o)return;Rc.push({stream:c.stream,content:c.content}),s();break}case"devServer.state":{const c=a.payload;if(c.workdir!==o)return;e(l=>({status:l.status?{...l.status,state:c.state,errorMessage:c.errorMessage}:l.status}));break}}}}});function k2(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 pv(e,t,n){const s=await je(`/api/providers/${e}/models/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok){const a=await s.json();throw new Error(a.error??"Failed to update model")}return s.json()}function gv(e,t,n,s){return e.map(a=>a.id===t?{...a,models:a.models.map(o=>o.id===n?{...o,...s,source:"user"}:o)}:a)}const E2=3e4;function j2(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 Dt=Jn((e,t)=>({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 n=await je("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const s=await n.json();e({version:s.version,model:s.model,maxContext:s.maxContext,llmUrl:s.llmUrl,llmStatus:s.llmStatus,backend:s.backend,providers:s.providers??[],activeProviderId:s.activeProviderId??null,defaultModelSelection:s.defaultModelSelection??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await je("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const s=await n.json(),o=Ce.getState().currentSession;if(o!=null&&o.providerId&&o.providerModel){e({llmStatus:s.llmStatus,backend:s.backend});return}e({model:s.model,llmStatus:s.llmStatus,backend:s.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:s,providers:a}=t();if(n===s)return!0;e({activating:!0,error:null});try{const o=await je(`/api/providers/${n}/activate`,{method:"POST"});if(!o.ok){const l=await o.json();throw new Error(l.error??"Failed to activate provider")}const c=await o.json();return e({activeProviderId:c.activeProviderId,model:c.model,backend:c.backend,providers:a.map(l=>({...l,isActive:l.id===c.activeProviderId})),activating:!1}),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(n,s)=>{var l;const{providers:a,defaultModelSelection:o}=t();let c=s;if(!c){const h=o?o.split("/"):[],f=h[0],p=h.slice(1).join("/")??"";if(f===n&&p)c=p;else{const m=a.find(x=>x.id===n);c=((l=m==null?void 0:m.models[0])==null?void 0:l.id)??""}}e({activeProviderId:n,model:c,defaultModelSelection:`${n}/${c}`,providers:a.map(h=>({...h,isActive:h.id===n}))})},updateModelContext:async(n,s,a)=>{e({activating:!0,error:null});try{const o=await pv(n,s,{contextWindow:a}),{providers:c}=t();return e({providers:gv(c,n,s,{contextWindow:a}),activating:!1}),o.contextState&&Ce.getState().updateContextState(o.contextState),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(n,s,a)=>{e({activating:!0,error:null});try{const o=await pv(n,s,a),{providers:c}=t(),l={...a.contextWindow!==void 0&&{contextWindow:a.contextWindow},...k2({temperature:a.temperature??void 0,topP:a.topP??void 0,topK:a.topK??void 0,maxTokens:a.maxTokens??void 0}),...a.supportsVision!==void 0&&{supportsVision:a.supportsVision}};return e({providers:gv(c,n,s,l),activating:!1}),o.contextState&&Ce.getState().updateContextState(o.contextState),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const s=await je(`/api/providers/${n}/refresh`,{method:"POST"});if(!s.ok){const c=await s.json();throw new Error(c.error??"Failed to refresh models")}const a=await s.json(),{providers:o}=t();return e({providers:o.map(c=>c.id===n?{...c,models:a.models,status:a.status}:c),activating:!1}),!0}catch(s){return e({error:s instanceof Error?s.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:s}=t();if(n)return;const a=setInterval(()=>{s()},E2);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:s}=t();return n.find(a=>a.id===s)},getModelContext:n=>{const{providers:s,activeProviderId:a}=t(),o=s.find(l=>l.id===a);if(!o)return 2e5;const c=o.models.find(l=>l.id===n);return(c==null?void 0:c.contextWindow)??2e5}})),Pt=Jn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const s=await(await je("/api/projects")).json();e({projects:s.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,s)=>{try{const a=await je("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:s})});if(!a.ok){const c=await a.json().catch(()=>({}));return{error:{code:c.code||"UNKNOWN",path:c.path,message:c.error}}}const o=await a.json();return await t().listProjects(),o.project}catch{return null}},loadProject:async n=>{try{const s=await je(`/api/projects/${n}`);if(!s.ok)return null;const a=await s.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,s)=>{var a;try{const o=await je(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)return null;const c=await o.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:c.project}),await t().listProjects(),c.project}catch{return null}},deleteProject:async n=>{var s;try{return(await je(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((s=t().currentProject)==null?void 0:s.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,s)=>{var a;try{const o=await je(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:s})});if(!o.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const c=await o.json();e({currentProject:c.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}}));let Oc=[];const Yo=Jn()((e,t)=>{function n(){if(Oc.length===0)return;const a=Oc;Oc=[],e(o=>{const c={...o.logs};for(const l of a){const h=c[l.processId]??[];c[l.processId]=[...h,{offset:h.length,content:l.content,timestamp:Date.now(),stream:l.stream}]}return{logs:c}})}const s=Y0(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(o=>({processes:[...o.processes,a]})),updateProcess:(a,o)=>e(c=>({processes:c.processes.map(l=>l.id===a?{...l,...o}:l)})),removeProcess:a=>e(o=>({processes:o.processes.filter(c=>c.id!==a),logs:Object.fromEntries(Object.entries(o.logs).filter(([c])=>c!==a))})),stopProcess:async(a,o)=>{try{(await je(`/api/sessions/${o}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,o,c)=>{Oc.push({processId:a,stream:o,content:c}),s()},setLogs:(a,o)=>e(c=>({logs:{...c.logs,[a]:o}})),clearLogs:a=>e(o=>({logs:{...o.logs,[a]:[]}})),handleMessage:(a,o)=>{switch(a){case"backgroundProcess.started":{const{processId:c,name:l,pid:h,status:f}=o;e(p=>({processes:[...p.processes,{id:c,sessionId:"",name:l,command:"",cwd:"",pid:h,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const c=o.processId,l=o.stream,h=o.content;t().appendLog(c,l,h);break}case"backgroundProcess.exited":{const c=o.processId,l=o.exitCode;e(h=>({processes:h.processes.map(f=>f.id===c?{...f,status:"exited",exitCode:l}:f)}));break}case"backgroundProcess.removed":{const c=o.processId;t().removeProcess(c);break}}}}}),T2=[{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"}],N2=[{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"}],X0={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"},$s={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Q0={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},um={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...$s},waiting_for_user:{...$s},phase_done:{...$s},phase_blocked:{...$s},new_message:{...Q0}},agentOverrides:{}};function J0(e,t,n){var o;const s=e.events[t];if(!n)return s;const a=(o=e.agentOverrides[n])==null?void 0:o[t];return a?{soundEnabled:a.soundEnabled??s.soundEnabled,browserNotification:a.browserNotification??s.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:s.customSoundUrl}:s}const gi=Jn((e,t)=>({settings:um,loaded:!1,load:()=>{Wt.getState().getSetting($e.NOTIFICATION_SETTINGS);const s=Wt.subscribe(o=>{const c=o.settings[$e.NOTIFICATION_SETTINGS];if(c!==void 0)try{const l=JSON.parse(c);e({settings:xv(l),loaded:!0})}catch{e({loaded:!0})}}),a=Wt.getState().settings[$e.NOTIFICATION_SETTINGS];if(a)try{const o=JSON.parse(a);e({settings:xv(o),loaded:!0})}catch{e({loaded:!0})}return s},update:n=>{e({settings:n}),bf(n)},updateEvent:(n,s)=>{const a=t().settings,o={...a,events:{...a.events,[n]:{...a.events[n],...s}}};e({settings:o}),bf(o)},updateAgentOverride:(n,s,a)=>{var h;const o=t().settings,c={...o.agentOverrides};if(a===null){if(c[n]){const f={...c[n]};delete f[s],Object.keys(f).length===0?delete c[n]:c[n]=f}}else c[n]={...c[n],[s]:{...((h=c[n])==null?void 0:h[s])??{},...a}};const l={...o,agentOverrides:c};e({settings:l}),bf(l)}}));function bf(e){Wt.getState().setSetting($e.NOTIFICATION_SETTINGS,JSON.stringify(e))}function xv(e){var t,n,s,a,o;return{soundEnabled:e.soundEnabled??um.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??um.browserNotificationEnabled,events:{complete:{...$s,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...$s,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...$s,...(s=e.events)==null?void 0:s.phase_done},phase_blocked:{...$s,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...Q0,...(o=e.events)==null?void 0:o.new_message}},agentOverrides:e.agentOverrides??{}}}const _v=new Map;function A2(e){let t=_v.get(e);return t||(t=new Audio(e),t.volume=.5,_v.set(e,t)),t}let Z0=typeof Notification<"u"?Notification.permission:"denied";function L2(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(Z0=e,e))}const D2={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},R2={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 O2(e){typeof Notification>"u"||Z0==="granted"&&(document.hasFocus()||new Notification(D2[e],{body:R2[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function ul(e,t){const{settings:n}=gi.getState(),s=J0(n,e,t);if(n.soundEnabled&&s.soundEnabled){const a=s.customSoundUrl??X0[e],o=A2(a);o.currentTime=0,o.play().catch(()=>{})}n.browserNotificationEnabled&&s.browserNotification&&O2(e)}const M2=e=>ul("complete",e),I2=e=>ul("phase_done",e),P2=e=>ul("phase_blocked",e),yv=e=>ul("waiting_for_user",e),B2=e=>ul("new_message",e);let Io=!1,Tr=null;const Sf=new Set,wf=new Set,Mc=new Map,Jt={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let ja=null,wn=null;function Cf(){ja===null&&(ja=requestAnimationFrame(()=>{ja=null,wn==null||wn()}))}function ui(){ja!==null&&(cancelAnimationFrame(ja),ja=null)}function Vt(e,t){return t!==null&&e.sessionId===t}function z2(e,t,n){return e.id!==void 0||Vt(e,t)||n===!0&&e.sessionId!==void 0}function H2(e,t){return e.includes(t)?e:[...e,t]}function Po(e,t){return e.filter(n=>n!==t)}function $2(e,t){const n=e.find(o=>o.id===t.id),s=t.messageCount??t.messages.length,a=n?{...n,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:s,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length,messageCount:s};return n?e.map(o=>o.id===t.id?a:o):[a,...e]}function vv(e,t,n){return e.map(s=>{const a=(n==null?void 0:n.id)===s.id?n:null,o=t.find(c=>c.id===s.id);return{...s,title:s.title??(o==null?void 0:o.title),mode:(a==null?void 0:a.mode)??(o==null?void 0:o.mode)??s.mode,phase:(a==null?void 0:a.phase)??(o==null?void 0:o.phase)??s.phase,isRunning:s.isRunning&&(o==null?void 0:o.isRunning)!==!1,messageCount:s.messageCount,recentUserPrompts:s.recentUserPrompts}})}const bv=new Map;function Wo(e,t){var o;const n=t===((o=e.currentSession)==null?void 0:o.id)?e.currentSession:null,s=e.sessions.find(c=>c.id===t),a=(n==null?void 0:n.mode)??(s==null?void 0:s.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function U2(e,t){if(e.type==="chat.done"){const n=e.payload,s=Wo(t,e.sessionId),a=n.agentType??s;n.reason==="complete"&&M2(a),n.reason==="waiting_for_user"&&yv(a);return}if(e.type==="chat.path_confirmation"){const n=Wo(t,e.sessionId);yv(n);return}if(e.type==="task.completed"){const n=Wo(t,e.sessionId);I2(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,s=bv.get(e.sessionId)??null;if(bv.set(e.sessionId,n.phase),s===n.phase)return;const a=Wo(t,e.sessionId);n.phase==="blocked"&&P2(a)}}const Ce=Jn((e,t)=>(wn=()=>{const n=Jt;if(!n.messageId)return;const s=n.deltaContent.length>0,a=n.thinkingContent.length>0,o=n.toolOutput.length>0;if(!s&&!a&&!o)return;const c=n.deltaContent,l=n.thinkingContent,h=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(f=>{var m;const p=f.streamingMessage;if(p&&p.id===n.messageId){const x={...p};if(s&&(x.content=x.content+c),a&&(x.thinkingContent=(x.thinkingContent??"")+l),o){const _=new Set;x.toolCalls=(m=x.toolCalls)==null?void 0:m.map(k=>{const v=h.filter(b=>b.callId===k.id);return v.length===0?k:(_.add(k.id),{...k,streamingOutput:[...k.streamingOutput??[],...v.map(b=>({stream:b.stream,content:b.content,timestamp:Date.now()}))]})});const w=h.filter(k=>!_.has(k.callId));w.length>0&&Jt.toolOutput.push(...w)}return{streamingMessage:x}}if(o){const x=new Set,_=f.messages.map(k=>{var b;if(k.id!==n.messageId)return k;const v=(b=k.toolCalls)==null?void 0:b.map(y=>{const S=h.filter(E=>E.callId===y.id);return S.length===0?y:(x.add(y.id),{...y,streamingOutput:[...y.streamingOutput??[],...S.map(E=>({stream:E.stream,content:E.content,timestamp:Date.now()}))]})});return{...k,toolCalls:v}}),w=h.filter(k=>!x.has(k.callId));return w.length>0&&Jt.toolOutput.push(...w),{messages:_}}return f})},{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestion:null,visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let s=!1;try{s=(await(await je("/api/auth")).json()).requiresAuth}catch{}if(s&&!Zt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Zt.onStatusChange(a=>{var o;if(e({connectionStatus:a}),a==="connected"){t().listSessions(void 0),Pt.getState().listProjects();const c=(o=t().currentSession)==null?void 0:o.id;c&&t().loadSession(c)}});try{if(await Zt.connect(),!Io){Io=!0;const a=t().handleServerMessage;Tr=Zt.subscribe(a)}}catch(a){console.error("Failed to connect:",a);const o=Zt.getLastCloseCode();if(!Zt.hasToken()&&(o===1006||o===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Tr&&(Tr(),Tr=null),Io=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Zt.disconnect(),Tr&&(Tr(),Tr=null),Io=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Zt.disconnect(),Tr&&(Tr(),Tr=null),Io=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async n=>{try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:n})});if(!s.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:a}=await s.json();Zt.setToken(a),e({showPasswordModal:!1}),t().connect();const{listProjects:o}=Pt.getState(),{fetchConfig:c}=Dt.getState();o(),c(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Zt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,s)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const o=await je("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:s})});if(!o.ok)return e({pendingSessionCreate:!1}),null;const c=await o.json();return Zt.send("session.load",{sessionId:c.session.id}),c.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!wf.has(n)){wf.add(n);try{const s=t().currentSession;!s||s.id!==n?(ui(),e({currentSession:null,unreadSessionIds:Po(t().unreadSessionIds,n),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmations:[],queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1})):e({unreadSessionIds:Po(t().unreadSessionIds,n)});const a=await je(`/api/sessions/${n}`);if(!a.ok)return;const o=await a.json();e({currentSession:o.session,messages:o.messages??[],contextState:o.contextState,queuedMessages:o.queueState??[]}),Zt.send("session.load",{sessionId:n});try{const c=await je(`/api/sessions/${n}/background-processes`);if(c.ok){const l=await c.json();Yo.getState().setProcesses(l.processes??[])}}catch{}}catch{}finally{wf.delete(n)}}},listSessions:async(n,s=20)=>{const a=n??"global";if(Mc.has(a))return console.warn("[STORE] listSessions skipped (already listing):",a),Mc.get(a);const o=(async()=>{try{const c=new URLSearchParams;c.set("limit",String(s)),n&&c.set("projectId",n);const h=await(await je(`/api/sessions?${c.toString()}`)).json(),f=h.sessions??[];e(p=>({sessions:vv(f,p.sessions,p.currentSession),sessionsHasMore:n?h.hasMore??!1:!0}))}catch{}finally{Mc.delete(a)}})();return Mc.set(a,o),o},loadMoreSessions:async n=>{const s=t();if(!(s.sessionsPaginationLoading||!s.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const a=new URLSearchParams;a.set("limit","20"),a.set("offset",String(s.sessions.length)),a.set("projectId",n);const c=await(await je(`/api/sessions?${a.toString()}`)).json(),l=c.sessions??[];e(h=>({sessions:[...h.sessions,...l.map(f=>{const p=h.sessions.find(m=>m.id===f.id);return(p==null?void 0:p.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:c.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var s;try{return(await je(`/api/sessions/${n}`,{method:"DELETE"})).ok?(await t().listSessions(),((s=t().currentSession)==null?void 0:s.id)===n&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(n,s)=>{var a;try{const o=await je(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s})});if(!o.ok)return!1;if(await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===n){const l=await o.json();l.session&&e({currentSession:l.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await je(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{ui(),e(n=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?Po(n.unreadSessionIds,n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,s,a)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o){e({streamingMessageId:null});try{const h=await(await je(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:s,messageKind:a==null?void 0:a.messageKind})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error sending message:",l)}}},stopGeneration:async()=>{var s;const n=(s=t().currentSession)==null?void 0:s.id;if(n&&!t().abortInProgress){ui(),wn==null||wn(),e({abortInProgress:!0});try{await je(`/api/sessions/${n}/stop`,{method:"POST"})}catch(a){console.error("Error stopping generation:",a)}}},continueGeneration:async()=>{var s;const n=(s=t().currentSession)==null?void 0:s.id;if(n){e({streamingMessageId:null});try{await je(`/api/sessions/${n}/continue`,{method:"POST"})}catch(a){console.error("Error continuing generation:",a)}}},launchRunner:(n,s,a)=>{e({streamingMessageId:null});const o={};n!=null&&n.trim()&&(o.content=n),s&&s.length>0&&(o.attachments=s),a&&(o.workflowId=a),Zt.send("runner.launch",o)},switchMode:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const o=await je(`/api/sessions/${s}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!o.ok){console.error("Failed to switch mode:",await o.json());return}const c=await o.json();c.session&&e({currentSession:c.session})}catch(o){console.error("Error switching mode:",o)}},switchDangerLevel:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const o=await je(`/api/sessions/${s}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!o.ok){console.error("Failed to switch danger level:",await o.json());return}const c=await o.json();c.session&&e({currentSession:c.session})}catch(o){console.error("Error switching danger level:",o)}},acceptAndBuild:(n,s,a)=>{var l;e({streamingMessageId:null});const o={};n&&(o.workflowId=n),s!=null&&s.trim()&&(o.content=s),a&&a.length>0&&(o.attachments=a);const c=(l=t().currentSession)==null?void 0:l.id;c&&je(`/api/sessions/${c}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{Zt.send("runner.launch",o)})},editCriteria:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const o=await je(`/api/sessions/${s}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});o.ok||console.error("Failed to update criteria:",await o.json())}catch(o){console.error("Error updating criteria:",o)}},compactContext:()=>{Zt.send("context.compact",{})},setSessionProvider:async(n,s)=>{var a,o;try{const c=(a=t().currentSession)==null?void 0:a.id;if(!c)return null;const l=await je(`/api/sessions/${c}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...s?{model:s}:{}})});if(!l.ok)return null;const h=await l.json();if(e({currentSession:h.session,messages:h.messages??[],contextState:h.contextState}),(o=h.session)!=null&&o.providerId){const f=Dt.getState();f.providers.find(m=>m.id===h.session.providerId)&&f.syncFromSession(h.session.providerId,h.session.providerModel??"")}return h.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,s)=>{e(a=>({subAgentContextStates:{...a.subAgentContextStates,[n]:s}}))},clearSubAgentContextState:n=>{e(s=>{const a={...s.subAgentContextStates};return delete a[n],{subAgentContextStates:a}})},confirmPath:async(n,s,a=!1)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o)try{await je(`/api/sessions/${o}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:s,alwaysAllow:a})})}catch(l){console.error("Error confirming path:",l)}},answerQuestion:async(n,s)=>{var o;const a=(o=t().currentSession)==null?void 0:o.id;if(a){try{await je(`/api/sessions/${a}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:s})})}catch(c){console.error("Error answering question:",c)}e({pendingQuestion:null})}},queueAsap:async(n,s,a)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o)try{const h=await(await je(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:s,messageKind:a})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing ASAP message:",l)}},queueCompletion:async(n,s,a)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o)try{const h=await(await je(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:s,messageKind:a})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing completion message:",l)}},cancelQueued:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const c=await(await je(`/api/sessions/${s}/queue/${n}`,{method:"DELETE"})).json();c.queueState&&e({queuedMessages:c.queueState})}catch(o){console.error("Error canceling queued message:",o)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{var c,l,h,f,p,m,x,_,w,k,v,b,y,S,E,N,T,L,A,z,R,$,F,W,Y;const s=t();U2(n,s);const a=((c=s.currentSession)==null?void 0:c.id)??null,o=()=>{const P=n.sessionId;!P||P===a||e(H=>({unreadSessionIds:H2(H.unreadSessionIds,P)}))};switch(n.type){case"session.state":{const P=n.payload;if(!z2(n,a,s.pendingSessionCreate))break;ui();const H=P.messages.find(K=>K.isStreaming)??null,J=t().pendingSessionCreate===!0;if(e({currentSession:P.session,sessions:$2(t().sessions,P.session),unreadSessionIds:Po(t().unreadSessionIds,P.session.id),messages:P.messages,streamingMessageId:(H==null?void 0:H.id)??null,streamingMessage:H,currentTodos:[],pendingPathConfirmations:P.pendingConfirmations??[],error:null,...J?{pendingSessionCreate:P.session.id}:{}}),P.session.providerId){const K=Dt.getState();K.providers.find(D=>D.id===P.session.providerId)&&K.syncFromSession(P.session.providerId,P.session.providerModel??"")}break}case"session.list":{const P=n.payload;e(H=>({sessions:vv(P.sessions,H.sessions,H.currentSession)}));break}case"session.deleted":{const P=n.payload;e(H=>({unreadSessionIds:Po(H.unreadSessionIds,P.sessionId)})),t().listSessions();break}case"session.deletedAll":{t().listSessions();break}case"session.running":{const P=n.payload,H=n.sessionId,J=(l=t().currentSession)==null?void 0:l.id,K=H&&H!==J;e(I=>({sessions:I.sessions.map(D=>D.id===H?{...D,isRunning:P.isRunning}:D)})),K||e(I=>({currentSession:I.currentSession?{...I.currentSession,isRunning:P.isRunning}:null,...P.isRunning?{}:{abortInProgress:!1,queuedMessages:[]}}));break}case"chat.message":{if(!Vt(n,((h=t().currentSession)==null?void 0:h.id)??null)){o();break}const P=n.payload;e(H=>{var K;if(H.messages.some(I=>I.id===P.message.id))return H;const J=P.message.role==="user";return console.warn("[Message Count] chat.message received:",{messageId:P.message.id,role:P.message.role,isUserMessage:J,willCount:J,currentCount:(K=H.sessions.find(I=>I.id===n.sessionId))==null?void 0:K.messageCount}),{messages:[...H.messages,P.message],sessions:H.sessions.map(I=>I.id===n.sessionId&&J?{...I,messageCount:I.messageCount+1}:I),streamingMessageId:P.message.isStreaming?P.message.id:H.streamingMessageId,streamingMessage:P.message.isStreaming?P.message:H.streamingMessage}});break}case"chat.message_updated":{if(!Vt(n,((f=t().currentSession)==null?void 0:f.id)??null)){o();break}const P=n.payload,H=P.updates.isStreaming===!1&&t().streamingMessageId===P.messageId;H&&(ui(),wn==null||wn()),e(J=>{const K=J.streamingMessage,I=H;if(K&&K.id===P.messageId){const D={...K,...P.updates};return{messages:J.messages.map(B=>B.id===P.messageId?D:B),streamingMessageId:I?null:J.streamingMessageId,streamingMessage:I?null:{...K,...P.updates}}}return{messages:J.messages.map(D=>D.id===P.messageId?{...D,...P.updates}:D),streamingMessageId:I?null:J.streamingMessageId}});break}case"chat.delta":{if(!Vt(n,((p=t().currentSession)==null?void 0:p.id)??null)){o();break}const P=n.payload;if(!Sf.has(P.messageId)){Sf.add(P.messageId);const H=Wo(t(),n.sessionId);B2(H)}Jt.messageId=P.messageId,Jt.deltaContent+=P.content,Cf();break}case"chat.thinking":{if(!Vt(n,((m=t().currentSession)==null?void 0:m.id)??null)){o();break}const P=n.payload;Jt.messageId=P.messageId,Jt.thinkingContent+=P.content,Cf();break}case"chat.tool_preparing":{if(!Vt(n,((x=t().currentSession)==null?void 0:x.id)??null)){o();break}const P=n.payload,H=t().streamingMessage;if(!H||H.id!==P.messageId||((_=H.toolCalls)==null?void 0:_.find((K,I)=>I===P.index)))return;e(K=>{const I=K.streamingMessage.preparingToolCalls??[],D=I.findIndex(V=>V.index===P.index);let B;return D>=0?B=I.map((V,U)=>U===D?{...V,arguments:P.arguments}:V):B=[...I,{index:P.index,name:P.name,...P.arguments?{arguments:P.arguments}:{}}],{streamingMessage:{...K.streamingMessage,preparingToolCalls:B}}});break}case"chat.tool_call":{if(!Vt(n,((w=t().currentSession)==null?void 0:w.id)??null)){o();break}const P=n.payload,H=J=>{var D;const K=(D=J.preparingToolCalls)==null?void 0:D.filter((B,V)=>{var U;return B.name===P.tool?(U=J.preparingToolCalls)==null?void 0:U.slice(0,V).some(Z=>Z.name===P.tool):!0}),I=Jt.toolOutput.filter(B=>B.callId===P.callId);return I.length>0&&(Jt.toolOutput=Jt.toolOutput.filter(B=>B.callId!==P.callId)),{...J,toolCalls:[...J.toolCalls??[],{id:P.callId,name:P.tool,arguments:P.args,startedAt:Date.now(),...I.length>0?{streamingOutput:I.map(B=>({stream:B.stream,content:B.content,timestamp:Date.now()}))}:{}}],...K&&K.length>0?{preparingToolCalls:K}:{preparingToolCalls:void 0}}};e(J=>{const K=J.streamingMessage;return K&&K.id===P.messageId?{streamingMessage:H(K)}:{messages:J.messages.map(I=>I.id===P.messageId?H(I):I)}});break}case"chat.tool_output":{if(!Vt(n,((k=t().currentSession)==null?void 0:k.id)??null)){o();break}const P=n.payload;Jt.messageId=P.messageId,Jt.toolOutput.push({messageId:P.messageId,callId:P.callId,stream:P.stream,content:P.output}),Cf();break}case"chat.tool_result":{if(!Vt(n,((v=t().currentSession)==null?void 0:v.id)??null)){o();break}const P=n.payload,H=J=>{var I;const K=(I=J.toolCalls)==null?void 0:I.map(D=>D.id===P.callId?{...D,result:P.result}:D);return{...J,toolCalls:K}};e(J=>{const K=J.streamingMessage;return K&&K.id===P.messageId?{streamingMessage:H(K)}:{messages:J.messages.map(I=>I.id===P.messageId?H(I):I)}});break}case"chat.vision_fallback":{if(!Vt(n,((b=t().currentSession)==null?void 0:b.id)??null)){o();break}const P=n.payload;e(H=>{const J=`${P.messageId}-${P.attachmentId}`,K={...H.visionFallbackByMessage};return K[J]={type:P.type,attachmentId:P.attachmentId,filename:P.filename,description:P.description},{visionFallbackByMessage:K}});break}case"chat.todo":{if(!Vt(n,((y=t().currentSession)==null?void 0:y.id)??null)){o();break}const P=n.payload;e({currentTodos:P.todos});break}case"chat.summary":{if(!Vt(n,((S=t().currentSession)==null?void 0:S.id)??null)){o();break}const P=n.payload;e(H=>({currentSession:H.currentSession?{...H.currentSession,summary:P.summary}:null}));break}case"chat.progress":{if(!Vt(n,((E=t().currentSession)==null?void 0:E.id)??null)){o();break}const P=n.payload;console.warn("Progress:",P.message,P.phase);break}case"chat.format_retry":{if(!Vt(n,((N=t().currentSession)==null?void 0:N.id)??null)){o();break}const P=n.payload;console.warn("Format retry:",P.attempt,"/",P.maxAttempts);break}case"chat.done":{if(!Vt(n,((T=t().currentSession)==null?void 0:T.id)??null)){o();break}ui(),wn==null||wn();const P=n.payload,H=P.stats;Jt.messageId=null,Jt.deltaContent="",Jt.thinkingContent="",Jt.toolOutput=[],Sf.delete(P.messageId),e(J=>{const K=J.streamingMessage,I=K&&K.id===P.messageId?{...K,isStreaming:!1,stats:H??K.stats}:null;return{messages:J.messages.map(D=>D.id===P.messageId?I??{...D,isStreaming:!1,stats:H??D.stats,completeReason:P.reason}:D),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Vt(n,((L=t().currentSession)==null?void 0:L.id)??null)){o();break}ui(),wn==null||wn();const P=n.payload;console.error("Chat error:",P.error,"recoverable:",P.recoverable),P.recoverable||(Jt.messageId=null,Jt.deltaContent="",Jt.thinkingContent="",Jt.toolOutput=[]),e(H=>({error:{code:"CHAT_ERROR",message:P.error},streamingMessageId:P.recoverable?H.streamingMessageId:null,...P.recoverable?{}:{messages:H.streamingMessage?H.messages.map(J=>J.id===H.streamingMessage.id?H.streamingMessage:J):H.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Vt(n,((A=t().currentSession)==null?void 0:A.id)??null)){o();break}const P=n.payload,H={callId:P.callId,tool:P.tool,paths:P.paths,workdir:P.workdir,reason:P.reason};e(J=>({pendingPathConfirmations:[...J.pendingPathConfirmations,H]}));break}case"chat.ask_user":{if(!Vt(n,((z=t().currentSession)==null?void 0:z.id)??null)){o();return}const P=n.payload;e({pendingQuestion:{callId:P.callId,question:P.question}});break}case"mode.changed":{if(!Vt(n,((R=t().currentSession)==null?void 0:R.id)??null)){o();break}const P=n.payload;e(H=>({currentSession:H.currentSession?{...H.currentSession,mode:P.mode}:null}));break}case"phase.changed":{const P=n.payload,H=n.sessionId,J=($=t().currentSession)==null?void 0:$.id,K=H&&H!==J;e(I=>({sessions:I.sessions.map(D=>D.id===H?{...D,phase:P.phase}:D)})),K||e(I=>({currentSession:I.currentSession?{...I.currentSession,phase:P.phase}:null}));break}case"criteria.updated":{if(!Vt(n,((F=t().currentSession)==null?void 0:F.id)??null)){o();break}const P=n.payload;e(H=>({currentSession:H.currentSession?{...H.currentSession,criteria:P.criteria}:null}));break}case"context.state":{const P=n.payload,H=Vt(n,((W=t().currentSession)==null?void 0:W.id)??null);P.subAgentId?H&&t().updateSubAgentContextState(P.subAgentId,P.context):H?e({contextState:P.context}):o();break}case"session.name_generated":{const P=n.payload,H=n.sessionId,J=(Y=t().currentSession)==null?void 0:Y.id;e(K=>{const I=K.sessions.map(B=>B.id===H?{...B,title:P.name,updatedAt:new Date().toISOString()}:B),D=J===H?K.currentSession?{...K.currentSession,title:P.name,updatedAt:new Date().toISOString()}:null:K.currentSession;return{sessions:I,currentSession:D}});break}case"queue.state":{const P=n.payload;e({queuedMessages:P.messages??[]});break}case"git.status":{const P=n.payload;e({gitStatus:{branch:P.branch,diff:P.diff}});break}case"devServer.output":case"devServer.state":{Rr.getState().handleMessage(n);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Yo.getState().handleMessage(n.type,n.payload);break}case"error":{const P=n.payload;console.error("Server error:",P),e({error:{code:P.code,message:P.message},streamingMessageId:null});break}}}}));function Ym(){return Ce(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function F2(){return Ce(e=>e.queuedMessages)}function V2(){return Ce(e=>e.abortInProgress)}function G2(){const e=Ce(s=>s.connect),t=Ce(s=>s.connectionStatus),n=gi(s=>s.load);return O.useEffect(()=>{e()},[e]),O.useEffect(()=>{t==="connected"&&n()},[t,n]),{connectionStatus:t}}const W2="modulepreload",q2=function(e){return"/"+e},Sv={},Q=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=c(n.map(f=>{if(f=q2(f),f in Sv)return;Sv[f]=!0;const p=f.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":W2,p||(x.as="script"),x.crossOrigin="",x.href=f,h&&x.setAttribute("nonce",h),document.head.appendChild(x),p)return new Promise((_,w)=>{x.addEventListener("load",_),x.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return a.then(c=>{for(const l of c||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},eS=[{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"}],Or=[{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 wv(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Ht=Jn((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:wv(),followSystemTheme:!0,applySavedTheme:()=>{const{getSavedTheme:n,applyPreset:s,applyTokens:a}=t(),o=n();if(o)try{const c=JSON.parse(o);c.preset&&c.tokens?(s(c.preset),e({basePreset:c.preset}),a(c.tokens)):c.preset?s(c.preset):c.tokens&&a(c.tokens)}catch{s("dark")}else s("dark")},applyPreset:n=>{Or.find(a=>a.id===n)&&(e({currentPreset:n,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1}),t().applyTheme())},startCustomizing:()=>{var a;const{currentPreset:n}=t(),s=((a=Or.find(o=>o.id===n))==null?void 0:a.tokens)??{};e({basePreset:n,customTokens:{...s},isCustom:!0,isCustomizing:!0})},setCustomToken:(n,s)=>{e(a=>({customTokens:{...a.customTokens,[n]:s}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:n}=t();t().saveTheme(JSON.stringify({tokens:n})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:n=>{e({customTokens:n,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var c,l;const{basePreset:n,customTokens:s,isCustom:a}=t();if(a&&n)return{...((c=Or.find(f=>f.id===n))==null?void 0:c.tokens)??{},...s};if(a)return{...eS.reduce((h,f)=>({...h,[f.key]:f.defaultValue}),{}),...s};const o=Or.find(h=>h.id===t().currentPreset);return(o==null?void 0:o.tokens)??((l=Or[0])==null?void 0:l.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const n=t().getActiveTheme(),s=document.documentElement;Object.entries(n).forEach(([a,o])=>{s.style.setProperty(`--${a}`,o)})},getSavedTheme:()=>{try{const n=localStorage.getItem("openfox:theme");if(!n)return null;if(n[0]!=="{")return JSON.stringify({preset:n});const s=JSON.parse(n);if(s.preset)return JSON.stringify({preset:s.preset});if(s.tokens)return JSON.stringify({tokens:s.tokens})}catch{return null}return null},saveTheme:async n=>{localStorage.setItem("openfox:theme",n);const{useSettingsStore:s}=await Q(async()=>{const{useSettingsStore:a}=await Promise.resolve().then(()=>_f);return{useSettingsStore:a}},void 0);await s.getState().setSetting($e.DISPLAY_THEME,n)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:n=>{e({followSystemTheme:n}),Q(async()=>{const{useSettingsStore:s,SETTINGS_KEYS:a}=await Promise.resolve().then(()=>_f);return{useSettingsStore:s,SETTINGS_KEYS:a}},void 0).then(({useSettingsStore:s,SETTINGS_KEYS:a})=>{s.getState().setSetting(a.DISPLAY_FOLLOW_SYSTEM_THEME,String(n))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const n=window.matchMedia("(prefers-color-scheme: dark)"),s=o=>{const{followSystemTheme:c}=t();c&&(t().applyPreset(o?"dark":"light"),t().saveTheme(JSON.stringify({preset:o?"dark":"light"})))};s(n.matches);const a=o=>s(o.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0})},addUserPreset:n=>{const{basePreset:s,customTokens:a,currentPreset:o}=t(),c={id:"custom-"+Date.now(),name:n,basePreset:s||o,tokens:{...a}},l=[...t().userPresets,c];e({userPresets:l}),t().saveUserPresets()},applyUserPreset:n=>{const s=t().userPresets[n];s&&(e({currentPreset:s.basePreset,basePreset:s.basePreset,customTokens:{...s.tokens},isCustom:!0,isCustomizing:!1}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:s.basePreset,tokens:s.tokens})).catch(()=>{}))},deleteUserPreset:n=>{const s=t().userPresets.filter((a,o)=>o!==n);e({userPresets:s}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:wv()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),Q(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>_f);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting($e.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function K2({canLoad:e,projectId:t,currentProjectId:n}){const s=Pt(c=>c.loadProject),a=Ce(c=>c.listSessions),o=Ce(c=>c.clearSession);O.useEffect(()=>{e&&t&&(n!==t&&s(t),a(t),o())},[e,t,n,s,a,o])}function Y2({canLoad:e,projectId:t,sessionId:n,currentProjectId:s,currentSessionId:a}){const o=Ce(f=>f.loadSession),c=Pt(f=>f.loadProject),l=Ce(f=>f.listSessions),h=Ce(f=>f.pendingSessionCreate);O.useEffect(()=>{e&&t&&s!==t&&c(t)},[e,t,s,c]),O.useEffect(()=>{e&&n&&a!==n&&o(n),e&&t&&l(t)},[e,n,a,o,l,h,t])}function X2({className:e="w-5 h-5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function tS({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function Q2({className:e="w-5 h-5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 J2({className:e="w-3 h-3 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Z2({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.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 Mr({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Ir({className:e="w-3 h-3 text-text-muted",rotate:t}){return u.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function ej({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[u.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),u.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Xm({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 tj({className:e="w-3 h-3"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Qm({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[u.jsx("circle",{cx:"12",cy:"5",r:"2"}),u.jsx("circle",{cx:"12",cy:"12",r:"2"}),u.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Eu({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Jm({className:e="w-5 h-5 text-accent-primary"}){return u.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:u.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 nj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 rj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 sj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.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 ij({className:e="w-3 h-3"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 aj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Cv({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function nS({className:e="w-[18px] h-[18px]"}){return u.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[u.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function oj({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.jsx("path",{d:"M9.5 2h4.5v4.5"}),u.jsx("path",{d:"M14 2L7.5 8.5"})]})}function lj({className:e="w-3 h-3",color:t}){return u.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{d:"M8 5v14l11-7z"})})}function La({className:e="w-3 h-3 text-accent-primary"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function cj({className:e="w-5 h-5"}){return u.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:u.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 Zm({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 uj({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[u.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"}),u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function dj({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return u.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[u.jsx("title",{children:"Running"}),u.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),u.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function hj({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function fj({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function rS({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function mj({className:e="w-3.5 h-3.5 shrink-0",color:t}){return u.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:u.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 pj({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"4 17 10 11 4 5"}),u.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function ju({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 ep(){return u.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 gj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 dm({className:e="w-2.5 h-2.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 tp({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:u.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 sS({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.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 xj({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function _j({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function kv({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function hm(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Ev(e,t){const n=Zt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:hm(),type:e,payload:t}))}const _r=Jn((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const s=await je(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(s.ok){const a=await s.json();e({sessions:a});const o=Zt.ws;if(o&&o.readyState===WebSocket.OPEN)for(const c of a)o.send(JSON.stringify({id:hm(),type:"terminal.subscribe",payload:{sessionId:c.id}}))}}catch(s){console.error("Failed to fetch terminals:",s)}},createSession:async(n,s)=>{try{const a=await je("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:s})});if(a.ok){const o=await a.json();e(l=>({sessions:[...l.sessions,o]}));const c=Zt.ws;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({id:hm(),type:"terminal.subscribe",payload:{sessionId:o.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,s)=>{Ev("terminal.write",{sessionId:n,data:s})},resizeSession:(n,s,a)=>{Ev("terminal.resize",{sessionId:n,cols:s,rows:a})},killSession:async n=>{try{(await je(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(o=>o.id!==n)}))}catch(s){console.error("Failed to kill terminal:",s)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:s}=n.payload||{};s&&e(a=>{const o=a.sessions.filter(c=>c.id!==s);return o.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:o}});break}}}}));Zt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&_r.getState().handleMessage(e)});const wa={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function fm(e){if(!e)return structuredClone(wa);try{const t=JSON.parse(e);return{terminalToggle:t.terminalToggle??structuredClone(wa.terminalToggle),quickAction:t.quickAction??structuredClone(wa.quickAction),agentSwitching:t.agentSwitching??structuredClone(wa.agentSwitching)}}catch{return structuredClone(wa)}}function jv(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function iS(e){if(e.type==="double-press")return`Double ${e.key==="Control"?"Ctrl":e.key==="Shift"?"Shift":e.key==="Alt"?"Alt":e.key==="Meta"?"Meta":e.key}`;const t=e.modifiers.map(s=>{switch(s){case"ctrl":return"Ctrl";case"meta":return"⌘";case"alt":return"Alt";case"shift":return"Shift"}}),n=e.key.length===1?e.key.toUpperCase():e.key;return[...t,n].join("+")}function yj(e){return e.type==="double-press"}function aS(e){return e.type==="chord"}function vj(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.code===`Key${t.toUpperCase()}`:t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function oS(e,t){const n=t.modifiers.includes("ctrl"),s=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),o=t.modifiers.includes("shift");return vj(e,t.key)&&e.ctrlKey===n&&e.metaKey===s&&e.altKey===a&&e.shiftKey===o}function np(){const e=Wt(t=>t.settings[$e.KEYBINDINGS]);return fm(e)}function bj(e,t,n){const s=O.useRef(0),a=O.useRef(t);a.current=t,O.useEffect(()=>{if(!e)return;const o=e.threshold??300,c=l=>{if(l.key!==e.key)return;const h=e.key==="Control",f=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!h&&l.ctrlKey||!f&&l.shiftKey||!p&&l.altKey||!m&&l.metaKey)return;const x=Date.now();x-s.current<o?(l.preventDefault(),l.stopPropagation(),a.current(),s.current=0):s.current=x};return window.addEventListener("keydown",c,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",c,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function Sj(e,t){const n=O.useRef(t);n.current=t,O.useEffect(()=>{if(!e)return;const s=a=>{oS(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function lS(e,t,n){bj(e&&yj(e)?e:void 0,t,n),Sj(e&&aS(e)?e:void 0,t)}function wj(e,t,n){const s=O.useRef(n);s.current=n,O.useEffect(()=>{const a=o=>{for(let c=0;c<e.length;c++){const l=e[c];if(!l)continue;const h=t[c];if(h&&aS(l)&&oS(o,l)){o.preventDefault(),s.current(h.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var Pa=B0();const Tu=O.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...s},a)=>u.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...s,children:u.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Tu.displayName="IconButton";const Cj="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",Da=O.forwardRef((e,t)=>u.jsx(Tu,{ref:t,icon:Cj,title:"Edit",...e}));Da.displayName="EditButton";const kj="M6 18L18 6M6 6l12 12",rp=O.forwardRef((e,t)=>u.jsx(Tu,{ref:t,icon:kj,...e}));rp.displayName="CloseButton";const Ej={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 Nt({label:e,title:t,size:n="md",minHeight:s,children:a,footer:o,className:c,onClose:l,isOpen:h,closeOnBackdropClick:f=!0,closeOnEscape:p=!0,showCloseButton:m=!0}){const[x,_]=O.useState(!1),w=h!==void 0,k=w?h:x,v=O.useCallback(()=>{w||_(!0)},[w]),b=O.useCallback(()=>{w||_(!1),l==null||l()},[w,l]);O.useEffect(()=>{if(!k||!p)return;const S=E=>{E.key==="Escape"&&(E.stopPropagation(),b())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[k,b,p]);const y=e&&(typeof e=="string"?u.jsx("button",{type:"button",onClick:v,className:c,children:e}):u.jsx("span",{onClick:v,className:c,style:{cursor:"pointer"},children:e}));return u.jsxs(u.Fragment,{children:[y,k&&(typeof document<"u"?Pa.createPortal(u.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:f?b:void 0}),u.jsxs("div",{className:`relative w-full ${Ej[n]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||m)&&u.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&u.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),m&&u.jsx(rp,{onClick:b,className:"ml-auto","aria-label":"Close"})]}),u.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:s?{minHeight:s}:void 0,children:a}),o&&u.jsx("div",{className:"px-4 py-3 border-t border-border",children:o})]})]}),document.body):null)]})}const rt=O.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:s,...a},o)=>{const c="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",l={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"},h={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return u.jsx("button",{ref:o,className:`${c} ${l[e]} ${h[t]} ${n}`,...a,children:s})});rt.displayName="Button";function jj({value:e,defaultUrl:t,disabled:n,onChange:s}){const a=e??t;return u.jsxs("div",{className:"relative",children:[u.jsx("select",{value:a,disabled:n,onChange:o=>{const c=o.target.value;s(c===t?null:c)},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:N2.map(({url:o,label:c})=>u.jsx("option",{value:o,title:c,children:c.split(" ")[0]},o))}),u.jsx(Ir,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const Tv=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function Tj(){const e=gi(h=>h.settings),t=gi(h=>h.update),n=gi(h=>h.updateEvent),s=gi(h=>h.updateAgentOverride),a=gi(h=>h.load);O.useEffect(()=>{a()},[a]);const o=async()=>{await L2()==="granted"&&t({...e,browserNotificationEnabled:!0})},c=(h,f,p,m)=>{h==="general"?n(f,{[p]:m}):s(h,f,{[p]:m})},l=(h,f,p)=>{h==="general"?n(f,{customSoundUrl:p}):s(h,f,{customSoundUrl:p})};return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),u.jsx(Nv,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:h=>t({...e,soundEnabled:h})}),u.jsx(Nv,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:h=>{h&&typeof Notification<"u"&&Notification.permission!=="granted"?o():t({...e,browserNotificationEnabled:h})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&u.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),u.jsx("div",{className:"border border-border rounded overflow-hidden",children:u.jsxs("table",{className:"w-full text-sm",children:[u.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:u.jsxs("tr",{className:"border-b border-border",children:[u.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),Tv.map(h=>u.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:h.label},h.key))]})}),u.jsx("tbody",{children:T2.map(h=>u.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[u.jsx("td",{className:"px-3 py-2",children:u.jsx("div",{className:"text-text-primary text-xs",children:h.label})}),Tv.map(f=>{const p=J0(e,h.key,f.key==="general"?void 0:f.key),m=X0[h.key];return u.jsx("td",{className:"px-2 py-2 align-top",children:u.jsxs("div",{className:"flex flex-col items-center gap-1",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:u.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:x=>c(f.key,h.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),u.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:u.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>c(f.key,h.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&u.jsx(jj,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:x=>l(f.key,h.key,x)})]})},f.key)})]},h.key))})]})})]})]})}function Nv({label:e,description:t,checked:n,onChange:s}){return u.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[u.jsx("div",{className:"pt-0.5",children:u.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),s(!n)},children:u.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),u.jsx("div",{className:"text-xs text-text-muted",children:t})]})]})}async function sp(e,t,n){t({loading:!0});try{const a=await(await je(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const Nr=Jn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchSkills:async()=>{await sp("/api/skills",e,!0)},toggleSkill:async n=>{try{const a=await(await je(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(o=>({defaults:o.defaults.map(c=>c.id===n?{...c,enabled:a.enabled}:c),userItems:o.userItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c)}))}catch{}},fetchSkill:async n=>{try{const s=await je(`/api/skills/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await je(`/api/skills/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createSkill:async(n,s)=>{const a=await Vs("POST","/api/skills",{...n,destination:s});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,s)=>{const a=await Vs("PUT",`/api/skills/${n}`,s);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const s=await je(`/api/skills/${n}`,{method:"DELETE"}),a=await s.json();return s.ok?(e(o=>({userItems:o.userItems.filter(c=>c.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,s)=>ku(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),s)}));function ip(){const[e,t]=O.useState({id:null,type:null}),n=O.useCallback(o=>t({id:o,type:"delete"}),[]),s=O.useCallback(()=>t({id:null,type:null}),[]),a=O.useCallback((o,c)=>e.id===o&&e.type===c,[e.id,e.type]);return{requestDelete:n,clearConfirm:s,isConfirming:a}}function ap({onConfirm:e,onCancel:t}){return u.jsxs("div",{className:"flex items-center gap-1",children:[u.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"}),u.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function op({onClick:e}){return u.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:u.jsx(ju,{})})}function tl({onClick:e}){return u.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:u.jsx(Xm,{})})}function Si({label:e,value:t,onChange:n,placeholder:s,readOnly:a,hint:o,mono:c}){return u.jsxs("div",{children:[u.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,o&&u.jsx("span",{className:"text-text-muted ml-1",children:o})]}),u.jsx("input",{value:t,onChange:l=>n(l.target.value),readOnly:a,placeholder:s,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 ${c?"font-mono":""} ${a?"opacity-60":""}`})]})}function Nj({onCancel:e,onSave:t,saving:n,saveDisabled:s}){return u.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[u.jsx(rt,{variant:"secondary",onClick:e,children:"Cancel"}),u.jsx(rt,{variant:"primary",onClick:t,disabled:n||s,children:n?"Saving...":"Save"})]})}function lp({message:e}){return u.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function cS({label:e="Custom",children:t}){return u.jsxs("div",{children:[u.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),u.jsx("div",{className:"space-y-2",children:t})]})}function uS({description:e,onNew:t,newLabel:n="+ New"}){return u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsx("p",{className:"text-text-secondary text-sm",children:e}),u.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:u.jsx(rt,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function dS({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:s,onDuplicate:a,onDelete:o,children:c}){return u.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[u.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c}),u.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&u.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:u.jsx(Eu,{})}),u.jsx(tl,{onClick:a}),!e&&s&&u.jsx(Da,{onClick:s}),!e&&(t?u.jsx(ap,{onConfirm:()=>{o==null||o()},onCancel:()=>{}}):u.jsx(op,{onClick:()=>o==null?void 0:o()}))]})]})}function Aj({id:e,name:t,description:n,isBuiltIn:s,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:l,onDelete:h}){return u.jsxs(dS,{isBuiltIn:s,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:l,onDelete:h,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),u.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&u.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function hS({loading:e,hasItems:t,loadingLabel:n,emptyLabel:s,children:a}){return e&&!t?u.jsx("div",{className:"text-text-muted text-sm",children:n}):t?u.jsx("div",{className:"space-y-4",children:a}):s?u.jsx("div",{className:"text-text-muted text-sm",children:s}):null}function fS({name:e,id:t,nameLabel:n="Name",idLabel:s="ID",namePlaceholder:a="My Item",idPlaceholder:o="my-item",nameHint:c,readOnlyId:l=!1,readOnlyHint:h="(read-only)",onNameChange:f,onIdChange:p}){return u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsx(Si,{label:n,value:e,onChange:f,placeholder:a,hint:c}),u.jsx(Si,{label:s,value:t,onChange:p,readOnly:l,placeholder:o,hint:l?h:void 0,mono:!0})]})}function mS(e={}){const{initialData:t={}}=e,[n,s]=O.useState("list"),[a,o]=O.useState(null),[c,l]=O.useState(""),[h,f]=O.useState(!1),[p,m]=O.useState(t),x=O.useCallback(()=>{m(t),l(""),o(null)},[t]),_=O.useCallback(b=>{s(b),b==="list"&&x()},[x]),w=O.useCallback(b=>{m(y=>typeof b=="function"?b(y):b)},[]),k=O.useCallback((b,y={})=>{o(b),s("edit"),m({...y}),l("")},[]),v=O.useCallback(()=>{o(null),s("edit"),m(t),l("")},[t]);return{view:n,editingId:a,formError:c,saving:h,formData:p,setView:_,setEditingId:o,setFormError:l,setFormData:w,setSaving:f,resetForm:x,startEditing:k,startNew:v}}function cp(){return u.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[u.jsx("span",{children:"⚠️"}),u.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 Av({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:o,onDelete:c}){return u.jsx(Aj,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:o,onDelete:c})}function Lj({isOpen:e}){const t=Nr(H=>H.defaults),n=Nr(H=>H.userItems),s=Nr(H=>H.projectItems),a=Nr(H=>H.loading),o=Nr(H=>H.fetchSkills),c=Nr(H=>H.fetchSkill),l=Nr(H=>H.fetchDefaultContent),h=Nr(H=>H.createSkill),f=Nr(H=>H.updateSkill),p=Nr(H=>H.deleteSkill),{view:m,editingId:x,formError:_,saving:w,formData:k,setView:v,setEditingId:b,setFormError:y,setFormData:S,setSaving:E}=mS(),{clearConfirm:N}=ip();O.useEffect(()=>{e&&(o(),v("list"),b(null),N())},[e,o,N]);const T=(H,J,K,I)=>{S({name:I??H.metadata.name,id:K??H.metadata.id,description:H.metadata.description??"",version:H.metadata.version??"1.0.0",prompt:H.prompt,isReadOnly:J,destination:"user"})},L=async H=>{if(t.some(K=>K.id===H)){const K=await l(H);if(!K)return;T(K,!0),b(H),y(""),v("edit")}else{const K=await c(H);if(!K)return;T(K,!0),b(H),y(""),v("edit")}},A=async H=>{const K=t.some(D=>D.id===H)?await l(H):await c(H);if(!K)return;const I=`${H}-copy-${Date.now()}`;T(K,!1,I,`${K.metadata.name} (copy)`),b(null),y(""),v("edit")},z=()=>{S({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),v("edit")},R=async H=>{const J=await c(H);J&&(T(J,!1),b(H),y(""),v("edit"))},$=async H=>{await p(H),N()},F=async()=>{const H=x??k.id;if(!H||!k.name||!k.prompt){y("Name, ID, and prompt are required.");return}E(!0),y("");const J={metadata:{id:H,name:k.name,description:k.description,version:k.version},prompt:k.prompt},K=x?await f(x,J):await h(J,k.destination);if(E(!1),!K.success){y(K.error??"Failed to save skill.");return}v("list")},W=H=>{S(J=>({...J,name:H})),x||S(J=>({...J,id:H.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},Y=k.isReadOnly;if(m==="edit")return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex justify-between items-center mb-3",children:[u.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:Y?k.name:x?"Edit Skill":"New Skill"}),u.jsx("button",{onClick:()=>v("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),_&&u.jsx(lp,{message:_}),u.jsxs("div",{className:"space-y-3 mb-3",children:[u.jsx(fS,{name:k.name,id:k.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:W,onIdChange:()=>{}}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsx(Si,{label:"Description",value:k.description,onChange:H=>S(J=>({...J,description:H})),placeholder:"What this skill does...",readOnly:Y}),u.jsx(Si,{label:"Version",value:k.version,onChange:H=>S(J=>({...J,version:H})),placeholder:"1.0.0",readOnly:Y})]})]}),u.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[u.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),u.jsx("textarea",{value:k.prompt,onChange:H=>S(J=>({...J,prompt:H.target.value})),readOnly:Y,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"})]}),!x&&u.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[u.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),u.jsxs("select",{value:k.destination,onChange:H=>S(J=>({...J,destination:H.target.value})),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[u.jsx("option",{value:"user",children:"Global config"}),u.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),u.jsx(cp,{}),u.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[u.jsx(rt,{variant:"secondary",onClick:()=>v("list"),children:"Cancel"}),Y?u.jsx(rt,{variant:"primary",onClick:()=>{S(H=>({...H,name:H.name+" (copy)",id:`${x}-copy-${Date.now()}`,isReadOnly:!1})),b(null)},children:"Duplicate & Customize"}):u.jsx(rt,{variant:"primary",onClick:F,disabled:w||!k.name||!k.id||!k.prompt,children:w?"Saving...":"Save"})]})]});function P({items:H}){return H.map(J=>u.jsx(Av,{skill:J,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>L(J.id),onEdit:()=>R(J.id),onDuplicate:()=>A(J.id),onDelete:()=>$(J.id)},J.id))}return u.jsxs("div",{children:[u.jsx(uS,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:z}),u.jsxs(hS,{loading:a,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&u.jsxs("div",{children:[u.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),u.jsx("div",{className:"space-y-2",children:t.map(H=>u.jsx(Av,{skill:H,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>L(H.id),onDuplicate:()=>A(H.id)},H.id))})]}),n.length>0&&u.jsx(cS,{children:u.jsx(P,{items:n})}),s.length>0&&u.jsxs("div",{className:"mt-4",children:[u.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),u.jsx("div",{className:"space-y-2",children:u.jsx(P,{items:s})})]})]})]})}function Dj(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),s=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${s} ${a}`}return e}function pi(e){const t=e.split(" ").map(n=>parseInt(n,10));return t.length===3&&t.every(n=>!isNaN(n))?`#${t.map(n=>(n??0).toString(16).padStart(2,"0")).join("")}`:e}function Rj({isOpen:e,isNew:t,basePresetId:n,presetName:s,initialTokens:a,onClose:o,onSave:c}){const[l,h]=O.useState(a),[f,p]=O.useState(s);O.useEffect(()=>{h(a),p(s)},[a,s]);const m=(v,b)=>{const y=b.startsWith("#")?Dj(b):b;h(S=>({...S,[v]:y}))},x=()=>{c(f.trim()||"Untitled",{...l})},_=eS.reduce((v,b)=>{const y=b.category;return v[y]||(v[y]=[]),v[y].push(b),v},{}),w={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},k=Or.find(v=>v.id===n);return u.jsx(Nt,{isOpen:e,onClose:o,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:u.jsxs("div",{className:"flex gap-2 justify-end",children:[u.jsx("button",{type:"button",onClick:o,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),u.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),u.jsx("input",{type:"text",value:f,onChange:v=>p(v.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"})]}),!t&&u.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",u.jsx("span",{className:"text-text-primary",children:k==null?void 0:k.name})]}),Object.entries(_).map(([v,b])=>u.jsxs("div",{className:"space-y-3",children:[u.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:w[v]??v}),u.jsx("div",{className:"grid grid-cols-2 gap-3",children:b.map(y=>u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("label",{htmlFor:y.key,className:"text-xs text-text-muted",children:y.label}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"color",id:y.key,value:pi(l[y.key]??y.defaultValue),onChange:S=>m(y.key,S.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent"}),u.jsx("input",{type:"text",value:l[y.key]??y.defaultValue,onChange:S=>m(y.key,S.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"})]})]},y.key))})]},v))]})})}function Oj(){const[e,t]=O.useState(null),n=Ht(E=>E.currentPreset),s=Ht(E=>E.isCustom),a=Ht(E=>E.basePreset),o=Ht(E=>E.userPresets),c=Ht(E=>E.applyPreset),l=Ht(E=>E.applyUserPreset),h=Ht(E=>E.deleteUserPreset),f=Ht(E=>E.saveTheme),p=Ht(E=>E.followSystemTheme),m=Ht(E=>E.setFollowSystemTheme),x=E=>{c(E),f(JSON.stringify({preset:E})).catch(()=>{})},_=E=>{l(E)},w=E=>{const N=Or.find(T=>T.id===E);N&&t({type:"new",presetIndex:o.length,basePresetId:E,presetName:N.name+" Copy",tokens:{...N.tokens}})},k=E=>{const N=o[E];if(!N)return;const T=Or.find(A=>A.id===N.basePreset),L=T?{...T.tokens,...N.tokens}:N.tokens;t({type:"edit",presetIndex:E,basePresetId:N.basePreset,presetName:N.name,tokens:L})},v=(E,N)=>{if(!e)return;const T=[...o];if(e.type==="new"){const L={id:"custom-"+Date.now(),name:E,basePreset:e.basePresetId,tokens:N};T.push(L);const A=T.length-1;Ht.setState({userPresets:T}),Ht.getState().saveUserPresets(),Ht.getState().applyUserPreset(A)}else{const L=T[e.presetIndex];L&&(T[e.presetIndex]={...L,name:E,tokens:N}),Ht.setState({userPresets:T}),Ht.getState().saveUserPresets(),Ht.getState().applyUserPreset(e.presetIndex)}t(null)},b=()=>{t(null)},y=(E,N)=>{E.stopPropagation(),h(N)},S=s?a:n;return u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),u.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[u.jsx("button",{type:"button",role:"switch","aria-checked":p,onClick:()=>m(!p),className:`relative w-10 h-5 rounded-full transition-colors ${p?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,children:u.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${p?"translate-x-5":"translate-x-0"}`})}),u.jsx("span",{className:"text-sm text-text-secondary",children:"Follow system theme"})]}),u.jsx("div",{className:"grid grid-cols-5 gap-2",children:Or.map(E=>u.jsxs("div",{className:"relative group",children:[u.jsxs("button",{type:"button",onClick:()=>x(E.id),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${S===E.id&&!s?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[u.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:pi(E.tokens["color-bg-primary"]??"#000"),borderColor:pi(E.tokens["color-border"]??"#000")},children:u.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:pi(E.tokens["color-text-primary"]??"#fff")}})}),u.jsx("span",{className:"text-xs",children:E.name})]}),u.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),w(E.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:u.jsx("span",{className:"text-xs",children:"✎"})})]},E.id))}),o.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),u.jsx("div",{className:"grid grid-cols-5 gap-2",children:o.map((E,N)=>{const T=Or.find(A=>A.id===E.basePreset),L=T?{...T.tokens,...E.tokens}:E.tokens;return u.jsxs("div",{className:"relative group",children:[u.jsxs("button",{type:"button",onClick:()=>_(N),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${s&&a===E.basePreset&&S===E.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[u.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:pi(L["color-bg-primary"]??"#000"),borderColor:pi(L["color-border"]??"#000")},children:u.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:pi(L["color-text-primary"]??"#fff")}})}),u.jsx("span",{className:"text-xs truncate w-full text-center",children:E.name})]}),u.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),k(N)},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:u.jsx("span",{className:"text-xs",children:"✎"})}),u.jsx("button",{type:"button",onClick:A=>y(A,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:u.jsx(tp,{className:"w-3 h-3"})})]},E.id)})})]}),e&&u.jsx(Rj,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:b,onSave:v})]})}function Nu(){const e=Wt(a=>a.settings),t=Wt(a=>a.loading),n=Wt(a=>a.getSetting),s=Wt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:s}}function Mj({isOpen:e,onClose:t}){const[n,s]=O.useState("instructions");return u.jsx(Nt,{isOpen:e,onClose:t,title:"Settings",size:"xl",minHeight:"500px",children:u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[u.jsx(pa,{label:"Instructions",active:n==="instructions",onClick:()=>s("instructions")}),u.jsx(pa,{label:"Skills",active:n==="skills",onClick:()=>s("skills")}),u.jsx(pa,{label:"Notifications",active:n==="notifications",onClick:()=>s("notifications")}),u.jsx(pa,{label:"Display",active:n==="display",onClick:()=>s("display")}),u.jsx(pa,{label:"Shortcuts",active:n==="keybindings",onClick:()=>s("keybindings")}),u.jsx(pa,{label:"Advanced",active:n==="advanced",onClick:()=>s("advanced")})]}),n==="instructions"&&u.jsx($j,{isOpen:e}),n==="skills"&&u.jsx(Lj,{isOpen:e}),n==="notifications"&&u.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:u.jsx(Tj,{})}),n==="display"&&u.jsx(Bj,{}),n==="keybindings"&&u.jsx(zj,{}),n==="advanced"&&u.jsx(Ij,{onClose:t})]})})}function Lv({enabled:e,onClick:t}){return u.jsx("button",{type:"button",onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function Ij({onClose:e}){const[,t]=wr(),{settings:n,loading:s,getSetting:a,setSetting:o}=Nu(),c=n[$e.LLM_DISABLE_XML_PROTECTION]==="true",l=n[$e.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",h=s[$e.LLM_DISABLE_XML_PROTECTION]??!1;O.useEffect(()=>{a($e.LLM_DISABLE_XML_PROTECTION),a($e.DISPLAY_SHOW_OPEN_IN_EDITOR)},[a]);const f=async()=>{const x=String(!c);await o($e.LLM_DISABLE_XML_PROTECTION,x)},p=async()=>{const x=String(!l);await o($e.DISPLAY_SHOW_OPEN_IN_EDITOR,x)};function m(){e(),t("/onboarding")}return h?u.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):u.jsxs("div",{className:"space-y-6",children:[u.jsx("div",{children:u.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Disable XML Tool Call Protection"}),u.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Allow the model to output XML tool call format instead of JSON function calls. Some third-party providers may require this."})]}),u.jsx(Lv,{enabled:c,onClick:f})]})}),u.jsx("hr",{className:"border-border"}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Integrations"}),u.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm text-text-primary",children:'Show "Open in VSCode" links'}),u.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Display a link on file reads to open the file directly in VS Code."})]}),u.jsx(Lv,{enabled:l,onClick:p})]})]}),u.jsx("hr",{className:"border-border"}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),u.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),u.jsx(rt,{variant:"secondary",onClick:m,children:"Launch Onboarding"})]})]})}function Pj(){return u.jsx(Oj,{})}function Bj(){const{settings:e,loading:t,getSetting:n,setSetting:s}=Nu(),a=t[$e.DISPLAY_SHOW_THINKING]??!1,o=[{key:$e.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:$e.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:$e.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:$e.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:$e.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:$e.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but very slow - does not affect red/green diff coloring"}],c=Object.fromEntries(o.map(p=>[p.key,e[p.key]??"true"])),[l,h]=O.useState(()=>Object.fromEntries(o.map(p=>[p.key,c[p.key]==="true"])));O.useEffect(()=>{o.forEach(p=>n(p.key))},[n]),O.useEffect(()=>{h(Object.fromEntries(o.map(p=>[p.key,c[p.key]==="true"])))},[JSON.stringify(c)]);const f=async p=>{const m=String(!l[p]);h(x=>({...x,[p]:!x[p]})),await s(p,m)};return a?u.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):u.jsxs("div",{className:"space-y-6",children:[u.jsx(Pj,{}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),u.jsx("div",{className:"space-y-4",children:o.map(({key:p,label:m,description:x})=>u.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm text-text-primary",children:m}),u.jsx("div",{className:"text-xs text-text-muted",children:x})]}),u.jsx("button",{type:"button",onClick:()=>f(p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${l[p]?"bg-accent-primary":"bg-bg-tertiary"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l[p]?"translate-x-6":"translate-x-1"}`})})]},p))})]})]})}function zj(){const{settings:e,loading:t,getSetting:n,setSetting:s}=Nu(),a=e[$e.KEYBINDINGS],o=t[$e.KEYBINDINGS]??!1,c=fm(a),[l,h]=O.useState(null);O.useEffect(()=>{n($e.KEYBINDINGS)},[n]);const f=[{id:"terminalToggle",label:"Toggle Terminal",binding:c.terminalToggle},{id:"quickAction",label:"Quick Action",binding:c.quickAction},...c.agentSwitching.map((_,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:_}))],p=_=>{h(_)},m=O.useCallback(_=>{if(!l)return;const w=fm(a),k=structuredClone(w);if(l.startsWith("agentSwitching.")){const v=parseInt(l.split(".")[1],10);k.agentSwitching[v]=_}else l==="terminalToggle"?k.terminalToggle=_:l==="quickAction"&&(k.quickAction=_);h(null),s($e.KEYBINDINGS,JSON.stringify(k))},[l,a,s]),x=()=>{s($e.KEYBINDINGS,JSON.stringify(wa))};return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),u.jsx("button",{type:"button",onClick:x,disabled:o,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),o?u.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):u.jsx("div",{className:"space-y-1",children:f.map(_=>u.jsx(Hj,{label:_.label,binding:_.binding,isRecording:l===_.id,onStartRecording:()=>p(_.id),onBindingRecorded:m,onCancelRecording:()=>h(null)},_.id))})]})}function Hj({label:e,binding:t,isRecording:n,onStartRecording:s,onBindingRecorded:a,onCancelRecording:o}){const c=O.useRef(null),l=O.useRef(0),h=O.useRef("");return O.useEffect(()=>{if(!n)return;const f=new Set(["Control","Shift","Alt","Meta"]);let p=[];const m=_=>{if(_.preventDefault(),_.stopPropagation(),_.key==="Escape"){o();return}if(f.has(_.key)){_.ctrlKey&&!p.includes("ctrl")&&p.push("ctrl"),_.metaKey&&!p.includes("meta")&&p.push("meta"),_.altKey&&!p.includes("alt")&&p.push("alt"),_.shiftKey&&!p.includes("shift")&&p.push("shift");return}if(p.length>0||_.ctrlKey||_.metaKey||_.altKey||_.shiftKey){const v=[...p];_.ctrlKey&&!v.includes("ctrl")&&v.push("ctrl"),_.metaKey&&!v.includes("meta")&&v.push("meta"),_.altKey&&!v.includes("alt")&&v.push("alt"),_.shiftKey&&!v.includes("shift")&&v.push("shift"),a({type:"chord",key:jv(_),modifiers:v});return}const w=Date.now(),k=jv(_);if(k===h.current&&w-l.current<400){a({type:"double-press",key:k,threshold:300});return}l.current=w,h.current=k},x=_=>{_.key==="Control"&&(p=p.filter(w=>w!=="ctrl")),_.key==="Shift"&&(p=p.filter(w=>w!=="shift")),_.key==="Alt"&&(p=p.filter(w=>w!=="alt")),_.key==="Meta"&&(p=p.filter(w=>w!=="meta"))};return window.addEventListener("keydown",m,!0),window.addEventListener("keyup",x,!0),()=>{window.removeEventListener("keydown",m,!0),window.removeEventListener("keyup",x,!0)}},[n,a,o]),u.jsxs("div",{ref:c,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${n?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[u.jsx("span",{className:"text-sm text-text-primary",children:e}),u.jsx("div",{className:"flex items-center gap-2",children:n?u.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):u.jsx("button",{type:"button",onClick:s,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:iS(t)})})]})}function pa({label:e,active:t,onClick:n}){return u.jsx("button",{onClick:n,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function $j({isOpen:e}){const{settings:t,loading:n,getSetting:s,setSetting:a}=Nu(),o=t[$e.GLOBAL_INSTRUCTIONS]??"",c=n[$e.GLOBAL_INSTRUCTIONS]??!1,[l,h]=O.useState(o),[f,p]=O.useState(!1),[m,x]=O.useState(!1);O.useEffect(()=>{e&&s($e.GLOBAL_INSTRUCTIONS)},[e,s]),O.useEffect(()=>{h(o),p(!1)},[o]);const _=async()=>{x(!0),await a($e.GLOBAL_INSTRUCTIONS,l),x(!1),p(!1)},w=()=>{h(o),p(!1)},k=c||m;return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),u.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),u.jsx("textarea",{value:l,onChange:v=>{h(v.target.value),p(!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:k})]}),f&&u.jsx(cp,{}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx(rt,{variant:"secondary",onClick:w,disabled:!f,children:"Discard"}),u.jsx(rt,{variant:"primary",onClick:_,disabled:!f||k,children:m?"Saving...":"Save"})]})]})}var kf={exports:{}},Dv;function Uj(){return Dv||(Dv=1,(function(e,t){(function(n,s){e.exports=s()})(globalThis,(()=>(()=>{var n={4567:function(c,l,h){var f=this&&this.__decorate||function(y,S,E,N){var T,L=arguments.length,A=L<3?S:N===null?N=Object.getOwnPropertyDescriptor(S,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(y,S,E,N);else for(var z=y.length-1;z>=0;z--)(T=y[z])&&(A=(L<3?T(A):L>3?T(S,E,A):T(S,E))||A);return L>3&&A&&Object.defineProperty(S,E,A),A},p=this&&this.__param||function(y,S){return function(E,N){S(E,N,y)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const m=h(9042),x=h(9924),_=h(844),w=h(4725),k=h(2585),v=h(3656);let b=l.AccessibilityManager=class extends _.Disposable{constructor(y,S,E,N){super(),this._terminal=y,this._coreBrowserService=E,this._renderService=N,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 T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,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 x.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((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
58
|
+
*/var ov;function e2(){if(ov)return vf;ov=1;var e=Su();function t(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function l(m,x){var _=x(),w=s({inst:{value:_,getSnapshot:x}}),k=w[0].inst,v=w[1];return o(function(){k.value=_,k.getSnapshot=x,h(k)&&v({inst:k})},[m,_,x]),a(function(){return h(k)&&v({inst:k}),m(function(){h(k)&&v({inst:k})})},[m]),c(_),_}function h(m){var x=m.getSnapshot;m=m.value;try{var _=x();return!n(m,_)}catch{return!0}}function f(m,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return vf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,vf}var lv;function t2(){return lv||(lv=1,yf.exports=e2()),yf.exports}var n2=t2();const r2=HE.useInsertionEffect,s2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",i2=s2?O.useLayoutEffect:O.useEffect,a2=r2||i2,H0=e=>{const t=O.useRef([e,(...n)=>t[0](...n)]).current;return a2(()=>{t[0]=e}),t[1]},o2="popstate",Gm="pushState",Wm="replaceState",l2="hashchange",cv=[o2,Gm,Wm,l2],c2=e=>{for(const t of cv)addEventListener(t,e);return()=>{for(const t of cv)removeEventListener(t,e)}},$0=(e,t)=>n2.useSyncExternalStore(c2,e,t),uv=()=>location.search,u2=({ssrSearch:e}={})=>$0(uv,e!=null?()=>e:uv),dv=()=>location.pathname,d2=({ssrPath:e}={})=>$0(dv,e!=null?()=>e:dv),h2=(e,{replace:t=!1,state:n=null}={})=>history[t?Wm:Gm](n,"",e),f2=(e={})=>[d2(e),h2],hv=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[hv]>"u"){for(const e of[Gm,Wm]){const t=history[e];history[e]=function(){const n=t.apply(this,arguments),s=new Event(e);return s.arguments=arguments,dispatchEvent(s),n}}Object.defineProperty(window,hv,{value:!0})}const m2=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",U0=(e="")=>e==="/"?"":e,p2=(e,t)=>e[0]==="~"?e.slice(1):U0(t)+e,g2=(e="",t)=>m2(fv(U0(e)),fv(t)),fv=e=>{try{return decodeURI(e)}catch{return e}},F0={hook:f2,searchHook:u2,parser:ZE,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},V0=O.createContext(F0),Ia=()=>O.useContext(V0),G0={},W0=O.createContext(G0),x2=()=>O.useContext(W0),Cu=e=>{const[t,n]=e.hook(e);return[g2(e.base,t),H0((s,a)=>e.aroundNav(n,p2(s,e.base),a))]},wr=()=>Cu(Ia()),qm=(e,t,n,s)=>{const{pattern:a,keys:o}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",s),c=a.exec(n)||[],[l,...h]=c;return l!==void 0?[!0,(()=>{const f=o!==!1?Object.fromEntries(o.map((m,x)=>[m,h[x]])):c.groups;let p={...h};return f&&Object.assign(p,f),p})(),...s?[l]:[]]:[!1,null]},Km=e=>qm(Ia().parser,e,wr()[0]),_2=({children:e,...t})=>{var p,m,x;const n=Ia(),s=t.hook?F0:n;let a=s;const[o,c=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];o&&(t.ssrSearch=c,t.ssrPath=o),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let l=O.useRef({}),h=l.current,f=h;for(let _ in s){const w=_==="base"?s[_]+(t[_]??""):t[_]??s[_];h===f&&w!==f[_]&&(l.current=f={...f}),f[_]=w,(w!==s[_]||w!==a[_])&&(a=f)}return O.createElement(V0.Provider,{value:a,children:e})},mv=({children:e,component:t},n)=>t?O.createElement(t,{params:n}):typeof e=="function"?e(n):e,y2=e=>{let t=O.useRef(G0);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([s,a])=>a!==n[s])?e:n},Mo=({path:e,nest:t,match:n,...s})=>{const a=Ia(),[o]=Cu(a),[c,l,h]=n??qm(a.parser,e,o,t),f=y2({...x2(),...l});if(!c)return null;const p=h?O.createElement(_2,{base:h},mv(s,f)):mv(s,f);return O.createElement(W0.Provider,{value:f,children:p})},Xn=O.forwardRef((e,t)=>{const n=Ia(),[s,a]=Cu(n),{to:o="",href:c=o,onClick:l,asChild:h,children:f,className:p,replace:m,state:x,transition:_,...w}=e,k=H0(b=>{b.ctrlKey||b.metaKey||b.altKey||b.shiftKey||b.button!==0||(l==null||l(b),b.defaultPrevented||(b.preventDefault(),a(c,e)))}),v=n.hrefs(c[0]==="~"?c.slice(1):n.base+c,n);return h&&O.isValidElement(f)?O.cloneElement(f,{onClick:k,href:v}):O.createElement("a",{...w,onClick:k,href:v,className:p!=null&&p.call?p(s===c):p,children:f,ref:t})}),q0=e=>Array.isArray(e)?e.flatMap(t=>q0(t&&t.type===O.Fragment?t.props.children:t)):[e],v2=({children:e,location:t})=>{const n=Ia(),[s]=Cu(n);for(const a of q0(e)){let o=0;if(O.isValidElement(a)&&(o=qm(n.parser,a.props.path,t||s,a.props.nest))[0])return O.cloneElement(a,{match:o})}return null};function b2(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function K0(){if(typeof crypto<"u"&&crypto.randomUUID)try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class S2{constructor(t){me(this,"ws",null);me(this,"handlers",new Set);me(this,"statusHandler",null);me(this,"baseUrl");me(this,"isReconnecting",!1);me(this,"connectingPromise",null);me(this,"lastCloseCode",0);me(this,"reconnectAttempts",0);me(this,"manualReconnectScheduled",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,s;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((s=this.ws)==null?void 0:s.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,o)=>{try{const c=this.getUrl();this.ws=new WebSocket(c);const l=setTimeout(()=>{var h;((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING&&(this.ws.close(),o(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var h;clearTimeout(l),this.isReconnecting=!1,this.connectingPromise=null,(h=this.statusHandler)==null||h.call(this,"connected"),a()},this.ws.onclose=h=>{var f,p,m;clearTimeout(l),this.lastCloseCode=h.code,((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),o(new Error(`Connection closed: ${h.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=h=>{clearTimeout(l),console.error("WebSocket error:",h),this.connectingPromise=null,o(h)},this.ws.onmessage=h=>{try{const f=JSON.parse(h.data);b2(f)&&this.handlers.forEach(p=>p(f))}catch(f){console.error("Failed to parse WebSocket message:",f)}}}catch(c){this.connectingPromise=null,o(c)}}),this.connectingPromise)))}attemptReconnect(){var a;if(([1e3,1005,1006,4e3].includes(this.lastCloseCode)||this.lastCloseCode===0)&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(a=this.statusHandler)==null||a.call(this,"reconnecting");const s=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(()=>{})},s)}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(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const s=K0(),a={id:s,type:t,payload:n};return this.ws.send(JSON.stringify(a)),s}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const w2=window.location.protocol==="https:"?"wss:":"ws:";let cm=window.location.port;cm||(cm=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const C2=`${w2}//${window.location.hostname}:${cm}/ws`,Zt=new S2(C2),Vs=async(e,t,n)=>{try{const s=await je(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return s.ok?{success:!0}:{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}},ku=async(e,t,n)=>{try{const s=await je(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await s.json();return s.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function Y0(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Rc=[];const Rr=Jn()((e,t)=>{function n(){if(Rc.length===0)return;const a=Rc;Rc=[],e(o=>({logs:[...o.logs,...a]}))}const s=Y0(n);return{workdir:null,status:null,logs:[],config:null,loading:!1,setWorkdir:a=>{t().workdir!==a&&(e({workdir:a,status:null,logs:[],config:null,loading:!0}),a&&(t().fetchStatus(),t().fetchConfig()))},fetchStatus:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server?workdir=${encodeURIComponent(a)}`)).json();e({status:c,loading:!1})}catch{e({loading:!1})}},fetchConfig:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/config?workdir=${encodeURIComponent(a)}`)).json();e({config:c.config??null})}catch{}},fetchLogs:async()=>{const a=t().workdir;if(a)try{const l=(await(await je(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(h=>({stream:h.stream,content:h.content}));e({logs:l})}catch{}},start:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/start?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},stop:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/stop?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c})}catch{}},restart:async()=>{const a=t().workdir;if(a)try{const c=await(await je(`/api/dev-server/restart?workdir=${encodeURIComponent(a)}`,{method:"POST"})).json();e({status:c,logs:[]})}catch{}},saveConfig:async a=>{const o=t().workdir;if(o)try{const l=await(await je(`/api/dev-server/config?workdir=${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();e({config:l.config??a}),t().fetchStatus()}catch{}},handleMessage:a=>{const o=t().workdir;if(o)switch(a.type){case"devServer.output":{const c=a.payload;if(c.workdir!==o)return;Rc.push({stream:c.stream,content:c.content}),s();break}case"devServer.state":{const c=a.payload;if(c.workdir!==o)return;e(l=>({status:l.status?{...l.status,state:c.state,errorMessage:c.errorMessage}:l.status}));break}}}}});function k2(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 pv(e,t,n){const s=await je(`/api/providers/${e}/models/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok){const a=await s.json();throw new Error(a.error??"Failed to update model")}return s.json()}function gv(e,t,n,s){return e.map(a=>a.id===t?{...a,models:a.models.map(o=>o.id===n?{...o,...s,source:"user"}:o)}:a)}const E2=3e4;function j2(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 Dt=Jn((e,t)=>({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 n=await je("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const s=await n.json();e({version:s.version,model:s.model,maxContext:s.maxContext,llmUrl:s.llmUrl,llmStatus:s.llmStatus,backend:s.backend,providers:s.providers??[],activeProviderId:s.activeProviderId??null,defaultModelSelection:s.defaultModelSelection??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}},refreshModel:async()=>{try{const n=await je("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const s=await n.json(),o=Ce.getState().currentSession;if(o!=null&&o.providerId&&o.providerModel){e({llmStatus:s.llmStatus,backend:s.backend});return}e({model:s.model,llmStatus:s.llmStatus,backend:s.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:s,providers:a}=t();if(n===s)return!0;e({activating:!0,error:null});try{const o=await je(`/api/providers/${n}/activate`,{method:"POST"});if(!o.ok){const l=await o.json();throw new Error(l.error??"Failed to activate provider")}const c=await o.json();return e({activeProviderId:c.activeProviderId,model:c.model,backend:c.backend,providers:a.map(l=>({...l,isActive:l.id===c.activeProviderId})),activating:!1}),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to switch provider",activating:!1}),!1}},syncFromSession:(n,s)=>{var l;const{providers:a,defaultModelSelection:o}=t();let c=s;if(!c){const h=o?o.split("/"):[],f=h[0],p=h.slice(1).join("/")??"";if(f===n&&p)c=p;else{const m=a.find(x=>x.id===n);c=((l=m==null?void 0:m.models[0])==null?void 0:l.id)??""}}e({activeProviderId:n,model:c,defaultModelSelection:`${n}/${c}`,providers:a.map(h=>({...h,isActive:h.id===n}))})},updateModelContext:async(n,s,a)=>{e({activating:!0,error:null});try{const o=await pv(n,s,{contextWindow:a}),{providers:c}=t();return e({providers:gv(c,n,s,{contextWindow:a}),activating:!1}),o.contextState&&Ce.getState().updateContextState(o.contextState),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to update model context",activating:!1}),!1}},updateModelSettings:async(n,s,a)=>{e({activating:!0,error:null});try{const o=await pv(n,s,a),{providers:c}=t(),l={...a.contextWindow!==void 0&&{contextWindow:a.contextWindow},...k2({temperature:a.temperature??void 0,topP:a.topP??void 0,topK:a.topK??void 0,maxTokens:a.maxTokens??void 0}),...a.supportsVision!==void 0&&{supportsVision:a.supportsVision}};return e({providers:gv(c,n,s,l),activating:!1}),o.contextState&&Ce.getState().updateContextState(o.contextState),!0}catch(o){return e({error:o instanceof Error?o.message:"Failed to update model settings",activating:!1}),!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const s=await je(`/api/providers/${n}/refresh`,{method:"POST"});if(!s.ok){const c=await s.json();throw new Error(c.error??"Failed to refresh models")}const a=await s.json(),{providers:o}=t();return e({providers:o.map(c=>c.id===n?{...c,models:a.models,status:a.status}:c),activating:!1}),!0}catch(s){return e({error:s instanceof Error?s.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:s}=t();if(n)return;const a=setInterval(()=>{s()},E2);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:s}=t();return n.find(a=>a.id===s)},getModelContext:n=>{const{providers:s,activeProviderId:a}=t(),o=s.find(l=>l.id===a);if(!o)return 2e5;const c=o.models.find(l=>l.id===n);return(c==null?void 0:c.contextWindow)??2e5}})),Pt=Jn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const s=await(await je("/api/projects")).json();e({projects:s.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,s)=>{try{const a=await je("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:s})});if(!a.ok){const c=await a.json().catch(()=>({}));return{error:{code:c.code||"UNKNOWN",path:c.path,message:c.error}}}const o=await a.json();return await t().listProjects(),o.project}catch{return null}},loadProject:async n=>{try{const s=await je(`/api/projects/${n}`);if(!s.ok)return null;const a=await s.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,s)=>{var a;try{const o=await je(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)return null;const c=await o.json();return((a=t().currentProject)==null?void 0:a.id)===n&&e({currentProject:c.project}),await t().listProjects(),c.project}catch{return null}},deleteProject:async n=>{var s;try{return(await je(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((s=t().currentProject)==null?void 0:s.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,s)=>{var a;try{const o=await je(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:s})});if(!o.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const c=await o.json();e({currentProject:c.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}}));let Oc=[];const Yo=Jn()((e,t)=>{function n(){if(Oc.length===0)return;const a=Oc;Oc=[],e(o=>{const c={...o.logs};for(const l of a){const h=c[l.processId]??[];c[l.processId]=[...h,{offset:h.length,content:l.content,timestamp:Date.now(),stream:l.stream}]}return{logs:c}})}const s=Y0(n);return{processes:[],logs:{},loading:!1,setProcesses:a=>e({processes:a}),addProcess:a=>e(o=>({processes:[...o.processes,a]})),updateProcess:(a,o)=>e(c=>({processes:c.processes.map(l=>l.id===a?{...l,...o}:l)})),removeProcess:a=>e(o=>({processes:o.processes.filter(c=>c.id!==a),logs:Object.fromEntries(Object.entries(o.logs).filter(([c])=>c!==a))})),stopProcess:async(a,o)=>{try{(await je(`/api/sessions/${o}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,o,c)=>{Oc.push({processId:a,stream:o,content:c}),s()},setLogs:(a,o)=>e(c=>({logs:{...c.logs,[a]:o}})),clearLogs:a=>e(o=>({logs:{...o.logs,[a]:[]}})),handleMessage:(a,o)=>{switch(a){case"backgroundProcess.started":{const{processId:c,name:l,pid:h,status:f}=o;e(p=>({processes:[...p.processes,{id:c,sessionId:"",name:l,command:"",cwd:"",pid:h,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const c=o.processId,l=o.stream,h=o.content;t().appendLog(c,l,h);break}case"backgroundProcess.exited":{const c=o.processId,l=o.exitCode;e(h=>({processes:h.processes.map(f=>f.id===c?{...f,status:"exited",exitCode:l}:f)}));break}case"backgroundProcess.removed":{const c=o.processId;t().removeProcess(c);break}}}}}),T2=[{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"}],N2=[{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"}],X0={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"},$s={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},Q0={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},um={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...$s},waiting_for_user:{...$s},phase_done:{...$s},phase_blocked:{...$s},new_message:{...Q0}},agentOverrides:{}};function J0(e,t,n){var o;const s=e.events[t];if(!n)return s;const a=(o=e.agentOverrides[n])==null?void 0:o[t];return a?{soundEnabled:a.soundEnabled??s.soundEnabled,browserNotification:a.browserNotification??s.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:s.customSoundUrl}:s}const gi=Jn((e,t)=>({settings:um,loaded:!1,load:()=>{Wt.getState().getSetting($e.NOTIFICATION_SETTINGS);const s=Wt.subscribe(o=>{const c=o.settings[$e.NOTIFICATION_SETTINGS];if(c!==void 0)try{const l=JSON.parse(c);e({settings:xv(l),loaded:!0})}catch{e({loaded:!0})}}),a=Wt.getState().settings[$e.NOTIFICATION_SETTINGS];if(a)try{const o=JSON.parse(a);e({settings:xv(o),loaded:!0})}catch{e({loaded:!0})}return s},update:n=>{e({settings:n}),bf(n)},updateEvent:(n,s)=>{const a=t().settings,o={...a,events:{...a.events,[n]:{...a.events[n],...s}}};e({settings:o}),bf(o)},updateAgentOverride:(n,s,a)=>{var h;const o=t().settings,c={...o.agentOverrides};if(a===null){if(c[n]){const f={...c[n]};delete f[s],Object.keys(f).length===0?delete c[n]:c[n]=f}}else c[n]={...c[n],[s]:{...((h=c[n])==null?void 0:h[s])??{},...a}};const l={...o,agentOverrides:c};e({settings:l}),bf(l)}}));function bf(e){Wt.getState().setSetting($e.NOTIFICATION_SETTINGS,JSON.stringify(e))}function xv(e){var t,n,s,a,o;return{soundEnabled:e.soundEnabled??um.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??um.browserNotificationEnabled,events:{complete:{...$s,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...$s,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...$s,...(s=e.events)==null?void 0:s.phase_done},phase_blocked:{...$s,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...Q0,...(o=e.events)==null?void 0:o.new_message}},agentOverrides:e.agentOverrides??{}}}const _v=new Map;function A2(e){let t=_v.get(e);return t||(t=new Audio(e),t.volume=.5,_v.set(e,t)),t}let Z0=typeof Notification<"u"?Notification.permission:"denied";function L2(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(Z0=e,e))}const D2={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},R2={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 O2(e){typeof Notification>"u"||Z0==="granted"&&(document.hasFocus()||new Notification(D2[e],{body:R2[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function ul(e,t){const{settings:n}=gi.getState(),s=J0(n,e,t);if(n.soundEnabled&&s.soundEnabled){const a=s.customSoundUrl??X0[e],o=A2(a);o.currentTime=0,o.play().catch(()=>{})}n.browserNotificationEnabled&&s.browserNotification&&O2(e)}const M2=e=>ul("complete",e),I2=e=>ul("phase_done",e),P2=e=>ul("phase_blocked",e),yv=e=>ul("waiting_for_user",e),B2=e=>ul("new_message",e);let Io=!1,Tr=null;const Sf=new Set,wf=new Set,Mc=new Map,Jt={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let ja=null,wn=null;function Cf(){ja===null&&(ja=requestAnimationFrame(()=>{ja=null,wn==null||wn()}))}function ui(){ja!==null&&(cancelAnimationFrame(ja),ja=null)}function Vt(e,t){return t!==null&&e.sessionId===t}function z2(e,t,n){return e.id!==void 0||Vt(e,t)||n===!0&&e.sessionId!==void 0}function H2(e,t){return e.includes(t)?e:[...e,t]}function Po(e,t){return e.filter(n=>n!==t)}function $2(e,t){const n=e.find(o=>o.id===t.id),s=t.messageCount??t.messages.length,a=n?{...n,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:s,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,mode:t.mode,phase:t.phase,isRunning:t.isRunning,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(o=>o.status.type==="passed").length,messageCount:s};return n?e.map(o=>o.id===t.id?a:o):[a,...e]}function vv(e,t,n){return e.map(s=>{const a=(n==null?void 0:n.id)===s.id?n:null,o=t.find(c=>c.id===s.id);return{...s,title:s.title??(o==null?void 0:o.title),mode:(a==null?void 0:a.mode)??(o==null?void 0:o.mode)??s.mode,phase:(a==null?void 0:a.phase)??(o==null?void 0:o.phase)??s.phase,isRunning:s.isRunning&&(o==null?void 0:o.isRunning)!==!1,messageCount:s.messageCount,recentUserPrompts:s.recentUserPrompts}})}const bv=new Map;function Wo(e,t){var o;const n=t===((o=e.currentSession)==null?void 0:o.id)?e.currentSession:null,s=e.sessions.find(c=>c.id===t),a=(n==null?void 0:n.mode)??(s==null?void 0:s.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function U2(e,t){if(e.type==="chat.done"){const n=e.payload,s=Wo(t,e.sessionId),a=n.agentType??s;n.reason==="complete"&&M2(a),n.reason==="waiting_for_user"&&yv(a);return}if(e.type==="chat.path_confirmation"){const n=Wo(t,e.sessionId);yv(n);return}if(e.type==="task.completed"){const n=Wo(t,e.sessionId);I2(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,s=bv.get(e.sessionId)??null;if(bv.set(e.sessionId,n.phase),s===n.phase)return;const a=Wo(t,e.sessionId);n.phase==="blocked"&&P2(a)}}const Ce=Jn((e,t)=>(wn=()=>{const n=Jt;if(!n.messageId)return;const s=n.deltaContent.length>0,a=n.thinkingContent.length>0,o=n.toolOutput.length>0;if(!s&&!a&&!o)return;const c=n.deltaContent,l=n.thinkingContent,h=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(f=>{var m;const p=f.streamingMessage;if(p&&p.id===n.messageId){const x={...p};if(s&&(x.content=x.content+c),a&&(x.thinkingContent=(x.thinkingContent??"")+l),o){const _=new Set;x.toolCalls=(m=x.toolCalls)==null?void 0:m.map(k=>{const v=h.filter(b=>b.callId===k.id);return v.length===0?k:(_.add(k.id),{...k,streamingOutput:[...k.streamingOutput??[],...v.map(b=>({stream:b.stream,content:b.content,timestamp:Date.now()}))]})});const w=h.filter(k=>!_.has(k.callId));w.length>0&&Jt.toolOutput.push(...w)}return{streamingMessage:x}}if(o){const x=new Set,_=f.messages.map(k=>{var b;if(k.id!==n.messageId)return k;const v=(b=k.toolCalls)==null?void 0:b.map(y=>{const S=h.filter(E=>E.callId===y.id);return S.length===0?y:(x.add(y.id),{...y,streamingOutput:[...y.streamingOutput??[],...S.map(E=>({stream:E.stream,content:E.content,timestamp:Date.now()}))]})});return{...k,toolCalls:v}}),w=h.filter(k=>!x.has(k.callId));return w.length>0&&Jt.toolOutput.push(...w),{messages:_}}return f})},{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],pendingQuestion:null,visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,error:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let s=!1;try{s=(await(await je("/api/auth")).json()).requiresAuth}catch{}if(s&&!Zt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Zt.onStatusChange(a=>{var o;if(e({connectionStatus:a}),a==="connected"){t().listSessions(void 0),Pt.getState().listProjects();const c=(o=t().currentSession)==null?void 0:o.id;c&&t().loadSession(c)}});try{if(await Zt.connect(),!Io){Io=!0;const a=t().handleServerMessage;Tr=Zt.subscribe(a)}}catch(a){console.error("Failed to connect:",a);const o=Zt.getLastCloseCode();if(!Zt.hasToken()&&(o===1006||o===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Tr&&(Tr(),Tr=null),Io=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Zt.disconnect(),Tr&&(Tr(),Tr=null),Io=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Zt.disconnect(),Tr&&(Tr(),Tr=null),Io=!1,e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async n=>{try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:n})});if(!s.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:a}=await s.json();Zt.setToken(a),e({showPasswordModal:!1}),t().connect();const{listProjects:o}=Pt.getState(),{fetchConfig:c}=Dt.getState();o(),c(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Zt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,s)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const o=await je("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:n,title:s})});if(!o.ok)return e({pendingSessionCreate:!1}),null;const c=await o.json();try{Zt.send("session.load",{sessionId:c.session.id})}catch{}return c.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!wf.has(n)){wf.add(n);try{const s=t().currentSession;!s||s.id!==n?(ui(),e({currentSession:null,unreadSessionIds:Po(t().unreadSessionIds,n),subAgentContextStates:{},messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingPathConfirmations:[],queuedMessages:[],abortInProgress:!1,error:null,pendingSessionCreate:!1})):e({unreadSessionIds:Po(t().unreadSessionIds,n)});const a=await je(`/api/sessions/${n}`);if(!a.ok)return;const o=await a.json();e({currentSession:o.session,messages:o.messages??[],contextState:o.contextState,queuedMessages:o.queueState??[]}),Zt.send("session.load",{sessionId:n});try{const c=await je(`/api/sessions/${n}/background-processes`);if(c.ok){const l=await c.json();Yo.getState().setProcesses(l.processes??[])}}catch{}}catch{}finally{wf.delete(n)}}},listSessions:async(n,s=20)=>{const a=n??"global";if(Mc.has(a))return console.warn("[STORE] listSessions skipped (already listing):",a),Mc.get(a);const o=(async()=>{try{const c=new URLSearchParams;c.set("limit",String(s)),n&&c.set("projectId",n);const h=await(await je(`/api/sessions?${c.toString()}`)).json(),f=h.sessions??[];e(p=>({sessions:vv(f,p.sessions,p.currentSession),sessionsHasMore:n?h.hasMore??!1:!0}))}catch{}finally{Mc.delete(a)}})();return Mc.set(a,o),o},loadMoreSessions:async n=>{const s=t();if(!(s.sessionsPaginationLoading||!s.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const a=new URLSearchParams;a.set("limit","20"),a.set("offset",String(s.sessions.length)),a.set("projectId",n);const c=await(await je(`/api/sessions?${a.toString()}`)).json(),l=c.sessions??[];e(h=>({sessions:[...h.sessions,...l.map(f=>{const p=h.sessions.find(m=>m.id===f.id);return(p==null?void 0:p.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:c.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var s;try{return(await je(`/api/sessions/${n}`,{method:"DELETE"})).ok?(await t().listSessions(),((s=t().currentSession)==null?void 0:s.id)===n&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(n,s)=>{var a;try{const o=await je(`/api/sessions/${n}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s})});if(!o.ok)return!1;if(await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===n){const l=await o.json();l.session&&e({currentSession:l.session})}return!0}catch{return!1}},deleteAllSessions:async n=>{try{return(await je(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{ui(),e(n=>({currentSession:null,messages:[],streamingMessageId:null,streamingMessage:null,currentTodos:[],contextState:null,pendingSessionCreate:!1,unreadSessionIds:n.currentSession?Po(n.unreadSessionIds,n.currentSession.id):n.unreadSessionIds}))},sendMessage:async(n,s,a)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o){e({streamingMessageId:null});try{const h=await(await je(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:s,messageKind:a==null?void 0:a.messageKind})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error sending message:",l)}}},stopGeneration:async()=>{var s;const n=(s=t().currentSession)==null?void 0:s.id;if(n&&!t().abortInProgress){ui(),wn==null||wn(),e({abortInProgress:!0});try{await je(`/api/sessions/${n}/stop`,{method:"POST"})}catch(a){console.error("Error stopping generation:",a)}}},continueGeneration:async()=>{var s;const n=(s=t().currentSession)==null?void 0:s.id;if(n){e({streamingMessageId:null});try{await je(`/api/sessions/${n}/continue`,{method:"POST"})}catch(a){console.error("Error continuing generation:",a)}}},launchRunner:(n,s,a)=>{e({streamingMessageId:null});const o={};n!=null&&n.trim()&&(o.content=n),s&&s.length>0&&(o.attachments=s),a&&(o.workflowId=a),Zt.send("runner.launch",o)},switchMode:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const o=await je(`/api/sessions/${s}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:n})});if(!o.ok){console.error("Failed to switch mode:",await o.json());return}const c=await o.json();c.session&&e({currentSession:c.session})}catch(o){console.error("Error switching mode:",o)}},switchDangerLevel:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const o=await je(`/api/sessions/${s}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:n})});if(!o.ok){console.error("Failed to switch danger level:",await o.json());return}const c=await o.json();c.session&&e({currentSession:c.session})}catch(o){console.error("Error switching danger level:",o)}},acceptAndBuild:(n,s,a)=>{var l;e({streamingMessageId:null});const o={};n&&(o.workflowId=n),s!=null&&s.trim()&&(o.content=s),a&&a.length>0&&(o.attachments=a);const c=(l=t().currentSession)==null?void 0:l.id;c&&je(`/api/sessions/${c}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{Zt.send("runner.launch",o)})},editCriteria:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const o=await je(`/api/sessions/${s}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:n})});o.ok||console.error("Failed to update criteria:",await o.json())}catch(o){console.error("Error updating criteria:",o)}},compactContext:()=>{Zt.send("context.compact",{})},setSessionProvider:async(n,s)=>{var a,o;try{const c=(a=t().currentSession)==null?void 0:a.id;if(!c)return null;const l=await je(`/api/sessions/${c}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...s?{model:s}:{}})});if(!l.ok)return null;const h=await l.json();if(e({currentSession:h.session,messages:h.messages??[],contextState:h.contextState}),(o=h.session)!=null&&o.providerId){const f=Dt.getState();f.providers.find(m=>m.id===h.session.providerId)&&f.syncFromSession(h.session.providerId,h.session.providerModel??"")}return h.session}catch{return null}},updateContextState:n=>{e({contextState:n})},updateSubAgentContextState:(n,s)=>{e(a=>({subAgentContextStates:{...a.subAgentContextStates,[n]:s}}))},clearSubAgentContextState:n=>{e(s=>{const a={...s.subAgentContextStates};return delete a[n],{subAgentContextStates:a}})},confirmPath:async(n,s,a=!1)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o)try{await je(`/api/sessions/${o}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,approved:s,alwaysAllow:a})})}catch(l){console.error("Error confirming path:",l)}},answerQuestion:async(n,s)=>{var o;const a=(o=t().currentSession)==null?void 0:o.id;if(a){try{await je(`/api/sessions/${a}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:s})})}catch(c){console.error("Error answering question:",c)}e({pendingQuestion:null})}},queueAsap:async(n,s,a)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o)try{const h=await(await je(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:s,messageKind:a})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing ASAP message:",l)}},queueCompletion:async(n,s,a)=>{var c;const o=(c=t().currentSession)==null?void 0:c.id;if(o)try{const h=await(await je(`/api/sessions/${o}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,attachments:s,messageKind:a})})).json();h.queueState&&e({queuedMessages:h.queueState})}catch(l){console.error("Error queueing completion message:",l)}},cancelQueued:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const c=await(await je(`/api/sessions/${s}/queue/${n}`,{method:"DELETE"})).json();c.queueState&&e({queuedMessages:c.queueState})}catch(o){console.error("Error canceling queued message:",o)}},clearError:()=>{e({error:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{var c,l,h,f,p,m,x,_,w,k,v,b,y,S,E,N,T,L,A,z,R,$,F,W,Y;const s=t();U2(n,s);const a=((c=s.currentSession)==null?void 0:c.id)??null,o=()=>{const P=n.sessionId;!P||P===a||e(H=>({unreadSessionIds:H2(H.unreadSessionIds,P)}))};switch(n.type){case"session.state":{const P=n.payload;if(!z2(n,a,s.pendingSessionCreate))break;ui();const H=P.messages.find(K=>K.isStreaming)??null,J=t().pendingSessionCreate===!0;if(e({currentSession:P.session,sessions:$2(t().sessions,P.session),unreadSessionIds:Po(t().unreadSessionIds,P.session.id),messages:P.messages,streamingMessageId:(H==null?void 0:H.id)??null,streamingMessage:H,currentTodos:[],pendingPathConfirmations:P.pendingConfirmations??[],error:null,...J?{pendingSessionCreate:P.session.id}:{}}),P.session.providerId){const K=Dt.getState();K.providers.find(D=>D.id===P.session.providerId)&&K.syncFromSession(P.session.providerId,P.session.providerModel??"")}break}case"session.list":{const P=n.payload;e(H=>({sessions:vv(P.sessions,H.sessions,H.currentSession)}));break}case"session.deleted":{const P=n.payload;e(H=>({unreadSessionIds:Po(H.unreadSessionIds,P.sessionId)})),t().listSessions();break}case"session.deletedAll":{t().listSessions();break}case"session.running":{const P=n.payload,H=n.sessionId,J=(l=t().currentSession)==null?void 0:l.id,K=H&&H!==J;e(I=>({sessions:I.sessions.map(D=>D.id===H?{...D,isRunning:P.isRunning}:D)})),K||e(I=>({currentSession:I.currentSession?{...I.currentSession,isRunning:P.isRunning}:null,...P.isRunning?{}:{abortInProgress:!1,queuedMessages:[]}}));break}case"chat.message":{if(!Vt(n,((h=t().currentSession)==null?void 0:h.id)??null)){o();break}const P=n.payload;e(H=>{var K;if(H.messages.some(I=>I.id===P.message.id))return H;const J=P.message.role==="user";return console.warn("[Message Count] chat.message received:",{messageId:P.message.id,role:P.message.role,isUserMessage:J,willCount:J,currentCount:(K=H.sessions.find(I=>I.id===n.sessionId))==null?void 0:K.messageCount}),{messages:[...H.messages,P.message],sessions:H.sessions.map(I=>I.id===n.sessionId&&J?{...I,messageCount:I.messageCount+1}:I),streamingMessageId:P.message.isStreaming?P.message.id:H.streamingMessageId,streamingMessage:P.message.isStreaming?P.message:H.streamingMessage}});break}case"chat.message_updated":{if(!Vt(n,((f=t().currentSession)==null?void 0:f.id)??null)){o();break}const P=n.payload,H=P.updates.isStreaming===!1&&t().streamingMessageId===P.messageId;H&&(ui(),wn==null||wn()),e(J=>{const K=J.streamingMessage,I=H;if(K&&K.id===P.messageId){const D={...K,...P.updates};return{messages:J.messages.map(B=>B.id===P.messageId?D:B),streamingMessageId:I?null:J.streamingMessageId,streamingMessage:I?null:{...K,...P.updates}}}return{messages:J.messages.map(D=>D.id===P.messageId?{...D,...P.updates}:D),streamingMessageId:I?null:J.streamingMessageId}});break}case"chat.delta":{if(!Vt(n,((p=t().currentSession)==null?void 0:p.id)??null)){o();break}const P=n.payload;if(!Sf.has(P.messageId)){Sf.add(P.messageId);const H=Wo(t(),n.sessionId);B2(H)}Jt.messageId=P.messageId,Jt.deltaContent+=P.content,Cf();break}case"chat.thinking":{if(!Vt(n,((m=t().currentSession)==null?void 0:m.id)??null)){o();break}const P=n.payload;Jt.messageId=P.messageId,Jt.thinkingContent+=P.content,Cf();break}case"chat.tool_preparing":{if(!Vt(n,((x=t().currentSession)==null?void 0:x.id)??null)){o();break}const P=n.payload,H=t().streamingMessage;if(!H||H.id!==P.messageId||((_=H.toolCalls)==null?void 0:_.find((K,I)=>I===P.index)))return;e(K=>{const I=K.streamingMessage.preparingToolCalls??[],D=I.findIndex(V=>V.index===P.index);let B;return D>=0?B=I.map((V,U)=>U===D?{...V,arguments:P.arguments}:V):B=[...I,{index:P.index,name:P.name,...P.arguments?{arguments:P.arguments}:{}}],{streamingMessage:{...K.streamingMessage,preparingToolCalls:B}}});break}case"chat.tool_call":{if(!Vt(n,((w=t().currentSession)==null?void 0:w.id)??null)){o();break}const P=n.payload,H=J=>{var D;const K=(D=J.preparingToolCalls)==null?void 0:D.filter((B,V)=>{var U;return B.name===P.tool?(U=J.preparingToolCalls)==null?void 0:U.slice(0,V).some(Z=>Z.name===P.tool):!0}),I=Jt.toolOutput.filter(B=>B.callId===P.callId);return I.length>0&&(Jt.toolOutput=Jt.toolOutput.filter(B=>B.callId!==P.callId)),{...J,toolCalls:[...J.toolCalls??[],{id:P.callId,name:P.tool,arguments:P.args,startedAt:Date.now(),...I.length>0?{streamingOutput:I.map(B=>({stream:B.stream,content:B.content,timestamp:Date.now()}))}:{}}],...K&&K.length>0?{preparingToolCalls:K}:{preparingToolCalls:void 0}}};e(J=>{const K=J.streamingMessage;return K&&K.id===P.messageId?{streamingMessage:H(K)}:{messages:J.messages.map(I=>I.id===P.messageId?H(I):I)}});break}case"chat.tool_output":{if(!Vt(n,((k=t().currentSession)==null?void 0:k.id)??null)){o();break}const P=n.payload;Jt.messageId=P.messageId,Jt.toolOutput.push({messageId:P.messageId,callId:P.callId,stream:P.stream,content:P.output}),Cf();break}case"chat.tool_result":{if(!Vt(n,((v=t().currentSession)==null?void 0:v.id)??null)){o();break}const P=n.payload,H=J=>{var I;const K=(I=J.toolCalls)==null?void 0:I.map(D=>D.id===P.callId?{...D,result:P.result}:D);return{...J,toolCalls:K}};e(J=>{const K=J.streamingMessage;return K&&K.id===P.messageId?{streamingMessage:H(K)}:{messages:J.messages.map(I=>I.id===P.messageId?H(I):I)}});break}case"chat.vision_fallback":{if(!Vt(n,((b=t().currentSession)==null?void 0:b.id)??null)){o();break}const P=n.payload;e(H=>{const J=`${P.messageId}-${P.attachmentId}`,K={...H.visionFallbackByMessage};return K[J]={type:P.type,attachmentId:P.attachmentId,filename:P.filename,description:P.description},{visionFallbackByMessage:K}});break}case"chat.todo":{if(!Vt(n,((y=t().currentSession)==null?void 0:y.id)??null)){o();break}const P=n.payload;e({currentTodos:P.todos});break}case"chat.summary":{if(!Vt(n,((S=t().currentSession)==null?void 0:S.id)??null)){o();break}const P=n.payload;e(H=>({currentSession:H.currentSession?{...H.currentSession,summary:P.summary}:null}));break}case"chat.progress":{if(!Vt(n,((E=t().currentSession)==null?void 0:E.id)??null)){o();break}const P=n.payload;console.warn("Progress:",P.message,P.phase);break}case"chat.format_retry":{if(!Vt(n,((N=t().currentSession)==null?void 0:N.id)??null)){o();break}const P=n.payload;console.warn("Format retry:",P.attempt,"/",P.maxAttempts);break}case"chat.done":{if(!Vt(n,((T=t().currentSession)==null?void 0:T.id)??null)){o();break}ui(),wn==null||wn();const P=n.payload,H=P.stats;Jt.messageId=null,Jt.deltaContent="",Jt.thinkingContent="",Jt.toolOutput=[],Sf.delete(P.messageId),e(J=>{const K=J.streamingMessage,I=K&&K.id===P.messageId?{...K,isStreaming:!1,stats:H??K.stats}:null;return{messages:J.messages.map(D=>D.id===P.messageId?I??{...D,isStreaming:!1,stats:H??D.stats,completeReason:P.reason}:D),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Vt(n,((L=t().currentSession)==null?void 0:L.id)??null)){o();break}ui(),wn==null||wn();const P=n.payload;console.error("Chat error:",P.error,"recoverable:",P.recoverable),P.recoverable||(Jt.messageId=null,Jt.deltaContent="",Jt.thinkingContent="",Jt.toolOutput=[]),e(H=>({error:{code:"CHAT_ERROR",message:P.error},streamingMessageId:P.recoverable?H.streamingMessageId:null,...P.recoverable?{}:{messages:H.streamingMessage?H.messages.map(J=>J.id===H.streamingMessage.id?H.streamingMessage:J):H.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Vt(n,((A=t().currentSession)==null?void 0:A.id)??null)){o();break}const P=n.payload,H={callId:P.callId,tool:P.tool,paths:P.paths,workdir:P.workdir,reason:P.reason};e(J=>({pendingPathConfirmations:[...J.pendingPathConfirmations,H]}));break}case"chat.ask_user":{if(!Vt(n,((z=t().currentSession)==null?void 0:z.id)??null)){o();return}const P=n.payload;e({pendingQuestion:{callId:P.callId,question:P.question}});break}case"mode.changed":{if(!Vt(n,((R=t().currentSession)==null?void 0:R.id)??null)){o();break}const P=n.payload;e(H=>({currentSession:H.currentSession?{...H.currentSession,mode:P.mode}:null}));break}case"phase.changed":{const P=n.payload,H=n.sessionId,J=($=t().currentSession)==null?void 0:$.id,K=H&&H!==J;e(I=>({sessions:I.sessions.map(D=>D.id===H?{...D,phase:P.phase}:D)})),K||e(I=>({currentSession:I.currentSession?{...I.currentSession,phase:P.phase}:null}));break}case"criteria.updated":{if(!Vt(n,((F=t().currentSession)==null?void 0:F.id)??null)){o();break}const P=n.payload;e(H=>({currentSession:H.currentSession?{...H.currentSession,criteria:P.criteria}:null}));break}case"context.state":{const P=n.payload,H=Vt(n,((W=t().currentSession)==null?void 0:W.id)??null);P.subAgentId?H&&t().updateSubAgentContextState(P.subAgentId,P.context):H?e({contextState:P.context}):o();break}case"session.name_generated":{const P=n.payload,H=n.sessionId,J=(Y=t().currentSession)==null?void 0:Y.id;e(K=>{const I=K.sessions.map(B=>B.id===H?{...B,title:P.name,updatedAt:new Date().toISOString()}:B),D=J===H?K.currentSession?{...K.currentSession,title:P.name,updatedAt:new Date().toISOString()}:null:K.currentSession;return{sessions:I,currentSession:D}});break}case"queue.state":{const P=n.payload;e({queuedMessages:P.messages??[]});break}case"git.status":{const P=n.payload;e({gitStatus:{branch:P.branch,diff:P.diff}});break}case"devServer.output":case"devServer.state":{Rr.getState().handleMessage(n);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Yo.getState().handleMessage(n.type,n.payload);break}case"error":{const P=n.payload;console.error("Server error:",P),e({error:{code:P.code,message:P.message},streamingMessageId:null});break}}}}));function Ym(){return Ce(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function F2(){return Ce(e=>e.queuedMessages)}function V2(){return Ce(e=>e.abortInProgress)}function G2(){const e=Ce(s=>s.connect),t=Ce(s=>s.connectionStatus),n=gi(s=>s.load);return O.useEffect(()=>{e()},[e]),O.useEffect(()=>{t==="connected"&&n()},[t,n]),{connectionStatus:t}}const W2="modulepreload",q2=function(e){return"/"+e},Sv={},Q=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=c(n.map(f=>{if(f=q2(f),f in Sv)return;Sv[f]=!0;const p=f.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":W2,p||(x.as="script"),x.crossOrigin="",x.href=f,h&&x.setAttribute("nonce",h),document.head.appendChild(x),p)return new Promise((_,w)=>{x.addEventListener("load",_),x.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return a.then(c=>{for(const l of c||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},eS=[{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"}],Or=[{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 wv(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Ht=Jn((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:wv(),followSystemTheme:!0,applySavedTheme:()=>{const{getSavedTheme:n,applyPreset:s,applyTokens:a}=t(),o=n();if(o)try{const c=JSON.parse(o);c.preset&&c.tokens?(s(c.preset),e({basePreset:c.preset}),a(c.tokens)):c.preset?s(c.preset):c.tokens&&a(c.tokens)}catch{s("dark")}else s("dark")},applyPreset:n=>{Or.find(a=>a.id===n)&&(e({currentPreset:n,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1}),t().applyTheme())},startCustomizing:()=>{var a;const{currentPreset:n}=t(),s=((a=Or.find(o=>o.id===n))==null?void 0:a.tokens)??{};e({basePreset:n,customTokens:{...s},isCustom:!0,isCustomizing:!0})},setCustomToken:(n,s)=>{e(a=>({customTokens:{...a.customTokens,[n]:s}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:n}=t();t().saveTheme(JSON.stringify({tokens:n})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:n=>{e({customTokens:n,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var c,l;const{basePreset:n,customTokens:s,isCustom:a}=t();if(a&&n)return{...((c=Or.find(f=>f.id===n))==null?void 0:c.tokens)??{},...s};if(a)return{...eS.reduce((h,f)=>({...h,[f.key]:f.defaultValue}),{}),...s};const o=Or.find(h=>h.id===t().currentPreset);return(o==null?void 0:o.tokens)??((l=Or[0])==null?void 0:l.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const n=t().getActiveTheme(),s=document.documentElement;Object.entries(n).forEach(([a,o])=>{s.style.setProperty(`--${a}`,o)})},getSavedTheme:()=>{try{const n=localStorage.getItem("openfox:theme");if(!n)return null;if(n[0]!=="{")return JSON.stringify({preset:n});const s=JSON.parse(n);if(s.preset)return JSON.stringify({preset:s.preset});if(s.tokens)return JSON.stringify({tokens:s.tokens})}catch{return null}return null},saveTheme:async n=>{localStorage.setItem("openfox:theme",n);const{useSettingsStore:s}=await Q(async()=>{const{useSettingsStore:a}=await Promise.resolve().then(()=>_f);return{useSettingsStore:a}},void 0);await s.getState().setSetting($e.DISPLAY_THEME,n)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:n=>{e({followSystemTheme:n}),Q(async()=>{const{useSettingsStore:s,SETTINGS_KEYS:a}=await Promise.resolve().then(()=>_f);return{useSettingsStore:s,SETTINGS_KEYS:a}},void 0).then(({useSettingsStore:s,SETTINGS_KEYS:a})=>{s.getState().setSetting(a.DISPLAY_FOLLOW_SYSTEM_THEME,String(n))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const n=window.matchMedia("(prefers-color-scheme: dark)"),s=o=>{const{followSystemTheme:c}=t();c&&(t().applyPreset(o?"dark":"light"),t().saveTheme(JSON.stringify({preset:o?"dark":"light"})))};s(n.matches);const a=o=>s(o.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0})},addUserPreset:n=>{const{basePreset:s,customTokens:a,currentPreset:o}=t(),c={id:"custom-"+Date.now(),name:n,basePreset:s||o,tokens:{...a}},l=[...t().userPresets,c];e({userPresets:l}),t().saveUserPresets()},applyUserPreset:n=>{const s=t().userPresets[n];s&&(e({currentPreset:s.basePreset,basePreset:s.basePreset,customTokens:{...s.tokens},isCustom:!0,isCustomizing:!1}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:s.basePreset,tokens:s.tokens})).catch(()=>{}))},deleteUserPreset:n=>{const s=t().userPresets.filter((a,o)=>o!==n);e({userPresets:s}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:wv()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),Q(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>_f);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting($e.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function K2({canLoad:e,projectId:t,currentProjectId:n}){const s=Pt(c=>c.loadProject),a=Ce(c=>c.listSessions),o=Ce(c=>c.clearSession);O.useEffect(()=>{e&&t&&(n!==t&&s(t),a(t),o())},[e,t,n,s,a,o])}function Y2({canLoad:e,projectId:t,sessionId:n,currentProjectId:s,currentSessionId:a}){const o=Ce(f=>f.loadSession),c=Pt(f=>f.loadProject),l=Ce(f=>f.listSessions),h=Ce(f=>f.pendingSessionCreate);O.useEffect(()=>{e&&t&&s!==t&&c(t)},[e,t,s,c]),O.useEffect(()=>{e&&n&&a!==n&&o(n),e&&t&&l(t)},[e,n,a,o,l,h,t])}function X2({className:e="w-5 h-5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function tS({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function Q2({className:e="w-5 h-5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 J2({className:e="w-3 h-3 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Z2({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.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 Mr({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function Ir({className:e="w-3 h-3 text-text-muted",rotate:t}){return u.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function ej({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[u.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),u.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Xm({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 tj({className:e="w-3 h-3"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Qm({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[u.jsx("circle",{cx:"12",cy:"5",r:"2"}),u.jsx("circle",{cx:"12",cy:"12",r:"2"}),u.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function Eu({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Jm({className:e="w-5 h-5 text-accent-primary"}){return u.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:u.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 nj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 rj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 sj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.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 ij({className:e="w-3 h-3"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 aj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 Cv({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function nS({className:e="w-[18px] h-[18px]"}){return u.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[u.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function oj({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.jsx("path",{d:"M9.5 2h4.5v4.5"}),u.jsx("path",{d:"M14 2L7.5 8.5"})]})}function lj({className:e="w-3 h-3",color:t}){return u.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{d:"M8 5v14l11-7z"})})}function La({className:e="w-3 h-3 text-accent-primary"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function cj({className:e="w-5 h-5"}){return u.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:u.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 Zm({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 uj({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[u.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"}),u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function dj({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return u.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[u.jsx("title",{children:"Running"}),u.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),u.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function hj({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function fj({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function rS({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function mj({className:e="w-3.5 h-3.5 shrink-0",color:t}){return u.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:u.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 pj({className:e="w-4 h-4"}){return u.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"4 17 10 11 4 5"}),u.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function ju({className:e="w-3.5 h-3.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 ep(){return u.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 gj({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 dm({className:e="w-2.5 h-2.5"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.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 tp({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:u.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 sS({className:e="w-4 h-4"}){return u.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:u.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 xj({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function _j({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function kv({className:e="w-3.5 h-3.5 text-text-muted"}){return u.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function hm(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Ev(e,t){const n=Zt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:hm(),type:e,payload:t}))}const _r=Jn((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const s=await je(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(s.ok){const a=await s.json();e({sessions:a});const o=Zt.ws;if(o&&o.readyState===WebSocket.OPEN)for(const c of a)o.send(JSON.stringify({id:hm(),type:"terminal.subscribe",payload:{sessionId:c.id}}))}}catch(s){console.error("Failed to fetch terminals:",s)}},createSession:async(n,s)=>{try{const a=await je("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:s})});if(a.ok){const o=await a.json();e(l=>({sessions:[...l.sessions,o]}));const c=Zt.ws;c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify({id:hm(),type:"terminal.subscribe",payload:{sessionId:o.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,s)=>{Ev("terminal.write",{sessionId:n,data:s})},resizeSession:(n,s,a)=>{Ev("terminal.resize",{sessionId:n,cols:s,rows:a})},killSession:async n=>{try{(await je(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(o=>o.id!==n)}))}catch(s){console.error("Failed to kill terminal:",s)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:s}=n.payload||{};s&&e(a=>{const o=a.sessions.filter(c=>c.id!==s);return o.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:o}});break}}}}));Zt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&_r.getState().handleMessage(e)});const wa={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function fm(e){if(!e)return structuredClone(wa);try{const t=JSON.parse(e);return{terminalToggle:t.terminalToggle??structuredClone(wa.terminalToggle),quickAction:t.quickAction??structuredClone(wa.quickAction),agentSwitching:t.agentSwitching??structuredClone(wa.agentSwitching)}}catch{return structuredClone(wa)}}function jv(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function iS(e){if(e.type==="double-press")return`Double ${e.key==="Control"?"Ctrl":e.key==="Shift"?"Shift":e.key==="Alt"?"Alt":e.key==="Meta"?"Meta":e.key}`;const t=e.modifiers.map(s=>{switch(s){case"ctrl":return"Ctrl";case"meta":return"⌘";case"alt":return"Alt";case"shift":return"Shift"}}),n=e.key.length===1?e.key.toUpperCase():e.key;return[...t,n].join("+")}function yj(e){return e.type==="double-press"}function aS(e){return e.type==="chord"}function vj(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.code===`Key${t.toUpperCase()}`:t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function oS(e,t){const n=t.modifiers.includes("ctrl"),s=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),o=t.modifiers.includes("shift");return vj(e,t.key)&&e.ctrlKey===n&&e.metaKey===s&&e.altKey===a&&e.shiftKey===o}function np(){const e=Wt(t=>t.settings[$e.KEYBINDINGS]);return fm(e)}function bj(e,t,n){const s=O.useRef(0),a=O.useRef(t);a.current=t,O.useEffect(()=>{if(!e)return;const o=e.threshold??300,c=l=>{if(l.key!==e.key)return;const h=e.key==="Control",f=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!h&&l.ctrlKey||!f&&l.shiftKey||!p&&l.altKey||!m&&l.metaKey)return;const x=Date.now();x-s.current<o?(l.preventDefault(),l.stopPropagation(),a.current(),s.current=0):s.current=x};return window.addEventListener("keydown",c,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",c,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function Sj(e,t){const n=O.useRef(t);n.current=t,O.useEffect(()=>{if(!e)return;const s=a=>{oS(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function lS(e,t,n){bj(e&&yj(e)?e:void 0,t,n),Sj(e&&aS(e)?e:void 0,t)}function wj(e,t,n){const s=O.useRef(n);s.current=n,O.useEffect(()=>{const a=o=>{for(let c=0;c<e.length;c++){const l=e[c];if(!l)continue;const h=t[c];if(h&&aS(l)&&oS(o,l)){o.preventDefault(),s.current(h.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var Pa=B0();const Tu=O.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...s},a)=>u.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...s,children:u.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));Tu.displayName="IconButton";const Cj="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",Da=O.forwardRef((e,t)=>u.jsx(Tu,{ref:t,icon:Cj,title:"Edit",...e}));Da.displayName="EditButton";const kj="M6 18L18 6M6 6l12 12",rp=O.forwardRef((e,t)=>u.jsx(Tu,{ref:t,icon:kj,...e}));rp.displayName="CloseButton";const Ej={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 Nt({label:e,title:t,size:n="md",minHeight:s,children:a,footer:o,className:c,onClose:l,isOpen:h,closeOnBackdropClick:f=!0,closeOnEscape:p=!0,showCloseButton:m=!0}){const[x,_]=O.useState(!1),w=h!==void 0,k=w?h:x,v=O.useCallback(()=>{w||_(!0)},[w]),b=O.useCallback(()=>{w||_(!1),l==null||l()},[w,l]);O.useEffect(()=>{if(!k||!p)return;const S=E=>{E.key==="Escape"&&(E.stopPropagation(),b())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[k,b,p]);const y=e&&(typeof e=="string"?u.jsx("button",{type:"button",onClick:v,className:c,children:e}):u.jsx("span",{onClick:v,className:c,style:{cursor:"pointer"},children:e}));return u.jsxs(u.Fragment,{children:[y,k&&(typeof document<"u"?Pa.createPortal(u.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:f?b:void 0}),u.jsxs("div",{className:`relative w-full ${Ej[n]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||m)&&u.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&u.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),m&&u.jsx(rp,{onClick:b,className:"ml-auto","aria-label":"Close"})]}),u.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:s?{minHeight:s}:void 0,children:a}),o&&u.jsx("div",{className:"px-4 py-3 border-t border-border",children:o})]})]}),document.body):null)]})}const rt=O.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:s,...a},o)=>{const c="rounded font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",l={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"},h={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return u.jsx("button",{ref:o,className:`${c} ${l[e]} ${h[t]} ${n}`,...a,children:s})});rt.displayName="Button";function jj({value:e,defaultUrl:t,disabled:n,onChange:s}){const a=e??t;return u.jsxs("div",{className:"relative",children:[u.jsx("select",{value:a,disabled:n,onChange:o=>{const c=o.target.value;s(c===t?null:c)},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:N2.map(({url:o,label:c})=>u.jsx("option",{value:o,title:c,children:c.split(" ")[0]},o))}),u.jsx(Ir,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const Tv=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function Tj(){const e=gi(h=>h.settings),t=gi(h=>h.update),n=gi(h=>h.updateEvent),s=gi(h=>h.updateAgentOverride),a=gi(h=>h.load);O.useEffect(()=>{a()},[a]);const o=async()=>{await L2()==="granted"&&t({...e,browserNotificationEnabled:!0})},c=(h,f,p,m)=>{h==="general"?n(f,{[p]:m}):s(h,f,{[p]:m})},l=(h,f,p)=>{h==="general"?n(f,{customSoundUrl:p}):s(h,f,{customSoundUrl:p})};return u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),u.jsx(Nv,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:h=>t({...e,soundEnabled:h})}),u.jsx(Nv,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:h=>{h&&typeof Notification<"u"&&Notification.permission!=="granted"?o():t({...e,browserNotificationEnabled:h})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&u.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),u.jsx("div",{className:"border border-border rounded overflow-hidden",children:u.jsxs("table",{className:"w-full text-sm",children:[u.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:u.jsxs("tr",{className:"border-b border-border",children:[u.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),Tv.map(h=>u.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:h.label},h.key))]})}),u.jsx("tbody",{children:T2.map(h=>u.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[u.jsx("td",{className:"px-3 py-2",children:u.jsx("div",{className:"text-text-primary text-xs",children:h.label})}),Tv.map(f=>{const p=J0(e,h.key,f.key==="general"?void 0:f.key),m=X0[h.key];return u.jsx("td",{className:"px-2 py-2 align-top",children:u.jsxs("div",{className:"flex flex-col items-center gap-1",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:u.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:x=>c(f.key,h.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),u.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:u.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>c(f.key,h.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&u.jsx(jj,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:x=>l(f.key,h.key,x)})]})},f.key)})]},h.key))})]})})]})]})}function Nv({label:e,description:t,checked:n,onChange:s}){return u.jsxs("label",{className:"flex items-start gap-3 cursor-pointer group",children:[u.jsx("div",{className:"pt-0.5",children:u.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),s(!n)},children:u.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})}),u.jsxs("div",{children:[u.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),u.jsx("div",{className:"text-xs text-text-muted",children:t})]})]})}async function sp(e,t,n){t({loading:!0});try{const a=await(await je(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const Nr=Jn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchSkills:async()=>{await sp("/api/skills",e,!0)},toggleSkill:async n=>{try{const a=await(await je(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(o=>({defaults:o.defaults.map(c=>c.id===n?{...c,enabled:a.enabled}:c),userItems:o.userItems.map(c=>c.id===n?{...c,enabled:a.enabled}:c)}))}catch{}},fetchSkill:async n=>{try{const s=await je(`/api/skills/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await je(`/api/skills/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createSkill:async(n,s)=>{const a=await Vs("POST","/api/skills",{...n,destination:s});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,s)=>{const a=await Vs("PUT",`/api/skills/${n}`,s);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const s=await je(`/api/skills/${n}`,{method:"DELETE"}),a=await s.json();return s.ok?(e(o=>({userItems:o.userItems.filter(c=>c.id!==n)})),{success:!0}):{success:!1,error:a.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateSkill:async(n,s)=>ku(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),s)}));function ip(){const[e,t]=O.useState({id:null,type:null}),n=O.useCallback(o=>t({id:o,type:"delete"}),[]),s=O.useCallback(()=>t({id:null,type:null}),[]),a=O.useCallback((o,c)=>e.id===o&&e.type===c,[e.id,e.type]);return{requestDelete:n,clearConfirm:s,isConfirming:a}}function ap({onConfirm:e,onCancel:t}){return u.jsxs("div",{className:"flex items-center gap-1",children:[u.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"}),u.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function op({onClick:e}){return u.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:u.jsx(ju,{})})}function tl({onClick:e}){return u.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:u.jsx(Xm,{})})}function Si({label:e,value:t,onChange:n,placeholder:s,readOnly:a,hint:o,mono:c}){return u.jsxs("div",{children:[u.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,o&&u.jsx("span",{className:"text-text-muted ml-1",children:o})]}),u.jsx("input",{value:t,onChange:l=>n(l.target.value),readOnly:a,placeholder:s,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 ${c?"font-mono":""} ${a?"opacity-60":""}`})]})}function Nj({onCancel:e,onSave:t,saving:n,saveDisabled:s}){return u.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[u.jsx(rt,{variant:"secondary",onClick:e,children:"Cancel"}),u.jsx(rt,{variant:"primary",onClick:t,disabled:n||s,children:n?"Saving...":"Save"})]})}function lp({message:e}){return u.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function cS({label:e="Custom",children:t}){return u.jsxs("div",{children:[u.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),u.jsx("div",{className:"space-y-2",children:t})]})}function uS({description:e,onNew:t,newLabel:n="+ New"}){return u.jsxs("div",{className:"flex items-center justify-between mb-4",children:[u.jsx("p",{className:"text-text-secondary text-sm",children:e}),u.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:u.jsx(rt,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function dS({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:s,onDuplicate:a,onDelete:o,children:c}){return u.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[u.jsx("div",{className:"min-w-0 flex-1 mr-3",children:c}),u.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&n&&u.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:u.jsx(Eu,{})}),u.jsx(tl,{onClick:a}),!e&&s&&u.jsx(Da,{onClick:s}),!e&&(t?u.jsx(ap,{onConfirm:()=>{o==null||o()},onCancel:()=>{}}):u.jsx(op,{onClick:()=>o==null?void 0:o()}))]})]})}function Aj({id:e,name:t,description:n,isBuiltIn:s,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:l,onDelete:h}){return u.jsxs(dS,{isBuiltIn:s,isConfirmingDelete:a,onView:o,onEdit:c,onDuplicate:l,onDelete:h,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),u.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&u.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function hS({loading:e,hasItems:t,loadingLabel:n,emptyLabel:s,children:a}){return e&&!t?u.jsx("div",{className:"text-text-muted text-sm",children:n}):t?u.jsx("div",{className:"space-y-4",children:a}):s?u.jsx("div",{className:"text-text-muted text-sm",children:s}):null}function fS({name:e,id:t,nameLabel:n="Name",idLabel:s="ID",namePlaceholder:a="My Item",idPlaceholder:o="my-item",nameHint:c,readOnlyId:l=!1,readOnlyHint:h="(read-only)",onNameChange:f,onIdChange:p}){return u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsx(Si,{label:n,value:e,onChange:f,placeholder:a,hint:c}),u.jsx(Si,{label:s,value:t,onChange:p,readOnly:l,placeholder:o,hint:l?h:void 0,mono:!0})]})}function mS(e={}){const{initialData:t={}}=e,[n,s]=O.useState("list"),[a,o]=O.useState(null),[c,l]=O.useState(""),[h,f]=O.useState(!1),[p,m]=O.useState(t),x=O.useCallback(()=>{m(t),l(""),o(null)},[t]),_=O.useCallback(b=>{s(b),b==="list"&&x()},[x]),w=O.useCallback(b=>{m(y=>typeof b=="function"?b(y):b)},[]),k=O.useCallback((b,y={})=>{o(b),s("edit"),m({...y}),l("")},[]),v=O.useCallback(()=>{o(null),s("edit"),m(t),l("")},[t]);return{view:n,editingId:a,formError:c,saving:h,formData:p,setView:_,setEditingId:o,setFormError:l,setFormData:w,setSaving:f,resetForm:x,startEditing:k,startNew:v}}function cp(){return u.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[u.jsx("span",{children:"⚠️"}),u.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 Av({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:o,onDelete:c}){return u.jsx(Aj,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:o,onDelete:c})}function Lj({isOpen:e}){const t=Nr(H=>H.defaults),n=Nr(H=>H.userItems),s=Nr(H=>H.projectItems),a=Nr(H=>H.loading),o=Nr(H=>H.fetchSkills),c=Nr(H=>H.fetchSkill),l=Nr(H=>H.fetchDefaultContent),h=Nr(H=>H.createSkill),f=Nr(H=>H.updateSkill),p=Nr(H=>H.deleteSkill),{view:m,editingId:x,formError:_,saving:w,formData:k,setView:v,setEditingId:b,setFormError:y,setFormData:S,setSaving:E}=mS(),{clearConfirm:N}=ip();O.useEffect(()=>{e&&(o(),v("list"),b(null),N())},[e,o,N]);const T=(H,J,K,I)=>{S({name:I??H.metadata.name,id:K??H.metadata.id,description:H.metadata.description??"",version:H.metadata.version??"1.0.0",prompt:H.prompt,isReadOnly:J,destination:"user"})},L=async H=>{if(t.some(K=>K.id===H)){const K=await l(H);if(!K)return;T(K,!0),b(H),y(""),v("edit")}else{const K=await c(H);if(!K)return;T(K,!0),b(H),y(""),v("edit")}},A=async H=>{const K=t.some(D=>D.id===H)?await l(H):await c(H);if(!K)return;const I=`${H}-copy-${Date.now()}`;T(K,!1,I,`${K.metadata.name} (copy)`),b(null),y(""),v("edit")},z=()=>{S({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),v("edit")},R=async H=>{const J=await c(H);J&&(T(J,!1),b(H),y(""),v("edit"))},$=async H=>{await p(H),N()},F=async()=>{const H=x??k.id;if(!H||!k.name||!k.prompt){y("Name, ID, and prompt are required.");return}E(!0),y("");const J={metadata:{id:H,name:k.name,description:k.description,version:k.version},prompt:k.prompt},K=x?await f(x,J):await h(J,k.destination);if(E(!1),!K.success){y(K.error??"Failed to save skill.");return}v("list")},W=H=>{S(J=>({...J,name:H})),x||S(J=>({...J,id:H.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},Y=k.isReadOnly;if(m==="edit")return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex justify-between items-center mb-3",children:[u.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:Y?k.name:x?"Edit Skill":"New Skill"}),u.jsx("button",{onClick:()=>v("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),_&&u.jsx(lp,{message:_}),u.jsxs("div",{className:"space-y-3 mb-3",children:[u.jsx(fS,{name:k.name,id:k.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:W,onIdChange:()=>{}}),u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsx(Si,{label:"Description",value:k.description,onChange:H=>S(J=>({...J,description:H})),placeholder:"What this skill does...",readOnly:Y}),u.jsx(Si,{label:"Version",value:k.version,onChange:H=>S(J=>({...J,version:H})),placeholder:"1.0.0",readOnly:Y})]})]}),u.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[u.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),u.jsx("textarea",{value:k.prompt,onChange:H=>S(J=>({...J,prompt:H.target.value})),readOnly:Y,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"})]}),!x&&u.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[u.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),u.jsxs("select",{value:k.destination,onChange:H=>S(J=>({...J,destination:H.target.value})),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[u.jsx("option",{value:"user",children:"Global config"}),u.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]}),u.jsx(cp,{}),u.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[u.jsx(rt,{variant:"secondary",onClick:()=>v("list"),children:"Cancel"}),Y?u.jsx(rt,{variant:"primary",onClick:()=>{S(H=>({...H,name:H.name+" (copy)",id:`${x}-copy-${Date.now()}`,isReadOnly:!1})),b(null)},children:"Duplicate & Customize"}):u.jsx(rt,{variant:"primary",onClick:F,disabled:w||!k.name||!k.id||!k.prompt,children:w?"Saving...":"Save"})]})]});function P({items:H}){return H.map(J=>u.jsx(Av,{skill:J,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>L(J.id),onEdit:()=>R(J.id),onDuplicate:()=>A(J.id),onDelete:()=>$(J.id)},J.id))}return u.jsxs("div",{children:[u.jsx(uS,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:z}),u.jsxs(hS,{loading:a,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&u.jsxs("div",{children:[u.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),u.jsx("div",{className:"space-y-2",children:t.map(H=>u.jsx(Av,{skill:H,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>L(H.id),onDuplicate:()=>A(H.id)},H.id))})]}),n.length>0&&u.jsx(cS,{children:u.jsx(P,{items:n})}),s.length>0&&u.jsxs("div",{className:"mt-4",children:[u.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),u.jsx("div",{className:"space-y-2",children:u.jsx(P,{items:s})})]})]})]})}function Dj(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),s=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${s} ${a}`}return e}function pi(e){const t=e.split(" ").map(n=>parseInt(n,10));return t.length===3&&t.every(n=>!isNaN(n))?`#${t.map(n=>(n??0).toString(16).padStart(2,"0")).join("")}`:e}function Rj({isOpen:e,isNew:t,basePresetId:n,presetName:s,initialTokens:a,onClose:o,onSave:c}){const[l,h]=O.useState(a),[f,p]=O.useState(s);O.useEffect(()=>{h(a),p(s)},[a,s]);const m=(v,b)=>{const y=b.startsWith("#")?Dj(b):b;h(S=>({...S,[v]:y}))},x=()=>{c(f.trim()||"Untitled",{...l})},_=eS.reduce((v,b)=>{const y=b.category;return v[y]||(v[y]=[]),v[y].push(b),v},{}),w={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},k=Or.find(v=>v.id===n);return u.jsx(Nt,{isOpen:e,onClose:o,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:u.jsxs("div",{className:"flex gap-2 justify-end",children:[u.jsx("button",{type:"button",onClick:o,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),u.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),u.jsx("input",{type:"text",value:f,onChange:v=>p(v.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"})]}),!t&&u.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",u.jsx("span",{className:"text-text-primary",children:k==null?void 0:k.name})]}),Object.entries(_).map(([v,b])=>u.jsxs("div",{className:"space-y-3",children:[u.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:w[v]??v}),u.jsx("div",{className:"grid grid-cols-2 gap-3",children:b.map(y=>u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("label",{htmlFor:y.key,className:"text-xs text-text-muted",children:y.label}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"color",id:y.key,value:pi(l[y.key]??y.defaultValue),onChange:S=>m(y.key,S.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent"}),u.jsx("input",{type:"text",value:l[y.key]??y.defaultValue,onChange:S=>m(y.key,S.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"})]})]},y.key))})]},v))]})})}function Oj(){const[e,t]=O.useState(null),n=Ht(E=>E.currentPreset),s=Ht(E=>E.isCustom),a=Ht(E=>E.basePreset),o=Ht(E=>E.userPresets),c=Ht(E=>E.applyPreset),l=Ht(E=>E.applyUserPreset),h=Ht(E=>E.deleteUserPreset),f=Ht(E=>E.saveTheme),p=Ht(E=>E.followSystemTheme),m=Ht(E=>E.setFollowSystemTheme),x=E=>{c(E),f(JSON.stringify({preset:E})).catch(()=>{})},_=E=>{l(E)},w=E=>{const N=Or.find(T=>T.id===E);N&&t({type:"new",presetIndex:o.length,basePresetId:E,presetName:N.name+" Copy",tokens:{...N.tokens}})},k=E=>{const N=o[E];if(!N)return;const T=Or.find(A=>A.id===N.basePreset),L=T?{...T.tokens,...N.tokens}:N.tokens;t({type:"edit",presetIndex:E,basePresetId:N.basePreset,presetName:N.name,tokens:L})},v=(E,N)=>{if(!e)return;const T=[...o];if(e.type==="new"){const L={id:"custom-"+Date.now(),name:E,basePreset:e.basePresetId,tokens:N};T.push(L);const A=T.length-1;Ht.setState({userPresets:T}),Ht.getState().saveUserPresets(),Ht.getState().applyUserPreset(A)}else{const L=T[e.presetIndex];L&&(T[e.presetIndex]={...L,name:E,tokens:N}),Ht.setState({userPresets:T}),Ht.getState().saveUserPresets(),Ht.getState().applyUserPreset(e.presetIndex)}t(null)},b=()=>{t(null)},y=(E,N)=>{E.stopPropagation(),h(N)},S=s?a:n;return u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),u.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[u.jsx("button",{type:"button",role:"switch","aria-checked":p,onClick:()=>m(!p),className:`relative w-10 h-5 rounded-full transition-colors ${p?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,children:u.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${p?"translate-x-5":"translate-x-0"}`})}),u.jsx("span",{className:"text-sm text-text-secondary",children:"Follow system theme"})]}),u.jsx("div",{className:"grid grid-cols-5 gap-2",children:Or.map(E=>u.jsxs("div",{className:"relative group",children:[u.jsxs("button",{type:"button",onClick:()=>x(E.id),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${S===E.id&&!s?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[u.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:pi(E.tokens["color-bg-primary"]??"#000"),borderColor:pi(E.tokens["color-border"]??"#000")},children:u.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:pi(E.tokens["color-text-primary"]??"#fff")}})}),u.jsx("span",{className:"text-xs",children:E.name})]}),u.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),w(E.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:u.jsx("span",{className:"text-xs",children:"✎"})})]},E.id))}),o.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),u.jsx("div",{className:"grid grid-cols-5 gap-2",children:o.map((E,N)=>{const T=Or.find(A=>A.id===E.basePreset),L=T?{...T.tokens,...E.tokens}:E.tokens;return u.jsxs("div",{className:"relative group",children:[u.jsxs("button",{type:"button",onClick:()=>_(N),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${s&&a===E.basePreset&&S===E.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[u.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:pi(L["color-bg-primary"]??"#000"),borderColor:pi(L["color-border"]??"#000")},children:u.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:pi(L["color-text-primary"]??"#fff")}})}),u.jsx("span",{className:"text-xs truncate w-full text-center",children:E.name})]}),u.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),k(N)},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:u.jsx("span",{className:"text-xs",children:"✎"})}),u.jsx("button",{type:"button",onClick:A=>y(A,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:u.jsx(tp,{className:"w-3 h-3"})})]},E.id)})})]}),e&&u.jsx(Rj,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:b,onSave:v})]})}function Nu(){const e=Wt(a=>a.settings),t=Wt(a=>a.loading),n=Wt(a=>a.getSetting),s=Wt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:s}}function Mj({isOpen:e,onClose:t}){const[n,s]=O.useState("instructions");return u.jsx(Nt,{isOpen:e,onClose:t,title:"Settings",size:"xl",minHeight:"500px",children:u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-border mb-4 -mt-1",children:[u.jsx(pa,{label:"Instructions",active:n==="instructions",onClick:()=>s("instructions")}),u.jsx(pa,{label:"Skills",active:n==="skills",onClick:()=>s("skills")}),u.jsx(pa,{label:"Notifications",active:n==="notifications",onClick:()=>s("notifications")}),u.jsx(pa,{label:"Display",active:n==="display",onClick:()=>s("display")}),u.jsx(pa,{label:"Shortcuts",active:n==="keybindings",onClick:()=>s("keybindings")}),u.jsx(pa,{label:"Advanced",active:n==="advanced",onClick:()=>s("advanced")})]}),n==="instructions"&&u.jsx($j,{isOpen:e}),n==="skills"&&u.jsx(Lj,{isOpen:e}),n==="notifications"&&u.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:u.jsx(Tj,{})}),n==="display"&&u.jsx(Bj,{}),n==="keybindings"&&u.jsx(zj,{}),n==="advanced"&&u.jsx(Ij,{onClose:t})]})})}function Lv({enabled:e,onClick:t}){return u.jsx("button",{type:"button",onClick:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function Ij({onClose:e}){const[,t]=wr(),{settings:n,loading:s,getSetting:a,setSetting:o}=Nu(),c=n[$e.LLM_DISABLE_XML_PROTECTION]==="true",l=n[$e.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",h=s[$e.LLM_DISABLE_XML_PROTECTION]??!1;O.useEffect(()=>{a($e.LLM_DISABLE_XML_PROTECTION),a($e.DISPLAY_SHOW_OPEN_IN_EDITOR)},[a]);const f=async()=>{const x=String(!c);await o($e.LLM_DISABLE_XML_PROTECTION,x)},p=async()=>{const x=String(!l);await o($e.DISPLAY_SHOW_OPEN_IN_EDITOR,x)};function m(){e(),t("/onboarding")}return h?u.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):u.jsxs("div",{className:"space-y-6",children:[u.jsx("div",{children:u.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Disable XML Tool Call Protection"}),u.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Allow the model to output XML tool call format instead of JSON function calls. Some third-party providers may require this."})]}),u.jsx(Lv,{enabled:c,onClick:f})]})}),u.jsx("hr",{className:"border-border"}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Integrations"}),u.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm text-text-primary",children:'Show "Open in VSCode" links'}),u.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Display a link on file reads to open the file directly in VS Code."})]}),u.jsx(Lv,{enabled:l,onClick:p})]})]}),u.jsx("hr",{className:"border-border"}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),u.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Reset your OpenFox setup and go through the initial configuration again."}),u.jsx(rt,{variant:"secondary",onClick:m,children:"Launch Onboarding"})]})]})}function Pj(){return u.jsx(Oj,{})}function Bj(){const{settings:e,loading:t,getSetting:n,setSetting:s}=Nu(),a=t[$e.DISPLAY_SHOW_THINKING]??!1,o=[{key:$e.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:$e.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:$e.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:$e.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:$e.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:$e.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but very slow - does not affect red/green diff coloring"}],c=Object.fromEntries(o.map(p=>[p.key,e[p.key]??"true"])),[l,h]=O.useState(()=>Object.fromEntries(o.map(p=>[p.key,c[p.key]==="true"])));O.useEffect(()=>{o.forEach(p=>n(p.key))},[n]),O.useEffect(()=>{h(Object.fromEntries(o.map(p=>[p.key,c[p.key]==="true"])))},[JSON.stringify(c)]);const f=async p=>{const m=String(!l[p]);h(x=>({...x,[p]:!x[p]})),await s(p,m)};return a?u.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):u.jsxs("div",{className:"space-y-6",children:[u.jsx(Pj,{}),u.jsxs("div",{children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),u.jsx("div",{className:"space-y-4",children:o.map(({key:p,label:m,description:x})=>u.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-sm text-text-primary",children:m}),u.jsx("div",{className:"text-xs text-text-muted",children:x})]}),u.jsx("button",{type:"button",onClick:()=>f(p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${l[p]?"bg-accent-primary":"bg-bg-tertiary"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l[p]?"translate-x-6":"translate-x-1"}`})})]},p))})]})]})}function zj(){const{settings:e,loading:t,getSetting:n,setSetting:s}=Nu(),a=e[$e.KEYBINDINGS],o=t[$e.KEYBINDINGS]??!1,c=fm(a),[l,h]=O.useState(null);O.useEffect(()=>{n($e.KEYBINDINGS)},[n]);const f=[{id:"terminalToggle",label:"Toggle Terminal",binding:c.terminalToggle},{id:"quickAction",label:"Quick Action",binding:c.quickAction},...c.agentSwitching.map((_,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:_}))],p=_=>{h(_)},m=O.useCallback(_=>{if(!l)return;const w=fm(a),k=structuredClone(w);if(l.startsWith("agentSwitching.")){const v=parseInt(l.split(".")[1],10);k.agentSwitching[v]=_}else l==="terminalToggle"?k.terminalToggle=_:l==="quickAction"&&(k.quickAction=_);h(null),s($e.KEYBINDINGS,JSON.stringify(k))},[l,a,s]),x=()=>{s($e.KEYBINDINGS,JSON.stringify(wa))};return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),u.jsx("button",{type:"button",onClick:x,disabled:o,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),o?u.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):u.jsx("div",{className:"space-y-1",children:f.map(_=>u.jsx(Hj,{label:_.label,binding:_.binding,isRecording:l===_.id,onStartRecording:()=>p(_.id),onBindingRecorded:m,onCancelRecording:()=>h(null)},_.id))})]})}function Hj({label:e,binding:t,isRecording:n,onStartRecording:s,onBindingRecorded:a,onCancelRecording:o}){const c=O.useRef(null),l=O.useRef(0),h=O.useRef("");return O.useEffect(()=>{if(!n)return;const f=new Set(["Control","Shift","Alt","Meta"]);let p=[];const m=_=>{if(_.preventDefault(),_.stopPropagation(),_.key==="Escape"){o();return}if(f.has(_.key)){_.ctrlKey&&!p.includes("ctrl")&&p.push("ctrl"),_.metaKey&&!p.includes("meta")&&p.push("meta"),_.altKey&&!p.includes("alt")&&p.push("alt"),_.shiftKey&&!p.includes("shift")&&p.push("shift");return}if(p.length>0||_.ctrlKey||_.metaKey||_.altKey||_.shiftKey){const v=[...p];_.ctrlKey&&!v.includes("ctrl")&&v.push("ctrl"),_.metaKey&&!v.includes("meta")&&v.push("meta"),_.altKey&&!v.includes("alt")&&v.push("alt"),_.shiftKey&&!v.includes("shift")&&v.push("shift"),a({type:"chord",key:jv(_),modifiers:v});return}const w=Date.now(),k=jv(_);if(k===h.current&&w-l.current<400){a({type:"double-press",key:k,threshold:300});return}l.current=w,h.current=k},x=_=>{_.key==="Control"&&(p=p.filter(w=>w!=="ctrl")),_.key==="Shift"&&(p=p.filter(w=>w!=="shift")),_.key==="Alt"&&(p=p.filter(w=>w!=="alt")),_.key==="Meta"&&(p=p.filter(w=>w!=="meta"))};return window.addEventListener("keydown",m,!0),window.addEventListener("keyup",x,!0),()=>{window.removeEventListener("keydown",m,!0),window.removeEventListener("keyup",x,!0)}},[n,a,o]),u.jsxs("div",{ref:c,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${n?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[u.jsx("span",{className:"text-sm text-text-primary",children:e}),u.jsx("div",{className:"flex items-center gap-2",children:n?u.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):u.jsx("button",{type:"button",onClick:s,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:iS(t)})})]})}function pa({label:e,active:t,onClick:n}){return u.jsx("button",{onClick:n,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:e})}function $j({isOpen:e}){const{settings:t,loading:n,getSetting:s,setSetting:a}=Nu(),o=t[$e.GLOBAL_INSTRUCTIONS]??"",c=n[$e.GLOBAL_INSTRUCTIONS]??!1,[l,h]=O.useState(o),[f,p]=O.useState(!1),[m,x]=O.useState(!1);O.useEffect(()=>{e&&s($e.GLOBAL_INSTRUCTIONS)},[e,s]),O.useEffect(()=>{h(o),p(!1)},[o]);const _=async()=>{x(!0),await a($e.GLOBAL_INSTRUCTIONS,l),x(!1),p(!1)},w=()=>{h(o),p(!1)},k=c||m;return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),u.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),u.jsx("textarea",{value:l,onChange:v=>{h(v.target.value),p(!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:k})]}),f&&u.jsx(cp,{}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx(rt,{variant:"secondary",onClick:w,disabled:!f,children:"Discard"}),u.jsx(rt,{variant:"primary",onClick:_,disabled:!f||k,children:m?"Saving...":"Save"})]})]})}var kf={exports:{}},Dv;function Uj(){return Dv||(Dv=1,(function(e,t){(function(n,s){e.exports=s()})(globalThis,(()=>(()=>{var n={4567:function(c,l,h){var f=this&&this.__decorate||function(y,S,E,N){var T,L=arguments.length,A=L<3?S:N===null?N=Object.getOwnPropertyDescriptor(S,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(y,S,E,N);else for(var z=y.length-1;z>=0;z--)(T=y[z])&&(A=(L<3?T(A):L>3?T(S,E,A):T(S,E))||A);return L>3&&A&&Object.defineProperty(S,E,A),A},p=this&&this.__param||function(y,S){return function(E,N){S(E,N,y)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const m=h(9042),x=h(9924),_=h(844),w=h(4725),k=h(2585),v=h(3656);let b=l.AccessibilityManager=class extends _.Disposable{constructor(y,S,E,N){super(),this._terminal=y,this._coreBrowserService=E,this._renderService=N,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 T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,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 x.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((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
59
59
|
`)))),this.register(this._terminal.onA11yTab((T=>this._handleTab(T)))),this.register(this._terminal.onKey((T=>this._handleKey(T.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,v.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,_.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(y){for(let S=0;S<y;S++)this._handleChar(" ")}_handleChar(y){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==y&&(this._charsToAnnounce+=y):this._charsToAnnounce+=y,y===`
|
|
60
60
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(y){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(y)||this._charsToConsume.push(y)}_refreshRows(y,S){this._liveRegionDebouncer.refresh(y,S,this._terminal.rows)}_renderRows(y,S){const E=this._terminal.buffer,N=E.lines.length.toString();for(let T=y;T<=S;T++){const L=E.lines.get(E.ydisp+T),A=[],z=(L==null?void 0:L.translateToString(!0,void 0,void 0,A))||"",R=(E.ydisp+T+1).toString(),$=this._rowElements[T];$&&(z.length===0?($.innerText=" ",this._rowColumns.set($,[0,1])):($.textContent=z,this._rowColumns.set($,A)),$.setAttribute("aria-posinset",R),$.setAttribute("aria-setsize",N))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(y,S){const E=y.target,N=this._rowElements[S===0?1:this._rowElements.length-2];if(E.getAttribute("aria-posinset")===(S===0?"1":`${this._terminal.buffer.lines.length}`)||y.relatedTarget!==N)return;let T,L;if(S===0?(T=E,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(T=this._rowElements.shift(),L=E,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),S===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(S===0?-1:1),this._rowElements[S===0?1:this._rowElements.length-2].focus(),y.preventDefault(),y.stopImmediatePropagation()}_handleSelectionChange(){var z;if(this._rowElements.length===0)return;const y=document.getSelection();if(!y)return;if(y.isCollapsed)return void(this._rowContainer.contains(y.anchorNode)&&this._terminal.clearSelection());if(!y.anchorNode||!y.focusNode)return void console.error("anchorNode and/or focusNode are null");let S={node:y.anchorNode,offset:y.anchorOffset},E={node:y.focusNode,offset:y.focusOffset};if((S.node.compareDocumentPosition(E.node)&Node.DOCUMENT_POSITION_PRECEDING||S.node===E.node&&S.offset>E.offset)&&([S,E]=[E,S]),S.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(S={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(S.node))return;const N=this._rowElements.slice(-1)[0];if(E.node.compareDocumentPosition(N)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(E={node:N,offset:((z=N.textContent)==null?void 0:z.length)??0}),!this._rowContainer.contains(E.node))return;const T=({node:R,offset:$})=>{const F=R instanceof Text?R.parentNode:R;let W=parseInt(F==null?void 0:F.getAttribute("aria-posinset"),10)-1;if(isNaN(W))return console.warn("row is invalid. Race condition?"),null;const Y=this._rowColumns.get(F);if(!Y)return console.warn("columns is null. Race condition?"),null;let P=$<Y.length?Y[$]:Y.slice(-1)[0]+1;return P>=this._terminal.cols&&(++W,P=0),{row:W,column:P}},L=T(S),A=T(E);if(L&&A){if(L.row>A.row||L.row===A.row&&L.column>=A.column)throw new Error("invalid range");this._terminal.select(L.column,L.row,(A.row-L.row)*this._terminal.cols-L.column+A.column)}}_handleResize(y){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let S=this._rowContainer.children.length;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);for(;this._rowElements.length>y;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const y=this._coreBrowserService.mainDocument.createElement("div");return y.setAttribute("role","listitem"),y.tabIndex=-1,this._refreshRowDimensions(y),y}_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 y=0;y<this._terminal.rows;y++)this._refreshRowDimensions(this._rowElements[y])}}_refreshRowDimensions(y){y.style.height=`${this._renderService.dimensions.css.cell.height}px`}};l.AccessibilityManager=b=f([p(1,k.IInstantiationService),p(2,w.ICoreBrowserService),p(3,w.IRenderService)],b)},3614:(c,l)=>{function h(x){return x.replace(/\r?\n/g,"\r")}function f(x,_){return _?"\x1B[200~"+x+"\x1B[201~":x}function p(x,_,w,k){x=f(x=h(x),w.decPrivateModes.bracketedPasteMode&&k.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(x,!0),_.value=""}function m(x,_,w){const k=w.getBoundingClientRect(),v=x.clientX-k.left-10,b=x.clientY-k.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${v}px`,_.style.top=`${b}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(l,"__esModule",{value:!0}),l.rightClickHandler=l.moveTextAreaUnderMouseCursor=l.paste=l.handlePasteEvent=l.copyHandler=l.bracketTextForPaste=l.prepareTextForTerminal=void 0,l.prepareTextForTerminal=h,l.bracketTextForPaste=f,l.copyHandler=function(x,_){x.clipboardData&&x.clipboardData.setData("text/plain",_.selectionText),x.preventDefault()},l.handlePasteEvent=function(x,_,w,k){x.stopPropagation(),x.clipboardData&&p(x.clipboardData.getData("text/plain"),_,w,k)},l.paste=p,l.moveTextAreaUnderMouseCursor=m,l.rightClickHandler=function(x,_,w,k,v){m(x,_,w),v&&k.rightClickSelect(x),_.value=k.selectionText,_.select()}},7239:(c,l,h)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.ColorContrastCache=void 0;const f=h(1505);l.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(p,m,x){this._css.set(p,m,x)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,x){this._color.set(p,m,x)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(c,l)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.addDisposableDomListener=void 0,l.addDisposableDomListener=function(h,f,p,m){h.addEventListener(f,p,m);let x=!1;return{dispose:()=>{x||(x=!0,h.removeEventListener(f,p,m))}}}},3551:function(c,l,h){var f=this&&this.__decorate||function(b,y,S,E){var N,T=arguments.length,L=T<3?y:E===null?E=Object.getOwnPropertyDescriptor(y,S):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(b,y,S,E);else for(var A=b.length-1;A>=0;A--)(N=b[A])&&(L=(T<3?N(L):T>3?N(y,S,L):N(y,S))||L);return T>3&&L&&Object.defineProperty(y,S,L),L},p=this&&this.__param||function(b,y){return function(S,E){y(S,E,b)}};Object.defineProperty(l,"__esModule",{value:!0}),l.Linkifier=void 0;const m=h(3656),x=h(8460),_=h(844),w=h(2585),k=h(4725);let v=l.Linkifier=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(b,y,S,E,N){super(),this._element=b,this._mouseService=y,this._renderService=S,this._bufferService=E,this._linkProviderService=N,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new x.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new x.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)((()=>{var T;this._lastMouseEvent=void 0,(T=this._activeProviderReplies)==null||T.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 y=this._positionFromMouseEvent(b,this._element,this._mouseService);if(!y)return;this._isMouseOut=!1;const S=b.composedPath();for(let E=0;E<S.length;E++){const N=S[E];if(N.classList.contains("xterm"))break;if(N.classList.contains("xterm-hover"))return}this._lastBufferCell&&y.x===this._lastBufferCell.x&&y.y===this._lastBufferCell.y||(this._handleHover(y),this._lastBufferCell=y)}_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,y){var E,N;this._activeProviderReplies&&y||((E=this._activeProviderReplies)==null||E.forEach((T=>{T==null||T.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=b.y);let S=!1;for(const[T,L]of this._linkProviderService.linkProviders.entries())y?(N=this._activeProviderReplies)!=null&&N.get(T)&&(S=this._checkLinkProviderResult(T,b,S)):L.provideLinks(b.y,(A=>{var R,$;if(this._isMouseOut)return;const z=A==null?void 0:A.map((F=>({link:F})));(R=this._activeProviderReplies)==null||R.set(T,z),S=this._checkLinkProviderResult(T,b,S),(($=this._activeProviderReplies)==null?void 0:$.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(b.y,this._activeProviderReplies)}))}_removeIntersectingLinks(b,y){const S=new Set;for(let E=0;E<y.size;E++){const N=y.get(E);if(N)for(let T=0;T<N.length;T++){const L=N[T],A=L.link.range.start.y<b?0:L.link.range.start.x,z=L.link.range.end.y>b?this._bufferService.cols:L.link.range.end.x;for(let R=A;R<=z;R++){if(S.has(R)){N.splice(T--,1);break}S.add(R)}}}}_checkLinkProviderResult(b,y,S){var T;if(!this._activeProviderReplies)return S;const E=this._activeProviderReplies.get(b);let N=!1;for(let L=0;L<b;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(N=!0);if(!N&&E){const L=E.find((A=>this._linkAtPosition(A.link,y)));L&&(S=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!S)for(let L=0;L<this._activeProviderReplies.size;L++){const A=(T=this._activeProviderReplies.get(L))==null?void 0:T.find((z=>this._linkAtPosition(z.link,y)));if(A){S=!0,this._handleNewLink(A);break}}return S}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(b){if(!this._currentLink)return;const y=this._positionFromMouseEvent(b,this._element,this._mouseService);y&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,y)&&this._currentLink.link.activate(b,this._currentLink.link.text)}_clearCurrentLink(b,y){this._currentLink&&this._lastMouseEvent&&(!b||!y||this._currentLink.link.range.start.y>=b&&this._currentLink.link.range.end.y<=y)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(b){if(!this._lastMouseEvent)return;const y=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);y&&this._linkAtPosition(b.link,y)&&(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 S,E;return(E=(S=this._currentLink)==null?void 0:S.state)==null?void 0:E.decorations.pointerCursor},set:S=>{var E;(E=this._currentLink)!=null&&E.state&&this._currentLink.state.decorations.pointerCursor!==S&&(this._currentLink.state.decorations.pointerCursor=S,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",S))}},underline:{get:()=>{var S,E;return(E=(S=this._currentLink)==null?void 0:S.state)==null?void 0:E.decorations.underline},set:S=>{var E,N,T;(E=this._currentLink)!=null&&E.state&&((T=(N=this._currentLink)==null?void 0:N.state)==null?void 0:T.decorations.underline)!==S&&(this._currentLink.state.decorations.underline=S,this._currentLink.state.isHovered&&this._fireUnderlineEvent(b.link,S))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((S=>{if(!this._currentLink)return;const E=S.start===0?0:S.start+1+this._bufferService.buffer.ydisp,N=this._bufferService.buffer.ydisp+1+S.end;if(this._currentLink.link.range.start.y>=E&&this._currentLink.link.range.end.y<=N&&(this._clearCurrentLink(E,N),this._lastMouseEvent)){const T=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);T&&this._askForLink(T,!1)}}))))}_linkHover(b,y,S){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(y,!0),this._currentLink.state.decorations.pointerCursor&&b.classList.add("xterm-cursor-pointer")),y.hover&&y.hover(S,y.text)}_fireUnderlineEvent(b,y){const S=b.range,E=this._bufferService.buffer.ydisp,N=this._createLinkUnderlineEvent(S.start.x-1,S.start.y-E-1,S.end.x,S.end.y-E-1,void 0);(y?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(N)}_linkLeave(b,y,S){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(y,!1),this._currentLink.state.decorations.pointerCursor&&b.classList.remove("xterm-cursor-pointer")),y.leave&&y.leave(S,y.text)}_linkAtPosition(b,y){const S=b.range.start.y*this._bufferService.cols+b.range.start.x,E=b.range.end.y*this._bufferService.cols+b.range.end.x,N=y.y*this._bufferService.cols+y.x;return S<=N&&N<=E}_positionFromMouseEvent(b,y,S){const E=S.getCoords(b,y,this._bufferService.cols,this._bufferService.rows);if(E)return{x:E[0],y:E[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(b,y,S,E,N){return{x1:b,y1:y,x2:S,y2:E,cols:this._bufferService.cols,fg:N}}};l.Linkifier=v=f([p(1,k.IMouseService),p(2,k.IRenderService),p(3,w.IBufferService),p(4,k.ILinkProviderService)],v)},9042:(c,l)=>{Object.defineProperty(l,"__esModule",{value:!0}),l.tooMuchOutput=l.promptLabel=void 0,l.promptLabel="Terminal input",l.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(c,l,h){var f=this&&this.__decorate||function(k,v,b,y){var S,E=arguments.length,N=E<3?v:y===null?y=Object.getOwnPropertyDescriptor(v,b):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(k,v,b,y);else for(var T=k.length-1;T>=0;T--)(S=k[T])&&(N=(E<3?S(N):E>3?S(v,b,N):S(v,b))||N);return E>3&&N&&Object.defineProperty(v,b,N),N},p=this&&this.__param||function(k,v){return function(b,y){v(b,y,k)}};Object.defineProperty(l,"__esModule",{value:!0}),l.OscLinkProvider=void 0;const m=h(511),x=h(2585);let _=l.OscLinkProvider=class{constructor(k,v,b){this._bufferService=k,this._optionsService=v,this._oscLinkService=b}provideLinks(k,v){var z;const b=this._bufferService.buffer.lines.get(k-1);if(!b)return void v(void 0);const y=[],S=this._optionsService.rawOptions.linkHandler,E=new m.CellData,N=b.getTrimmedLength();let T=-1,L=-1,A=!1;for(let R=0;R<N;R++)if(L!==-1||b.hasContent(R)){if(b.loadCell(R,E),E.hasExtendedAttrs()&&E.extended.urlId){if(L===-1){L=R,T=E.extended.urlId;continue}A=E.extended.urlId!==T}else L!==-1&&(A=!0);if(A||L!==-1&&R===N-1){const $=(z=this._oscLinkService.getLinkData(T))==null?void 0:z.uri;if($){const F={start:{x:L+1,y:k},end:{x:R+(A||R!==N-1?0:1),y:k}};let W=!1;if(!(S!=null&&S.allowNonHttpProtocols))try{const Y=new URL($);["http:","https:"].includes(Y.protocol)||(W=!0)}catch{W=!0}W||y.push({text:$,range:F,activate:(Y,P)=>S?S.activate(Y,P,F):w(0,P),hover:(Y,P)=>{var H;return(H=S==null?void 0:S.hover)==null?void 0:H.call(S,Y,P,F)},leave:(Y,P)=>{var H;return(H=S==null?void 0:S.leave)==null?void 0:H.call(S,Y,P,F)}})}A=!1,E.hasExtendedAttrs()&&E.extended.urlId?(L=R,T=E.extended.urlId):(L=-1,T=-1)}}v(y)}};function w(k,v){if(confirm(`Do you want to navigate to ${v}?
|
|
61
61
|
|
|
@@ -85,7 +85,7 @@ WARNING: This link could potentially be dangerous`)){const b=window.open();if(b)
|
|
|
85
85
|
`,children:[u.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[u.jsx(Xn,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),u.jsx(dl,{items:[{label:"Edit project settings",onClick:()=>o(!0)},{label:"Delete all sessions",onClick:E,danger:!0}],trigger:u.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:u.jsx(Qm,{})})}),n&&u.jsx(hl,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),w&&u.jsx(sT,{isOpen:a,onClose:()=>o(!1),project:w}),u.jsx("div",{className:"flex-1 overflow-y-auto",children:b.length===0?u.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"No sessions"}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"divide-y divide-border",children:oT(b,l,h,y,S,e)}),_&&u.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),u.jsx("div",{ref:k,className:"h-px"})]})})]})]})}function oT(e,t,n,s,a,o){const c=vS(e);return Array.from(c).map(([l,h])=>{const f=h[0];return f?u.jsxs("div",{children:[u.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:_S(f.updatedAt)}),h.map(p=>{const m=(t==null?void 0:t.id)===p.id,x=n.includes(p.id),_=p.isRunning;return u.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${m?"bg-bg-tertiary":""}`,children:u.jsxs(Xn,{href:`/p/${o}/s/${p.id}`,className:`block ${m?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[u.jsxs("div",{className:"flex justify-between items-center mb-1",children:[u.jsx("span",{className:`font-medium truncate text-sm ${m?"text-accent-primary":"text-text-primary"}`,children:p.title??p.id.slice(0,6)}),u.jsx(dl,{items:[{label:"Rename session",onClick:w=>a(p.id,w)},{label:"Delete session",onClick:w=>s(p.id,w),danger:!0}],trigger:u.jsx("button",{onClick:w=>w.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:u.jsx(Qm,{})})})]}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[_?u.jsx(dj,{}):x&&!m?u.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,u.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Au(p.updatedAt)}),u.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[p.messageCount," messages"]})]})]})},p.id)})]},l):null})}const Rv=["⠋","⠙","⠹","⠸","⠼","⠴"];function lT(){var l;const e=Pt(h=>h.currentProject),t=Ce(h=>h.currentSession),n=Ym(),s=!1,a=O.useRef(0),o=O.useRef(null);O.useEffect(()=>(n?(o.current=window.setInterval(()=>{a.current=(a.current+1)%Rv.length,c()},150),c()):(o.current&&(clearInterval(o.current),o.current=null),c()),()=>{o.current&&(clearInterval(o.current),o.current=null)}),[n,e,t,s]);const c=()=>{var m;const f=(m=t==null?void 0:t.metadata)==null?void 0:m.title,p=n?`${Rv[a.current]} `:"";e&&f?document.title=`${p}${e.name} - ${f} | OpenFox`:e?document.title=`${p}${e.name} | OpenFox`:document.title=`${p}OpenFox`};return typeof window<"u"&&((l=t==null?void 0:t.metadata)!=null&&l.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function SS(e,t=28){if(e.length<=t)return e;const n=e.split("/").filter(Boolean);if(n.length<=2)return e;const s=n[0],a=n[n.length-1],o=n.slice(1,-1).join("/"),c=t-s.length-a.length-3;if(c<0)return e;const l=o.slice(0,Math.floor(c/2)),h=o.slice(-Math.ceil(c/2));return`/${s}/${l}...${h}/${a}`}function wS({isOpen:e,onClose:t,projectName:n,onConfirm:s}){const a=()=>{s(),t()};return u.jsx(Nt,{isOpen:e,onClose:t,title:"Delete Project",size:"sm",children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("p",{className:"text-text-secondary",children:["This will permanently delete the project"," ",u.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx(rt,{variant:"secondary",onClick:t,children:"Cancel"}),u.jsx(rt,{variant:"danger",onClick:a,children:"Delete"})]})]})})}const Lu=O.forwardRef(({className:e="",...t},n)=>u.jsx("input",{ref:n,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...t}));Lu.displayName="Input";function cT(e){return!e||e.trim()===""?{valid:!1,error:"Project name cannot be empty"}:/^[a-zA-Z0-9._-]+$/.test(e)?{valid:!0}:{valid:!1,error:"Project name can only contain letters, numbers, hyphens, underscores, and dots"}}function CS({isOpen:e,onClose:t,path:n,onRetry:s}){const[a,o]=O.useState(!1),[c,l]=O.useState(null),[h,f]=O.useState(null);O.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const E=await(await je("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();f({sudoAvailable:E.sudoAvailable,userInGroup:E.userInGroup,groupHasWrite:E.groupHasWrite,groupName:E.groupName||null})}catch{f({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=O.useCallback(async S=>{o(!0),l(null);try{const N=await(await je("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:S})})).json();N.success?(s(),t()):N.sudoAvailable?l("Failed to fix permissions: "+(N.error||"Unknown error")):l(`Passwordless sudo is not available. Please fix permissions manually:
|
|
86
86
|
|
|
87
87
|
`+(S==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(E){l("Failed to fix permissions: "+(E instanceof Error?E.message:"Unknown error"))}finally{o(!1)}},[n,s,t]),x=(h==null?void 0:h.userInGroup)??!1,_=(h==null?void 0:h.groupHasWrite)??!1,w=(h==null?void 0:h.sudoAvailable)??!1,k=(h==null?void 0:h.groupName)??"",v=x&&!_,b=!x&&_,y=!x&&!_;return u.jsx(Nt,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"text-sm text-text-secondary",children:[u.jsx("p",{children:v?u.jsxs(u.Fragment,{children:["The group ",u.jsx("strong",{children:k})," doesn't have write access:"]}):b?u.jsxs(u.Fragment,{children:["You're not a member of group ",u.jsx("strong",{children:k}),":"]}):u.jsxs(u.Fragment,{children:["You're not a member of group ",u.jsx("strong",{children:k})," and it doesn't have write access:"]})}),u.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),c?u.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:c}):h?u.jsxs("div",{className:"flex flex-col gap-2",children:[v&&u.jsxs(u.Fragment,{children:[u.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),u.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),u.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),b&&u.jsxs(u.Fragment,{children:[u.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),u.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),u.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",k," $USER"]})]}),y&&u.jsxs(u.Fragment,{children:[u.jsx(rt,{type:"button",variant:"primary",onClick:()=>m("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),u.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),u.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",k," $USER",u.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!c&&u.jsxs("div",{className:"text-xs text-text-secondary",children:[u.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),u.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),u.jsx("div",{className:"flex justify-end",children:u.jsx(rt,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function uT({isOpen:e,onClose:t}){const[,n]=wr(),[s,a]=O.useState(""),[o,c]=O.useState(null),[l,h]=O.useState(!1),[f,p]=O.useState(""),[m,x]=O.useState(null),_=O.useRef(null);O.useEffect(()=>{e&&(je("/api/config").then(E=>E.json()).then(E=>{E.workdir&&p(E.workdir)}),a(""),c(null),h(!1),x(null),setTimeout(()=>{var E;(E=_.current)==null||E.focus()},100))},[e]);const w=O.useCallback(async E=>{E.preventDefault();const N=cT(s);if(!N.valid){c(N.error);return}const T=`${f}/${s}`;await b(T)},[s,n,t,f]),k=O.useCallback(()=>{x(null)},[]),v=O.useCallback(async()=>{const E=`${f}/${s}`;await b(E)},[f,s,n,t,x,c,h]);async function b(E){h(!0),c(null),x(null);try{const N=await je("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,workdir:E})});if(!N.ok){const A=await N.json().catch(()=>({}));if(A.code==="EACCES"){x(E),h(!1);return}throw new Error(A.error||"Failed to create project")}const L=(await N.json()).project;t(),n(`/p/${L.id}`)}catch(N){c(N instanceof Error?N.message:"Failed to create project"),h(!1)}}const y=O.useCallback(()=>{a(""),c(null),t()},[t]),S=s?`${f}/${s}`:"";return u.jsxs(u.Fragment,{children:[u.jsx(Nt,{isOpen:e,onClose:y,title:"Create New Project",size:"sm",children:u.jsxs("form",{onSubmit:w,className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),u.jsx(Lu,{ref:_,id:"project-name",value:s,onChange:E=>{a(E.target.value),c(null)},placeholder:"my-project",disabled:l,"data-testid":"create-project-name-input",className:"w-full"}),s&&u.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",u.jsx("span",{className:"font-mono",children:S})]}),o&&u.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:o})]}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx(rt,{type:"button",variant:"secondary",onClick:y,disabled:l,children:"Cancel"}),u.jsx(rt,{type:"submit",variant:"primary",disabled:l||!s.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:l?u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(La,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),m&&u.jsx(CS,{isOpen:!!m,onClose:k,path:m,onRetry:v})]})}const dT={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function fl({size:e="md",className:t=""}){return u.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${dT[e]} ${t}`})}function hT({text:e,...t}){return u.jsxs("div",{className:"text-center",children:[u.jsx(fl,{...t,className:"mx-auto mb-4"}),e&&u.jsx("div",{className:"text-text-secondary",children:e})]})}function kS({onSelect:e,onClose:t,initialPath:n}){const[s,a]=O.useState(null),[o,c]=O.useState(!0),[l,h]=O.useState(""),[f,p]=O.useState(-1),m=O.useRef(null),x=O.useRef([]),_=O.useCallback(async y=>{c(!0),h(""),p(-1);try{const S=y?`/api/directories?path=${encodeURIComponent(y)}`:"/api/directories",N=await(await je(S)).json();a(N)}catch(S){console.error("Failed to load directories:",S)}finally{c(!1)}},[]);O.useEffect(()=>{_(n)},[n,_]);const w=((s==null?void 0:s.current)??"").split("/").filter(Boolean).map((y,S,E)=>({name:y,path:"/"+E.slice(0,S+1).join("/")})),k=(s==null?void 0:s.directories.filter(y=>l===""||y.name.toLowerCase().includes(l.toLowerCase())))??[],v=[...s!=null&&s.parent?[{type:"parent",path:s.parent,name:".."}]:[],...k.map(y=>({type:"dir",path:y.path,name:y.name}))];O.useEffect(()=>{p(l?0:-1)},[l,k.length]),O.useEffect(()=>{var y;f>=0&&x.current[f]&&((y=x.current[f])==null||y.scrollIntoView({block:"nearest"}))},[f]);const b=y=>{var S;if(y.key==="ArrowDown")y.preventDefault(),p(E=>Math.min(E+1,v.length-1));else if(y.key==="ArrowUp")y.preventDefault(),p(E=>Math.max(E-1,0));else if(y.key==="Enter"){if(y.preventDefault(),f>=0&&v[f]){const E=v[f];E.type,_(E.path)}}else y.key==="Escape"&&(h(""),(S=m.current)==null||S.focus())};return u.jsxs(Nt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",children:[s&&u.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30 -mx-4 -mt-4 mb-4 border-b border-border",children:u.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[w.map((y,S)=>u.jsxs("span",{className:"flex items-center shrink-0",children:[u.jsx("span",{className:"text-text-muted",children:"/"}),u.jsx("button",{onClick:()=>_(y.path),className:`px-1 ${S===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:y.name})]},y.path)),w.length===0&&u.jsx("button",{onClick:()=>_("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),u.jsx("div",{className:"px-4 mb-3",children:u.jsxs("div",{className:"relative",children:[u.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none flex items-center justify-center",children:u.jsx(ep,{})}),u.jsx(Lu,{autoFocus:!0,ref:m,value:l,onChange:y=>h(y.target.value),onKeyDown:b,placeholder:"Filter directories...",className:"w-full pl-9"})]})}),u.jsx("div",{className:"flex-1 overflow-y-auto -mx-4",children:o?u.jsx("div",{className:"p-8 text-center",children:u.jsx(fl,{size:"sm"})}):v.length===0?u.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:l?"No matching directories":"No subdirectories"}):u.jsx("div",{className:"divide-y divide-border",children:v.map((y,S)=>u.jsxs("button",{ref:E=>{x.current[S]=E},onClick:()=>_(y.path),onDoubleClick:()=>e(y.path),className:`w-full p-3 flex items-center gap-3 text-left transition-colors ${S===f?"bg-accent-primary/20 text-accent-primary":"hover:bg-bg-tertiary/50"}`,children:[y.type==="parent"?u.jsx(X2,{className:"w-5 h-5 text-text-muted"}):u.jsx(Jm,{className:"w-5 h-5"}),u.jsx("span",{className:"flex-1",children:y.name}),S===f&&u.jsx("span",{className:"text-xs text-text-muted",children:"⏎ navigate · dbl-click select"})]},y.path))})}),u.jsxs("div",{className:"flex flex-col gap-2 pt-4 border-t border-border mt-4 -mx-4 -mb-4 p-4",children:[(s==null?void 0:s.current)&&u.jsx("button",{onClick:()=>e(s.current),className:"w-full px-4 py-2 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Select this folder"}),u.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})]})]})}function fT({isOpen:e,onClose:t}){const[,n]=wr(),[s,a]=O.useState(!1),[o,c]=O.useState(null),[l,h]=O.useState(!1),f=Pt(R=>R.projects),p=Pt(R=>R.createProject),m=Pt(R=>R.listProjects),x=Pt(R=>R.deleteProject),[_,w]=O.useState(null),[k,v]=O.useState(null),[b,y]=O.useState(null);O.useEffect(()=>{je("/api/config").then(R=>R.json()).then(R=>{R.workdir&&c(R.workdir)})},[]),O.useEffect(()=>{e&&m()},[e,m]);const S=R=>{n(`/p/${R}`),t()},E=(R,$)=>{$.stopPropagation(),w(R)},N=()=>{_&&(x(_.id),w(null))},T=async R=>{const $=R.split("/").filter(Boolean).pop()??"",F=await p($,R);return m(),v(R),L(F)?(y(F.error.path||R),!1):!0};function L(R){return R!=null&&typeof R=="object"&&"error"in R&&R.error!=null&&typeof R.error=="object"&&"code"in R.error&&R.error.code==="EACCES"}const A=O.useCallback(()=>{y(null)},[]),z=O.useCallback(async()=>{if(y(null),k){const R=k.split("/").filter(Boolean).pop()??"",$=await p(R,k);m(),v(k),L($)&&y($.error.path||k)}},[k,p,m,y]);return O.useEffect(()=>{if(k){const R=f.find($=>$.workdir===k);R&&(n(`/p/${R.id}`),t(),v(null))}},[f,k,n,t]),e?u.jsxs(Nt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:u.jsx("div",{className:"flex justify-end gap-2",children:u.jsx(rt,{variant:"secondary",onClick:t,children:"Close"})}),children:[u.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[u.jsxs("div",{className:"w-full sm:w-1/2 border-b sm:border-b-0 sm:border-r border-border flex flex-col max-h-[40vh] sm:max-h-[50vh]",children:[u.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:u.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),u.jsx("div",{className:"flex-1 overflow-y-auto",children:f.length===0?u.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[u.jsx("p",{className:"mb-2",children:"No recent projects"}),u.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):u.jsx("div",{className:"divide-y divide-border",children:f.map(R=>u.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[u.jsxs("button",{onClick:()=>S(R.id),className:"flex-1 flex items-center gap-3 text-left",children:[u.jsx(Jm,{className:"w-5 h-5 text-accent-primary"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium truncate",children:R.name}),u.jsx("div",{className:"text-xs text-text-muted truncate",children:SS(R.workdir,32)})]})]}),u.jsx("button",{onClick:$=>E(R,$),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:u.jsx(ju,{className:"w-4 h-4"})})]},R.id))})})]}),u.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:u.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[u.jsx(rt,{variant:"primary",onClick:()=>h(!0),children:"Select existing project"}),u.jsx(rt,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),s&&u.jsx(uT,{isOpen:s,onClose:()=>a(!1)}),_&&u.jsx(wS,{isOpen:!0,onClose:()=>w(null),projectName:_.name,onConfirm:N}),l&&u.jsx(kS,{initialPath:o??void 0,onSelect:R=>{T(R).then($=>{$&&h(!1)})},onClose:()=>h(!1)}),b&&u.jsx(CS,{isOpen:!0,onClose:A,path:b,onRetry:z})]}):null}function mT(){const[e,t]=O.useState(!1),[n,s]=O.useState(null),a=Ce(w=>w.sessions),o=Pt(w=>w.projects),c=Pt(w=>w.loading),l=Pt(w=>w.listProjects),h=Ce(w=>w.listSessions),f=Pt(w=>w.deleteProject),p=Ce(w=>w.connectionStatus);O.useEffect(()=>{p==="connected"&&(l(),h())},[p,l,h]);const m=[...o].sort((w,k)=>{const v=a.filter(E=>E.workdir.startsWith(w.workdir)),b=a.filter(E=>E.workdir.startsWith(k.workdir)),y=v.length>0?new Date(v.reduce((E,N)=>new Date(N.updatedAt)>new Date(E.updatedAt)?N:E).updatedAt).getTime():new Date(w.updatedAt).getTime();return(b.length>0?new Date(b.reduce((E,N)=>new Date(N.updatedAt)>new Date(E.updatedAt)?N:E).updatedAt).getTime():new Date(k.updatedAt).getTime())-y}),x=w=>{const k=o.find(v=>v.id===w);return k?a.filter(v=>v.workdir.startsWith(k.workdir)).sort((v,b)=>new Date(b.updatedAt).getTime()-new Date(v.updatedAt).getTime()).slice(0,5):[]},_=()=>{t(!0)};return u.jsxs("div",{className:"flex-1 flex flex-col overflow-y-auto bg-primary",children:[u.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[u.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),u.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),u.jsx(rt,{variant:"primary",onClick:_,children:"Open Project"})]}),m.map(w=>{const k=x(w.id);return u.jsx("div",{className:"mb-6 md:mb-8",children:u.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[u.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[u.jsxs(Xn,{href:`/p/${w.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[u.jsx(Jm,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),u.jsx("span",{className:"text-text-primary font-semibold",children:w.name})]}),u.jsx(Xn,{href:`/p/${w.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"}),u.jsx("button",{type:"button",onClick:()=>s({id:w.id,name:w.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:u.jsx(ju,{className:"w-4 h-4"})})]}),u.jsx("div",{className:"divide-y divide-border",children:k.length>0?k.map(v=>{const b=o.find(S=>v.workdir.startsWith(S.workdir)),y=b?`/p/${b.id}/s/${v.id}`:"#";return u.jsx(Xn,{href:y,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:u.jsx("div",{className:"flex-1 min-w-0",children:u.jsx("div",{className:"text-sm text-text-muted truncate",children:v.title??v.id.slice(0,8)})})}),u.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u.jsx("span",{className:"text-text-muted text-xs",children:Xj(v.updatedAt)}),u.jsxs("span",{className:"text-text-muted text-xs",children:[v.messageCount," msgs"]})]})]})},v.id)}):u.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},w.id)}),m.length===0&&!c&&u.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),c&&u.jsx("div",{className:"flex justify-center py-12",children:u.jsx(fl,{})})]}),e&&u.jsx(fT,{isOpen:e,onClose:()=>t(!1)}),n&&u.jsx(wS,{isOpen:!0,onClose:()=>s(null),projectName:n.name,onConfirm:()=>f(n.id)})]})}function pT(){const[,e]=Km("/p/:projectId/new"),[,t]=wr(),n=e==null?void 0:e.projectId,s=Ce(c=>c.createSession),a=Ce(c=>c.resetPendingSessionCreate),o=O.useCallback(async()=>{if(!n)return;const c=await s(n);c?(t(`/p/${n}/s/${c.id}`),a()):(t(`/p/${n}`),a())},[n,s,t,a]);return O.useEffect(()=>{o()},[o]),u.jsx("div",{className:"flex-1 flex items-center justify-center",children:u.jsx(fl,{})})}function gT(){const e=Pt(t=>t.currentProject);return u.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:u.jsxs("div",{className:"max-w-md",children:[u.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),u.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),u.jsxs("div",{className:"flex flex-col gap-3",children:[e&&u.jsx(Xn,{href:`/p/${e.id}/new`,"data-testid":"create-new-session-button",className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),u.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const Bo=e=>Math.round(e*10)/10;function mm(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function xT(e){return`${e.providerId}::${e.model}`}function _T(e){return`${e.providerName} > ${e.model}`}function Ov(e){let t=0,n=0,s=0,a=0,o=0,c=0;const l=[],h=[];let f=0;for(const[x,_]of e.entries()){const w=_.stats,k=mm(w);t+=w.totalTime,n+=w.toolTime,s+=w.prefillTokens,a+=w.generationTokens;const v=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,b=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;o+=v,c+=b,l.push({messageId:_.id,timestamp:_.timestamp,...k,mode:w.mode,responseIndex:x+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const y=w.llmCalls??[];for(const S of y)f+=1,h.push({messageId:_.id,timestamp:S.timestamp??_.timestamp,providerId:S.providerId,providerName:S.providerName,backend:S.backend,model:S.model,mode:w.mode,responseIndex:x+1,sessionCallIndex:f,callIndex:S.callIndex,promptTokens:S.promptTokens,completionTokens:S.completionTokens,ttft:S.ttft,completionTime:S.completionTime,prefillSpeed:S.prefillSpeed,generationSpeed:S.generationSpeed,totalTime:S.totalTime,...S.temperature!==void 0&&{temperature:S.temperature},...S.topP!==void 0&&{topP:S.topP},...S.topK!==void 0&&{topK:S.topK},...S.maxTokens!==void 0&&{maxTokens:S.maxTokens}})}const p=o>0?Bo(s/o):0,m=c>0?Bo(a/c):0;return{totalTime:Bo(t),aiTime:Bo(t-n),toolTime:Bo(n),prefillTokens:s,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:h.length,dataPoints:l,callDataPoints:h}}function yT(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null).sort((a,o)=>new Date(a.timestamp).getTime()-new Date(o.timestamp).getTime());if(t.length===0)return null;const n=new Map;for(const a of t){const o=xT(mm(a.stats)),c=n.get(o)??[];n.set(o,[...c,a])}const s=Array.from(n.entries()).map(([a,o])=>{const c=mm(o[0].stats),l=Ov(o);return{...c,key:a,label:_T(c),...l}});return{...Ov(t),modelGroups:s}}function vT(e){return O.useMemo(()=>yT(e),[e])}function ES(){var a;const e=Ce(o=>o.gitStatus),t=Ce(o=>o.currentSession),[n,s]=O.useState(!0);return O.useEffect(()=>{t!=null&&t.workdir&&s(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((a=e==null?void 0:e.diff)==null?void 0:a.files)??[],loading:n,error:null}}}function eu(e){return e.toLocaleString("en-US").replace(/,/g," ")}function Mv(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function bT(e){if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=Math.round(e%60);return`${t}m${n}s`}const Iv=["▁","▂","▃","▄","▅","▆","▇","█"];function ST(e,t,n){if(n===t)return 4;const s=(e-t)/(n-t);return Math.min(7,Math.max(0,Math.round(s*7)))}function wT(e,t){if(e===t){const a=Math.max(Math.abs(e)*.05,1);return{minY:e-a,maxY:t+a}}const n=t-e,s=Math.max(n*.1,.1);return{minY:e-s,maxY:t+s}}function CT(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((m,x)=>m.x-x.x),s=n[0].x,a=n[n.length-1].x,o=Math.min(...n.map(m=>m.y)),c=Math.max(...n.map(m=>m.y)),{minY:l,maxY:h}=wT(o,c),f=Array.from({length:t},()=>" "),p=new Map;for(const m of n){const x=a===s?0:Math.round((m.x-s)/(a-s)*(t-1)),_=p.get(x)??[];p.set(x,[..._,m.y])}for(const[m,x]of p){const _=Math.max(...x);f[m]=Iv[ST(_,l,h)]??Iv[0]}return{blocks:f.join(""),minX:s,maxX:a,minY:l,maxY:h}}function Pv(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Bv({data:e,width:t=60,height:n=78,label:s,xLabel:a,yLabel:o,showAxes:c=!0,formatY:l=Pv,formatX:h=Pv}){const f=O.useMemo(()=>{const p=CT(e,t),m=Math.max(t*6,240),x=10,_=8,k=[...e].sort((S,E)=>S.x-E.x).map(S=>{const E=p.maxX===p.minX?m/2:x+(S.x-p.minX)/(p.maxX-p.minX)*(m-x*2),N=p.maxY===p.minY?n/2:_+(p.maxY-S.y)/(p.maxY-p.minY)*(n-_*2);return{...S,cx:E,cy:N,leftPercent:E/m*100,topPercent:N/n*100}}),v=k.map((S,E)=>`${E===0?"M":"L"} ${S.cx.toFixed(1)} ${S.cy.toFixed(1)}`).join(" "),y=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(S=>({value:S,y:p.maxY===p.minY?n/2:_+(p.maxY-S)/(p.maxY-p.minY)*(n-_*2)}));return{...p,chartWidth:m,points:k,path:v,gridLines:y}},[e,n,t]);return e.length===0?u.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[s&&u.jsx("div",{className:"mb-1",children:s}),u.jsx("div",{children:"No data"})]}):u.jsxs("div",{className:"font-mono text-xs",children:[s&&u.jsx("div",{className:"text-text-secondary mb-2",children:s}),u.jsxs("div",{className:"flex gap-3",children:[c&&u.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(p=>u.jsx("span",{children:l(p.value)},`${p.value}-${p.y}`))}),u.jsx("div",{className:"flex-1 min-w-0",children:u.jsxs("div",{className:"relative h-[78px]",children:[u.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(p=>u.jsx("line",{x1:"0",x2:f.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),f.points.map(p=>u.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),f.points.length>1&&u.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(p=>u.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${h(p.x)} -> ${l(p.y)}`,children:u.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:u.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),c&&u.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[u.jsx("span",{className:"w-12"}),u.jsxs("span",{className:"flex-1 flex justify-between",children:[u.jsx("span",{children:h(f.minX)}),u.jsx("span",{children:a}),u.jsx("span",{children:h(f.maxX)})]})]}),o&&c&&u.jsx("div",{className:"text-text-muted mt-1 text-center",children:o})]})}function kT({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:s="response",width:a=60}){const o=e.map(l=>({x:l.x,y:l.ppSpeed})),c=e.map(l=>({x:l.x,y:l.tgSpeed}));return u.jsxs("div",{className:"space-y-5",children:[u.jsx(Bv,{data:o,width:a,label:t,xLabel:s}),u.jsx(Bv,{data:c,width:a,label:n,xLabel:s})]})}function ET(e){const t=new Map;for(const n of e.callDataPoints){const s=t.get(n.messageId)??[];t.set(n.messageId,[...s,n])}return e.dataPoints.map(n=>{const s=[...t.get(n.messageId)??[]].sort((a,o)=>a.callIndex-o.callIndex);return{...n,callCount:s.length,calls:s,isExpandable:s.length>1}})}function jT(e){return{mode:"responses",xLabel:"response",prefillLabel:"Prefill Speed (tok/s) by Response",generationLabel:"Generation Speed (tok/s) by Response",points:e.dataPoints.map(t=>({x:t.responseIndex,ppSpeed:t.prefillSpeed,tgSpeed:t.generationSpeed}))}}function TT(e){return{mode:"calls",xLabel:"context",prefillLabel:"Prefill Speed (tok/s) vs Context",generationLabel:"Generation Speed (tok/s) vs Context",points:e.callDataPoints.map(t=>({x:t.promptTokens,ppSpeed:t.prefillSpeed,tgSpeed:t.generationSpeed}))}}function NT(e){return e.callDataPoints.length>0?TT(e):jT(e)}function Ef(e){if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),n=e%60;return`${t}m ${n.toFixed(0)}s`}function wi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function qo(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function AT(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${wi(t)} ctx`:`${wi(t)}-${wi(n)} ctx`}function tu(e){return`${qo(e)} t/s`}function jS(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function LT(e){return{exportedAt:new Date().toISOString(),providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model,label:e.label,summary:{totalTime:e.totalTime,aiTime:e.aiTime,toolTime:e.toolTime,prefillTokens:e.prefillTokens,generationTokens:e.generationTokens,avgPrefillSpeed:e.avgPrefillSpeed,avgGenerationSpeed:e.avgGenerationSpeed,responseCount:e.responseCount,llmCallCount:e.llmCallCount},responses:e.dataPoints.map(t=>({responseIndex:t.responseIndex,timestamp:t.timestamp,mode:t.mode,prefillTokens:t.prefillTokens,generationTokens:t.generationTokens,prefillSpeed:t.prefillSpeed,generationSpeed:t.generationSpeed,totalTime:t.totalTime,aiTime:t.aiTime,toolTime:t.toolTime})),llmCalls:e.callDataPoints.map(t=>({sessionCallIndex:t.sessionCallIndex,responseIndex:t.responseIndex,callIndex:t.callIndex,timestamp:t.timestamp,mode:t.mode,promptTokens:t.promptTokens,completionTokens:t.completionTokens,ttft:t.ttft,completionTime:t.completionTime,prefillSpeed:t.prefillSpeed,generationSpeed:t.generationSpeed,totalTime:t.totalTime}))}}function DT({isOpen:e,onClose:t,stats:n}){const s=O.useRef(null),[a,o]=O.useState({}),[c,l]=O.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});O.useEffect(()=>{var w;n.modelGroups.some(k=>k.key===c)||l(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[c,n.modelGroups]);const h=O.useMemo(()=>n.modelGroups.find(w=>w.key===c)??n.modelGroups[0],[c,n.modelGroups]),f=O.useMemo(()=>h?ET(h):[],[h]),p=O.useMemo(()=>h?NT(h):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[h]),m=O.useCallback(w=>{o(k=>({...k,[w]:!k[w]}))},[]),x=O.useCallback(()=>{if(!h)return;const w=LT(h);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(k=>console.error("Failed to copy:",k))},[h]),_=O.useCallback(async()=>{if(s.current)try{const w=(await Q(async()=>{const{default:b}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:b}},[])).default,k=await w(s.current,{backgroundColor:"#1a1a1a",scale:2}),v=document.createElement("a");v.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,v.href=k.toDataURL("image/png"),v.click()}catch(w){console.error("Failed to export PNG:",w),x()}},[x]);return u.jsx(Nt,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:u.jsxs("div",{ref:s,className:"space-y-6",children:[u.jsx("section",{children:u.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>u.jsx("button",{onClick:()=>l(w.key),className:`px-3 py-1.5 rounded border text-xs transition-colors ${w.key===(h==null?void 0:h.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:w.label,children:w.label},w.key))})}),h&&u.jsxs("section",{children:[u.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),u.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[u.jsx(ns,{label:"AI Time",value:Ef(h.aiTime)}),u.jsx(ns,{label:"Total Time",value:Ef(h.totalTime)}),u.jsx(ns,{label:"Tool Time",value:Ef(h.toolTime)}),u.jsx(ns,{label:"Responses",value:h.responseCount.toString()}),u.jsx(ns,{label:"LLM Calls",value:h.llmCallCount.toString()})]}),u.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[u.jsx(ns,{label:"Prefill Tokens",value:wi(h.prefillTokens),subValue:`@ ${qo(h.avgPrefillSpeed)} tok/s`}),u.jsx(ns,{label:"Gen Tokens",value:wi(h.generationTokens),subValue:`@ ${qo(h.avgGenerationSpeed)} tok/s`}),u.jsx(ns,{label:"Avg PP Speed",value:`${qo(h.avgPrefillSpeed)}`,subValue:"tok/s"}),u.jsx(ns,{label:"Avg TG Speed",value:`${qo(h.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),h&&p.points.length>1&&u.jsxs("section",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),u.jsx("button",{onClick:_,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),u.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:u.jsx(kT,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),h&&u.jsxs("section",{children:[u.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",h.responseCount," responses)"]}),u.jsx("div",{className:"overflow-y-auto bg-bg-tertiary/30 rounded",children:u.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[u.jsxs("colgroup",{children:[u.jsx("col",{className:"w-[7%]"}),u.jsx("col",{className:"w-[14%]"}),u.jsx("col",{className:"w-[10%]"}),u.jsx("col",{className:"w-[14%]"}),u.jsx("col",{className:"w-[14%]"}),u.jsx("col",{className:"w-[14%]"}),u.jsx("col",{className:"w-[11%]"}),u.jsx("col",{className:"w-[2%]"})]}),u.jsx("thead",{children:u.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[u.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),u.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),u.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),u.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),u.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),u.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),u.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),u.jsx("th",{className:"px-2 py-2"})]})}),u.jsx("tbody",{children:f.map((w,k)=>u.jsxs(O.Fragment,{children:[u.jsx(RT,{row:w,index:k,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((v,b)=>u.jsx(OT,{dataPoint:v,index:b},`${v.messageId}-${v.callIndex}`))]},w.messageId))})]})})]})]})})}function ns({label:e,value:t,subValue:n}){return u.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[u.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),u.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&u.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function RT({row:e,index:t,isExpanded:n,onToggle:s}){const a=e.calls.length>0?AT(e.calls.map(o=>o.promptTokens)):`${wi(e.prefillTokens)} ctx`;return u.jsxs("tr",{onClick:s,className:`${t%2===0?"bg-bg-tertiary/20":""} ${s?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[u.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),u.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:jS(e.timestamp)}),u.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),u.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),u.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:tu(e.prefillSpeed)}),u.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:tu(e.generationSpeed)}),u.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),u.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function OT({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return u.jsxs(u.Fragment,{children:[u.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[u.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),u.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:jS(e.timestamp)}),u.jsxs("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:[e.totalTime.toFixed(1),"s"]}),u.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:wi(e.promptTokens)}),u.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:tu(e.prefillSpeed)}),u.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:tu(e.generationSpeed)}),u.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),u.jsx("td",{className:"px-2 py-2"})]}),n&&u.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:u.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:u.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&u.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&u.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&u.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&u.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const MT={pending:{icon:"○",color:"text-text-muted",label:"Pending"},in_progress:{icon:"●",color:"text-accent-warning",label:"In Progress",animate:!0},completed:{icon:"◉",color:"text-purple-400",label:"Completed"},passed:{icon:"✓",color:"text-accent-success",label:"Passed"},failed:{icon:"✗",color:"text-accent-error",label:"Failed"}},IT=O.memo(function({criteria:t}){if(t.length===0)return u.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No criteria yet"});const n={pending:0,in_progress:0,completed:0,passed:0,failed:0};for(const a of t){const o=a.status.type;o in n&&n[o]++}const s=Object.keys(n).filter(a=>n[a]>0);return u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx("span",{className:"font-semibold text-text-primary",children:"Total:"}),u.jsx("span",{className:"text-text-secondary",children:t.length})]}),u.jsx("div",{className:"space-y-1",children:s.map(a=>{const o=MT[a];return u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx("span",{className:`${o.color} ${o.animate?"animate-pulse":""} text-sm leading-tight`,children:o.icon}),u.jsxs("span",{className:"text-text-muted",children:[o.label,":"]}),u.jsx("span",{className:"text-text-primary font-medium",children:n[a]})]},a)})})]})});function PT({isOpen:e,onClose:t}){const n=Rr(k=>k.config),s=Rr(k=>k.saveConfig),[a,o]=O.useState(""),[c,l]=O.useState(""),[h,f]=O.useState(!1),[p,m]=O.useState(!1),[x,_]=O.useState(!1);O.useEffect(()=>{e&&(o((n==null?void 0:n.command)??""),l((n==null?void 0:n.url)??""),f((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!a.trim()||!c.trim()||(_(!0),await s({command:a.trim(),url:c.trim(),hotReload:h,disableInspect:p}),_(!1),t())};return u.jsx(Nt,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),u.jsx("input",{className:"input w-full",type:"text",value:a,onChange:k=>o(k.target.value),placeholder:"npm run dev"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),u.jsx("input",{className:"input w-full",type:"text",value:c,onChange:k=>l(k.target.value),placeholder:"http://localhost:3000"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",id:"hotReload",checked:h,onChange:k=>f(k.target.checked),className:"rounded border-border bg-bg-tertiary"}),u.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:k=>m(k.target.checked),className:"rounded border-border bg-bg-tertiary"}),u.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),u.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[u.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),u.jsx("button",{className:"btn btn-primary",onClick:w,disabled:x||!a.trim()||!c.trim(),children:x?"Saving...":"Save"})]})]})})}const zv={30:"text-black",31:"text-red-400",32:"text-accent-success",33:"text-accent-warning",34:"text-blue-400",35:"text-purple-400",36:"text-cyan-400",37:"text-gray-300",90:"text-gray-500",91:"text-red-500",92:"text-green-500",93:"text-yellow-400",94:"text-blue-500",95:"text-pink-400",96:"text-cyan-500",97:"text-white"},BT={40:"bg-black",41:"bg-red-900",42:"bg-green-900",43:"bg-yellow-900",44:"bg-blue-900",45:"bg-purple-900",46:"bg-cyan-900",47:"bg-gray-700"},Hv={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},zT="text-text-primary";function HT(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let s=0,a="text-text-primary",o;try{for(;(o=n.exec(e))!==null;){if(o.index>s){const f=e.slice(s,o.index);f&&t.push({text:f,className:a})}const c=o[1];if(!c)continue;const l=c.split(";").map(Number);if(l.length===0||l[0]===0){a="text-text-primary";continue}const h=[];for(const f of l)if(f>=30&&f<=37){const p=zv[f];p&&h.push(p)}else if(f>=40&&f<=47){const p=BT[f];p&&h.push(p)}else if(f>=90&&f<=97){const p=zv[f];p&&h.push(p)}else if(f in Hv){const p=Hv[f];p&&h.push(p)}else f===39?h.push(zT):f===49&&(a=a.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));h.length>0&&(a=h.join(" ")),s=n.lastIndex}if(s<e.length){const c=e.slice(s);c&&t.push({text:c,className:a})}return t}catch(c){return console.warn("ANSI parsing failed, stripping codes:",c),[{text:$T(e),className:"text-text-primary"}]}}function $T(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function nu(e){const t=HT(e),n=[];return t.forEach((s,a)=>{const o=s.text.split(`
|
|
88
|
-
`);o.forEach((c,l)=>{n.push(Hs.createElement("span",{key:`${a}-${l}`,className:s.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},c)),l<o.length-1&&n.push(Hs.createElement("br",{key:`${a}-${l}-br`}))})}),n.length===1?n[0]:n}function TS({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return u.jsx("pre",{ref:t,className:n,children:e.length===0?u.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((s,a)=>u.jsx("span",{className:s.stream==="stderr"?"text-accent-warning":"",children:nu(s.content)},a))})}const NS=O.memo(function({title:t,logs:n,onClose:s,preClassName:a}){const o=O.useRef(null);return O.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[n]),u.jsx(Nt,{isOpen:!0,onClose:s,title:t,size:"full",children:u.jsx(TS,{logs:n,preRef:o,preClassName:a})})}),UT=O.memo(function({logs:t,anchorRef:n,isHiding:s,onExpand:a,onClose:o}){const[c,l]=O.useState(null),h=O.useRef(null);return O.useEffect(()=>{var p;const f=(p=n.current)==null?void 0:p.getBoundingClientRect();f&&l({bottom:window.innerHeight-f.bottom,right:window.innerWidth-f.right,width:f.width,height:f.height})},[n]),O.useEffect(()=>{h.current&&(h.current.scrollTop=h.current.scrollHeight)},[t]),c?u.jsxs("div",{className:"relative",children:[u.jsx("pre",{ref:h,className:"fixed z-50 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border overflow-auto transition-all duration-150 ease-out select-text",style:{bottom:c.bottom,right:c.right,width:c.width*2,maxHeight:c.height*3,transformOrigin:"bottom right",transform:s?"scale(0.01)":"scale(1)",opacity:s?0:1},children:t.map((f,p)=>u.jsx("span",{className:f.stream==="stderr"?"text-accent-warning":"",children:nu(f.content)},p))}),u.jsx("button",{onClick:()=>{o(),a()},className:"fixed z-50 px-2 py-1 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors duration-150",style:{bottom:c.bottom+8,right:c.right+8},children:"Expand"})]}):null}),FT=O.memo(function({workdir:t}){const n=Rr(F=>F.setWorkdir),s=Rr(F=>F.status),a=Rr(F=>F.config),o=Rr(F=>F.logs),c=Rr(F=>F.start),l=Rr(F=>F.stop),h=Rr(F=>F.fetchLogs),f=Ce(F=>F.currentSession),[p,m]=O.useState(!1),[x,_]=O.useState(!1),[w,k]=O.useState(!1),[v,b]=O.useState(!1),y=O.useRef(null),S=O.useRef(null),E=O.useRef(null),N=O.useRef(null),T=O.useRef(null),L=()=>{const F=s==null?void 0:s.inspectProxyPort;if(!F){s!=null&&s.url&&window.open(s.url,"_blank");return}const W=`${window.location.protocol}//${window.location.hostname}:${F}`,Y=window.open(W,"_blank");if(Y){T.current=Y;const P=()=>{var J;!T.current||T.current.closed||(T.current.postMessage({type:"setFoxSessionId",sessionId:(f==null?void 0:f.id)??null},"*"),T.current.postMessage({type:"setFoxSessionTitle",sessionTitle:((J=f==null?void 0:f.metadata)==null?void 0:J.title)??null},"*"),T.current.postMessage({type:"setFoxInspectEnabled",enabled:!(a!=null&&a.disableInspect)},"*"))},H=setInterval(()=>{P(),(!T.current||T.current.closed)&&clearInterval(H)},500);setTimeout(()=>clearInterval(H),5e3)}},A=(s==null?void 0:s.state)??"off",z=a!==null,R=A==="running"||A==="warning";O.useEffect(()=>{n(t??null)},[t,n]),O.useEffect(()=>{R&&h()},[R,h]),O.useEffect(()=>{E.current&&R&&(E.current.scrollTop=E.current.scrollHeight)},[o,R]);const $=()=>{R?l():c()};return u.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${A==="running"?"bg-accent-success":A==="warning"?"bg-accent-warning":A==="error"?"bg-accent-error":"bg-text-muted"}`}),u.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),u.jsx("button",{onClick:()=>m(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:u.jsx(sj,{})})]}),z?u.jsxs(u.Fragment,{children:[A==="running"||A==="warning"?u.jsxs("div",{className:"flex gap-2",children:[u.jsxs("button",{onClick:$,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[u.jsx(rS,{}),"Stop"]}),(s==null?void 0:s.url)&&u.jsxs("button",{onClick:()=>L(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:s.url,children:[u.jsx(oj,{}),"Open"]})]}):u.jsx("button",{onClick:$,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"}),R&&u.jsxs("div",{ref:N,className:"relative",onMouseEnter:()=>{S.current&&clearTimeout(S.current),y.current=setTimeout(()=>{k(!0),b(!1)},500)},onMouseLeave:()=>{y.current&&clearTimeout(y.current),b(!0),S.current=setTimeout(()=>k(!1),150)},children:[u.jsx(TS,{logs:o,preRef:E,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),(w||v)&&N.current&&Pa.createPortal(u.jsx(UT,{logs:o,anchorRef:N,isHiding:v,onExpand:()=>_(!0),onClose:()=>k(!1)}),document.body)]})]}):u.jsx("button",{onClick:()=>m(!0),className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),u.jsx(PT,{isOpen:p,onClose:()=>m(!1)}),x&&u.jsx(NS,{title:"Dev Server Logs",logs:o,onClose:()=>_(!1)})]})}),VT=O.memo(function({sessionId:t}){var _;const n=Yo(w=>w.processes),s=Yo(w=>w.stopProcess),[a,o]=O.useState(null),[c,l]=O.useState([]),h=n.filter(w=>w.status!=="exited"),f=h.filter(w=>w.status==="running").length;if(n.length===0)return null;const p=w=>{switch(w){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=w=>{const k=Yo.getState().logs[w]??[];l(k.map(v=>({content:v.content,stream:v.stream}))),o(w)},x=w=>{t&&s(w,t)};return u.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[u.jsx("div",{className:"flex items-center justify-between",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),u.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),u.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),u.jsx("div",{className:"space-y-2",children:h.map(w=>u.jsx("div",{className:"border border-border rounded p-2",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[u.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(w.status)}`}),u.jsx("span",{className:"text-sm text-text-primary truncate",title:w.name,children:w.name}),u.jsxs("span",{className:"text-xs text-text-muted",children:["[",w.status,"]"]})]}),u.jsxs("div",{className:"flex gap-1 ml-2",children:[u.jsx("button",{onClick:()=>m(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),u.jsx("button",{onClick:()=>x(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},w.id))}),a&&u.jsx(NS,{title:((_=h.find(w=>w.id===a))==null?void 0:_.name)??"",logs:c,onClose:()=>{o(null),l([])}})]})});function GT({isOpen:e,onClose:t,versionInfo:n}){const[s,a]=O.useState("ready"),[o,c]=O.useState(""),[l,h]=O.useState(n);O.useEffect(()=>{if(e){if(n){h(n);return}fetch("/api/auto-update/check").then(p=>p.json()).then(p=>h({current:p.current,latest:p.latest})).catch(()=>{})}},[e]),O.useEffect(()=>{if(!e||s!=="updating")return;const p=setInterval(()=>{c(m=>m.length>=3?"":m+".")},400);return()=>clearInterval(p)},[e,s]);const f=O.useCallback(async()=>{a("updating");const p=(l==null?void 0:l.current)==="1.0.0"&&(l==null?void 0:l.latest)==="1.1.0";if(await je("/api/auto-update",{method:"POST"}),p){setTimeout(()=>{a("reloading"),localStorage.setItem("openfox_updated_to",(l==null?void 0:l.latest)??"unknown"),localStorage.setItem("update_pending","true"),setTimeout(()=>window.location.reload(),1e3)},5e3);return}let m=!1,x=!1;const _=setInterval(async()=>{try{(await fetch("/api/health")).ok&&m&&(x=!0,clearInterval(_),a("reloading"),localStorage.setItem("openfox_updated_to",(l==null?void 0:l.latest)??"unknown"),localStorage.setItem("update_pending","true"),window.location.reload())}catch{m=!0}},2e3);setTimeout(()=>{x||clearInterval(_)},3e5)},[l==null?void 0:l.current,l==null?void 0:l.latest]);return O.useEffect(()=>{e&&(a("ready"),c(""))},[e]),u.jsxs(Nt,{isOpen:e,onClose:s==="updating"?void 0:t,title:"New OpenFox Version Available",size:"sm",closeOnBackdropClick:s!=="updating",showCloseButton:s!=="updating",children:[u.jsxs("div",{className:"flex flex-col gap-4",children:[l&&u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Current version"}),u.jsx("span",{className:"text-text-primary font-mono",children:l.current})]}),l&&u.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Latest version"}),u.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:l.latest})]}),s==="updating"&&u.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[u.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:u.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),u.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Updating",o]})]}),s==="reloading"&&u.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[u.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:u.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),u.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Update complete, reloading",o]})]})]}),s==="ready"&&u.jsx("button",{onClick:f,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),s==="ready"&&u.jsx("div",{className:"flex justify-center mt-2",children:u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[u.jsx("span",{children:"⚠️"}),u.jsx("p",{className:"text-text-secondary",children:"Server will restart to apply this update. Sessions in progress will be interrupted."})]})})]})}function WT({file:e}){const t=SS(e.path,28),n=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",s=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"";return u.jsxs("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:[u.jsx("span",{className:`truncate ${n}`,title:e.path,children:t}),s&&u.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:s})]})}function qT(){const{diff:e}=ES();return e.loading?u.jsx("div",{className:"mt-3",children:u.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[u.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),u.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?u.jsx("div",{className:"mt-3",children:u.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):u.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:u.jsx("div",{className:"pr-1",children:e.files.map((t,n)=>u.jsx(WT,{file:t},n))})})}function $v({summary:e,messages:t,workdir:n}){const[s,a]=O.useState(!1),[o,c]=O.useState(!1),[l,h]=O.useState(!1),[f,p]=O.useState(!1),m=vT(t),{branch:x}=ES(),_=Dt(v=>v.version),w=Ce(v=>v.currentSession),k=O.useCallback(async()=>{c(!0);try{const v=await fetch("/api/auto-update/check");if(v.ok){const b=await v.json();h(b.isUpdateAvailable)}}catch{}finally{c(!1)}},[]);return O.useEffect(()=>{k()},[k]),O.useEffect(()=>{if(new URLSearchParams(window.location.search).get("test-update")==="1"){h(!0),p(!0);const b=new URL(window.location.href);b.searchParams.delete("test-update"),window.history.replaceState({},"",b.toString())}},[]),u.jsxs("div",{className:"flex flex-col h-full",children:[m&&u.jsxs("div",{className:"mb-4",children:[u.jsx("button",{onClick:()=>a(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:u.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[u.jsx("span",{className:"text-text-secondary",children:bT(m.aiTime)}),u.jsx("span",{className:"w-px h-3 bg-border"}),u.jsx("span",{className:"text-text-secondary",children:Mv(m.avgPrefillSpeed)}),u.jsx("span",{children:"pp"}),u.jsx("span",{className:"w-px h-3 bg-border"}),u.jsx("span",{className:"text-text-secondary",children:Mv(m.avgGenerationSpeed)}),u.jsx("span",{children:"tg"})]})}),u.jsx(DT,{isOpen:s,onClose:()=>a(!1),stats:m})]}),u.jsxs("div",{className:"flex flex-col flex-1 overflow-y-auto",children:[u.jsx("div",{className:"flex items-center justify-between mb-2",children:u.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Summary"})}),e?u.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e}):u.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No summary yet"}),u.jsxs("div",{className:"mt-4",children:[u.jsx("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Progress"}),u.jsx(IT,{criteria:(w==null?void 0:w.criteria)??[]})]})]}),x&&u.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[u.jsx(Z2,{}),u.jsx("span",{className:"truncate text-text-secondary",title:x,children:x})]}),u.jsx(qT,{}),u.jsx(FT,{workdir:n}),u.jsx(VT,{sessionId:w==null?void 0:w.id}),_&&u.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[u.jsxs("div",{className:"flex items-center justify-center gap-1",children:[u.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",u.jsxs("span",{className:"font-mono",children:["v",_]}),u.jsx("button",{onClick:()=>k(),disabled:o,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:u.jsx(Zm,{className:`w-3 h-3 ${o?"animate-spin":""}`})})]}),l&&u.jsx("button",{onClick:()=>p(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"})]}),u.jsx(GT,{isOpen:f,onClose:()=>p(!1),versionInfo:null})]})}function KT({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:s}){const a=Ce(o=>o.currentSession);return u.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&u.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),u.jsxs("div",{className:"flex h-full",children:[u.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?u.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary",children:u.jsx($v,{summary:(a==null?void 0:a.summary)??null,messages:s,workdir:a==null?void 0:a.workdir})}):u.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),u.jsx("aside",{className:`
|
|
88
|
+
`);o.forEach((c,l)=>{n.push(Hs.createElement("span",{key:`${a}-${l}`,className:s.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},c)),l<o.length-1&&n.push(Hs.createElement("br",{key:`${a}-${l}-br`}))})}),n.length===1?n[0]:n}function TS({logs:e,preRef:t,preClassName:n="text-sm font-mono"}){return u.jsx("pre",{ref:t,className:n,children:e.length===0?u.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((s,a)=>u.jsx("span",{className:s.stream==="stderr"?"text-accent-warning":"",children:nu(s.content)},a))})}const NS=O.memo(function({title:t,logs:n,onClose:s,preClassName:a}){const o=O.useRef(null);return O.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[n]),u.jsx(Nt,{isOpen:!0,onClose:s,title:t,size:"full",children:u.jsx(TS,{logs:n,preRef:o,preClassName:a})})}),UT=O.memo(function({logs:t,anchorRef:n,isHiding:s,onExpand:a,onClose:o}){const[c,l]=O.useState(null),h=O.useRef(null);return O.useEffect(()=>{var p;const f=(p=n.current)==null?void 0:p.getBoundingClientRect();f&&l({bottom:window.innerHeight-f.bottom,right:window.innerWidth-f.right,width:f.width,height:f.height})},[n]),O.useEffect(()=>{h.current&&(h.current.scrollTop=h.current.scrollHeight)},[t]),c?u.jsxs("div",{className:"relative",children:[u.jsx("pre",{ref:h,className:"fixed z-50 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border overflow-auto transition-all duration-150 ease-out select-text",style:{bottom:c.bottom,right:c.right,width:c.width*2,maxHeight:c.height*3,transformOrigin:"bottom right",transform:s?"scale(0.01)":"scale(1)",opacity:s?0:1},children:t.map((f,p)=>u.jsx("span",{className:f.stream==="stderr"?"text-accent-warning":"",children:nu(f.content)},p))}),u.jsx("button",{onClick:()=>{o(),a()},className:"fixed z-50 px-2 py-1 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors duration-150",style:{bottom:c.bottom+8,right:c.right+8},children:"Expand"})]}):null}),FT=O.memo(function({workdir:t}){const n=Rr(F=>F.setWorkdir),s=Rr(F=>F.status),a=Rr(F=>F.config),o=Rr(F=>F.logs),c=Rr(F=>F.start),l=Rr(F=>F.stop),h=Rr(F=>F.fetchLogs),f=Ce(F=>F.currentSession),[p,m]=O.useState(!1),[x,_]=O.useState(!1),[w,k]=O.useState(!1),[v,b]=O.useState(!1),y=O.useRef(null),S=O.useRef(null),E=O.useRef(null),N=O.useRef(null),T=O.useRef(null),L=()=>{const F=s==null?void 0:s.inspectProxyPort;if(!F){s!=null&&s.url&&window.open(s.url,"_blank");return}const W=`${window.location.protocol}//${window.location.hostname}:${F}`,Y=window.open(W,"_blank");if(Y){T.current=Y;const P=()=>{var J;!T.current||T.current.closed||(T.current.postMessage({type:"setFoxSessionId",sessionId:(f==null?void 0:f.id)??null},"*"),T.current.postMessage({type:"setFoxSessionTitle",sessionTitle:((J=f==null?void 0:f.metadata)==null?void 0:J.title)??null},"*"),T.current.postMessage({type:"setFoxInspectEnabled",enabled:!(a!=null&&a.disableInspect)},"*"))},H=setInterval(()=>{P(),(!T.current||T.current.closed)&&clearInterval(H)},500);setTimeout(()=>clearInterval(H),5e3)}},A=(s==null?void 0:s.state)??"off",z=a!==null,R=A==="running"||A==="warning";O.useEffect(()=>{n(t??null)},[t,n]),O.useEffect(()=>{R&&h()},[R,h]),O.useEffect(()=>{E.current&&R&&(E.current.scrollTop=E.current.scrollHeight)},[o,R]);const $=()=>{R?l():c()};return u.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${A==="running"?"bg-accent-success":A==="warning"?"bg-accent-warning":A==="error"?"bg-accent-error":"bg-text-muted"}`}),u.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),u.jsx("button",{onClick:()=>m(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:u.jsx(sj,{})})]}),z?u.jsxs(u.Fragment,{children:[A==="running"||A==="warning"?u.jsxs("div",{className:"flex gap-2",children:[u.jsxs("button",{onClick:$,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[u.jsx(rS,{}),"Stop"]}),(s==null?void 0:s.url)&&u.jsxs("button",{onClick:()=>L(),className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",title:s.url,children:[u.jsx(oj,{}),"Open"]})]}):u.jsx("button",{onClick:$,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"}),R&&u.jsxs("div",{ref:N,className:"relative",onMouseEnter:()=>{S.current&&clearTimeout(S.current),y.current=setTimeout(()=>{k(!0),b(!1)},500)},onMouseLeave:()=>{y.current&&clearTimeout(y.current),b(!0),S.current=setTimeout(()=>k(!1),150)},children:[u.jsx(TS,{logs:o,preRef:E,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),(w||v)&&N.current&&Pa.createPortal(u.jsx(UT,{logs:o,anchorRef:N,isHiding:v,onExpand:()=>_(!0),onClose:()=>k(!1)}),document.body)]})]}):u.jsx("button",{onClick:()=>m(!0),className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),u.jsx(PT,{isOpen:p,onClose:()=>m(!1)}),x&&u.jsx(NS,{title:"Dev Server Logs",logs:o,onClose:()=>_(!1)})]})}),VT=O.memo(function({sessionId:t}){var _;const n=Yo(w=>w.processes),s=Yo(w=>w.stopProcess),[a,o]=O.useState(null),[c,l]=O.useState([]),h=n.filter(w=>w.status!=="exited"),f=h.filter(w=>w.status==="running").length;if(n.length===0)return null;const p=w=>{switch(w){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=w=>{const k=Yo.getState().logs[w]??[];l(k.map(v=>({content:v.content,stream:v.stream}))),o(w)},x=w=>{t&&s(w,t)};return u.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[u.jsx("div",{className:"flex items-center justify-between",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),u.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),u.jsxs("span",{className:"text-xs text-text-muted",children:["(",f," running)"]})]})}),u.jsx("div",{className:"space-y-2",children:h.map(w=>u.jsx("div",{className:"border border-border rounded p-2",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[u.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(w.status)}`}),u.jsx("span",{className:"text-sm text-text-primary truncate",title:w.name,children:w.name}),u.jsxs("span",{className:"text-xs text-text-muted",children:["[",w.status,"]"]})]}),u.jsxs("div",{className:"flex gap-1 ml-2",children:[u.jsx("button",{onClick:()=>m(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),u.jsx("button",{onClick:()=>x(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-accent-error/20 text-text-secondary hover:text-accent-error transition-colors",title:"Stop process",children:"Stop"})]})]})},w.id))}),a&&u.jsx(NS,{title:((_=h.find(w=>w.id===a))==null?void 0:_.name)??"",logs:c,onClose:()=>{o(null),l([])}})]})});function GT({isOpen:e,onClose:t,versionInfo:n}){const[s,a]=O.useState("ready"),[o,c]=O.useState("waiting"),[l,h]=O.useState(""),[f,p]=O.useState(n),m=O.useRef(!1);O.useEffect(()=>{if(e){if(n){p(n);return}fetch("/api/auto-update/check").then(w=>w.json()).then(w=>p({current:w.current,latest:w.latest})).catch(()=>{})}},[e]),O.useEffect(()=>{if(!e||s!=="updating")return;const w=setInterval(()=>{h(k=>k.length>=3?"":k+".")},400);return()=>clearInterval(w)},[e,s]);const x=O.useCallback(async()=>{a("updating"),c("waiting"),m.current=!1;const w=(f==null?void 0:f.current)==="1.0.0"&&(f==null?void 0:f.latest)==="1.1.0";if(await je("/api/auto-update",{method:"POST"}),w){setTimeout(()=>{a("reloading"),localStorage.setItem("openfox_updated_to",(f==null?void 0:f.latest)??"unknown"),localStorage.setItem("update_pending","true"),setTimeout(()=>window.location.reload(),1e3)},5e3);return}let k=!1;const v=setInterval(async()=>{try{(await fetch("/api/health")).ok&&m.current&&(k=!0,clearInterval(v),a("reloading"),localStorage.setItem("openfox_updated_to",(f==null?void 0:f.latest)??"unknown"),localStorage.setItem("update_pending","true"),window.location.reload())}catch{m.current=!0}},2e3);setTimeout(()=>{k||c("takingLonger")},6e4),setTimeout(()=>{k||(clearInterval(v),a("failed"))},12e4)},[f==null?void 0:f.current,f==null?void 0:f.latest]);O.useEffect(()=>{e&&(a("ready"),c("waiting"),h(""),m.current=!1)},[e]);const _=s!=="updating";return u.jsxs(Nt,{isOpen:e,onClose:_?t:void 0,title:s==="failed"?"Update Failed":"New OpenFox Version Available",size:"sm",closeOnBackdropClick:_,showCloseButton:_,children:[u.jsxs("div",{className:"flex flex-col gap-4",children:[f&&u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-text-muted",children:"Current version"}),u.jsx("span",{className:"text-text-primary font-mono",children:f.current})]}),f&&u.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[u.jsx("span",{className:"text-text-muted",children:"Latest version"}),u.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:f.latest})]}),s==="updating"&&u.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[u.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:u.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),u.jsx("p",{className:"text-xs text-text-muted text-center",children:o==="takingLonger"?"Taking longer than expected…":`Updating${l}`})]}),s==="reloading"&&u.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[u.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:u.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),u.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Update complete, reloading",l]})]}),s==="failed"&&u.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[u.jsx("span",{children:"⚠️"}),u.jsx("p",{className:"text-text-secondary",children:"The update timed out. The server may need to be updated manually."})]}),u.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),u.jsxs("p",{className:"text-xs text-text-muted",children:["Run this command in your terminal to complete the update, then start the service with"," ",u.jsx("span",{className:"font-mono text-text-secondary",children:"openfox service start"}),"."]})]})]}),s==="ready"&&u.jsx("button",{onClick:x,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),s==="failed"&&u.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"}),s==="ready"&&u.jsx("div",{className:"flex justify-center mt-2",children:u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-warning/10 border border-accent-warning/30 rounded text-xs",children:[u.jsx("span",{children:"⚠️"}),u.jsx("p",{className:"text-text-secondary",children:"Server will restart to apply this update. Sessions in progress will be interrupted."})]})})]})}function WT({file:e}){const t=SS(e.path,28),n=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",s=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"";return u.jsxs("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:[u.jsx("span",{className:`truncate ${n}`,title:e.path,children:t}),s&&u.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:s})]})}function qT(){const{diff:e}=ES();return e.loading?u.jsx("div",{className:"mt-3",children:u.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[u.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),u.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?u.jsx("div",{className:"mt-3",children:u.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):u.jsx("div",{className:"mt-3 max-h-[150px] overflow-y-auto",children:u.jsx("div",{className:"pr-1",children:e.files.map((t,n)=>u.jsx(WT,{file:t},n))})})}function $v({summary:e,messages:t,workdir:n}){const[s,a]=O.useState(!1),[o,c]=O.useState(!1),[l,h]=O.useState(!1),[f,p]=O.useState(!1),m=vT(t),{branch:x}=ES(),_=Dt(v=>v.version),w=Ce(v=>v.currentSession),k=O.useCallback(async()=>{c(!0);try{const v=await fetch("/api/auto-update/check");if(v.ok){const b=await v.json();h(b.isUpdateAvailable)}}catch{}finally{c(!1)}},[]);return O.useEffect(()=>{k()},[k]),O.useEffect(()=>{if(new URLSearchParams(window.location.search).get("test-update")==="1"){h(!0),p(!0);const b=new URL(window.location.href);b.searchParams.delete("test-update"),window.history.replaceState({},"",b.toString())}},[]),u.jsxs("div",{className:"flex flex-col h-full",children:[m&&u.jsxs("div",{className:"mb-4",children:[u.jsx("button",{onClick:()=>a(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:u.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[u.jsx("span",{className:"text-text-secondary",children:bT(m.aiTime)}),u.jsx("span",{className:"w-px h-3 bg-border"}),u.jsx("span",{className:"text-text-secondary",children:Mv(m.avgPrefillSpeed)}),u.jsx("span",{children:"pp"}),u.jsx("span",{className:"w-px h-3 bg-border"}),u.jsx("span",{className:"text-text-secondary",children:Mv(m.avgGenerationSpeed)}),u.jsx("span",{children:"tg"})]})}),u.jsx(DT,{isOpen:s,onClose:()=>a(!1),stats:m})]}),u.jsxs("div",{className:"flex flex-col flex-1 overflow-y-auto",children:[u.jsx("div",{className:"flex items-center justify-between mb-2",children:u.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Summary"})}),e?u.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:e}):u.jsx("div",{className:"text-text-muted text-sm text-center py-2",children:"No summary yet"}),u.jsxs("div",{className:"mt-4",children:[u.jsx("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Progress"}),u.jsx(IT,{criteria:(w==null?void 0:w.criteria)??[]})]})]}),x&&u.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[u.jsx(Z2,{}),u.jsx("span",{className:"truncate text-text-secondary",title:x,children:x})]}),u.jsx(qT,{}),u.jsx(FT,{workdir:n}),u.jsx(VT,{sessionId:w==null?void 0:w.id}),_&&u.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[u.jsxs("div",{className:"flex items-center justify-center gap-1",children:[u.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",u.jsxs("span",{className:"font-mono",children:["v",_]}),u.jsx("button",{onClick:()=>k(),disabled:o,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:u.jsx(Zm,{className:`w-3 h-3 ${o?"animate-spin":""}`})})]}),l&&u.jsx("button",{onClick:()=>p(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"})]}),u.jsx(GT,{isOpen:f,onClose:()=>p(!1),versionInfo:null})]})}function KT({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:s}){const a=Ce(o=>o.currentSession);return u.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&u.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),u.jsxs("div",{className:"flex h-full",children:[u.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?u.jsx("aside",{className:"hidden md:block w-[320px] shrink-0 border-l border-border p-4 overflow-y-auto bg-secondary",children:u.jsx($v,{summary:(a==null?void 0:a.summary)??null,messages:s,workdir:a==null?void 0:a.workdir})}):u.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),u.jsx("aside",{className:`
|
|
89
89
|
md:hidden
|
|
90
90
|
p-4 overflow-y-auto bg-secondary
|
|
91
91
|
transition-all duration-300 ease-in-out
|
package/dist/web/index.html
CHANGED
|
@@ -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-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-BEkw-EHs.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-D3nUB0zb.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 s,l={};const e=(e,r)=>(e=new URL(e+".js",r).href,l[e]||new Promise(l=>{if("document"in self){const s=document.createElement("script");s.src=e,s.onload=l,document.head.appendChild(s)}else s=e,importScripts(e),l()}).then(()=>{let s=l[e];if(!s)throw new Error(`Module ${e} didn’t register its module`);return s}));self.define=(r,i)=>{const n=s||("document"in self?document.currentScript.src:"")||location.href;if(l[n])return;let u={};const a=s=>e(s,n),t={module:{uri:n},exports:u,require:a};l[n]=Promise.all(r.map(s=>t[s]||a(s))).then(s=>(i(...s),u))}}define(["./workbox-8c29f6e4"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"f56e37509bb3bfaf3b55d341f32b2b24"},{url:"__inspect__.js",revision:"878b477aaf1805c028895f3d3bb4af71"},{url:"assets/zig-VOosw3JB.js",revision:null},{url:"assets/zenscript-DVFEvuxE.js",revision:null},{url:"assets/yaml-Buea-lGh.js",revision:null},{url:"assets/xsl-CtQFsRM5.js",revision:null},{url:"assets/xml-sdJ4AIDG.js",revision:null},{url:"assets/wolfram-lXgVvXCa.js",revision:null},{url:"assets/wit-5i3qLPDT.js",revision:null},{url:"assets/wikitext-BhOHFoWU.js",revision:null},{url:"assets/wgsl-Dx-B1_4e.js",revision:null},{url:"assets/wenyan-BV7otONQ.js",revision:null},{url:"assets/wasm-MzD3tlZU.js",revision:null},{url:"assets/wasm-CG6Dc4jp.js",revision:null},{url:"assets/vyper-CDx5xZoG.js",revision:null},{url:"assets/vue-vine-BoDAl6tE.js",revision:null},{url:"assets/vue-html-AaS7Mt5G.js",revision:null},{url:"assets/vue-D2xRrEX4.js",revision:null},{url:"assets/vitesse-light-CVO1_9PV.js",revision:null},{url:"assets/vitesse-dark-D0r3Knsf.js",revision:null},{url:"assets/vitesse-black-Bkuqu6BP.js",revision:null},{url:"assets/viml-CJc9bBzg.js",revision:null},{url:"assets/vhdl-CeAyd5Ju.js",revision:null},{url:"assets/vesper-DRje8inN.js",revision:null},{url:"assets/verilog-BQ8w6xss.js",revision:null},{url:"assets/vb-D17OF-Vu.js",revision:null},{url:"assets/vala-CsfeWuGM.js",revision:null},{url:"assets/v-BcVCzyr7.js",revision:null},{url:"assets/typst-DHCkPAjA.js",revision:null},{url:"assets/typespec-CAFt9gP4.js",revision:null},{url:"assets/typescript-BPQ3VLAy.js",revision:null},{url:"assets/twig-CW1WmMYd.js",revision:null},{url:"assets/turtle-BsS91CYL.js",revision:null},{url:"assets/tsx-COt5Ahok.js",revision:null},{url:"assets/tsv-B_m7g4N7.js",revision:null},{url:"assets/ts-tags-D351s5mN.js",revision:null},{url:"assets/toml-vGWfd6FD.js",revision:null},{url:"assets/tokyo-night-hegEt444.js",revision:null},{url:"assets/tex-idrVyKtj.js",revision:null},{url:"assets/terraform-BETggiCN.js",revision:null},{url:"assets/templ-DhtptRzy.js",revision:null},{url:"assets/tcl-dwOrl1Do.js",revision:null},{url:"assets/tasl-QIJgUcNo.js",revision:null},{url:"assets/talonscript-CkByrt1z.js",revision:null},{url:"assets/systemd-4A_iFExJ.js",revision:null},{url:"assets/system-verilog-CnnmHF94.js",revision:null},{url:"assets/synthwave-84-CbfX1IO0.js",revision:null},{url:"assets/swift-D82vCrfD.js",revision:null},{url:"assets/svelte-Cy7k_4gC.js",revision:null},{url:"assets/surrealql-Bq5Q-fJD.js",revision:null},{url:"assets/stylus-BEDo0Tqx.js",revision:null},{url:"assets/stata-DI20mbqo.js",revision:null},{url:"assets/ssh-config-_ykCGR6B.js",revision:null},{url:"assets/sql-CRqJ_cUM.js",revision:null},{url:"assets/splunk-BtCnVYZw.js",revision:null},{url:"assets/sparql-rVzFXLq3.js",revision:null},{url:"assets/soy-8wufbnw4.js",revision:null},{url:"assets/solidity-rGO070M0.js",revision:null},{url:"assets/solarized-light-L9t79GZl.js",revision:null},{url:"assets/solarized-dark-DXbdFlpD.js",revision:null},{url:"assets/snazzy-light-Bw305WKR.js",revision:null},{url:"assets/smalltalk-BERRCDM3.js",revision:null},{url:"assets/slack-ochin-DqwNpetd.js",revision:null},{url:"assets/slack-dark-BthQWCQV.js",revision:null},{url:"assets/shellsession-BADoaaVG.js",revision:null},{url:"assets/shellscript-Yzrsuije.js",revision:null},{url:"assets/shaderlab-Dg9Lc6iA.js",revision:null},{url:"assets/sdbl-DVxCFoDh.js",revision:null},{url:"assets/scss-D5BDwBP9.js",revision:null},{url:"assets/scheme-C98Dy4si.js",revision:null},{url:"assets/scala-C151Ov-r.js",revision:null},{url:"assets/sass-Cj5Yp3dK.js",revision:null},{url:"assets/sas-DEy46yEz.js",revision:null},{url:"assets/rust-B1yitclQ.js",revision:null},{url:"assets/ruby-DyJCeAvU.js",revision:null},{url:"assets/rst-CpCqk9r5.js",revision:null},{url:"assets/rosmsg-BJDFO7_C.js",revision:null},{url:"assets/rose-pine-qdsjHGoJ.js",revision:null},{url:"assets/rose-pine-moon-D4_iv3hh.js",revision:null},{url:"assets/rose-pine-dawn-DHQR4-dF.js",revision:null},{url:"assets/ron-D8l8udqQ.js",revision:null},{url:"assets/riscv-BM1_JUlF.js",revision:null},{url:"assets/rel-C3B-1QV4.js",revision:null},{url:"assets/regexp-CDVJQ6XC.js",revision:null},{url:"assets/reg-C-SQnVFl.js",revision:null},{url:"assets/red-bN70gL4F.js",revision:null},{url:"assets/razor-BjBPvh-w.js",revision:null},{url:"assets/raku-DXvB9xmW.js",revision:null},{url:"assets/racket-BqYA7rlc.js",revision:null},{url:"assets/r-Dspwwk_N.js",revision:null},{url:"assets/qss-IeuSbFQv.js",revision:null},{url:"assets/qmldir-C8lEn-DE.js",revision:null},{url:"assets/qml-3beO22l8.js",revision:null},{url:"assets/python-B6aJPvgy.js",revision:null},{url:"assets/purescript-CklMAg4u.js",revision:null},{url:"assets/puppet-BMWR74SV.js",revision:null},{url:"assets/pug-DKIMFp6K.js",revision:null},{url:"assets/proto-C7zT0LnQ.js",revision:null},{url:"assets/prolog-CbFg5uaA.js",revision:null},{url:"assets/prisma-Dd19v3D-.js",revision:null},{url:"assets/powershell-Dpen1YoG.js",revision:null},{url:"assets/powerquery-CEu0bR-o.js",revision:null},{url:"assets/postcss-CXtECtnM.js",revision:null},{url:"assets/polar-C0HS_06l.js",revision:null},{url:"assets/poimandres-CS3Unz2-.js",revision:null},{url:"assets/po-BTJTHyun.js",revision:null},{url:"assets/plsql-ChMvpjG-.js",revision:null},{url:"assets/plastic-3e1v2bzS.js",revision:null},{url:"assets/pkl-u5AG7uiY.js",revision:null},{url:"assets/php-Csjmro_R.js",revision:null},{url:"assets/perl-B9cMNwum.js",revision:null},{url:"assets/pascal-D93ZcfNL.js",revision:null},{url:"assets/openscad-C4EeE6gA.js",revision:null},{url:"assets/one-light-C3Wv6jpd.js",revision:null},{url:"assets/one-dark-pro-DVMEJ2y_.js",revision:null},{url:"assets/odin-BBf5iR-q.js",revision:null},{url:"assets/ocaml-C0hk2d4L.js",revision:null},{url:"assets/objective-cpp-CLxacb5B.js",revision:null},{url:"assets/objective-c-DXmwc3jG.js",revision:null},{url:"assets/nushell-Cz2AlsmD.js",revision:null},{url:"assets/nord-Ddv68eIx.js",revision:null},{url:"assets/nix-CwoSXNpI.js",revision:null},{url:"assets/nim-BIad80T-.js",revision:null},{url:"assets/night-owl-light-CMTm3GFP.js",revision:null},{url:"assets/night-owl-C39BiMTA.js",revision:null},{url:"assets/nginx-BpAMiNFr.js",revision:null},{url:"assets/nextflow-groovy-vE_lwT2v.js",revision:null},{url:"assets/nextflow-C-mBbutL.js",revision:null},{url:"assets/narrat-DRg8JJMk.js",revision:null},{url:"assets/move-IF9eRakj.js",revision:null},{url:"assets/moonbit-_H4v1dQx.js",revision:null},{url:"assets/monokai-D4h5O-jR.js",revision:null},{url:"assets/mojo-rZm6bMo-.js",revision:null},{url:"assets/mipsasm-CKIfxQSi.js",revision:null},{url:"assets/min-light-CTRr51gU.js",revision:null},{url:"assets/min-dark-CafNBF8u.js",revision:null},{url:"assets/mermaid-mWjccvbQ.js",revision:null},{url:"assets/mdx-Cmh6b_Ma.js",revision:null},{url:"assets/mdc-DTYItulj.js",revision:null},{url:"assets/matlab-D7o27uSR.js",revision:null},{url:"assets/material-theme-palenight-Csfq5Kiy.js",revision:null},{url:"assets/material-theme-ocean-CyktbL80.js",revision:null},{url:"assets/material-theme-lighter-B0m2ddpp.js",revision:null},{url:"assets/material-theme-darker-BfHTSMKl.js",revision:null},{url:"assets/material-theme-D5KoaKCx.js",revision:null},{url:"assets/marko-DjSrsDqO.js",revision:null},{url:"assets/markdown-Cvjx9yec.js",revision:null},{url:"assets/make-CHLpvVh8.js",revision:null},{url:"assets/luau-KW6xsasC.js",revision:null},{url:"assets/lua-BaeVxFsk.js",revision:null},{url:"assets/logo-BtOb2qkB.js",revision:null},{url:"assets/log-2UxHyX5q.js",revision:null},{url:"assets/llvm-DjAJT7YJ.js",revision:null},{url:"assets/liquid-C0sCDyMI.js",revision:null},{url:"assets/light-plus-B7mTdjB0.js",revision:null},{url:"assets/less-B1dDrJ26.js",revision:null},{url:"assets/lean-BZvkOJ9d.js",revision:null},{url:"assets/latex-CaSxy8MP.js",revision:null},{url:"assets/laserwave-DUszq2jm.js",revision:null},{url:"assets/kusto-wEQ09or8.js",revision:null},{url:"assets/kotlin-BdnUsdx6.js",revision:null},{url:"assets/kdl-DV7GczEv.js",revision:null},{url:"assets/kanagawa-wave-DWedfzmr.js",revision:null},{url:"assets/kanagawa-lotus-CfQXZHmo.js",revision:null},{url:"assets/kanagawa-dragon-CkXjmgJE.js",revision:null},{url:"assets/just-CUsbIsdP.js",revision:null},{url:"assets/julia-D7OTSIA_.js",revision:null},{url:"assets/jsx-g9-lgVsj.js",revision:null},{url:"assets/jssm-C2t-YnRu.js",revision:null},{url:"assets/jsonnet-DFQXde-d.js",revision:null},{url:"assets/jsonl-DcaNXYhu.js",revision:null},{url:"assets/jsonc-Des-eS-w.js",revision:null},{url:"assets/json5-C9tS-k6U.js",revision:null},{url:"assets/json-Cp-IABpG.js",revision:null},{url:"assets/jison-wvAkD_A8.js",revision:null},{url:"assets/jinja-f2NsQr07.js",revision:null},{url:"assets/javascript-wDzz0qaB.js",revision:null},{url:"assets/java-CylS5w8V.js",revision:null},{url:"assets/ini-BEwlwnbL.js",revision:null},{url:"assets/index-D3nUB0zb.css",revision:null},{url:"assets/index-BhmZRmbE.js",revision:null},{url:"assets/imba-DGztddWO.js",revision:null},{url:"assets/hy-DFXneXwc.js",revision:null},{url:"assets/hxml-Bvhsp5Yf.js",revision:null},{url:"assets/hurl-irOxFIW8.js",revision:null},{url:"assets/http-jrhK8wxY.js",revision:null},{url:"assets/html2canvas.esm-QH1iLAAe.js",revision:null},{url:"assets/html-pp8916En.js",revision:null},{url:"assets/html-derivative-DlHx6ybY.js",revision:null},{url:"assets/houston-DnULxvSX.js",revision:null},{url:"assets/horizon-bright-CUuTKBJd.js",revision:null},{url:"assets/horizon-BUw7H-hv.js",revision:null},{url:"assets/hlsl-D3lLCCz7.js",revision:null},{url:"assets/hjson-D5-asLiD.js",revision:null},{url:"assets/hcl-BWvSN4gD.js",revision:null},{url:"assets/haxe-CzTSHFRz.js",revision:null},{url:"assets/haskell-Df6bDoY_.js",revision:null},{url:"assets/handlebars-BpdQsYii.js",revision:null},{url:"assets/haml-D5jkg6IW.js",revision:null},{url:"assets/hack-DbPARsA_.js",revision:null},{url:"assets/gruvbox-light-soft-hJgmCMqR.js",revision:null},{url:"assets/gruvbox-light-medium-DRw_LuNl.js",revision:null},{url:"assets/gruvbox-light-hard-CH1njM8p.js",revision:null},{url:"assets/gruvbox-dark-soft-CVdnzihN.js",revision:null},{url:"assets/gruvbox-dark-medium-GsRaNv29.js",revision:null},{url:"assets/gruvbox-dark-hard-CFHQjOhq.js",revision:null},{url:"assets/groovy-gcz8RCvz.js",revision:null},{url:"assets/graphql-ChdNCCLP.js",revision:null},{url:"assets/go-C27-OAKa.js",revision:null},{url:"assets/gnuplot-DdkO51Og.js",revision:null},{url:"assets/gn-n2N0HUVH.js",revision:null},{url:"assets/glsl-DplSGwfg.js",revision:null},{url:"assets/glimmer-ts-BfAWNZQY.js",revision:null},{url:"assets/glimmer-js-ByusRIyA.js",revision:null},{url:"assets/gleam-BspZqrRM.js",revision:null},{url:"assets/github-light-high-contrast-BfjtVDDH.js",revision:null},{url:"assets/github-light-default-D7oLnXFd.js",revision:null},{url:"assets/github-light-DAi9KRSo.js",revision:null},{url:"assets/github-dark-high-contrast-E3gJ1_iC.js",revision:null},{url:"assets/github-dark-dimmed-DH5Ifo-i.js",revision:null},{url:"assets/github-dark-default-Cuk6v7N8.js",revision:null},{url:"assets/github-dark-DHJKELXO.js",revision:null},{url:"assets/git-rebase-r7XF79zn.js",revision:null},{url:"assets/git-commit-F4YmCXRG.js",revision:null},{url:"assets/gherkin-DyxjwDmM.js",revision:null},{url:"assets/genie-D0YGMca9.js",revision:null},{url:"assets/gdshader-DkwncUOv.js",revision:null},{url:"assets/gdscript-C5YyOfLZ.js",revision:null},{url:"assets/gdresource-BOOCDP_w.js",revision:null},{url:"assets/fsharp-CXgrBDvD.js",revision:null},{url:"assets/fortran-free-form-BxgE0vQu.js",revision:null},{url:"assets/fortran-fixed-form-CkoXwp7k.js",revision:null},{url:"assets/fluent-C4IJs8-o.js",revision:null},{url:"assets/fish-BvzEVeQv.js",revision:null},{url:"assets/fennel-BYunw83y.js",revision:null},{url:"assets/everforest-light-C8M2exoo.js",revision:null},{url:"assets/everforest-dark-BgDCqdQA.js",revision:null},{url:"assets/erlang-DsQrWhSR.js",revision:null},{url:"assets/erb-Dm6A9KJ5.js",revision:null},{url:"assets/emacs-lisp-CXvaQtF9.js",revision:null},{url:"assets/elm-DbKCFpqz.js",revision:null},{url:"assets/elixir-CkH2-t6x.js",revision:null},{url:"assets/edge-FbVlp4U3.js",revision:null},{url:"assets/dream-maker-BtqSS_iP.js",revision:null},{url:"assets/dracula-soft-BXkSAIEj.js",revision:null},{url:"assets/dracula-BzJJZx-M.js",revision:null},{url:"assets/dotenv-Da5cRb03.js",revision:null},{url:"assets/docker-BcOcwvcX.js",revision:null},{url:"assets/diff-D97Zzqfu.js",revision:null},{url:"assets/desktop-BmXAJ9_W.js",revision:null},{url:"assets/dax-CEL-wOlO.js",revision:null},{url:"assets/dart-bE4Kk8sk.js",revision:null},{url:"assets/dark-plus-C3mMm8J8.js",revision:null},{url:"assets/d-85-TOEBH.js",revision:null},{url:"assets/cypher-COkxafJQ.js",revision:null},{url:"assets/cue-D82EKSYY.js",revision:null},{url:"assets/csv-fuZLfV_i.js",revision:null},{url:"assets/css-CLj8gQPS.js",revision:null},{url:"assets/csharp-DSvCPggb.js",revision:null},{url:"assets/crystal-DGywbUpC.js",revision:null},{url:"assets/cpp-UfJy6YNI.js",revision:null},{url:"assets/coq-DkFqJrB1.js",revision:null},{url:"assets/common-lisp-Cg-RD9OK.js",revision:null},{url:"assets/coffee-Ch7k5sss.js",revision:null},{url:"assets/codeql-DsOJ9woJ.js",revision:null},{url:"assets/codeowners-Bp6g37R7.js",revision:null},{url:"assets/cobol-nBiQ_Alo.js",revision:null},{url:"assets/cmake-D1j8_8rp.js",revision:null},{url:"assets/clojure-P80f7IUj.js",revision:null},{url:"assets/clarity-D53aC0YG.js",revision:null},{url:"assets/catppuccin-mocha-D87Tk5Gz.js",revision:null},{url:"assets/catppuccin-macchiato-DQyhUUbL.js",revision:null},{url:"assets/catppuccin-latte-C9dUb6Cb.js",revision:null},{url:"assets/catppuccin-frappe-DFWUc33u.js",revision:null},{url:"assets/cairo-KRGpt6FW.js",revision:null},{url:"assets/cadence-Bv_4Rxtq.js",revision:null},{url:"assets/c3-MRO5bC_T.js",revision:null},{url:"assets/c-BIGW1oBm.js",revision:null},{url:"assets/bsl-BO_Y6i37.js",revision:null},{url:"assets/blade-2xfisSek.js",revision:null},{url:"assets/bird2-BIv1doCn.js",revision:null},{url:"assets/bicep-Bmn6On1c.js",revision:null},{url:"assets/bibtex-CHM0blh-.js",revision:null},{url:"assets/berry-uYugtg8r.js",revision:null},{url:"assets/beancount-k_qm7-4y.js",revision:null},{url:"assets/bat-BkioyH1T.js",revision:null},{url:"assets/ballerina-BFfxhgS-.js",revision:null},{url:"assets/ayu-mirage-32ctXXKs.js",revision:null},{url:"assets/ayu-light-BA47KaF1.js",revision:null},{url:"assets/ayu-dark-DYE7WIF3.js",revision:null},{url:"assets/awk-DMzUqQB5.js",revision:null},{url:"assets/aurora-x-D-2ljcwZ.js",revision:null},{url:"assets/astro-HNnZUWAn.js",revision:null},{url:"assets/asm-D_Q5rh1f.js",revision:null},{url:"assets/asciidoc-Ve4PFQV2.js",revision:null},{url:"assets/ara-BRHolxvo.js",revision:null},{url:"assets/applescript-Co6uUVPk.js",revision:null},{url:"assets/apl-CORt7UWP.js",revision:null},{url:"assets/apex-Dqspr-GT.js",revision:null},{url:"assets/apache-Pmp26Uib.js",revision:null},{url:"assets/angular-ts-BrjP3tb8.js",revision:null},{url:"assets/angular-html-DA-rfuFy.js",revision:null},{url:"assets/andromeeda-C4gqWexZ.js",revision:null},{url:"assets/ada-bCR0ucgS.js",revision:null},{url:"assets/actionscript-3-CoDkCxhg.js",revision:null},{url:"assets/abap-BdImnpbu.js",revision:null},{url:"assets/openfox-192.png",revision:"79feeb86d692c274854e37959a7dae67"},{url:"assets/openfox-512.png",revision:"fee24b214220594b4f595a467e73036e"},{url:"manifest.webmanifest",revision:"c25f372c782e623ab1e768a8dfe350ca"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))});
|
|
1
|
+
if(!self.define){let s,l={};const e=(e,r)=>(e=new URL(e+".js",r).href,l[e]||new Promise(l=>{if("document"in self){const s=document.createElement("script");s.src=e,s.onload=l,document.head.appendChild(s)}else s=e,importScripts(e),l()}).then(()=>{let s=l[e];if(!s)throw new Error(`Module ${e} didn’t register its module`);return s}));self.define=(r,i)=>{const n=s||("document"in self?document.currentScript.src:"")||location.href;if(l[n])return;let u={};const a=s=>e(s,n),t={module:{uri:n},exports:u,require:a};l[n]=Promise.all(r.map(s=>t[s]||a(s))).then(s=>(i(...s),u))}}define(["./workbox-8c29f6e4"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"f4a3b1936d780225c38558ef7896132a"},{url:"__inspect__.js",revision:"878b477aaf1805c028895f3d3bb4af71"},{url:"assets/zig-VOosw3JB.js",revision:null},{url:"assets/zenscript-DVFEvuxE.js",revision:null},{url:"assets/yaml-Buea-lGh.js",revision:null},{url:"assets/xsl-CtQFsRM5.js",revision:null},{url:"assets/xml-sdJ4AIDG.js",revision:null},{url:"assets/wolfram-lXgVvXCa.js",revision:null},{url:"assets/wit-5i3qLPDT.js",revision:null},{url:"assets/wikitext-BhOHFoWU.js",revision:null},{url:"assets/wgsl-Dx-B1_4e.js",revision:null},{url:"assets/wenyan-BV7otONQ.js",revision:null},{url:"assets/wasm-MzD3tlZU.js",revision:null},{url:"assets/wasm-CG6Dc4jp.js",revision:null},{url:"assets/vyper-CDx5xZoG.js",revision:null},{url:"assets/vue-vine-BoDAl6tE.js",revision:null},{url:"assets/vue-html-AaS7Mt5G.js",revision:null},{url:"assets/vue-D2xRrEX4.js",revision:null},{url:"assets/vitesse-light-CVO1_9PV.js",revision:null},{url:"assets/vitesse-dark-D0r3Knsf.js",revision:null},{url:"assets/vitesse-black-Bkuqu6BP.js",revision:null},{url:"assets/viml-CJc9bBzg.js",revision:null},{url:"assets/vhdl-CeAyd5Ju.js",revision:null},{url:"assets/vesper-DRje8inN.js",revision:null},{url:"assets/verilog-BQ8w6xss.js",revision:null},{url:"assets/vb-D17OF-Vu.js",revision:null},{url:"assets/vala-CsfeWuGM.js",revision:null},{url:"assets/v-BcVCzyr7.js",revision:null},{url:"assets/typst-DHCkPAjA.js",revision:null},{url:"assets/typespec-CAFt9gP4.js",revision:null},{url:"assets/typescript-BPQ3VLAy.js",revision:null},{url:"assets/twig-CW1WmMYd.js",revision:null},{url:"assets/turtle-BsS91CYL.js",revision:null},{url:"assets/tsx-COt5Ahok.js",revision:null},{url:"assets/tsv-B_m7g4N7.js",revision:null},{url:"assets/ts-tags-D351s5mN.js",revision:null},{url:"assets/toml-vGWfd6FD.js",revision:null},{url:"assets/tokyo-night-hegEt444.js",revision:null},{url:"assets/tex-idrVyKtj.js",revision:null},{url:"assets/terraform-BETggiCN.js",revision:null},{url:"assets/templ-DhtptRzy.js",revision:null},{url:"assets/tcl-dwOrl1Do.js",revision:null},{url:"assets/tasl-QIJgUcNo.js",revision:null},{url:"assets/talonscript-CkByrt1z.js",revision:null},{url:"assets/systemd-4A_iFExJ.js",revision:null},{url:"assets/system-verilog-CnnmHF94.js",revision:null},{url:"assets/synthwave-84-CbfX1IO0.js",revision:null},{url:"assets/swift-D82vCrfD.js",revision:null},{url:"assets/svelte-Cy7k_4gC.js",revision:null},{url:"assets/surrealql-Bq5Q-fJD.js",revision:null},{url:"assets/stylus-BEDo0Tqx.js",revision:null},{url:"assets/stata-DI20mbqo.js",revision:null},{url:"assets/ssh-config-_ykCGR6B.js",revision:null},{url:"assets/sql-CRqJ_cUM.js",revision:null},{url:"assets/splunk-BtCnVYZw.js",revision:null},{url:"assets/sparql-rVzFXLq3.js",revision:null},{url:"assets/soy-8wufbnw4.js",revision:null},{url:"assets/solidity-rGO070M0.js",revision:null},{url:"assets/solarized-light-L9t79GZl.js",revision:null},{url:"assets/solarized-dark-DXbdFlpD.js",revision:null},{url:"assets/snazzy-light-Bw305WKR.js",revision:null},{url:"assets/smalltalk-BERRCDM3.js",revision:null},{url:"assets/slack-ochin-DqwNpetd.js",revision:null},{url:"assets/slack-dark-BthQWCQV.js",revision:null},{url:"assets/shellsession-BADoaaVG.js",revision:null},{url:"assets/shellscript-Yzrsuije.js",revision:null},{url:"assets/shaderlab-Dg9Lc6iA.js",revision:null},{url:"assets/sdbl-DVxCFoDh.js",revision:null},{url:"assets/scss-D5BDwBP9.js",revision:null},{url:"assets/scheme-C98Dy4si.js",revision:null},{url:"assets/scala-C151Ov-r.js",revision:null},{url:"assets/sass-Cj5Yp3dK.js",revision:null},{url:"assets/sas-DEy46yEz.js",revision:null},{url:"assets/rust-B1yitclQ.js",revision:null},{url:"assets/ruby-DyJCeAvU.js",revision:null},{url:"assets/rst-CpCqk9r5.js",revision:null},{url:"assets/rosmsg-BJDFO7_C.js",revision:null},{url:"assets/rose-pine-qdsjHGoJ.js",revision:null},{url:"assets/rose-pine-moon-D4_iv3hh.js",revision:null},{url:"assets/rose-pine-dawn-DHQR4-dF.js",revision:null},{url:"assets/ron-D8l8udqQ.js",revision:null},{url:"assets/riscv-BM1_JUlF.js",revision:null},{url:"assets/rel-C3B-1QV4.js",revision:null},{url:"assets/regexp-CDVJQ6XC.js",revision:null},{url:"assets/reg-C-SQnVFl.js",revision:null},{url:"assets/red-bN70gL4F.js",revision:null},{url:"assets/razor-BjBPvh-w.js",revision:null},{url:"assets/raku-DXvB9xmW.js",revision:null},{url:"assets/racket-BqYA7rlc.js",revision:null},{url:"assets/r-Dspwwk_N.js",revision:null},{url:"assets/qss-IeuSbFQv.js",revision:null},{url:"assets/qmldir-C8lEn-DE.js",revision:null},{url:"assets/qml-3beO22l8.js",revision:null},{url:"assets/python-B6aJPvgy.js",revision:null},{url:"assets/purescript-CklMAg4u.js",revision:null},{url:"assets/puppet-BMWR74SV.js",revision:null},{url:"assets/pug-DKIMFp6K.js",revision:null},{url:"assets/proto-C7zT0LnQ.js",revision:null},{url:"assets/prolog-CbFg5uaA.js",revision:null},{url:"assets/prisma-Dd19v3D-.js",revision:null},{url:"assets/powershell-Dpen1YoG.js",revision:null},{url:"assets/powerquery-CEu0bR-o.js",revision:null},{url:"assets/postcss-CXtECtnM.js",revision:null},{url:"assets/polar-C0HS_06l.js",revision:null},{url:"assets/poimandres-CS3Unz2-.js",revision:null},{url:"assets/po-BTJTHyun.js",revision:null},{url:"assets/plsql-ChMvpjG-.js",revision:null},{url:"assets/plastic-3e1v2bzS.js",revision:null},{url:"assets/pkl-u5AG7uiY.js",revision:null},{url:"assets/php-Csjmro_R.js",revision:null},{url:"assets/perl-B9cMNwum.js",revision:null},{url:"assets/pascal-D93ZcfNL.js",revision:null},{url:"assets/openscad-C4EeE6gA.js",revision:null},{url:"assets/one-light-C3Wv6jpd.js",revision:null},{url:"assets/one-dark-pro-DVMEJ2y_.js",revision:null},{url:"assets/odin-BBf5iR-q.js",revision:null},{url:"assets/ocaml-C0hk2d4L.js",revision:null},{url:"assets/objective-cpp-CLxacb5B.js",revision:null},{url:"assets/objective-c-DXmwc3jG.js",revision:null},{url:"assets/nushell-Cz2AlsmD.js",revision:null},{url:"assets/nord-Ddv68eIx.js",revision:null},{url:"assets/nix-CwoSXNpI.js",revision:null},{url:"assets/nim-BIad80T-.js",revision:null},{url:"assets/night-owl-light-CMTm3GFP.js",revision:null},{url:"assets/night-owl-C39BiMTA.js",revision:null},{url:"assets/nginx-BpAMiNFr.js",revision:null},{url:"assets/nextflow-groovy-vE_lwT2v.js",revision:null},{url:"assets/nextflow-C-mBbutL.js",revision:null},{url:"assets/narrat-DRg8JJMk.js",revision:null},{url:"assets/move-IF9eRakj.js",revision:null},{url:"assets/moonbit-_H4v1dQx.js",revision:null},{url:"assets/monokai-D4h5O-jR.js",revision:null},{url:"assets/mojo-rZm6bMo-.js",revision:null},{url:"assets/mipsasm-CKIfxQSi.js",revision:null},{url:"assets/min-light-CTRr51gU.js",revision:null},{url:"assets/min-dark-CafNBF8u.js",revision:null},{url:"assets/mermaid-mWjccvbQ.js",revision:null},{url:"assets/mdx-Cmh6b_Ma.js",revision:null},{url:"assets/mdc-DTYItulj.js",revision:null},{url:"assets/matlab-D7o27uSR.js",revision:null},{url:"assets/material-theme-palenight-Csfq5Kiy.js",revision:null},{url:"assets/material-theme-ocean-CyktbL80.js",revision:null},{url:"assets/material-theme-lighter-B0m2ddpp.js",revision:null},{url:"assets/material-theme-darker-BfHTSMKl.js",revision:null},{url:"assets/material-theme-D5KoaKCx.js",revision:null},{url:"assets/marko-DjSrsDqO.js",revision:null},{url:"assets/markdown-Cvjx9yec.js",revision:null},{url:"assets/make-CHLpvVh8.js",revision:null},{url:"assets/luau-KW6xsasC.js",revision:null},{url:"assets/lua-BaeVxFsk.js",revision:null},{url:"assets/logo-BtOb2qkB.js",revision:null},{url:"assets/log-2UxHyX5q.js",revision:null},{url:"assets/llvm-DjAJT7YJ.js",revision:null},{url:"assets/liquid-C0sCDyMI.js",revision:null},{url:"assets/light-plus-B7mTdjB0.js",revision:null},{url:"assets/less-B1dDrJ26.js",revision:null},{url:"assets/lean-BZvkOJ9d.js",revision:null},{url:"assets/latex-CaSxy8MP.js",revision:null},{url:"assets/laserwave-DUszq2jm.js",revision:null},{url:"assets/kusto-wEQ09or8.js",revision:null},{url:"assets/kotlin-BdnUsdx6.js",revision:null},{url:"assets/kdl-DV7GczEv.js",revision:null},{url:"assets/kanagawa-wave-DWedfzmr.js",revision:null},{url:"assets/kanagawa-lotus-CfQXZHmo.js",revision:null},{url:"assets/kanagawa-dragon-CkXjmgJE.js",revision:null},{url:"assets/just-CUsbIsdP.js",revision:null},{url:"assets/julia-D7OTSIA_.js",revision:null},{url:"assets/jsx-g9-lgVsj.js",revision:null},{url:"assets/jssm-C2t-YnRu.js",revision:null},{url:"assets/jsonnet-DFQXde-d.js",revision:null},{url:"assets/jsonl-DcaNXYhu.js",revision:null},{url:"assets/jsonc-Des-eS-w.js",revision:null},{url:"assets/json5-C9tS-k6U.js",revision:null},{url:"assets/json-Cp-IABpG.js",revision:null},{url:"assets/jison-wvAkD_A8.js",revision:null},{url:"assets/jinja-f2NsQr07.js",revision:null},{url:"assets/javascript-wDzz0qaB.js",revision:null},{url:"assets/java-CylS5w8V.js",revision:null},{url:"assets/ini-BEwlwnbL.js",revision:null},{url:"assets/index-D3nUB0zb.css",revision:null},{url:"assets/index-BEkw-EHs.js",revision:null},{url:"assets/imba-DGztddWO.js",revision:null},{url:"assets/hy-DFXneXwc.js",revision:null},{url:"assets/hxml-Bvhsp5Yf.js",revision:null},{url:"assets/hurl-irOxFIW8.js",revision:null},{url:"assets/http-jrhK8wxY.js",revision:null},{url:"assets/html2canvas.esm-QH1iLAAe.js",revision:null},{url:"assets/html-pp8916En.js",revision:null},{url:"assets/html-derivative-DlHx6ybY.js",revision:null},{url:"assets/houston-DnULxvSX.js",revision:null},{url:"assets/horizon-bright-CUuTKBJd.js",revision:null},{url:"assets/horizon-BUw7H-hv.js",revision:null},{url:"assets/hlsl-D3lLCCz7.js",revision:null},{url:"assets/hjson-D5-asLiD.js",revision:null},{url:"assets/hcl-BWvSN4gD.js",revision:null},{url:"assets/haxe-CzTSHFRz.js",revision:null},{url:"assets/haskell-Df6bDoY_.js",revision:null},{url:"assets/handlebars-BpdQsYii.js",revision:null},{url:"assets/haml-D5jkg6IW.js",revision:null},{url:"assets/hack-DbPARsA_.js",revision:null},{url:"assets/gruvbox-light-soft-hJgmCMqR.js",revision:null},{url:"assets/gruvbox-light-medium-DRw_LuNl.js",revision:null},{url:"assets/gruvbox-light-hard-CH1njM8p.js",revision:null},{url:"assets/gruvbox-dark-soft-CVdnzihN.js",revision:null},{url:"assets/gruvbox-dark-medium-GsRaNv29.js",revision:null},{url:"assets/gruvbox-dark-hard-CFHQjOhq.js",revision:null},{url:"assets/groovy-gcz8RCvz.js",revision:null},{url:"assets/graphql-ChdNCCLP.js",revision:null},{url:"assets/go-C27-OAKa.js",revision:null},{url:"assets/gnuplot-DdkO51Og.js",revision:null},{url:"assets/gn-n2N0HUVH.js",revision:null},{url:"assets/glsl-DplSGwfg.js",revision:null},{url:"assets/glimmer-ts-BfAWNZQY.js",revision:null},{url:"assets/glimmer-js-ByusRIyA.js",revision:null},{url:"assets/gleam-BspZqrRM.js",revision:null},{url:"assets/github-light-high-contrast-BfjtVDDH.js",revision:null},{url:"assets/github-light-default-D7oLnXFd.js",revision:null},{url:"assets/github-light-DAi9KRSo.js",revision:null},{url:"assets/github-dark-high-contrast-E3gJ1_iC.js",revision:null},{url:"assets/github-dark-dimmed-DH5Ifo-i.js",revision:null},{url:"assets/github-dark-default-Cuk6v7N8.js",revision:null},{url:"assets/github-dark-DHJKELXO.js",revision:null},{url:"assets/git-rebase-r7XF79zn.js",revision:null},{url:"assets/git-commit-F4YmCXRG.js",revision:null},{url:"assets/gherkin-DyxjwDmM.js",revision:null},{url:"assets/genie-D0YGMca9.js",revision:null},{url:"assets/gdshader-DkwncUOv.js",revision:null},{url:"assets/gdscript-C5YyOfLZ.js",revision:null},{url:"assets/gdresource-BOOCDP_w.js",revision:null},{url:"assets/fsharp-CXgrBDvD.js",revision:null},{url:"assets/fortran-free-form-BxgE0vQu.js",revision:null},{url:"assets/fortran-fixed-form-CkoXwp7k.js",revision:null},{url:"assets/fluent-C4IJs8-o.js",revision:null},{url:"assets/fish-BvzEVeQv.js",revision:null},{url:"assets/fennel-BYunw83y.js",revision:null},{url:"assets/everforest-light-C8M2exoo.js",revision:null},{url:"assets/everforest-dark-BgDCqdQA.js",revision:null},{url:"assets/erlang-DsQrWhSR.js",revision:null},{url:"assets/erb-Dm6A9KJ5.js",revision:null},{url:"assets/emacs-lisp-CXvaQtF9.js",revision:null},{url:"assets/elm-DbKCFpqz.js",revision:null},{url:"assets/elixir-CkH2-t6x.js",revision:null},{url:"assets/edge-FbVlp4U3.js",revision:null},{url:"assets/dream-maker-BtqSS_iP.js",revision:null},{url:"assets/dracula-soft-BXkSAIEj.js",revision:null},{url:"assets/dracula-BzJJZx-M.js",revision:null},{url:"assets/dotenv-Da5cRb03.js",revision:null},{url:"assets/docker-BcOcwvcX.js",revision:null},{url:"assets/diff-D97Zzqfu.js",revision:null},{url:"assets/desktop-BmXAJ9_W.js",revision:null},{url:"assets/dax-CEL-wOlO.js",revision:null},{url:"assets/dart-bE4Kk8sk.js",revision:null},{url:"assets/dark-plus-C3mMm8J8.js",revision:null},{url:"assets/d-85-TOEBH.js",revision:null},{url:"assets/cypher-COkxafJQ.js",revision:null},{url:"assets/cue-D82EKSYY.js",revision:null},{url:"assets/csv-fuZLfV_i.js",revision:null},{url:"assets/css-CLj8gQPS.js",revision:null},{url:"assets/csharp-DSvCPggb.js",revision:null},{url:"assets/crystal-DGywbUpC.js",revision:null},{url:"assets/cpp-UfJy6YNI.js",revision:null},{url:"assets/coq-DkFqJrB1.js",revision:null},{url:"assets/common-lisp-Cg-RD9OK.js",revision:null},{url:"assets/coffee-Ch7k5sss.js",revision:null},{url:"assets/codeql-DsOJ9woJ.js",revision:null},{url:"assets/codeowners-Bp6g37R7.js",revision:null},{url:"assets/cobol-nBiQ_Alo.js",revision:null},{url:"assets/cmake-D1j8_8rp.js",revision:null},{url:"assets/clojure-P80f7IUj.js",revision:null},{url:"assets/clarity-D53aC0YG.js",revision:null},{url:"assets/catppuccin-mocha-D87Tk5Gz.js",revision:null},{url:"assets/catppuccin-macchiato-DQyhUUbL.js",revision:null},{url:"assets/catppuccin-latte-C9dUb6Cb.js",revision:null},{url:"assets/catppuccin-frappe-DFWUc33u.js",revision:null},{url:"assets/cairo-KRGpt6FW.js",revision:null},{url:"assets/cadence-Bv_4Rxtq.js",revision:null},{url:"assets/c3-MRO5bC_T.js",revision:null},{url:"assets/c-BIGW1oBm.js",revision:null},{url:"assets/bsl-BO_Y6i37.js",revision:null},{url:"assets/blade-2xfisSek.js",revision:null},{url:"assets/bird2-BIv1doCn.js",revision:null},{url:"assets/bicep-Bmn6On1c.js",revision:null},{url:"assets/bibtex-CHM0blh-.js",revision:null},{url:"assets/berry-uYugtg8r.js",revision:null},{url:"assets/beancount-k_qm7-4y.js",revision:null},{url:"assets/bat-BkioyH1T.js",revision:null},{url:"assets/ballerina-BFfxhgS-.js",revision:null},{url:"assets/ayu-mirage-32ctXXKs.js",revision:null},{url:"assets/ayu-light-BA47KaF1.js",revision:null},{url:"assets/ayu-dark-DYE7WIF3.js",revision:null},{url:"assets/awk-DMzUqQB5.js",revision:null},{url:"assets/aurora-x-D-2ljcwZ.js",revision:null},{url:"assets/astro-HNnZUWAn.js",revision:null},{url:"assets/asm-D_Q5rh1f.js",revision:null},{url:"assets/asciidoc-Ve4PFQV2.js",revision:null},{url:"assets/ara-BRHolxvo.js",revision:null},{url:"assets/applescript-Co6uUVPk.js",revision:null},{url:"assets/apl-CORt7UWP.js",revision:null},{url:"assets/apex-Dqspr-GT.js",revision:null},{url:"assets/apache-Pmp26Uib.js",revision:null},{url:"assets/angular-ts-BrjP3tb8.js",revision:null},{url:"assets/angular-html-DA-rfuFy.js",revision:null},{url:"assets/andromeeda-C4gqWexZ.js",revision:null},{url:"assets/ada-bCR0ucgS.js",revision:null},{url:"assets/actionscript-3-CoDkCxhg.js",revision:null},{url:"assets/abap-BdImnpbu.js",revision:null},{url:"assets/openfox-192.png",revision:"79feeb86d692c274854e37959a7dae67"},{url:"assets/openfox-512.png",revision:"fee24b214220594b4f595a467e73036e"},{url:"manifest.webmanifest",revision:"c25f372c782e623ab1e768a8dfe350ca"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))});
|