@runfusion/fusion 0.34.0 → 0.36.0
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/bin.js +2790 -633
- package/dist/client/.vite/manifest.json +56 -56
- package/dist/client/assets/{AgentDetailView-CzqwIIpv.js → AgentDetailView-CGycokdR.js} +1 -1
- package/dist/client/assets/{AgentPermissionPolicyEditor-2eoM2XQH.js → AgentPermissionPolicyEditor-BoD6come.js} +1 -1
- package/dist/client/assets/{AgentsView-BrtAvhJl.js → AgentsView-B_afRRfc.js} +3 -3
- package/dist/client/assets/ChatView-IjNrSZSf.js +6 -0
- package/dist/client/assets/{DevServerView-CF6FPLRb.js → DevServerView-Dd613aZ5.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-BpvHQxhu.js → DirectoryPicker-H-fUl2dF.js} +1 -1
- package/dist/client/assets/{DocumentsView-RMWZBJ-y.js → DocumentsView-Dshc9e5K.js} +1 -1
- package/dist/client/assets/{EvalsView-DtVxpc4T.js → EvalsView-50W0K5h7.js} +1 -1
- package/dist/client/assets/{ExperimentalAgentOnboardingModal-fzJmb-yG.js → ExperimentalAgentOnboardingModal-BXBljPFj.js} +1 -1
- package/dist/client/assets/{GoalsView-BAchggxo.js → GoalsView-Dh508Z2s.js} +1 -1
- package/dist/client/assets/{InsightsView-B8892IbG.js → InsightsView-sVbGRKTl.js} +1 -1
- package/dist/client/assets/{MemoryView-Cfp1WmAm.js → MemoryView-006a_sB0.js} +1 -1
- package/dist/client/assets/{NodesView-Dt26DSEQ.js → NodesView-CiRPqgVx.js} +1 -1
- package/dist/client/assets/{PiExtensionsManager-xHU56SMh.js → PiExtensionsManager-Y1ETuTxf.js} +1 -1
- package/dist/client/assets/{PluginManager-37WUEOmp.js → PluginManager-Df_KHiXn.js} +1 -1
- package/dist/client/assets/{ResearchView-pu88M5xL.js → ResearchView-DU_QuS_-.js} +1 -1
- package/dist/client/assets/{SecretsView-BT7ofJLN.js → SecretsView-D61Jvysn.js} +1 -1
- package/dist/client/assets/{SettingsModal-DxYXsn08.js → SettingsModal-BarzmqNb.js} +1 -1
- package/dist/client/assets/SettingsModal-Cpur3WpT.js +31 -0
- package/dist/client/assets/{SetupWizardModal-yWTk3Cac.js → SetupWizardModal-BF3iRNq9.js} +1 -1
- package/dist/client/assets/{SkillsView-CWNfKNTs.js → SkillsView-tCKOFw3j.js} +1 -1
- package/dist/client/assets/{StashRecoveryView-D0t4IIX-.js → StashRecoveryView-nGtypd10.js} +1 -1
- package/dist/client/assets/{TodoView-B4W1Lhy6.js → TodoView-IyGPV6AO.js} +1 -1
- package/dist/client/assets/{dashboard-view-4OCJIthP.js → dashboard-view-DiA5-hnb.js} +1 -1
- package/dist/client/assets/{folder-open-BTdhwFQ5.js → folder-open-Byqfi_N-.js} +1 -1
- package/dist/client/assets/index-B9Ro_NwC.js +742 -0
- package/dist/client/assets/index-DVFBXjGT.css +1 -0
- package/dist/client/assets/{upload-kESyjow_.js → upload-D6_BjqVi.js} +1 -1
- package/dist/client/assets/{users-DNXMrdcp.js → users-CERYgInO.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/version.json +1 -1
- package/dist/droid-cli/index.ts +1 -1
- package/dist/droid-cli/package.json +3 -3
- package/dist/droid-cli/src/__tests__/thinking-config.test.ts +1 -1
- package/dist/extension.js +1959 -310
- package/dist/pi-claude-cli/index.ts +3 -3
- package/dist/pi-claude-cli/package.json +3 -3
- package/dist/pi-claude-cli/src/__tests__/event-bridge.test.ts +3 -3
- package/dist/pi-claude-cli/src/__tests__/provider.test.ts +3 -3
- package/dist/pi-claude-cli/src/__tests__/thinking-config.test.ts +1 -1
- package/dist/pi-claude-cli/src/event-bridge.ts +2 -2
- package/dist/pi-claude-cli/src/provider.ts +1 -1
- package/dist/pi-claude-cli/src/thinking-config.ts +1 -1
- package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
- package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
- package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +34607 -33421
- package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-reports/package.json +1 -1
- package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
- package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
- package/package.json +7 -7
- package/skill/fusion/SKILL.md +1 -0
- package/skill/fusion/references/cli-commands.md +3 -0
- package/skill/fusion/references/extension-tools.md +27 -0
- package/skill/fusion/references/fusion-capabilities.md +3 -0
- package/dist/client/assets/ChatView-BuIe4MhL.js +0 -6
- package/dist/client/assets/SettingsModal-Cz9MHNGg.js +0 -31
- package/dist/client/assets/index-D4nQgFjo.js +0 -742
- package/dist/client/assets/index-k4s0JWir.css +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PluginManager-Df_KHiXn.js","assets/vendor-react-K0fH_qHe.js","assets/index-B9Ro_NwC.js","assets/vendor-xterm-DzcZoU0P.js","assets/vendor-xterm-LZoznX6r.css","assets/vendor-codemirror-jBKmHyH0.js","assets/index-DVFBXjGT.css","assets/DirectoryPicker-H-fUl2dF.js","assets/folder-open-Byqfi_N-.js","assets/DirectoryPicker-DzKVmxOf.css","assets/PluginManager-BJQXdUmV.css","assets/PiExtensionsManager-Y1ETuTxf.js","assets/PiExtensionsManager-kgTOHPE9.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as Es,cm as gl,cE as Ir,cF as Rr,L as Ve,cG as Ds,cH as Er,cI as Dr,cJ as et,cK as Lr,P as jt,cL as Or,cM as Br,cN as $r,cO as _r,cP as Gr,cQ as Da,cR as La,cS as Ur,cT as zr,ck as Lt,M as fs,b3 as bl,_ as fl,J as xl,aj as qr,a as Hr,cU as Wr,cV as Kr,cW as Vr,cX as Yr,cY as Qr,ax as Xr,S as Oa,cZ as Jr,c_ as Zr,s as en,v as tn,p as sn,u as an,by as ln,c$ as rn,d0 as nn,G as vt,d1 as Ba,ba as on,x as $a,d2 as cn,d3 as _a,d4 as Ga,z as X,d5 as dn,d6 as un,d7 as mn,aN as Ua,d8 as za,h as hn,d9 as qa,da as pn,db as xs,dc as vs,dd as Ha,de as gn,df as bn,dg as Wa,dh as fn,bS as Ka,bR as xn,di as Va,dj as vn,dk as Ya,dl as jn,dm as yn,dn as kn,dp as Nn,dq as Cn,dr as wn,ds as Sn,dt as Pn,du as An,j as js,dv as Fn,dw as Mn,dx as Tn,y as In,dy as Rn,bU as En,c0 as Dn,bW as Ln,b$ as On,bV as Bn,dz as $n,R as _n,dA as Gn,dB as Qa,dC as Xa,dD as Un,dE as zn,dF as qn,dG as ys,dH as Hn,dI as Wn,C as Kn,T as Vn,dJ as Yn,dK as ks,dL as Qn,dM as Ns,dN as Xn,dO as Jn,c3 as Zn,dP as ei,dQ as ti,dR as si,dS as ai,dT as li,m as Ee,dU as ri,dV as ni,dW as Ja,a0 as vl,dX as ii,dY as oi}from"./index-B9Ro_NwC.js";import{r,j as e}from"./vendor-react-K0fH_qHe.js";import{u as ci}from"./SettingsModal-BarzmqNb.js";import{U as di}from"./users-CERYgInO.js";import{S as ui,A as mi}from"./AgentPermissionPolicyEditor-BoD6come.js";import{SecretsView as hi}from"./SecretsView-D61Jvysn.js";import"./vendor-xterm-DzcZoU0P.js";import"./vendor-codemirror-jBKmHyH0.js";/**
|
|
3
|
+
* @license lucide-react v1.7.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const pi=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],jl=Es("moon",pi);/**
|
|
8
|
+
* @license lucide-react v1.7.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const gi=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],bi=Es("settings-2",gi);/**
|
|
13
|
+
* @license lucide-react v1.7.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const fi=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],yl=Es("sun",fi),xi=[{value:"light",label:"Light",icon:yl},{value:"dark",label:"Dark",icon:jl},{value:"system",label:"System",icon:gl}],vi=[{value:90,label:"Small"},{value:100,label:"Default"},{value:110,label:"Large"},{value:120,label:"Largest"}],Za=[{value:"default",label:"Default",className:"theme-swatch-default"},{value:"ocean",label:"Ocean",className:"theme-swatch-ocean"},{value:"forest",label:"Forest",className:"theme-swatch-forest"},{value:"sunset",label:"Sunset",className:"theme-swatch-sunset"},{value:"zen",label:"Zen",className:"theme-swatch-zen"},{value:"berry",label:"Berry",className:"theme-swatch-berry"},{value:"high-contrast",label:"High Contrast",className:"theme-swatch-high-contrast"},{value:"industrial",label:"Industrial",className:"theme-swatch-industrial"},{value:"monochrome",label:"Mono",className:"theme-swatch-monochrome"},{value:"slate",label:"Slate",className:"theme-swatch-slate"},{value:"ash",label:"Ash",className:"theme-swatch-ash"},{value:"graphite",label:"Graphite",className:"theme-swatch-graphite"},{value:"silver",label:"Silver",className:"theme-swatch-silver"},{value:"solarized",label:"Solarized",className:"theme-swatch-solarized"},{value:"factory",label:"Factory",className:"theme-swatch-factory"},{value:"ayu",label:"Ayu",className:"theme-swatch-ayu"},{value:"one-dark",label:"One Dark",className:"theme-swatch-one-dark"},{value:"nord",label:"Nord",className:"theme-swatch-nord"},{value:"dracula",label:"Dracula",className:"theme-swatch-dracula"},{value:"gruvbox",label:"Gruvbox",className:"theme-swatch-gruvbox"},{value:"tokyo-night",label:"Tokyo Night",className:"theme-swatch-tokyo-night"},{value:"catppuccin-mocha",label:"Catppuccin Mocha",className:"theme-swatch-catppuccin-mocha"},{value:"github-dark",label:"GitHub Dark",className:"theme-swatch-github-dark"},{value:"everforest",label:"Everforest",className:"theme-swatch-everforest"},{value:"rose-pine",label:"Rosé Pine",className:"theme-swatch-rose-pine"},{value:"kanagawa",label:"Kanagawa",className:"theme-swatch-kanagawa"},{value:"night-owl",label:"Night Owl",className:"theme-swatch-night-owl"},{value:"palenight",label:"Palenight",className:"theme-swatch-palenight"},{value:"monokai-pro",label:"Monokai Pro",className:"theme-swatch-monokai-pro"},{value:"slime",label:"Slime",className:"theme-swatch-slime"},{value:"brutalist",label:"Brutalist",className:"theme-swatch-brutalist"},{value:"neon-city",label:"Neon City",className:"theme-swatch-neon-city"},{value:"parchment",label:"Parchment",className:"theme-swatch-parchment"},{value:"terminal",label:"Terminal",className:"theme-swatch-terminal"},{value:"glass",label:"Glass",className:"theme-swatch-glass"},{value:"horizon",label:"Horizon",className:"theme-swatch-horizon"},{value:"vitesse",label:"Vitesse",className:"theme-swatch-vitesse"},{value:"outrun",label:"Outrun",className:"theme-swatch-outrun"},{value:"snazzy",label:"Snazzy",className:"theme-swatch-snazzy"},{value:"porple",label:"Porple",className:"theme-swatch-porple"},{value:"espresso",label:"Espresso",className:"theme-swatch-espresso"},{value:"mars",label:"Mars",className:"theme-swatch-mars"},{value:"poimandres",label:"Poimandres",className:"theme-swatch-poimandres"},{value:"ember",label:"Ember",className:"theme-swatch-ember"},{value:"rust",label:"Rust",className:"theme-swatch-rust"},{value:"copper",label:"Copper",className:"theme-swatch-copper"},{value:"foundry",label:"Foundry",className:"theme-swatch-foundry"},{value:"carbon",label:"Carbon",className:"theme-swatch-carbon"},{value:"sandstone",label:"Sandstone",className:"theme-swatch-sandstone"},{value:"lagoon",label:"Lagoon",className:"theme-swatch-lagoon"},{value:"frost",label:"Frost",className:"theme-swatch-frost"},{value:"lavender",label:"Lavender",className:"theme-swatch-lavender"},{value:"neon-bloom",label:"Neon Bloom",className:"theme-swatch-neon-bloom"},{value:"sepia",label:"Sepia",className:"theme-swatch-sepia"}];function ji({themeMode:n,colorTheme:o,dashboardFontScalePct:u=100,onThemeModeChange:k,onColorThemeChange:C,onDashboardFontScaleChange:w=()=>{}}){const I=r.useCallback(()=>{k("dark"),C("default"),w(100)},[k,C,w]);return e.jsxs("div",{className:"theme-selector",children:[e.jsx("div",{className:"theme-mode-toggle",role:"radiogroup","aria-label":"Theme mode",children:xi.map(({value:j,label:R,icon:E})=>e.jsxs("button",{className:`theme-mode-btn${n===j?" active":""}`,onClick:()=>k(j),"aria-pressed":n===j,"aria-label":`${R} mode`,title:`${R} mode`,children:[e.jsx(E,{size:16}),e.jsx("span",{children:R})]},j))}),e.jsxs("div",{className:"theme-current-preview",children:[e.jsx("div",{className:"theme-preview-icon",children:n==="light"?e.jsx(yl,{size:20}):n==="dark"?e.jsx(jl,{size:20}):e.jsx(gl,{size:20})}),e.jsxs("div",{className:"theme-preview-info",children:[e.jsx("div",{className:"theme-preview-label",children:"Current theme"}),e.jsxs("div",{className:"theme-preview-value",children:[n==="system"?"System":`${n.charAt(0).toUpperCase()+n.slice(1)}`," / ",Za.find(j=>j.value===o)?.label]})]})]}),e.jsx("div",{className:"theme-section-title",children:"Font Size"}),e.jsx("div",{className:"theme-font-size-toggle",role:"radiogroup","aria-label":"Dashboard font size",children:vi.map(({value:j,label:R})=>e.jsx("button",{className:`theme-font-size-btn${u===j?" active":""}`,onClick:()=>w(j),"aria-pressed":u===j,children:e.jsx("span",{children:R})},j))}),e.jsx("div",{className:"theme-section-title",children:"Color Theme"}),e.jsx("div",{className:"theme-grid",role:"radiogroup","aria-label":"Color theme",children:Za.map(({value:j,label:R,className:E})=>e.jsxs("button",{className:`theme-option${o===j?" active":""}`,onClick:()=>C(j),"aria-pressed":o===j,"aria-label":`${R} theme`,title:R,children:[e.jsxs("div",{className:`theme-option-swatch ${E}`,"aria-hidden":"true",children:[e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-1"}),e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-2"}),e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-3"}),e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-4"})]}),e.jsx("span",{className:"theme-option-label",children:R})]},j))}),e.jsx("button",{className:"theme-reset-btn",onClick:I,"aria-label":"Reset to default theme",children:e.jsx("span",{children:"Reset to defaults"})})]})}const yi={installed:{text:"Installed",tone:"ok"},missing:{text:"Not installed",tone:"err"},"version-mismatch":{text:"Version mismatch",tone:"warn"},skipped:{text:"Check disabled",tone:"warn"}};function ki({defer:n=!1}){const[o,u]=r.useState(null),[k,C]=r.useState(!1),[w,I]=r.useState(!1),[j,R]=r.useState(null),[E,S]=r.useState(null),[B,q]=r.useState(null),P=r.useCallback(async()=>{C(!0),S(null);try{const p=await Ir();u(p)}catch(p){S(p instanceof Error?p.message:String(p))}finally{C(!1)}},[]);r.useEffect(()=>{n||P()},[n,P]);const _=r.useCallback(async()=>{I(!0),R(null),S(null);try{const p=await Rr();u({binary:p.binary,expectedVersion:p.expectedVersion,state:p.state,install:p.install}),R(p.installResult)}catch(p){S(p instanceof Error?p.message:String(p))}finally{I(!1)}},[]),H=r.useCallback(async(p,O)=>{try{await navigator.clipboard.writeText(O),q(p),setTimeout(()=>q(y=>y===p?null:y),1500)}catch{}},[]),A=o?yi[o.state]:null;return e.jsxs("div",{className:"cli-binary-panel",children:[e.jsxs("div",{className:"cli-binary-header",children:[e.jsx("h4",{className:"settings-section-heading",children:"CLI Binary"}),A&&e.jsx("span",{className:`cli-binary-pill cli-binary-pill--${A.tone}`,children:A.text})]}),e.jsxs("small",{className:"cli-binary-help",children:["Installing the global CLI lets you run ",e.jsx("code",{children:"fn"})," and ",e.jsx("code",{children:"fusion"})," from any terminal. Automations and scripts work without it via ",e.jsx("code",{children:"npx"}),", but a global install is faster and more convenient."]}),k&&!o&&e.jsx("p",{className:"cli-binary-status-line",children:"Checking…"}),o&&e.jsxs("div",{className:"cli-binary-detail",children:[o.binary.installed?e.jsxs("ul",{className:"cli-binary-info-list",children:[e.jsxs("li",{children:[e.jsx("span",{children:"Binary:"}),e.jsx("code",{children:o.binary.binary})]}),o.binary.path&&e.jsxs("li",{children:[e.jsx("span",{children:"Path:"}),e.jsx("code",{children:o.binary.path})]}),e.jsxs("li",{children:[e.jsx("span",{children:"Version:"}),e.jsx("code",{children:o.binary.version??"unknown"}),e.jsxs("span",{className:"cli-binary-expected",children:["(expected ",o.expectedVersion,")"]})]})]}):e.jsxs("p",{className:"cli-binary-status-line",children:["Neither ",e.jsx("code",{children:"fn"})," nor ",e.jsx("code",{children:"fusion"})," was found on PATH."]}),e.jsxs("div",{className:"cli-binary-actions",children:[e.jsx("button",{type:"button",className:"cli-binary-install-btn",onClick:_,disabled:w,children:w?"Installing…":o.binary.installed?"Reinstall":"Install with npm"}),e.jsx("button",{type:"button",className:"cli-binary-refresh-btn",onClick:()=>void P(),disabled:k||w,children:"Refresh"})]}),e.jsxs("div",{className:"cli-binary-commands",children:[e.jsx("label",{children:"Or copy and run yourself:"}),[{label:"npm",command:o.install.npm},{label:"curl",command:o.install.curl}].map(({label:p,command:O})=>e.jsxs("div",{className:"cli-binary-command-row",children:[e.jsx("code",{children:O}),e.jsx("button",{type:"button",onClick:()=>void H(p,O),className:"cli-binary-copy-btn",children:B===p?"Copied":"Copy"})]},p))]})]}),j&&e.jsxs("details",{className:"cli-binary-install-log",open:!j.success,children:[e.jsx("summary",{children:j.success?`Install succeeded in ${(j.durationMs/1e3).toFixed(1)}s`:`Install failed (exit ${j.exitCode??"n/a"})`}),j.permissionsHint&&e.jsx("p",{className:"cli-binary-permissions-hint",children:j.permissionsHint}),j.stdout&&e.jsx("pre",{className:"cli-binary-install-output",children:j.stdout}),j.stderr&&e.jsx("pre",{className:"cli-binary-install-output cli-binary-install-output--err",children:j.stderr})]}),E&&e.jsx("p",{className:"field-error",children:E})]})}function Ls(n){const{name:o,subname:u,logo:k,learnMoreHref:C,statusKind:w,statusText:I,description:j,tabs:R,children:E,busy:S,canTest:B=!0,toast:q,onTest:P,onSave:_,onSaveAndTest:H,belowForm:A,testId:p}=n,O=w==="ok"?"runtime-card__status runtime-card__status--ok":w==="err"?"runtime-card__status runtime-card__status--err":"runtime-card__status runtime-card__status--neutral";return e.jsxs("div",{className:"runtime-card","data-testid":p,"aria-live":"polite",children:[e.jsxs("header",{className:"runtime-card__header",children:[e.jsx("span",{className:"runtime-card__logo",children:k}),e.jsxs("div",{className:"runtime-card__title",children:[e.jsx("h3",{className:"runtime-card__name",children:o}),u&&e.jsx("small",{className:"runtime-card__cobrand",children:u}),e.jsxs("small",{className:O,children:[w==="loading"&&e.jsx(Ve,{size:12,className:"animate-spin"}),I]})]}),e.jsx("a",{className:"runtime-card__learn-more btn btn-sm btn-ghost",href:C,target:"_blank",rel:"noreferrer",children:"Learn more →"})]}),e.jsx("p",{className:"runtime-card__description",children:j}),R,e.jsx("div",{className:"runtime-card__form",children:E}),A,e.jsxs("footer",{className:"runtime-card__footer",children:[q&&e.jsx("span",{className:q.kind==="ok"?"runtime-card__toast runtime-card__toast--ok":"runtime-card__toast runtime-card__toast--err",role:"status",children:q.message}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:P,disabled:S!==null||!B,children:S==="testing"?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:12,className:"animate-spin"})," Testing…"]}):"Test"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:_,disabled:S!==null,children:S==="saving"?"Saving…":"Save"}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:H,disabled:S!==null||!B,children:S==="save-test"?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:12,className:"animate-spin"})," Saving…"]}):"Save & Test"})]})]})}const Cs="fusion-plugin-hermes-runtime",el="https://github.com/NousResearch/hermes-agent",Ni=["auto","anthropic","openrouter","gemini","openai-codex","copilot","copilot-acp","huggingface","zai","kimi-coding","minimax","minimax-cn","kilocode","xiaomi","nous"],Fe={binaryPath:"",model:"",provider:"auto",maxTurns:12,yolo:!1,cliTimeoutMs:3e5,profile:""};function Ci(n){return{binaryPath:typeof n.binaryPath=="string"?n.binaryPath:Fe.binaryPath,model:typeof n.model=="string"?n.model:Fe.model,provider:typeof n.provider=="string"?n.provider:Fe.provider,maxTurns:typeof n.maxTurns=="number"?n.maxTurns:Fe.maxTurns,yolo:typeof n.yolo=="boolean"?n.yolo:Fe.yolo,cliTimeoutMs:typeof n.cliTimeoutMs=="number"?n.cliTimeoutMs:Fe.cliTimeoutMs,profile:typeof n.profile=="string"?n.profile:Fe.profile}}function wi(){const[n,o]=r.useState(Fe),[u,k]=r.useState(null),[C,w]=r.useState([]),[I,j]=r.useState(null),[R,E]=r.useState(null),S=r.useRef(!0);r.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]),r.useEffect(()=>{j("loading"),Ds(Cs).then(y=>{S.current&&o(Ci(y))}).catch(()=>{}).finally(()=>{S.current&&j(null)})},[]),r.useEffect(()=>{Er(n.binaryPath?{binaryPath:n.binaryPath}:{}).then(y=>{S.current&&w(y)}).catch(()=>{})},[n.binaryPath]);const B=r.useCallback(async()=>{try{const y=await Dr(n.binaryPath?{binaryPath:n.binaryPath}:{});return S.current&&k(y),y}catch(y){return S.current&&E({kind:"err",message:y instanceof Error?y.message:String(y)}),null}},[n.binaryPath]);r.useEffect(()=>{B()},[B]);const q=r.useCallback(()=>({binaryPath:n.binaryPath,model:n.model,provider:n.provider,maxTurns:n.maxTurns,yolo:n.yolo,cliTimeoutMs:n.cliTimeoutMs,profile:n.profile}),[n]),P=r.useCallback(async()=>{j("testing"),E(null);const y=await B();S.current&&(j(null),y?y.binary.available?E({kind:"ok",message:`✓ hermes detected${y.binary.version?` (${y.binary.version})`:""}${y.binary.binaryPath?` at ${y.binary.binaryPath}`:""}.`}):E({kind:"err",message:`✗ ${y.binary.reason??"hermes not found"}`}):E({kind:"err",message:"Test failed — see status above."}))},[B]),_=r.useCallback(async()=>{j("saving"),E(null);try{await et(Cs,q()),S.current&&E({kind:"ok",message:"Settings saved."})}catch(y){S.current&&E({kind:"err",message:y instanceof Error?y.message:String(y)})}finally{S.current&&j(null)}},[q]),H=r.useCallback(async()=>{j("save-test"),E(null);try{await et(Cs,q());const y=await B();if(!S.current)return;y?y.binary.available?E({kind:"ok",message:`Saved · ✓ hermes detected${y.binary.version?` (${y.binary.version})`:""}.`}):E({kind:"err",message:`Saved · ✗ ${y.binary.reason??"hermes not found"}`}):E({kind:"err",message:"Saved, but probe failed."})}catch(y){S.current&&E({kind:"err",message:y instanceof Error?y.message:String(y)})}finally{S.current&&j(null)}},[q,B]),A=u?.binary,p=u===null?"loading":A?.available?"ok":"err",O=u===null?"Probing local hermes binary…":A?.available?`✓ Detected${A.version?` ${A.version}`:""}${A.binaryPath?` · ${A.binaryPath}`:""}`:`✗ ${A?.reason??"not detected on PATH"}`;return e.jsxs(Ls,{testId:"hermes-runtime-card",logo:e.jsx("span",{style:{width:40,height:40,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"#fff"},children:e.jsx("img",{src:"/brands/hermes-logo.svg",alt:"Nous Research",style:{width:28,height:28,display:"block",filter:"invert(1) brightness(0)"}})}),name:"Hermes",subname:"by Nous Research",learnMoreHref:el,statusKind:p,statusText:O,description:e.jsxs(e.Fragment,{children:["Drives the local ",e.jsx("code",{children:"hermes"})," CLI as a subprocess. Each Fusion prompt is sent as ",e.jsx("code",{children:"hermes chat -q …"}),"; subsequent prompts resume the same hermes session via ",e.jsx("code",{children:"--resume"}),". Provider, model, and skills are configured inside hermes itself; this card only chooses overrides."]}),busy:I,toast:R,onTest:()=>void P(),onSave:()=>void _(),onSaveAndTest:()=>void H(),belowForm:A?.available===!1?e.jsxs("div",{className:"onboarding-helper-text",children:[e.jsxs("p",{children:[e.jsx("code",{children:"hermes"})," not detected. Install the upstream agent:"]}),e.jsx("pre",{children:e.jsx("code",{children:"pipx install hermes-agent"})}),e.jsx("p",{children:e.jsx("a",{href:el,target:"_blank",rel:"noreferrer",children:"Hermes on GitHub"})})]}):null,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"hermes-profile",children:"Profile (optional)"}),e.jsxs("select",{id:"hermes-profile",value:n.profile,onChange:y=>o(z=>({...z,profile:y.target.value})),children:[e.jsx("option",{value:"",children:"Auto / use Hermes default"}),C.map(y=>e.jsxs("option",{value:y.name,children:[y.name,y.model?` — ${y.model}`:"",y.isDefault?" (default)":""]},y.name))]}),e.jsxs("small",{children:["Select a Hermes profile to use. Activates the profile by setting"," ",e.jsx("code",{children:"HERMES_HOME"})," to the profile directory when invoking"," ",e.jsx("code",{children:"hermes chat"}),"."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"hermes-binary",children:"Binary path"}),e.jsx("input",{id:"hermes-binary",type:"text",placeholder:"hermes (defaults to PATH)",value:n.binaryPath,onChange:y=>o(z=>({...z,binaryPath:y.target.value}))}),e.jsxs("small",{children:["Leave blank to resolve ",e.jsx("code",{children:"hermes"})," from your PATH."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"hermes-model",children:"Model override"}),e.jsx("input",{id:"hermes-model",type:"text",placeholder:"e.g. claude-sonnet-4-5, MiniMax-M2.7",value:n.model,disabled:!!n.profile,onChange:y=>o(z=>({...z,model:y.target.value}))}),n.profile?e.jsxs("small",{children:["Controlled by profile: ",e.jsx("strong",{children:n.profile})]}):e.jsx("small",{children:"Optional — overrides Hermes's configured default model."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"hermes-provider",children:"Provider"}),e.jsx("select",{id:"hermes-provider",value:n.provider,disabled:!!n.profile,onChange:y=>o(z=>({...z,provider:y.target.value})),children:Ni.map(y=>e.jsx("option",{value:y,children:y},y))}),n.profile?e.jsxs("small",{children:["Controlled by profile: ",e.jsx("strong",{children:n.profile})]}):e.jsxs("small",{children:["Inference provider Hermes routes calls through (default: ",e.jsx("code",{children:"auto"}),"))."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"hermes-maxTurns",children:"Max turns"}),e.jsx("input",{id:"hermes-maxTurns",type:"number",min:1,max:500,value:n.maxTurns,onChange:y=>o(z=>({...z,maxTurns:Number(y.target.value)||Fe.maxTurns}))}),e.jsx("small",{children:"Cap per Hermes turn. Hermes's own default is 90; we cap lower."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"hermes-yolo",style:{display:"inline-flex",alignItems:"center",gap:"var(--space-xs)"},children:[e.jsx("input",{id:"hermes-yolo",type:"checkbox",checked:n.yolo,onChange:y=>o(z=>({...z,yolo:y.target.checked}))}),"Auto-approve dangerous tool calls (",e.jsx("code",{children:"--yolo"}),")"]}),e.jsx("small",{children:"Required for non-interactive sessions that trigger shell-style tools."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"hermes-timeoutMs",children:"CLI hard-kill timeout (ms)"}),e.jsx("input",{id:"hermes-timeoutMs",type:"number",min:1e3,step:1e3,value:n.cliTimeoutMs,onChange:y=>o(z=>({...z,cliTimeoutMs:Number(y.target.value)||Fe.cliTimeoutMs}))}),e.jsx("small",{children:"Fusion-side hard cap. Default 5 min."})]})]})}const ws="fusion-plugin-openclaw-runtime",Si="https://docs.openclaw.ai/",Pi="https://github.com/openclaw/openclaw",kl=["off","minimal","low","medium","high","xhigh","adaptive","max"],Me={binaryPath:"",agentId:"main",model:"",thinking:"off",useGateway:!1,cliTimeoutSec:0,cliTimeoutMs:3e5};function Ai(n){return{binaryPath:typeof n.binaryPath=="string"?n.binaryPath:Me.binaryPath,agentId:typeof n.agentId=="string"?n.agentId:Me.agentId,model:typeof n.model=="string"?n.model:Me.model,thinking:kl.includes(n.thinking)?n.thinking:Me.thinking,useGateway:typeof n.useGateway=="boolean"?n.useGateway:Me.useGateway,cliTimeoutSec:typeof n.cliTimeoutSec=="number"?n.cliTimeoutSec:Me.cliTimeoutSec,cliTimeoutMs:typeof n.cliTimeoutMs=="number"?n.cliTimeoutMs:Me.cliTimeoutMs}}function Fi(){const[n,o]=r.useState(Me),[u,k]=r.useState(null),[C,w]=r.useState(null),[I,j]=r.useState(null),R=r.useRef(!0);r.useEffect(()=>(R.current=!0,()=>{R.current=!1}),[]),r.useEffect(()=>{w("loading"),Ds(ws).then(p=>{R.current&&o(Ai(p))}).catch(()=>{}).finally(()=>{R.current&&w(null)})},[]);const E=r.useCallback(async()=>{try{const p=await Lr(n.binaryPath?{binaryPath:n.binaryPath}:void 0);return R.current&&k(p),p}catch(p){return R.current&&j({kind:"err",message:p instanceof Error?p.message:String(p)}),null}},[n.binaryPath]);r.useEffect(()=>{E()},[E]);const S=r.useCallback(()=>({binaryPath:n.binaryPath,agentId:n.agentId,model:n.model,thinking:n.thinking,useGateway:n.useGateway,cliTimeoutSec:n.cliTimeoutSec,cliTimeoutMs:n.cliTimeoutMs}),[n]),B=r.useCallback(async()=>{w("testing"),j(null);const p=await E();R.current&&(w(null),p?p.binary.available?j({kind:"ok",message:`✓ openclaw detected${p.binary.version?` (${p.binary.version})`:""}${p.binary.binaryPath?` at ${p.binary.binaryPath}`:""}.`}):j({kind:"err",message:`✗ ${p.binary.reason??"openclaw not found"}`}):j({kind:"err",message:"Test failed — see status above."}))},[E]),q=r.useCallback(async()=>{w("saving"),j(null);try{await et(ws,S()),R.current&&j({kind:"ok",message:"Settings saved."})}catch(p){R.current&&j({kind:"err",message:p instanceof Error?p.message:String(p)})}finally{R.current&&w(null)}},[S]),P=r.useCallback(async()=>{w("save-test"),j(null);try{await et(ws,S());const p=await E();if(!R.current)return;p?p.binary.available?j({kind:"ok",message:`Saved · ✓ openclaw detected${p.binary.version?` (${p.binary.version})`:""}${p.binary.binaryPath?` at ${p.binary.binaryPath}`:""}.`}):j({kind:"err",message:`Saved · ✗ ${p.binary.reason??"openclaw not found"}`}):j({kind:"err",message:"Saved, but probe failed."})}catch(p){R.current&&j({kind:"err",message:p instanceof Error?p.message:String(p)})}finally{R.current&&w(null)}},[S,E]),_=u?.binary,H=u===null?"loading":_?.available?"ok":"err",A=u===null?"Probing local openclaw binary…":_?.available?`✓ Detected${_.version?` ${_.version}`:""}${_.binaryPath?` · ${_.binaryPath}`:""}`:`✗ ${_?.reason??"not detected on PATH"}`;return e.jsxs(Ls,{testId:"openclaw-runtime-card",logo:e.jsx(jt,{provider:"openclaw",size:"lg"}),name:"OpenClaw",learnMoreHref:Si,statusKind:H,statusText:A,description:e.jsxs(e.Fragment,{children:["Drives the local ",e.jsx("code",{children:"openclaw"})," CLI as a subprocess. Each Fusion prompt is dispatched via"," ",e.jsx("code",{children:"openclaw agent --local --json"}),"; the agent definition, model, and thinking level are resolved by OpenClaw. This card only sets overrides and the binary path."]}),busy:C,toast:I,onTest:()=>void B(),onSave:()=>void q(),onSaveAndTest:()=>void P(),belowForm:_?.available===!1?e.jsxs("div",{className:"onboarding-helper-text",children:[e.jsxs("p",{children:[e.jsx("code",{children:"openclaw"})," not detected. Install the upstream agent:"]}),e.jsx("pre",{children:e.jsx("code",{children:"npm install -g openclaw"})}),e.jsx("p",{children:e.jsx("a",{href:Pi,target:"_blank",rel:"noreferrer",children:"openclaw on GitHub"})})]}):null,children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openclaw-binaryPath",children:"Binary path"}),e.jsx("input",{id:"openclaw-binaryPath",type:"text",placeholder:"openclaw (defaults to PATH)",value:n.binaryPath,onChange:p=>o(O=>({...O,binaryPath:p.target.value}))}),e.jsxs("small",{children:["Leave blank to resolve ",e.jsx("code",{children:"openclaw"})," from your PATH."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openclaw-agentId",children:"Agent ID"}),e.jsx("input",{id:"openclaw-agentId",type:"text",placeholder:"main",value:n.agentId,onChange:p=>o(O=>({...O,agentId:p.target.value}))}),e.jsxs("small",{children:["OpenClaw agent definition to run (default: ",e.jsx("code",{children:"main"}),")."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openclaw-model",children:"Model override"}),e.jsx("input",{id:"openclaw-model",type:"text",placeholder:"e.g. anthropic/claude-haiku-4-5, minimax/MiniMax-M2.7",value:n.model,onChange:p=>o(O=>({...O,model:p.target.value}))}),e.jsx("small",{children:"Optional — overrides the OpenClaw default model."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openclaw-thinking",children:"Thinking level"}),e.jsx("select",{id:"openclaw-thinking",value:n.thinking,onChange:p=>o(O=>({...O,thinking:p.target.value})),children:kl.map(p=>e.jsx("option",{value:p,children:p},p))}),e.jsx("small",{children:"Controls how much extended thinking the model uses."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"openclaw-useGateway",style:{display:"inline-flex",alignItems:"center",gap:"var(--space-xs)"},children:[e.jsx("input",{id:"openclaw-useGateway",type:"checkbox",checked:n.useGateway,onChange:p=>o(O=>({...O,useGateway:p.target.checked}))}),"Route through OpenClaw gateway (otherwise embedded)"]}),e.jsx("small",{children:"When enabled, calls pass through the OpenClaw gateway service."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openclaw-cliTimeoutSec",children:"OpenClaw timeout (sec)"}),e.jsx("input",{id:"openclaw-cliTimeoutSec",type:"number",min:0,step:1,value:n.cliTimeoutSec,onChange:p=>o(O=>({...O,cliTimeoutSec:parseInt(p.target.value,10)||0}))}),e.jsx("small",{children:"OpenClaw-side run timeout in seconds (0 = no timeout)."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openclaw-cliTimeoutMs",children:"CLI subprocess timeout (ms)"}),e.jsx("input",{id:"openclaw-cliTimeoutMs",type:"number",min:0,step:1e3,value:n.cliTimeoutMs,onChange:p=>o(O=>({...O,cliTimeoutMs:parseInt(p.target.value,10)||Me.cliTimeoutMs}))}),e.jsxs("small",{children:["Fusion-side hard cap before the CLI subprocess is killed (default:"," ",Me.cliTimeoutMs/1e3,"s)."]})]})]})}const Ss="fusion-plugin-paperclip-runtime",tl="https://paperclip.ing/",Mi="https://github.com/paperclipai/paperclip",sl=[{value:"rolling-issue",label:"Rolling issue (default)",help:"One Paperclip issue per Fusion session; subsequent prompts are added as comments. Closest to a chat experience."},{value:"issue-per-prompt",label:"Issue per prompt",help:"Each prompt creates a new top-level Paperclip issue. Maximally explicit; tends to clutter the board."},{value:"wakeup-only",label:"Wakeup only (advanced)",help:"No issue side-effects; the prompt is delivered via the wakeup payload only. Requires the agent's prompt template to know how to handle a payload-driven wake."}],be={transport:"api",apiUrl:"http://localhost:3100",apiKey:"",cliBinaryPath:"paperclipai",cliConfigPath:"",agentId:"",companyId:"",mode:"rolling-issue",parentIssueId:"",projectId:"",goalId:"",runTimeoutMs:6e5},Ti=new Set(["issue-per-prompt","rolling-issue","wakeup-only"]);function Ii(n){const o=(w,I)=>typeof n[w]=="string"?n[w]:I,u=(w,I)=>typeof n[w]=="number"?n[w]:I,k=n.transport==="cli"?"cli":"api",C=Ti.has(n.mode)?n.mode:be.mode;return{transport:k,apiUrl:o("apiUrl",be.apiUrl),apiKey:o("apiKey",be.apiKey),cliBinaryPath:o("cliBinaryPath",be.cliBinaryPath),cliConfigPath:o("cliConfigPath",be.cliConfigPath),agentId:o("agentId",be.agentId),companyId:o("companyId",be.companyId),mode:C,parentIssueId:o("parentIssueId",be.parentIssueId),projectId:o("projectId",be.projectId),goalId:o("goalId",be.goalId),runTimeoutMs:u("runTimeoutMs",be.runTimeoutMs)}}function Ri(){const[n,o]=r.useState(be),[u,k]=r.useState(null),[C,w]=r.useState(null),[I,j]=r.useState([]),[R,E]=r.useState([]),[S,B]=r.useState(null),[q,P]=r.useState(null),[_,H]=r.useState(!1),A=r.useRef(!0);r.useEffect(()=>(A.current=!0,()=>{A.current=!1}),[]);const p=r.useMemo(()=>n.transport==="cli"&&C&&C.ok?{apiUrl:C.apiUrl,apiKey:n.apiKey||C.apiKey||void 0}:{apiUrl:n.apiUrl,apiKey:n.apiKey||void 0},[n.transport,n.apiUrl,n.apiKey,C]);r.useEffect(()=>{B("loading"),Ds(Ss).then(b=>{A.current&&o(Ii(b))}).catch(()=>{}).finally(()=>{A.current&&B(null)})},[]),r.useEffect(()=>{if(n.transport!=="cli"){w(null);return}let b=!1;return Or({cliConfigPath:n.cliConfigPath||void 0}).then(F=>{!b&&A.current&&w(F)}).catch(()=>{!b&&A.current&&w({ok:!1,reason:"Discovery request failed"})}),()=>{b=!0}},[n.transport,n.cliConfigPath]);const O=n.transport==="cli",y=r.useMemo(()=>({cliBinaryPath:n.cliBinaryPath||void 0,cliConfigPath:n.cliConfigPath||void 0}),[n.cliBinaryPath,n.cliConfigPath]),z=r.useCallback(async()=>{if(!O&&!p.apiUrl)return null;try{const b=O?await Br(y):await $r(p);A.current&&k(b);const F=O?await _r(y):await Gr(p);if(!A.current)return b;j(F);let Q=n.companyId;if(F.some(ae=>ae.id===Q)||(Q=b.connection.identity?.companyId??F[0]?.id??"",Q&&Q!==n.companyId&&o(ae=>({...ae,companyId:Q}))),Q){const ae=O?await Da({...y,companyId:Q}):await La({...p,companyId:Q});if(A.current&&(E(ae),!ae.some(M=>M.id===n.agentId))){const M=b.connection.identity?.agentId??ae[0]?.id??"";M&&M!==n.agentId&&o(ie=>({...ie,agentId:M}))}}else A.current&&E([]);return b}catch(b){return A.current&&P({kind:"err",message:b instanceof Error?b.message:String(b)}),null}},[O,y,p.apiUrl,p.apiKey,n.companyId,n.agentId]);r.useEffect(()=>{z()},[z]),r.useEffect(()=>{if(!n.companyId){E([]);return}if(!O&&!p.apiUrl){E([]);return}let b=!1;return(O?Da({...y,companyId:n.companyId}):La({...p,companyId:n.companyId})).then(Q=>{!b&&A.current&&E(Q)}).catch(()=>{!b&&A.current&&E([])}),()=>{b=!0}},[O,y,p.apiUrl,p.apiKey,n.companyId]);const J=r.useCallback(()=>{const b={transport:n.transport,mode:n.mode,parentIssueId:n.parentIssueId,projectId:n.projectId,goalId:n.goalId,runTimeoutMs:n.runTimeoutMs,agentId:n.agentId,companyId:n.companyId};return n.transport==="api"?b.apiUrl=n.apiUrl:(b.cliBinaryPath=n.cliBinaryPath,n.cliConfigPath&&(b.cliConfigPath=n.cliConfigPath)),_&&(b.apiKey=n.apiKey),b},[n,_]),le=r.useCallback(async()=>{B("testing"),P(null);const b=await z();if(A.current)if(B(null),!b)n.transport==="cli"&&C&&!C.ok?P({kind:"err",message:`✗ CLI discovery failed: ${C.reason}`}):P({kind:"err",message:"Test failed — see status above."});else if(b.connection.available){const F=b.connection.identity;P({kind:"ok",message:F?`✓ Connected as ${F.agentName}${F.companyName?` at ${F.companyName}`:""}.`:"✓ Connected."})}else P({kind:"err",message:`✗ ${b.connection.reason??"Paperclip server unreachable"}`})},[z,n.transport,C]),te=r.useCallback(async()=>{B("saving"),P(null);try{await et(Ss,J()),A.current&&(P({kind:"ok",message:"Settings saved."}),H(!1))}catch(b){A.current&&P({kind:"err",message:b instanceof Error?b.message:String(b)})}finally{A.current&&B(null)}},[J]),a=r.useCallback(async()=>{B("save-test"),P(null);try{await et(Ss,J()),A.current&&H(!1);const b=await z();if(!A.current)return;if(!b)n.transport==="cli"&&C&&!C.ok?P({kind:"err",message:`Saved · ✗ CLI discovery failed: ${C.reason}`}):P({kind:"err",message:"Saved, but probe failed."});else if(b.connection.available){const F=b.connection.identity;P({kind:"ok",message:F?`Saved · ✓ Connected as ${F.agentName}${F.companyName?` at ${F.companyName}`:""}.`:"Saved · ✓ Connected."})}else P({kind:"err",message:`Saved · ✗ ${b.connection.reason??"Paperclip server unreachable"}`})}catch(b){A.current&&P({kind:"err",message:b instanceof Error?b.message:String(b)})}finally{A.current&&B(null)}},[J,z,n.transport,C]),i=u?.connection.available??null,W=u?.connection.identity,se=C?.ok===!0,je=u===null?"loading":i?"ok":"err",ye=u===null?n.transport==="cli"&&C&&!se?`✗ CLI discovery failed: ${C.reason}`:"Probing Paperclip server…":i?W?`✓ Connected as ${W.agentName}${W.role?` (${W.role})`:""}${W.companyName?` at ${W.companyName}`:""}`:"✓ Connected":`✗ ${u.connection.reason??"Unreachable"}`,fe=e.jsxs("div",{className:"runtime-card__tabs",role:"tablist","aria-label":"Paperclip connection mode",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":n.transport==="api",className:"runtime-card__tab",onClick:()=>o(b=>({...b,transport:"api"})),children:"API (URL + token)"}),e.jsx("button",{type:"button",role:"tab","aria-selected":n.transport==="cli",className:"runtime-card__tab",onClick:()=>o(b=>({...b,transport:"cli"})),children:"Local CLI (auto-derive)"})]});return e.jsxs(Ls,{testId:"paperclip-runtime-card",logo:e.jsx(jt,{provider:"paperclip",size:"lg"}),name:"Paperclip",learnMoreHref:tl,statusKind:je,statusText:ye,description:e.jsx(e.Fragment,{children:'Drive a Paperclip agent ("employee") in a Paperclip company. Each prompt dispatches a task-shaped request; governance, budgets, and approvals are enforced by Paperclip. Expect seconds-to-minutes latency per turn.'}),tabs:fe,busy:S,toast:q,onTest:()=>void le(),onSave:()=>void te(),onSaveAndTest:()=>void a(),belowForm:i===!1?e.jsxs("div",{className:"onboarding-helper-text",children:[e.jsx("p",{children:"Make sure a Paperclip server is running. To install Paperclip:"}),e.jsx("pre",{children:e.jsx("code",{children:"npm install -g paperclipai"})}),e.jsxs("p",{children:[e.jsx("a",{href:tl,target:"_blank",rel:"noreferrer",children:"Paperclip docs"})," ","·"," ",e.jsx("a",{href:Mi,target:"_blank",rel:"noreferrer",children:"GitHub"})]})]}):null,children:[n.transport==="cli"&&C&&e.jsx("div",{className:"settings-muted",style:{marginBottom:"var(--space-sm)"},children:se?e.jsxs("small",{children:["CLI config: ",e.jsx("code",{children:C.configPath})," ","· resolved ",e.jsx("code",{children:C.apiUrl}),C.deploymentMode?` · ${C.deploymentMode}`:""]}):e.jsxs("small",{children:["CLI discovery failed: ",C.reason]})}),n.transport==="api"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-apiUrl",children:"API URL"}),e.jsx("input",{id:"paperclip-apiUrl",type:"text",placeholder:"http://localhost:3100",value:n.apiUrl,onChange:b=>o(F=>({...F,apiUrl:b.target.value}))}),e.jsx("small",{children:"Base URL of the Paperclip server."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-apiKey",children:"API key"}),e.jsx("input",{id:"paperclip-apiKey",type:"password",placeholder:_?"":"•••••••• (leave blank to keep existing)",value:n.apiKey,onChange:b=>{o(F=>({...F,apiKey:b.target.value})),H(!0)}}),e.jsx("small",{children:"Agent API key. Local-trusted deployments may leave this blank."})]})]}),n.transport==="cli"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-cliBinaryPath",children:"paperclipai binary"}),e.jsx("input",{id:"paperclip-cliBinaryPath",type:"text",placeholder:"paperclipai",value:n.cliBinaryPath,onChange:b=>o(F=>({...F,cliBinaryPath:b.target.value}))}),e.jsx("small",{children:"Optional — informational; the adapter currently reads the instance config file directly."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-cliConfigPath",children:"Instance config path"}),e.jsx("input",{id:"paperclip-cliConfigPath",type:"text",placeholder:"~/.paperclip/instances/default/config.json",value:n.cliConfigPath,onChange:b=>o(F=>({...F,cliConfigPath:b.target.value}))}),e.jsxs("small",{children:["Override the path to ",e.jsx("code",{children:"config.json"}),". Leave blank for the default."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-cli-apikey",children:"API key (override, optional)"}),e.jsx("input",{id:"paperclip-cli-apikey",type:"password",placeholder:_?"":"Optional — only required for non-local-trusted modes",value:n.apiKey,onChange:b=>{o(F=>({...F,apiKey:b.target.value})),H(!0)}}),e.jsx("small",{children:"Local-trusted deployments do not require a key."}),u!==null&&i===!1&&n.agentId&&e.jsx("button",{type:"button",className:"btn btn--sm",style:{marginTop:"0.4rem"},disabled:S!==null,onClick:async()=>{const b=n.agentId,F=n.companyId.trim();if(!b||!F){P({kind:"err",message:"✗ Company ID is required to mint a Paperclip API key."});return}B("testing"),P(null);const Q=await Ur({cliBinaryPath:n.cliBinaryPath||void 0,agentRef:b,companyId:F,keyName:"fusion-runtime",configPath:n.cliConfigPath||void 0});A.current&&(B(null),Q.ok?(o(ae=>({...ae,apiKey:Q.key.apiKey})),H(!0),P({kind:"ok",message:`✓ API key minted via paperclipai (key 'fusion-runtime' installed for agent ${b}). Click Save to persist.`}),z()):P({kind:"err",message:`✗ Mint failed: ${Q.reason}. Run \`paperclipai onboard\` first if your CLI isn't authenticated.`}))},children:"✨ Mint API key via paperclipai"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-companyId",children:"Company"}),e.jsx("select",{id:"paperclip-companyId",value:n.companyId,onChange:b=>o(F=>({...F,companyId:b.target.value})),disabled:I.length===0,children:I.length===0?e.jsx("option",{value:"",children:i?"No companies discovered":"Connect to populate"}):I.map(b=>e.jsxs("option",{value:b.id,children:[b.name," (",b.id,")"]},b.id))}),e.jsx("small",{children:"Select a Paperclip company."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-agentId",children:"Agent"}),e.jsx("select",{id:"paperclip-agentId",value:n.agentId,onChange:b=>o(F=>({...F,agentId:b.target.value})),disabled:R.length===0,children:R.length===0?e.jsx("option",{value:"",children:n.companyId?"No agents discovered":"Pick a company first"}):R.map(b=>e.jsxs("option",{value:b.id,children:[b.name,b.role?` (${b.role})`:""]},b.id))}),e.jsx("small",{children:"Pick the Paperclip agent this Fusion runtime will proxy."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-mode",children:"Conversation mode"}),e.jsx("select",{id:"paperclip-mode",value:n.mode,onChange:b=>o(F=>({...F,mode:b.target.value})),children:sl.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))}),e.jsx("small",{children:sl.find(b=>b.value===n.mode)?.help})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-projectId",children:"Project ID (optional)"}),e.jsx("input",{id:"paperclip-projectId",type:"text",placeholder:"Optional",value:n.projectId,onChange:b=>o(F=>({...F,projectId:b.target.value}))}),e.jsx("small",{children:"Pin work to a specific Paperclip project."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-parentIssueId",children:"Parent issue ID (optional)"}),e.jsx("input",{id:"paperclip-parentIssueId",type:"text",placeholder:"Optional",value:n.parentIssueId,onChange:b=>o(F=>({...F,parentIssueId:b.target.value}))}),e.jsx("small",{children:"Scope work under an existing parent issue."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-goalId",children:"Goal ID (optional)"}),e.jsx("input",{id:"paperclip-goalId",type:"text",placeholder:"Optional",value:n.goalId,onChange:b=>o(F=>({...F,goalId:b.target.value}))}),e.jsx("small",{children:"Associate work with a Paperclip goal."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"paperclip-runTimeoutMs",children:"Run timeout (ms)"}),e.jsx("input",{id:"paperclip-runTimeoutMs",type:"number",min:0,step:1e3,value:n.runTimeoutMs,onChange:b=>o(F=>({...F,runTimeoutMs:parseInt(b.target.value,10)||be.runTimeoutMs}))}),e.jsx("small",{children:"Local cap before Fusion gives up on a Paperclip run."})]})]})}const Ze=[{id:"default-executor",name:"Default Executor",description:"Standard task execution agent with full tooling and review support.",role:"executor",prompt:`You are a task execution agent for "fn", an AI-orchestrated task board.
|
|
18
|
+
|
|
19
|
+
You are working in a git worktree isolated from the main branch. Your job is to implement the task described in the PROMPT.md specification you're given.`,builtIn:!0},{id:"default-triage",name:"Default Triage",description:"Standard task specification agent producing detailed PROMPT.md files.",role:"triage",prompt:`You are a task specification agent for "fn", an AI-orchestrated task board.
|
|
20
|
+
|
|
21
|
+
Your job: take a rough task description and produce a fully specified PROMPT.md that another AI agent can execute autonomously.`,builtIn:!0},{id:"default-reviewer",name:"Default Reviewer",description:"Standard independent code and plan reviewer with balanced criteria.",role:"reviewer",prompt:`You are an independent code and plan reviewer.
|
|
22
|
+
|
|
23
|
+
You provide quality assessment for task implementations with full read access to the codebase.`,builtIn:!0},{id:"default-merger",name:"Default Merger",description:"Standard merge agent for squash merges with conflict resolution.",role:"merger",prompt:`You are a merge agent for "fn", an AI-orchestrated task board.
|
|
24
|
+
|
|
25
|
+
Your job is to finalize a squash merge: resolve any conflicts and write a good commit message.`,builtIn:!0},{id:"senior-engineer",name:"Senior Engineer",description:"Autonomous executor with architectural awareness, performance focus, and minimal hand-holding.",role:"executor",prompt:`You are a senior engineering agent for "fn", an AI-orchestrated task board.
|
|
26
|
+
|
|
27
|
+
You operate with a high degree of autonomy, making architectural decisions and balancing trade-offs independently.`,builtIn:!0},{id:"strict-reviewer",name:"Strict Reviewer",description:"Rigorous reviewer with stricter criteria for security, edge cases, and type safety.",role:"reviewer",prompt:`You are a strict code and plan reviewer with rigorous standards.
|
|
28
|
+
|
|
29
|
+
You hold all submissions to a high bar for correctness, security, and maintainability.`,builtIn:!0},{id:"concise-triage",name:"Concise Triage",description:"Shorter, more focused specification format with minimal prose.",role:"triage",prompt:`You are a task specification agent for "fn". Produce a concise, actionable PROMPT.md from the given task description.
|
|
30
|
+
|
|
31
|
+
Be brief and precise — avoid verbosity.`,builtIn:!0}],Ei={"executor-welcome":{key:"executor-welcome",name:"Executor Welcome",roles:["executor"],description:"Introductory section for the executor agent",defaultContent:"You are a task execution agent..."},"executor-guardrails":{key:"executor-guardrails",name:"Executor Guardrails",roles:["executor"],description:"Behavioral guardrails and constraints for the executor",defaultContent:"Treat the File Scope in PROMPT.md..."},"executor-spawning":{key:"executor-spawning",name:"Executor Spawning",roles:["executor"],description:"Instructions for spawning child agents",defaultContent:"You can spawn child agents..."},"executor-completion":{key:"executor-completion",name:"Executor Completion",roles:["executor"],description:"Completion criteria and signaling for executor",defaultContent:"After all steps are done..."},"triage-welcome":{key:"triage-welcome",name:"Triage Welcome",roles:["triage"],description:"Introductory section for the triage/specification agent",defaultContent:"You are a task specification agent..."},"triage-context":{key:"triage-context",name:"Triage Context",roles:["triage"],description:"Context-gathering instructions for triage",defaultContent:"What you receive: A raw task title..."},"reviewer-verdict":{key:"reviewer-verdict",name:"Reviewer Verdict",roles:["reviewer"],description:"Verdict criteria and format for code/review agent",defaultContent:"APPROVE — Step will achieve its stated outcomes..."},"merger-conflicts":{key:"merger-conflicts",name:"Merger Conflicts",roles:["merger"],description:"Merge conflict resolution instructions for merger",defaultContent:"If there are merge conflicts..."},"agent-generation-system":{key:"agent-generation-system",name:"Agent Generation System",roles:["executor"],description:"System prompt for generating agent specifications",defaultContent:"You are an agent specification generator..."},"workflow-step-refine":{key:"workflow-step-refine",name:"Workflow Step Refine",roles:["executor"],description:"System prompt for refining workflow step descriptions",defaultContent:"You are an expert at creating detailed agent prompts..."},"planning-system":{key:"planning-system",name:"Planning System",roles:["triage"],description:"System prompt for the AI planning assistant",defaultContent:"You are a planning assistant for the fn task board system..."},"subtask-breakdown-system":{key:"subtask-breakdown-system",name:"Subtask Breakdown System",roles:["executor"],description:"System prompt for AI subtask decomposition",defaultContent:"You are a task decomposition assistant..."},"mission-interview-system":{key:"mission-interview-system",name:"Mission Interview System",roles:["triage"],description:"System prompt for AI-assisted mission planning",defaultContent:"You are a mission planning assistant..."},"ai-refine-system":{key:"ai-refine-system",name:"AI Refine System",roles:["executor"],description:"System prompt for AI-powered text refinement",defaultContent:"You are a text refinement assistant..."},"agent-onboarding-system":{key:"agent-onboarding-system",name:"Agent Onboarding System",roles:["executor"],description:"System prompt for AI-guided agent onboarding interview",defaultContent:"You are an agent onboarding assistant for the fn task board system..."}},al=["executor","triage","reviewer","merger"],gt={executor:"Executor Agent",triage:"Triage Agent",reviewer:"Reviewer Agent",merger:"Merger Agent",scheduler:"Scheduler Agent",engineer:"Engineer Agent",custom:"Custom Agent"},bt=n=>`prompt-role-tone--${n}`,Ps={name:"",description:"",role:"executor",prompt:""};function Di(n,o){const u=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,50),k=new Set(Ze.map(I=>I.id)),C=new Set(o.map(I=>I.id));if(!k.has(u)&&!C.has(u))return u;let w=2;for(;k.has(`${u}-${w}`)||C.has(`${u}-${w}`);)w++;return`${u}-${w}`}function Li({value:n,onChange:o,promptOverrides:u,onPromptOverridesChange:k}){const[C,w]=r.useState("templates"),[I,j]=r.useState(null),[R,E]=r.useState(!1),[S,B]=r.useState(Ps),[q,P]=r.useState(null),[_,H]=r.useState(null),[A,p]=r.useState(new Set),[O,y]=r.useState(null),[z,J]=r.useState(!1),[le,te]=r.useState(null),a=r.useRef(null),i=n?.templates??[],W=n?.roleAssignments??{},se=le===null?null:le.source==="builtin"?Ze.find(m=>m.id===le.id):i.find(m=>m.id===le.id),je=r.useCallback(m=>{const v=Ze.filter(U=>U.role===m),L=i.filter(U=>U.role===m);return[...v,...L]},[i]);r.useEffect(()=>{le!==null&&a.current?.focus()},[le]);const ye=r.useCallback(()=>{E(!0),j(null),B(Ps),P(null),te(null)},[]),fe=r.useCallback(m=>{j(m.id),E(!1),B({name:m.name,description:m.description,role:m.role,prompt:m.prompt}),P(null),te(null)},[]),b=r.useCallback(()=>{j(null),E(!1),B(Ps),P(null),te(null),J(!1)},[]),F=r.useCallback(()=>{const m=S.name.trim();if(!m){P("Template name is required");return}let v;if(R){if(v=Di(m,i),new Set(Ze.map(ke=>ke.id)).has(v)){P(`Template ID "${v}" conflicts with a built-in template. Please use a different name.`);return}}else v=I;const L={id:v,name:m,description:S.description.trim(),role:S.role,prompt:S.prompt,builtIn:!1};let U;R?U=[...i,L]:U=i.map($=>$.id===v?L:$);const V={...W};for(const[$,ke]of Object.entries(V))ke===v&&S.role!==$&&delete V[$];o({...n,templates:U,roleAssignments:Object.keys(V).length>0?V:void 0}),b()},[S,R,I,i,W,n,o,b]),Q=r.useCallback(m=>{const v=i.filter(V=>V.id!==m),L={...W};let U=!1;for(const[V,$]of Object.entries(L))$===m&&(delete L[V],U=!0);o({...n,templates:v.length>0?v:void 0,roleAssignments:Object.keys(L).length>0||U?Object.keys(L).length>0?L:void 0:W}),H(null),I===m&&b()},[i,W,n,o,I,b]),ae=r.useCallback((m,v)=>{const L={...W};v===""?delete L[m]:L[m]=v,o({...n,roleAssignments:Object.keys(L).length>0?L:void 0})},[W,n,o]),M=r.useCallback((m,v)=>{const L={...u};L[m]=v||null,k(L)},[u,k]),ie=r.useCallback(m=>{const v={...u};v[m]=null,k(v)},[u,k]),re=r.useCallback(m=>{p(v=>{const L=new Set(v);return L.has(m)?L.delete(m):L.add(m),L})},[]),Ue=r.useCallback(m=>{y(v=>v===m?null:m)},[]),ze=r.useCallback((m,v)=>{J(!1),te({source:m,id:v})},[]),tt=r.useCallback(()=>{te(null),J(m=>!m)},[]),Ce=m=>Ze.some(v=>v.id===m);return e.jsxs("div",{className:"prompt-manager",children:[e.jsxs("div",{className:"prompt-manager-tabs",children:[e.jsxs("button",{type:"button",className:`prompt-manager-tab ${C==="templates"?"active":""}`,onClick:()=>w("templates"),"data-testid":"tab-templates",children:[e.jsx(zr,{size:14}),"Templates"]}),e.jsxs("button",{type:"button",className:`prompt-manager-tab ${C==="assignments"?"active":""}`,onClick:()=>w("assignments"),"data-testid":"tab-assignments",children:[e.jsx(di,{size:14}),"Assignments"]}),e.jsxs("button",{type:"button",className:`prompt-manager-tab ${C==="overrides"?"active":""}`,onClick:()=>w("overrides"),"data-testid":"tab-overrides",children:[e.jsx(bi,{size:14}),"Overrides"]})]}),e.jsxs("div",{className:"prompt-manager-content",children:[C==="templates"&&e.jsxs("div",{className:"prompt-manager-templates-tab","data-testid":"templates-tab",children:[(R||I!==null)&&e.jsxs("div",{className:"prompt-template-editor","data-testid":"template-editor",children:[e.jsx("h4",{className:"prompt-template-editor-title",children:R?"New Custom Template":"Edit Custom Template"}),e.jsxs("div",{className:"prompt-template-editor-fields",children:[e.jsxs("div",{className:"prompt-template-field",children:[e.jsx("label",{htmlFor:"template-name",children:"Name"}),e.jsx("input",{id:"template-name",type:"text",value:S.name,onChange:m=>B(v=>({...v,name:m.target.value})),placeholder:"e.g. My Custom Executor","data-testid":"template-name-input"})]}),e.jsxs("div",{className:"prompt-template-field",children:[e.jsx("label",{htmlFor:"template-description",children:"Description"}),e.jsx("input",{id:"template-description",type:"text",value:S.description,onChange:m=>B(v=>({...v,description:m.target.value})),placeholder:"Brief description of this template","data-testid":"template-description-input"})]}),e.jsxs("div",{className:"prompt-template-field",children:[e.jsx("label",{htmlFor:"template-role",children:"Role"}),e.jsx("select",{id:"template-role",value:S.role,onChange:m=>B(v=>({...v,role:m.target.value})),"data-testid":"template-role-select",children:al.map(m=>e.jsx("option",{value:m,children:gt[m]},m))})]}),e.jsxs("div",{className:"prompt-template-field",children:[e.jsxs("div",{className:"prompt-template-prompt-label-row",children:[e.jsx("label",{htmlFor:"template-prompt",children:"Prompt"}),e.jsx("button",{type:"button",className:"btn-icon prompt-template-fullscreen-btn",onClick:tt,"aria-label":"Expand prompt to fullscreen","data-testid":"template-prompt-fullscreen",children:e.jsx(Lt,{size:14})})]}),z?e.jsxs("div",{className:"prompt-override-fullscreen",onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),J(!1))},children:[e.jsxs("div",{className:"prompt-override-fullscreen-header",children:[e.jsx("div",{className:"prompt-override-fullscreen-title",children:"Edit Prompt"}),e.jsxs("button",{type:"button",className:"prompt-override-fullscreen-close",onClick:()=>J(!1),"data-testid":"template-prompt-collapse",children:[e.jsx(fs,{size:14}),"Collapse"]})]}),e.jsx("textarea",{id:"template-prompt-fullscreen","aria-label":"Template prompt - fullscreen",className:"prompt-template-prompt-textarea",value:S.prompt,onChange:m=>B(v=>({...v,prompt:m.target.value})),placeholder:"Enter the system prompt for this template...",rows:30,autoFocus:!0,"data-testid":"template-prompt-input-fullscreen"}),e.jsx("div",{className:"prompt-override-footer",children:e.jsxs("small",{className:"prompt-override-hint",children:[S.prompt.length," characters"]})})]}):e.jsx("textarea",{id:"template-prompt",value:S.prompt,onChange:m=>B(v=>({...v,prompt:m.target.value})),placeholder:"Enter the system prompt for this template...",rows:8,className:"prompt-template-prompt-textarea","data-testid":"template-prompt-input"})]}),q&&e.jsx("div",{className:"prompt-template-error","data-testid":"template-error",children:q}),e.jsxs("div",{className:"prompt-template-editor-actions",children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:b,"data-testid":"cancel-template-btn",children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:F,"data-testid":"save-template-btn",children:R?"Create":"Save"})]})]})]}),e.jsxs("div",{className:"prompt-template-section","data-testid":"builtin-templates",children:[e.jsx("h4",{className:"prompt-template-section-title",children:"Built-in Templates"}),e.jsx("p",{className:"prompt-template-section-desc",children:"These templates are provided by Fusion and cannot be modified."}),e.jsx("div",{className:"prompt-template-list",children:Ze.map(m=>e.jsxs("div",{className:"prompt-template-card","data-testid":`builtin-template-${m.id}`,children:[e.jsxs("div",{className:"prompt-template-card-header",children:[e.jsxs("div",{className:"prompt-template-card-info",children:[e.jsx("span",{className:"prompt-template-card-name",children:m.name}),e.jsx("span",{className:`prompt-template-badge-built-in ${bt(m.role)}`,children:"Built-in"}),e.jsx("span",{className:`prompt-template-badge-role ${bt(m.role)}`,children:gt[m.role]})]}),e.jsx("div",{className:"prompt-template-card-actions",children:e.jsx("button",{type:"button",className:"btn-icon prompt-template-fullscreen-btn",onClick:()=>ze("builtin",m.id),title:"View full prompt","aria-label":`View full prompt for ${m.name}`,"data-testid":`expand-view-${m.id}`,children:e.jsx(Lt,{size:14})})})]}),e.jsx("p",{className:"prompt-template-card-description",children:m.description}),e.jsx("div",{className:"prompt-template-card-preview",children:e.jsx("code",{children:m.prompt})})]},m.id))})]}),e.jsxs("div",{className:"prompt-template-section","data-testid":"custom-templates",children:[e.jsx("h4",{className:"prompt-template-section-title",children:"Custom Templates"}),e.jsx("p",{className:"prompt-template-section-desc",children:"Create custom templates to override built-in prompts for specific roles."}),i.length===0&&!R&&e.jsx("div",{className:"prompt-template-empty",children:"No custom templates yet. Create one to get started."}),i.length>0&&e.jsx("div",{className:"prompt-template-list",children:i.map(m=>e.jsx("div",{className:"prompt-template-card","data-testid":`custom-template-${m.id}`,children:_===m.id?e.jsxs("div",{className:"prompt-template-delete-confirm",children:[e.jsxs("p",{children:['Delete "',m.name,'"?']}),e.jsxs("div",{className:"prompt-template-delete-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>Q(m.id),"data-testid":`confirm-delete-${m.id}`,children:"Delete"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>H(null),"data-testid":`cancel-delete-${m.id}`,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-template-card-header",children:[e.jsxs("div",{className:"prompt-template-card-info",children:[e.jsx("span",{className:"prompt-template-card-name",children:m.name}),e.jsx("span",{className:"prompt-template-badge-custom",children:"Custom"}),e.jsx("span",{className:`prompt-template-badge-role ${bt(m.role)}`,children:gt[m.role]}),Ce(m.id)&&e.jsx("span",{className:"prompt-template-badge-override",children:"Overrides built-in"})]}),e.jsxs("div",{className:"prompt-template-card-actions",children:[e.jsx("button",{type:"button",className:"btn-icon prompt-template-fullscreen-btn",onClick:()=>ze("custom",m.id),title:"View full prompt","aria-label":`View full prompt for ${m.name}`,"data-testid":`expand-view-${m.id}`,children:e.jsx(Lt,{size:14})}),e.jsx("button",{type:"button",className:"btn-icon",onClick:()=>fe(m),title:"Edit","aria-label":`Edit ${m.name}`,"data-testid":`edit-${m.id}`,children:e.jsx(bl,{size:14})}),e.jsx("button",{type:"button",className:"btn-icon",onClick:()=>H(m.id),title:"Delete","aria-label":`Delete ${m.name}`,"data-testid":`delete-${m.id}`,children:e.jsx(fl,{size:14})})]})]}),e.jsx("p",{className:"prompt-template-card-description",children:m.description}),e.jsx("div",{className:"prompt-template-card-preview",children:e.jsx("code",{children:m.prompt})})]})},m.id))}),!R&&I===null&&e.jsxs("button",{type:"button",className:"btn btn-primary prompt-template-add-btn",onClick:ye,"data-testid":"add-template-btn",children:[e.jsx(xl,{size:14}),"Add Custom Template"]})]}),se&&e.jsxs("div",{ref:a,className:"prompt-override-fullscreen",role:"dialog","aria-modal":"true",tabIndex:-1,onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),te(null))},children:[e.jsxs("div",{className:"prompt-override-fullscreen-header",children:[e.jsxs("div",{className:"prompt-override-fullscreen-title",children:[se.name,e.jsx("span",{className:`prompt-template-badge-role ${bt(se.role)}`,children:gt[se.role]})]}),e.jsxs("button",{type:"button",className:"prompt-override-fullscreen-close",onClick:()=>te(null),"data-testid":`collapse-view-${se.id}`,children:[e.jsx(fs,{size:14}),"Collapse"]})]}),e.jsx("pre",{className:"prompt-template-fullscreen-pre",children:se.prompt})]})]}),C==="assignments"&&e.jsxs("div",{className:"prompt-manager-assignments-tab","data-testid":"assignments-tab",children:[e.jsx("p",{className:"prompt-assignments-desc",children:"Assign specific templates to agent roles. When a role has an assignment, that template will be used instead of the default built-in."}),e.jsx("div",{className:"prompt-role-assignment-list",children:al.map(m=>{const v=je(m),L=W[m]??"",U=v.find($=>$.id===L),V=!!L;return e.jsxs("div",{className:"prompt-role-assignment-row","data-testid":`assignment-${m}`,children:[e.jsxs("div",{className:"prompt-role-assignment-label",children:[e.jsx("span",{className:`prompt-role-badge ${bt(m)}`,children:gt[m]}),V&&e.jsxs("span",{className:"prompt-role-assignment-status",children:[U?.name??"Custom"," (overrides default)"]})]}),e.jsxs("select",{className:"prompt-role-select",value:L,onChange:$=>ae(m,$.target.value),"data-testid":`select-${m}`,children:[e.jsx("option",{value:"",children:"Use default"}),v.map($=>e.jsxs("option",{value:$.id,children:[$.name,Ce($.id)?" (built-in)":" (custom)"]},$.id))]})]},m)})}),Object.keys(W).length>0&&e.jsxs("div",{className:"prompt-assignments-note",children:[e.jsx("strong",{children:"Note:"})," Role assignments are stored in the agentPrompts configuration. Custom templates override built-ins by ID."]})]}),C==="overrides"&&e.jsxs("div",{className:"prompt-manager-overrides-tab","data-testid":"overrides-tab",children:[e.jsx("p",{className:"prompt-overrides-desc",children:"Customize specific segments of AI agent prompts. Edits override built-in defaults. Use the Reset button to restore the original default for any prompt."}),e.jsx("div",{className:"prompt-overrides-list",children:Object.values(Ei).map(m=>{const v=m.key,L=u?.[v]??"",U=L!=="",V=A.has(v);return e.jsxs("div",{className:"prompt-override-item","data-testid":`override-${v}`,children:[e.jsxs("div",{className:"prompt-override-header",children:[e.jsxs("button",{type:"button",className:"prompt-override-info",onClick:()=>re(v),children:[e.jsx("span",{className:"prompt-override-name",children:m.name}),e.jsx("code",{className:"prompt-override-key",children:v}),U&&e.jsx("span",{className:"prompt-override-badge",children:"customized"})]}),e.jsxs("div",{className:"prompt-override-header-actions",children:[V&&e.jsx("button",{type:"button",className:"prompt-override-fullscreen-btn",onClick:$=>{$.stopPropagation(),Ue(v)},"aria-label":"Expand to fullscreen","data-testid":`fullscreen-${v}`,children:e.jsx(Lt,{size:14})}),e.jsx("button",{type:"button",className:"prompt-override-expand-btn","aria-label":V?"Collapse":"Expand","data-testid":`expand-${v}`,onClick:$=>{$.stopPropagation(),re(v)},children:V?e.jsx(qr,{size:16}):e.jsx(Hr,{size:16})})]})]}),e.jsx("p",{className:"prompt-override-description",children:m.description}),V&&(O===v?e.jsxs("div",{className:"prompt-override-fullscreen",onKeyDown:$=>{$.key==="Escape"&&($.preventDefault(),y(null))},children:[e.jsxs("div",{className:"prompt-override-fullscreen-header",children:[e.jsxs("div",{className:"prompt-override-fullscreen-title",children:[m.name,e.jsx("code",{className:"prompt-override-key",children:v})]}),e.jsxs("button",{type:"button",className:"prompt-override-fullscreen-close",onClick:()=>y(null),"data-testid":`collapse-fullscreen-${v}`,children:[e.jsx(fs,{size:14}),"Collapse"]})]}),e.jsx("textarea",{id:`prompt-${v}-fullscreen`,"aria-label":`${m.name} prompt override (${v}) - fullscreen`,className:"prompt-override-textarea",value:L,onChange:$=>{M(v,$.target.value)},placeholder:`Default: ${m.defaultContent.slice(0,100)}${m.defaultContent.length>100?"...":""}`,rows:30,autoFocus:!0,"data-testid":`override-input-fullscreen-${v}`}),e.jsxs("div",{className:"prompt-override-footer",children:[U&&e.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>ie(v),"data-testid":`reset-fullscreen-${v}`,children:"Reset"}),e.jsx("small",{className:"prompt-override-hint",children:U?"Custom override active. Click Reset to restore default.":`No override set. Using built-in default (${m.defaultContent.length} chars).`})]})]}):e.jsxs("div",{className:"prompt-override-editor",children:[e.jsx("textarea",{id:`prompt-${v}`,"aria-label":`${m.name} prompt override (${v})`,className:"prompt-override-textarea",value:L,onChange:$=>{M(v,$.target.value)},placeholder:`Default: ${m.defaultContent.slice(0,100)}${m.defaultContent.length>100?"...":""}`,rows:4,"data-testid":`override-input-${v}`}),e.jsxs("div",{className:"prompt-override-footer",children:[U&&e.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:$=>{$.stopPropagation(),ie(v)},"data-testid":`reset-${v}`,children:"Reset"}),e.jsx("small",{className:"prompt-override-hint",children:U?"Custom override active. Click Reset to restore default.":`No override set. Using built-in default (${m.defaultContent.length} chars).`})]})]}))]},v)})})]})]})]})}const Oi=["openai-compatible","openai-responses","anthropic-compatible","google-generative-ai"];function Bi(n){return(Array.isArray(n)?n:n.providers??[]).map(u=>"apiType"in u?u:{id:u.id,name:u.name?.trim()||u.id,apiType:u.api==="anthropic-messages"?"anthropic-compatible":u.api==="openai-responses"?"openai-responses":u.api==="google-generative-ai"?"google-generative-ai":"openai-compatible",baseUrl:u.baseUrl,...u.apiKey?{apiKey:u.apiKey}:{},models:(u.models??[]).map(k=>({id:k.id,name:k.name??k.id}))})}function $i(n){return n.split(",").map(o=>o.trim()).filter(Boolean).map(o=>({id:o,name:o}))}function _i({embedded:n=!1,onProviderChange:o}){const[u,k]=r.useState([]),[C,w]=r.useState(!1),[I,j]=r.useState(!1),[R,E]=r.useState(null),[S,B]=r.useState(null),[q,P]=r.useState(!1),[_,H]=r.useState(""),[A,p]=r.useState("openai-compatible"),[O,y]=r.useState(""),[z,J]=r.useState(""),[le,te]=r.useState(""),[a,i]=r.useState(!1),[W,se]=r.useState(null),[je,ye]=r.useState(!1),[fe,b]=r.useState(null),F=r.useCallback(async()=>{w(!0),E(null);try{const m=await Wr();k(Bi(m)),j(!0)}catch(m){E(m instanceof Error?m.message:"Failed to load custom providers.")}finally{w(!1)}},[]),Q=r.useCallback(m=>{m&&!I&&!C&&F()},[I,C,F]);r.useEffect(()=>{n&&!I&&!C&&F()},[n,I,C,F]);const ae=r.useCallback(()=>{B(null),H(""),p("openai-compatible"),y(""),J(""),te(""),se(null),b(null),ye(!1),P(!1)},[]),M=r.useCallback(()=>{B(null),H(""),p("openai-compatible"),y(""),J(""),te(""),se(null),b(null),ye(!1),P(!0)},[]),ie=r.useCallback(m=>{B(m),H(m.name),p(m.apiType),y(m.baseUrl),J(m.apiKey??""),te((m.models??[]).map(v=>v.id).join(", ")),se(null),b(null),ye(!1),P(!0)},[]),re=r.useCallback(()=>{if(!_.trim())return"Provider name is required.";if(!O.trim())return"Base URL is required.";let m=!1;try{const v=new URL(O.trim());m=v.protocol==="http:"||v.protocol==="https:"}catch{m=!1}return m?Oi.includes(A)?null:"API type is invalid.":"Base URL must be a valid http/https URL."},[A,O,_]),Ue=r.useCallback(async()=>{const m=O.trim();if(!m){b("Base URL is required to detect models.");return}ye(!0),b(null);try{const v=await Kr({baseUrl:m,apiKey:z.trim()||void 0,apiType:A});v.models.length>0?te(L=>{const U=new Set(L.split(",").map(ke=>ke.trim()).filter(Boolean)),V=v.models.map(ke=>ke.id.trim()).filter(ke=>!U.has(ke));if(V.length===0)return L;const $=L.trim();return V.join(", ")+($?", "+$:"")}):b("No models found. The provider may require an API key.")}catch(v){b(v instanceof Error?v.message:"Failed to detect models")}finally{ye(!1)}},[O,z,A]),ze=r.useCallback(async()=>{const m=re();if(se(m),m)return;const v=$i(le),L={name:_.trim(),apiType:A,baseUrl:O.trim(),...z.trim()?{apiKey:z.trim()}:{},...v.length>0?{models:v}:{}};i(!0),E(null);try{S?await Vr(S.id,L):await Yr(L),await F(),o?.(),ae()}catch(U){se(U instanceof Error?U.message:"Failed to save provider.")}finally{i(!1)}},[z,A,O,S,F,le,_,ae,re]),tt=r.useCallback(async m=>{if(window.confirm(`Delete custom provider "${m.name}"?`)){E(null);try{await Qr(m.id),await F(),o?.()}catch(v){E(v instanceof Error?v.message:"Failed to delete provider.")}}},[F,o]),Ce=e.jsxs(e.Fragment,{children:[n?null:C?e.jsxs("div",{className:"custom-provider-empty",role:"status",children:[e.jsx(Ve,{"aria-hidden":"true",className:"spin"})," Loading custom providers…"]}):null,n?null:!C&&R?e.jsxs("div",{className:"custom-provider-form-error",role:"alert",children:[e.jsx(Xr,{"aria-hidden":"true"}),e.jsx("span",{children:R})]}):null,!C&&u.length>0?e.jsx("div",{className:"custom-provider-list",children:u.map(m=>{const v=q&&S?.id===m.id;return e.jsxs("div",{children:[e.jsxs("div",{className:"auth-provider-card custom-provider-item",children:[e.jsxs("div",{className:"custom-provider-item-info",children:[e.jsx("div",{className:"custom-provider-item-name",children:m.name}),e.jsxs("div",{className:"custom-provider-item-meta",children:[e.jsx("span",{className:"custom-provider-badge",children:m.apiType})," ",m.baseUrl]})]}),e.jsxs("div",{className:"custom-provider-item-actions",children:[e.jsx("button",{type:"button",className:"btn btn-icon btn-sm",onClick:()=>ie(m),"aria-label":`Edit ${m.name}`,children:e.jsx(bl,{"aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"btn btn-icon btn-sm",onClick:()=>void tt(m),"aria-label":`Delete ${m.name}`,children:e.jsx(fl,{"aria-hidden":"true"})})]})]}),v?e.jsxs("div",{className:"custom-provider-form custom-provider-item-edit-form",children:[e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-name",children:"Provider name"}),e.jsx("input",{id:"custom-provider-name",className:"input",value:_,onChange:L=>H(L.target.value),disabled:a})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-api-type",children:"API type"}),e.jsxs("select",{id:"custom-provider-api-type",className:"select",value:A,onChange:L=>p(L.target.value),disabled:a,children:[e.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible"}),e.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),e.jsx("option",{value:"anthropic-compatible",children:"Anthropic-compatible"})]})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-base-url",children:"Base URL"}),e.jsx("input",{id:"custom-provider-base-url",className:"input",placeholder:"https://api.example.com/v1",value:O,onChange:L=>y(L.target.value),disabled:a})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-api-key",children:"API key"}),e.jsx("input",{id:"custom-provider-api-key",type:"password",className:"input",value:z,onChange:L=>J(L.target.value),disabled:a})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-models",children:"Available models"}),e.jsx("input",{id:"custom-provider-models",className:"input",placeholder:"e.g., gpt-4, gpt-3.5-turbo",value:le,onChange:L=>te(L.target.value),disabled:a})]}),e.jsx("div",{style:{display:"flex",gap:"8px",alignItems:"center",marginTop:"4px"},children:e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void Ue(),disabled:a||je||!O.trim(),title:"Auto-detect models from the provider's /models endpoint",children:je?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"spin",size:14})," Detecting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Oa,{size:14})," Detect Models"]})})}),fe?e.jsx("div",{className:"custom-provider-form-error",children:fe}):null,W?e.jsx("div",{className:"custom-provider-form-error",children:W}):null,e.jsxs("div",{className:"custom-provider-form-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:ae,disabled:a,children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:()=>void ze(),disabled:a,children:a?"Saving…":"Save Changes"})]})]}):null]},m.id)})}):null,!C&&u.length===0&&!R?e.jsx("div",{className:"custom-provider-empty",children:"No custom providers configured."}):null,e.jsxs("button",{type:"button",className:"btn btn-sm custom-provider-add-btn",onClick:M,children:[e.jsx(xl,{"aria-hidden":"true"})," Add Custom Provider"]}),q&&!S?e.jsxs("div",{className:"custom-provider-form",children:[e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-name",children:"Provider name"}),e.jsx("input",{id:"custom-provider-name",className:"input",value:_,onChange:m=>H(m.target.value),disabled:a})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-api-type",children:"API type"}),e.jsxs("select",{id:"custom-provider-api-type",className:"select",value:A,onChange:m=>p(m.target.value),disabled:a,children:[e.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible"}),e.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),e.jsx("option",{value:"anthropic-compatible",children:"Anthropic-compatible"})]})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-base-url",children:"Base URL"}),e.jsx("input",{id:"custom-provider-base-url",className:"input",placeholder:"https://api.example.com/v1",value:O,onChange:m=>y(m.target.value),disabled:a})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-api-key",children:"API key"}),e.jsx("input",{id:"custom-provider-api-key",type:"password",className:"input",value:z,onChange:m=>J(m.target.value),disabled:a})]}),e.jsxs("div",{className:"form-group custom-provider-form-row",children:[e.jsx("label",{htmlFor:"custom-provider-models",children:"Available models"}),e.jsx("input",{id:"custom-provider-models",className:"input",placeholder:"e.g., gpt-4, gpt-3.5-turbo",value:le,onChange:m=>te(m.target.value),disabled:a})]}),e.jsx("div",{style:{display:"flex",gap:"8px",alignItems:"center",marginTop:"4px"},children:e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void Ue(),disabled:a||je||!O.trim(),title:"Auto-detect models from the provider's /models endpoint",children:je?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"spin",size:14})," Detecting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Oa,{size:14})," Detect Models"]})})}),fe?e.jsx("div",{className:"custom-provider-form-error",children:fe}):null,W?e.jsx("div",{className:"custom-provider-form-error",children:W}):null,e.jsxs("div",{className:"custom-provider-form-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:ae,disabled:a,children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:()=>void ze(),disabled:a,children:a?"Saving…":"Save Provider"})]})]}):null]});return e.jsx("div",{className:"custom-providers-section",children:n?Ce:e.jsx(Jr,{summary:"Advanced: Custom Providers",onToggle:Q,children:Ce})})}const ll={always:{label:"Always require approval",description:"All fn_agent_create/fn_agent_delete requests require approval unless caller is trusted."},"trusted-only":{label:"Trusted-only",description:"Trusted roles/agent IDs bypass approval; other callers require approval."},never:{label:"Never require approval",description:"Allow provisioning without approval for non-privileged callers."}};function rl(n){return Array.from(new Set(n.split(/[\n,]+/).map(o=>o.trim()).filter(o=>o.length>0)))}function Gi({value:n,onChange:o,disabled:u=!1}){const k=n?.approvalMode??"trusted-only",C=n?.alwaysApproveDelete??!0,w=I=>{o({...n??{},...I})};return e.jsxs("div",{className:"agent-provisioning-policy-editor card",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-provisioning-approval-mode",children:"Approval mode"}),e.jsx("select",{id:"agent-provisioning-approval-mode",className:"select",value:k,onChange:I=>w({approvalMode:I.target.value}),disabled:u,children:Zr.map(I=>e.jsx("option",{value:I,children:ll[I].label},I))}),e.jsx("small",{className:"agent-provisioning-policy-help",children:ll[k].description})]}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{className:"checkbox-label",htmlFor:"agent-provisioning-always-approve-delete",children:[e.jsx("input",{id:"agent-provisioning-always-approve-delete",type:"checkbox",checked:C,onChange:I=>w({alwaysApproveDelete:I.target.checked}),disabled:u}),"Always require approval for fn_agent_delete"]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-provisioning-trusted-roles",children:"Trusted roles"}),e.jsx("textarea",{id:"agent-provisioning-trusted-roles",className:"input agent-provisioning-policy-textarea",value:(n?.trustedRoles??[]).join(", "),onChange:I=>w({trustedRoles:rl(I.target.value)}),disabled:u,placeholder:"reviewer, ceo",rows:2})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-provisioning-trusted-agent-ids",children:"Trusted agent IDs"}),e.jsx("textarea",{id:"agent-provisioning-trusted-agent-ids",className:"input agent-provisioning-policy-textarea",value:(n?.trustedAgentIds??[]).join(", "),onChange:I=>w({trustedAgentIds:rl(I.target.value)}),disabled:u,placeholder:"agent-abc123",rows:2})]}),e.jsxs("p",{className:"agent-provisioning-policy-help",children:["These settings govern durable provisioning tools only: ",e.jsx("code",{children:"fn_agent_create"})," and ",e.jsx("code",{children:"fn_agent_delete"}),". Ephemeral ",e.jsx("code",{children:"fn_spawn_agent"})," requests stay under the task/agent mutation approval gate (FN-3973)."]})]})}function As(n,o){if(!o)return n;const u=n.includes("?")?"&":"?";return`${n}${u}projectId=${encodeURIComponent(o)}`}async function nl(n,o){const u=await fetch(n,{credentials:"same-origin",...o,headers:{"Content-Type":"application/json",...o?.headers??{}}}),k=await u.json();if(!u.ok)throw new Error(k.error??`Request failed (${u.status})`);return k}function Ui(n){const[o,u]=r.useState({status:"missing"}),[k,C]=r.useState(!1),w=r.useCallback(async()=>{try{const j=await nl(As("/api/worktrunk/status",n));u(j)}catch(j){u({status:"failed",error:j instanceof Error?j.message:"Failed to load worktrunk status"})}},[n]);r.useEffect(()=>{w()},[w]),r.useEffect(()=>en(As("/api/events",n),{events:{"approval:updated":()=>{o.pendingApprovalId&&w()},"approval:decided":()=>{o.pendingApprovalId&&w()}}}),[n,w,o.pendingApprovalId]);const I=r.useCallback(async()=>{C(!0),u(j=>({...j,status:"installing",error:void 0}));try{const j=await nl(As("/api/worktrunk/install-request",n),{method:"POST",body:JSON.stringify({})});u({status:j.status,version:j.version,installPath:j.installPath,pendingApprovalId:j.pendingApprovalId??j.approvalRequestId,error:j.error})}catch(j){u({status:"failed",error:j instanceof Error?j.message:"Failed to request install"})}finally{C(!1)}},[n]);return{...o,requestInstall:I,requesting:k}}const Ot="__custom__";function zi(n){const o=new Map;for(const u of n){const k=u.value.trim();!k||o.has(k)||o.set(k,{...u,value:k,label:u.label?.trim()||k})}return[...o.values()].sort((u,k)=>u.value.localeCompare(k.value))}function il({id:n,value:o,onChange:u,options:k,loading:C=!1,error:w,placeholder:I="owner/repo",ariaLabel:j}){const R=r.useRef(null),E=r.useId(),[S,B]=r.useState(!1),q=r.useMemo(()=>zi(k),[k]),P=q.find(p=>p.value===o),_=P?P.value:Ot;r.useEffect(()=>{B(_===Ot)},[_]);const H=p=>{if(p===Ot){B(!0),requestAnimationFrame(()=>{R.current?.focus()});return}B(!1),u(p)},A=w||(C?"Loading detected GitHub remotes…":null);return e.jsxs("div",{className:"tracking-repo-select",children:[e.jsxs("select",{id:n,className:"select",value:_,onChange:p=>H(p.target.value),"aria-label":j,"aria-describedby":A?E:void 0,children:[q.map(p=>e.jsx("option",{value:p.value,children:p.source?`${p.label} — ${p.source}`:p.label},p.value)),e.jsx("option",{value:Ot,children:"Custom…"})]}),S?e.jsx("input",{ref:R,className:"input tracking-repo-select__custom-input",type:"text",value:o,placeholder:I,onChange:p=>u(p.target.value),"aria-describedby":A?E:void 0}):null,A?e.jsx("small",{id:E,className:w?"tracking-repo-select__hint tracking-repo-select__hint--error":"tracking-repo-select__hint",children:A}):null]})}const qi=r.lazy(()=>vl(()=>import("./PluginManager-Df_KHiXn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(n=>({default:n.PluginManager}))),Hi=r.lazy(()=>vl(()=>import("./PiExtensionsManager-Y1ETuTxf.js"),__vite__mapDeps([11,1,2,3,4,5,6,12])).then(n=>({default:n.PiExtensionsManager}))),Fs="fusion_github_star_count",ol=3600*1e3,cl="fusion:github-star-clicked";function Ms(n){return ii.reduce((o,u)=>(o[u]=n?.[u]??"allow",o),{})}function Wi(n){return n==="online"?"Online":n==="connecting"?"Connecting":n==="error"?"Error":"Offline"}function Ki(n){const o=new Map;for(const u of n){const k=`${u.owner}/${u.repo}`;o.has(k)||o.set(k,{value:k,label:k})}return[...o.values()].sort((u,k)=>u.value.localeCompare(k.value))}function Vi(){const[n,o]=r.useState(()=>{try{return localStorage.getItem(cl)==="true"}catch{return!1}}),u=r.useCallback(()=>{o(!0);try{localStorage.setItem(cl,"true")}catch{}},[]);return[n,u]}function Yi(){const[n,o]=r.useState(()=>{try{const u=localStorage.getItem(Fs);if(u){const k=JSON.parse(u);if(Date.now()-k.fetchedAt<ol)return k.count}}catch{}return null});return r.useEffect(()=>{try{const u=localStorage.getItem(Fs);if(u){const k=JSON.parse(u);if(Date.now()-k.fetchedAt<ol)return}}catch{}fetch("https://api.github.com/repos/Runfusion/Fusion").then(u=>{if(u.ok)return u.json()}).then(u=>{if(u&&typeof u.stargazers_count=="number"){const k={count:u.stargazers_count,fetchedAt:Date.now()};try{localStorage.setItem(Fs,JSON.stringify(k))}catch{}o(u.stargazers_count)}}).catch(()=>{})},[]),n}const dl="(max-width: 768px)",Ts=".fusion/memory/DREAMS.md",Qi=72;function Xi(n,o){if(n.length<=o)return n;const u=Math.max(1,o-1),k=Math.ceil(u/2),C=Math.floor(u/2);return`${n.slice(0,k)}…${n.slice(n.length-C)}`}function Ji(n){const o=`${n.label} — ${n.path}`;return Xi(o,Qi)}function ft(n){return n?.join(", ")??""}function xt(n){return n.split(",").map(o=>o.trim()).filter(o=>o.length>0)}const ul=[{id:"__account_header",label:"Account",scope:void 0,isGroupHeader:!0},{id:"authentication",label:"Authentication",scope:void 0,icon:vt},{id:"__global_header",label:"Global",scope:void 0,isGroupHeader:!0},{id:"global-general",label:"General",scope:"global"},{id:"appearance",label:"Appearance",scope:"global"},{id:"notifications",label:"Notifications",scope:"global"},{id:"node-sync",label:"Node Sync",scope:"global"},{id:"global-models",label:"Models",scope:"global"},{id:"research-global",label:"Research Defaults",scope:"global"},{id:"experimental",label:"Experimental Features",scope:"global"},{id:"remote",label:"Remote Access",scope:"global"},{id:"__runtimes_header",label:"Runtimes",scope:void 0,isGroupHeader:!0},{id:"hermes-runtime",label:"Hermes",scope:"global"},{id:"openclaw-runtime",label:"OpenClaw",scope:"global"},{id:"paperclip-runtime",label:"Paperclip",scope:"global"},{id:"__project_header",label:"Project",scope:void 0,isGroupHeader:!0},{id:"general",label:"Project General",scope:"project"},{id:"secrets",label:"Secrets",scope:"project"},{id:"project-models",label:"Project Models",scope:"project"},{id:"scheduling",label:"Scheduling",scope:"project"},{id:"scheduled-evals",label:"Scheduled Evals",scope:"project"},{id:"node-routing",label:"Node Routing",scope:"project"},{id:"worktrees",label:"Worktrees",scope:"project"},{id:"commands",label:"Commands",scope:"project"},{id:"merge",label:"Merge",scope:"project"},{id:"agent-permissions",label:"Agent Permissions",scope:"project"},{id:"memory",label:"Memory",scope:"project"},{id:"research-project",label:"Research",scope:"project"},{id:"prompts",label:"Prompts",scope:"project"},{id:"backups",label:"Backups",scope:"project"},{id:"plugins",label:"Plugins",scope:"project"}],ml=1440*60*1e3,Zi=2,Is=["in-review","merged","failed","awaiting-approval","awaiting-user-review","planning-awaiting-input","gridlock","fallback-used","memory-dreams-processed","message:agent-to-user","message:agent-to-agent","message:room","oauth-token-expired"],hl=[{event:"in-review",label:"Task completed (in-review)",description:"When a task moves to In Review (ready for review)"},{event:"merged",label:"Task merged",description:"When a task is successfully merged to main"},{event:"failed",label:"Task failed",description:"When a task fails during execution (high priority)"},{event:"awaiting-approval",label:"Plan needs approval",description:"When a task specification needs manual approval before execution"},{event:"awaiting-user-review",label:"User review needed",description:"When an agent hands off a task for human review (high priority)"},{event:"planning-awaiting-input",label:"Planning needs input",description:"When planning mode is waiting for your response to continue"},{event:"gridlock",label:"Pipeline gridlocked",description:"When all schedulable todo tasks are blocked and work cannot advance"},{event:"fallback-used",label:"Fallback model used (recovered)",description:"When Fusion recovers from a retryable model failure by switching to a fallback model"},{event:"memory-dreams-processed",label:"DREAMS.md entry added",description:"When manual dream processing writes a new entry to project or agent DREAMS.md"},{event:"message:agent-to-user",label:"Agent → user message",description:"An agent sent you a direct message"},{event:"message:agent-to-agent",label:"Agent → agent message",description:"Agents are talking to each other (including replies)"},{event:"message:room",label:"Agent message in room",description:"An agent posted a reply in a chat room you're watching"},{event:"oauth-token-expired",label:"OAuth token expired",description:"Notify when a provider OAuth token (Codex, Claude, etc.) expires."}],pl={insights:"Insights",roadmap:"Roadmaps",memoryView:"Memory Editor",remoteAccess:"Remote Access",skillsView:"Skills View",nodesView:"Nodes View",devServerView:"Dev Server",todoView:"Todo List",researchView:"Research View",evalsView:"Evals View",goalsView:"Goals View",sandbox:"Sandbox (command isolation)",chatRooms:"Chat Rooms",agentOnboarding:"Planning-style Agent Onboarding"},$t={devServer:"devServerView"};function Nl(n){return $t[n]??n}function Bt(n,o){return n[o]===!0?!0:Object.entries($t).some(([u,k])=>k===o&&n[u]===!0)}function eo(n){if(!n)return{};const o={};for(const[u,k]of Object.entries(n))o[Nl(u)]=k;for(const[u,k]of Object.entries($t))o[k]!==void 0&&!(u in o)&&(o[u]=null);return o}const Rs="global-general";function co({onClose:n,addToast:o,projectId:u,initialSection:k,themeMode:C="dark",colorTheme:w="default",onThemeModeChange:I,onColorThemeChange:j,dashboardFontScalePct:R=100,onDashboardFontScaleChange:E,onReopenOnboarding:S,onOpenApprovals:B}){const{confirm:q}=tn(),P=Ui(u),_=P.status==="installed",H=sn();an(!0);const{keyboardOverlap:A,viewportHeight:p,viewportOffsetTop:O,keyboardOpen:y}=ln({enabled:H==="mobile"}),z=y?{"--keyboard-overlap":`${A}px`,"--vv-offset-top":`${O}px`,...p!==null?{"--vv-height":`${p}px`}:{}}:{},J=r.useRef(null),le=r.useRef(null);rn(J,!0,"fusion:settings-modal-size");const te=nn(),[a,i]=r.useState({maxConcurrent:2,maxTriageConcurrent:2,maxWorktrees:4,pollIntervalMs:15e3,heartbeatMultiplier:1,groupOverlappingFiles:!0,overlapIgnorePaths:[],autoMerge:!0,mergeStrategy:"direct",mergeIntegrationWorktree:"reuse-task-worktree",mergeAdvanceAutoSync:"stash-and-ff",recycleWorktrees:!1,executorAllowSiblingBranchRename:!1,worktreeNaming:"random",worktreesDir:"",worktrunk:{enabled:!1,binaryPath:"",onFailure:"fail"},includeTaskIdInCommit:!0,worktreeInitCommand:"",ntfyEnabled:!1,ntfyTopic:void 0,ntfyAccessToken:void 0,failureNotificationMode:"sticky-only",failureNotificationDelayMs:3e4,webhookEnabled:!1,webhookUrl:void 0,webhookFormat:"generic",webhookEvents:void 0}),[W,se]=r.useState(!0),[je,ye]=r.useState(null),[fe,b]=r.useState(null),[F,Q]=r.useState(null),ae=ul.find(t=>!t.isGroupHeader),[M,ie]=r.useState(()=>k==="pi-extensions"?"plugins":k??Rs),[re,Ue]=r.useState(()=>k==="pi-extensions"?"pi-extensions":"fusion-plugins"),[ze,tt]=r.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(dl)?.matches===!0:!1),[Ce,m]=r.useState(null),[v,L]=r.useState(!1),[U,V]=r.useState(null),$=Yi(),[ke,Cl]=Vi(),[st,Os]=r.useState(null),[Bs,at]=r.useState(null),[we,_t]=r.useState(null),[$s,_s]=r.useState(!1),{entries:wl,currentPath:Te,setPath:Gt,loading:Sl,error:Pl,refresh:Al}=Ba("project",we!==null,u),{entries:Fl,currentPath:De,setPath:Ut,loading:Ml,error:Tl,refresh:Il}=Ba("project",$s,u),{nodes:Gs}=on(),zt=a.experimentalFeatures??{},qt=Bt(zt,"remoteAccess"),Ht=Bt(zt,"researchView"),Wt=Bt(zt,"evalsView"),qe=ul.filter(t=>t.id==="remote"?qt:t.id==="research-global"||t.id==="research-project"?Ht:t.id==="scheduled-evals"?Wt:!0),lt=qe.some(t=>t.id===Rs)?Rs:qe.find(t=>!t.isGroupHeader)?.id??ae?.id??"general",rt=qe.find(t=>t.id===M)?.scope;r.useEffect(()=>{if(M==="remote"&&!qt){ie(lt);return}if((M==="research-global"||M==="research-project")&&!Ht){ie(lt);return}if(M==="scheduled-evals"&&!Wt){ie(lt);return}qe.some(t=>t.id===M)||ie(lt)},[M,qt,Ht,Wt,lt,qe]);const[Le,Kt]=r.useState([]),[Rl,Us]=r.useState(!1),[xe,ve]=r.useState(null),[zs,Vt]=r.useState({}),[yt,qs]=r.useState({}),[Ye,Hs]=r.useState({}),[Yt,Qt]=r.useState({}),[Ws,Xt]=r.useState(null),[nt,kt]=r.useState({}),[Nt,Ct]=r.useState({}),[Qe,it]=r.useState({}),ue=r.useRef(null),ot=r.useRef({}),[ne,Ks]=r.useState([]),[wt,Vs]=r.useState(!1),[me,Jt]=r.useState([]),[he,Zt]=r.useState([]),[ce,Ys]=r.useState({}),[oe,St]=r.useState({}),[ct,dt]=r.useState(null),[Z,Se]=r.useState(null),[Pe,es]=r.useState(null),[ts,Pt]=r.useState(!1),[Y,At]=r.useState(null),[He,ss]=r.useState(null),[pe,Qs]=r.useState(null),[Xs,Js]=r.useState(!1),[Zs,as]=r.useState(null),[Xe,El]=r.useState("persistent"),[ut,ea]=r.useState(null),[ls,ta]=r.useState(null),[rs,Dl]=r.useState(null),[We,Je]=r.useState(null),[ns,Ft]=r.useState(""),[sa,aa]=r.useState(!1),[Oe,mt]=r.useState(!1),[Ll,la]=r.useState([]),[ra,na]=r.useState([]),[Ol,ia]=r.useState(!1),[Bl,oa]=r.useState([]),[$l,ca]=r.useState(!1),[_l,da]=r.useState(null),[Gl,ua]=r.useState([]),[Ul,ma]=r.useState(!1),[zl,is]=r.useState(null),os=r.useRef(!1),[ha,pa]=r.useState([]),[ge,cs]=r.useState(Ts),[ds,ql]=r.useState(""),[ga,ba]=r.useState(!1),[Be,fa]=r.useState(null),[xa,va]=r.useState(!1),[ja,ya]=r.useState(!1),[ka,Na]=r.useState(!1),us=r.useRef(!1),[Mt,Ca]=r.useState(4),wa=r.useRef(4),Sa=r.useRef(!1),Pa=r.useRef(!1),[Hl,ht]=r.useState(!1),[,ms]=r.useState(null),[Ae,Aa]=r.useState(null),[Tt,It]=r.useState(!1),[hs,Wl]=r.useState("both"),[ps,Kl]=r.useState(!0),Fa=r.useRef(null),{status:Vl,capabilities:Yl,loading:Ql,error:Xl,refresh:Ma}=ci({projectId:u,enabled:M==="memory"});r.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const t=window.matchMedia(dl);if(!t)return;const s=l=>{tt(l?l.matches:t.matches)};return s(),t.addEventListener("change",s),()=>t.removeEventListener("change",s)},[]),r.useEffect(()=>{Promise.all([$a(u),cn(u)]).then(([t,s])=>{const l={...t,mergeIntegrationWorktree:Ga(t.mergeIntegrationWorktree),mergeAdvanceAutoSync:_a(t.mergeAdvanceAutoSync)};i(l),ye(l),b(s),Q({...s,project:{...s.project,mergeIntegrationWorktree:s.project.mergeIntegrationWorktree===void 0?void 0:Ga(s.project.mergeIntegrationWorktree),mergeAdvanceAutoSync:s.project.mergeAdvanceAutoSync===void 0?void 0:_a(s.project.mergeAdvanceAutoSync)}}),se(!1)}).catch(t=>{o(X(t),"error"),se(!1)})},[o,u]),r.useEffect(()=>{if(M!=="scheduling"||Sa.current)return;let t=!1;return dn().then(s=>{t||(Pa.current||Ca(s.globalMaxConcurrent),wa.current=s.globalMaxConcurrent,Sa.current=!0)}).catch(()=>{}),()=>{t=!0}},[M]),r.useEffect(()=>{let t=!1;return un().then(s=>{t||typeof s.version=="string"&&s.version.trim().length>0&&m(s.version)}).catch(()=>{}),()=>{t=!0}},[]);const Jl=r.useCallback(async()=>{L(!0);try{const t=await mn();V(t),t.error&&o(t.error,"error")}catch(t){const s=X(t)||"Failed to check for updates";V({currentVersion:Ce??"unknown",latestVersion:null,updateAvailable:!1,error:s}),o(s,"error")}finally{L(!1)}},[o,Ce]),Zl=r.useCallback(()=>U?U.error?U.error:U.updateAvailable&&U.latestVersion?e.jsxs(e.Fragment,{children:["v",U.latestVersion," available ·"," ",e.jsx("a",{href:"https://runfusion.ai",target:"_blank",rel:"noreferrer",className:"settings-update-result-link",children:"Learn more"})]}):"You're up to date ✓":null,[U]),ee=r.useCallback(async()=>{try{const{providers:t}=await Ua(),s=za(t);Kt(s),Vt(l=>{const c={};for(const[d,h]of Object.entries(l)){const g=s.find(T=>T.id===d);g&&!g.authenticated&&(c[d]=h)}return Object.keys(c).length===Object.keys(l).length?l:c})}catch{}},[]);r.useEffect(()=>{(M==="global-models"||M==="project-models")&&(Vs(!0),hn().then(t=>{Ks(t.models),Jt(t.favoriteProviders),Zt(t.favoriteModels)}).catch(()=>Ks([])).finally(()=>Vs(!1)))},[M]),r.useEffect(()=>{M==="backups"&&(Pt(!0),qa(u).then(t=>es(t)).catch(()=>es(null)).finally(()=>Pt(!1)))},[M,u]);const Rt=r.useCallback(async()=>{const[t,s]=await Promise.allSettled([pn(u),xs(u)]);t.status==="fulfilled"&&i(l=>({...l,...t.value.settings})),s.status==="fulfilled"&&(At(s.value),ss(s.value.externalTunnel??null))},[u]);r.useEffect(()=>{const t=Y?.state;(t==="running"||t==="starting")&&ss(null)},[Y?.state]),r.useEffect(()=>{M==="remote"&&Rt().catch(()=>{At(null)})},[M,Rt]),r.useEffect(()=>{if(M!=="remote")return;const t=Y?.state;if(t!=="starting"&&t!=="stopping")return;const s=setInterval(()=>{xs(u).then(l=>{At(l),ss(l.externalTunnel??null)}).catch(()=>{})},1e3);return()=>clearInterval(s)},[M,u,Y?.state]),r.useEffect(()=>{if(M!=="remote")return;if(Y?.state!=="running"){Je(null);return}let t=!1;return(async()=>{try{const s=await vs("image/svg",{projectId:u,tokenType:"persistent"});if(t)return;Je({url:s.url,qrSvg:s.data??null})}catch{if(t)return;try{const s=await Ha({projectId:u,tokenType:"persistent"});if(t)return;Je({url:s.url,qrSvg:null})}catch{t||Je(null)}}})(),()=>{t=!0}},[M,u,Y?.state,Y?.url]),r.useEffect(()=>{if(M!=="remote")return;const t=He?.url;if(Y?.state!=="stopped"||!t)return;let s=!1;return(async()=>{try{const l=await vs("image/svg",{projectId:u,tokenType:"persistent"});if(s)return;Je({url:t,qrSvg:l.data??null})}catch{s||Je({url:t,qrSvg:null})}})(),()=>{s=!0}},[M,He?.url,u,Y?.state]),r.useEffect(()=>{M==="worktrees"&&gn(u).then(t=>la(t)).catch(()=>la([]))},[M,u]),r.useEffect(()=>{M==="merge"&&bn(u).then(t=>{const s=t.map(h=>h.name).filter(h=>typeof h=="string"&&h.length>0),l=new Set,c=["main","master","trunk","develop"],d=[];for(const h of c)s.includes(h)&&!l.has(h)&&(d.push(h),l.add(h));for(const h of[...s].sort((g,T)=>g.localeCompare(T)))l.has(h)||(l.add(h),d.push(h));na(d)}).catch(()=>na([]))},[M,u]),r.useEffect(()=>{if(M!=="general")return;let t=!1;return ca(!0),da(null),Wa(u).then(s=>{t||oa(Ki(s))}).catch(()=>{t||(oa([]),da("Could not load detected remotes. Enter a custom owner/repo value."))}).finally(()=>{t||ca(!1)}),()=>{t=!0}},[M,u]),r.useEffect(()=>{if(M!=="global-general"||os.current)return;let t=!1;return ma(!0),is(null),fn().then(async s=>{const l=await Promise.allSettled(s.map(async g=>(await Wa(g.id)).map(G=>({value:`${G.owner}/${G.repo}`,label:`${G.owner}/${G.repo}`,source:g.name}))));if(t)return;const c=new Map;let d=0;for(const g of l)if(g.status==="fulfilled"){d+=1;for(const T of g.value)c.has(T.value)||c.set(T.value,T)}const h=[...c.values()].sort((g,T)=>g.value.localeCompare(T.value));ua(h),s.length>0&&d===0&&is("Could not load remotes from registered projects. Enter a custom owner/repo value."),os.current=!0}).catch(()=>{t||(ua([]),is("Could not load project list. Enter a custom owner/repo value."),os.current=!0)}).finally(()=>{t||ma(!1)}),()=>{t=!0}},[M,u]),r.useEffect(()=>{if(M!=="memory"||Oe)return;if(us.current){us.current=!1;return}let t=!1;return aa(!0),Ka(u).then(async({files:s})=>{if(t)return;pa(s);const l=s.some(d=>d.path===ge)?ge:s.find(d=>d.path===Ts)?.path??s.find(d=>d.layer==="dreams")?.path??s[0]?.path??Ts;cs(l);const{content:c}=await xn(l,u);t||(Ft(c),mt(!1))}).catch(s=>{t||(o(X(s)||"Failed to load project memory","error"),Ft(""))}).finally(()=>{t||aa(!1)}),()=>{t=!0}},[M,Oe,ge,u,o]),r.useEffect(()=>((M==="authentication"||M==="research-global")&&(Us(!0),ee().finally(()=>Us(!1))),()=>{ue.current&&(clearInterval(ue.current),ue.current=null)}),[M,ee]),r.useEffect(()=>{if(M!=="authentication"||!Le.some(l=>l.type!=="api_key"&&l.loginInProgress))return;const s=setInterval(()=>{ee()},2e3);return()=>clearInterval(s)},[M,Le,ee]);const Et=r.useCallback(()=>{le.current?.scrollTo({top:0,behavior:"smooth"})},[]),Ke=r.useCallback(t=>{if(t in ot.current){const s={...ot.current};delete s[t],ot.current=s}Vt(s=>{if(!(t in s))return s;const l={...s};return delete l[t],l}),qs(s=>{if(!(t in s))return s;const l={...s};return delete l[t],l}),Qt(s=>{if(!(t in s))return s;const l={...s};return delete l[t],l}),Hs(s=>{if(!(t in s))return s;const l={...s};return delete l[t],l})},[]);r.useEffect(()=>{const t=Ye["github-copilot"];t?.userCode&&ot.current["github-copilot"]!==t.userCode&&(ot.current["github-copilot"]=t.userCode,Va(t.userCode))},[Ye]);const er=r.useCallback(async t=>{const s=Le.find(l=>l.id===t);if(!(s?.requiresManualCode===!0&&!await q({title:"Heads up — manual paste-back required",message:`After you sign in with ${s.name}, the browser will try to redirect to a localhost address that this dashboard can't reach. The redirect tab will look like it failed. Before that happens, copy the full URL from the browser address bar — you'll paste it back here to finish login. Continue?`,confirmLabel:"Continue to login",cancelLabel:"Cancel"}))){ve(t),Ke(t);try{const{url:l,instructions:c,manualCode:d,deviceCode:h}=await vn(t);c?.trim()&&!(t==="github-copilot"&&h)&&Vt(g=>({...g,[t]:c})),d&&qs(g=>({...g,[t]:d})),h&&t==="github-copilot"&&Hs(g=>({...g,[t]:h})),(t!=="github-copilot"||!h)&&window.open(Ya(h?.verificationUri??l),"_blank"),ue.current=setInterval(async()=>{try{const{providers:g}=await Ua(),T=za(g);Kt(T);const G=T.find(x=>x.id===t);if(G?.authenticated){ue.current&&(clearInterval(ue.current),ue.current=null),ve(null),Ke(t),o("Login successful","success"),Et();return}G?.loginInProgress||(ue.current&&(clearInterval(ue.current),ue.current=null),ve(null),Ke(t),o("Login did not complete. Please try again.","error"))}catch{}},2e3)}catch(l){const c=X(l)||"Login failed";c.includes("already in progress")||typeof l=="object"&&l!==null&&"status"in l&&l.status===409?(o("Login already in progress. You can cancel it and retry.","warning"),await ee()):o(c,"error"),ve(null),Ke(t)}}},[o,Le,Ke,q,ee,Et]),tr=r.useCallback(async t=>{const s=Yt[t]?.trim();if(!s){o("Paste the full redirect URL or authorization code first.","warning");return}Xt(t);try{(await jn(t,s)).submitted?(Qt(c=>{if(!(t in c))return c;const d={...c};return delete d[t],d}),o("Authorization code received. Finishing login…","success")):o("That authorization code was already submitted. Waiting for login…","warning")}catch(l){o(X(l)||"Failed to submit authorization code","error")}finally{Xt(null)}},[o,Yt]),Ta=r.useCallback(async t=>{ve(t),Kt(s=>s.map(l=>l.id===t?{...l,loginInProgress:!1}:l));try{await yn(t),Ke(t),await ee().catch(()=>{}),o("Login cancelled","success")}catch(s){o(X(s)||"Failed to cancel login","error")}finally{ve(null),Xt(s=>s===t?null:s),ue.current&&(clearInterval(ue.current),ue.current=null)}},[o,Ke,ee]),sr=r.useCallback(async t=>{ve(t);try{await kn(t),await ee(),o("Logged out","success")}catch(s){o(X(s)||"Logout failed","error")}finally{ve(null)}},[o,ee]),Ia=r.useCallback(async t=>{const s=nt[t]?.trim();if(!s){Ct(l=>({...l,[t]:"API key is required"}));return}ve(t),Ct(l=>{const c={...l};return delete c[t],c});try{const l=await Nn(t,s);if(kt(c=>{const d={...c};return delete d[t],d}),await ee(),t==="opencode"||t==="opencode-go"){const c=l.modelsRefreshed,d=l.refreshReason,h=l.refreshError;h?it(g=>({...g,[t]:{tone:"error",message:`Saved, but model refresh failed: ${h}. Make sure the \`opencode\` CLI is installed on PATH.`}})):d==="no-models-from-cli"?it(g=>({...g,[t]:{tone:"error",message:"Saved. The local `opencode` CLI returned no models — run `opencode auth login` and `opencode models opencode --refresh`, then click Save again."}})):typeof c=="number"&&c>0?it(g=>({...g,[t]:{tone:"success",message:`Refreshed ${c} opencode-go models.`}})):it(g=>{const T={...g};return delete T[t],T})}o("API key saved","success"),Et()}catch(l){Ct(c=>({...c,[t]:X(l)||"Failed to save API key"})),(t==="opencode"||t==="opencode-go")&&it(c=>{const d={...c};return delete d[t],d})}finally{ve(null)}},[nt,o,ee,Et]),ar=r.useCallback(async t=>{ve(t);try{await Cn(t),kt(s=>{const l={...s};return delete l[t],l}),Ct(s=>{const l={...s};return delete l[t],l}),await ee(),o("API key cleared","success")}catch(s){o(X(s)||"Failed to clear API key","error")}finally{ve(null)}},[o,ee]),Dt=r.useCallback(async t=>{if(!((t==="ntfy"||t==="ntfy-message"||t==="ntfy-room")&&(!a.ntfyEnabled||!a.ntfyTopic||!/^[a-zA-Z0-9_-]{1,64}$/.test(a.ntfyTopic)))){if(t==="webhook"){if(!a.webhookEnabled||!a.webhookUrl?.trim())return;try{const s=new URL(a.webhookUrl.trim());if(s.protocol!=="http:"&&s.protocol!=="https:")return}catch{return}}Ys(s=>({...s,[t]:!0})),St(s=>{const l={...s};return delete l[t],l});try{const s=t==="ntfy"?{ntfyEnabled:a.ntfyEnabled,ntfyTopic:a.ntfyTopic,...a.ntfyBaseUrl?.trim()?{ntfyBaseUrl:a.ntfyBaseUrl.trim()}:{},...a.ntfyAccessToken?.trim()?{ntfyAccessToken:a.ntfyAccessToken.trim()}:{}}:t==="ntfy-message"?{messageEventType:"message:agent-to-user"}:t==="ntfy-room"?{messageEventType:"message:room"}:{webhookUrl:a.webhookUrl,webhookFormat:a.webhookFormat||"generic"};if((await wn(t==="ntfy-message"||t==="ntfy-room"?"ntfy":t,s,u)).success){const c=t==="ntfy"?"Test notification sent — check your ntfy app!":t==="ntfy-message"?"Message inbox test sent — check your ntfy inbox for the agent-to-user message.":t==="ntfy-room"?"Room reply test sent — check your ntfy inbox for the room reply.":"Test notification sent — check your webhook endpoint!";St(d=>({...d,[t]:{status:"success",message:c}})),o(c,"success")}else{const c=t==="ntfy-message"?"Failed to send message inbox test":t==="ntfy-room"?"Failed to send room reply test":"Failed to send test notification";St(d=>({...d,[t]:{status:"error",message:c}})),o(c,"error")}}catch(s){const l=X(s)||"Failed to send test notification";St(c=>({...c,[t]:{status:"error",message:l}})),o(l,"error")}finally{Ys(s=>({...s,[t]:!1}))}}},[o,a.ntfyAccessToken,a.ntfyBaseUrl,a.ntfyEnabled,a.ntfyTopic,a.webhookEnabled,a.webhookFormat,a.webhookUrl,u]),lr=r.useCallback(async()=>{Pt(!0);try{const t=await Sn(u);if(t.success){o("Backup created successfully","success");const s=await qa(u);es(s)}else o(t.error||"Failed to create backup","error")}catch(t){o(X(t)||"Failed to create backup","error")}finally{Pt(!1)}},[o,u]),rr=r.useCallback(async()=>{try{const t=rt==="global"?"global":rt==="project"?"project":"both",s=await Pn(t,u),l=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),c=URL.createObjectURL(l),d=document.createElement("a"),h=`fusion-settings-${new Date().toISOString().replace(/[:.]/g,"-").slice(0,19)}.json`;d.href=c,d.download=h,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(c),o(`Settings exported (${t==="global"?"global":t==="project"?"project":"all"} scope)`,"success")}catch(t){o(X(t)||"Failed to export settings","error")}},[o,rt,u]),nr=r.useCallback(async t=>{const s=t.target.files?.[0];if(s){ms(s),It(!0);try{const l=await s.text(),c=JSON.parse(l);Aa(c),ht(!0)}catch(l){o(`Invalid JSON file: ${X(l)}`,"error"),ms(null)}finally{It(!1)}}},[o]),ir=r.useCallback(async()=>{if(Ae){It(!0);try{const t=await An(Ae,{scope:hs,merge:ps},u);if(t.success){const s=[];t.globalCount>0&&s.push(`${t.globalCount} global`),t.projectCount>0&&s.push(`${t.projectCount} project`),o(`Imported ${s.join(", ")} setting(s)`,"success"),ht(!1),Aa(null),ms(null);const l=await $a(u);i(l)}else o(t.error||"Import failed","error")}catch(t){o(X(t)||"Failed to import settings","error")}finally{It(!1)}}},[o,Ae,hs,ps,u]),Ie=r.useCallback(async t=>{const s=me,c=s.includes(t)?s.filter(d=>d!==t):[t,...s];Jt(c);try{await js({favoriteProviders:c,favoriteModels:he})}catch{Jt(s)}},[me,he]),Re=r.useCallback(async t=>{const s=he,c=s.includes(t)?s.filter(d=>d!==t):[t,...s];Zt(c);try{await js({favoriteProviders:me,favoriteModels:c})}catch{Zt(s)}},[he,me]);r.useEffect(()=>{const t=s=>{s.key==="Escape"&&n()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[n]);const or=Fn(n),Ra=[{laneId:"default",label:"Default Model",globalProviderKey:"defaultProvider",globalModelKey:"defaultModelId",projectProviderKey:"defaultProviderOverride",projectModelKey:"defaultModelIdOverride",helperText:"Default AI model used for task execution when no per-task override is set.",fallbackOrder:"Project override → Global default lane → Automatic resolution"},{laneId:"execution",label:"Execution Model",globalProviderKey:"executionGlobalProvider",globalModelKey:"executionGlobalModelId",projectProviderKey:"executionProvider",projectModelKey:"executionModelId",helperText:"AI model used for task implementation (executor agent).",fallbackOrder:"Project override → Global execution lane → Global default lane → Automatic resolution"},{laneId:"planning",label:"Planning Model",globalProviderKey:"planningGlobalProvider",globalModelKey:"planningGlobalModelId",projectProviderKey:"planningProvider",projectModelKey:"planningModelId",helperText:"AI model used for task planning.",fallbackOrder:"Project override → Global planning lane → Global default lane → Automatic resolution"},{laneId:"validator",label:"Reviewer Model",globalProviderKey:"validatorGlobalProvider",globalModelKey:"validatorGlobalModelId",projectProviderKey:"validatorProvider",projectModelKey:"validatorModelId",helperText:"AI model used for code and specification review.",fallbackOrder:"Project override → Global reviewer lane → Global default lane → Automatic resolution"},{laneId:"summarization",label:"Title and Git Commit Message Summarization Model",globalProviderKey:"titleSummarizerGlobalProvider",globalModelKey:"titleSummarizerGlobalModelId",projectProviderKey:"titleSummarizerProvider",projectModelKey:"titleSummarizerModelId",helperText:"AI model used for auto-generating task titles and merge commit summaries.",fallbackOrder:"Project override → Global summarization lane → Project planning lane → Project default lane → Global default lane → Automatic resolution"}];function gs(t){if(!fe?.project)return"inherited";const s=fe.project[t.projectProviderKey],l=fe.project[t.projectModelKey];return s!==void 0||l!==void 0?"overridden":"inherited"}function cr(t){const s=a[t.projectProviderKey],l=a[t.projectModelKey];return s&&l?`${s}/${l}`:""}function dr(t,s){if(s){const l=s.indexOf("/");i(c=>({...c,[t.projectProviderKey]:s.slice(0,l),[t.projectModelKey]:s.slice(l+1)}))}else{if(gs(t)==="inherited")return;i(c=>({...c,[t.projectProviderKey]:void 0,[t.projectModelKey]:void 0}))}}function ur(t){gs(t)!=="inherited"&&i(l=>({...l,[t.projectProviderKey]:void 0,[t.projectModelKey]:void 0}))}const mr=r.useCallback(t=>{_t(t),Gt(".")},[Gt]),$e=r.useCallback(()=>{_t(null)},[]),bs=r.useCallback(t=>{we!==null&&(i(s=>{const l=s.overlapIgnorePaths&&s.overlapIgnorePaths.length>0?[...s.overlapIgnorePaths]:[""];return l[we]=t,{...s,overlapIgnorePaths:l}}),$e())},[we,$e]),hr=r.useCallback(()=>{if(Te===".")return;const t=Te.endsWith("/")?Te:`${Te}/`;bs(t)},[Te,bs]),pr=r.useCallback(t=>{t.target===t.currentTarget&&$e()},[$e]),gr=r.useCallback(()=>{Ut("."),_s(!0)},[Ut]),_e=r.useCallback(()=>{_s(!1)},[]),br=r.useCallback(t=>{const s=t.endsWith("/")?t:`${t}/`;i(l=>({...l,worktreesDir:s})),_e()},[_e]),fr=r.useCallback(()=>{const t=De==="."?"./":De.endsWith("/")?De:`${De}/`;i(s=>({...s,worktreesDir:t})),_e()},[De,_e]),xr=r.useCallback(t=>{t.target===t.currentTarget&&_e()},[_e]),vr=r.useCallback((t,s)=>{i(l=>{const c=l.overlapIgnorePaths&&l.overlapIgnorePaths.length>0?[...l.overlapIgnorePaths]:[""];return c[t]=s,{...l,overlapIgnorePaths:c}})},[]),jr=r.useCallback(t=>{if(i(s=>{const c=(s.overlapIgnorePaths&&s.overlapIgnorePaths.length>0?[...s.overlapIgnorePaths]:[""]).filter((d,h)=>h!==t);return{...s,overlapIgnorePaths:c.length>0?c:[]}}),we===t){$e();return}we!==null&&we>t&&_t(we-1)},[we,$e]),yr=r.useCallback(()=>{i(t=>{const s=t.overlapIgnorePaths&&t.overlapIgnorePaths.length>0?t.overlapIgnorePaths:[""];return{...t,overlapIgnorePaths:[...s,""]}})},[]),kr=r.useCallback(async()=>{if(st||Z)return;const t=a.researchSettings?.limits;if(t?.maxConcurrentRuns!==void 0&&(!Number.isFinite(t.maxConcurrentRuns)||t.maxConcurrentRuns<1)){at("Research max concurrent runs must be at least 1.");return}if(t?.maxSourcesPerRun!==void 0&&(!Number.isFinite(t.maxSourcesPerRun)||t.maxSourcesPerRun<1)){at("Research max sources per run must be at least 1.");return}if(t?.maxDurationMs!==void 0&&(!Number.isFinite(t.maxDurationMs)||t.maxDurationMs<1e3)){at("Research max duration must be at least 1000 ms.");return}if(t?.requestTimeoutMs!==void 0&&(!Number.isFinite(t.requestTimeoutMs)||t.requestTimeoutMs<1e3)){at("Research request timeout must be at least 1000 ms.");return}at(null);try{const s={...a,worktreeInitCommand:a.worktreeInitCommand?.trim()||void 0,worktreesDir:a.worktreesDir?.trim()||void 0,worktrunk:{enabled:_&&a.worktrunk?.enabled===!0,binaryPath:a.worktrunk?.binaryPath?.trim()||void 0,onFailure:a.worktrunk?.onFailure??"fail"},taskPrefix:a.taskPrefix?.trim()||void 0,githubTrackingDefaultRepo:a.githubTrackingDefaultRepo?.trim()||void 0,githubAuthToken:a.githubAuthToken?.trim()||void 0,overlapIgnorePaths:(a.overlapIgnorePaths??[]).map(d=>d.trim()).filter(d=>d.length>0),experimentalFeatures:eo(a.experimentalFeatures)},l={};for(const[d,h]of Object.entries(s))if(!(d==="githubTrackingDefaultRepo"&&M!=="global-general")&&d!=="persistAgentThinkingLog"&&Mn(d)){const g=je?.[d];h===void 0&&g!==void 0?l[d]=null:l[d]=h}const c={};for(const[d,h]of Object.entries(s)){if(d==="githubTokenConfigured"||d==="prAuthAvailable"||d==="githubTrackingDefaultRepo"&&M==="global-general"||!Tn(d))continue;const g=F?.project?.[d];["planningProvider","planningModelId","validatorProvider","validatorModelId","executionProvider","executionModelId","titleSummarizerProvider","titleSummarizerModelId","defaultProviderOverride","defaultModelIdOverride","planningFallbackProvider","planningFallbackModelId","validatorFallbackProvider","validatorFallbackModelId","titleSummarizerFallbackProvider","titleSummarizerFallbackModelId"].includes(d)?h!==g&&(h==null&&g!==void 0&&g!==null?c[d]=null:h!==void 0&&(c[d]=h)):h!==g&&(h===void 0&&g!==void 0&&g!==null?c[d]=null:h!==void 0&&(c[d]=h))}await Promise.all([Object.keys(l).length>0?js(l):Promise.resolve(),Object.keys(c).length>0?In(c,u):Promise.resolve(),Mt!==wa.current?Rn({globalMaxConcurrent:Mt??4}):Promise.resolve()]),o("Settings saved","success"),n()}catch(s){o(X(s),"error")}},[a,Mt,st,Z,je,F,n,o,u,M]),Nr=r.useCallback(async()=>{try{await En(ge,ns,u),mt(!1),o("Memory saved","success")}catch(t){o(X(t)||"Failed to save memory","error")}},[ge,ns,u,o]),Cr=r.useCallback(async()=>{ya(!0);try{const{path:t,content:s}=await Dn(ge,u),l=t??ge;ge!==l&&(us.current=!0),cs(l),Ft(s),mt(!1);const{files:c}=await Ka(u);pa(c),o("Memory file compacted","success")}catch(t){o(X(t)||"Failed to compact memory","error")}finally{ya(!1)}},[ge,u,o]),wr=r.useCallback(async()=>{ba(!0),fa(null);try{const t=await Ln(ds,u);fa(t),o(t.qmdAvailable?"Memory retrieval test complete":"qmd is not installed; local fallback was used",t.qmdAvailable?"success":"warning")}catch(t){o(X(t)||"Failed to test memory retrieval","error")}finally{ba(!1)}},[ds,u,o]),Sr=r.useCallback(async()=>{va(!0);try{await On(u),o("Dream processing completed","success")}catch(t){o(t instanceof Error?t.message:"Failed to run dream processing","error")}finally{va(!1)}},[u,o]),Pr=r.useCallback(async()=>{Na(!0);try{const t=await Bn(u);await Ma(),o(t.qmdAvailable?"qmd installed successfully":"qmd install finished, but qmd is still unavailable",t.qmdAvailable?"success":"warning")}catch(t){o(X(t)||"Failed to install qmd","error")}finally{Na(!1)}},[u,Ma,o]),Ar=()=>{if(!Z)return;const t=Z.name.trim();if(!t){o("Preset name is required","error");return}const s=a.modelPresets||[];let l;ct?l=ct:l=oi(t,s);const c={id:l,name:t,executorProvider:Z.executorProvider,executorModelId:Z.executorModelId,validatorProvider:Z.validatorProvider,validatorModelId:Z.validatorModelId};i(d=>{const h=d.modelPresets||[],g=ct?h.map(T=>T.id===ct?c:T):[...h,c];return{...d,modelPresets:g}}),dt(null),Se(null)},Ge=r.useCallback(async(t,s)=>{Qs(t);try{await s(),await Rt()}catch(l){o(X(l)||`Failed to ${t}`,"error")}finally{Qs(null)}},[o,Rt]),Fr=r.useCallback(()=>{if(typeof navigator<"u"&&navigator.userAgent.includes("Windows"))return"winget install Cloudflare.cloudflared";const t=typeof navigator<"u"?navigator.platform:"",s=typeof navigator<"u"?navigator.userAgent:"",l=/(Mac|iPhone|iPad|iPod)/i.test(t),c=/(arm64|aarch64)/i.test(`${t} ${s}`);return l?"brew install cloudflared":`curl -L --output /tmp/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${c?"arm64":"amd64"} && chmod +x /tmp/cloudflared && sudo mv /tmp/cloudflared /usr/local/bin/cloudflared # If sudo is unavailable, use: mkdir -p ~/.local/bin && mv /tmp/cloudflared ~/.local/bin/cloudflared`},[]),Ea=r.useCallback(()=>typeof navigator>"u"||!/(Mac|iPhone|iPad|iPod)/i.test(navigator.platform)?null:`curl -L --output /tmp/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-${/(arm64|aarch64)/i.test(`${navigator.platform} ${navigator.userAgent}`)?"arm64":"amd64"} && chmod +x /tmp/cloudflared && sudo mv /tmp/cloudflared /usr/local/bin/cloudflared`,[]),Mr=r.useCallback(async()=>{Js(!0),as(null);try{const t=await $n(u);if(!t.success){as(t.error??"Installation failed");return}const s=await xs(u);At(s),o("cloudflared installed successfully","success")}catch(t){as(t instanceof Error?t.message:"Installation failed")}finally{Js(!1)}},[o,u]),K=()=>rt==="global"?e.jsxs("div",{className:"settings-scope-banner settings-scope-global",children:[e.jsx("span",{className:"settings-scope-icon",children:e.jsx(vt,{size:14})}),e.jsx("span",{children:"These settings are shared across all your Fusion projects."})]}):rt==="project"?e.jsxs("div",{className:"settings-scope-banner settings-scope-project",children:[e.jsx("span",{className:"settings-scope-icon",children:e.jsx(Qa,{size:14})}),e.jsx("span",{children:"These settings only affect this project."})]}):null,Tr=()=>{switch(M){case"general":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"General"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"taskPrefix",children:"Task Prefix"}),e.jsx("input",{id:"taskPrefix",type:"text",placeholder:"FN",value:a.taskPrefix||"",onChange:t=>{const s=t.target.value;i(l=>({...l,taskPrefix:s||void 0})),s&&!/^[A-Z]{1,10}$/.test(s)?Os("Prefix must be 1–10 uppercase letters"):Os(null)}}),st&&e.jsx("small",{className:"field-error",children:st}),!st&&e.jsx("small",{children:"Prefix for new task IDs (e.g. KB, PROJ)"})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"requirePlanApproval",className:"checkbox-label",children:[e.jsx("input",{id:"requirePlanApproval",type:"checkbox",checked:a.requirePlanApproval||!1,onChange:t=>i(s=>({...s,requirePlanApproval:t.target.checked}))}),"Require plan approval"]}),e.jsx("small",{children:"When enabled, AI-generated task specifications require manual approval before moving to Todo"})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"ephemeralAgentsEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"ephemeralAgentsEnabled",type:"checkbox",checked:a.ephemeralAgentsEnabled!==!1,onChange:t=>i(s=>({...s,ephemeralAgentsEnabled:t.target.checked}))}),"Use ephemeral task-worker agents"]}),e.jsxs("small",{children:["When enabled (default), Fusion spawns short-lived ",e.jsx("code",{children:"executor-FN-XXXX"})," agents to run each task. When disabled, only permanent agents execute tasks and the scheduler auto-assigns work using the agent reporting chain. Tasks with no eligible permanent agent stay queued."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"completionDocumentationMode",children:"Completion Documentation Automation"}),e.jsxs("select",{id:"completionDocumentationMode",value:a.completionDocumentationMode||"off",onChange:t=>i(s=>({...s,completionDocumentationMode:t.target.value})),children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"changeset",children:"Require changeset (.changeset/*.md)"}),e.jsx("option",{value:"changelog",children:"Require changelog update (existing changelog)"})]}),e.jsxs("small",{children:["Controls how future task specs handle release-note artifacts at completion. Use changeset mode for repositories that follow",e.jsx("code",{children:".changeset"})," workflows, or changelog mode when contributors should update an existing changelog file."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"showQuickChatFAB",className:"checkbox-label",children:[e.jsx("input",{id:"showQuickChatFAB",type:"checkbox",checked:a.showQuickChatFAB===!0,onChange:t=>i(s=>({...s,showQuickChatFAB:t.target.checked}))}),"Show quick chat button"]}),e.jsx("small",{children:"Show the floating chat button in the dashboard. Chat is still accessible from the Chat tab in the mobile navigation."})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Chat history"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"chatAutoCleanupDays",children:"Auto-cleanup old chats"}),e.jsxs("select",{id:"chatAutoCleanupDays",className:"select",value:a.chatAutoCleanupDays??0,onChange:t=>i(s=>({...s,chatAutoCleanupDays:Number(t.target.value)||0})),children:[e.jsx("option",{value:0,children:"Off"}),e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:14,children:"14 days"}),e.jsx("option",{value:30,children:"30 days"}),e.jsx("option",{value:60,children:"60 days"}),e.jsx("option",{value:90,children:"90 days"})]}),e.jsx("small",{children:"Delete chat sessions and rooms that have been idle for this many days. Default: Off."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mailAutoCleanupDays",children:"Auto-prune old mail"}),e.jsxs("select",{id:"mailAutoCleanupDays",className:"select",value:a.mailAutoCleanupDays??0,onChange:t=>i(s=>({...s,mailAutoCleanupDays:Number(t.target.value)||0})),children:[e.jsx("option",{value:0,children:"Off"}),e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:14,children:"14 days"}),e.jsx("option",{value:30,children:"30 days"}),e.jsx("option",{value:60,children:"60 days"}),e.jsx("option",{value:90,children:"90 days"})]}),e.jsx("small",{children:"Delete inbox/outbox messages older than this many days. Default: Off. 7 days is the suggested setting."})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Chat Rooms"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"chatRoomRecentVerbatimMessages",children:"Recent verbatim room messages"}),e.jsx("input",{id:"chatRoomRecentVerbatimMessages",type:"number",min:"1",className:"input",placeholder:"25",value:a.chatRoomRecentVerbatimMessages??"",onChange:t=>i(s=>({...s,chatRoomRecentVerbatimMessages:Number(t.target.value)||void 0}))}),e.jsx("small",{children:"Number of most-recent chat-room messages kept verbatim in the responder transcript. Older messages are compacted into a summary block. Default: 25."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"chatRoomCompactionFetchLimit",children:"Room compaction fetch limit"}),e.jsx("input",{id:"chatRoomCompactionFetchLimit",type:"number",min:"1",className:"input",placeholder:"200",value:a.chatRoomCompactionFetchLimit??"",onChange:t=>i(s=>({...s,chatRoomCompactionFetchLimit:Number(t.target.value)||void 0}))}),e.jsx("small",{children:"Upper bound on messages fetched from the room store for compaction consideration. Default: 200."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"chatRoomSummaryMaxChars",children:"Room summary max characters"}),e.jsx("input",{id:"chatRoomSummaryMaxChars",type:"number",min:"200",className:"input",placeholder:"3000",value:a.chatRoomSummaryMaxChars??"",onChange:t=>i(s=>({...s,chatRoomSummaryMaxChars:Number(t.target.value)||void 0}))}),e.jsx("small",{children:'Hard cap on the synthesized "Earlier room context" summary block. Default: 3000.'})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Capacity Risk Banner"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"capacityRiskBannerEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"capacityRiskBannerEnabled",type:"checkbox",checked:a.capacityRiskBannerEnabled===!0,onChange:t=>i(s=>({...s,capacityRiskBannerEnabled:t.target.checked}))}),"Show capacity risk banner"]}),e.jsx("small",{children:"Warn on the board when todo work exceeds the threshold and no idle agents are available."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"capacityRiskTodoThresholdGeneral",children:"Todo threshold"}),e.jsx("input",{id:"capacityRiskTodoThresholdGeneral",type:"number",min:0,className:"input",value:a.capacityRiskTodoThreshold??20,onChange:t=>i(s=>({...s,capacityRiskTodoThreshold:t.target.value===""?0:Math.max(0,Number.parseInt(t.target.value,10)||0)}))}),e.jsx("small",{children:"Banner fires when todo count is strictly greater than this value (default 20). Applies when the banner is enabled."})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"GitHub Tracking"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"githubTrackingMode",children:"Default tracking mode for new tasks"}),e.jsxs("select",{id:"githubTrackingMode",className:"select",value:a.githubTrackingEnabledByDefault?"new-tasks":"off",onChange:t=>i(s=>({...s,githubTrackingEnabledByDefault:t.target.value==="new-tasks"})),children:[e.jsx("option",{value:"off",children:"Off (default)"}),e.jsx("option",{value:"new-tasks",children:"On for new tasks"})]}),e.jsx("small",{children:"Controls whether newly created tasks have GitHub issue tracking enabled by default. Individual tasks can still override this from the task detail modal."}),e.jsxs("small",{children:["Tracking issues use this task's title. If a task has no title yet, Fusion can summarize its description using the title summarization model in Project Models.",!a.autoSummarizeTitles&&!a.useAiMergeCommitSummary&&!a.githubTrackingEnabledByDefault?" Enable summarization in Project Models to configure that model.":""]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"projectGithubTrackingDefaultRepoGeneral",children:"Project default tracking repo"}),e.jsx(il,{id:"projectGithubTrackingDefaultRepoGeneral",ariaLabel:"Project default tracking repo",value:a.githubTrackingDefaultRepo??"",options:Bl,loading:$l,error:_l??void 0,placeholder:"owner/repo",onChange:t=>i(s=>({...s,githubTrackingDefaultRepo:t||void 0}))}),e.jsx("small",{children:"Default repo used when creating GitHub issues for tracked tasks. Falls back to the global default if blank."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"githubTrackingDedupEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"githubTrackingDedupEnabled",type:"checkbox",checked:a.githubTrackingDedupEnabled!==!1,onChange:t=>i(s=>({...s,githubTrackingDedupEnabled:t.target.checked}))}),"Search the tracking repo for likely duplicates before opening a new issue"]}),e.jsx("small",{children:"When enabled, Fusion checks open and closed issues in the target repo for likely duplicates (using File Scope paths and key symptoms) before creating a new tracking issue. Uncheck to always create a new issue."})]})]});case"global-general":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"General"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"showGitHubStarButton",className:"checkbox-label",children:[e.jsx("input",{id:"showGitHubStarButton",type:"checkbox",checked:a.showGitHubStarButton!==!1,onChange:t=>i(s=>({...s,showGitHubStarButton:t.target.checked}))}),'Show "Star on GitHub" button in Settings header']}),e.jsx("small",{children:"Once you click the Star button it's hidden automatically. Uncheck this to keep it hidden even before clicking."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"globalGithubTrackingDefaultRepo",children:"Global default tracking repo"}),e.jsx(il,{id:"globalGithubTrackingDefaultRepo",ariaLabel:"Global default tracking repo",value:a.githubTrackingDefaultRepo??"",options:Gl,loading:Ul,error:zl??void 0,placeholder:"owner/repo",onChange:t=>i(s=>({...s,githubTrackingDefaultRepo:t||void 0}))}),e.jsx("small",{children:"Projects inherit this value when they do not set a project default tracking repo."})]}),e.jsx(ki,{}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"persistAgentToolOutput",className:"checkbox-label",children:[e.jsx("input",{id:"persistAgentToolOutput",type:"checkbox",checked:a.persistAgentToolOutput!==!1,onChange:t=>i(s=>({...s,persistAgentToolOutput:t.target.checked}))}),"Save tool output in agent logs"]}),e.jsx("small",{children:"When disabled, tool rows are still logged but detailed tool payloads are omitted. Very large tool payloads may still be clipped even when this stays enabled."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("h5",{className:"settings-section-heading",children:"Save AI thinking logs"}),e.jsxs("label",{htmlFor:"persistAgentThinkingLogPermanent",className:"checkbox-label",children:[e.jsx("input",{id:"persistAgentThinkingLogPermanent",type:"checkbox",checked:Ja(a,{ephemeral:!1}),onChange:t=>i(s=>({...s,persistAgentThinkingLogPermanent:t.target.checked}))}),"Save AI thinking for permanent agents"]}),e.jsxs("label",{htmlFor:"persistAgentThinkingLogEphemeral",className:"checkbox-label",children:[e.jsx("input",{id:"persistAgentThinkingLogEphemeral",type:"checkbox",checked:Ja(a,{ephemeral:!0}),onChange:t=>i(s=>({...s,persistAgentThinkingLogEphemeral:t.target.checked}))}),"Save AI thinking for ephemeral / task-worker agents"]}),e.jsxs("small",{children:["Leave both thinking toggles off to keep the original default behavior. This only controls persisted ",e.jsx("code",{children:"thinking"})," rows and does not affect assistant text or tool rows."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"fnBinaryCheckEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"fnBinaryCheckEnabled",type:"checkbox",checked:a.fnBinaryCheckEnabled!==!1,onChange:t=>i(s=>({...s,fnBinaryCheckEnabled:t.target.checked}))}),"Check for the ",e.jsx("code",{children:"fn"})," CLI binary on PATH"]}),e.jsxs("small",{children:["When enabled, the dashboard probes for a globally-installed"," ",e.jsx("code",{children:"fn"})," / ",e.jsx("code",{children:"fusion"})," CLI by spawning"," ",e.jsx("code",{children:"<bin> --version"}),". Disable this if your local dev process is the source of truth and you don't want any outdated globally-installed binary executed during the probe."]})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Updates"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"updateCheckEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"updateCheckEnabled",type:"checkbox",checked:a.updateCheckEnabled!==!1,onChange:t=>i(s=>({...s,updateCheckEnabled:t.target.checked}))}),"Check for updates automatically"]}),e.jsxs("small",{children:["When enabled, Fusion checks npm for new versions of"," ",e.jsx("code",{children:"@runfusion/fusion"})," and shows update notices in the CLI and dashboard. Cadence is governed by the frequency below."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"updateCheckFrequency",children:"Frequency"}),e.jsxs("select",{id:"updateCheckFrequency",value:a.updateCheckFrequency??"daily",onChange:t=>i(s=>({...s,updateCheckFrequency:t.target.value})),disabled:a.updateCheckEnabled===!1,children:[e.jsx("option",{value:"manual",children:"Manual only — never auto-check"}),e.jsx("option",{value:"on-startup",children:"On startup — once per server launch"}),e.jsx("option",{value:"daily",children:"Daily (recommended)"}),e.jsx("option",{value:"weekly",children:"Weekly"})]}),e.jsx("small",{children:"Controls how often the dashboard re-fetches the npm registry. Use the version + refresh control in the header to trigger an immediate check at any time."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"autoReloadOnVersionChange",className:"checkbox-label",children:[e.jsx("input",{id:"autoReloadOnVersionChange",type:"checkbox",checked:a.autoReloadOnVersionChange!==!1,onChange:t=>i(s=>({...s,autoReloadOnVersionChange:t.target.checked}))}),"Auto-reload dashboard on version change"]}),e.jsx("small",{children:"When enabled (default), the dashboard automatically reloads when it detects a new build version — either from server rebuilds or service worker updates. Disable this to stay on the current version until you manually refresh."})]})]});case"global-models":{const t=a.defaultProvider&&a.defaultModelId?`${a.defaultProvider}/${a.defaultModelId}`:"",s=Ra.filter(l=>l.laneId!=="default");return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Default Model"}),wt?e.jsx("div",{className:"settings-empty-state",children:"Loading available models…"}):ne.length===0?e.jsx("div",{className:"settings-empty-state settings-muted",children:"No models available. Configure authentication first."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"defaultModel",children:"Default Model"}),e.jsx(Ee,{id:"defaultModel",label:"Default Model",models:ne,value:t,onChange:l=>{if(!l)i(c=>({...c,defaultProvider:void 0,defaultModelId:void 0}));else{const c=l.indexOf("/");i(d=>({...d,defaultProvider:l.slice(0,c),defaultModelId:l.slice(c+1)}))}},placeholder:"Use default",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re}),e.jsx("small",{children:'Default AI model used for task execution when no per-task override is set. "Use default" lets the engine choose automatically.'})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"fallbackModel",children:"Fallback Model"}),e.jsx(Ee,{id:"fallbackModel",label:"Fallback Model",models:ne,value:a.fallbackProvider&&a.fallbackModelId?`${a.fallbackProvider}/${a.fallbackModelId}`:"",onChange:l=>{if(!l)i(c=>({...c,fallbackProvider:void 0,fallbackModelId:void 0}));else{const c=l.indexOf("/");i(d=>({...d,fallbackProvider:l.slice(0,c),fallbackModelId:l.slice(c+1)}))}},placeholder:"No fallback",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re}),e.jsx("small",{children:"Used automatically if the primary default model hits a retryable provider error like rate limiting or overload."})]})]}),(()=>{const l=ne.find(c=>c.provider===a.defaultProvider&&c.id===a.defaultModelId);return l&&!l.reasoning?null:e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"defaultThinkingLevel",children:"Thinking Effort"}),e.jsxs("select",{id:"defaultThinkingLevel",value:a.defaultThinkingLevel||"",onChange:c=>{const d=c.target.value;i(h=>({...h,defaultThinkingLevel:d||void 0}))},children:[e.jsx("option",{value:"",children:"Default"}),ni.map(c=>e.jsx("option",{value:c,children:c.charAt(0).toUpperCase()+c.slice(1)},c))]}),e.jsx("small",{children:"Controls how much reasoning effort the AI model uses. Higher levels produce better results but cost more."})]})})(),ne.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Model Lanes"}),e.jsx("p",{className:"settings-description",children:"Global baseline models for each AI role. Project settings can override these per-project."}),s.map(l=>{const c=a[l.globalProviderKey],d=a[l.globalModelKey],h=c&&d?`${c}/${d}`:"";return e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:`global-${l.laneId}-model`,children:l.label}),e.jsx(Ee,{id:`global-${l.laneId}-model`,label:l.label,models:ne,value:h,onChange:g=>{if(!g){i(G=>({...G,[l.globalProviderKey]:void 0,[l.globalModelKey]:void 0}));return}const T=g.indexOf("/");i(G=>({...G,[l.globalProviderKey]:g.slice(0,T),[l.globalModelKey]:g.slice(T+1)}))},placeholder:"Use default",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re}),e.jsx("small",{children:l.helperText})]},`global-${l.laneId}`)})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Startup Model Sync"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"openrouterModelSync",className:"checkbox-label",children:[e.jsx("input",{id:"openrouterModelSync",type:"checkbox",checked:a.openrouterModelSync!==!1,onChange:l=>i(c=>({...c,openrouterModelSync:l.target.checked}))}),"Sync OpenRouter model list at startup"]}),e.jsx("small",{children:"When enabled, startup fetches the latest available models from the OpenRouter API so model pickers always include the newest catalog."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"opencodeGoModelSync",className:"checkbox-label",children:[e.jsx("input",{id:"opencodeGoModelSync",type:"checkbox",checked:a.opencodeGoModelSync!==!1,onChange:l=>i(c=>({...c,opencodeGoModelSync:l.target.checked}))}),"Sync opencode-go model list at startup"]}),e.jsxs("small",{children:["When enabled, startup refreshes models through the local ",e.jsx("code",{children:"opencode models opencode --refresh"}),"flow and publishes them under the opencode-go provider in model pickers."]})]}),e.jsxs("details",{children:[e.jsx("summary",{children:"OpenRouter advanced"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterAppAttributionReferer",children:"OpenRouter HTTP-Referer"}),e.jsx("input",{id:"openrouterAppAttributionReferer",className:"input",placeholder:"https://runfusion.ai",value:a.openrouterAppAttribution?.referer??"",onChange:l=>i(c=>({...c,openrouterAppAttribution:{...c.openrouterAppAttribution||{},referer:l.target.value}}))}),e.jsx("small",{children:"Leave empty to omit this header. Default: https://runfusion.ai."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterAppAttributionTitle",children:"OpenRouter X-Title"}),e.jsx("input",{id:"openrouterAppAttributionTitle",className:"input",placeholder:"Fusion",value:a.openrouterAppAttribution?.title??"",onChange:l=>i(c=>({...c,openrouterAppAttribution:{...c.openrouterAppAttribution||{},title:l.target.value}}))}),e.jsx("small",{children:"Leave empty to omit this header. Default: Fusion."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterModelFiltersSupportedParameters",children:"OpenRouter supported_parameters filter"}),e.jsx("input",{id:"openrouterModelFiltersSupportedParameters",className:"input",placeholder:"tools, structured_outputs",value:ft(a.openrouterModelFilters?.supported_parameters),onChange:l=>{const c=xt(l.target.value);i(d=>({...d,openrouterModelFilters:{...d.openrouterModelFilters||{},supported_parameters:c.length>0?c:void 0}}))}}),e.jsx("small",{children:"Comma-separated values sent to OpenRouter model sync."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterModelFiltersOutputModalities",children:"OpenRouter output_modalities filter"}),e.jsx("input",{id:"openrouterModelFiltersOutputModalities",className:"input",placeholder:"text",value:ft(a.openrouterModelFilters?.output_modalities),onChange:l=>{const c=xt(l.target.value);i(d=>({...d,openrouterModelFilters:{...d.openrouterModelFilters||{},output_modalities:c.length>0?c:void 0}}))}}),e.jsx("small",{children:"Comma-separated values sent to OpenRouter model sync."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterProviderPreferencesOrder",children:"OpenRouter routing order"}),e.jsx("input",{id:"openrouterProviderPreferencesOrder",className:"input",placeholder:"openai, anthropic",value:ft(a.openrouterProviderPreferences?.order),onChange:l=>{const c=xt(l.target.value);i(d=>({...d,openrouterProviderPreferences:{...d.openrouterProviderPreferences||{},order:c.length>0?c:void 0}}))}})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterProviderPreferencesIgnore",children:"OpenRouter routing ignore"}),e.jsx("input",{id:"openrouterProviderPreferencesIgnore",className:"input",placeholder:"provider-name",value:ft(a.openrouterProviderPreferences?.ignore),onChange:l=>{const c=xt(l.target.value);i(d=>({...d,openrouterProviderPreferences:{...d.openrouterProviderPreferences||{},ignore:c.length>0?c:void 0}}))}})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterProviderPreferencesOnly",children:"OpenRouter routing only"}),e.jsx("input",{id:"openrouterProviderPreferencesOnly",className:"input",placeholder:"provider-name",value:ft(a.openrouterProviderPreferences?.only),onChange:l=>{const c=xt(l.target.value);i(d=>({...d,openrouterProviderPreferences:{...d.openrouterProviderPreferences||{},only:c.length>0?c:void 0}}))}})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterProviderPreferencesAllowFallbacks",children:"OpenRouter allow fallbacks"}),e.jsxs("select",{id:"openrouterProviderPreferencesAllowFallbacks",className:"select",value:a.openrouterProviderPreferences?.allow_fallbacks===void 0?"default":a.openrouterProviderPreferences.allow_fallbacks?"allow":"deny",onChange:l=>{const c=l.target.value;i(d=>({...d,openrouterProviderPreferences:{...d.openrouterProviderPreferences||{},allow_fallbacks:c==="default"?void 0:c==="allow"}}))},children:[e.jsx("option",{value:"default",children:"default"}),e.jsx("option",{value:"allow",children:"allow"}),e.jsx("option",{value:"deny",children:"deny"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"openrouterProviderPreferencesSort",children:"OpenRouter routing sort"}),e.jsxs("select",{id:"openrouterProviderPreferencesSort",className:"select",value:a.openrouterProviderPreferences?.sort??"default",onChange:l=>{const c=l.target.value;i(d=>({...d,openrouterProviderPreferences:{...d.openrouterProviderPreferences||{},sort:c==="default"?void 0:c}}))},children:[e.jsx("option",{value:"default",children:"default"}),e.jsx("option",{value:"price",children:"price"}),e.jsx("option",{value:"throughput",children:"throughput"}),e.jsx("option",{value:"latency",children:"latency"})]})]}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{htmlFor:"openrouterProviderPreferencesRequireParameters",className:"checkbox-label",children:[e.jsx("input",{id:"openrouterProviderPreferencesRequireParameters",type:"checkbox",checked:a.openrouterProviderPreferences?.require_parameters===!0,onChange:l=>i(c=>({...c,openrouterProviderPreferences:{...c.openrouterProviderPreferences||{},require_parameters:l.target.checked}}))}),"Require parameters"]})})]})]})}case"secrets":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Secrets"}),e.jsx(hi,{addToast:o})]});case"project-models":{const t=a.modelPresets||[],s=t.map(x=>({id:x.id,name:x.name})),l=new Set(Object.values(a.defaultPresetBySize||{}).filter(Boolean)),c=Ra.filter(x=>x.laneId==="default"||x.laneId==="execution"||x.laneId==="planning"||x.laneId==="validator"),d=si(a),h=ai(a),g=li(a),T=x=>x.laneId==="default"?"Project Default Model":x.label,G=x=>x.laneId==="default"?"Project-wide default AI model used when no more specific task or project lane override is set.":x.helperText;return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Token Cap"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"tokenCap",children:"Token Cap"}),e.jsxs("div",{className:"settings-token-cap-row",children:[e.jsx("input",{id:"tokenCap",type:"number",placeholder:"No cap",value:a.tokenCap??"",onChange:x=>{const N=x.target.value;i(D=>({...D,tokenCap:N?parseInt(N,10):null}))}}),a.tokenCap!=null&&e.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",title:"Reset to default (no cap)",onClick:()=>i(x=>({...x,tokenCap:null})),style:{whiteSpace:"nowrap"},children:"Reset"})]}),e.jsx("small",{children:"Automatically compact context when approaching this token count. Leave empty for no cap (compact only on overflow errors). Set a number to proactively compact when reaching this token count."})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Model Lanes"}),e.jsx("p",{className:"settings-description",children:"Override global model settings at the project level. Each lane controls a specific AI usage context. Unset lanes inherit from the corresponding global lane. The Project Default Model is the fallback for this project when a more specific lane is unset."}),wt?e.jsx("div",{className:"settings-empty-state",children:"Loading available models…"}):ne.length===0?e.jsx("div",{className:"settings-empty-state settings-muted",children:"No models available. Configure authentication first."}):e.jsx(e.Fragment,{children:c.map(x=>{const N=gs(x),D=cr(x),de=N==="overridden",f=T(x);return e.jsxs("div",{className:"form-group",children:[e.jsxs("div",{className:"settings-model-lane-label-row",children:[e.jsx("label",{htmlFor:`${x.laneId}Model`,children:f}),e.jsx("span",{className:`settings-lane-badge ${de?"settings-lane-badge--override":"settings-lane-badge--inherited"}`,title:de?"Explicitly set for this project":"Inherited from global settings",children:de?"Override (Project)":"Inherited (Global)"})]}),e.jsxs("div",{className:"settings-model-lane-control-row",children:[e.jsx("div",{className:"settings-model-lane-control-main",children:e.jsx(Ee,{id:`${x.laneId}Model`,label:f,models:ne,value:D,onChange:Ne=>dr(x,Ne),placeholder:x.laneId==="default"?"Use global default":"Use global",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re})}),de&&e.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",title:"Reset to inherit from global",onClick:()=>ur(x),style:{whiteSpace:"nowrap"},children:"Reset"})]}),e.jsxs("small",{children:[G(x)," Falls back to: ",x.fallbackOrder,"."]})]},x.laneId)})}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Fallback Models"}),wt?e.jsx("div",{className:"settings-empty-state",children:"Loading available models…"}):ne.length===0?e.jsx("div",{className:"settings-empty-state settings-muted",children:"No models available."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"planningFallbackModel",children:"Planning Fallback Model"}),e.jsx(Ee,{id:"planningFallbackModel",label:"Planning Fallback Model",models:ne,value:a.planningFallbackProvider&&a.planningFallbackModelId?`${a.planningFallbackProvider}/${a.planningFallbackModelId}`:"",onChange:x=>{if(!x)i(N=>({...N,planningFallbackProvider:void 0,planningFallbackModelId:void 0}));else{const N=x.indexOf("/");i(D=>({...D,planningFallbackProvider:x.slice(0,N),planningFallbackModelId:x.slice(N+1)}))}},placeholder:"Use global fallback",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re}),e.jsx("small",{children:"Used if the planning model fails due to rate limits or provider overload. Defaults to the global fallback model."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"validatorFallbackModel",children:"Reviewer Fallback Model"}),e.jsx(Ee,{id:"validatorFallbackModel",label:"Reviewer Fallback Model",models:ne,value:a.validatorFallbackProvider&&a.validatorFallbackModelId?`${a.validatorFallbackProvider}/${a.validatorFallbackModelId}`:"",onChange:x=>{if(!x)i(N=>({...N,validatorFallbackProvider:void 0,validatorFallbackModelId:void 0}));else{const N=x.indexOf("/");i(D=>({...D,validatorFallbackProvider:x.slice(0,N),validatorFallbackModelId:x.slice(N+1)}))}},placeholder:"Use global fallback",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re}),e.jsx("small",{children:"Used if the reviewer model fails due to rate limits or provider overload. Defaults to the global fallback model."})]})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Model Presets"}),e.jsxs("div",{className:"form-group settings-model-presets",children:[e.jsx("label",{children:"Configured presets"}),t.length===0?e.jsx("div",{className:"settings-empty-state settings-muted",children:"No presets configured yet."}):e.jsx("div",{className:"settings-preset-list",children:t.map(x=>{const N=ri(x),D=`${N.executorValue||"default"} / ${N.validatorValue||"default"}`;return e.jsxs("div",{className:"settings-preset-item",children:[e.jsxs("div",{className:"settings-preset-item-meta",children:[e.jsx("strong",{children:x.name}),e.jsx("span",{className:"settings-muted settings-preset-summary",children:D})]}),e.jsxs("div",{className:"settings-preset-item-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>{dt(x.id),Se({...x})},children:"Edit"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:async()=>{l.has(x.id)&&!await q({title:"Delete Preset",message:`Preset "${x.name}" is used in auto-selection. Delete it anyway?`,danger:!0})||(i(de=>({...de,modelPresets:(de.modelPresets||[]).filter(f=>f.id!==x.id),defaultPresetBySize:Object.fromEntries(Object.entries(de.defaultPresetBySize||{}).filter(([,f])=>f!==x.id))})),ct===x.id&&(dt(null),Se(null)))},children:"Delete"})]})]},x.id)})}),Z?null:e.jsx("div",{className:"settings-preset-actions",children:e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>{dt(null),Se({id:"",name:"",executorProvider:void 0,executorModelId:void 0,validatorProvider:void 0,validatorModelId:void 0})},children:"Add Preset"})})]}),Z?e.jsxs("div",{className:"form-group settings-preset-editor",children:[e.jsx("label",{children:"Preset editor"}),e.jsxs("div",{className:"settings-preset-editor-fields",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"preset-name",children:"Name"}),e.jsx("input",{id:"preset-name",type:"text",value:Z.name,onChange:x=>{const N=x.target.value;Se(D=>D&&{...D,name:N})}})]}),ne.length===0?e.jsx("small",{children:"No models available. Configure authentication first."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"preset-executor-model",children:"Executor model"}),e.jsx(Ee,{id:"preset-executor-model",label:"Preset executor model",models:ne,value:Z.executorProvider&&Z.executorModelId?`${Z.executorProvider}/${Z.executorModelId}`:"",onChange:x=>{if(!x){Se(D=>D&&{...D,executorProvider:void 0,executorModelId:void 0});return}const N=x.indexOf("/");Se(D=>D&&{...D,executorProvider:x.slice(0,N),executorModelId:x.slice(N+1)})},placeholder:"Use default",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"preset-validator-model",children:"Reviewer model"}),e.jsx(Ee,{id:"preset-validator-model",label:"Preset reviewer model",models:ne,value:Z.validatorProvider&&Z.validatorModelId?`${Z.validatorProvider}/${Z.validatorModelId}`:"",onChange:x=>{if(!x){Se(D=>D&&{...D,validatorProvider:void 0,validatorModelId:void 0});return}const N=x.indexOf("/");Se(D=>D&&{...D,validatorProvider:x.slice(0,N),validatorModelId:x.slice(N+1)})},placeholder:"Use default",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re})]})]})]}),e.jsxs("div",{className:"modal-actions settings-preset-editor-actions",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ar,children:"Save preset"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>{dt(null),Se(null)},children:"Cancel"})]})]}):null,e.jsx("div",{className:"form-group settings-preset-auto-select",children:e.jsxs("label",{htmlFor:"autoSelectModelPreset",className:"checkbox-label",children:[e.jsx("input",{id:"autoSelectModelPreset",type:"checkbox",checked:a.autoSelectModelPreset||!1,onChange:x=>i(N=>({...N,autoSelectModelPreset:x.target.checked}))}),"Auto-select preset based on task size"]})}),a.autoSelectModelPreset?e.jsx("div",{className:"settings-preset-size-grid",children:["S","M","L"].map(x=>e.jsxs("div",{className:"form-group settings-preset-size-row",children:[e.jsx("label",{htmlFor:`preset-size-${x}`,children:x==="S"?"Small tasks (S):":x==="M"?"Medium tasks (M):":"Large tasks (L):"}),e.jsxs("select",{id:`preset-size-${x}`,value:a.defaultPresetBySize?.[x]||"",onChange:N=>{const D=N.target.value||void 0;i(de=>({...de,defaultPresetBySize:{...de.defaultPresetBySize||{},[x]:D}}))},children:[e.jsx("option",{value:"",children:"No preset"}),s.map(N=>e.jsx("option",{value:N.id,children:N.name},N.id))]})]},x))}):null,e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"AI Title and Git Commit Message Summarization"}),e.jsx("p",{className:"settings-description",children:"Configures the model used for two short-summary jobs: auto-generating task titles from long descriptions, and generating merge commit summaries from step commits and diff stats."}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"autoSummarizeTitles",className:"checkbox-label",children:[e.jsx("input",{id:"autoSummarizeTitles",type:"checkbox",checked:a.autoSummarizeTitles||!1,onChange:x=>i(N=>({...N,autoSummarizeTitles:x.target.checked}))}),"Auto-summarize long descriptions as titles"]}),e.jsx("small",{children:"When enabled, tasks created without a title but with descriptions over 200 characters will automatically get an AI-generated title (max 60 characters). The same model is also used to generate fallback merge commit message bodies when the branch's commit log is empty (e.g. squash merges with no unique commits), and GitHub tracking issue titles when a tracked task has no title yet."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"useAiMergeCommitSummary",className:"checkbox-label",children:[e.jsx("input",{id:"useAiMergeCommitSummary",type:"checkbox",checked:a.useAiMergeCommitSummary||!1,onChange:x=>i(N=>({...N,useAiMergeCommitSummary:x.target.checked}))}),"AI merge commit summaries"]}),e.jsx("small",{children:"When enabled, merge commit messages will include an AI-generated summary of the changes instead of just listing step commit subjects. Uses the title summarization model."})]}),(a.autoSummarizeTitles||a.useAiMergeCommitSummary||a.githubTrackingEnabledByDefault||!1)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Title, commit message, and GitHub tracking issue summarization model"}),wt?e.jsx("small",{children:"Loading available models..."}):ne.length===0?e.jsx("small",{children:"No models available. Configure authentication first."}):e.jsx(Ee,{id:"titleSummarizerModel",label:"Title, commit message, and GitHub tracking issue summarization model",models:ne,value:a.titleSummarizerProvider&&a.titleSummarizerModelId?`${a.titleSummarizerProvider}/${a.titleSummarizerModelId}`:"",onChange:x=>{if(!x){i(D=>({...D,titleSummarizerProvider:void 0,titleSummarizerModelId:void 0}));return}const N=x.indexOf("/");i(D=>({...D,titleSummarizerProvider:x.slice(0,N),titleSummarizerModelId:x.slice(N+1)}))},placeholder:"Use fallback model",favoriteProviders:me,onToggleFavorite:Ie,favoriteModels:he,onToggleModelFavorite:Re}),e.jsx("small",{children:"Also used to summarize task descriptions into GitHub tracking issue titles when a task has no title yet."}),e.jsx("small",{children:a.titleSummarizerProvider&&a.titleSummarizerModelId?"Using explicitly configured model":g.provider&&g.modelId?g.provider===d.provider&&g.modelId===d.modelId?"(using planning model)":g.provider===h.provider&&g.modelId===h.modelId?a.defaultProviderOverride&&a.defaultModelIdOverride?"(using project default model)":"(using global default model)":"(using global summarization model)":"(using automatic model selection)"})]}),e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"modal-actions settings-summarization-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>i(x=>({...x,titleSummarizerProvider:d.provider,titleSummarizerModelId:d.modelId})),disabled:!d.provider||!d.modelId,children:"Use planning model"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>i(x=>({...x,titleSummarizerProvider:h.provider,titleSummarizerModelId:h.modelId})),disabled:!h.provider||!h.modelId,children:"Use default model"})]})})]})]})}case"appearance":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Appearance"}),e.jsx(ji,{themeMode:C,colorTheme:w,dashboardFontScalePct:R,onThemeModeChange:t=>{i(s=>({...s,themeMode:t})),I?.(t)},onColorThemeChange:t=>{i(s=>({...s,colorTheme:t})),j?.(t)},onDashboardFontScaleChange:t=>{i(s=>({...s,dashboardFontScalePct:t})),E?.(t)}}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:te,onChange:t=>ti(t.target.checked)}),e.jsx("span",{children:"Hide AI session notification banners"})]}),e.jsx("small",{className:"form-text text-muted",children:"Suppress the “needs your input” banner that appears when AI sessions are awaiting input or have failed."})]})]});case"scheduling":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Scheduling"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"globalMaxConcurrent",children:"Global Max Concurrent"}),e.jsx("input",{id:"globalMaxConcurrent",type:"number",min:0,max:1e4,value:Mt??"",onChange:t=>{const s=t.target.value;Pa.current=!0,Ca(s===""?void 0:Number(s))}}),e.jsx("small",{className:"form-text text-muted",children:"Maximum concurrent agents across all projects"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"maxConcurrent",children:"Max Concurrent Tasks"}),e.jsx("input",{id:"maxConcurrent",type:"number",min:1,max:10,value:a.maxConcurrent??"",onChange:t=>{const s=t.target.value;i(l=>({...l,maxConcurrent:s===""?void 0:Number(s)}))}})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"maxTriageConcurrent",children:"Max Triage Concurrent"}),e.jsx("input",{id:"maxTriageConcurrent",type:"number",min:1,max:10,value:a.maxTriageConcurrent??"",onChange:t=>{const s=t.target.value;i(l=>({...l,maxTriageConcurrent:s===""?void 0:Number(s)}))}}),e.jsx("small",{children:"Maximum concurrent planning agents"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"pollIntervalMs",children:"Poll Interval (ms)"}),e.jsx("input",{id:"pollIntervalMs",type:"number",min:5e3,step:1e3,value:a.pollIntervalMs??"",onChange:t=>{const s=t.target.value;i(l=>({...l,pollIntervalMs:s===""?void 0:Number(s)}))}})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"heartbeatScopeDiscipline",children:"Heartbeat Scope Discipline"}),e.jsxs("select",{id:"heartbeatScopeDiscipline",className:"select",value:a.heartbeatScopeDiscipline??"strict",onChange:t=>{i(s=>({...s,heartbeatScopeDiscipline:t.target.value}))},children:[e.jsx("option",{value:"strict",children:"Strict (default)"}),e.jsx("option",{value:"lite",children:"Lite"}),e.jsx("option",{value:"off",children:"Off"})]}),e.jsx("small",{children:"Strict — coordination-focused; higher per-tick tokens. Lite — pre-2026-05-11 behavior. Off — minimal procedure."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"taskStuckTimeoutMs",children:"Stuck Task Timeout (minutes)"}),e.jsx("input",{id:"taskStuckTimeoutMs",type:"number",min:1,step:1,value:a.taskStuckTimeoutMs?Math.round(a.taskStuckTimeoutMs/6e4):"",onChange:t=>{const s=t.target.value,l=Number(s);i(c=>({...c,taskStuckTimeoutMs:s&&l>0?l*6e4:void 0}))}}),e.jsx("small",{children:"Timeout in minutes for detecting stuck tasks. When a task's agent session shows no activity for longer than this duration, the task is terminated and retried. Leave empty to disable. Suggested: 10."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"staleHighFanoutBlockerAgeThresholdMs",children:"Stale High Fan-out Escalation (hours)"}),e.jsx("input",{id:"staleHighFanoutBlockerAgeThresholdMs",type:"number",min:1,step:1,value:a.staleHighFanoutBlockerAgeThresholdMs?Math.round(a.staleHighFanoutBlockerAgeThresholdMs/36e5):"",onChange:t=>{const s=t.target.value,l=Number(s);i(c=>({...c,staleHighFanoutBlockerAgeThresholdMs:s&&l>0?l*36e5:void 0}))}}),e.jsx("small",{children:"Escalate high fan-out blockers only after they remain in in-progress or in-review for this many hours (age source: columnMovedAt, fallback updatedAt). Default: 2 hours."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"preserveProgressOnStuckRequeue",className:"checkbox-label",children:[e.jsx("input",{id:"preserveProgressOnStuckRequeue",type:"checkbox",checked:a.preserveProgressOnStuckRequeue!==!1,onChange:t=>i(s=>({...s,preserveProgressOnStuckRequeue:t.target.checked}))}),"Preserve step progress on stuck-task requeue"]}),e.jsx("small",{children:"When the stuck detector kills and re-queues a task, keep completed step statuses so the agent can resume from where it left off. Disable to reset every step to pending on each stuck retry. Default: enabled."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"specStalenessEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"specStalenessEnabled",type:"checkbox",checked:a.specStalenessEnabled||!1,onChange:t=>i(s=>({...s,specStalenessEnabled:t.target.checked}))}),"Enable plan staleness enforcement"]}),e.jsx("small",{children:"When enabled, tasks with stale plans (PROMPT.md older than the threshold) are automatically sent back to planning for replanning"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"specStalenessMaxAgeMs",children:"Stale Spec Threshold (hours)"}),e.jsx("input",{id:"specStalenessMaxAgeMs",type:"number",min:0,step:1,value:a.specStalenessMaxAgeMs!==void 0?Math.round(a.specStalenessMaxAgeMs/36e5):"",onChange:t=>{const s=t.target.value,l=Number(s);i(c=>({...c,specStalenessMaxAgeMs:s!==""?l*36e5:void 0}))},disabled:!a.specStalenessEnabled}),e.jsx("small",{children:"Maximum age in hours before a plan is considered stale. Default: 6 hours."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"autoArchiveDoneTasksEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"autoArchiveDoneTasksEnabled",type:"checkbox",checked:a.autoArchiveDoneTasksEnabled??!0,onChange:t=>i(s=>({...s,autoArchiveDoneTasksEnabled:t.target.checked}))}),"Enable automatic task archiving"]}),e.jsx("small",{children:"Completed tasks older than the threshold are moved out of the active task database."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"autoArchiveDoneAfterMs",children:"Archive Completed Tasks After (days)"}),e.jsx("input",{id:"autoArchiveDoneAfterMs",type:"number",min:1,step:1,value:a.autoArchiveDoneAfterMs!==void 0?Math.round(a.autoArchiveDoneAfterMs/ml):Zi,onChange:t=>{const s=t.target.value,l=Number(s);i(c=>({...c,autoArchiveDoneAfterMs:s===""?void 0:l*ml}))},disabled:a.autoArchiveDoneTasksEnabled===!1}),e.jsx("small",{children:"Number of days a task can stay in Done before it is archived. Default: 2 days (48 hours)."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"archiveAgentLogMode",children:"Archive Agent Log"}),e.jsxs("select",{id:"archiveAgentLogMode",value:a.archiveAgentLogMode??"compact",onChange:t=>i(s=>({...s,archiveAgentLogMode:t.target.value})),disabled:a.autoArchiveDoneTasksEnabled===!1,children:[e.jsx("option",{value:"compact",children:"Compact summary and recent entries"}),e.jsx("option",{value:"none",children:"Do not archive agent logs"}),e.jsx("option",{value:"full",children:"Full agent log"})]}),e.jsx("small",{children:"Compact mode keeps archive size low while preserving recent agent activity for context."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"maxStuckKills",children:"Max Stuck Retries"}),e.jsx("input",{id:"maxStuckKills",type:"number",min:1,step:1,value:a.maxStuckKills??"",onChange:t=>{const s=t.target.value,l=Number(s);i(c=>({...c,maxStuckKills:s&&l>0?l:void 0}))}}),e.jsx("small",{children:"Maximum stuck-detector retries before a task is marked failed. Default: 6."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"groupOverlappingFiles",className:"checkbox-label",children:[e.jsx("input",{id:"groupOverlappingFiles",type:"checkbox",checked:a.groupOverlappingFiles,onChange:t=>i(s=>({...s,groupOverlappingFiles:t.target.checked}))}),"Serialize tasks with overlapping files"]}),e.jsx("small",{children:"When enabled, tasks that modify the same files are queued serially to avoid merge conflicts"})]}),e.jsxs("div",{className:"form-group settings-overlap-ignore-group",children:[e.jsx("label",{children:"Ignored overlap paths"}),e.jsxs("small",{children:["Optional file or directory paths to ignore when overlap serialization is enabled. Paths are project-relative (for example ",e.jsx("code",{children:"docs/"})," or ",e.jsx("code",{children:"generated/*"}),")."]}),e.jsx("div",{className:"settings-overlap-ignore-list",children:(a.overlapIgnorePaths&&a.overlapIgnorePaths.length>0?a.overlapIgnorePaths:[""]).map((t,s)=>e.jsxs("div",{className:"settings-overlap-ignore-row",children:[e.jsxs("div",{className:"settings-overlap-ignore-path-controls",children:[e.jsx("input",{type:"text",value:t,placeholder:"docs/",onChange:l=>vr(s,l.target.value)}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>mr(s),"aria-label":`Browse path for ignored overlap entry ${s+1}`,children:"Browse"})]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>jr(s),disabled:(a.overlapIgnorePaths??[]).length===0&&s===0,children:"Remove"})]},`overlap-ignore-${s}`))}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:yr,children:"Add ignored path"})]}),e.jsx("div",{className:"settings-section-divider"}),e.jsx("h5",{className:"settings-section-heading",children:"Step Execution"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"runStepsInNewSessions",className:"checkbox-label",children:[e.jsx("input",{id:"runStepsInNewSessions",type:"checkbox",checked:a.runStepsInNewSessions||!1,onChange:t=>i(s=>({...s,runStepsInNewSessions:t.target.checked}))}),"Run each step in a new session"]}),e.jsx("small",{children:"Run each task step in its own fresh agent session for better isolation and error recovery. Failed steps can be retried individually."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"maxParallelSteps",children:"Maximum parallel steps"}),e.jsx("input",{id:"maxParallelSteps",type:"number",min:1,max:4,value:a.maxParallelSteps??"",onChange:t=>{const s=t.target.value;i(l=>({...l,maxParallelSteps:s===""?void 0:Number(s)}))},disabled:!a.runStepsInNewSessions}),e.jsx("small",{children:"Maximum number of steps to run in parallel when file scopes don't overlap (1-4)"})]})]});case"scheduled-evals":{const t=a.evalSettings??{},s=t.enabled??!1;return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Scheduled Evals"}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{htmlFor:"scheduled-evals-enabled",className:"checkbox-label",children:[e.jsx("input",{id:"scheduled-evals-enabled",type:"checkbox",checked:s,onChange:l=>i(c=>({...c,evalSettings:{...c.evalSettings??{},enabled:l.target.checked}}))}),"Enable scheduled eval runs for this project"]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"scheduled-evals-interval",children:"Interval (ms)"}),e.jsx("input",{id:"scheduled-evals-interval",className:"input",type:"number",min:6e4,max:6048e5,step:1e3,disabled:!s,value:t.intervalMs??864e5,onChange:l=>i(c=>({...c,evalSettings:{...c.evalSettings??{},intervalMs:l.target.value===""?void 0:Number(l.target.value)}}))})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"scheduled-evals-provider",children:"Evaluator Provider"}),e.jsx("input",{id:"scheduled-evals-provider",className:"input",value:t.evaluatorProvider??"",onChange:l=>i(c=>({...c,evalSettings:{...c.evalSettings??{},evaluatorProvider:l.target.value.trim()===""?void 0:l.target.value}})),placeholder:"openai"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"scheduled-evals-model",children:"Evaluator Model"}),e.jsx("input",{id:"scheduled-evals-model",className:"input",value:t.evaluatorModelId??"",onChange:l=>i(c=>({...c,evalSettings:{...c.evalSettings??{},evaluatorModelId:l.target.value.trim()===""?void 0:l.target.value}})),placeholder:"gpt-5"}),e.jsx("small",{className:"form-text text-muted",children:"Leave provider and model blank to inherit the project validator lane model settings."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"scheduled-evals-follow-up-policy",children:"Follow-up Policy"}),e.jsxs("select",{id:"scheduled-evals-follow-up-policy",className:"select",disabled:!s,value:t.followUpPolicy??"suggest-only",onChange:l=>i(c=>({...c,evalSettings:{...c.evalSettings??{},followUpPolicy:l.target.value}})),children:[e.jsx("option",{value:"disabled",children:"Disabled"}),e.jsx("option",{value:"suggest-only",children:"Suggest only"}),e.jsx("option",{value:"auto-create",children:"Auto-create tasks"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"scheduled-evals-retention-days",children:"Retention (days)"}),e.jsx("input",{id:"scheduled-evals-retention-days",className:"input",type:"number",min:1,max:365,step:1,disabled:!s,value:t.retentionDays??30,onChange:l=>i(c=>({...c,evalSettings:{...c.evalSettings??{},retentionDays:l.target.value===""?void 0:Number(l.target.value)}}))})]})]})}case"node-routing":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Node Routing"}),e.jsx("p",{className:"settings-section-description",children:"Configure how tasks are routed to execution nodes."}),e.jsx("p",{className:"settings-node-routing-note",children:"These settings apply at the project level."}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"defaultNodeId",children:"Default Execution Node"}),e.jsxs("select",{id:"defaultNodeId",className:"select",value:typeof a.defaultNodeId=="string"?a.defaultNodeId:"",onChange:t=>{const s=t.target.value;i(l=>({...l,defaultNodeId:s||void 0}))},children:[e.jsx("option",{value:"",children:"Local execution (no default node)"}),Gs.map(t=>e.jsxs("option",{value:t.id,children:[t.name," (",Wi(t.status),")"]},t.id))]}),(()=>{const t=Gs.find(s=>s.id===a.defaultNodeId);return t?e.jsxs("div",{className:"settings-node-status",children:[e.jsx("span",{children:"Selected node:"}),e.jsx(ei,{status:t.status,showLabel:!0})]}):null})(),e.jsx("small",{children:"Used when a task has no node override. Node status is shown for safer routing selection."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"unavailableNodePolicy",children:"Unavailable Node Policy"}),e.jsxs("select",{id:"unavailableNodePolicy",className:"select",value:a.unavailableNodePolicy==="fallback-local"?"fallback-local":"block",onChange:t=>i(s=>({...s,unavailableNodePolicy:t.target.value})),children:[e.jsx("option",{value:"block",children:"Block execution"}),e.jsx("option",{value:"fallback-local",children:"Fall back to local"})]})]})]});case"worktrees":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Worktrees"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"maxWorktrees",children:"Max Worktrees"}),e.jsx("input",{id:"maxWorktrees",type:"number",min:1,max:20,value:a.maxWorktrees??"",onChange:t=>{const s=t.target.value;i(l=>({...l,maxWorktrees:s===""?void 0:Number(s)}))}}),e.jsx("small",{children:"Limits total git worktrees including in-review tasks"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"worktreeInitCommand",children:"Worktree Init Command"}),e.jsx("input",{id:"worktreeInitCommand",type:"text",placeholder:"pnpm install --frozen-lockfile",value:a.worktreeInitCommand||"",onChange:t=>i(s=>({...s,worktreeInitCommand:t.target.value}))}),e.jsx("small",{children:"Shell command to run in each new worktree after creation"})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"recycleWorktrees",className:"checkbox-label",children:[e.jsx("input",{id:"recycleWorktrees",type:"checkbox",checked:a.recycleWorktrees,onChange:t=>i(s=>({...s,recycleWorktrees:t.target.checked}))}),"Recycle worktrees"]}),e.jsx("small",{children:"Off by default (opt-in). When enabled, completed task worktrees are returned to an idle pool instead of being deleted, preserving build caches for faster startup"})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"executorAllowSiblingBranchRename",className:"checkbox-label",children:[e.jsx("input",{id:"executorAllowSiblingBranchRename",type:"checkbox",checked:a.executorAllowSiblingBranchRename===!0,onChange:t=>i(s=>({...s,executorAllowSiblingBranchRename:t.target.checked}))}),"Allow silent sibling branch rename during executor conflicts"]}),e.jsxs("small",{children:["Discouraged. This restores the legacy behavior where a live ",e.jsx("code",{children:"fusion/<task-id>"})," branch collision silently forks work onto sibling branches like ",e.jsx("code",{children:"-2"})," and can hide prior commits from the default recovery flow."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"worktreeNaming",children:"Worktree Naming Style"}),e.jsxs("select",{id:"worktreeNaming",value:a.worktreeNaming||"random",onChange:t=>i(s=>({...s,worktreeNaming:t.target.value})),disabled:a.recycleWorktrees,children:[e.jsx("option",{value:"random",children:"Random names (e.g., swift-falcon)"}),e.jsx("option",{value:"task-id",children:"Task ID (e.g., FN-042)"}),e.jsx("option",{value:"task-title",children:"Task title (e.g., fix-login-bug)"})]}),e.jsx("small",{children:a.recycleWorktrees?"Naming style is not applicable when recycling worktrees — pooled worktrees retain their existing names":"How to name fresh worktree directories. Only applies when recycling is off."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"worktreesDir",children:"Worktrees Directory"}),e.jsxs("div",{className:"settings-overlap-ignore-path-controls",children:[e.jsx("input",{id:"worktreesDir",type:"text",placeholder:"Defaults to .worktrees — leave empty unless overriding",value:a.worktreesDir||"",disabled:a.worktrunk?.enabled===!0,onChange:t=>i(s=>({...s,worktreesDir:t.target.value}))}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:gr,"aria-label":"Browse worktrees directory",disabled:a.worktrunk?.enabled===!0,children:"Browse"})]}),e.jsx("small",{children:a.worktrunk?.enabled===!0?"Disabled because Worktrunk integration is enabled — worktrunk manages the worktree directory layout. Disable worktrunk integration to use a custom directory.":e.jsxs(e.Fragment,{children:["Optional. Supports ",e.jsx("code",{children:"~"})," and ",e.jsx("code",{children:"{repo}"}),". Defaults to ",e.jsx("code",{children:"<projectRoot>/.worktrees"})," when unset. Only affects newly-created worktrees."]})})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"worktreeRebaseBeforeMerge",className:"checkbox-label",children:[e.jsx("input",{id:"worktreeRebaseBeforeMerge",type:"checkbox",checked:a.worktreeRebaseBeforeMerge!==!1,onChange:t=>i(s=>({...s,worktreeRebaseBeforeMerge:t.target.checked}))}),"Rebase from remote before merge"]}),e.jsx("small",{children:"When enabled, the merger fetches from the configured remote and rebases the task branch onto the latest default-branch tip before merging — catching concurrent pushes from other collaborators or fusion workers. Any conflicts the rebase surfaces flow into the existing smart/AI resolve pipeline."})]}),a.worktreeRebaseBeforeMerge!==!1&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"worktreeRebaseRemote",children:"Rebase Remote"}),e.jsxs("select",{id:"worktreeRebaseRemote",value:a.worktreeRebaseRemote??"",onChange:t=>i(s=>({...s,worktreeRebaseRemote:t.target.value||void 0})),children:[e.jsx("option",{value:"",children:"Use git default"}),Ll.map(t=>e.jsxs("option",{value:t.name,children:[t.name," (",t.fetchUrl,")"]},t.name))]}),e.jsxs("small",{children:['Which remote to fetch for the pre-merge rebase. "Use git default" falls back to the remote configured for the default branch (typically ',e.jsx("code",{children:"origin"}),")."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"worktreeRebaseLocalBase",className:"checkbox-label",children:[e.jsx("input",{id:"worktreeRebaseLocalBase",type:"checkbox",checked:a.worktreeRebaseLocalBase!==!1,onChange:t=>i(s=>({...s,worktreeRebaseLocalBase:t.target.checked}))}),"Also rebase onto local default-branch HEAD"]}),e.jsx("small",{children:"In addition to the remote rebase above, also rebase the task branch onto the local default-branch HEAD (rootDir). This catches sibling tasks that merged locally but haven't been pushed yet — without it, two concurrent tasks where one deletes code can have the other silently re-introduce it via the fallback strategy. Enabled by default; only disable if it causes issues with your workflow."})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"Worktrunk integration"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"worktrunkEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"worktrunkEnabled",type:"checkbox",checked:a.worktrunk?.enabled===!0,disabled:!_&&a.worktrunk?.enabled!==!0,onChange:t=>i(s=>({...s,worktrunk:{enabled:t.target.checked,binaryPath:s.worktrunk?.binaryPath??"",onFailure:s.worktrunk?.onFailure??"fail"}}))}),"Enable worktrunk integration"]}),e.jsxs("small",{children:["Disabled by default (opt-in). When enabled, Fusion shells out to ",e.jsx("code",{children:"worktrunk"})," for worktree create, sync, prune, and remove operations and follows worktrunk's directory layout."]}),!_&&a.worktrunk?.enabled!==!0&&e.jsx("small",{className:"settings-muted",children:"Install the worktrunk binary below to enable this integration."})]}),e.jsxs("div",{className:"form-group","data-testid":"worktrunk-install-affordance",children:[P.status==="installed"&&e.jsxs("small",{className:"settings-muted",children:["worktrunk ",P.version??""," installed at ",P.installPath??"~/.fusion/bin/worktrunk"]}),(P.status==="missing"||P.status==="installing")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void P.requestInstall(),disabled:P.requesting||P.status==="installing",children:"Install worktrunk binary"}),e.jsx("small",{className:"settings-muted",children:"Enable worktrunk and request approval to install the pinned release."})]}),P.status==="pending-approval"&&e.jsxs(e.Fragment,{children:[e.jsx("small",{className:"settings-muted",children:"Awaiting approval — open Approvals to continue."}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>B?.(P.pendingApprovalId),children:"Open Approvals"})]}),(P.status==="denied"||P.status==="failed")&&e.jsxs(e.Fragment,{children:[e.jsx("small",{style:{color:"var(--color-error)"},children:P.error??"Worktrunk install failed."}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>void P.requestInstall(),children:"Try again"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"worktrunkBinaryPath",children:"Worktrunk binary path"}),e.jsx("input",{id:"worktrunkBinaryPath",type:"text",className:"input",placeholder:"auto-detect (~/.fusion/bin/worktrunk or $PATH)",value:a.worktrunk?.binaryPath??"",disabled:a.worktrunk?.enabled!==!0,onChange:t=>i(s=>({...s,worktrunk:{enabled:s.worktrunk?.enabled===!0,binaryPath:t.target.value,onFailure:s.worktrunk?.onFailure??"fail"}}))}),e.jsx("small",{children:"Optional. Leave blank to auto-resolve; Fusion will offer to install on first use."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"worktrunkOnFailure",children:"Worktrunk failure behavior"}),e.jsxs("select",{id:"worktrunkOnFailure",className:"select",value:a.worktrunk?.onFailure??"fail",disabled:a.worktrunk?.enabled!==!0,onChange:t=>i(s=>({...s,worktrunk:{enabled:s.worktrunk?.enabled===!0,binaryPath:s.worktrunk?.binaryPath??"",onFailure:t.target.value}})),children:[e.jsx("option",{value:"fail",children:"Fail and pause the task (default)"}),e.jsx("option",{value:"fallback-native",children:"Fall back to Fusion's native worktree backend"})]}),e.jsxs("small",{children:[e.jsx("code",{children:"fail"})," stops on worktrunk errors for explicit operator recovery; ",e.jsx("code",{children:"fallback-native"})," keeps progress moving by switching to Fusion's built-in worktree backend."]})]})]});case"commands":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Commands"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"testCommand",children:"Test Command"}),e.jsx("input",{id:"testCommand",type:"text",placeholder:"e.g. pnpm test",value:a.testCommand||"",onChange:t=>i(s=>({...s,testCommand:t.target.value||void 0}))}),e.jsx("small",{children:"Command used to run tests — injected into generated task specs"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"buildCommand",children:"Build Command"}),e.jsx("input",{id:"buildCommand",type:"text",placeholder:"e.g. pnpm build",value:a.buildCommand||"",onChange:t=>i(s=>({...s,buildCommand:t.target.value||void 0}))}),e.jsx("small",{children:"Command used to build the project — injected into generated task specs"})]})]});case"merge":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Merge"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"autoMerge",className:"checkbox-label",children:[e.jsx("input",{id:"autoMerge",type:"checkbox",checked:a.autoMerge,onChange:t=>i(s=>({...s,autoMerge:t.target.checked}))}),"Auto-merge completed tasks"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"When enabled, tasks that pass review are automatically merged into the main branch"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mergerMode",children:"AI merge"}),e.jsxs("select",{id:"mergerMode",className:"select",value:a.merger?.mode??"ai",onChange:t=>i(s=>({...s,merger:{...s.merger??{},mode:t.target.value}})),children:[e.jsx("option",{value:"ai",children:"AI merge (default) — AI merges in a clean room, an AI reviewer audits with retries, then lands"}),e.jsx("option",{value:"deterministic",children:"Deterministic (legacy) — rebase / conflict-strategy / audit pipeline"})]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsxs("small",{children:["AI mode merges the task branch into an isolated clean-room checkout at the target branch's tip, has an AI reviewer audit the squash (with corrective retries — advisory concerns land with a logged warning, an unfixable correctness concern hard-fails), then fast-forwards the target branch and syncs your local checkout (AI reconciles a conflicting restore). Each task merges to its own target branch, or the default integration branch. ",e.jsx("strong",{children:"The legacy merge settings below do not apply while AI merge is on."})]})]})]}),(a.merger?.mode??"ai")==="ai"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mergerMaxReviewPasses",children:"Max AI review passes"}),e.jsx("input",{id:"mergerMaxReviewPasses",type:"number",min:0,max:10,value:a.merger?.maxReviewPasses??3,onChange:t=>i(s=>({...s,merger:{...s.merger??{},maxReviewPasses:t.target.value===""?void 0:Number(t.target.value)}}))}),e.jsx("small",{children:"AI corrective rounds before landing the best result (advisory concern) or hard-failing (unfixable correctness concern). Default 3. The reviewer uses your project's reviewer/validator model."})]})}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"testMode",className:"checkbox-label",children:[e.jsx("input",{id:"testMode",type:"checkbox",checked:a.testMode===!0,onChange:t=>i(s=>({...s,testMode:t.target.checked}))}),"Enable test mode"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"Forces all AI lanes to use the deterministic mock provider. No network calls, zero token cost."})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"workflowRevisionForkOnScopeMismatch",className:"checkbox-label",children:[e.jsx("input",{id:"workflowRevisionForkOnScopeMismatch",type:"checkbox",checked:a.workflowRevisionForkOnScopeMismatch!==!1,onChange:t=>i(s=>({...s,workflowRevisionForkOnScopeMismatch:t.target.checked}))}),"Fork scope-mismatched workflow revisions into follow-up tasks"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"When enabled, workflow revision feedback that explicitly names files outside the original task's declared File Scope is split into a dependent follow-up task instead of being appended to the current task's PROMPT.md."})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"verificationFixRetries",children:"Verification auto-fix retries"}),e.jsx("input",{id:"verificationFixRetries",className:"input",type:"number",min:0,max:3,step:1,value:a.verificationFixRetries??3,onChange:t=>{const s=t.target.value;if(s===""){i(d=>({...d,verificationFixRetries:void 0}));return}const l=Number.parseInt(s,10);if(!Number.isFinite(l)){i(d=>({...d,verificationFixRetries:void 0}));return}const c=Math.max(0,Math.min(3,l));i(d=>({...d,verificationFixRetries:c}))}}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"Controls auto-fix retry attempts after deterministic test/build verification failures — applies to both executor-time and in-merge verification (0-3)."})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mergeStrategy",children:"Auto-completion mode"}),e.jsxs("select",{id:"mergeStrategy",value:a.mergeStrategy||"direct",onChange:t=>i(s=>({...s,mergeStrategy:t.target.value})),children:[e.jsx("option",{value:"direct",children:"Direct merge into the current branch"}),e.jsx("option",{value:"pull-request",children:"Create, monitor, and merge a GitHub pull request"})]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"Controls what happens after a task reaches In Review. Direct mode merges into the current branch locally. Pull request mode keeps the task in In Review while Fusion waits for GitHub reviews and required checks before merging the PR."})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"integrationBranch",children:"Integration branch"}),(()=>{const t=a.integrationBranch??"",s=t.length>0&&ra.includes(t);if(Ol||t.length>0&&!s)return e.jsxs("div",{className:"form-inline-group",children:[e.jsx("input",{id:"integrationBranch",type:"text",className:"input",placeholder:"branch name",value:t,onChange:h=>{const g=h.target.value.trim();i(T=>({...T,integrationBranch:g.length===0?void 0:g}))},"data-testid":"integration-branch-custom-input"}),e.jsx("button",{type:"button",className:"btn-link",onClick:()=>{ia(!1),i(h=>({...h,integrationBranch:void 0}))},"data-testid":"integration-branch-use-dropdown",children:"Use dropdown"})]});const c="__fusion-custom__",d="";return e.jsxs("select",{id:"integrationBranch",className:"select",value:t,onChange:h=>{const g=h.target.value;if(g===c){ia(!0);return}i(T=>({...T,integrationBranch:g===d?void 0:g}))},"data-testid":"integration-branch-select",children:[e.jsx("option",{value:d,children:"(auto-detect — origin/HEAD → main)"}),ra.map(h=>e.jsx("option",{value:h,children:h},h)),e.jsx("option",{value:c,children:"Custom…"})]})})(),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsxs("small",{children:["The canonical branch Fusion merges tasks into and uses as the reference for all ahead/behind / overlap / pre-rebase computations. Leave on ",e.jsx("em",{children:"auto-detect"}),"to resolve via the standard cascade (",e.jsx("code",{children:"integrationBranch"})," → legacy ",e.jsx("code",{children:"baseBranch"})," →",e.jsx("code",{children:"origin/HEAD"})," symbolic ref → fallback ",e.jsx("code",{children:"main"}),"). Pick a local branch from the dropdown — common integration names like ",e.jsx("code",{children:"main"}),",",e.jsx("code",{children:"master"}),", ",e.jsx("code",{children:"trunk"}),", and ",e.jsx("code",{children:"develop"})," are listed first — or choose ",e.jsx("em",{children:"Custom…"})," to type a branch that doesn't exist locally yet. Applies to both direct merges and pull-request mode; individual tasks can still override via task metadata."]})]})]}),a.mergeStrategy!=="pull-request"&&(a.merger?.mode??"ai")!=="ai"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"directMergeCommitStrategy",children:"Direct merge commit routing"}),e.jsxs("select",{id:"directMergeCommitStrategy",className:"select",value:a.directMergeCommitStrategy??"auto",onChange:t=>i(s=>({...s,directMergeCommitStrategy:t.target.value})),children:[e.jsx("option",{value:"auto",children:"Auto — squash single-substantive branches, preserve multi-substantive history"}),e.jsx("option",{value:"always-squash",children:"Always squash direct merges"}),e.jsx("option",{value:"always-rebase",children:"Always preserve direct-merge commit history"})]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsxs("small",{children:["Auto keeps today's squash behavior for branches with zero or one substantive commit, but switches multi-substantive branches to a history-preserving rebase-and-merge path. Individual tasks can override this in PROMPT.md with ",e.jsx("code",{children:"**Direct Merge Commit Strategy:** auto|always-squash|always-rebase"}),"."]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mergeIntegrationWorktree",children:"Integration worktree"}),e.jsxs("select",{id:"mergeIntegrationWorktree",className:"select",value:a.mergeIntegrationWorktree??"reuse-task-worktree",onChange:t=>i(s=>({...s,mergeIntegrationWorktree:t.target.value})),children:[e.jsx("option",{value:"reuse-task-worktree",children:"Reuse task worktree (default)"}),e.jsx("option",{value:"cwd-main",children:"Use project root (legacy)"})]}),e.jsx("small",{children:"Auto-merge runs in the task worktree by default. Switch to the legacy project-root path only if you need the pre-FN-5279 fallback; worktrunk-managed projects still defer to worktrunk."}),(a.mergeIntegrationWorktree??"reuse-task-worktree")!=="reuse-task-worktree"&&e.jsxs("div",{className:"settings-warning-banner",role:"alert","aria-live":"polite","data-testid":"merge-integration-worktree-warning",children:[e.jsx("strong",{children:"Legacy integration-branch mode."})," ","Auto-merge will run rebase, conflict resolution, and squash commits inside the project root (the user's checked-out integration-branch worktree) instead of the task worktree. Fusion assumes that directory is already on the integration branch and clean; if it isn't, merges may fail or touch the user's working tree. Reuse-task-worktree is the recommended default (FN-5279). Switch back unless you have a specific reason to opt in (FN-5348)."]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mergeAdvanceAutoSync",children:"Auto-sync project checkout after merge"}),e.jsxs("select",{id:"mergeAdvanceAutoSync",className:"select",value:a.mergeAdvanceAutoSync??"stash-and-ff",onChange:t=>i(s=>({...s,mergeAdvanceAutoSync:t.target.value})),"data-testid":"merge-advance-auto-sync-select",children:[e.jsx("option",{value:"stash-and-ff",children:"Stash + fast-forward (default) — preserve local edits"}),e.jsx("option",{value:"ff-only",children:"Fast-forward only — skip dirty worktrees"}),e.jsx("option",{value:"off",children:"Off — leave the project root stale (legacy behavior)"})]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsxs("small",{children:["After Fusion advances the integration branch ref, the merger can auto-sync other worktrees still checked out on that branch (typically your project-root checkout). ",e.jsx("code",{children:"Stash + fast-forward"})," snapshots real local edits as a patch against the previous tip, snaps the worktree to the new tip, then reapplies the patch — untracked files that collide with newly-tracked paths are left in a temp dir for manual recovery. ",e.jsx("code",{children:"Fast-forward only"})," snaps cleanly when the worktree has no edits and skips otherwise. ",e.jsx("code",{children:"Off"})," is the legacy behavior: ",e.jsx("code",{children:"git status"}),' in your project root will show the new commits inverted as "staged changes" until you pull manually. Only applies to direct merges.']})]})]})]}),a.mergeStrategy==="pull-request"&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"requirePrApproval",className:"checkbox-label",children:[e.jsx("input",{id:"requirePrApproval",type:"checkbox",checked:a.requirePrApproval??!1,onChange:t=>i(s=>({...s,requirePrApproval:t.target.checked}))}),"Wait for an approving review before merging the PR"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"When enabled, Fusion holds the PR in In Review until at least one approving GitHub review has been submitted. Useful on free private repos where GitHub's required-reviewer enforcement isn't available — without this, a fresh PR with no required checks is treated as immediately mergeable."})]})]}),e.jsx("h4",{className:"settings-section-heading settings-section-heading--spaced",children:"GitHub Authentication"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"githubAuthMode",children:"GitHub auth mode"}),e.jsxs("select",{id:"githubAuthMode",className:"select",value:a.githubAuthMode??"gh-cli",onChange:t=>i(s=>({...s,githubAuthMode:t.target.value})),children:[e.jsx("option",{value:"gh-cli",children:"GitHub CLI (gh auth)"}),e.jsx("option",{value:"token",children:"Personal access token"})]})]}),(a.githubAuthMode??"gh-cli")==="token"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"githubAuthToken",children:"GitHub personal access token"}),e.jsx("input",{id:"githubAuthToken",type:"password",className:"input",value:a.githubAuthToken??"",onChange:t=>i(s=>({...s,githubAuthToken:t.target.value||void 0}))})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"includeTaskIdInCommit",className:"checkbox-label",children:[e.jsx("input",{id:"includeTaskIdInCommit",type:"checkbox",checked:a.includeTaskIdInCommit!==!1,onChange:t=>i(s=>({...s,includeTaskIdInCommit:t.target.checked}))}),"Include task ID in commit scope"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsxs("small",{children:["When disabled, merge commit messages omit the task ID from the scope (e.g. ",e.jsx("code",{children:"feat: ..."})," instead of ",e.jsx("code",{children:"feat(KB-001): ..."}),")"]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"commitAuthorEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"commitAuthorEnabled",type:"checkbox",checked:a.commitAuthorEnabled!==!1,onChange:t=>i(s=>({...s,commitAuthorEnabled:t.target.checked}))}),"Add Fusion as co-author on commits"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsxs("small",{children:["When enabled, commits made by Fusion keep your git identity as the primary author and append a ",e.jsx("code",{children:"Co-authored-by"})," trailer crediting Fusion (recognized by GitHub for shared attribution)."]})]})]}),a.commitAuthorEnabled!==!1&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"commitAuthorName",children:"Co-author Name"}),e.jsx("input",{id:"commitAuthorName",type:"text",value:a.commitAuthorName??"",placeholder:"Fusion",onChange:t=>i(s=>({...s,commitAuthorName:t.target.value||void 0}))}),e.jsxs("small",{children:["Name used in the ",e.jsx("code",{children:"Co-authored-by"})," trailer"]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"commitAuthorEmail",children:"Co-author Email"}),e.jsx("input",{id:"commitAuthorEmail",type:"email",value:a.commitAuthorEmail??"",placeholder:"noreply@runfusion.ai",onChange:t=>i(s=>({...s,commitAuthorEmail:t.target.value||void 0}))}),e.jsxs("small",{children:["Email used in the ",e.jsx("code",{children:"Co-authored-by"})," trailer"]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"autoResolveConflicts",className:"checkbox-label",children:[e.jsx("input",{id:"autoResolveConflicts",type:"checkbox",checked:a.autoResolveConflicts!==!1,onChange:t=>i(s=>({...s,autoResolveConflicts:t.target.checked}))}),"Auto-resolve conflicts in lock files and generated files"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"When enabled, lock files (package-lock.json, pnpm-lock.yaml, etc.), generated files (dist/*, *.gen.ts), and trivial whitespace conflicts are resolved automatically without AI intervention. Complex code conflicts still require AI review."})]})]}),(a.merger?.mode??"ai")!=="ai"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"smartConflictResolution",className:"checkbox-label",children:[e.jsx("input",{id:"smartConflictResolution",type:"checkbox",checked:a.smartConflictResolution!==!1,onChange:t=>i(s=>({...s,smartConflictResolution:t.target.checked}))}),"Smart conflict resolution"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"When enabled, lock files (package-lock.json, pnpm-lock.yaml, etc.) are resolved using 'ours' strategy, generated files (dist/*, *.gen.ts) using 'theirs' strategy, and trivial whitespace conflicts are auto-resolved without spawning an AI agent. Complex code conflicts still require AI review."})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mergeConflictStrategy",children:"Conflict Fallback Strategy"}),e.jsxs("select",{id:"mergeConflictStrategy",value:a.mergeConflictStrategy??"smart-prefer-main",onChange:t=>i(s=>({...s,mergeConflictStrategy:t.target.value})),children:[e.jsx("option",{value:"smart-prefer-main",children:"Smart, prefer main on fallback — fetch+ff origin → AI → auto-resolve → -X ours (default; protects just-merged sibling work)"}),e.jsx("option",{value:"smart-prefer-branch",children:'Smart, prefer task on fallback — fetch+ff origin → AI → auto-resolve → -X theirs (legacy "smart" behavior; task branch wins)'}),e.jsx("option",{value:"ai-only",children:"AI only — AI → auto-resolve → AI retry; never silently pick a side"}),e.jsx("option",{value:"abort",children:"Abort — one AI attempt; require manual resolution if it fails"})]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsxs("small",{children:["Both ",e.jsx("strong",{children:"Smart"})," options start with a best-effort ",e.jsx("code",{children:"git fetch"})," + fast-forward of local main from ",e.jsx("code",{children:"origin"})," (so a freshly-pushed sibling commit doesn't get clobbered), then run an AI agent, then auto-resolve handles lock/generated/trivial files. They differ only in the ",e.jsx("em",{children:"final fallback"}),":"," ",e.jsx("strong",{children:"Smart, prefer main"})," uses ",e.jsx("code",{children:"-X ours"})," so main wins — protects just-merged sibling work and is the new default."," ",e.jsx("strong",{children:"Smart, prefer task"})," uses ",e.jsx("code",{children:"-X theirs"})," so the task branch wins — fast, but can resurrect code an earlier sibling task deleted (the FN-2887 class of regression)."," ",e.jsx("strong",{children:"AI only"})," retries the AI agent rather than auto-picking a side."," ",e.jsx("strong",{children:"Abort"})," stops after the first AI attempt and waits for a human."," ",e.jsxs("em",{children:["Legacy ",e.jsx("code",{children:'"smart"'})," and ",e.jsx("code",{children:'"prefer-main"'})," values from older settings are migrated automatically."]})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"mergeStrategyOverlapBehavior",children:"Smart Prefer Main Overlap Guard"}),e.jsxs("select",{id:"mergeStrategyOverlapBehavior",value:a.mergeStrategyOverlapBehavior??"flip-to-prefer-branch",onChange:t=>i(s=>({...s,mergeStrategyOverlapBehavior:t.target.value})),children:[e.jsx("option",{value:"flip-to-prefer-branch",children:"Flip overlapping files to prefer the task branch (default)"}),e.jsx("option",{value:"warn-only",children:"Warn only — keep legacy main-wins fallback"}),e.jsx("option",{value:"ignore",children:"Ignore overlap detection — preserve legacy behavior"})]}),e.jsx("small",{children:"When using smart-prefer-main, automatically prefer the branch side for files that main has recently modified to avoid silently discarding branch work."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"postMergeAuditMode",children:"Post-merge audit mode"}),e.jsxs("select",{className:"select",id:"postMergeAuditMode",value:a.postMergeAuditMode??"warn",onChange:t=>i(s=>({...s,postMergeAuditMode:t.target.value})),children:[e.jsx("option",{value:"block",children:"Block (strict)"}),e.jsx("option",{value:"warn",children:"Warn (default; log findings, continue)"}),e.jsx("option",{value:"off",children:"Off (skip audit)"})]}),e.jsxs("small",{children:["Controls the post-merge audit gate. ",e.jsx("strong",{children:"Warn"})," (default) logs findings but auto-completes the merge. ",e.jsx("strong",{children:"Block"})," is the stricter opt-in mode that refuses to auto-complete merges with duplicate-subject or touched-file overlap risks. ",e.jsx("strong",{children:"Off"})," skips the audit entirely. Switching to Off is recommended only if you trust your branches don't silently drop edits."]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"pushAfterMerge",className:"checkbox-label",children:[e.jsx("input",{id:"pushAfterMerge",type:"checkbox",checked:a.pushAfterMerge===!0,onChange:t=>i(s=>({...s,pushAfterMerge:t.target.checked}))}),"Push to remote after merge"]}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:"When enabled, the merged result is automatically pushed to the configured git remote. This includes pulling the latest from the remote first (rebase) and resolving any conflicts with AI if needed."})]})]}),a.pushAfterMerge&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"pushRemote",children:"Push Remote"}),e.jsx("input",{id:"pushRemote",type:"text",placeholder:"origin",value:a.pushRemote||"",onChange:t=>i(s=>({...s,pushRemote:t.target.value||void 0}))}),e.jsxs("details",{className:"settings-option-details",children:[e.jsx("summary",{children:"More details"}),e.jsx("small",{children:'Git remote to push to (e.g. "origin"). Can include branch name (e.g. "origin main"). Default: "origin".'})]})]})]});case"agent-permissions":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Agent Permissions"}),e.jsx("div",{className:"form-group",children:e.jsx("small",{className:"settings-muted",children:"Per-agent settings override project defaults. Each category controls a separate approval gate."})}),e.jsx(mi,{mode:"project-default",value:a.defaultAgentPermissionPolicy?{presetId:"custom",rules:Ms(a.defaultAgentPermissionPolicy.rules)}:{presetId:"custom",rules:Ms()},onChange:t=>i(s=>({...s,defaultAgentPermissionPolicy:{rules:Ms(t?.rules)}}))}),e.jsx("h4",{className:"settings-section-heading",children:"Agent Provisioning Approvals"}),e.jsx("div",{className:"form-group",children:e.jsx("small",{className:"settings-muted",children:"Configure project-level approval behavior for durable provisioning tools (fn_agent_create/fn_agent_delete)."})}),e.jsx(Gi,{value:a.agentProvisioning,onChange:t=>i(s=>({...s,agentProvisioning:t}))})]});case"memory":{const{capabilities:t,status:s,loading:l,error:c}={capabilities:Yl,status:Vl,loading:Ql,error:Xl},d=a.memoryEnabled!==!1,h=!l&&s!==null,g=h?t?.writable??!0:!0,T=d&&g,G=ha.find(N=>N.path===ge),x={"long-term":"Long-term",daily:"Daily",dreams:"Dreams"};return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Memory"}),e.jsx("div",{className:"form-group",children:e.jsxs("small",{className:"settings-muted",children:["Memory lives in ",e.jsx("code",{children:".fusion/memory/"}),". Agents search with qmd first, fall back to local files when qmd is missing, and open exact line windows only when needed."]})}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryEnabled",type:"checkbox",checked:a.memoryEnabled!==!1,onChange:N=>i(D=>({...D,memoryEnabled:N.target.checked}))}),"Enable memory tools"]}),e.jsx("small",{children:"Agents get memory_search, memory_get, and memory_append tools. Search defaults to qmd with a local file fallback."})]}),l?e.jsx("div",{className:"form-group",children:e.jsx("small",{className:"settings-muted",children:"Checking memory write access..."})}):c?e.jsx("div",{className:"form-group",children:e.jsxs("small",{className:"field-error",children:["Failed to load backend status: ",c]})}):null,h&&s.qmdAvailable===!1&&e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:["qmd is not installed. Search will use local files. Install indexed retrieval: ",e.jsx("code",{children:s.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Pr,disabled:ka,children:ka?"Installing…":"Install qmd"})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:a.memoryAutoSummarizeEnabled||!1,onChange:N=>i(D=>({...D,memoryAutoSummarizeEnabled:N.target.checked}))}),"Auto-Summarize Memory"]}),e.jsx("small",{children:"Automatically compact memory when it exceeds the threshold on a schedule"})]}),(a.memoryAutoSummarizeEnabled||!1)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:"Compaction Threshold (chars)"}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:a.memoryAutoSummarizeThresholdChars??5e4,onChange:N=>i(D=>({...D,memoryAutoSummarizeThresholdChars:parseInt(N.target.value,10)||5e4})),min:1e3}),e.jsx("small",{children:"Memory will be compacted when it exceeds this character count"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:"Schedule (cron)"}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:a.memoryAutoSummarizeSchedule??"0 3 * * *",onChange:N=>i(D=>({...D,memoryAutoSummarizeSchedule:N.target.value})),placeholder:"0 3 * * *"}),e.jsx("small",{children:"Cron expression for auto-summarize schedule (default: daily at 3 AM)"})]})]}),e.jsx("div",{style:{borderTop:"1px solid var(--border)",margin:"var(--space-lg) 0"}}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:a.memoryDreamsEnabled===!0,onChange:N=>i(D=>({...D,memoryDreamsEnabled:N.target.checked})),disabled:!d}),"Process dreams from daily memory"]}),e.jsx("small",{children:"Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md."})]}),d&&a.memoryDreamsEnabled===!0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:"Dream Schedule"}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",value:a.memoryDreamsSchedule??"0 4 * * *",onChange:N=>i(D=>({...D,memoryDreamsSchedule:N.target.value}))}),e.jsx("small",{children:"Cron expression for dream processing."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Sr,disabled:xa||a.memoryDreamsEnabled!==!0,children:xa?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:14,className:"animate-spin"}),"Dreaming…"]}):"Dream Now"}),e.jsx("small",{children:"Manually trigger dream processing now."})]})]}),e.jsxs("div",{className:"memory-retrieval-test",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryRetrievalQuery",children:"Test Retrieval"}),e.jsx("input",{id:"memoryRetrievalQuery",type:"text",value:ds,onChange:N=>ql(N.target.value),placeholder:"Search memory with qmd"}),e.jsx("small",{children:"Runs the same qmd-backed memory_search path agents use."})]}),e.jsx("div",{className:"form-group",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:wr,disabled:ga,children:ga?"Testing…":"Test Retrieval"})}),Be&&e.jsxs("div",{className:"memory-test-result",children:[e.jsxs("strong",{children:[Be.results.length," result",Be.results.length===1?"":"s"," ",'for "',Be.query,'"']}),e.jsxs("small",{children:["qmd ",Be.qmdAvailable?"available":"missing"," · ",Be.usedFallback?"local fallback used":"qmd path used"]}),Be.results.length>0?e.jsx("ul",{children:Be.results.map((N,D)=>e.jsxs("li",{children:[e.jsxs("span",{children:[N.path,":",N.lineStart]}),e.jsx("p",{children:N.snippet})]},`${N.path}-${N.lineStart}-${D}`))}):e.jsx("small",{children:"No matching memory found."})]})]}),!d&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:"Memory is currently disabled. You can view the file, but editing is read-only until memory is re-enabled."}),d&&h&&!g&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:"Memory is configured with a read-only backend. You can view the file, but saving is disabled."}),sa?e.jsx("div",{className:"settings-empty-state",children:"Loading memory…"}):e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryFilePath",children:"Memory File"}),e.jsx("select",{id:"memoryFilePath",value:ge,onChange:N=>{cs(N.target.value),mt(!1)},disabled:Oe,children:ha.map(N=>e.jsx("option",{value:N.path,title:`${N.label} — ${N.path}`,children:Ji(N)},N.path))}),e.jsx("small",{children:Oe?"Save or discard the current edits before switching files.":"Choose any project memory file to view or edit. Dreams is selected by default."})]}),G&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:x[G.layer]}),e.jsx("strong",{children:G.path}),e.jsxs("small",{children:[G.size.toLocaleString()," bytes · updated ",new Date(G.updatedAt).toLocaleString()]})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:G?.label||"Memory Editor"}),e.jsxs("small",{children:[G?.layer==="long-term"&&"Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams.",G?.layer==="daily"&&"Raw daily observations, open loops, and running context for dream processing.",G?.layer==="dreams"&&"Synthesized patterns and open loops promoted from daily memory.",!G&&"Edits the selected memory file."]}),e.jsx("div",{className:"memory-editor-frame",children:e.jsx(Zn,{content:ns,onChange:N=>{Ft(N),mt(!0)},readOnly:!T,filePath:ge})})]})]}),!sa&&e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Cr,disabled:!T||Oe||ja,children:ja?"Compacting…":"Compact Selected File"}),e.jsx("small",{children:Oe?"Save or discard edits before compacting this file.":`Compacts ${ge} and writes the result back to the same file.`})]}),Oe&&T&&e.jsx("div",{className:"form-group",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Nr,children:"Save Memory"})}),Oe&&!T&&e.jsx("div",{className:"form-group",children:e.jsxs("small",{className:"field-error",children:["Cannot save: ",d?"Backend is read-only":"Memory is disabled"]})})]})}case"research-global":{const t=a.researchGlobalWebSearchProvider??a.researchGlobalDefaults?.searchProvider??"builtin",s=t==="searxng"||t==="brave"||t==="google"||t==="tavily",l=t==="brave"||t==="tavily"?t:null,c=l?Le.some(h=>h.id===l&&!h.authenticated):!1,d=h=>{i(g=>({...g,researchGlobalWebSearchProvider:h,researchGlobalDefaults:{...g.researchGlobalDefaults??{},searchProvider:h}}))};return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Research Defaults"}),e.jsxs("div",{className:"form-group settings-research-provider-group",children:[e.jsxs("label",{htmlFor:"research-global-provider-builtin",className:"checkbox-label",children:[e.jsx("input",{id:"research-global-provider-builtin",type:"radio",name:"research-global-search-provider",checked:!s,onChange:()=>d("builtin")}),"Built-in (uses agent web tools)"]}),e.jsx("small",{children:"Searches and fetches use the agent's native WebSearch/WebFetch tools. No API key required."}),e.jsxs("details",{className:"settings-option-details settings-research-provider-advanced-details",children:[e.jsx("summary",{children:"Advanced — external search providers"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-global-search-provider-advanced",children:"Search Provider"}),e.jsxs("select",{id:"research-global-search-provider-advanced",className:"input",value:s?t:"searxng",onChange:h=>d(h.target.value),children:[e.jsx("option",{value:"searxng",children:"SearXNG"}),e.jsx("option",{value:"brave",children:"Brave"}),e.jsx("option",{value:"google",children:"Google Custom Search"}),e.jsx("option",{value:"tavily",children:"Tavily"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-global-searxng-url",children:"SearXNG URL"}),e.jsx("input",{id:"research-global-searxng-url",className:"input",value:a.researchGlobalSearxngUrl??"",onChange:h=>i(g=>({...g,researchGlobalSearxngUrl:h.target.value||void 0})),placeholder:"https://searx.example.com"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-global-google-cx",children:"Google Search CX"}),e.jsx("input",{id:"research-global-google-cx",className:"input",value:a.researchGlobalGoogleSearchCx??"",onChange:h=>i(g=>({...g,researchGlobalGoogleSearchCx:h.target.value||void 0})),placeholder:"custom-search-engine-id"})]}),e.jsxs("div",{className:"settings-empty-state settings-research-empty-state",role:"note",children:["Configure Brave, Tavily, and Google API keys in Authentication.",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>ie("authentication"),children:"Open Authentication Settings"})]})]})]}),e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"settings-research-limits-grid",children:[e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-global-max-concurrent",children:"Default Max Concurrent Runs"}),e.jsx("input",{id:"research-global-max-concurrent",className:"input",type:"number",min:1,value:a.researchGlobalMaxConcurrentRuns??3,onChange:h=>i(g=>({...g,researchGlobalMaxConcurrentRuns:h.target.value===""?void 0:Number(h.target.value)}))})]}),e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-global-max-sources",children:"Default Max Sources Per Run"}),e.jsx("input",{id:"research-global-max-sources",className:"input",type:"number",min:1,value:a.researchGlobalMaxSourcesPerRun??20,onChange:h=>i(g=>({...g,researchGlobalMaxSourcesPerRun:h.target.value===""?void 0:Number(h.target.value),researchGlobalDefaults:{...g.researchGlobalDefaults??{},maxSourcesPerRun:h.target.value===""?void 0:Number(h.target.value)}}))})]}),e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-global-default-timeout",children:"Default Max Duration (ms)"}),e.jsx("input",{id:"research-global-default-timeout",className:"input",type:"number",min:1e3,value:a.researchGlobalDefaultTimeout??3e5,onChange:h=>i(g=>({...g,researchGlobalDefaultTimeout:h.target.value===""?void 0:Number(h.target.value)}))})]}),e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-global-fetch-timeout",children:"Request Timeout (ms)"}),e.jsx("input",{id:"research-global-fetch-timeout",className:"input",type:"number",min:1e3,value:a.researchGlobalFetchTimeoutMs??3e4,onChange:h=>i(g=>({...g,researchGlobalFetchTimeoutMs:h.target.value===""?void 0:Number(h.target.value)}))})]}),e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-global-max-synthesis-rounds",children:"Max Synthesis Rounds"}),e.jsx("input",{id:"research-global-max-synthesis-rounds",className:"input",type:"number",min:1,value:a.researchGlobalMaxSynthesisRounds??2,onChange:h=>i(g=>({...g,researchGlobalMaxSynthesisRounds:h.target.value===""?void 0:Number(h.target.value)}))})]})]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Enabled Sources"}),e.jsxs("label",{htmlFor:"research-global-source-webSearch",className:"checkbox-label settings-research-source-locked",children:[e.jsx("input",{id:"research-global-source-webSearch",type:"checkbox",checked:!0,disabled:!0,readOnly:!0}),"Web Search ",e.jsx("span",{className:"settings-muted",children:"Always on"})]}),e.jsxs("div",{className:"settings-research-source-grid",children:[e.jsxs("label",{htmlFor:"research-global-source-github",className:"checkbox-label",children:[e.jsx("input",{id:"research-global-source-github",type:"checkbox",checked:a.researchGlobalGitHubEnabled??!1,onChange:h=>i(g=>({...g,researchGlobalGitHubEnabled:h.target.checked}))}),"GitHub"]}),e.jsxs("label",{htmlFor:"research-global-source-local-docs",className:"checkbox-label",children:[e.jsx("input",{id:"research-global-source-local-docs",type:"checkbox",checked:a.researchGlobalLocalDocsEnabled??!0,onChange:h=>i(g=>({...g,researchGlobalLocalDocsEnabled:h.target.checked}))}),"Local Docs"]})]})]}),c&&e.jsxs("div",{className:"settings-empty-state",role:"alert",children:["Missing credentials for the selected research provider.",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>ie("authentication"),children:"Open Authentication"})]})]})}case"research-project":{const t=a.researchSettings?.limits,s=a.researchSettings?.enabledSources;return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Project Research Settings"}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{htmlFor:"research-project-enabled",className:"checkbox-label",children:[e.jsx("input",{id:"research-project-enabled",type:"checkbox",checked:a.researchSettings?.enabled??!0,onChange:l=>i(c=>({...c,researchSettings:{...c.researchSettings??{},enabled:l.target.checked}}))}),"Enable research in this project"]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Enabled Sources"}),e.jsxs("label",{htmlFor:"research-project-source-webSearch",className:"checkbox-label settings-research-source-locked",children:[e.jsx("input",{id:"research-project-source-webSearch",type:"checkbox",checked:!0,disabled:!0,readOnly:!0}),"Web Search ",e.jsx("span",{className:"settings-muted",children:"Always on"})]}),e.jsx("small",{className:"settings-muted",children:"Web search is always enabled. Configure the search provider under Research Defaults."}),e.jsx("div",{className:"settings-research-source-grid",children:[["pageFetch","Page Fetch"],["github","GitHub"],["localDocs","Local Docs"],["llmSynthesis","LLM Synthesis"]].map(([l,c])=>e.jsxs("label",{htmlFor:`research-project-source-${l}`,className:"checkbox-label",children:[e.jsx("input",{id:`research-project-source-${l}`,type:"checkbox",checked:s?.[l]??!1,onChange:d=>i(h=>({...h,researchSettings:{...h.researchSettings??{},enabledSources:{...h.researchSettings?.enabledSources??{},[l]:d.target.checked}}}))}),c]},l))})]}),e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"settings-research-limits-grid",children:[e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-project-max-concurrent",children:"Max Concurrent Runs"}),e.jsx("input",{id:"research-project-max-concurrent",className:"input",type:"number",min:1,value:t?.maxConcurrentRuns??3,onChange:l=>i(c=>({...c,researchSettings:{...c.researchSettings??{},limits:{...c.researchSettings?.limits??{},maxConcurrentRuns:l.target.value===""?void 0:Number(l.target.value)}}}))})]}),e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-project-max-sources",children:"Max Sources Per Run"}),e.jsx("input",{id:"research-project-max-sources",className:"input",type:"number",min:1,value:t?.maxSourcesPerRun??20,onChange:l=>i(c=>({...c,researchSettings:{...c.researchSettings??{},limits:{...c.researchSettings?.limits??{},maxSourcesPerRun:l.target.value===""?void 0:Number(l.target.value)}}}))})]}),e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-project-max-duration",children:"Max Duration (ms)"}),e.jsx("input",{id:"research-project-max-duration",className:"input",type:"number",min:1e3,value:t?.maxDurationMs??3e5,onChange:l=>i(c=>({...c,researchSettings:{...c.researchSettings??{},limits:{...c.researchSettings?.limits??{},maxDurationMs:l.target.value===""?void 0:Number(l.target.value)}}}))})]}),e.jsxs("div",{className:"settings-research-limit-field",children:[e.jsx("label",{htmlFor:"research-project-request-timeout",children:"Request Timeout (ms)"}),e.jsx("input",{id:"research-project-request-timeout",className:"input",type:"number",min:1e3,value:t?.requestTimeoutMs??3e4,onChange:l=>i(c=>({...c,researchSettings:{...c.researchSettings??{},limits:{...c.researchSettings?.limits??{},requestTimeoutMs:l.target.value===""?void 0:Number(l.target.value)}}}))})]}),Bs&&e.jsx("small",{className:"field-error settings-research-limits-error",children:Bs})]})})]})}case"experimental":{const t=a.experimentalFeatures??{},l=Array.from(new Set([...Object.keys(pl),...Object.keys(t).map(Nl)])).sort((c,d)=>c.localeCompare(d)).map(c=>[c,Bt(t,c)]);return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Experimental Features"}),e.jsx("div",{className:"form-group",children:e.jsx("small",{children:"Experimental features are early capabilities that are not yet fully stable. Enable them to test new functionality, but be aware they may change or be removed."})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Feature Flags"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:l.map(([c,d])=>e.jsxs("label",{htmlFor:`experimental-${c}`,className:"checkbox-label",children:[e.jsx("input",{id:`experimental-${c}`,type:"checkbox",checked:d,onChange:h=>{i(g=>{const T={...g.experimentalFeatures??{},[c]:h.target.checked};for(const[G,x]of Object.entries($t))x===c&&delete T[G];return{...g,experimentalFeatures:T}})}}),e.jsx("span",{children:pl[c]??c})]},c))})]})]})}case"backups":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Database Backups"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"autoBackupEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"autoBackupEnabled",type:"checkbox",checked:a.autoBackupEnabled||!1,onChange:t=>i(s=>({...s,autoBackupEnabled:t.target.checked}))}),"Enable automatic database backups"]}),e.jsx("small",{children:"When enabled, the database is backed up automatically on a schedule"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"autoBackupSchedule",children:"Backup Schedule (Cron)"}),e.jsx("input",{id:"autoBackupSchedule",type:"text",placeholder:"0 2 * * *",value:a.autoBackupSchedule||"0 2 * * *",onChange:t=>i(s=>({...s,autoBackupSchedule:t.target.value})),disabled:!a.autoBackupEnabled}),e.jsx("small",{children:"Cron expression for backup timing. Default: 0 2 * * * (daily at 2 AM). Examples: 0 * * * * (hourly), 0 0 * * 0 (weekly), */15 * * * * (every 15 min)"}),a.autoBackupSchedule&&!/^[\s\d*,/-]+$/.test(a.autoBackupSchedule)&&e.jsx("small",{className:"field-error",children:"Invalid cron expression format"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"autoBackupRetention",children:"Retention Count"}),e.jsx("input",{id:"autoBackupRetention",type:"number",min:1,max:100,value:a.autoBackupRetention??"",onChange:t=>{const s=t.target.value;i(l=>({...l,autoBackupRetention:s===""?void 0:Number(s)}))},disabled:!a.autoBackupEnabled}),e.jsx("small",{children:"Number of backup files to keep (oldest are deleted first). Range: 1-100."}),a.autoBackupRetention!==void 0&&(a.autoBackupRetention<1||a.autoBackupRetention>100)&&e.jsx("small",{className:"field-error",children:"Must be between 1 and 100"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"autoBackupDir",children:"Backup Directory"}),e.jsx("input",{id:"autoBackupDir",type:"text",placeholder:".fusion/backups",value:a.autoBackupDir||".fusion/backups",onChange:t=>i(s=>({...s,autoBackupDir:t.target.value})),disabled:!a.autoBackupEnabled}),e.jsx("small",{children:"Directory for backup files, relative to project root"}),a.autoBackupDir&&a.autoBackupDir.includes("..")&&e.jsx("small",{className:"field-error",children:"Path cannot contain parent directory traversal (..)"})]}),e.jsx("h4",{className:"settings-section-heading",children:"Memory Backups"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryBackupEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryBackupEnabled",type:"checkbox",checked:a.memoryBackupEnabled||!1,onChange:t=>i(s=>({...s,memoryBackupEnabled:t.target.checked}))}),"Enable automatic memory backups"]}),e.jsx("small",{children:"When enabled, project and agent memory files are backed up automatically on a schedule."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryBackupSchedule",children:"Memory Backup Schedule (Cron)"}),e.jsx("input",{id:"memoryBackupSchedule",type:"text",placeholder:"0 3 * * *",value:a.memoryBackupSchedule||"0 3 * * *",onChange:t=>i(s=>({...s,memoryBackupSchedule:t.target.value})),disabled:!a.memoryBackupEnabled}),e.jsx("small",{children:"Cron expression for memory backup timing. Default: 0 3 * * * (daily at 3 AM)."}),a.memoryBackupSchedule&&!/^[\s\d*,/-]+$/.test(a.memoryBackupSchedule)&&e.jsx("small",{className:"field-error",children:"Invalid cron expression format"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryBackupRetention",children:"Memory Retention Count"}),e.jsx("input",{id:"memoryBackupRetention",type:"number",min:1,max:100,value:a.memoryBackupRetention??"",onChange:t=>{const s=t.target.value;i(l=>({...l,memoryBackupRetention:s===""?void 0:Number(s)}))},disabled:!a.memoryBackupEnabled}),e.jsx("small",{children:"Number of memory backups to keep (oldest are deleted first). Range: 1-100."}),a.memoryBackupRetention!==void 0&&(a.memoryBackupRetention<1||a.memoryBackupRetention>100)&&e.jsx("small",{className:"field-error",children:"Must be between 1 and 100"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryBackupDir",children:"Memory Backup Directory"}),e.jsx("input",{id:"memoryBackupDir",type:"text",placeholder:".fusion/backups/memory",value:a.memoryBackupDir||".fusion/backups/memory",onChange:t=>i(s=>({...s,memoryBackupDir:t.target.value})),disabled:!a.memoryBackupEnabled}),e.jsx("small",{children:"Directory for memory backups, relative to project root."}),a.memoryBackupDir&&a.memoryBackupDir.includes("..")&&e.jsx("small",{className:"field-error",children:"Path cannot contain parent directory traversal (..)"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryBackupScope",children:"Memory Backup Scope"}),e.jsxs("select",{id:"memoryBackupScope",value:a.memoryBackupScope||"all",onChange:t=>i(s=>({...s,memoryBackupScope:t.target.value})),disabled:!a.memoryBackupEnabled,children:[e.jsx("option",{value:"all",children:"All (project + agents)"}),e.jsx("option",{value:"project",children:"Project only (.fusion/memory)"}),e.jsx("option",{value:"agents",children:"Agents only (.fusion/agent-memory)"})]})]}),ts?e.jsx("div",{className:"settings-empty-state",children:"Loading backup info…"}):Pe?e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Current Backups"}),e.jsxs("div",{className:"backup-stats",children:[e.jsxs("div",{className:"backup-stat",children:[e.jsx("span",{className:"backup-stat-value",children:Pe.count}),e.jsx("span",{className:"backup-stat-label",children:"backups"})]}),e.jsxs("div",{className:"backup-stat",children:[e.jsx("span",{className:"backup-stat-value",children:Pe.totalSize>1024*1024?`${(Pe.totalSize/(1024*1024)).toFixed(1)} MB`:`${(Pe.totalSize/1024).toFixed(1)} KB`}),e.jsx("span",{className:"backup-stat-label",children:"total size"})]})]}),Pe.backups.length>0&&e.jsxs("details",{className:"backup-list",children:[e.jsxs("summary",{children:["View ",Pe.backups.length," backup(s)"]}),e.jsxs("ul",{children:[Pe.backups.slice(0,10).map(t=>e.jsxs("li",{children:[e.jsx("code",{children:t.filename}),e.jsx("span",{className:"backup-size",children:t.size>1024*1024?`${(t.size/(1024*1024)).toFixed(1)} MB`:`${(t.size/1024).toFixed(1)} KB`})]},t.filename)),Pe.backups.length>10&&e.jsx("li",{children:e.jsxs("em",{children:["...and ",Pe.backups.length-10," more"]})})]})]})]}):null,e.jsx("div",{className:"form-group",children:e.jsx("button",{type:"button",className:"btn btn-sm",onClick:lr,disabled:ts,children:ts?"Creating…":"Backup Now"})})]});case"notifications":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Notifications"}),e.jsxs("div",{className:"notification-provider-card",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"failureNotificationMode",children:"Failure notification mode"}),e.jsxs("select",{id:"failureNotificationMode",value:a.failureNotificationMode??"sticky-only",onChange:t=>{const s=t.target.value;i(l=>({...l,failureNotificationMode:s}))},children:[e.jsx("option",{value:"sticky-only",children:"Sticky failures only (default)"}),e.jsx("option",{value:"terminal-only",children:"Terminal failures only (suppress auto-retried)"}),e.jsx("option",{value:"all",children:"All failures (legacy)"})]}),e.jsx("small",{children:"Sticky-only suppresses recovered failures; terminal-only waits for paused/in-review failed tasks; all restores legacy alerts."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"failureNotificationDelayMs",children:"Failure notification delay (ms)"}),e.jsx("input",{id:"failureNotificationDelayMs",type:"number",min:0,step:1e3,disabled:(a.failureNotificationMode??"sticky-only")==="all",value:a.failureNotificationDelayMs??3e4,onChange:t=>{const s=Number(t.target.value);i(l=>({...l,failureNotificationDelayMs:Number.isFinite(s)&&s>=0?s:0}))}}),e.jsx("small",{children:"How long a failure must persist before a push notification is sent. 0 = notify immediately."})]})]}),e.jsxs("div",{className:"notification-provider-card",children:[e.jsxs("div",{className:"notification-provider-header",children:[e.jsx("strong",{children:"ntfy"}),e.jsxs("label",{htmlFor:"ntfyEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"ntfyEnabled",type:"checkbox",checked:a.ntfyEnabled||!1,onChange:t=>i(s=>({...s,ntfyEnabled:t.target.checked}))}),"Enable"]})]}),a.ntfyEnabled&&e.jsxs("div",{className:"notification-provider-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"ntfyTopic",children:"ntfy Topic"}),e.jsx("input",{id:"ntfyTopic",type:"text",placeholder:"my-topic-name",value:a.ntfyTopic||"",onChange:t=>{const s=t.target.value;i(l=>({...l,ntfyTopic:s||void 0}))}}),e.jsxs("small",{children:["Your ntfy.sh topic name (1–64 alphanumeric/hyphen/underscore characters)."," ",e.jsx("a",{href:"https://ntfy.sh",target:"_blank",rel:"noopener noreferrer",className:"settings-inline-link",children:"Learn more about ntfy.sh"})]}),a.ntfyTopic&&!/^[a-zA-Z0-9_-]{1,64}$/.test(a.ntfyTopic)&&e.jsx("small",{className:"field-error",children:"Topic must be 1–64 alphanumeric, hyphen, or underscore characters"}),e.jsxs("details",{className:"ntfy-advanced-disclosure",children:[e.jsx("summary",{children:"Advanced"}),e.jsxs("div",{className:"ntfy-advanced-content",children:[e.jsx("label",{htmlFor:"ntfyBaseUrl",children:"Custom ntfy server URL (optional)"}),e.jsx("input",{id:"ntfyBaseUrl",type:"url",placeholder:"https://ntfy.sh",value:a.ntfyBaseUrl||"",onChange:t=>{const s=t.target.value;i(l=>({...l,ntfyBaseUrl:s||void 0}))}}),e.jsx("small",{children:"Leave blank to keep the default server: https://ntfy.sh. Custom servers must use http:// or https://."}),e.jsx("label",{htmlFor:"ntfyAccessToken",children:"Access token (optional)"}),e.jsx("input",{id:"ntfyAccessToken",type:"password",autoComplete:"off",placeholder:"tk_...",value:a.ntfyAccessToken||"",onChange:t=>{const s=t.target.value;i(l=>({...l,ntfyAccessToken:s||void 0}))}}),e.jsx("small",{children:"Leave blank to publish without authentication. When set, Fusion sends an Authorization Bearer header with ntfy requests."})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Notify on events"}),e.jsx("div",{className:"ntfy-events-list",children:hl.map(({event:t,label:s,description:l})=>{const c=a.ntfyEvents?.includes(t)??!0;return e.jsxs("div",{children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:d=>{const h=a.ntfyEvents??[...Is],g=d.target.checked?h.includes(t)?h:[...h,t]:h.filter(T=>T!==t);i(T=>({...T,ntfyEvents:g.length>0?g:void 0}))}}),s]}),e.jsx("small",{children:l})]},`ntfy-${t}`)})})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"ntfyDashboardHost",children:"Dashboard Hostname"}),e.jsx("input",{id:"ntfyDashboardHost",type:"text",placeholder:"http://localhost:3000",value:a.ntfyDashboardHost||"",onChange:t=>{const s=t.target.value;i(l=>({...l,ntfyDashboardHost:s||void 0}))}}),e.jsx("small",{children:"Base URL for deep links in notifications. When set, clicking a notification opens the dashboard directly to the task."}),a.ntfyDashboardHost&&!/^https?:\/\/.+/.test(a.ntfyDashboardHost)&&e.jsx("small",{className:"field-error",children:"Must be a valid URL starting with http:// or https://"})]}),e.jsxs("div",{className:"notification-provider-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>Dt("ntfy"),disabled:ce.ntfy||ce["ntfy-message"]||ce["ntfy-room"]||!a.ntfyEnabled||!a.ntfyTopic||!/^[a-zA-Z0-9_-]{1,64}$/.test(a.ntfyTopic),children:ce.ntfy?"Sending…":"Test notification"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>Dt("ntfy-message"),disabled:ce.ntfy||ce["ntfy-message"]||ce["ntfy-room"]||!a.ntfyEnabled||!a.ntfyTopic||!/^[a-zA-Z0-9_-]{1,64}$/.test(a.ntfyTopic),children:ce["ntfy-message"]?"Sending…":"Test message inbox"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>Dt("ntfy-room"),disabled:ce.ntfy||ce["ntfy-message"]||ce["ntfy-room"]||!a.ntfyEnabled||!a.ntfyTopic||!/^[a-zA-Z0-9_-]{1,64}$/.test(a.ntfyTopic),children:ce["ntfy-room"]?"Sending…":"Test room reply"})]}),(oe.ntfy||oe["ntfy-message"]||oe["ntfy-room"])&&e.jsxs("div",{className:"notification-test-feedback","aria-live":"polite",children:[oe.ntfy&&e.jsxs("small",{className:`notification-test-feedback-item notification-test-feedback-item--${oe.ntfy.status}`,children:["General: ",oe.ntfy.message]}),oe["ntfy-message"]&&e.jsxs("small",{className:`notification-test-feedback-item notification-test-feedback-item--${oe["ntfy-message"].status}`,children:["Message inbox: ",oe["ntfy-message"].message]}),oe["ntfy-room"]&&e.jsxs("small",{className:`notification-test-feedback-item notification-test-feedback-item--${oe["ntfy-room"].status}`,children:["Room reply: ",oe["ntfy-room"].message]})]})]})]}),e.jsxs("div",{className:"notification-provider-card",children:[e.jsxs("div",{className:"notification-provider-header",children:[e.jsx("strong",{children:"Webhook"}),e.jsxs("label",{htmlFor:"webhookEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"webhookEnabled",type:"checkbox",checked:a.webhookEnabled||!1,onChange:t=>i(s=>({...s,webhookEnabled:t.target.checked}))}),"Webhook notifications"]})]}),a.webhookEnabled&&e.jsxs("div",{className:"notification-provider-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"webhookUrl",children:"Webhook URL"}),e.jsx("input",{id:"webhookUrl",type:"text",placeholder:"https://hooks.example.com/...",value:a.webhookUrl||"",onChange:t=>{const s=t.target.value;i(l=>({...l,webhookUrl:s||void 0}))}})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"webhookFormat",children:"Format"}),e.jsxs("select",{id:"webhookFormat",value:a.webhookFormat||"generic",onChange:t=>{const s=t.target.value;i(l=>({...l,webhookFormat:s}))},children:[e.jsx("option",{value:"slack",children:"Slack"}),e.jsx("option",{value:"discord",children:"Discord"}),e.jsx("option",{value:"generic",children:"Generic"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Notify on events"}),e.jsx("div",{className:"ntfy-events-list",children:hl.map(({event:t,label:s,description:l})=>{const d=(a.webhookEvents??[...Is]).includes(t);return e.jsxs("div",{children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:h=>{const g=a.webhookEvents??[...Is],T=h.target.checked?g.includes(t)?g:[...g,t]:g.filter(G=>G!==t);i(G=>({...G,webhookEvents:T.length>0?T:void 0}))}}),s]}),e.jsx("small",{children:l})]},`webhook-${t}`)})})]}),e.jsx("div",{className:"notification-provider-actions",children:e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>Dt("webhook"),disabled:ce.webhook||!a.webhookUrl,children:ce.webhook?"Sending…":"Test notification"})}),oe.webhook&&e.jsx("div",{className:"notification-test-feedback","aria-live":"polite",children:e.jsx("small",{className:`notification-test-feedback-item notification-test-feedback-item--${oe.webhook.status}`,children:oe.webhook.message})})]})]})]});case"node-sync":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Node Sync"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"settingsSyncEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"settingsSyncEnabled",type:"checkbox",checked:a.settingsSyncEnabled||!1,onChange:t=>i(s=>({...s,settingsSyncEnabled:t.target.checked}))}),"Enable automatic settings sync"]}),e.jsx("small",{children:"Automatically synchronize settings between this node and connected remote nodes"})]}),a.settingsSyncEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"settingsSyncAuth",className:"checkbox-label",children:[e.jsx("input",{id:"settingsSyncAuth",type:"checkbox",checked:a.settingsSyncAuth||!1,onChange:t=>i(s=>({...s,settingsSyncAuth:t.target.checked}))}),"Sync model auth credentials"]}),e.jsx("small",{children:"Include API keys and OAuth tokens in sync operations"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"settingsSyncInterval",children:"Sync interval"}),e.jsxs("select",{id:"settingsSyncInterval",className:"select",value:a.settingsSyncInterval||9e5,onChange:t=>i(s=>({...s,settingsSyncInterval:parseInt(t.target.value,10)})),children:[e.jsx("option",{value:3e5,children:"Every 5 minutes"}),e.jsx("option",{value:9e5,children:"Every 15 minutes"}),e.jsx("option",{value:18e5,children:"Every 30 minutes"}),e.jsx("option",{value:36e5,children:"Every 1 hour"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"settingsSyncConflictResolution",children:"Conflict resolution"}),e.jsxs("select",{id:"settingsSyncConflictResolution",className:"select",value:a.settingsSyncConflictResolution||"last-write-wins",onChange:t=>i(s=>({...s,settingsSyncConflictResolution:t.target.value})),children:[e.jsx("option",{value:"last-write-wins",children:"Last write wins"}),e.jsx("option",{value:"always-ask",children:"Always ask"}),e.jsx("option",{value:"keep-local",children:"Keep local"}),e.jsx("option",{value:"keep-remote",children:"Keep remote"})]})]})]})]});case"remote":{const t=a,s=t.remoteActiveProvider??null,l=Y?.state??"stopped",c=l==="running"?"running":l==="starting"?"starting":l==="failed"||l==="error"?"error":"stopped";return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Remote Access"}),e.jsxs("div",{className:`remote-status-bar remote-status-bar--${c}`,children:[e.jsx("span",{className:`remote-status-dot remote-status-dot--${c}`}),e.jsx("strong",{children:l}),Y?.provider&&e.jsxs("span",{children:[" · ",Y.provider]}),Y?.url&&e.jsx("code",{className:"remote-status-url",children:Y.url}),Y?.lastError&&e.jsx("span",{className:"field-error",children:Y.lastError})]}),l==="stopped"&&He&&e.jsxs("div",{className:"remote-external-tunnel-panel",role:"status",children:[e.jsxs("div",{className:"remote-external-tunnel-header",children:[e.jsx(vt,{"aria-hidden":"true"}),e.jsxs("strong",{children:["External ",He.provider," tunnel detected"]})]}),He.url&&e.jsx("code",{className:"settings-url-output",children:He.url}),We?.qrSvg&&e.jsxs("div",{className:"remote-external-tunnel-qr",children:[e.jsx("small",{children:"Scan to open:"}),e.jsx("img",{src:`data:image/svg+xml;utf8,${encodeURIComponent(We.qrSvg)}`,alt:"External tunnel QR code",className:"settings-qr-preview-image"})]})]}),l==="running"&&(Y?.url||We)&&(()=>{let d=null,h=Y?.url??null;if(We?.url)try{const g=new URL(We.url);d=g.searchParams.get("rt"),h||(h=`${g.origin}/`)}catch{}return e.jsxs("div",{className:"remote-share-block",children:[h&&e.jsxs("div",{className:"remote-share-row",children:[e.jsx("small",{children:"Tailnet URL:"}),e.jsx("code",{className:"settings-url-output",children:h})]}),d&&e.jsxs("div",{className:"remote-share-row",children:[e.jsx("small",{children:"Remote access code:"}),e.jsx("code",{className:"settings-url-output",children:d})]}),We?.qrSvg&&e.jsxs("div",{className:"remote-share-row",children:[e.jsx("small",{children:"Scan to connect:"}),e.jsx("img",{src:`data:image/svg+xml;utf8,${encodeURIComponent(We.qrSvg)}`,alt:"Remote access QR code",className:"settings-qr-preview-image"})]})]})})(),e.jsxs("div",{className:"form-group",children:[e.jsxs("div",{className:"remote-provider-selector",role:"radiogroup","aria-label":"Remote provider",children:[e.jsxs("label",{className:"remote-provider-option",children:[e.jsx("input",{type:"radio",name:"remoteProvider",value:"tailscale",checked:s==="tailscale",onChange:()=>i(d=>({...d,remoteActiveProvider:"tailscale"}))}),e.jsx("span",{children:e.jsxs("span",{className:"remote-provider-option-content",children:[e.jsx("span",{"data-testid":"remote-provider-icon-tailscale","aria-hidden":"true",children:e.jsx(vt,{size:16})}),e.jsx("span",{children:"Tailscale"})]})})]}),e.jsxs("label",{className:"remote-provider-option",children:[e.jsx("input",{type:"radio",name:"remoteProvider",value:"cloudflare",checked:s==="cloudflare",onChange:()=>i(d=>({...d,remoteActiveProvider:"cloudflare"}))}),e.jsx("span",{children:e.jsxs("span",{className:"remote-provider-option-content",children:[e.jsx("span",{"data-testid":"remote-provider-icon-cloudflare","aria-hidden":"true",className:"remote-provider-option-icon",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"remote-cloudflare-option-icon",children:e.jsx("path",{d:"M7 16.5h10.8a2.9 2.9 0 0 0 .3-5.8 4.9 4.9 0 0 0-9.3-1.6A3.6 3.6 0 0 0 7 16.5m-1.9 0h3.2a2.5 2.5 0 0 0 .2-5 3.4 3.4 0 0 0-3.4 3.4c0 .6 0 1 .2 1.6",fill:"var(--provider-cloudflare)"})})}),e.jsx("span",{children:"Cloudflare"})]})})]})]}),!s&&e.jsx("small",{children:"Select a provider above to configure remote access."})]}),s==="cloudflare"&&Y?.cloudflaredAvailable===!0&&e.jsxs("div",{className:"remote-cli-detection remote-cli-detection--available",role:"status",children:[e.jsx(Kn,{"aria-hidden":"true"}),e.jsx("span",{children:"cloudflared is installed"})]}),s==="cloudflare"&&Y?.cloudflaredAvailable===!1&&e.jsxs("div",{className:"remote-cli-detection remote-cli-detection--missing",role:"status",children:[e.jsx(Vn,{"aria-hidden":"true"}),e.jsxs("div",{className:"remote-cli-detection-content",children:[e.jsx("span",{children:"cloudflared is not installed"}),e.jsx("button",{type:"button",className:"btn btn-sm",disabled:Xs||pe!==null,onClick:()=>void Mr(),children:Xs?"Installing…":"Install cloudflared"}),Zs&&e.jsx("small",{className:"remote-cli-install-error",children:Zs}),e.jsxs("small",{className:"remote-cli-manual",children:["Manual install: ",e.jsx("code",{children:Fr()})]}),Ea()?e.jsxs("small",{className:"remote-cli-manual",children:["If Homebrew is unavailable: ",e.jsx("code",{children:Ea()})]}):null]})]}),s&&e.jsx("div",{className:"form-group remote-provider-settings",children:s==="tailscale"?e.jsxs(e.Fragment,{children:[e.jsxs("small",{children:["Tailscale Funnel will expose this dashboard on your tailnet's public ","https://<machine>.<tailnet>.ts.net/"," URL — no hostname or port configuration needed."]}),e.jsxs("label",{htmlFor:"remoteTailscaleAcceptRoutes",className:"checkbox-label",children:[e.jsx("input",{id:"remoteTailscaleAcceptRoutes",type:"checkbox",checked:!!t.remoteTailscaleAcceptRoutes,onChange:d=>i(h=>({...h,remoteTailscaleAcceptRoutes:d.target.checked}))}),"Accept routes"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:t.remoteCloudflareQuickTunnel??!0?"Using Quick Tunnel — automatically creates a random trycloudflare.com URL, no account needed.":"Named Tunnel mode enabled — configure tunnel name, token, and ingress URL below."}),e.jsxs("details",{className:"remote-cf-advanced-details",open:!(t.remoteCloudflareQuickTunnel??!0),onToggle:d=>{const h=d.currentTarget.open;i(g=>{const T=!!(g.remoteCloudflareQuickTunnel??!0),G=!h;return T===G?g:{...g,remoteCloudflareQuickTunnel:G}})},children:[e.jsx("summary",{children:"Advanced (Named Tunnel)"}),t.remoteCloudflareQuickTunnel??!0?null:e.jsxs("div",{className:"remote-cf-advanced-fields",children:[e.jsx("label",{htmlFor:"remoteCloudflareTunnelName",children:"Tunnel name"}),e.jsx("input",{id:"remoteCloudflareTunnelName",type:"text",placeholder:"Tunnel name",value:String(t.remoteCloudflareTunnelName??""),onChange:d=>i(h=>({...h,remoteCloudflareTunnelName:d.target.value}))}),e.jsx("label",{htmlFor:"remoteCloudflareTunnelToken",children:"Tunnel token"}),e.jsx("input",{id:"remoteCloudflareTunnelToken",type:"password",placeholder:"Tunnel token",value:String(t.remoteCloudflareTunnelToken??""),onChange:d=>i(h=>({...h,remoteCloudflareTunnelToken:d.target.value}))}),e.jsx("label",{htmlFor:"remoteCloudflareIngressUrl",children:"Ingress URL"}),e.jsx("input",{id:"remoteCloudflareIngressUrl",type:"text",placeholder:"https://your-domain.example",value:String(t.remoteCloudflareIngressUrl??""),onChange:d=>i(h=>({...h,remoteCloudflareIngressUrl:d.target.value}))})]})]})]})}),e.jsx("div",{className:"form-group remote-tunnel-actions",children:l==="running"||l==="starting"?e.jsx("button",{type:"button",className:"btn btn-danger",disabled:pe!==null,onClick:()=>void Ge("stop",async()=>{await Yn(u),o("Remote tunnel stopped","success")}),children:pe==="stop"?"Stopping…":"Stop Tunnel"}):e.jsxs(e.Fragment,{children:[He?e.jsxs("div",{className:"remote-external-tunnel-actions",children:[e.jsx("button",{type:"button",className:"btn",disabled:!s||pe!==null,onClick:()=>void Ge("start fresh",async()=>{const d=a,h={remoteActiveProvider:s,remoteTailscaleEnabled:s==="tailscale",remoteTailscaleHostname:String(d.remoteTailscaleHostname??""),remoteTailscaleTargetPort:Number(d.remoteTailscaleTargetPort??4040),remoteTailscaleAcceptRoutes:!!d.remoteTailscaleAcceptRoutes,remoteCloudflareEnabled:s==="cloudflare",remoteCloudflareQuickTunnel:!!(d.remoteCloudflareQuickTunnel??!0),remoteCloudflareTunnelName:String(d.remoteCloudflareTunnelName??""),remoteCloudflareTunnelToken:d.remoteCloudflareTunnelToken||null,remoteCloudflareIngressUrl:String(d.remoteCloudflareIngressUrl??""),remoteShortLivedEnabled:!!d.remoteShortLivedEnabled,remoteShortLivedTtlMs:Number(d.remoteShortLivedTtlMs??9e5),remoteRememberLastRunning:!!d.remoteRememberLastRunning};await ks(h,u),await Qn(u),await Ns(u),o("Remote tunnel restarted","success")}),children:pe==="start fresh"?"Restarting…":"Start Fresh"}),e.jsx("button",{type:"button",className:"btn btn-primary",disabled:!s||pe!==null,onClick:()=>void Ge("use existing",async()=>{const d=a,h={remoteActiveProvider:s,remoteTailscaleEnabled:s==="tailscale",remoteTailscaleHostname:String(d.remoteTailscaleHostname??""),remoteTailscaleTargetPort:Number(d.remoteTailscaleTargetPort??4040),remoteTailscaleAcceptRoutes:!!d.remoteTailscaleAcceptRoutes,remoteCloudflareEnabled:s==="cloudflare",remoteCloudflareQuickTunnel:!!(d.remoteCloudflareQuickTunnel??!0),remoteCloudflareTunnelName:String(d.remoteCloudflareTunnelName??""),remoteCloudflareTunnelToken:d.remoteCloudflareTunnelToken||null,remoteCloudflareIngressUrl:String(d.remoteCloudflareIngressUrl??""),remoteShortLivedEnabled:!!d.remoteShortLivedEnabled,remoteShortLivedTtlMs:Number(d.remoteShortLivedTtlMs??9e5),remoteRememberLastRunning:!!d.remoteRememberLastRunning};await ks(h,u),await Ns(u),o("Remote tunnel started","success")}),children:pe==="use existing"?"Starting…":"Use Existing"})]}):e.jsx("button",{type:"button",className:"btn btn-primary",disabled:!s||pe!==null,onClick:()=>void Ge("start",async()=>{const d=a,h={remoteActiveProvider:s,remoteTailscaleEnabled:s==="tailscale",remoteTailscaleHostname:String(d.remoteTailscaleHostname??""),remoteTailscaleTargetPort:Number(d.remoteTailscaleTargetPort??4040),remoteTailscaleAcceptRoutes:!!d.remoteTailscaleAcceptRoutes,remoteCloudflareEnabled:s==="cloudflare",remoteCloudflareQuickTunnel:!!(d.remoteCloudflareQuickTunnel??!0),remoteCloudflareTunnelName:String(d.remoteCloudflareTunnelName??""),remoteCloudflareTunnelToken:d.remoteCloudflareTunnelToken||null,remoteCloudflareIngressUrl:String(d.remoteCloudflareIngressUrl??""),remoteShortLivedEnabled:!!d.remoteShortLivedEnabled,remoteShortLivedTtlMs:Number(d.remoteShortLivedTtlMs??9e5),remoteRememberLastRunning:!!d.remoteRememberLastRunning};await ks(h,u),await Ns(u),o("Remote tunnel started","success")}),children:pe==="start"?"Starting…":"Start Tunnel"}),s==="cloudflare"&&Y?.cloudflaredAvailable===!1?e.jsx("small",{className:"field-error",children:"cloudflared must be installed to start the tunnel"}):null]})}),e.jsxs("details",{className:"remote-advanced-details",children:[e.jsx("summary",{children:"Advanced Settings"}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"remoteShortLivedEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"remoteShortLivedEnabled",type:"checkbox",checked:!!t.remoteShortLivedEnabled,onChange:d=>i(h=>({...h,remoteShortLivedEnabled:d.target.checked}))}),"Enable short-lived tokens"]}),e.jsx("label",{htmlFor:"remoteShortLivedTtlMs",children:"Short-lived TTL (ms)"}),e.jsx("input",{id:"remoteShortLivedTtlMs",type:"number",min:6e4,max:864e5,value:Number(t.remoteShortLivedTtlMs??9e5),onChange:d=>i(h=>({...h,remoteShortLivedTtlMs:Number(d.target.value||9e5)}))}),rs&&e.jsxs("small",{children:["Last short-lived token expires at ",new Date(rs.expiresAt).toLocaleString()," (",rs.ttlMs,"ms)"]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"remoteRememberLastRunning",className:"checkbox-label",children:[e.jsx("input",{id:"remoteRememberLastRunning",type:"checkbox",checked:!!t.remoteRememberLastRunning,onChange:d=>i(h=>({...h,remoteRememberLastRunning:d.target.checked}))}),"Remember last running state"]}),e.jsx("small",{children:"Automatically restore tunnel on startup if it was running when last stopped."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Auth Links"}),e.jsxs("div",{className:"settings-button-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm",disabled:pe!==null,onClick:()=>void Ge("regenerate persistent token",async()=>{await Xn(u),o("Persistent token regenerated","success")}),children:"Regenerate persistent token"}),e.jsx("button",{type:"button",className:"btn btn-sm",disabled:pe!==null,onClick:()=>void Ge("generate short-lived token",async()=>{const d=Number(t.remoteShortLivedTtlMs??9e5),h=await Jn(d,u);Dl(h),o("Short-lived token generated","success")}),children:"Generate short-lived token"}),e.jsx("button",{type:"button",className:"btn btn-sm",disabled:pe!==null,onClick:()=>void Ge("fetch remote url",async()=>{const d=Number(t.remoteShortLivedTtlMs??9e5),h=await Ha({projectId:u,tokenType:Xe,ttlMs:Xe==="short-lived"?d:void 0});ea(h),ta(null)}),children:"Show URL"}),e.jsx("button",{type:"button",className:"btn btn-sm",disabled:pe!==null,onClick:()=>void Ge("generate QR",async()=>{const d=Number(t.remoteShortLivedTtlMs??9e5),h=await vs("image/svg",{projectId:u,tokenType:Xe,ttlMs:Xe==="short-lived"?d:void 0});ea({url:h.url,expiresAt:h.expiresAt,tokenType:h.tokenType}),ta(h.data??null)}),children:"Generate QR"})]}),e.jsx("label",{htmlFor:"remoteAuthLinkTokenType",children:"Auth link token type"}),e.jsxs("select",{id:"remoteAuthLinkTokenType",value:Xe,onChange:d=>El(d.target.value),children:[e.jsx("option",{value:"persistent",children:"Persistent token"}),e.jsx("option",{value:"short-lived",children:"Short-lived token"})]}),e.jsxs("small",{children:["URL and QR generation use the selected token type.",Xe==="short-lived"?` TTL: ${Number(t.remoteShortLivedTtlMs??9e5)}ms.`:""]}),ut?.url&&e.jsxs(e.Fragment,{children:[e.jsxs("small",{children:["Authenticated URL:",e.jsx("code",{className:"settings-url-output",children:ut.url})]}),e.jsxs("small",{children:["Token type: ",e.jsx("strong",{children:ut.tokenType}),ut.expiresAt?` · Expires at ${new Date(ut.expiresAt).toLocaleString()}`:" · No expiry"]})]}),ls&&e.jsxs("div",{className:"settings-qr-preview","aria-live":"polite",children:[e.jsx("p",{className:"settings-qr-preview-label",children:"Scan this QR code on your phone"}),e.jsx("div",{className:"settings-qr-preview-image-wrap",children:e.jsx("img",{src:`data:image/svg+xml;utf8,${encodeURIComponent(ls)}`,alt:"Remote access QR code",className:"settings-qr-preview-image"})}),e.jsxs("details",{children:[e.jsx("summary",{children:"QR SVG markup"}),e.jsx("pre",{className:"settings-raw-output",children:ls})]})]})]})]})]})}case"prompts":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Prompts"}),e.jsx(Li,{value:a.agentPrompts,onChange:t=>{i(s=>({...s,agentPrompts:t}))},promptOverrides:a.promptOverrides,onPromptOverridesChange:t=>{i(s=>({...s,promptOverrides:t}))}})]});case"plugins":return e.jsxs(e.Fragment,{children:[K(),e.jsx("h4",{className:"settings-section-heading",children:"Plugins"}),e.jsxs("div",{className:"settings-plugins-subsection-toggle",role:"tablist","aria-label":"Plugin manager type",children:[e.jsx("button",{type:"button",id:"plugins-tab-fusion-plugins",role:"tab","aria-controls":"plugins-panel-fusion-plugins","aria-selected":re==="fusion-plugins",tabIndex:re==="fusion-plugins"?0:-1,className:`settings-plugins-subsection-btn${re==="fusion-plugins"?" active":""}`,onClick:()=>Ue("fusion-plugins"),children:"Fusion Plugins"}),e.jsx("button",{type:"button",id:"plugins-tab-pi-extensions",role:"tab","aria-controls":"plugins-panel-pi-extensions","aria-selected":re==="pi-extensions",tabIndex:re==="pi-extensions"?0:-1,className:`settings-plugins-subsection-btn${re==="pi-extensions"?" active":""}`,onClick:()=>Ue("pi-extensions"),children:"Pi Extensions"})]}),e.jsx("div",{id:"plugins-panel-fusion-plugins",role:"tabpanel","aria-labelledby":"plugins-tab-fusion-plugins",className:"settings-plugins-subsection-panel",hidden:re!=="fusion-plugins",children:re==="fusion-plugins"&&e.jsxs(e.Fragment,{children:[e.jsx(r.Suspense,{fallback:null,children:e.jsx(qi,{addToast:o,projectId:u})}),e.jsx(ys,{slotId:"settings-section",projectId:u})]})}),e.jsx("div",{id:"plugins-panel-pi-extensions",role:"tabpanel","aria-labelledby":"plugins-tab-pi-extensions",className:"settings-plugins-subsection-panel",hidden:re!=="pi-extensions",children:re==="pi-extensions"&&e.jsx(r.Suspense,{fallback:null,children:e.jsx(Hi,{addToast:o,projectId:u})})})]});case"authentication":{const t=Le.filter(f=>f.type==="cli"),l=[...Le.filter(f=>f.type!=="cli")].sort((f,Ne)=>f.authenticated!==Ne.authenticated?f.authenticated?-1:1:f.name.localeCompare(Ne.name)),c=l.filter(f=>f.authenticated),d=l.filter(f=>!f.authenticated),h=t.find(f=>f.id==="claude-cli"),g=t.find(f=>f.id==="cursor-cli"),T=t.find(f=>f.id==="llama-cpp"),G=h?e.jsx(Un,{compact:!0,authenticated:h.authenticated,onToggled:()=>{ee()}}):null,x=g?e.jsx(zn,{compact:!0,authenticated:g.authenticated,onToggled:()=>{ee()}}):null,N=T?e.jsx(qn,{compact:!0,authenticated:T.authenticated,onToggled:()=>{ee()}}):null,D=c.length>0||(h?.authenticated??!1)||(g?.authenticated??!1)||(T?.authenticated??!1),de=d.length>0||h&&!h.authenticated||g&&!g.authenticated||T&&!T.authenticated;return e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"settings-section-heading",children:"Authentication"}),Rl?e.jsx("div",{className:"settings-empty-state",children:"Loading authentication status…"}):Le.length===0?e.jsx("div",{className:"settings-empty-state settings-muted",children:"No providers available"}):e.jsxs("div",{className:"auth-panel-body",children:[e.jsx(ys,{slotId:"settings-provider-card",projectId:u,renderPlaceholder:!1,actions:{refreshAuthProviders:()=>{ee()}}}),e.jsx(ys,{slotId:"settings-integration-card",projectId:u,renderPlaceholder:!1,actions:{refreshAuthProviders:()=>{ee()}}}),!D&&e.jsx("div",{className:"auth-section-hint",children:"Sign in to at least one provider to get started with AI models."}),D&&e.jsxs("div",{className:"auth-provider-group",children:[e.jsx("div",{className:"auth-group-label",children:"Authenticated"}),h?.authenticated&&G,g?.authenticated&&x,T?.authenticated&&N,c.map(f=>e.jsx("div",{className:"auth-provider-card auth-provider-card--authenticated",children:e.jsxs("div",{className:"auth-provider-header",children:[e.jsxs("div",{className:"auth-provider-info",children:[e.jsx("span",{className:"auth-provider-icon-slot","data-testid":`auth-provider-icon-${f.id}`,"aria-hidden":"true",children:e.jsx(jt,{provider:f.id,size:"md"})}),e.jsx("strong",{children:f.name}),e.jsx("span",{"data-testid":`auth-status-${f.id}`,className:`auth-status-badge ${f.authenticated?"authenticated":"not-authenticated"}`,children:"✓ Active"}),f.authenticated&&f.keyHint&&e.jsxs("span",{className:"auth-key-hint",children:["Key: ",f.keyHint]})]}),f.type==="api_key"?e.jsxs("div",{className:"auth-apikey-section",children:[e.jsxs("div",{className:"auth-apikey-input-row",children:[e.jsx("input",{type:"password",className:"auth-apikey-input",placeholder:"Enter API key",value:nt[f.id]??"",onChange:Ne=>kt(pt=>({...pt,[f.id]:Ne.target.value})),disabled:xe===f.id}),f.authenticated&&!nt[f.id]?e.jsx("button",{className:"btn btn-sm",onClick:()=>ar(f.id),disabled:xe===f.id,children:"Clear"}):e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>Ia(f.id),disabled:xe===f.id,children:"Save"})]}),xe===f.id&&e.jsx("small",{className:"auth-apikey-progress",children:"Saving…"}),Nt[f.id]&&e.jsx("small",{className:"auth-apikey-error",children:Nt[f.id]}),(f.id==="opencode"||f.id==="opencode-go")&&Qe[f.id]&&e.jsx("small",{className:Qe[f.id].tone==="error"?"form-error":"text-muted",children:Qe[f.id].message})]}):e.jsx("div",{children:xe===f.id?e.jsx("button",{className:"btn btn-sm",disabled:!0,children:"Logging out…"}):f.loginInProgress?e.jsxs("div",{className:"auth-provider-actions-row",children:[e.jsx("button",{className:"btn btn-sm",disabled:!0,children:"Waiting for login…"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>Ta(f.id),children:"Cancel"})]}):e.jsx("button",{className:"btn btn-sm",onClick:()=>sr(f.id),children:"Logout"})})]})},f.id))]}),de&&e.jsxs("div",{className:"auth-provider-group",children:[e.jsx("div",{className:"auth-group-label",children:"Available"}),h&&!h.authenticated&&G,g&&!g.authenticated&&x,T&&!T.authenticated&&N,d.map(f=>e.jsx("div",{className:"auth-provider-card",children:e.jsxs("div",{className:"auth-provider-header",children:[e.jsxs("div",{className:"auth-provider-info",children:[e.jsx("span",{className:"auth-provider-icon-slot","data-testid":`auth-provider-icon-${f.id}`,"aria-hidden":"true",children:e.jsx(jt,{provider:f.id,size:"md"})}),e.jsx("strong",{children:f.name}),e.jsx("span",{"data-testid":`auth-status-${f.id}`,className:`auth-status-badge ${f.authenticated?"authenticated":"not-authenticated"}`,children:"✗ Not connected"})]}),f.type==="api_key"?e.jsxs("div",{className:"auth-apikey-section",children:[e.jsxs("div",{className:"auth-apikey-input-row",children:[e.jsx("input",{type:"password",className:"auth-apikey-input",placeholder:"Enter API key",value:nt[f.id]??"",onChange:Ne=>kt(pt=>({...pt,[f.id]:Ne.target.value})),disabled:xe===f.id}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>Ia(f.id),disabled:xe===f.id,children:"Save"})]}),xe===f.id&&e.jsx("small",{className:"auth-apikey-progress",children:"Saving…"}),Nt[f.id]&&e.jsx("small",{className:"auth-apikey-error",children:Nt[f.id]}),(f.id==="opencode"||f.id==="opencode-go")&&Qe[f.id]&&e.jsx("small",{className:Qe[f.id].tone==="error"?"form-error":"text-muted",children:Qe[f.id].message})]}):e.jsxs("div",{children:[xe===f.id?e.jsx("button",{className:"btn btn-sm",disabled:!0,children:"Waiting for login…"}):f.loginInProgress?e.jsxs("div",{className:"auth-provider-actions-row",children:[e.jsx("button",{className:"btn btn-sm",disabled:!0,children:"Waiting for login…"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>Ta(f.id),children:"Cancel"})]}):e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>er(f.id),children:"Login"}),f.id==="github-copilot"&&Ye[f.id]&&(f.loginInProgress||xe===f.id)&&e.jsxs("div",{className:"auth-device-code-panel","data-testid":`auth-device-code-${f.id}`,children:[e.jsx("strong",{children:"Enter this code on GitHub"}),e.jsx("div",{className:"auth-device-code-pill",children:Ye[f.id].userCode}),e.jsxs("div",{className:"auth-provider-actions-row",children:[e.jsx("button",{className:"btn btn-sm",onClick:()=>{(async()=>{if(await Va(Ye[f.id].userCode)){o("Copied code to clipboard","success");return}o("Failed to copy code — copy it manually from the box above","error")})()},children:"Copy code"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>window.open(Ya(Ye[f.id].verificationUri),"_blank"),children:"Open GitHub"})]})]}),zs[f.id]&&(f.loginInProgress||xe===f.id)&&e.jsx(Hn,{instructions:zs[f.id],"data-testid":`auth-login-instructions-${f.id}`}),yt[f.id]&&(f.loginInProgress||xe===f.id)&&e.jsx(Wn,{value:Yt[f.id]??"",onChange:Ne=>Qt(pt=>({...pt,[f.id]:Ne})),onSubmit:()=>void tr(f.id),prompt:yt[f.id].prompt,placeholder:yt[f.id].placeholder,helpText:yt[f.id].helpText,disabled:Ws===f.id,submitLabel:Ws===f.id?"Submitting…":"Submit code","data-testid":`auth-manual-code-${f.id}`})]})]})},f.id))]})]}),e.jsx("small",{className:"auth-hint",children:"Authentication changes take effect immediately — no need to save."}),S&&e.jsxs("div",{className:"form-group",style:{marginTop:"var(--space-md)"},children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:S,children:"Reopen onboarding guide"}),e.jsx("small",{className:"settings-muted",children:"Re-run the setup wizard to review or update your AI provider and model configuration."})]}),e.jsx(_i,{})]})}case"hermes-runtime":return e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"settings-section-heading",children:"Hermes Runtime"}),e.jsx(wi,{})]});case"openclaw-runtime":return e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"settings-section-heading",children:"OpenClaw Runtime"}),e.jsx(Fi,{})]});case"paperclip-runtime":return e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"settings-section-heading",children:"Paperclip Runtime"}),e.jsx(Ri,{})]})}};return e.jsxs("div",{className:"modal-overlay open settings-modal-overlay",...or,role:"dialog","aria-modal":"true",children:[e.jsxs("div",{className:"modal modal-lg settings-modal",ref:J,style:z,children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{className:"settings-modal-heading",children:[e.jsx("h3",{children:"Settings"}),e.jsxs("div",{className:"settings-update-check",children:[Ce&&e.jsxs("button",{type:"button",className:"settings-version-check-btn",onClick:()=>{Jl()},disabled:v,"aria-label":"Check for updates",title:"Check for updates",children:[e.jsxs("span",{className:"settings-modal-version",children:["Version ",Ce]}),e.jsx(_n,{size:12,className:v?"spinning":void 0})]}),U&&e.jsx("span",{"aria-live":"polite",className:`settings-update-result ${U.error?"settings-update-result--error":U.updateAvailable?"settings-update-result--available":"settings-update-result--up-to-date"}`,children:Zl()})]})]}),e.jsxs("div",{className:"settings-header-actions",children:[a.showGitHubStarButton!==!1&&e.jsxs("a",{href:"https://github.com/Runfusion/Fusion",target:"_blank",rel:"noopener noreferrer",className:"settings-github-star-btn","aria-label":"Star Fusion on GitHub",title:"Star Fusion on GitHub",onClick:Cl,"data-clicked":ke?"true":"false",children:[e.jsxs("span",{className:"settings-github-star-btn__action",children:[e.jsx(jt,{provider:"github",size:"sm"}),e.jsx(ui,{size:11,"aria-hidden":"true"}),"Star"]}),$!==null&&e.jsx("span",{className:"settings-github-star-btn__count","aria-label":`${$.toLocaleString()} stars`,children:$>=1e3?`${($/1e3).toFixed(1)}k`:$.toLocaleString()})]}),e.jsxs("a",{href:"https://github.com/Runfusion/Fusion/discussions",target:"_blank",rel:"noopener noreferrer",className:"btn btn-sm settings-header-help-btn","aria-label":"Help and discussions",title:"Help and discussions",children:[e.jsx(Gn,{size:13,"aria-hidden":"true"}),"Help"]})]}),e.jsx("button",{className:"modal-close",onClick:n,"aria-label":"Close",children:"×"})]}),W?e.jsx("div",{className:"settings-empty-state settings-loading",children:"Loading…"}):e.jsxs("div",{className:"settings-layout",children:[ze&&e.jsxs("div",{className:"settings-mobile-section-picker",children:[e.jsx("label",{htmlFor:"settings-mobile-section",children:"Settings Section"}),e.jsx("select",{id:"settings-mobile-section",className:"select touch-target",value:M,onChange:t=>ie(t.target.value),children:qe.filter(t=>!t.isGroupHeader).map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))})]}),e.jsx("nav",{className:"settings-sidebar",children:qe.map(t=>t.isGroupHeader?e.jsx("div",{className:"settings-group-header",children:t.label},t.id):e.jsxs("button",{className:`settings-nav-item${M===t.id?" active":""}`,onClick:()=>ie(t.id),title:t.scope==="global"?"Shared across all projects":t.scope==="project"?"Specific to this project":void 0,children:[t.scope==="global"&&e.jsx(vt,{className:"settings-scope-icon","aria-label":"Global setting",size:16}),t.scope==="project"&&e.jsx(Qa,{className:"settings-scope-icon","aria-label":"Project setting",size:16}),t.icon&&!t.scope&&e.jsx(t.icon,{className:"settings-scope-icon","aria-label":"Global setting",size:16}),t.label]},t.id))}),e.jsx("div",{className:"settings-content",ref:le,children:Tr()})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsxs("div",{className:"modal-actions-left",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:rr,title:"Export settings to JSON file",children:"Export"}),e.jsx("input",{type:"file",ref:Fa,accept:".json,application/json",style:{display:"none"},onChange:nr}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>Fa.current?.click(),disabled:Tt,title:"Import settings from JSON file",children:Tt?"Loading…":"Import"})]}),e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn btn-sm",onClick:n,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:kr,disabled:W,children:"Save"})]})]})]}),we!==null&&e.jsx("div",{className:"modal-overlay open",onClick:pr,role:"dialog","aria-modal":"true","aria-label":"Browse workspace path",children:e.jsxs("div",{className:"modal modal-lg settings-overlap-path-picker-modal",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Select ignored overlap path"}),e.jsx("button",{className:"modal-close",onClick:$e,"aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"modal-body settings-overlap-path-picker-body",children:[e.jsx("p",{className:"settings-overlap-path-picker-note",children:"Choose a file to ignore directly, or navigate into a folder and select the current directory."}),e.jsx(Xa,{entries:wl,currentPath:Te,onSelectFile:bs,onNavigate:Gt,loading:Sl,error:Pl,onRetry:Al,workspace:"project",projectId:u})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("div",{className:"modal-actions-left",children:e.jsxs("small",{children:["Current directory: ",e.jsx("code",{children:Te==="."?"(project root)":Te})]})}),e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn btn-sm",onClick:$e,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:hr,disabled:Te===".",children:"Select current directory"})]})]})]})}),$s&&e.jsx("div",{className:"modal-overlay open",onClick:xr,role:"dialog","aria-modal":"true","aria-label":"Browse worktrees directory",children:e.jsxs("div",{className:"modal modal-lg settings-overlap-path-picker-modal",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Select worktrees directory"}),e.jsx("button",{className:"modal-close",onClick:_e,"aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"modal-body settings-overlap-path-picker-body",children:[e.jsx("p",{className:"settings-overlap-path-picker-note",children:"Navigate to the folder where Fusion should create task worktrees, then select the current directory."}),e.jsx(Xa,{entries:Fl,currentPath:De,onSelectFile:br,onNavigate:Ut,loading:Ml,error:Tl,onRetry:Il,workspace:"project",projectId:u})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("div",{className:"modal-actions-left",children:e.jsxs("small",{children:["Current directory: ",e.jsx("code",{children:De==="."?"(project root)":De})]})}),e.jsxs("div",{className:"modal-actions-right",children:[e.jsx("button",{className:"btn btn-sm",onClick:_e,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:fr,children:"Select current directory"})]})]})]})}),Hl&&Ae&&e.jsx("div",{className:"modal-overlay open",onClick:t=>t.target===t.currentTarget&&ht(!1),role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"modal modal-md",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Import Settings"}),e.jsx("button",{className:"modal-close",onClick:()=>ht(!1),"aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("p",{children:"Review the settings to be imported:"}),Ae.global&&Object.keys(Ae.global).length>0&&e.jsxs("div",{className:"form-group",children:[e.jsx("strong",{children:"Global Settings:"}),e.jsx("ul",{className:"import-preview-list",children:Object.entries(Ae.global).filter(([,t])=>t!==void 0).map(([t])=>e.jsx("li",{children:t},t))})]}),Ae.project&&Object.keys(Ae.project).length>0&&e.jsxs("div",{className:"form-group",children:[e.jsx("strong",{children:"Project Settings:"}),e.jsx("ul",{className:"import-preview-list",children:Object.entries(Ae.project).filter(([,t])=>t!==void 0).map(([t])=>e.jsx("li",{children:t},t))})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"import-scope",children:"Import Scope:"}),e.jsxs("select",{id:"import-scope",value:hs,onChange:t=>Wl(t.target.value),children:[e.jsx("option",{value:"both",children:"Both global and project settings"}),e.jsx("option",{value:"global",children:"Global settings only"}),e.jsx("option",{value:"project",children:"Project settings only"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"import-merge",className:"checkbox-label",children:[e.jsx("input",{id:"import-merge",type:"checkbox",checked:ps,onChange:t=>Kl(t.target.checked)}),"Merge with existing settings (recommended)"]}),e.jsx("small",{children:"If unchecked, existing settings will be replaced with imported values."})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn btn-sm",onClick:()=>ht(!1),children:"Cancel"}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:ir,disabled:Tt,children:Tt?"Importing…":"Confirm Import"})]})]})})]})}export{co as SettingsModal};
|