blade-code 0.10.2 → 0.10.3
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/blade.js +2 -2
- package/dist/{chunk-8nm1hqr1.js → chunk-0n97186m.js} +2 -2
- package/dist/{chunk-t8q9ks7e.js → chunk-15d49qty.js} +1 -1
- package/dist/chunk-1cx96gx1.js +1 -0
- package/dist/{chunk-8mepk4tc.js → chunk-1g5qc1qx.js} +2 -2
- package/dist/{chunk-d9ddpapp.js → chunk-35yktzm1.js} +1 -1
- package/dist/chunk-3wp3h373.js +180 -0
- package/dist/chunk-4ncbd4k0.js +1 -0
- package/dist/chunk-5fxc90rb.js +1 -0
- package/dist/{chunk-zkbf8n6y.js → chunk-5twefby5.js} +1 -1
- package/dist/{chunk-sndbq5xt.js → chunk-63ysxybd.js} +1 -1
- package/dist/{chunk-nah0cbnp.js → chunk-6tx8k249.js} +2 -2
- package/dist/{chunk-k9a1vb8a.js → chunk-7089z4e1.js} +2 -2
- package/dist/chunk-7443b95r.js +1 -0
- package/dist/chunk-79s052sw.js +2 -0
- package/dist/{chunk-m9zpxzg2.js → chunk-7hqbwpt5.js} +2 -2
- package/dist/chunk-8th744ef.js +1 -0
- package/dist/chunk-8thp1nep.js +1 -0
- package/dist/{chunk-6n5xdf2r.js → chunk-948qe2pp.js} +1 -1
- package/dist/{chunk-mjp61rqd.js → chunk-9ffr01c3.js} +1 -1
- package/dist/{chunk-gafbzeyk.js → chunk-9p5f3ryf.js} +1 -1
- package/dist/{chunk-e2ccyhgz.js → chunk-9yytfg19.js} +1 -1
- package/dist/chunk-aa0ffw17.js +1 -0
- package/dist/{chunk-44wkjs2j.js → chunk-an96c54z.js} +2 -2
- package/dist/{chunk-2beq0syt.js → chunk-bexgcc2d.js} +1 -1
- package/dist/{chunk-5tfzehcg.js → chunk-bfw2p0x8.js} +2 -2
- package/dist/{chunk-bpzv054r.js → chunk-bn148dr5.js} +2 -2
- package/dist/{chunk-ct32ngah.js → chunk-c05t8207.js} +8 -8
- package/dist/chunk-c45y8tx1.js +1484 -0
- package/dist/chunk-ccwskwb3.js +1 -0
- package/dist/chunk-da1jvzbz.js +10 -0
- package/dist/{chunk-af49jmns.js → chunk-dqvcgwhe.js} +2 -2
- package/dist/{chunk-kq5my0yy.js → chunk-drrdzmaa.js} +2 -2
- package/dist/{chunk-px5ck9pf.js → chunk-ea7wsges.js} +2 -2
- package/dist/{chunk-2km4w0ky.js → chunk-eezg6pee.js} +2 -2
- package/dist/{chunk-vjpd3nee.js → chunk-epj56s0n.js} +1 -1
- package/dist/{chunk-0h81hxkw.js → chunk-fvhc1yj8.js} +1 -1
- package/dist/{chunk-d3236505.js → chunk-gb54hc78.js} +1 -1
- package/dist/{chunk-m5tjrr5c.js → chunk-grp43mdb.js} +2 -2
- package/dist/{chunk-fjw32ex5.js → chunk-gxmrakrk.js} +1 -1
- package/dist/{chunk-a7nbn5kf.js → chunk-gxzbv67r.js} +2 -2
- package/dist/{chunk-k89phc5j.js → chunk-jqwntnp1.js} +2 -2
- package/dist/{chunk-88vy9hh0.js → chunk-jza1rsan.js} +1 -1
- package/dist/{chunk-0h9m2fqd.js → chunk-mgwny24b.js} +1 -1
- package/dist/chunk-n3y9ytvg.js +3 -0
- package/dist/chunk-nxj1638n.js +6 -0
- package/dist/chunk-p5tpzh6f.js +1 -0
- package/dist/{chunk-gr5mzxdf.js → chunk-pnrx3spk.js} +1 -1
- package/dist/{chunk-jxv6r0c7.js → chunk-qda309d9.js} +2 -2
- package/dist/{chunk-beqaxytd.js → chunk-qm11hjd3.js} +1 -1
- package/dist/chunk-r4j5ca1h.js +1 -0
- package/dist/{chunk-tm2ckreq.js → chunk-r4pz99sy.js} +20 -20
- package/dist/{chunk-rkzds6k8.js → chunk-rcdynprn.js} +2 -2
- package/dist/{chunk-y0hwzmdn.js → chunk-s95rgkd8.js} +1 -1
- package/dist/chunk-t8x2qpe2.js +1 -0
- package/dist/{chunk-4vaywb2r.js → chunk-tq52pbde.js} +1 -1
- package/dist/{chunk-vvy506b3.js → chunk-v93hcxe7.js} +1 -1
- package/dist/chunk-vmg5n0zv.js +1 -0
- package/dist/{chunk-6sc78810.js → chunk-vwq9s5nj.js} +3 -3
- package/dist/{chunk-ws3gc024.js → chunk-wje6bck2.js} +1 -1
- package/dist/{chunk-qhf0knnx.js → chunk-xdbg7cn3.js} +1 -1
- package/dist/{chunk-th7sxjtk.js → chunk-ydtcvxsm.js} +1 -1
- package/dist/{chunk-wvj9h7mb.js → chunk-ygx03mdh.js} +1 -1
- package/dist/{chunk-6hj2dk75.js → chunk-z906d5tb.js} +2 -2
- package/dist/chunk-zq9r0jx3.js +1 -0
- package/dist/chunk-zyz82mcd.js +1 -0
- package/dist/web/assets/{ChatView-CnwNosSG.js → ChatView-Pqa25Vua.js} +5 -5
- package/dist/web/assets/{CodeBlockHighlighter-CBo_AxjZ.js → CodeBlockHighlighter-Dxt-FWJk.js} +1 -1
- package/dist/web/assets/{FilePreview-hNo6RCNY.js → FilePreview-Dj2yppPn.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-BON4fqSr.js → MarkdownRenderer-BI2xpTV2.js} +12 -12
- package/dist/web/assets/McpModal-COw0BcHJ.js +5 -0
- package/dist/web/assets/SettingsModal-h4AxN730.js +1 -0
- package/dist/web/assets/SkillsModal-CTZTu9xg.js +1 -0
- package/dist/web/assets/{TaskSwitcher-Ds8CBVtp.js → TaskSwitcher-DPXkV-qb.js} +1 -1
- package/dist/web/assets/{TerminalPanel-Dm4bu6ib.js → TerminalPanel-tpUxwaCh.js} +1 -1
- package/dist/web/assets/index-Dep3eEsS.css +1 -0
- package/dist/web/assets/index-bjyn3NHs.js +32 -0
- package/dist/web/assets/useRequest-BvqVDnKl.js +1 -0
- package/dist/web/assets/{vendor-icons-CsBKlDXT.js → vendor-icons-D_AkWmWB.js} +70 -60
- package/dist/web/assets/{vendor-radix-DXRuAJHH.js → vendor-radix-DBy9B2DN.js} +1 -1
- package/dist/web/index.html +4 -4
- package/package.json +1 -1
- package/dist/chunk-1wyfb6s7.js +0 -1
- package/dist/chunk-3vyjshqp.js +0 -1
- package/dist/chunk-6g21dh3n.js +0 -1
- package/dist/chunk-asbp4cv4.js +0 -1
- package/dist/chunk-bqk3wqts.js +0 -1
- package/dist/chunk-cjdnfyy0.js +0 -1485
- package/dist/chunk-d8zj7c0t.js +0 -6
- package/dist/chunk-jv4nkkb5.js +0 -1
- package/dist/chunk-m3tx1k0s.js +0 -1
- package/dist/chunk-m78ceafk.js +0 -1
- package/dist/chunk-nqq4sbmv.js +0 -1
- package/dist/chunk-p7ppnewt.js +0 -3
- package/dist/chunk-qev36qrb.js +0 -2
- package/dist/chunk-tckfyfsx.js +0 -1
- package/dist/chunk-xhpezpjq.js +0 -10
- package/dist/chunk-y5vq7gek.js +0 -174
- package/dist/chunk-ydqeg4p8.js +0 -1
- package/dist/chunk-yknrffcs.js +0 -1
- package/dist/chunk-ymmtbq2b.js +0 -1
- package/dist/chunk-z2yzyr9h.js +0 -1
- package/dist/web/assets/McpModal-Go_8v1Vu.js +0 -5
- package/dist/web/assets/SettingsModal-CRu1zGQf.js +0 -1
- package/dist/web/assets/index-BNsnHxlt.js +0 -32
- package/dist/web/assets/index-DVTiq-7u.css +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,j as e}from"./vendor-react-DG5dkZ_t.js";import{v as C,D as be,e as fe,w as ge,g as je,a as ce,j as T,b as pe,x as Oe,y as Ke,K as qe,z as ze}from"./index-BNsnHxlt.js";import{X as ve,f as he,a4 as Ge,a5 as He,L as J,a6 as ye,O as Ae,a as xe,B as _e,D as Se,T as me,a7 as Je,i as We,a8 as Ye,u as Qe,a9 as Ve,P as Ce}from"./vendor-icons-CsBKlDXT.js";import"./vendor-radix-DXRuAJHH.js";const Xe=/^[a-z][a-z0-9._-]{0,63}$/;function Ze({open:o,onOpenChange:x,onSave:g,saveError:D}){const[U,M]=s.useState([]),[S,E]=s.useState([]),[l,p]=s.useState(),[c,k]=s.useState(),[B,w]=s.useState(""),[F,m]=s.useState(""),[r,A]=s.useState(""),[d,h]=s.useState(""),[_,i]=s.useState(""),[N,y]=s.useState(""),[f,I]=s.useState(!1),[O,W]=s.useState(!1),[Z,$]=s.useState(!1),[ee,H]=s.useState(!1),[Y,R]=s.useState(null);s.useEffect(()=>{if(!o)return;let n=!0;return E([]),p(void 0),k(void 0),w(""),m(""),A(""),h(""),i(""),y(""),I(!1),R(null),W(!0),C("/providers").then(P=>{n&&M(P)}).catch(P=>{n&&R(P instanceof Error?P.message:"Failed to load providers")}).finally(()=>{n&&W(!1)}),()=>{n=!1}},[o]),s.useEffect(()=>{if(!l)return;let n=!0;return E([]),k(void 0),R(null),l.factoryWireApi||l.custom?($(!1),()=>{n=!1}):($(!0),C(`/providers/${l.id}/models`).then(P=>{n&&E(P)}).catch(P=>{n&&R(P instanceof Error?P.message:"Failed to load models")}).finally(()=>{n&&$(!1)}),()=>{n=!1})},[l]);const L=l==null?void 0:l.factoryWireApi,z=!!(L||l!=null&&l.custom),Q=z?d.trim():c==null?void 0:c.id,V=async()=>{if(!l||!Q||!l.configured&&!N)return;if(L){if(!Xe.test(F.trim())){R('Channel ID must start with a lowercase letter and contain only lowercase letters, numbers, ".", "_" or "-"');return}let te;try{te=new URL(_.trim())}catch{R("Base URL must be an absolute HTTP(S) URL");return}if(!["http:","https:"].includes(te.protocol)){R("Base URL must be an absolute HTTP(S) URL");return}}H(!0);const n=L?F.trim():l.id,P=await g({provider:n,model:Q,displayName:B||(z?Q:(c==null?void 0:c.name)??""),apiKey:N||void 0,...L?{modelProvider:{id:n,name:r.trim()||n,baseUrl:_.trim(),wireApi:L}}:{}});H(!1),P&&x(!1)};return e.jsx(be,{open:o,onOpenChange:x,children:e.jsxs(fe,{onCloseAutoFocus:n=>ge("[data-add-model-trigger]",n),onEscapeKeyDown:n=>{n.preventDefault(),x(!1)},onKeyDown:n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),x(!1))},className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[480px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(je,{className:"sr-only",children:"Add Model"}),e.jsxs("div",{className:"flex flex-col gap-5 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono text-base font-semibold",children:"Add Model"}),e.jsx("button",{type:"button",onClick:()=>x(!1),"aria-label":"Close add model",className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(ve,{className:"h-4 w-4"})})]}),(Y||D)&&e.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(he,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Y||D})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Provider",e.jsxs("select",{"aria-label":"Provider",value:(l==null?void 0:l.id)??"",disabled:O,onChange:n=>{p(U.find(P=>P.id===n.target.value)),w(""),m(""),A(""),h(""),i("")},className:"field",children:[e.jsx("option",{value:"",children:O?"Loading providers...":"Select provider"}),U.map(n=>e.jsxs("option",{value:n.id,children:[n.name," (",n.modelCount,")",n.configured?" - configured":""]},n.id))]})]}),z?e.jsxs(e.Fragment,{children:[L&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Channel ID",e.jsx("input",{"aria-label":"Channel ID",value:F,onChange:n=>{m(n.target.value),R(null)},placeholder:"team-gateway",autoComplete:"off",spellCheck:!1,className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:"Stable config and credential identifier."})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Channel name",e.jsx("input",{"aria-label":"Channel name",value:r,onChange:n=>A(n.target.value),placeholder:"Team Gateway",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Base URL",e.jsx("input",{"aria-label":"Base URL",value:_,onChange:n=>{i(n.target.value),R(null)},placeholder:L==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:L==="anthropic-messages"?"Uses the Anthropic Messages protocol.":"Uses the OpenAI Chat Completions protocol."})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Model ID",e.jsx("input",{"aria-label":"Model ID",value:d,onChange:n=>{h(n.target.value),R(null)},placeholder:"vendor-model-2026",className:"field"})]})]}):e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Model",e.jsxs("select",{"aria-label":"Model",value:(c==null?void 0:c.id)??"",disabled:!l||Z,onChange:n=>{const P=S.find(te=>te.id===n.target.value);k(P),P&&w(P.name)},className:"field",children:[e.jsx("option",{value:"",children:Z?"Loading models...":"Select model"}),S.map(n=>e.jsxs("option",{value:n.id,children:[n.name," - ",Math.round(n.contextWindow/1e3),"K",n.reasoning?" - reasoning":"",n.input.includes("image")?" - vision":""]},n.id))]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Display name",e.jsx("input",{value:B,onChange:n=>w(n.target.value),placeholder:(c==null?void 0:c.name)??"Optional alias",className:"field"})]}),(l==null?void 0:l.supportsApiKey)&&!l.configured&&e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["API Key",e.jsxs("span",{className:"relative",children:[e.jsx("input",{"aria-label":"API key",type:f?"text":"password",value:N,onChange:n=>y(n.target.value),className:"field w-full pr-10",placeholder:"Stored separately in auth.json"}),e.jsx("button",{type:"button",onClick:()=>I(!f),"aria-label":f?"Hide API key":"Show API key",className:"absolute right-2 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded",children:f?e.jsx(Ge,{className:"h-4 w-4"}):e.jsx(He,{className:"h-4 w-4"})})]})]}),l&&!l.configured&&!l.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:"This provider requires OAuth or ambient credentials. Configure it externally before selecting the model."}),e.jsxs("button",{type:"button",disabled:ee||!l||!Q||L&&(!F.trim()||!_.trim())||!l.configured&&(!l.supportsApiKey||N.trim().length===0),onClick:()=>void V(),className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 font-mono text-sm font-semibold text-white disabled:opacity-50",children:[ee&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),ee?"Saving...":"Save Model"]})]})]})})}function et(o){const[x,g]=s.useState(""),[D,U]=s.useState(""),[M,S]=s.useState(""),[E,l]=s.useState(""),[p,c]=s.useState(!1),[k,B]=s.useState(null);s.useEffect(()=>{var m,r,A,d,h;g(((m=o.model)==null?void 0:m.displayName)??""),U(((A=(r=o.model)==null?void 0:r.overrides)==null?void 0:A.baseUrl)??""),S(((h=(d=o.model)==null?void 0:d.overrides)==null?void 0:h.streamIdleTimeout)!==void 0?String(o.model.overrides.streamIdleTimeout):""),l(""),B(null)},[o.model]);const w=async()=>{if(!o.model)return;B(null);const m=M.trim()?Number(M):void 0;if(m!==void 0&&(!Number.isFinite(m)||m<1e3)){B("Stream idle timeout must be at least 1000ms");return}c(!0);try{E.trim()&&await C(`/providers/${o.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:E.trim()})});const r={...o.model.overrides};D.trim()?r.baseUrl=D.trim():delete r.baseUrl,m!==void 0?r.streamIdleTimeout=m:delete r.streamIdleTimeout,await o.onSave(o.model.id,{displayName:x||void 0,overrides:Object.keys(r).length>0?r:void 0})&&o.onOpenChange(!1)}catch(r){B(r instanceof Error?r.message:"Failed to update provider credential")}finally{c(!1)}},F=o.model?`[data-edit-model-trigger="${o.model.id.replace(/"/g,'\\"')}"]`:"[data-edit-model-trigger]";return e.jsx(be,{open:o.open,onOpenChange:o.onOpenChange,children:e.jsxs(fe,{onCloseAutoFocus:m=>ge(F,m),onEscapeKeyDown:m=>{m.preventDefault(),o.onOpenChange(!1)},onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),o.onOpenChange(!1))},className:"gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(je,{className:"sr-only",children:"Edit Model"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono font-semibold",children:"Edit Model Overrides"}),e.jsx("button",{type:"button",onClick:()=>o.onOpenChange(!1),"aria-label":"Close edit model",className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(ve,{className:"h-4 w-4"})})]}),(k||o.saveError)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:k||o.saveError}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Display name",e.jsx("input",{value:x,onChange:m=>g(m.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Replace provider API key",e.jsx("input",{type:"password",value:E,onChange:m=>l(m.target.value),placeholder:"Leave empty to keep current credential",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Base URL override",e.jsx("input",{value:D,onChange:m=>U(m.target.value),placeholder:"Leave empty to use default endpoint",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Stream idle timeout (ms)",e.jsx("input",{type:"number",min:1e3,step:1e3,value:M,onChange:m=>S(m.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void w(),disabled:p,className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 text-white disabled:opacity-60",children:[p&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),p?"Saving...":"Save"]})]})})}function tt({provider:o,onOpenChange:x,onSave:g,saveError:D}){const[U,M]=s.useState(o.name),[S,E]=s.useState(o.defaultBaseUrl??""),[l,p]=s.useState(o.wireApi??"openai-completions"),[c,k]=s.useState(o.apiKeyEnv??""),[B,w]=s.useState(""),[F,m]=s.useState(null),[r,A]=s.useState(!1);s.useEffect(()=>{M(o.name),E(o.defaultBaseUrl??""),p(o.wireApi??"openai-completions"),k(o.apiKeyEnv??""),w(""),m(null)},[o]);const d=async()=>{if(!U.trim()){m("Channel name is required");return}try{const h=new URL(S.trim());if(!["http:","https:"].includes(h.protocol))throw new Error}catch{m("Base URL must be an absolute HTTP(S) URL");return}A(!0),m(null);try{await g(o.id,{name:U.trim(),baseUrl:S.trim(),wireApi:l,apiKeyEnv:c.trim()||null,...B.trim()?{apiKey:B.trim()}:{}})&&x(!1)}finally{A(!1)}};return e.jsx(be,{open:!0,onOpenChange:x,children:e.jsxs(fe,{onCloseAutoFocus:h=>ge(`[data-edit-provider-trigger="${o.id.replace(/"/g,'\\"')}"]`,h),onEscapeKeyDown:h=>{h.preventDefault(),x(!1)},onKeyDown:h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),x(!1))},className:"gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(je,{className:"sr-only",children:"Edit Provider Channel"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-mono font-semibold",children:"Edit Provider Channel"}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-zinc-400",children:o.id})]}),e.jsx("button",{type:"button",onClick:()=>x(!1),"aria-label":"Close edit provider",className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(ve,{className:"h-4 w-4"})})]}),(F||D)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:F||D}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Channel name",e.jsx("input",{"aria-label":"Channel name",value:U,onChange:h=>M(h.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Wire API",e.jsxs("select",{"aria-label":"Wire API",value:l,onChange:h=>p(h.target.value),className:"field",children:[e.jsx("option",{value:"openai-completions",children:"OpenAI Chat Completions"}),e.jsx("option",{value:"anthropic-messages",children:"Anthropic Messages"})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Base URL",e.jsx("input",{"aria-label":"Provider Base URL",value:S,onChange:h=>{E(h.target.value),m(null)},className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["API key environment variable",e.jsx("input",{"aria-label":"API key environment variable",value:c,onChange:h=>k(h.target.value),placeholder:"Optional, for example TEAM_GATEWAY_API_KEY",autoComplete:"off",spellCheck:!1,className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Replace API key",e.jsx("input",{"aria-label":"Provider API key",type:"password",value:B,onChange:h=>w(h.target.value),placeholder:"Leave empty to keep current credential",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void d(),disabled:r,className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 text-white disabled:opacity-60",children:[r&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),r?"Saving...":"Save channel"]})]})})}const at={disabled:"Hooks disabled",not_required:"No external hooks",untrusted:"Review required",trusted:"Trusted",modified:"Changed since approval",error:"Trust store error"};function st(){const o=ce(i=>{var N;return(N=i.currentSessionRef)==null?void 0:N.projectPath}),x=s.useMemo(()=>o??new URLSearchParams(window.location.search).get("project")??"",[o]),[g,D]=s.useState(null),[U,M]=s.useState(""),[S,E]=s.useState(!1),[l,p]=s.useState(null),[c,k]=s.useState(null),[B,w]=s.useState(null),F=s.useRef(0),m=s.useRef(x);m.current=x;const r=U===x?g:null,A=s.useCallback(async()=>{const i=++F.current;if(!x){D(null),M(""),w(null);return}E(!0),w(null);try{const N=await C(`/hooks/trust?projectPath=${encodeURIComponent(x)}`);if(i!==F.current)return;D(N),M(x)}catch(N){if(i!==F.current)return;w(N instanceof Error?N.message:"Failed to load hook trust")}finally{i===F.current&&E(!1)}},[x]);s.useEffect(()=>(k(null),A(),()=>{F.current+=1}),[A]);const d=async i=>{if(!r)return;const N=x;p(i),w(null);try{const y=await C("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:x,action:i,...i==="trust"&&r.currentDigest?{expectedDigest:r.currentDigest}:{}})});m.current===N&&(D(y),M(N),k(null))}catch(y){m.current===N&&w(y instanceof Error?y.message:"Failed to update hook trust")}finally{p(null)}};if(!x)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project session to review its hooks."});const h=(r==null?void 0:r.state)==="trusted",_=(r==null?void 0:r.state)==="untrusted"||(r==null?void 0:r.state)==="modified";return e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h?e.jsx(ye,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ae,{className:T("h-4 w-4",_?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:r?at[r.state]:"Hook trust"}),S&&e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:x}),(r==null?void 0:r.currentDigest)&&e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:r.currentDigest})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void A(),disabled:S||l!==null,"aria-label":"Reload hook trust",className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"Reload"]}),h?e.jsx("button",{type:"button",onClick:()=>k("revoke"),disabled:l!==null,className:"h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400",children:"Revoke"}):e.jsx("button",{type:"button",onClick:()=>k("trust"),disabled:l!==null||!(r!=null&&r.currentDigest)||r.state==="error",className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:"Trust digest"})]})]}),B&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:B}),c&&r&&e.jsxs("div",{role:"alertdialog","aria-label":c==="trust"?"Trust project hooks":"Revoke project hook trust",className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-900/70 dark:bg-amber-950/30",children:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:c==="trust"?`Run these ${r.configuredHooks} hooks with your user permissions until their configuration changes?`:"Stop all configured hooks for this project until explicitly trusted again?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>k(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void d(c),disabled:l!==null,className:T("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:l?"Saving...":c==="trust"?"Trust reviewed hooks":"Revoke trust"})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((r==null?void 0:r.definitions)??[]).map((i,N)=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:i.event}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:i.type}),i.name&&e.jsx("span",{className:"text-[#71717a]",children:i.name}),i.pluginName&&e.jsxs("span",{className:"rounded bg-violet-100 px-1.5 py-0.5 text-[9px] text-violet-700 dark:bg-violet-950/50 dark:text-violet-300",children:[i.pluginName," · ",i.pluginSource]})]}),i.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:i.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:i.target})]},`${i.event}-${i.type}-${N}`)),r&&r.definitions.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:"No configured command, HTTP, or prompt hooks."})]})]})}const rt={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]};function nt(){const o=ce(a=>{var j;return(j=a.currentSessionRef)==null?void 0:j.projectPath}),x=ce(a=>a.selectedProjectPath),g=s.useMemo(()=>o??x??new URLSearchParams(window.location.search).get("project")??"",[x,o]),[D,U]=s.useState([]),[M,S]=s.useState([]),[E,l]=s.useState(rt),[p,c]=s.useState(!1),[k,B]=s.useState(""),[w,F]=s.useState(""),[m,r]=s.useState(""),[A,d]=s.useState(""),[h,_]=s.useState(!1),[i,N]=s.useState(null),[y,f]=s.useState(null),[I,O]=s.useState(""),[W,Z]=s.useState(""),[$,ee]=s.useState(!1),[H,Y]=s.useState(null),R=s.useRef(0),L=s.useRef(g);L.current=g;const z=A===g?D:[],Q=A===g?M:[],V=s.useCallback(async()=>{const a=++R.current;if(!g){U([]),d(""),f(null);return}_(!0),f(null);try{const[j,K,q]=await Promise.all([C(`/plugins?projectPath=${encodeURIComponent(g)}`),C(`/plugins/catalog?projectPath=${encodeURIComponent(g)}`),C(`/plugins/policy?projectPath=${encodeURIComponent(g)}`)]);if(a!==R.current)return;U(j),S(K),l(q.policy),c(q.environmentRequiresSha),B(q.policy.allowedGitHosts.join(", ")),F(q.policy.allowedMarketplaces.join(", ")),r(q.policy.allowedLocalRoots.join(", ")),d(g)}catch(j){if(a!==R.current)return;f(j instanceof Error?j.message:"Failed to load plugins")}finally{a===R.current&&_(!1)}},[g]);s.useEffect(()=>(V(),()=>{R.current+=1}),[V]);const n=async(a,j)=>{const K=g;N(a.name),f(null);try{await C(`/plugins/${encodeURIComponent(a.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:K,enabled:j,scope:"local"})}),L.current===K&&await V()}catch(q){L.current===K&&f(q instanceof Error?q.message:"Failed to update plugin")}finally{N(null)}},P=a=>[...new Set(a.split(",").map(j=>j.trim()).filter(Boolean))],te=async()=>{await X("policy:save",()=>C("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,scope:"local",policy:{...E,allowedGitHosts:P(k),allowedMarketplaces:P(w),allowedLocalRoots:P(m)}})}))},X=async(a,j,K)=>{const q=g;N(a),f(null);try{await j(),L.current===q&&(K==null||K(),Y(null),await V())}catch(se){L.current===q&&f(se instanceof Error?se.message:"Plugin action failed")}finally{N(null)}},le=async()=>{const a=I.trim();!a||!$||await X("install",()=>C("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,source:a,trust:!0})}),()=>{O(""),ee(!1)})},oe=async a=>{const j=`update:${a.name}`;if(H!==j){Y(j);return}await X(j,()=>C(`/plugins/${encodeURIComponent(a.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,trust:!0})}))},ue=async a=>{const j=`uninstall:${a.name}`;if(H!==j){Y(j);return}await X(j,()=>C(`/plugins/${encodeURIComponent(a.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,confirm:!0})}))},ae=async()=>{const a=W.trim();a&&await X("marketplace:add",()=>C("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,source:a})}),()=>Z(""))},ke=async a=>{await X(`marketplace:refresh:${a.name}`,()=>C(`/plugins/marketplaces/${encodeURIComponent(a.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g})}))},ie=async a=>{const j=`marketplace:remove:${a.name}`;if(H!==j){Y(j);return}await X(j,()=>C(`/plugins/marketplaces/${encodeURIComponent(a.name)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,confirm:!0})}))};return g?e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(_e,{className:"h-4 w-4"}),"Workspace plugins",h&&e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:g}),e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:"Changes apply to future sessions and persist in local project settings."})]}),e.jsxs("button",{type:"button",onClick:()=>void V(),disabled:h||i!==null,"aria-label":"Reload plugins",className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"Reload"]})]}),y&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:y}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),"Source policy"]}),e.jsx("button",{type:"button","aria-label":"Save plugin source policy",onClick:()=>void te(),disabled:i!==null,className:"rounded-md border border-[#D1D5DB] px-2 py-1 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:i==="policy:save"?"Saving…":"Save for project"})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-2",children:[e.jsxs("button",{type:"button",role:"switch","aria-label":"Restrict plugin sources","aria-checked":E.restrictToAllowedSources,onClick:()=>l(a=>({...a,restrictToAllowedSources:!a.restrictToAllowedSources})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:T("h-3.5 w-6 rounded-full p-0.5",E.restrictToAllowedSources?"bg-amber-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:T("block h-2.5 w-2.5 rounded-full bg-white transition-transform",E.restrictToAllowedSources&&"translate-x-2.5")})}),"Restrict to allowlists"]}),e.jsxs("button",{type:"button",role:"switch","aria-label":"Require full Git commit SHA","aria-checked":E.requireGitCommitSha,disabled:p,onClick:()=>l(a=>({...a,requireGitCommitSha:!a.requireGitCommitSha})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] disabled:opacity-50 dark:text-[#a1a1aa]",children:[e.jsx("span",{className:T("h-3.5 w-6 rounded-full p-0.5",E.requireGitCommitSha?"bg-emerald-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:T("block h-2.5 w-2.5 rounded-full bg-white transition-transform",E.requireGitCommitSha&&"translate-x-2.5")})}),"Require full Git SHA",p?" · environment locked":""]})]}),e.jsxs("div",{className:"mt-2 grid gap-1.5 sm:grid-cols-3",children:[e.jsx("input",{"aria-label":"Allowed plugin Git hosts",value:k,onChange:a=>B(a.target.value),placeholder:"github.com, *.corp.test",className:"h-7 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[9.5px] text-[#111827] outline-none dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsx("input",{"aria-label":"Allowed plugin Marketplaces",value:w,onChange:a=>F(a.target.value),placeholder:"team-market, official",className:"h-7 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[9.5px] text-[#111827] outline-none dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsx("input",{"aria-label":"Allowed local plugin roots",value:m,onChange:a=>r(a.target.value),placeholder:"/opt/approved/plugins",className:"h-7 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[9.5px] text-[#111827] outline-none dark:border-[#3f3f46] dark:text-[#E5E5E5]"})]}),E.restrictToAllowedSources&&!k.trim()&&!w.trim()&&!m.trim()&&e.jsx("p",{className:"mt-1.5 text-[9px] text-amber-700 dark:text-amber-400",children:"Empty allowlists deny every plugin source."})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(Se,{className:"h-3.5 w-3.5"}),"Install trusted plugin"]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("input",{"aria-label":"Plugin source",value:I,onChange:a=>O(a.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:i!==null,className:"h-8 min-w-0 flex-1 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[10.5px] text-[#111827] outline-none focus:border-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsxs("button",{type:"button",onClick:()=>void le(),disabled:!I.trim()||!$||i!==null,className:"inline-flex h-8 items-center gap-1 rounded-md bg-[#111827] px-3 text-[10.5px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]",children:[i==="install"?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Se,{className:"h-3.5 w-3.5"}),"Install"]})]}),e.jsxs("button",{type:"button",role:"checkbox","aria-checked":$,onClick:()=>ee(a=>!a),className:"mt-2 flex items-center gap-2 text-left text-[9.5px] text-amber-700 dark:text-amber-400",children:[e.jsx("span",{className:T("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",$?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:$?"✓":""}),"I trust this source to activate Hooks, MCP servers, skills, and commands."]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[z.map(a=>{var q;const j=i===a.name,K=[a.commands?`${a.commands} commands`:"",a.skills?`${a.skills} skills`:"",a.agents?`${a.agents} agents`:"",a.hooks?`${a.hooks} hooks`:"",a.mcpServers?`${a.mcpServers} MCP`:""].filter(Boolean);return e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[#E5E7EB] px-3 py-2.5 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),e.jsxs("span",{className:"text-[9.5px] text-[#9CA3AF]",children:["v",a.version]}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:a.source})]}),e.jsx("p",{className:"mt-1 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a.description}),e.jsx("p",{className:"mt-1 text-[9.5px] text-[#9CA3AF]",children:K.join(" · ")||"No declared resources"}),a.managed&&e.jsxs("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:["managed",a.marketplace?` · ${a.marketplace}`:"",a.revision?` · ${a.revision.slice(0,12)}`:""]}),!a.configurable&&e.jsx("p",{className:"mt-1 text-[9.5px] text-amber-600 dark:text-amber-400",children:"Invocation-scoped via --plugin-dir"}),(q=a.compatibilityIssues)==null?void 0:q.map(se=>e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:se.message},`${se.code}:${se.message}`))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("button",{type:"button",role:"switch","aria-label":a.status==="error"?`Unavailable ${a.name}`:`${a.enabled?"Disable":"Enable"} ${a.name}`,"aria-checked":a.enabled,disabled:a.status==="error"||!a.configurable||j||i!==null,onClick:()=>void n(a,!a.enabled),className:T("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",a.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:T("h-4 w-4 rounded-full bg-white transition-transform",a.enabled?"translate-x-5":"translate-x-0")})}),a.managed&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":`Update ${a.name}`,onClick:()=>void oe(a),disabled:i!==null,className:T("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",H===`update:${a.name}`?"bg-amber-100 text-amber-800 dark:bg-amber-950/50 dark:text-amber-300":"text-[#6B7280] hover:bg-[#F3F4F6] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]"),children:i===`update:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):H===`update:${a.name}`?"Confirm update":"Update"}),e.jsx("button",{type:"button","aria-label":`Uninstall ${a.name}`,onClick:()=>void ue(a),disabled:i!==null,className:T("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",H===`uninstall:${a.name}`?"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300":"text-[#9CA3AF] hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30"),children:i===`uninstall:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):H===`uninstall:${a.name}`?"Confirm remove":e.jsx(me,{className:"h-3 w-3"})})]})]})]},a.name)}),!h&&z.length===0&&!y&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:"No plugins discovered for this project."})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(Je,{className:"h-3.5 w-3.5"}),"Marketplaces"]}),e.jsxs("span",{className:"text-[9px] text-[#9CA3AF]",children:[Q.length," configured"]})]}),e.jsxs("div",{className:"flex gap-2 border-b border-[#E5E7EB] p-2 dark:border-[#27272a]",children:[e.jsx("input",{"aria-label":"Marketplace source",value:W,onChange:a=>Z(a.target.value),placeholder:"owner/repo, HTTPS Git URL, or ./path",disabled:i!==null,className:"h-7 min-w-0 flex-1 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[10px] text-[#111827] outline-none focus:border-[#6B7280] dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsxs("button",{type:"button","aria-label":"Add marketplace",onClick:()=>void ae(),disabled:!W.trim()||i!==null,className:"inline-flex h-7 items-center gap-1 rounded-md border border-[#D1D5DB] px-2 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[i==="marketplace:add"?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(We,{className:"h-3 w-3"}),"Add"]})]}),Q.map(a=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[a.name,e.jsxs("span",{className:"ml-2 font-normal text-[#9CA3AF]",children:[a.sourceType," · ",a.revision.slice(0,12)]})]}),e.jsx("p",{className:"mt-0.5 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a.description||"No description"})]}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx("button",{type:"button","aria-label":`Refresh marketplace ${a.name}`,disabled:i!==null,onClick:()=>void ke(a),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:i===`marketplace:refresh:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(xe,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Remove marketplace ${a.name}`,disabled:i!==null,onClick:()=>void ie(a),className:T("rounded p-1 text-[#9CA3AF] disabled:opacity-40",H===`marketplace:remove:${a.name}`?"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300":"hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30"),children:H===`marketplace:remove:${a.name}`?e.jsx("span",{className:"px-1 text-[8.5px]",children:"Confirm"}):e.jsx(me,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[a.plugins.slice(0,12).map(j=>e.jsxs("button",{type:"button",disabled:j.installed||i!==null,onClick:()=>{O(`${j.name}@${a.name}`),ee(!1)},title:j.description,className:"rounded bg-[#F3F4F6] px-1.5 py-0.5 text-[8.5px] text-[#6B7280] disabled:opacity-40 dark:bg-[#27272a] dark:text-[#a1a1aa]",children:[j.name,j.installed?" · installed":""]},j.name)),a.plugins.length>12&&e.jsxs("span",{className:"px-1 py-0.5 text-[8.5px] text-[#9CA3AF]",children:["+",a.plugins.length-12]})]})]},a.name)),!h&&Q.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-[10px] text-[#9CA3AF]",children:"Add a Marketplace to discover installable plugins."})]})]}):e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project to manage its plugins."})}const lt={not_required:"No trust required",trusted:"Workspace trusted",untrusted:"Review required",error:"Trust store error"};function ot(){const o=ce(y=>{var f;return(f=y.currentSessionRef)==null?void 0:f.projectPath}),x=s.useMemo(()=>o??new URLSearchParams(window.location.search).get("project")??"",[o]),[g,D]=s.useState(null),[U,M]=s.useState(""),[S,E]=s.useState(!1),[l,p]=s.useState(null),[c,k]=s.useState(null),[B,w]=s.useState(null),[F,m]=s.useState(!1),r=s.useRef(0),A=s.useRef(x);A.current=x;const d=U===x?g:null,h=s.useCallback(async()=>{const y=++r.current;if(!x){D(null),M(""),w(null);return}E(!0),w(null);try{const f=await C(`/workspace-trust?projectPath=${encodeURIComponent(x)}`);if(y!==r.current)return;D(f),M(x)}catch(f){if(y!==r.current)return;w(f instanceof Error?f.message:"Failed to load workspace trust")}finally{y===r.current&&E(!1)}},[x]);s.useEffect(()=>(k(null),m(!1),h(),()=>{r.current+=1}),[h]);const _=async y=>{if(!d)return;const f=x;p(y),w(null);try{const I=await C("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:f,action:y})});A.current===f&&(D(I),M(f),k(null),m(I.reloadRequired===!0))}catch(I){A.current===f&&w(I instanceof Error?I.message:"Failed to update workspace trust")}finally{p(null)}};if(!x)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project session to review folder trust."});const i=(d==null?void 0:d.state)==="trusted",N=(d==null?void 0:d.state)==="untrusted";return e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i?e.jsx(ye,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ae,{className:T("h-4 w-4",N?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:d?lt[d.state]:"Workspace trust"}),S&&e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:x}),d&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[d.decision,d.inheritedFrom?` · inherited from ${d.inheritedFrom}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void h(),disabled:S||l!==null,"aria-label":"Reload workspace trust",className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"Reload"]}),i?e.jsx("button",{type:"button",onClick:()=>k("revoke"),disabled:l!==null,className:"h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400",children:"Revoke"}):e.jsx("button",{type:"button",onClick:()=>k("trust"),disabled:l!==null||(d==null?void 0:d.state)==="error"||!d||d.sensitiveSources===0,className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:"Trust workspace"})]})]}),(B||(d==null?void 0:d.error))&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:B||(d==null?void 0:d.error)}),F&&e.jsx("div",{role:"status",className:"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-[11px] text-blue-700 dark:border-blue-900/60 dark:bg-blue-950/30 dark:text-blue-300",children:"Restart Blade to reload project models, MCP, LSP, permissions, and plugins."}),c&&d&&e.jsxs("div",{role:"alertdialog","aria-label":c==="trust"?"Trust workspace":"Revoke workspace trust",className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-900/70 dark:bg-amber-950/30",children:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:c==="trust"?`Allow ${d.sensitiveSources} project source(s) to configure models, MCP, LSP, permissions, environment, instructions, commands, skills, agents, or plugins?`:"Block project-controlled executable configuration after restart?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>k(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void _(c),disabled:l!==null,className:T("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:l?"Saving...":c==="trust"?"Trust reviewed workspace":"Revoke trust"})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((d==null?void 0:d.sources)??[]).map(y=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:y.path}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:y.kind})]}),y.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:y.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:y.effects.map((f,I)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:f.kind})," · ",f.name,f.target?` → ${f.target}`:""]},`${f.kind}-${f.name}-${I}`))})]},`${y.kind}-${y.path}`)),d&&d.sources.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:"No project-controlled executable configuration was found."})]})]})}const dt={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}},it={searchTasks:"Search tasks",openCommands:"Open command center",newTask:"New task",focusComposer:"Focus composer",toggleSidebar:"Toggle sidebar"};function pt(){var Ne,Ee;const{isSettingsOpen:o,settingsSection:x,toggleSettings:g,isSidebarOpen:D,setSidebarOpen:U}=pe(),{configuredModels:M,loadModels:S,isLoading:E,error:l}=Oe(),p=Ke(),[c,k]=s.useState("general"),[B,w]=s.useState(!1),[F,m]=s.useState(null),[r,A]=s.useState(null),[d,h]=s.useState(null),[_,i]=s.useState([]),[N,y]=s.useState(null),[f,I]=s.useState(null),[O,W]=s.useState(null),[Z,$]=s.useState(null),[ee,H]=s.useState({}),[Y,R]=s.useState(null),[L,z]=s.useState(null),[Q,V]=s.useState(""),[n,P]=s.useState("all"),te=s.useRef(null),X=s.useRef(null),le=s.useRef(0),[oe,ue]=s.useState(typeof Notification>"u"?"unsupported":Notification.permission),ae=[{value:"general",label:"General",category:"Settings"},{value:"trust",label:"Security",category:"Settings"},{value:"models",label:"Models",category:"Settings"},{value:"shortcuts",label:"Shortcuts",category:"Settings"},{value:"mcp",label:"MCP",category:"Integrations"},{value:"skills",label:"Skills",category:"Integrations"},{value:"plugins",label:"Plugins",category:"Integrations"},{value:"hooks",label:"Hooks",category:"Integrations"}],ie=s.useMemo(()=>qe.map(t=>({action:it[t.id],combo:ze(t),scope:t.scope})),[]).filter(t=>{const u=t.action.toLowerCase().includes(Q.toLowerCase()),b=n==="all"||t.scope.toLowerCase()===n;return u&&b}),a=M.reduce((t,u)=>{const b=u.provider||"unknown";return t[b]||(t[b]=[]),t[b].push(u),t},{}),j=new Map(_.map(t=>[t.id,t]));for(const t of _)t.custom&&!a[t.id]&&(a[t.id]=[]);const K=s.useCallback(async()=>{try{i(await C("/providers")),$(null)}catch(t){$(t instanceof Error?t.message:"Failed to load provider channels")}},[]);s.useEffect(()=>{o&&(k(x),S(),K(),p.loadSettings())},[o,S,K,p.loadSettings,x]);const q=()=>{const t=X.current,u=t!=null&&t.isConnected?t:document.querySelector("[data-settings-trigger]");u==null||u.focus({preventScroll:!0})},se=()=>{g(),requestAnimationFrame(q)};s.useLayoutEffect(()=>{if(!o)return;const t=document.activeElement instanceof HTMLElement?document.activeElement:null;t&&t!==document.body&&t!==document.documentElement&&!t.closest("[data-settings-panel]")&&(X.current=t);const u=requestAnimationFrame(()=>{var b;(b=te.current)==null||b.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(u),requestAnimationFrame(q)}},[o]);const Pe=async t=>{R("save"),z(null);try{return await C("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,displayName:t.displayName,model:t.model,apiKey:t.apiKey,modelProvider:t.modelProvider,overrides:t.overrides})}),await S(),await K(),!0}catch(u){return z(u instanceof Error?u.message:"Failed to save model"),!1}finally{R(null)}},Be=async()=>{typeof Notification>"u"||ue(await Notification.requestPermission())},Fe=async t=>{R("delete"),z(null);try{await C(`/models/${t}`,{method:"DELETE"}),await S(),h(null)}catch(u){z(u instanceof Error?u.message:"Failed to delete model")}finally{R(null)}},Re=async(t,u)=>{R("update"),z(null);try{return await C(`/models/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),await S(),!0}catch(b){return z(b instanceof Error?b.message:"Failed to update model"),!1}finally{R(null)}},Te=async(t,u)=>{W({providerId:t,type:"update"}),$(null);try{return await C(`/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),await Promise.all([S(),K()]),!0}catch(b){return $(b instanceof Error?b.message:"Failed to update provider channel"),!1}finally{W(null)}},De=async(t,u)=>{W({providerId:t.id,type:"probe"}),$(null);try{const b=await C(`/providers/${t.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:u})});H(v=>({...v,[t.id]:b}))}catch(b){$(b instanceof Error?b.message:"Provider probe failed")}finally{W(null)}},Me=async t=>{W({providerId:t.id,type:"delete"}),$(null);try{await C(`/providers/${t.id}?removeModels=true`,{method:"DELETE"}),I(null),m(null),H(u=>{const b={...u};return delete b[t.id],b}),await Promise.all([S(),K()])}catch(u){$(u instanceof Error?u.message:"Failed to delete provider channel")}finally{W(null)}},$e=(t,u)=>{var de,re;const b=t.key==="ArrowRight"||t.key==="ArrowDown"?1:t.key==="ArrowLeft"||t.key==="ArrowUp"?-1:0;if(b===0&&t.key!=="Home"&&t.key!=="End")return;t.preventDefault();const v=t.key==="Home"?0:t.key==="End"?ae.length-1:(u+b+ae.length)%ae.length;k(ae[v].value),(re=(de=t.currentTarget.parentElement)==null?void 0:de.querySelectorAll('[role="tab"]')[v])==null||re.focus()},Le=t=>{m(F===t?null:t)},Ie=t=>{if(!o||t.key!=="Escape"||!(t.target instanceof Node)||!t.currentTarget.contains(t.target)||B||r||N||Date.now()-le.current<250)return;const u=t.target instanceof Element?t.target:null;if(!(t.defaultPrevented||u!=null&&u.closest('[role="dialog"]'))){if(t.preventDefault(),d){h(null);return}if(f){I(null);return}se()}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-settings-panel":!0,onKeyDown:Ie,className:"flex h-full min-h-0 bg-white dark:bg-[#09090b]",children:[e.jsxs("nav",{role:"tablist","aria-label":"Settings sections",className:"flex h-full w-[220px] shrink-0 flex-col border-r border-[#E5E7EB] bg-[#F9FAFB] dark:border-zinc-800 dark:bg-[#111113]",children:[e.jsx("div",{className:"shrink-0 p-4",children:e.jsxs("button",{ref:te,type:"button",onClick:se,className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-[12px] font-mono text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:[e.jsx(Ye,{className:"h-3.5 w-3.5"}),"Back"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-3 pb-4",children:Object.entries(ae.reduce((t,u)=>(t[u.category]||(t[u.category]=[]),t[u.category].push(u),t),{})).map(([t,u])=>e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-[#9CA3AF] dark:text-[#71717a]",children:t}),u.map(b=>e.jsx("button",{onClick:()=>k(b.value),onKeyDown:v=>$e(v,ae.indexOf(b)),role:"tab",id:`settings-tab-${b.value}`,"aria-controls":`settings-panel-${b.value}`,"aria-selected":c===b.value,tabIndex:c===b.value?0:-1,className:T("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",c===b.value?"bg-[#E5E7EB] font-medium text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] hover:bg-[#E5E7EB]/60 hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]/50 dark:hover:text-[#E5E5E5]"),children:b.label},b.value))]},t))})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-y-auto p-6 sm:p-10",children:e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-xl font-semibold text-[#111827] dark:text-[#E5E5E5]",children:((Ne=ae.find(t=>t.value===c))==null?void 0:Ne.label)??"Settings"}),p.isLoading&&c==="general"&&e.jsxs("div",{role:"status",className:"flex shrink-0 items-center gap-2 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}),"Loading settings..."]}),p.error&&c==="general"&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(he,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:p.error}),e.jsx("button",{type:"button",onClick:()=>void p.loadSettings(),className:"shrink-0 underline",children:"Retry"})]}),c==="models"&&e.jsxs("div",{id:"settings-panel-models",role:"tabpanel","aria-labelledby":"settings-tab-models",className:"flex flex-col gap-6 flex-1 min-h-0 overflow-hidden",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:"Configure API keys and model settings for different providers."}),(l||L||Z)&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(he,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:Z||L||l}),e.jsx("button",{type:"button",onClick:()=>{z(null),$(null),l&&S()},className:"shrink-0 underline",children:l?"Retry":"Dismiss"})]}),d&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete ${d.displayName||d.model}`,className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsxs("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:["Delete ",d.displayName||d.model," and its saved configuration?"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>h(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void Fe(d.id),disabled:Y!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:Y==="delete"?"Deleting...":"Delete model"})]})]}),f&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete channel ${f.name}`,className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsxs("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:["Delete channel ",f.name,", its credential, and"," ",((Ee=a[f.id])==null?void 0:Ee.length)??0," configured model(s)? Fallback references will also be removed."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>I(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void Me(f),disabled:O!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(O==null?void 0:O.type)==="delete"?"Deleting...":"Delete channel"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[E&&M.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(J,{className:"h-4 w-4 animate-spin"}),"Loading models..."]}),Object.entries(a).map(([t,u])=>{const b=dt[t]||{bg:"#71717a",label:"?"},v=j.get(t),de=F===t,re=ee[t],Ue=(O==null?void 0:O.providerId)===t&&O.type==="probe";return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("button",{onClick:()=>Le(t),className:"flex min-w-0 flex-1 items-center justify-between p-4 text-left transition-colors hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded text-xs font-bold text-white",style:{backgroundColor:b.bg},children:b.label}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"truncate text-sm font-semibold font-mono text-[#111827] dark:text-[#E5E5E5]",children:(v==null?void 0:v.name)??t.replace(/-/g," ")}),e.jsxs("span",{className:"truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[u.length," model",u.length!==1?"s":"",v!=null&&v.custom?` · ${v.wireApi}`:""]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[e.jsxs("span",{className:T("text-xs font-mono",(v==null?void 0:v.configured)===!1?"text-amber-600":"text-[#16A34A]"),children:["●"," ",(v==null?void 0:v.configured)===!1?"Missing credential":"Configured"]}),e.jsx(Qe,{className:T("h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]",de&&"rotate-180")})]})]}),(v==null?void 0:v.custom)&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pr-3",children:[e.jsx("button",{type:"button",onClick:()=>{var G;return void De(v,(G=u[0])==null?void 0:G.id)},disabled:O!==null||u.length===0,"aria-label":`Test ${v.name}`,className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:Ue?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ve,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":v.id,onClick:()=>{$(null),y(v)},disabled:O!==null,"aria-label":`Edit channel ${v.name}`,className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(Ce,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>I(v),disabled:O!==null,"aria-label":`Delete channel ${v.name}`,className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-red-500 disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-red-400",children:e.jsx(me,{className:"h-3.5 w-3.5"})})]})]}),re&&e.jsxs("div",{role:"status",className:T("border-t px-4 py-2 font-mono text-[11px]",re.ok?"border-green-200 bg-green-50 text-green-700 dark:border-green-900/60 dark:bg-green-950/20 dark:text-green-300":"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-300"),children:[re.message," · ",re.latencyMs,"ms · ",re.wireApi]}),de&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:[(v==null?void 0:v.custom)&&e.jsxs("div",{className:"border-b border-[#E5E7EB] px-4 py-2 font-mono text-[11px] text-[#71717a] dark:border-zinc-800",children:[e.jsx("span",{className:"font-semibold",children:v.id})," ","· ",v.defaultBaseUrl]}),u.map(G=>{var we;return e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:G.displayName||G.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[G.displayName&&`${G.model} · `,((we=G.overrides)==null?void 0:we.baseUrl)||"default endpoint"]})]}),e.jsxs("div",{className:"flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:[e.jsx("button",{"data-edit-model-trigger":G.id,onClick:()=>{z(null),A(G)},disabled:Y!==null,"aria-label":`Edit ${G.displayName||G.model}`,className:"p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(Ce,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>h(G),disabled:Y!==null,"aria-label":`Delete ${G.displayName||G.model}`,className:"p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(me,{className:"h-3.5 w-3.5"})})]})]},G.id)})]})]},t)}),!E&&!l&&Object.keys(a).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No models configured yet"})]})}),e.jsx("button",{"data-add-model-trigger":!0,onClick:()=>{z(null),w(!0)},disabled:Y!==null,className:"w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0",children:"+ Add New Model"})]}),c==="general"&&e.jsxs("div",{id:"settings-panel-general",role:"tabpanel","aria-labelledby":"settings-tab-general","aria-busy":p.isLoading,className:"flex flex-col gap-6 overflow-x-hidden overflow-y-auto pr-2 [&>div>div.flex]:flex-wrap [&>div>div.flex]:gap-2 [&_select]:max-w-full",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"General"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Response Language"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"AI will respond in this language"})]}),e.jsxs("select",{"aria-label":"Response language",value:p.language,onChange:t=>p.updateSettings({language:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"en-US",children:"English (US)"}),e.jsx("option",{value:"zh-CN",children:"简体中文"}),e.jsx("option",{value:"zh-TW",children:"繁體中文"}),e.jsx("option",{value:"ja-JP",children:"日本語"}),e.jsx("option",{value:"ko-KR",children:"한국어"}),e.jsx("option",{value:"es-ES",children:"Español"}),e.jsx("option",{value:"fr-FR",children:"Français"}),e.jsx("option",{value:"de-DE",children:"Deutsch"}),e.jsx("option",{value:"pt-BR",children:"Português (BR)"}),e.jsx("option",{value:"ru-RU",children:"Русский"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Auto-save sessions"}),e.jsx(ne,{label:"Auto-save sessions",enabled:p.autoSaveSessions,onChange:t=>p.updateSettings({autoSaveSessions:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Appearance"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Theme Preference"}),e.jsx("div",{className:"flex items-center gap-2 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-1",children:["dark","light","system"].map(t=>e.jsx("button",{onClick:()=>p.updateSettings({uiTheme:t}),className:T("px-3 py-1 rounded text-[12px] font-mono transition-colors",p.uiTheme===t?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t==="dark"?"Dark":t==="light"?"Light":"System"},t))})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Compact sidebar"}),e.jsx(ne,{label:"Compact sidebar",enabled:!D,onChange:t=>U(!t)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Code theme"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"Syntax highlighting colors"})]}),e.jsxs("select",{"aria-label":"Code theme",value:p.theme,onChange:t=>p.updateSettings({theme:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"dracula",children:"Dracula"}),e.jsx("option",{value:"monokai",children:"Monokai"}),e.jsx("option",{value:"nord",children:"Nord"}),e.jsx("option",{value:"tokyo-night",children:"Tokyo Night"}),e.jsx("option",{value:"one-dark",children:"One Dark"}),e.jsx("option",{value:"catppuccin",children:"Catppuccin"}),e.jsx("option",{value:"gruvbox",children:"Gruvbox"}),e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"solarized-light",children:"Solarized Light"}),e.jsx("option",{value:"solarized-dark",children:"Solarized Dark"}),e.jsx("option",{value:"ayu-dark",children:"Ayu Dark"}),e.jsx("option",{value:"rose-pine",children:"Rose Pine"}),e.jsx("option",{value:"kanagawa",children:"Kanagawa"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Notifications"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Build finished"}),e.jsx(ne,{label:"Build finished notifications",enabled:p.notifyBuild,onChange:t=>p.updateSettings({notifyBuild:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Errors only"}),e.jsx(ne,{label:"Error notifications",enabled:p.notifyErrors,onChange:t=>p.updateSettings({notifyErrors:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"System sounds"}),e.jsx(ne,{label:"System sounds",enabled:p.notifySounds,onChange:t=>p.updateSettings({notifySounds:t})})]}),(p.notifyBuild||p.notifyErrors)&&oe!=="granted"&&e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] px-3 py-2 dark:border-[#27272a] dark:bg-[#18181b]",children:[e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:oe==="denied"?"Browser notifications are blocked":oe==="unsupported"?"Browser notifications are unavailable":"Enable alerts while this tab is in the background"}),oe==="default"&&e.jsx("button",{type:"button",onClick:()=>void Be(),className:"shrink-0 rounded-md bg-[#111827] px-2.5 py-1.5 text-[10px] font-mono text-white hover:bg-[#374151] dark:bg-[#E5E5E5] dark:text-[#111827]",children:"Enable"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Privacy"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Telemetry"}),e.jsx(ne,{label:"Telemetry",enabled:p.privacyTelemetry,onChange:t=>p.updateSettings({privacyTelemetry:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Crash reports"}),e.jsx(ne,{label:"Crash reports",enabled:p.privacyCrash,onChange:t=>p.updateSettings({privacyCrash:t})})]})]})]}),c==="shortcuts"&&e.jsxs("div",{id:"settings-panel-shortcuts",role:"tabpanel","aria-labelledby":"settings-tab-shortcuts",className:"flex flex-col gap-4 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:flex-row sm:items-center sm:gap-3",children:[e.jsx("input",{"aria-label":"Search shortcut actions",value:Q,onChange:t=>V(t.target.value),placeholder:"Search actions...",className:"flex-1 h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono"}),e.jsxs("select",{"aria-label":"Shortcut scope",value:n,onChange:t=>P(t.target.value),className:"h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:[e.jsx("option",{value:"all",children:"All scopes"}),e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"layout",children:"Layout"})]}),e.jsx("button",{onClick:()=>{V(""),P("all")},className:"h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:"Reset"})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.jsxs("div",{className:"grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold",children:[e.jsx("span",{children:"Action"}),e.jsx("span",{children:"Shortcut"}),e.jsx("span",{children:"Scope"})]}),ie.map((t,u)=>e.jsxs("div",{className:T("grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",u%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:t.action}),e.jsx("div",{className:"flex items-center gap-1",children:t.combo.map(b=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:b},b))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:t.scope})]},`${t.action}-${t.scope}`)),ie.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:"No shortcuts found."})]})]}),c==="mcp"&&e.jsxs("div",{id:"settings-panel-mcp",role:"tabpanel","aria-labelledby":"settings-tab-mcp",className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("p",{children:"MCP server configuration is available via the MCP panel."}),e.jsx("button",{type:"button",onClick:()=>{g(),pe.getState().toggleMcp()},className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-[#E5E7EB] px-3 text-[12px] font-medium text-[#111827] transition-colors hover:bg-[#F3F4F6] dark:border-zinc-700 dark:text-[#E5E5E5] dark:hover:bg-[#27272a]",children:"Open MCP Panel"})]}),c==="skills"&&e.jsxs("div",{id:"settings-panel-skills",role:"tabpanel","aria-labelledby":"settings-tab-skills",className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("p",{children:"Skills configuration is available via the Skills panel."}),e.jsx("button",{type:"button",onClick:()=>{g(),pe.getState().toggleSkills()},className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-[#E5E7EB] px-3 text-[12px] font-medium text-[#111827] transition-colors hover:bg-[#F3F4F6] dark:border-zinc-700 dark:text-[#E5E5E5] dark:hover:bg-[#27272a]",children:"Open Skills Panel"})]}),c==="hooks"&&e.jsx("div",{id:"settings-panel-hooks",role:"tabpanel","aria-labelledby":"settings-tab-hooks",className:"min-h-0 flex-1",children:e.jsx(st,{})}),c==="plugins"&&e.jsx("div",{id:"settings-panel-plugins",role:"tabpanel","aria-labelledby":"settings-tab-plugins",className:"min-h-0 flex-1",children:e.jsx(nt,{})}),c==="trust"&&e.jsx("div",{id:"settings-panel-trust",role:"tabpanel","aria-labelledby":"settings-tab-trust",className:"min-h-0 flex-1",children:e.jsx(ot,{})})]})})})]}),B&&e.jsx(Ze,{open:!0,onOpenChange:t=>{t||(le.current=Date.now()),w(t)},onSave:Pe,saveError:L}),r&&e.jsx(et,{open:!0,onOpenChange:t=>{t||(le.current=Date.now(),A(null))},model:r,onSave:Re,saveError:L}),N&&e.jsx(tt,{provider:N,onOpenChange:t=>{t||(le.current=Date.now(),y(null))},onSave:Te,saveError:Z})]})}function ne({label:o,enabled:x,onChange:g}){return e.jsx("button",{type:"button",role:"switch","aria-label":o,"aria-checked":x,onClick:()=>g(!x),className:T("flex h-6 w-11 items-center rounded-full px-1 transition-colors",x?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:T("h-4 w-4 rounded-full transition-transform",x?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{pt as SettingsModal};
|