blade-code 0.10.6 → 0.10.8
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-1w6azndv.js +1 -0
- package/dist/chunk-2gwaqpge.js +1 -0
- package/dist/chunk-2pjd4cys.js +1 -0
- package/dist/{chunk-xsmtpkjm.js → chunk-2thg3fq1.js} +1 -1
- package/dist/chunk-2zn5en0w.js +1 -0
- package/dist/{chunk-vvbd9fb5.js → chunk-33ave20b.js} +1 -1
- package/dist/chunk-3w1z6fwm.js +1 -0
- package/dist/chunk-43x4qbvt.js +1 -0
- package/dist/{chunk-kcwq1e7h.js → chunk-4h9ff923.js} +1 -1
- package/dist/chunk-52csdk21.js +3 -0
- package/dist/{chunk-frcg8gea.js → chunk-66hb7kxm.js} +2 -2
- package/dist/chunk-6j8wgp2s.js +2 -0
- package/dist/chunk-6vsszvgg.js +2 -0
- package/dist/chunk-7evtr0yr.js +10 -0
- package/dist/{chunk-yt39kfc6.js → chunk-7hbw6q6d.js} +1 -1
- package/dist/chunk-7zsyejr1.js +22 -0
- package/dist/{chunk-r083b7vn.js → chunk-8gcg2z3y.js} +16 -16
- package/dist/{chunk-rag8zchg.js → chunk-8gcvpmwk.js} +1 -1
- package/dist/{chunk-6cv4gddv.js → chunk-8gnfj89a.js} +2 -2
- package/dist/{chunk-76d7p64v.js → chunk-8h0yxh6y.js} +2 -2
- package/dist/chunk-8sfycn3y.js +194 -0
- package/dist/{chunk-c2rhwxyn.js → chunk-954vmnrn.js} +1 -1
- package/dist/chunk-a8h3fymk.js +100 -0
- package/dist/chunk-b5szbtmp.js +5 -0
- package/dist/chunk-bxm2hq0m.js +1 -0
- package/dist/chunk-c8da4b3d.js +1 -0
- package/dist/{chunk-p4j4aawd.js → chunk-cbpqcdga.js} +1 -1
- package/dist/{chunk-m4htdpr9.js → chunk-cf8e7e92.js} +72 -17
- package/dist/chunk-d0g4t8fw.js +8 -0
- package/dist/{chunk-b4n34hrn.js → chunk-eq2qj9ja.js} +1 -1
- package/dist/{chunk-7xm3vjkz.js → chunk-fj8v7pep.js} +1 -1
- package/dist/{chunk-bn0ge244.js → chunk-fxpq9nh6.js} +1 -1
- package/dist/chunk-g00wj2we.js +4 -0
- package/dist/{chunk-bnrce0hg.js → chunk-h28ptrrt.js} +1 -1
- package/dist/{chunk-gb4n3hwj.js → chunk-h421wzbm.js} +2 -2
- package/dist/{chunk-dcvvxsa1.js → chunk-j4tttsaz.js} +2 -2
- package/dist/{chunk-k0p9ecgc.js → chunk-kagpk2x5.js} +6 -6
- package/dist/chunk-kvnwhwx3.js +1 -0
- package/dist/{chunk-p196e4rq.js → chunk-m2xrx1je.js} +1 -1
- package/dist/chunk-nhc49pan.js +160 -0
- package/dist/{chunk-sf9pe2n6.js → chunk-nymm525r.js} +1 -1
- package/dist/{chunk-9sfmrb1j.js → chunk-nz57y1ad.js} +3 -3
- package/dist/{chunk-45dcfkwe.js → chunk-p2m56new.js} +2 -2
- package/dist/{chunk-w154jyby.js → chunk-pv9sw79c.js} +1 -1
- package/dist/chunk-qgp08qmz.js +6 -0
- package/dist/{chunk-evaht3v4.js → chunk-r7tsa2zv.js} +1 -1
- package/dist/{chunk-rw6gv740.js → chunk-rkvfsx8e.js} +1 -1
- package/dist/{chunk-v1p80wvh.js → chunk-rxqft6td.js} +2 -2
- package/dist/{chunk-g9n211y4.js → chunk-s9aj3p11.js} +2 -2
- package/dist/chunk-senkwdh6.js +2 -0
- package/dist/chunk-v1c58sm6.js +1 -0
- package/dist/{chunk-n9khyme2.js → chunk-v8pq6qmv.js} +2 -2
- package/dist/{chunk-1cvr3qtd.js → chunk-van4ysq6.js} +289 -305
- package/dist/chunk-vgp8m9fg.js +2 -0
- package/dist/{chunk-4y28hykg.js → chunk-vsg8f0e6.js} +1 -1
- package/dist/{chunk-kcs3xa8f.js → chunk-w0nscjd2.js} +2 -2
- package/dist/chunk-w26jhcj9.js +1 -0
- package/dist/{chunk-hjsm6ejs.js → chunk-wmnszjmv.js} +2 -2
- package/dist/chunk-x6wgh726.js +1 -0
- package/dist/{chunk-thvwt4kc.js → chunk-xa05phpw.js} +3 -3
- package/dist/{chunk-g4q26d9a.js → chunk-xmcsn7y0.js} +2 -2
- package/dist/{chunk-c9tzf9r5.js → chunk-y4c3wwpa.js} +1 -1
- package/dist/{chunk-0rp2ck29.js → chunk-yfs9tq3y.js} +2 -2
- package/dist/chunk-ymzcxryf.js +1 -0
- package/dist/{chunk-xkp4ph6v.js → chunk-zknv3d6y.js} +1 -1
- package/dist/chunk-zp4x2mwj.js +1 -0
- package/dist/chunk-zvk3g177.js +9 -0
- package/dist/web/assets/ChatView-Fqy97qw9.js +7 -0
- package/dist/web/assets/{CodeBlockHighlighter-CFW6qjnA.js → CodeBlockHighlighter-EgdsVoMQ.js} +1 -1
- package/dist/web/assets/{FilePreview-CR_XetY0.js → FilePreview-xicd9-Sl.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-CVrxJswQ.js → MarkdownRenderer-DBSjC_z3.js} +18 -18
- package/dist/web/assets/SettingsModal-Bkh5rMAJ.js +5 -0
- package/dist/web/assets/TaskSwitcher-DXcj0iJ_.js +1 -0
- package/dist/web/assets/{TerminalPanel-DTqvx8yB.js → TerminalPanel-DWVY-Elm.js} +1 -1
- package/dist/web/assets/index-Bi5ijAQP.css +1 -0
- package/dist/web/assets/index-CxEh32hc.js +32 -0
- package/dist/web/assets/{vendor-icons-D_AkWmWB.js → vendor-icons-Cv18Q6rW.js} +72 -67
- package/dist/web/assets/{vendor-radix-DBy9B2DN.js → vendor-radix-DXRuAJHH.js} +1 -1
- package/dist/web/index.html +4 -4
- package/package.json +3 -1
- package/dist/chunk-10k6egwk.js +0 -1
- package/dist/chunk-17xtw88g.js +0 -1
- package/dist/chunk-1kg9r8xp.js +0 -2
- package/dist/chunk-383vbwmt.js +0 -4
- package/dist/chunk-3kk3bk11.js +0 -1
- package/dist/chunk-47dsd91k.js +0 -99
- package/dist/chunk-4kaygjqv.js +0 -10
- package/dist/chunk-50fq7r0h.js +0 -22
- package/dist/chunk-59eje513.js +0 -1
- package/dist/chunk-710bvht9.js +0 -160
- package/dist/chunk-a9pbpgkg.js +0 -9
- package/dist/chunk-c8rky275.js +0 -6
- package/dist/chunk-j1sd03h7.js +0 -1
- package/dist/chunk-jqyvnmfr.js +0 -187
- package/dist/chunk-jrh5tzc4.js +0 -1
- package/dist/chunk-kj1ah6kn.js +0 -1
- package/dist/chunk-n34z4c47.js +0 -1
- package/dist/chunk-n5m2p0bq.js +0 -2
- package/dist/chunk-nfmsn652.js +0 -2
- package/dist/chunk-qvabd0vg.js +0 -1
- package/dist/chunk-t75wspk3.js +0 -1
- package/dist/chunk-vddqv6fv.js +0 -1
- package/dist/chunk-w4zvftrw.js +0 -5
- package/dist/chunk-wa7v7akz.js +0 -3
- package/dist/chunk-wxwqz67n.js +0 -1
- package/dist/chunk-x9hm3p3a.js +0 -1
- package/dist/chunk-xd2g4zjx.js +0 -1
- package/dist/web/assets/ChatView-Y-6k-ayR.js +0 -7
- package/dist/web/assets/McpModal-BO-85gll.js +0 -5
- package/dist/web/assets/SettingsModal-CW87OnxI.js +0 -1
- package/dist/web/assets/SkillsModal-Q8ZFPhys.js +0 -1
- package/dist/web/assets/TaskSwitcher-BzH-0QXr.js +0 -1
- package/dist/web/assets/index-B7etZcne.css +0 -1
- package/dist/web/assets/index-ClOgGy-I.js +0 -32
- package/dist/web/assets/useRequest-BvqVDnKl.js +0 -1
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-CVrxJswQ.js","assets/index-ClOgGy-I.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-radix-DBy9B2DN.js","assets/vendor-icons-D_AkWmWB.js","assets/index-B7etZcne.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as h,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as D,a as N,b as re,s as ke,c as Be,d as G,D as je,e as ye,f as $e,g as we,h as Ne,i as Ce,j as A,k as O,l as Pe,B as se,m as _e,n as Ve,o as Le,_ as Oe,S as He,p as Ue,t as Ke,q as qe,C as Ge,r as ze}from"./index-ClOgGy-I.js";import{O as me,N as We,G as Qe,V as Je,L as F,z as Xe,T as J,C as ae,Y as Ye,v as Ze,Z as et,_ as tt,y as X,m as ne,R as ie,s as st,H as rt,$ as Se,Q as at,a0 as nt,a1 as it,a2 as ot,P as Ee,a3 as lt,X as ct,a4 as dt,a5 as ut,f as Te,a6 as mt,W as xt,a as ht}from"./vendor-icons-D_AkWmWB.js";import{j as pt,k as ft,l as bt,m as Ae}from"./vendor-radix-DBy9B2DN.js";function xe(t){return t.split("/").filter(Boolean).at(-1)||t}function gt(){const t=D(),s=N(S=>S.sessions),r=N(S=>S.currentSessionRef),a=N(S=>S.taskDeliveryActions),d=N(S=>S.deliverTask),n=re(S=>S.openFilePreview),[u,c]=h.useState(!1),l=s.find(S=>ke({sessionId:S.sessionId,projectPath:S.projectPath},r));if(!(l!=null&&l.taskIsolation))return null;const i=l.taskDiffStat,k=l.taskIsolation==="worktree",o=Be(l),x=a[G(o)],f=l.taskDelivery,w=(f==null?void 0:f.status)==="conflicted",p=!!(i&&(i.changedFiles>0||i.commits>0)),j=!["queued","running"].includes(l.taskStatus),y=(f==null?void 0:f.status)==="applied"||(f==null?void 0:f.status)==="discarded",b=k&&p&&j&&!y,m=i?i.additions+i.deletions:0,g=m>0&&i?i.additions/m*100:0,C=S=>{d(o,S).catch(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(me,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:xe(l.taskSourceProjectPath||l.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k?e.jsx(We,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(me,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:k?"text-[hsl(var(--deck-accent))]":void 0,children:t(k?"artifact.env.isolated":"artifact.env.local")})]}),l.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:l.taskWorktreeBranch,children:[e.jsx(Qe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:l.taskWorktreeBranch})]})]})]}),i&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Je,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:i.changedFiles})]}),m>0&&e.jsxs("span",{className:"relative hidden h-1.5 w-14 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:inline-flex","aria-hidden":"true",children:[e.jsx("span",{className:"h-full bg-[hsl(var(--deck-accent))]",style:{width:`${g}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-g}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",i.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",i.deletions]}),i.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:i.commits})}),p&&(f==null?void 0:f.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({tab:"diff"}),className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),b&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!x,onClick:()=>C("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[x==="apply"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Xe,{className:"h-3 w-3"}),t(x==="apply"?"artifact.applying":w?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!x,onClick:()=>c(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[hsl(var(--deck-ink-faint))] transition hover:bg-red-500/10 hover:text-red-600 disabled:cursor-wait disabled:opacity-50 dark:hover:text-red-400","aria-label":t("artifact.discard"),title:t("artifact.discard"),children:x==="discard"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(J,{className:"h-3 w-3"})})]}),(f==null?void 0:f.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(ae,{className:"h-3 w-3"}),t("artifact.applied")]}),(f==null?void 0:f.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(J,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(f==null?void 0:f.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(Ye,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:f.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(je,{open:u,onOpenChange:c,children:e.jsxs(ye,{className:"w-[calc(100%_-_2rem)] max-w-md border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]",children:[e.jsxs($e,{children:[e.jsx(we,{children:t("artifact.discardDialog.title")}),e.jsx(Ne,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:xe(l.taskSourceProjectPath||l.projectPath),count:(i==null?void 0:i.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(Ce,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>c(!1),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-2 text-sm hover:bg-[hsl(var(--deck-surface-2))]",children:t("artifact.discardDialog.cancel")}),e.jsxs("button",{type:"button",onClick:()=>{c(!1),C("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(J,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}function vt({elicitation:t,messageId:s}){const r=D(),a=N(b=>b.currentSessionRef),d=N(b=>b.setElicitation),[n,u]=h.useState(()=>jt(t.details.fields??[])),[c,l]=h.useState(()=>yt(t.details.fields??[])),[i,k]=h.useState(!1),[o,x]=h.useState(),f=t.details.fields??[],w=h.useMemo(()=>f.every(b=>{var g;if(!b.required)return!0;if(Y(b))return!!((g=c[b.name])!=null&&g.trim()||b.defaultValue!==void 0);const m=n[b.name]??b.defaultValue;return Array.isArray(m)?m.length>0:m!==void 0}),[f,c,n]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const p=async(b,m)=>{if(!(!a||i)){k(!0),x(void 0);try{await O.respondToElicitation(a,t.toolCallId,{action:b,...m?{content:m}:{}}),d(s,{...t,status:"responded"})}catch(g){x(g instanceof Error?g.message:r("interaction.elicitation.failed"))}finally{k(!1)}}},j=async()=>{try{await p("accept",wt(f,n,c))}catch(b){x(b instanceof Error?b.message:String(b))}},y=()=>{const b=t.details.url;if(!b){x("MCP URL is unavailable");return}if(!window.open(b,"_blank","noopener,noreferrer")){x("The browser blocked the external window");return}p("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[r("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:r("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(U,{onClick:y,disabled:i,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(et,{className:"h-3.5 w-3.5"})}),e.jsx(U,{onClick:()=>void p("decline"),disabled:i,label:r("interaction.elicitation.decline")}),e.jsx(U,{onClick:()=>void p("cancel"),disabled:i,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[f.map(b=>e.jsx(kt,{field:b,value:n[b.name],rawValue:c[b.name]??"",onValueChange:m=>u(g=>({...g,[b.name]:m})),onRawChange:m=>l(g=>({...g,[b.name]:m}))},b.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(U,{onClick:()=>void j(),disabled:i||!w,primary:!0,label:r("interaction.elicitation.submit"),icon:i?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(U,{onClick:()=>void p("decline"),disabled:i,label:r("interaction.elicitation.decline")}),e.jsx(U,{onClick:()=>void p("cancel"),disabled:i,label:r("interaction.elicitation.cancel")})]})]}),o&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:o})]})}function kt({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:d}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:Nt(t).map(n=>{const u=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":u,onClick:()=>{if(t.type==="multi-select"){const c=Array.isArray(s)?s:[];a(c.includes(n.value)?c.filter(l=>l!==n.value):[...c,n.value])}else a(n.typedValue)},className:A("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",u?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Ct(t),value:r,onChange:n=>d(n.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function U({onClick:t,disabled:s,primary:r=!1,label:a,icon:d}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:A("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",r?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[d,a]})}function jt(t){return Object.fromEntries(t.filter(s=>!Y(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function yt(t){return Object.fromEntries(t.filter(s=>Y(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function wt(t,s,r){var d;const a={};for(const n of t){if(Y(n)){const c=((d=r[n.name])==null?void 0:d.trim())??"";if(!c){if(n.defaultValue!==void 0)a[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const l=Number(c);if(!Number.isFinite(l))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(l))throw new Error(`${n.title} must be a safe integer`);a[n.name]=l}else a[n.name]=c;continue}const u=s[n.name]??n.defaultValue;if(u===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(u)){if(n.minItems!==void 0&&u.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&u.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=u}return a}function Nt(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(s=>({...s,typedValue:s.value}))}function Y(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Ct(t){return t.type==="number"||t.type==="integer"?"number":t.format==="email"?"email":t.format==="uri"?"url":t.format==="date"?"date":t.format==="date-time"?"datetime-local":"text"}const St=h.lazy(()=>Oe(()=>import("./MarkdownRenderer-CVrxJswQ.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function he({text:t,label:s}){const[r,a]=h.useState(!1);if(!t.trim())return null;const d=async()=>{try{await navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:d,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(ae,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(tt,{className:"h-3.5 w-3.5"})})}function Et(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_1px_0_hsl(var(--deck-hairline))]",children:e.jsx(se,{size:20,pulse:!1})})}function Tt(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas-veil))]",children:e.jsx("span",{className:"font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:"U"})})}function pe(t){let s=t;return s=s.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),s=s.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),s=s.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),s=s.trim(),s}function At(t){if(typeof t=="string")return{text:pe(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
3
|
-
`),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:pe(s),images:r}}function oe(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
4
|
-
`)}function Ft(t){const s=t.agentContent;return s?Pe(s):oe(t.content)}function fe({content:t,syntaxHighlight:s=!0}){return e.jsx(h.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(St,{content:t,syntaxHighlight:s})})}function le({status:t}){if(!t)return null;const s={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},r={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:A("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function Mt(t){if(!t)return"";if(typeof t=="string")try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}return JSON.stringify(t,null,2)}function Rt({tool:t}){const[s,r]=h.useState(!1),a=Mt(t.arguments);return e.jsxs("div",{className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":s,"data-tool-call-id":t.toolCallId,onClick:()=>r(d=>!d),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[s?e.jsx(X,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(ne,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}),e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink))] font-mono shrink-0",children:t.toolName}),t.summary&&e.jsx("span",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono truncate",children:t.summary})]}),e.jsx(le,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),s&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[a&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:a})]}),t.output&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Output"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.output.length>500?t.output.slice(0,500)+"...":t.output})]})]})]})}function Fe({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(Rt,{tool:s},s.toolCallId))})}function Dt({toolCalls:t,toolCallIds:s}){const r=D(),[a,d]=h.useState(!1),n=h.useMemo(()=>new Map(t.map(o=>[o.toolCallId,o])),[t]),u=s.flatMap(o=>{const x=n.get(o);return x?[x]:[]});if(u.length===0)return null;const c=u.filter(o=>o.status==="running").length,l=u.filter(o=>o.status==="error").length,i=[...u].reverse().find(o=>o.status==="running"&&!!o.progressMessage),k=c>0?r(u.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:u.length}):l>0?r(u.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:u.length,errors:l}):r(u.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:u.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>d(o=>!o),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[a?e.jsx(X,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0"}),c>0&&e.jsx(F,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:k}),(i==null?void 0:i.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[i.progressMessage,i.progress!==void 0&&i.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(i.progress/i.progressTotal*100)))}%`]})]}),(i==null?void 0:i.progress)!==void 0&&i.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${i.toolName} progress`,"aria-valuemin":0,"aria-valuemax":i.progressTotal,"aria-valuenow":Math.min(i.progress,i.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,i.progress/i.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(Fe,{toolCalls:u})})]})}function It({content:t}){const s=D(),[r,a]=h.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(d=>!d),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(X,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(ne,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),r&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function Bt({tasks:t}){if(t.length===0)return null;const s=t.filter(a=>a.status==="completed").length,r=s===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function $t({toolCalls:t}){const s=re(a=>a.openFilePreview),r=h.useMemo(()=>{const a=new Map,d=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const u=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(u==null?void 0:u.changes)){for(const l of u.changes)l&&typeof l=="object"&&"path"in l&&typeof l.path=="string"&&a.set(l.path,{path:l.path,toolName:n.toolName});continue}const c=u==null?void 0:u.file_path;c&&d.includes(n.toolName)&&a.set(c,{path:c,toolName:n.toolName})}return Array.from(a.values())},[t]);return r.length===0?null:e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(({path:a})=>{const d=a.split("/").pop()||a;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:a}),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:a,children:[e.jsx(st,{className:"w-3 h-3"}),d]},a)})})]})}function Pt({subagent:t}){var H,z;const[s,r]=h.useState(null),[a,d]=h.useState(!1),[n,u]=h.useState(null),[c,l]=h.useState(!1),[i,k]=h.useState(""),[o,x]=h.useState(!1),[f,w]=h.useState(null),[p,j]=h.useState(null),y=N(T=>T.currentSessionRef),b=N(T=>T.isStreaming),m=N(T=>T.isTemporarySession);if(!t)return null;const g=t.status==="running",C=s!==null?s:g,S=t.toolCalls||n||[],R=t.output||t.thinking||S.length>0||t.sessionId,_=p&&p.status!=="running"?p.id:t.sessionId,E=!g&&!b&&!m&&(p==null?void 0:p.status)!=="running"&&!!(_&&y);h.useEffect(()=>{if(!C||g||!t.sessionId||!(y!=null&&y.projectPath)||n!==null||t.toolCalls&&t.toolCalls.length>0)return;let T=!0;return d(!0),O.getMessages({sessionId:t.sessionId,projectPath:y.projectPath}).then(P=>{var I,M;if(!T)return;const V=Le(P),B=new Map;for(const L of V)if((M=(I=L.agentContent)==null?void 0:I.toolCalls)!=null&&M.length)for(const K of L.agentContent.toolCalls)B.has(K.toolCallId)||B.set(K.toolCallId,K);u(Array.from(B.values()))}).finally(()=>{T&&d(!1)}),()=>{T=!1}},[C,g,t.sessionId,t.toolCalls,n,y==null?void 0:y.projectPath]),h.useEffect(()=>{if(!t.sessionId||!y)return;let T=!0;const P=t.rootAgentId??t.sessionId,V=t.resumeDepth??0;return O.listSubagents(y).then(B=>{if(!T)return;const I=B.filter(M=>M.id!==t.sessionId&&M.rootAgentId===P&&M.resumeDepth>V).sort((M,L)=>L.resumeDepth-M.resumeDepth||L.lastActiveAt-M.lastActiveAt)[0];I&&j(I)}).catch(()=>{}),()=>{T=!1}},[y==null?void 0:y.sessionId,y==null?void 0:y.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),h.useEffect(()=>{if(!p||p.status!=="running"||!y)return;let T=!0;const P=async()=>{try{const I=(await O.listSubagents(y)).find(M=>M.id===p.id);T&&I&&j(I)}catch{}},V=window.setInterval(()=>{P()},1e3);return()=>{T=!1,window.clearInterval(V)}},[y,p==null?void 0:p.id,p==null?void 0:p.status]);const $=async()=>{if(!(!y||!_||!i.trim()||o)){x(!0),w(null);try{const T=await O.resumeSubagent(y,_,i.trim());j(T.session),k(""),l(!1),r(!0)}catch(T){w(T instanceof Error?T.message:"Failed to resume subagent")}finally{x(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>r(!C),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[g&&e.jsx(F,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(le,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:A("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsxs("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:`Resumed from ${t.resumedFrom}`,children:["resumed · depth ",t.resumeDepth??1]})]}),R&&e.jsx(X,{className:A("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",C&&"rotate-180")})]}),C&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),a&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(F,{className:"w-3 h-3 animate-spin"}),"Loading subagent logs..."]}),!a&&S.length>0&&e.jsx(Fe,{toolCalls:S}),p&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsxs("div",{children:["Resumed as ",p.id," · ",p.status," · depth"," ",p.resumeDepth]}),(((H=p.result)==null?void 0:H.message)||((z=p.result)==null?void 0:z.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:p.result.message||p.result.error})]}),E&&e.jsxs("div",{className:"space-y-2",children:[c?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":"Subagent follow-up",value:i,onChange:T=>k(T.target.value),placeholder:"Describe the follow-up work",rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{l(!1),w(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>void $(),disabled:!i.trim()||o,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[o&&e.jsx(F,{className:"w-3 h-3 animate-spin"}),"Resume agent"]})]})]}):e.jsxs("button",{type:"button","aria-label":"Resume subagent",onClick:()=>l(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(ie,{className:"w-3 h-3"}),"Resume"]}),f&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:f})]})]})]})}function _t({confirmation:t,messageId:s}){const r=D(),[a,d]=h.useState(!1),[n,u]=h.useState(null),c=N(k=>k.currentSessionRef),l=N(k=>k.setConfirmation);if(!t)return null;const i=async(k,o)=>{if(!(!c||a)){d(!0),u(null);try{await O.respondPermission(c,t.toolCallId,{approved:k,scope:o}),l(s,{...t,status:k?"approved":"denied"})}catch(x){u(x instanceof Error?x.message:r("interaction.permission.failed"))}finally{d(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:r("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),n&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:n}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void i(!0,"once"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:a?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):r("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void i(!0,"session"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void i(!0,"project"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void i(!1),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.deny")})]})]})}function Vt({question:t,messageId:s}){const r=D(),[a,d]=h.useState({}),[n,u]=h.useState({}),[c,l]=h.useState(!1),[i,k]=h.useState(null),o=N(j=>j.currentSessionRef),x=N(j=>j.setQuestion),f=h.useMemo(()=>t?t.questions.reduce((j,y)=>{var C;const b=(C=n[y.header])==null?void 0:C.trim(),m=a[y.header];if(y.multiSelect){const S=Array.isArray(m)?[...m]:[];return b&&S.push(b),S.length>0&&(j[y.header]=S),j}const g=b||(typeof m=="string"?m:"");return g&&(j[y.header]=g),j},{}):{},[a,n,t]),w=(t==null?void 0:t.questions.every(j=>j.header in f))??!1;if(!t)return null;const p=async()=>{if(!(!o||c||!w)){l(!0),k(null);try{await O.respondToQuestion(o,t.toolCallId,f),x(s,{...t,status:"answered",answers:f})}catch(j){k(j instanceof Error?j.message:r("interaction.question.failed"))}finally{l(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((j,y)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:j.question}),e.jsxs("div",{className:"space-y-1",children:[j.options.map((b,m)=>e.jsxs("button",{type:"button",onClick:()=>{if(j.multiSelect){const g=a[j.header]||[],C=g.includes(b.label)?g.filter(S=>S!==b.label):[...g,b.label];d({...a,[j.header]:C})}else d({...a,[j.header]:b.label}),u({...n,[j.header]:""})},className:A("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(j.multiSelect?(a[j.header]||[]).includes(b.label):a[j.header]===b.label)?"bg-[#DCFCE7] text-[#166534] dark:bg-[#22C55E]/20 dark:text-[#E5E5E5]":"bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))]"),children:[e.jsx("div",{children:b.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:b.description})]},m)),e.jsx("input",{"aria-label":`${j.header} other response`,value:n[j.header]??"",onChange:b=>u({...n,[j.header]:b.target.value}),placeholder:r("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},y)),i&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:i}),e.jsxs("button",{type:"button",onClick:()=>void p(),disabled:c||!w,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[c&&e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function Lt({message:t}){const s=t.agentContent,r=N(w=>w.isStreaming&&w.currentAssistantMessageId===t.id);if(!s){const w=oe(t.content);return w?e.jsx(fe,{content:w}):null}const{toolCalls:a,tasks:d,confirmation:n,question:u,elicitation:c}=s,l=_e(s),i=Ve(s);if(!(i.length>0||d.length>0||l.length>0||n||u||c)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const x=a.length>0&&a.every(w=>w.status==="success"||w.status==="error")&&!r,f=!r;return e.jsxs("div",{className:"space-y-3",children:[i.map(w=>w.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(It,{content:w.content})},w.id):w.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(fe,{content:w.content,syntaxHighlight:f})},w.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(Dt,{toolCalls:a,toolCallIds:w.toolCallIds})},w.id)),d.length>0&&e.jsx(Bt,{tasks:d}),l.map(w=>e.jsx(Pt,{subagent:w},w.id)),n&&e.jsx(_t,{confirmation:n,messageId:t.id}),u&&e.jsx(Vt,{question:u,messageId:t.id}),c&&e.jsx(vt,{elicitation:c,messageId:t.id}),x&&e.jsx($t,{toolCalls:a})]})}function Ot({message:t,showAvatar:s=!0}){var n,u;const r=t.role==="user";if(t.role==="system"){const c=oe(t.content);return e.jsx("div",{"data-chat-message-id":t.id,className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:c})})}if(r){const c=(n=t.metadata)!=null&&n.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(u=t.metadata)!=null&&u.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(c){const k=typeof c.command=="string"?c.command:"",o=c.status==="running"?"running":c.status==="completed"?"success":"error",x=typeof c.output=="string"?c.output:[typeof c.stdout=="string"?c.stdout:"",typeof c.stderr=="string"&&c.stderr?`stderr:
|
|
5
|
-
${c.stderr}`:""].filter(Boolean).join(`
|
|
6
|
-
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-user-shell-command":!0,className:"flex w-full justify-end p-4",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),k]}),e.jsx(le,{status:o})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:x||"(no output)"}),typeof c.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",c.exitCode,typeof c.durationMs=="number"?` · ${(c.durationMs/1e3).toFixed(3)}s`:"",c.truncated===!0?" · truncated":""]})]})})}const{text:l,images:i}=At(t.content);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"user",className:"group flex gap-2 justify-end p-4 w-full items-start",children:[e.jsx("div",{className:"mt-1 flex shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(he,{text:l,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[l&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:l}),i.length>0&&e.jsx("div",{className:A("grid gap-2",i.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:i.map((k,o)=>e.jsx("img",{src:k,alt:`attachment-${o+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${k}-${o}`))})]}),e.jsx(Tt,{})]})}const d=Ft(t);return e.jsxs("div",{"data-chat-message-id":t.id,className:A("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(Et,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[e.jsx(Lt,{message:t}),d.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(he,{text:d,label:"Copy response"})})]})]})}const Ht=h.memo(Ot);function Ut(t,s,r){return Math.max(0,t+(r-s))}function Kt(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function be(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function qt({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const d=D(),[n,u]=h.useState(null),[c,l]=h.useState(!1),i=h.useRef(null),k=h.useCallback(()=>{var j;const x=s.current,f=r.current;if(!x||!f||t.length===0)return;const w=x.getBoundingClientRect().top;let p=((j=t[0])==null?void 0:j.id)??null;for(const y of t){const b=be(f,y.id);if(b)if(b.getBoundingClientRect().top-w<=24)p=y.id;else break}u(p)},[t,s,r]);h.useEffect(()=>{const x=s.current;if(!x)return;const f=()=>{i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,k()}))};return k(),x.addEventListener("scroll",f,{passive:!0}),()=>{x.removeEventListener("scroll",f),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null)}},[k,s]);const o=h.useCallback(x=>{const f=()=>{const p=be(r.current,x.id);p&&(p.scrollIntoView({behavior:"smooth",block:"start"}),u(x.id))};a(x.index)?f():window.requestAnimationFrame(()=>window.requestAnimationFrame(f))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":d("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocusCapture:()=>l(!0),onBlurCapture:x=>{x.currentTarget.contains(x.relatedTarget)||l(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:A("flex flex-col items-center gap-2 py-2 transition-opacity",c?"opacity-0":"opacity-100"),"aria-hidden":c,children:t.map(x=>e.jsx("li",{children:e.jsx("span",{className:A("block rounded-full transition-all",x.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},x.id))}),e.jsx("div",{className:A("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",c?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((x,f)=>e.jsxs("button",{type:"button",onClick:()=>o(x),className:A("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",x.id===n?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:A("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",x.id===n?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:d("chat.turns.label",{n:f+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:x.preview})]})]},x.id))})]})})}const ge=80;function Gt(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function zt(t){const s=Gt(t).replace(/\s+/g," ").trim();return s?s.length>ge?`${s.slice(0,ge-1)}…`:s:""}function Wt(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const d=zt(a.content);d&&s.push({id:a.id,index:r,preview:d})}return s}const ee=120,te=80,Qt=96;function q(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Jt({messages:t,isLoading:s}){const r=D(),a=h.useRef(null),d=h.useRef(null),n=h.useRef(!0),u=h.useRef(t.length),c=h.useRef(null),[l,i]=h.useState(ee),[k,o]=h.useState(!1);h.useEffect(()=>{const m=q(a.current);if(!m||!n.current)return;const g=window.requestAnimationFrame(()=>{m.scrollTop=m.scrollHeight});return()=>window.cancelAnimationFrame(g)},[t]),h.useEffect(()=>{const m=q(a.current);if(!m)return;d.current=m;const g=()=>{const S=m.scrollHeight-m.scrollTop-m.clientHeight<=Qt;n.current=S,o(!S)};return g(),m.addEventListener("scroll",g,{passive:!0}),()=>m.removeEventListener("scroll",g)},[]),h.useEffect(()=>{const m=u.current;u.current=t.length,i(g=>g>=m&&t.length>m?t.length:Math.min(Math.max(g,ee),t.length||ee))},[t.length]);const x=Math.max(t.length-l,0),f=x,w=h.useMemo(()=>t.slice(f),[t,f]),p=h.useMemo(()=>Wt(t),[t]);if(h.useLayoutEffect(()=>{var C;const m=c.current;if(!m)return;const g=q(a.current);if(c.current=null,!!g){if((C=m.element)!=null&&C.isConnected){const S=m.element.getBoundingClientRect().top-m.viewportTop;g.scrollTop+=S;return}g.scrollTop=Ut(m.scrollTop,m.scrollHeight,g.scrollHeight)}},[l]),s)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(se,{size:42,className:"relative"})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--deck-accent))]",children:[e.jsx(rt,{className:"w-3 h-3"}),r("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:r("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((m,g)=>e.jsxs("div",{className:A("flex gap-3",g%2===1&&"flex-row-reverse"),children:[e.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-md bg-[hsl(var(--deck-surface-2))]"}),e.jsx("span",{className:"h-10 animate-pulse rounded-lg bg-[hsl(var(--deck-surface-2))]",style:{width:`${m}%`,animationDelay:`${g*120}ms`}})]},m))})]})});if(t.length===0&&!s)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(se,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:r("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r("chat.list.empty.hint")})]})]})});const j=()=>{const m=q(a.current);m&&(n.current=!0,o(!1),m.scrollTo({top:m.scrollHeight,behavior:"smooth"}))},y=()=>{var g;const m=q(a.current);if(m){const C=((g=a.current)==null?void 0:g.querySelector("[data-chat-message-id]"))??null;c.current={element:C,viewportTop:(C==null?void 0:C.getBoundingClientRect().top)??0,scrollHeight:m.scrollHeight,scrollTop:m.scrollTop}}i(C=>Kt(C,t.length,te))},b=m=>m>=f?!0:(i(t.length),!1);return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(He,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[x>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:y,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(x,te),remaining:x}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("chat.list.showEarlier",{count:Math.min(x,te)})})}),w.map((m,g)=>{const C=f+g,S=C>0?t[C-1]:null,R=!S||S.role!==m.role||S.role==="user";return e.jsx(Ht,{message:m,showAvatar:R},m.id||`msg-${C}`)})]})}),e.jsx(qt,{turns:p,viewportRef:d,containerRef:a,onRevealTurn:b}),k&&e.jsxs("button",{type:"button",onClick:j,className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Se,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),r("chat.list.jumpLatest")]})]})}const Xt=h.memo(Jt),Me=pt,Re=ft,De=bt,ce=h.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Ae,{ref:a,sideOffset:s,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...r}));ce.displayName=Ae.displayName;const Yt={active:{labelKey:"goal.status.active",dot:"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.5)]",accent:"text-[hsl(var(--deck-accent))]"},paused:{labelKey:"goal.status.paused",dot:"bg-amber-400",accent:"text-amber-600 dark:text-amber-300"},blocked:{labelKey:"goal.status.blocked",dot:"bg-rose-500",accent:"text-rose-600 dark:text-rose-300"},usage_limited:{labelKey:"goal.status.usageLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},budget_limited:{labelKey:"goal.status.budgetLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},complete:{labelKey:"goal.status.complete",dot:"bg-emerald-500",accent:"text-emerald-600 dark:text-emerald-300"}};function W(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function Zt(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;return r===0?`${s}m`:`${s}m ${r}s`}function es(){const t=D(),s=N(E=>E.goal),r=N(E=>E.pauseGoal),a=N(E=>E.resumeGoal),d=N(E=>E.editGoal),n=N(E=>E.clearGoal),[u,c]=h.useState(!1),[l,i]=h.useState(!1),[k,o]=h.useState(""),[x,f]=h.useState(null),[w,p]=h.useState(!1);if(h.useEffect(()=>{c(!1),i(!1),o((s==null?void 0:s.objective)??""),p(!1)},[s==null?void 0:s.goalId]),!s)return null;const j=Yt[s.status],y=["active","paused","blocked"].includes(s.status),b=s.status==="active",m=s.status==="paused"||s.status==="blocked",g=x!==null,C=async(E,$)=>{f(E);try{await $()}finally{f(null)}},S=()=>{o(s.objective),i(!0),c(!0)},R=async E=>{E.preventDefault();const $=k.trim();if(!$||$===s.objective){i(!1);return}await C("edit",()=>d($)),i(!1)},_=async()=>{await C("delete",n),p(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Me,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0",children:[e.jsxs("div",{className:A("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",u&&"rounded-b-none border-b-0"),children:[s.status==="complete"?e.jsx(at,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(nt,{className:A("h-3.5 w-3.5 shrink-0",j.accent)}),e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",j.dot)}),e.jsx("span",{className:A("shrink-0 text-[10px] font-medium leading-none",j.accent),children:t(j.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(u?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>c(E=>!E),"aria-expanded":u,title:s.objective,children:s.objective}),s.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[W(s.tokensUsed),s.tokenBudget!==void 0&&`/${W(s.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[b&&e.jsx(Q,{label:t("goal.action.pause"),disabled:g,onClick:()=>void C("pause",r),children:x==="pause"?e.jsx(F,{className:"animate-spin"}):e.jsx(it,{})}),m&&e.jsx(Q,{label:t("goal.action.resume"),disabled:g,onClick:()=>void C("resume",a),children:x==="resume"?e.jsx(F,{className:"animate-spin"}):e.jsx(ot,{})}),e.jsx(Q,{label:t(y?"goal.action.edit":"goal.action.expand"),disabled:!y&&!u,onClick:y?S:()=>c(E=>!E),children:y?e.jsx(Ee,{}):e.jsx(lt,{})}),e.jsx(Q,{label:t("goal.action.delete"),disabled:g,destructive:!0,onClick:()=>p(!0),children:e.jsx(J,{})})]})]}),u&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:l?e.jsxs("form",{onSubmit:R,children:[e.jsx("textarea",{id:"goal-objective",value:k,onChange:E=>o(E.target.value),onKeyDown:E=>{E.key==="Escape"&&i(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(ct,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!k.trim()||x==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[x==="edit"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(ae,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:s.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(dt,{className:"h-3 w-3"}),W(s.tokensUsed),s.tokenBudget!==void 0&&` / ${W(s.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ut,{className:"h-3 w-3"}),Zt(s.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ie,{className:"h-3 w-3"}),s.continuationCount===1?t("goal.metrics.continuationOne",{n:s.continuationCount}):t("goal.metrics.continuationMany",{n:s.continuationCount})]})]}),s.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:s.statusReason})]})})]})}),e.jsx(je,{open:w,onOpenChange:p,children:e.jsxs(ye,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(we,{children:t("goal.dialog.title")}),e.jsx(Ne,{children:t("goal.dialog.description")}),e.jsxs(Ce,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>p(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:x==="delete",onClick:()=>void _(),className:"inline-flex gap-1.5 justify-center items-center px-3 h-8 text-[12px] font-medium text-white bg-rose-600 rounded-md hover:bg-rose-500 disabled:opacity-50",children:[x==="delete"&&e.jsx(F,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function Q({label:t,children:s,disabled:r,destructive:a,onClick:d}){return e.jsxs(Re,{children:[e.jsx(De,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:d,className:A("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",a?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:s})}),e.jsx(ce,{side:"top",className:"text-[10px]",children:t})]})}function ts(){const t=D(),s=N(l=>l.currentSessionRef),r=N(l=>l.sessions),a=N(l=>l.messages),d=h.useMemo(()=>{var i,k,o,x,f;const l=s?(i=Ue(r,s))==null?void 0:i.pendingInteraction:void 0;if(l)return l.type;for(let w=a.length-1;w>=0;w-=1){const p=(k=a[w])==null?void 0:k.agentContent;if(((o=p==null?void 0:p.confirmation)==null?void 0:o.status)==="pending")return"permission";if(((x=p==null?void 0:p.question)==null?void 0:x.status)==="pending")return"question";if(((f=p==null?void 0:p.elicitation)==null?void 0:f.status)==="pending")return"elicitation"}return null},[s,a,r]);if(!d)return null;const n=()=>{const l=document.querySelector(`[data-pending-interaction="${d}"]`);l==null||l.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>l==null?void 0:l.focus(),250)},u=d==="question",c=d==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(Te,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-[180px] flex-1",children:[e.jsx("div",{className:"text-[11.5px] font-semibold",children:t(u?"interaction.bar.questionTitle":c?"interaction.bar.elicitationTitle":"interaction.bar.permissionTitle")}),e.jsx("div",{className:"mt-0.5 text-[10px] leading-4 text-amber-800 dark:text-amber-300",children:t(u?"interaction.bar.questionHint":c?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Se,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const ss={running:"status.phase.running",compacting:"status.phase.compacting",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},ve=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString();function rs(){const t=D(),s=N(i=>i.tokenUsage),r=N(i=>i.isStreaming),a=N(i=>i.agentPhase),d=ss[a]??"",n=d?t(d):"",u=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,c=Math.min(u,100),l=u>95?"danger":u>80?"warn":"safe";return e.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-5 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm",children:[e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:A("text-[12px] font-medium",l==="safe"&&"text-[hsl(var(--deck-ink))]",l==="warn"&&"text-amber-600 dark:text-amber-400",l==="danger"&&"text-red-600 dark:text-red-400"),children:ve(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",ve(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(Me,{children:e.jsxs(Re,{children:[e.jsx(De,{asChild:!0,children:e.jsx(mt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(ce,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]","aria-hidden":"true",children:[e.jsx("div",{className:A("absolute inset-y-0 left-0 transition-[width] duration-300",l==="safe"&&"bg-[hsl(var(--deck-accent))]",l==="warn"&&"bg-amber-500",l==="danger"&&"bg-red-500"),style:{width:`${c}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(i=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${i}%`}},i))})]}),e.jsxs("span",{className:A("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",l==="warn"&&"text-amber-600 dark:text-amber-400",l==="danger"&&"text-red-600 dark:text-red-400"),children:[u,"%"]})]}),e.jsx("div",{className:"flex-1"}),r&&n&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:n})]})]})}function as(t){const s=[...t].reverse().find(d=>d.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(d=>d.type==="text").map(d=>d.text).join(`
|
|
7
|
-
`),a=s.content.filter(d=>d.type==="image_url").map((d,n)=>{var c;const u=((c=d.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:c[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:u,dataUrl:d.image_url.url}});return{content:r,attachments:a}}function cs(){var ue;const t=D(),s=N(v=>v.messages),r=N(v=>v.currentSessionRef),a=N(v=>v.isStreaming),d=N(v=>v.isStopping),n=N(v=>v.sessionEventConnectionState),u=N(v=>v.pendingSteeringCount),c=N(v=>v.pendingInputDelivery),l=N(v=>v.recoveredSteeringCount),i=N(v=>v.isLoading),k=N(v=>v.error),o=N(v=>v.errorContext),x=N(v=>v.sessions),f=N(v=>v.sendMessage),w=N(v=>v.abortSession),p=N(v=>v.retryTask),j=N(v=>v.retryingTaskKeys),y=re(v=>v.openSettings),b=N(v=>v.reconnectSessionEvents),m=N(v=>v.clearError),g=N(v=>v.unsubscribeFromEvents),[C,S]=h.useState(null),R=r?x.find(v=>v.sessionId===r.sessionId&&v.projectPath===r.projectPath):void 0,_=!!k&&((o==null?void 0:o.kind)==="navigation"||!(o!=null&&o.sessionRef)||ke(o.sessionRef,r)),E=(o==null?void 0:o.failureCode)??((ue=R==null?void 0:R.taskFailure)==null?void 0:ue.code),$=(o==null?void 0:o.kind)==="execution"&&E?t(Ke(E)):k==="queue_full"?t("chat.error.queueFull"):k==="turn_unavailable"||k==="turn_active"?t("chat.error.turnChanged"):k,H=n==="connecting"||n==="reconnecting",z=a&&n!=="connected",T=r?`session:${G(r)}`:"session:temporary",P=h.useMemo(()=>as(s),[s]),V=r?G(r):"temporary-session",B=!!(r&&(R!=null&&R.taskRetryAvailable)&&(!E||qe(E)))&&((o==null?void 0:o.kind)==="execution"||(o==null?void 0:o.kind)==="task_action"),I=(o==null?void 0:o.kind)==="execution"&&(E==="authentication"||E==="permission"||E==="model_unavailable"),M=r?j.includes(G(r)):!1;h.useEffect(()=>()=>{g()},[g]),h.useEffect(()=>{S(null)},[V]);const L=async v=>f({content:v.content,modelId:v.modelId,reasoningEffort:v.reasoningEffort,serviceTier:v.serviceTier,responseVerbosity:v.responseVerbosity,communicationStyle:v.communicationStyle,attachments:v.attachments.map(Z=>({type:"image",content:Z.dataUrl,mimeType:Z.mimeType,name:Z.name}))}),K=()=>w(),Ie=async()=>{if(I){m(),y("models");return}if(B&&r){m(),await p(r).catch(()=>{});return}if((o==null?void 0:o.kind)==="execution"&&P){S({...P,revision:Date.now()}),m();return}m(),requestAnimationFrame(()=>ze())},de=B?t(M?"chat.error.action.retryingTask":"chat.error.action.retryTask"):I?t("chat.error.action.checkModels"):(o==null?void 0:o.kind)==="execution"&&P?t("chat.error.action.editResend"):(o==null?void 0:o.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[_&&e.jsxs("div",{role:"alert",className:"flex min-h-11 flex-wrap items-center gap-2 border-b border-red-200/60 bg-red-50/80 px-4 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300 sm:px-5",children:[e.jsx(Te,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[e.jsx("span",{className:"font-semibold",children:t((o==null?void 0:o.kind)==="submission"?"chat.error.title.submission":(o==null?void 0:o.kind)==="execution"?"chat.error.title.execution":(o==null?void 0:o.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",$]}),de&&e.jsxs("button",{type:"button",onClick:()=>void Ie(),disabled:M,className:"inline-flex min-h-7 shrink-0 items-center gap-1.5 rounded-md border border-red-300/70 bg-white/65 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60 dark:border-red-800 dark:bg-red-950/45 dark:hover:bg-red-900/60",children:[B?M?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(ie,{className:"h-3 w-3"}):e.jsx(Ee,{className:"h-3 w-3"}),de]}),e.jsx("button",{type:"button",onClick:m,"aria-label":t("chat.error.dismiss"),className:"p-1 text-red-500 rounded transition-colors hover:bg-red-100/60 hover:text-red-700 dark:hover:bg-red-950/60 dark:hover:text-red-100",children:"✕"})]}),(H||n==="offline")&&e.jsxs("div",{role:n==="offline"?"alert":"status","aria-live":"polite",className:"flex min-h-10 flex-wrap items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 font-mono text-[11px] text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-200 sm:px-5",children:[H?e.jsx(F,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(xt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(H?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void b().catch(()=>{}),className:"inline-flex min-h-7 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/60 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[e.jsx(ht,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(gt,{}),e.jsx(Xt,{messages:s,isLoading:i},r?G(r):"temporary-session"),e.jsx(ts,{}),e.jsx(es,{}),e.jsx(Ge,{draftKey:T,draft:C==null?void 0:C.content,draftAttachments:C==null?void 0:C.attachments,draftRevision:C==null?void 0:C.revision,onSend:L,onAbort:K,disabled:i||z,isStreaming:a,isStopping:d,pendingSteeringCount:u,pendingInputDelivery:c,recoveredSteeringCount:l,workspacePath:r==null?void 0:r.projectPath},T),e.jsx(rs,{})]})}export{cs as ChatView};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{r,j as e}from"./vendor-react-DG5dkZ_t.js";import{_ as $,n as P,o as Se,p as Fe,q as se}from"./vendor-radix-DBy9B2DN.js";import{i as Ze,a as Xe,d as Me,u as $e,b as ze,c as et,e as de,f as oe,g as tt}from"./useRequest-BvqVDnKl.js";import{b as at,D as he,e as be,G as nt,g as ge,j as w,x as L,y as rt}from"./index-ClOgGy-I.js";import{a as Be,i as st,X as ve,f as De,L as le,k as ot,Z as Te,C as lt,D as dt}from"./vendor-icons-D_AkWmWB.js";function ie(n,s){if(Ze){if(!n)return s;var o;return Xe(n)?o=n():"current"in n?o=n.current:o=n,o}}var it=function(n){var s=function(o,u,f){var x=r.useRef(!1),c=r.useRef([]),p=r.useRef([]),h=r.useRef(void 0);n(function(){var b,S=Array.isArray(f)?f:[f],g=S.map(function(j){return ie(j)});if(!x.current){x.current=!0,c.current=g,p.current=u,h.current=o();return}(g.length!==c.current.length||!Me(c.current,g)||!Me(p.current,u))&&((b=h.current)===null||b===void 0||b.call(h),c.current=g,p.current=u,h.current=o())}),$e(function(){var b;(b=h.current)===null||b===void 0||b.call(h),x.current=!1})};return s},ct=it(r.useEffect);function xt(){var n=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,s=typeof self=="object"&&self&&self.Object===Object&&self;return n||s}xt()||(global.Date=Date);function mt(n,s){var o,u=ze(n),f=(o=s==null?void 0:s.wait)!==null&&o!==void 0?o:1e3,x=r.useMemo(function(){return et(function(){for(var c=[],p=0;p<arguments.length;p++)c[p]=arguments[p];return u.current.apply(u,$([],P(c),!1))},f,s)},[]);return $e(function(){x.cancel()}),{run:x,cancel:x.cancel,flush:x.flush}}function ut(n,s,o){o===void 0&&(o={});var u=o.enable,f=u===void 0?!0:u,x=ze(s);ct(function(){if(f){var c=ie(o.target,window);if(c!=null&&c.addEventListener){var p=function(b){return x.current(b)},h=Array.isArray(n)?n:[n];return h.forEach(function(b){c.addEventListener(b,p,{capture:o.capture,once:o.once,passive:o.passive})}),function(){h.forEach(function(b){c.removeEventListener(b,p,{capture:o.capture})})}}}},[n,o.capture,o.once,o.passive,f],o.target)}var ft=function(n){return n===document||n===document.documentElement||n===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):n.scrollTop},Pe=function(n){return n.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},pt=function(n){return n.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},ht=function(n,s){s===void 0&&(s={});var o=s.target,u=s.isNoMore,f=s.threshold,x=f===void 0?100:f,c=s.direction,p=c===void 0?"bottom":c,h=s.reloadDeps,b=h===void 0?[]:h,S=s.manual,g=s.onBefore,j=s.onSuccess,C=s.onError,d=s.onFinally,F=P(r.useState(),2),M=F[0],O=F[1],N=P(r.useState(!1),2),z=N[0],R=N[1],U=p==="top",D=r.useRef(void 0),_=r.useRef(0),H=r.useMemo(function(){return u?u(M):!1},[M]),I=de(function(m){return Se(void 0,void 0,void 0,function(){var v;return Fe(this,function(k){switch(k.label){case 0:return[4,n(m)];case 1:return v=k.sent(),[2,{currentData:v,lastData:m}]}})})},{manual:S,onFinally:function(m,v,k){R(!1),d==null||d(v==null?void 0:v.currentData,k)},onBefore:function(){return g==null?void 0:g()},onSuccess:function(m){var v,k,E;m.lastData?O(se(se({},m.currentData),{list:U?$($([],P(m.currentData.list),!1),P((k=m.lastData.list)!==null&&k!==void 0?k:[]),!1):$($([],P((E=m.lastData.list)!==null&&E!==void 0?E:[]),!1),P(m.currentData.list),!1)})):O(se(se({},m.currentData),{list:$([],P((v=m.currentData.list)!==null&&v!==void 0?v:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(U){var y=ie(o);if(y=y===document?document.documentElement:y,y){var ee=Pe(y);y.scrollTo(0,ee-_.current)}}else G()})}),j==null||j(m.currentData)},onError:function(m){return C==null?void 0:C(m)}}),Y=I.loading,J=I.error,K=I.run,q=I.runAsync,ce=I.cancel,Q=oe(function(){H||(R(!0),K(M))}),Z=function(m){return Se(void 0,void 0,void 0,function(){var v;return Fe(this,function(k){switch(k.label){case 0:return[4,q(m)];case 1:return v=k.sent(),[2,v.currentData]}})})},xe=oe(function(){return H?Promise.reject():(R(!0),Z(M))}),me=function(){return R(!1),K()},X=function(){return R(!1),Z()},G=function(){var m=ie(o);if(m){var v=m===document?document.documentElement:m,k=ft(v),E=Pe(v),y=pt(v);U?(D.current!==void 0&&D.current>k&&k<=x&&Q(),D.current=k,_.current=E-k):E-k<=y+x&&Q()}};return ut("scroll",function(){Y||z||G()},{target:o}),tt(function(){K()},$([],P(b),!1)),{data:M,loading:!z&&Y,error:J,loadingMore:z,noMore:H,loadMore:Q,loadMoreAsync:xe,reload:oe(me),reloadAsync:oe(X),mutate:O,cancel:ce}};const Le={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",reconnecting:"text-[#2563eb] dark:text-[#60a5fa]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},bt={connected:"Connected",connecting:"Connecting...",reconnecting:"Recovering...",offline:"Offline",error:"Error"},gt={disabled:"Not configured",unavailable:"Unavailable in this runtime",unauthenticated:"Authorization required",authorizing:"Waiting for authorization...",authenticated:"Authorized",error:"Authorization failed"},Oe=20,vt=["debug","info","notice","warning","error","critical","alert","emergency"],Re=n=>n.status!=="reconnecting"||!n.recovery?bt[n.status]:`Recovering ${n.recovery.attempt}/${n.recovery.maxAttempts}`,kt=async()=>L("/mcp"),Et=async n=>L(`/mcp/${encodeURIComponent(n)}/logs?limit=20`),jt="mcp server @modelcontextprotocol",Nt=3,Ue=n=>{var s;return((s=n.split("/").pop())==null?void 0:s.replace(/^server-/,""))||n},Ct=async(n,s)=>{const o=n&&n.length>=Nt?n:jt,u=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(o)}&size=${Oe}&from=${s}`,f=await L(u);return{list:f.objects.map(x=>x.package),total:f.total,hasMore:s+Oe<f.total}};function Dt(){const{isMcpOpen:n,toggleMcp:s}=at(),[o,u]=r.useState("installed"),[f,x]=r.useState(!1),[c,p]=r.useState(null),[h,b]=r.useState(""),[S,g]=r.useState(null),[j,C]=r.useState(null),[d,F]=r.useState(null),[M,O]=r.useState(null),[N,z]=r.useState(null),[R,U]=r.useState(""),[D,_]=r.useState(null),[H,I]=r.useState(!1),[Y,J]=r.useState(null),[K,q]=r.useState(null),[ce,Q]=r.useState(""),[Z,xe]=r.useState(""),[me,X]=r.useState(null),[G,m]=r.useState(null),v=r.useRef(null),{run:k}=mt(t=>{xe(t)},{wait:500}),{data:E=[],loading:y,error:ee,run:ke,runAsync:W}=de(kt,{refreshDeps:[n],ready:n,onSuccess:t=>{t.length>0&&!c&&p(t[0].id)}}),{data:ae,loading:ue,error:Ee,runAsync:ne}=de(Et,{manual:!0}),{data:A,loading:He,loadingMore:Je,noMore:qe,error:je,reload:Ne}=ht(async t=>{var l;const i=((l=t==null?void 0:t.list)==null?void 0:l.length)??0;return Ct(Z,i)},{target:v,isNoMore:t=>!(t!=null&&t.hasMore),reloadDeps:[Z],manual:!n||o!=="catalog"}),{runAsync:Ce,loading:ye,error:V}=de(async t=>{await L("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,config:t})})},{manual:!0,onSuccess:()=>{W(),x(!1),m(null),X(null)},onError:()=>{X(null)}}),te=r.useMemo(()=>{const t=h.trim().toLowerCase();return t?E.filter(i=>[i.name,i.endpoint,i.description].some(l=>l.toLowerCase().includes(t))):E},[h,E]),a=r.useMemo(()=>te.find(t=>t.id===c)??te[0],[te,c]),re=r.useMemo(()=>{if(!a)return[];const t=(a.prompts??[]).flatMap(l=>l.arguments.map(B=>({key:`prompt:${l.name}:${B.name}`,label:`${l.name}.${B.name}`,reference:{type:"prompt",name:l.name},argument:B.name}))),i=(a.resourceTemplates??[]).flatMap(l=>(l.variables??[]).map(B=>({key:`resource:${l.uriTemplate}:${B}`,label:`${l.uriTemplate} · ${B}`,reference:{type:"resource",uri:l.uriTemplate},argument:B})));return[...t,...i]},[a]),T=re.find(t=>t.key===N)??re[0];r.useEffect(()=>{if(!n||!E.some(i=>i.oauthStatus==="authorizing"||i.status==="connecting"||i.status==="reconnecting"))return;const t=window.setInterval(()=>{W()},1e3);return()=>window.clearInterval(t)},[n,W,E]),r.useEffect(()=>{j&&E.some(t=>t.name===j.serverName&&(t.oauthStatus==="authenticated"||t.oauthStatus==="disabled"||t.oauthStatus==="unavailable"))&&C(null)},[j,E]),r.useEffect(()=>{!n||o!=="installed"||!a||ne(a.name).catch(()=>{})},[n,ne,a,o]);const fe=async(t,i)=>{F({type:t,name:i}),g(null);try{const l=t==="delete"?"":`/${t}`;await L(`/mcp/${encodeURIComponent(i)}${l}`,{method:t==="delete"?"DELETE":"POST"}),await W(),t==="delete"&&(q(null),p(null))}catch(l){g(l instanceof Error?l.message:`Failed to ${t} server`)}finally{F(null)}},pe=async(t,i)=>{F({type:t,name:i.name}),g(null);try{if(t==="login"){const l=await L(`/mcp/${encodeURIComponent(i.name)}/oauth/login`,{method:"POST"});C({serverName:i.name,url:l.authorizationUrl})}else await L(`/mcp/${encodeURIComponent(i.name)}/oauth/logout`,{method:"POST"}),C(null);await W()}catch(l){g(l instanceof Error?l.message:`Failed to ${t} MCP OAuth`)}finally{F(null)}},Ge=async(t,i)=>{O(i),g(null);try{await L(`/mcp/${encodeURIComponent(t.name)}/logging-level`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:i})}),await W(),ne(t.name).catch(()=>{})}catch(l){g(l instanceof Error?l.message:"Failed to set MCP logging level")}finally{O(null)}},We=async t=>{if(T){I(!0),J(null),_(null);try{const i=await L(`/mcp/${encodeURIComponent(t.name)}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:T.reference,argument:{name:T.argument,value:R}})});_(i)}catch(i){J(i instanceof Error?i.message:"MCP completion failed")}finally{I(!1)}}},Ve=r.useMemo(()=>new Set(E.map(t=>t.name.toLowerCase())),[E]),Ye=t=>{m(t)},Ke=t=>t.startsWith("@modelcontextprotocol/"),Qe=t=>Ke(t.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx(he,{open:n,onOpenChange:s,children:e.jsxs(be,{onCloseAutoFocus:nt,className:"flex h-[min(680px,calc(100dvh-24px))] flex-col gap-0 overflow-hidden rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[900px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ge,{className:"sr-only",children:"MCP"}),e.jsx("div",{className:"flex flex-1 min-h-0",children:e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{onClick:ke,"aria-label":"Refresh MCP servers",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:y,children:e.jsx(Be,{className:w("h-4 w-4",y&&"animate-spin")})}),e.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>x(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),"Add server"]}),e.jsx("button",{onClick:s,"aria-label":"Close MCP",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(ve,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsxs(Ie,{active:o==="installed",onClick:()=>u("installed"),children:["Installed (",E.length,")"]}),e.jsx(Ie,{active:o==="catalog",onClick:()=>{u("catalog"),A||Ne()},children:"Catalog"})]}),S&&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(De,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:S}),e.jsx("button",{type:"button",onClick:()=>g(null),className:"underline shrink-0",children:"Dismiss"})]}),o==="installed"?e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Servers"}),e.jsx("input",{type:"search","aria-label":"Search installed MCP servers",value:h,onChange:t=>b(t.target.value),placeholder:"Search servers...",className:"h-8 shrink-0 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[12px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0",children:[y&&E.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(le,{className:"w-4 h-4 animate-spin"}),"Loading servers..."]}),ee&&!y&&e.jsxs("div",{role:"alert",className:"flex flex-col gap-2 items-center py-6 font-mono text-xs text-center text-red-600 dark:text-red-400",children:[e.jsx("span",{children:ee.message}),e.jsx("button",{type:"button",onClick:ke,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!ee&&!y&&te.length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:h?"No servers match your search":"No MCP servers configured"}),te.map(t=>e.jsxs("button",{onClick:()=>{p(t.id),q(null),g(null),z(null),U(""),_(null),J(null)},className:w("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",t.id===(a==null?void 0:a.id)?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:w("text-[11px] font-mono font-semibold",Le[t.status]),children:Re(t)})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.endpoint})]},t.id))]})]}),a?e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),e.jsx("span",{className:w("text-xs font-mono font-semibold",Le[a.status]),children:Re(a)})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:a.description}),a.error&&e.jsxs("p",{className:"text-[12px] font-mono text-[#ef4444]",children:["Error: ",a.error]}),a.instructions&&e.jsxs("div",{className:"rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Server instructions"}),e.jsxs("span",{className:"truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",a.instructions.sha256]})]}),e.jsx("pre",{className:"mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:a.instructions.text??"[details omitted by runtime policy]"}),(a.instructions.truncated||a.instructions.detailsOmitted)&&e.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:a.instructions.detailsOmitted?"Details omitted":"Truncated to the safe display budget"})]}),a.tasks&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Experimental MCP Tasks"}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a.tasks.enabled?`${a.tasks.maxTasksPerSession} per Session · ${a.tasks.pollIntervalMs}ms poll`:"Disabled by default"})]}),e.jsx("span",{className:w("text-[10px] font-mono font-semibold uppercase",a.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:a.tasks.enabled?"Enabled":"Disabled"})]}),a.oauthEnabled&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"OAuth"}),e.jsx("span",{role:a.oauthStatus==="authorizing"?"status":void 0,className:w("text-[11px] font-mono",a.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":a.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:gt[a.oauthStatus]})]}),a.oauthStatus==="authenticated"?e.jsx("button",{type:"button",onClick:()=>void pe("logout",a),disabled:d!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:(d==null?void 0:d.type)==="logout"?"Signing out...":"Sign out"}):a.oauthStatus==="authorizing"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-3.5 w-3.5 animate-spin text-[#2563eb]","aria-hidden":"true"}),(j==null?void 0:j.serverName)===a.name?e.jsx("a",{href:j.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white dark:bg-[#3b82f6]",children:"Continue authorization"}):e.jsx("button",{type:"button",onClick:()=>void pe("login",a),disabled:d!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:"Resume authorization"})]}):a.oauthStatus==="unavailable"?null:e.jsx("button",{type:"button",onClick:()=>void pe("login",a),disabled:d!==null,className:"h-7 rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:(d==null?void 0:d.type)==="login"?"Opening...":"Authorize"})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[a.status==="connected"||a.status==="reconnecting"?e.jsx("button",{onClick:()=>void fe("disconnect",a.name),disabled:d!==null,className:"h-7 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:(d==null?void 0:d.type)==="disconnect"&&d.name===a.name?"Disconnecting...":a.status==="reconnecting"?"Stop recovery":"Disconnect"}):e.jsx("button",{onClick:()=>void fe("connect",a.name),disabled:d!==null||a.oauthEnabled&&a.oauthStatus!=="authenticated",className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:(d==null?void 0:d.type)==="connect"&&d.name===a.name?"Connecting...":a.oauthEnabled&&a.oauthStatus!=="authenticated"?"Authorize first":"Connect"}),e.jsx("button",{onClick:()=>q(a.name),disabled:d!==null,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:"Delete"})]}),K===a.name&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete ${a.name}`,className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:"Remove this server and its saved configuration?"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>q(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("delete",a.name),disabled:d!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(d==null?void 0:d.type)==="delete"?"Deleting...":"Delete server"})]})]}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Tools (",a.tools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No tools available"}):a.tools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Argument completion"}),a.status!=="connected"?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Connect the server to request suggestions"}):a.completionSupported?re.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No completable prompt arguments or template variables"}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{"aria-label":"MCP completion target",className:"flex max-h-20 flex-wrap gap-1 overflow-y-auto",children:re.map(t=>e.jsx("button",{type:"button","aria-pressed":(T==null?void 0:T.key)===t.key,onClick:()=>{z(t.key),_(null),J(null)},className:w("max-w-full truncate rounded px-2 py-1 text-[10px] font-mono",(T==null?void 0:T.key)===t.key?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]"),children:t.label},t.key))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text","aria-label":"MCP completion partial value",value:R,onChange:t=>U(t.target.value),placeholder:"Partial value",className:"h-8 min-w-0 flex-1 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[11px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsx("button",{type:"button",onClick:()=>void We(a),disabled:H,className:"h-8 shrink-0 rounded-md bg-[#2563eb] px-3 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:H?"Completing...":"Complete"})]}),Y&&e.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:Y}),D&&e.jsxs("div",{"aria-label":"MCP completion suggestions",className:"rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:D.values.length>0?D.values.map(t=>e.jsx("span",{className:"rounded bg-white px-2 py-1 text-[10px] font-mono text-[#111827] dark:bg-[#0C0C0C] dark:text-[#E5E5E5]",children:t||"[empty]"},t)):e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF]",children:"No suggestions"})}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",D.sha256,D.truncated?" · truncated":""]})]})]}):e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Server does not advertise MCP completions"}),e.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Diagnostics"}),e.jsx("button",{type:"button","aria-label":`Refresh ${a.name} MCP logs`,onClick:()=>void ne(a.name),disabled:ue,className:"flex h-7 w-7 items-center justify-center rounded-md text-[#9CA3AF] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:text-[#71717a] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(Be,{className:w("h-3.5 w-3.5",ue&&"animate-spin")})})]}),e.jsx("div",{"aria-label":"MCP logging level",className:"flex flex-wrap gap-1",children:vt.map(t=>{var i,l;return e.jsx("button",{type:"button",onClick:()=>void Ge(a,t),disabled:a.status!=="connected"||M!==null,"aria-pressed":(((i=a.logging)==null?void 0:i.level)??"warning")===t,className:w("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((l=a.logging)==null?void 0:l.level)??"warning")===t?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] hover:text-[#111827] dark:bg-[#18181b] dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5]"),children:M===t?"Setting...":t},t)})}),Ee?e.jsx("div",{role:"alert",className:"rounded-md bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:bg-red-950/30 dark:text-red-300",children:Ee.message}):ae!=null&&ae.entries.length?e.jsx("div",{"aria-label":`${a.name} MCP logs`,className:"flex max-h-52 flex-col gap-1.5 overflow-y-auto rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:ae.entries.map(t=>e.jsxs("div",{className:"rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:w("text-[10px] font-mono font-semibold uppercase",["error","critical","alert","emergency"].includes(t.level)?"text-red-600 dark:text-red-400":t.level==="warning"?"text-amber-600 dark:text-amber-400":"text-[#2563eb] dark:text-[#60a5fa]"),children:t.level}),e.jsxs("span",{className:"truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[t.logger||a.name," · r",t.revision]})]}),e.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:t.message}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",t.dataSha256,t.truncated?" · truncated":"",t.detailsOmitted?" · details omitted":""]})]},t.revision))}):e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:ue?"Loading logs...":"No logs captured"})]}):e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a server to view details"})})]}):e.jsxs("div",{className:"flex flex-col flex-1 gap-4 min-h-0",children:[e.jsx("div",{className:"flex gap-3 items-center shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(ot,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text","aria-label":"Search MCP server catalog",value:ce,onChange:t=>{Q(t.target.value),k(t.target.value)},placeholder:"Search MCP servers on npm (min 3 chars)...",className:"flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none"})]})}),e.jsxs("div",{ref:v,className:"overflow-y-auto flex-1 min-h-0",children:[je?e.jsxs("div",{role:"alert",className:"flex flex-col gap-3 items-center py-12 font-mono text-center",children:[e.jsx(De,{className:"w-6 h-6 text-red-500"}),e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:je.message}),e.jsx("button",{type:"button",onClick:Ne,className:"rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]",children:"Retry catalog"})]}):He&&!A?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(le,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsxs("div",{className:"grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2",children:[A==null?void 0:A.list.map(t=>{var we,Ae;const i=Ve.has(Ue(t.name).toLowerCase()),l=me===t.name,B=Qe(t);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:t.name}),e.jsx("span",{className:w("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",B==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:B})]}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:t.description||"No description"}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsxs("span",{children:["v",t.version]}),((we=t.publisher)==null?void 0:we.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["by ",t.publisher.username]})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2 mt-auto",children:[e.jsxs("a",{href:((Ae=t.links)==null?void 0:Ae.npm)||`https://www.npmjs.com/package/${t.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5] flex items-center gap-1",children:[e.jsx(Te,{className:"w-3 h-3"}),"npm"]}),i?e.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[e.jsx(lt,{className:"w-3 h-3"}),"Installed"]}):e.jsxs("button",{onClick:()=>Ye(t),disabled:l,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(dt,{className:w("h-3 w-3",l&&"animate-pulse")}),l?"Installing...":"Install"]})]})]},t.name)}),(A==null?void 0:A.list.length)===0&&e.jsx("div",{className:"col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No packages found"})]}),Je&&e.jsx("div",{className:"flex justify-center items-center py-4",children:e.jsx(le,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),qe&&A&&A.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No more packages"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[(A==null?void 0:A.total)??0," packages found"]}),e.jsxs("a",{href:"https://glama.ai/mcp/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1",children:["Browse more on Glama",e.jsx(Te,{className:"w-3 h-3"})]})]})]})]})})]})}),e.jsx(yt,{open:f,onOpenChange:x,onAdd:Ce,saving:ye,error:(V==null?void 0:V.message)??null}),G&&e.jsx(wt,{pkg:G,onClose:()=>m(null),installing:ye,error:(V==null?void 0:V.message)??null,onInstall:t=>(X(G.name),Ce(t))})]})}function Ie({active:n,children:s,onClick:o}){return e.jsx("button",{onClick:o,className:w("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",n?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:s})}function yt({open:n,onOpenChange:s,onAdd:o,saving:u,error:f}){const[x,c]=r.useState("form"),[p,h]=r.useState(""),[b,S]=r.useState(""),[g,j]=r.useState(""),[C,d]=r.useState(null),[F,M]=r.useState(`{
|
|
2
|
-
"name": "my-server",
|
|
3
|
-
"command": "npx",
|
|
4
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
5
|
-
}`);r.useEffect(()=>{n&&d(null)},[n]);const O=async()=>{if(d(null),x==="json"){let N;try{N=JSON.parse(F)}catch{d("Enter valid JSON with a server name and transport.");return}await o(N).catch(()=>{})}else{if(!p||!b){d("Name and command are required.");return}await o({name:p,command:b,args:g.split(" ").filter(Boolean)}).catch(()=>{})}};return e.jsx(he,{open:n,onOpenChange:s,children:e.jsxs(be,{onCloseAutoFocus:N=>rt("[data-mcp-add-server-trigger]",N),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-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ge,{className:"sr-only",children:"Add MCP Server"}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Add MCP Server"}),e.jsx("button",{onClick:()=>s(!1),"aria-label":"Close add MCP server",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(ve,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(_e,{active:x==="form",onClick:()=>c("form"),children:"Form"}),e.jsx(_e,{active:x==="json",onClick:()=>c("json"),children:"JSON"})]}),x==="json"?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"JSON config"}),e.jsx("textarea",{"aria-label":"JSON configuration",className:"min-h-[140px] rounded-md bg-white dark:bg-[#0C0C0C] text-[#111827] dark:text-[#E5E5E5] font-mono text-[12px] p-3 border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]",value:F,onChange:N=>M(N.target.value)})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Server name"}),e.jsx("input",{"aria-label":"Server name",type:"text",value:p,onChange:N=>h(N.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Command"}),e.jsx("input",{"aria-label":"Server command",type:"text",value:b,onChange:N=>S(N.target.value),placeholder:"npx",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Arguments (space separated)"}),e.jsx("input",{"aria-label":"Server arguments",type:"text",value:g,onChange:N=>j(N.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem /tmp",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]})]}),(C||f)&&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:C||f}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:()=>s(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:()=>void O(),disabled:u,className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60",children:u?"Adding...":"Add Server"})]})]})]})})}function wt({pkg:n,onClose:s,onInstall:o,installing:u,error:f}){const x=Ue(n.name),[c,p]=r.useState(x),[h,b]=r.useState(`-y ${n.name}`),[S,g]=r.useState(null),j=async()=>{if(g(null),!c.trim()){g("Server name is required.");return}await o({name:c.trim(),command:"npx",args:h.split(" ").filter(Boolean)}).catch(()=>{})};return e.jsx(he,{open:!0,onOpenChange:s,children:e.jsxs(be,{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.jsxs(ge,{className:"sr-only",children:["Install ",n.name]}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install MCP Server"}),e.jsx("button",{onClick:s,"aria-label":"Close MCP installation",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(ve,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"rounded-md bg-white dark:bg-[#0C0C0C] p-3",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:n.name}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] mt-1",children:n.description||"No description"})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Server name"}),e.jsx("input",{"aria-label":"Server name",type:"text",value:c,onChange:C=>p(C.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Arguments"}),e.jsx("input",{"aria-label":"Server arguments",type:"text",value:h,onChange:C=>b(C.target.value),placeholder:"-y package-name",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["Command: npx ",h]})]})]}),(S||f)&&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:S||f}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:s,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:()=>void j(),disabled:u,className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60",children:u?"Installing...":"Install"})]})]})]})})}function _e({active:n,children:s,onClick:o}){return e.jsx("button",{onClick:o,className:w("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",n?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:s})}export{Dt as McpModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,j as e}from"./vendor-react-DG5dkZ_t.js";import{P as We,v as Ye,j as T,w as Qe,S as Ve,u as ce,x as $,D as Ne,e as Ee,y as we,g as Se,a as be,z as Xe,b as ve,A as Ze,E as et,K as tt,F as st}from"./index-ClOgGy-I.js";import{y as Le,C as at,X as Ce,f as ke,a7 as nt,a8 as lt,L as Z,u as Ae,Y as Oe,a as fe,N as rt,D as Te,T as ye,a9 as ot,i as it,aa as dt,ab as ct,P as De}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";function de({value:t,onChange:g,options:k,placeholder:b="Select...",disabled:l=!1,className:U,"aria-label":L}){const[D,y]=n.useState(!1),[i,M]=n.useState(-1),o=n.useRef(null),f=k.find(c=>c.value===t);n.useEffect(()=>{if(D){const c=k.findIndex(E=>E.value===t);M(c>=0?c:0)}},[D,k,t]);const R=c=>{if(!l){if(!D){(c.key==="Enter"||c.key===" "||c.key==="ArrowDown")&&(c.preventDefault(),y(!0));return}switch(c.key){case"ArrowDown":c.preventDefault(),M(E=>Math.min(E+1,k.length-1));break;case"ArrowUp":c.preventDefault(),M(E=>Math.max(E-1,0));break;case"Enter":case" ":c.preventDefault(),i>=0&&i<k.length&&(g(k[i].value),y(!1));break;case"Escape":c.preventDefault(),y(!1);break}}};return n.useEffect(()=>{var E;if(!D||i<0)return;const c=(E=o.current)==null?void 0:E.children[i];c==null||c.scrollIntoView({block:"nearest"})},[i,D]),e.jsxs(We,{open:D,onOpenChange:y,children:[e.jsx(Ye,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":D,"aria-haspopup":"listbox","aria-label":L,disabled:l,onKeyDown:R,className:T("field flex items-center justify-between gap-2 text-left",!f&&"text-zinc-400 dark:text-zinc-500",l&&"cursor-not-allowed opacity-50",U),children:[e.jsx("span",{className:"truncate",children:f?f.label:b}),e.jsx(Le,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),e.jsx(Qe,{align:"start",sideOffset:4,onKeyDown:R,className:"w-[var(--radix-popover-trigger-width)] max-h-[240px] p-1 overflow-hidden",children:e.jsx(Ve,{className:"max-h-[232px]",children:e.jsx("div",{ref:o,role:"listbox",children:k.map((c,E)=>e.jsxs("button",{type:"button",role:"option","aria-selected":c.value===t,"data-value":c.value,"data-highlighted":E===i||void 0,onClick:()=>{g(c.value),y(!1)},onMouseEnter:()=>M(E),className:T("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left font-mono text-[13px] outline-none transition-colors",E===i&&"bg-zinc-100 dark:bg-zinc-800",c.value===t&&"text-zinc-900 dark:text-zinc-50 font-medium"),children:[e.jsx(at,{className:T("h-3.5 w-3.5 shrink-0",c.value===t?"opacity-100":"opacity-0")}),e.jsx("span",{className:"truncate",children:c.label})]},c.value))})})})]})}const xt=[{id:"auto",name:"Auto",description:"Use the Blade default communication style",source:"built-in"},{id:"pragmatic",name:"Pragmatic",description:"Direct, factual, concise, and action-oriented",source:"built-in"},{id:"friendly",name:"Friendly",description:"Warm, collaborative, and task-focused",source:"built-in"},{id:"explanatory",name:"Explanatory",description:"Explain codebase-specific choices and tradeoffs",source:"built-in"}],mt=/^[a-z][a-z0-9._-]{0,63}$/;function ut({open:t,onOpenChange:g,onSave:k,saveError:b}){const l=ce(),[U,L]=n.useState([]),[D,y]=n.useState([]),[i,M]=n.useState(),[o,f]=n.useState(),[R,c]=n.useState(""),[E,m]=n.useState(""),[N,K]=n.useState(""),[h,x]=n.useState(""),[O,A]=n.useState(""),[I,P]=n.useState(""),[r,u]=n.useState(!1),[Y,z]=n.useState(!1),[Q,G]=n.useState(!1),[_,J]=n.useState(!1),[w,S]=n.useState(null);n.useEffect(()=>{if(!t)return;let d=!0;return y([]),M(void 0),f(void 0),c(""),m(""),K(""),x(""),A(""),P(""),u(!1),S(null),z(!0),$("/providers").then(F=>{d&&L(F)}).catch(F=>{d&&S(F instanceof Error?F.message:l("settings.models.addModal.loadProvidersError"))}).finally(()=>{d&&z(!1)}),()=>{d=!1}},[t,l]),n.useEffect(()=>{if(!i)return;let d=!0;return y([]),f(void 0),S(null),i.factoryWireApi||i.custom?(G(!1),()=>{d=!1}):(G(!0),$(`/providers/${i.id}/models`).then(F=>{d&&y(F)}).catch(F=>{d&&S(F instanceof Error?F.message:l("settings.models.addModal.loadModelsError"))}).finally(()=>{d&&G(!1)}),()=>{d=!1})},[i,l]);const B=i==null?void 0:i.factoryWireApi,V=!!(B||i!=null&&i.custom),q=V?h.trim():o==null?void 0:o.id,le=async()=>{if(!i||!q||!i.configured&&!I)return;if(B){if(!mt.test(E.trim())){S(l("settings.models.addModal.channelIdError"));return}let se;try{se=new URL(O.trim())}catch{S(l("settings.models.addModal.invalidBaseUrl"));return}if(!["http:","https:"].includes(se.protocol)){S(l("settings.models.addModal.invalidBaseUrl"));return}}J(!0);const d=B?E.trim():i.id,F=await k({provider:d,model:q,displayName:R||(V?q:(o==null?void 0:o.name)??""),apiKey:I||void 0,...B?{modelProvider:{id:d,name:N.trim()||d,baseUrl:O.trim(),wireApi:B}}:{}});J(!1),F&&g(!1)};return e.jsx(Ne,{open:t,onOpenChange:g,children:e.jsxs(Ee,{onCloseAutoFocus:d=>we("[data-add-model-trigger]",d),onEscapeKeyDown:d=>{d.preventDefault(),g(!1)},onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),g(!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(Se,{className:"sr-only",children:l("settings.models.addModal.title")}),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:l("settings.models.addModal.title")}),e.jsx("button",{type:"button",onClick:()=>g(!1),"aria-label":l("settings.models.addModal.close"),className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(Ce,{className:"h-4 w-4"})})]}),(w||b)&&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(ke,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:w||b})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.provider"),e.jsx(de,{"aria-label":l("settings.models.addModal.provider"),value:(i==null?void 0:i.id)??"",disabled:Y,onChange:d=>{M(U.find(F=>F.id===d)),c(""),m(""),K(""),x(""),A("")},placeholder:l(Y?"settings.models.addModal.loadingProviders":"settings.models.addModal.selectProvider"),options:U.map(d=>{const F=d.factoryWireApi==="openai-completions"?l("settings.models.addModal.customOpenAI"):d.factoryWireApi==="anthropic-messages"?l("settings.models.addModal.customAnthropic"):d.name;return{value:d.id,label:`${F} (${d.modelCount})${d.configured?l("settings.models.addModal.configuredSuffix"):""}`}})})]}),V?e.jsxs(e.Fragment,{children:[B&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.channelId"),e.jsx("input",{"aria-label":l("settings.models.addModal.channelId"),value:E,onChange:d=>{m(d.target.value),S(null)},placeholder:"team-gateway",autoComplete:"off",spellCheck:!1,className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:l("settings.models.addModal.channelIdHint")})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.channelName"),e.jsx("input",{"aria-label":l("settings.models.addModal.channelName"),value:N,onChange:d=>K(d.target.value),placeholder:"Team Gateway",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.baseUrl"),e.jsx("input",{"aria-label":l("settings.models.addModal.baseUrl"),value:O,onChange:d=>{A(d.target.value),S(null)},placeholder:B==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:l(B==="anthropic-messages"?"settings.models.addModal.anthropicProtocol":"settings.models.addModal.openaiProtocol")})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.modelId"),e.jsx("input",{"aria-label":l("settings.models.addModal.modelId"),value:h,onChange:d=>{x(d.target.value),S(null)},placeholder:"vendor-model-2026",className:"field"})]})]}):e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.model"),e.jsx(de,{"aria-label":l("settings.models.addModal.model"),value:(o==null?void 0:o.id)??"",disabled:!i||Q,onChange:d=>{const F=D.find(se=>se.id===d);f(F),F&&c(F.name)},placeholder:l(Q?"settings.models.addModal.loadingModels":"settings.models.addModal.selectModel"),options:D.map(d=>({value:d.id,label:`${d.name} - ${Math.round(d.contextWindow/1e3)}K${d.reasoning?l("settings.models.addModal.reasoningSuffix"):""}${d.input.includes("image")?l("settings.models.addModal.visionSuffix"):""}`}))})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.displayName"),e.jsx("input",{value:R,onChange:d=>c(d.target.value),placeholder:(o==null?void 0:o.name)??l("settings.models.addModal.displayNamePlaceholder"),className:"field"})]}),(i==null?void 0:i.supportsApiKey)&&!i.configured&&e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[l("settings.models.addModal.apiKey"),e.jsxs("span",{className:"relative",children:[e.jsx("input",{"aria-label":l("settings.models.addModal.apiKeyAria"),type:r?"text":"password",value:I,onChange:d=>P(d.target.value),className:"field w-full pr-10",placeholder:l("settings.models.addModal.apiKeyPlaceholder")}),e.jsx("button",{type:"button",onClick:()=>u(!r),"aria-label":l(r?"settings.models.addModal.hideApiKey":"settings.models.addModal.showApiKey"),className:"absolute right-2 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded",children:r?e.jsx(nt,{className:"h-4 w-4"}):e.jsx(lt,{className:"h-4 w-4"})})]})]}),i&&!i.configured&&!i.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:l("settings.models.addModal.oauthNote")}),e.jsxs("button",{type:"button",disabled:_||!i||!q||B&&(!E.trim()||!O.trim())||!i.configured&&(!i.supportsApiKey||I.trim().length===0),onClick:()=>void le(),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:[_&&e.jsx(Z,{className:"h-4 w-4 animate-spin"}),l(_?"settings.models.addModal.saving":"settings.models.addModal.saveModel")]})]})]})})}function pt(t){const g=ce(),[k,b]=n.useState(""),[l,U]=n.useState(""),[L,D]=n.useState(""),[y,i]=n.useState(""),[M,o]=n.useState(!1),[f,R]=n.useState(null);n.useEffect(()=>{var m,N,K,h,x;b(((m=t.model)==null?void 0:m.displayName)??""),U(((K=(N=t.model)==null?void 0:N.overrides)==null?void 0:K.baseUrl)??""),D(((x=(h=t.model)==null?void 0:h.overrides)==null?void 0:x.streamIdleTimeout)!==void 0?String(t.model.overrides.streamIdleTimeout):""),i(""),R(null)},[t.model]);const c=async()=>{if(!t.model)return;R(null);const m=L.trim()?Number(L):void 0;if(m!==void 0&&(!Number.isFinite(m)||m<1e3)){R(g("settings.models.editModal.streamIdleTimeoutError"));return}o(!0);try{y.trim()&&await $(`/providers/${t.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:y.trim()})});const N={...t.model.overrides};l.trim()?N.baseUrl=l.trim():delete N.baseUrl,m!==void 0?N.streamIdleTimeout=m:delete N.streamIdleTimeout,await t.onSave(t.model.id,{displayName:k||void 0,overrides:Object.keys(N).length>0?N:void 0})&&t.onOpenChange(!1)}catch(N){R(N instanceof Error?N.message:g("settings.models.editModal.credentialError"))}finally{o(!1)}},E=t.model?`[data-edit-model-trigger="${t.model.id.replace(/"/g,'\\"')}"]`:"[data-edit-model-trigger]";return e.jsx(Ne,{open:t.open,onOpenChange:t.onOpenChange,children:e.jsxs(Ee,{onCloseAutoFocus:m=>we(E,m),onEscapeKeyDown:m=>{m.preventDefault(),t.onOpenChange(!1)},onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),t.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(Se,{className:"sr-only",children:g("settings.models.editModal.srTitle")}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono font-semibold",children:g("settings.models.editModal.title")}),e.jsx("button",{type:"button",onClick:()=>t.onOpenChange(!1),"aria-label":g("settings.models.editModal.close"),className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(Ce,{className:"h-4 w-4"})})]}),(f||t.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:f||t.saveError}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[g("settings.models.editModal.displayName"),e.jsx("input",{value:k,onChange:m=>b(m.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[g("settings.models.editModal.replaceApiKey"),e.jsx("input",{type:"password",value:y,onChange:m=>i(m.target.value),placeholder:g("settings.models.editModal.replaceApiKeyPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[g("settings.models.editModal.baseUrlOverride"),e.jsx("input",{value:l,onChange:m=>U(m.target.value),placeholder:g("settings.models.editModal.baseUrlPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[g("settings.models.editModal.streamIdleTimeout"),e.jsx("input",{type:"number",min:1e3,step:1e3,value:L,onChange:m=>D(m.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void c(),disabled:M,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:[M&&e.jsx(Z,{className:"h-4 w-4 animate-spin"}),g(M?"settings.models.editModal.saving":"settings.models.editModal.save")]})]})})}function gt({provider:t,onOpenChange:g,onSave:k,saveError:b}){const l=ce(),[U,L]=n.useState(t.name),[D,y]=n.useState(t.defaultBaseUrl??""),[i,M]=n.useState(t.wireApi??"openai-completions"),[o,f]=n.useState(t.apiKeyEnv??""),[R,c]=n.useState(""),[E,m]=n.useState(null),[N,K]=n.useState(!1);n.useEffect(()=>{L(t.name),y(t.defaultBaseUrl??""),M(t.wireApi??"openai-completions"),f(t.apiKeyEnv??""),c(""),m(null)},[t]);const h=async()=>{if(!U.trim()){m(l("settings.models.editProvider.channelNameRequired"));return}try{const x=new URL(D.trim());if(!["http:","https:"].includes(x.protocol))throw new Error}catch{m(l("settings.models.editProvider.invalidBaseUrl"));return}K(!0),m(null);try{await k(t.id,{name:U.trim(),baseUrl:D.trim(),wireApi:i,apiKeyEnv:o.trim()||null,...R.trim()?{apiKey:R.trim()}:{}})&&g(!1)}finally{K(!1)}};return e.jsx(Ne,{open:!0,onOpenChange:g,children:e.jsxs(Ee,{onCloseAutoFocus:x=>we(`[data-edit-provider-trigger="${t.id.replace(/"/g,'\\"')}"]`,x),onEscapeKeyDown:x=>{x.preventDefault(),g(!1)},onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),g(!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(Se,{className:"sr-only",children:l("settings.models.editProvider.title")}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-mono font-semibold",children:l("settings.models.editProvider.title")}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-zinc-400",children:t.id})]}),e.jsx("button",{type:"button",onClick:()=>g(!1),"aria-label":l("settings.models.editProvider.close"),className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(Ce,{className:"h-4 w-4"})})]}),(E||b)&&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:E||b}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[l("settings.models.editProvider.channelName"),e.jsx("input",{"aria-label":l("settings.models.editProvider.channelName"),value:U,onChange:x=>L(x.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[l("settings.models.editProvider.wireApi"),e.jsx(de,{"aria-label":l("settings.models.editProvider.wireApi"),value:i,onChange:x=>M(x),options:[{value:"openai-completions",label:"OpenAI Chat Completions"},{value:"anthropic-messages",label:"Anthropic Messages"}]})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[l("settings.models.editProvider.baseUrl"),e.jsx("input",{"aria-label":l("settings.models.editProvider.baseUrlAria"),value:D,onChange:x=>{y(x.target.value),m(null)},className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[l("settings.models.editProvider.apiKeyEnv"),e.jsx("input",{"aria-label":l("settings.models.editProvider.apiKeyEnv"),value:o,onChange:x=>f(x.target.value),placeholder:l("settings.models.editProvider.apiKeyEnvPlaceholder"),autoComplete:"off",spellCheck:!1,className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[l("settings.models.editProvider.replaceApiKey"),e.jsx("input",{"aria-label":l("settings.models.editProvider.apiKeyAria"),type:"password",value:R,onChange:x=>c(x.target.value),placeholder:l("settings.models.editProvider.apiKeyPlaceholder"),className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void h(),disabled:N,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:[N&&e.jsx(Z,{className:"h-4 w-4 animate-spin"}),l(N?"settings.models.editProvider.saving":"settings.models.editProvider.save")]})]})})}const ht={disabled:"settings.hooks.state.disabled",not_required:"settings.hooks.state.notRequired",untrusted:"settings.hooks.state.review",trusted:"settings.hooks.state.trusted",modified:"settings.hooks.state.modified",error:"settings.hooks.state.error"};function bt(){const t=ce(),g=be(w=>w.currentSessionRef),k=g==null?void 0:g.projectPath,b=g==null?void 0:g.sessionId,l=n.useMemo(()=>k??new URLSearchParams(window.location.search).get("project")??"",[k]),[U,L]=n.useState(null),[D,y]=n.useState(null),[i,M]=n.useState(""),[o,f]=n.useState(""),[R,c]=n.useState(!1),[E,m]=n.useState(null),[N,K]=n.useState(null),[h,x]=n.useState(null),O=n.useRef(0),A=n.useRef(l);A.current=l;const I=b?`${l}\0${b}`:"",P=n.useRef(I);P.current=I;const r=i===l?U:null,u=o===I?D:null,Y=n.useCallback(async()=>{const w=++O.current;if(!l){L(null),y(null),M(""),f(""),x(null);return}c(!0),x(null);try{const S=await $(`/hooks/trust?projectPath=${encodeURIComponent(l)}`);if(w!==O.current)return;const B=b?await $(`/hooks/session?projectPath=${encodeURIComponent(l)}&sessionId=${encodeURIComponent(b)}`):null;if(w!==O.current)return;L(S),y(B),M(l),f(B?I:"")}catch(S){if(w!==O.current)return;x(S instanceof Error?S.message:t("settings.hooks.loadFailed"))}finally{w===O.current&&c(!1)}},[l,b,I,t]);n.useEffect(()=>(K(null),Y(),()=>{O.current+=1}),[Y]);const z=async w=>{if(!r)return;const S=l;m(w),x(null);try{const B=await $("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,action:w,...w==="trust"&&r.currentDigest?{expectedDigest:r.currentDigest}:{}})});A.current===S&&(L(B),M(S),K(null))}catch(B){A.current===S&&x(B instanceof Error?B.message:t("settings.hooks.updateFailed"))}finally{m(null)}},Q=async w=>{if(!b||!u)return;const S=I;m("session"),x(null);try{const B=await $("/hooks/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,sessionId:b,enabled:w})});P.current===S&&(y(B),f(S))}catch(B){P.current===S&&x(B instanceof Error?B.message:t("settings.hooks.sessionUpdateFailed"))}finally{m(null)}};if(!l)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.hooks.selectSession")});const G=(r==null?void 0:r.state)==="trusted",_=(r==null?void 0:r.state)==="untrusted"||(r==null?void 0:r.state)==="modified",J=u!==null&&!u.enabled&&!u.paused;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:[G?e.jsx(Ae,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Oe,{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:t(r?ht[r.state]:"settings.hooks.heading")}),R&&e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:l}),(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 Y(),disabled:R||E!==null,"aria-label":t("settings.hooks.reloadAria"),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(fe,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),G?e.jsx("button",{type:"button",onClick:()=>K("revoke"),disabled:E!==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:t("settings.hooks.revoke")}):e.jsx("button",{type:"button",onClick:()=>K("trust"),disabled:E!==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:t("settings.hooks.trustDigest")})]})]}),h&&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:h}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.hooks.currentSession")}),e.jsx("div",{className:"mt-0.5 text-[9.5px] text-[#9CA3AF]",children:b?u?u.paused?t("settings.hooks.session.paused"):u.enabled?t("settings.hooks.session.active"):u.configEnabled?t("settings.hooks.session.unavailable"):t("settings.hooks.session.disabled"):t("settings.hooks.session.loading"):t("settings.hooks.session.open")})]}),e.jsx("button",{type:"button",role:"switch","aria-label":u!=null&&u.paused?t("settings.hooks.session.enableAria"):u!=null&&u.enabled?t("settings.hooks.session.pauseAria"):t("settings.hooks.session.unavailableAria"),"aria-checked":(u==null?void 0:u.enabled)??!1,disabled:!u||E!==null||J,onClick:()=>void Q((u==null?void 0:u.paused)===!0),className:T("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",u!=null&&u.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",u!=null&&u.enabled?"translate-x-5":"translate-x-0")})})]}),N&&r&&e.jsxs("div",{role:"alertdialog","aria-label":t(N==="trust"?"settings.hooks.confirmTrustAria":"settings.hooks.confirmRevokeAria"),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:N==="trust"?t("settings.hooks.confirmTrust",{count:r.configuredHooks}):t("settings.hooks.confirmRevoke")}),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:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void z(N),disabled:E!==null,className:T("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",N==="trust"?"bg-emerald-600":"bg-red-600"),children:t(E?"settings.hooks.saving":N==="trust"?"settings.hooks.trustReviewed":"settings.hooks.revokeTrust")})]})]}),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((w,S)=>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:w.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:w.type}),w.name&&e.jsx("span",{className:"text-[#71717a]",children:w.name}),w.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:[w.pluginName," · ",w.pluginSource]})]}),w.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:w.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:w.target})]},`${w.event}-${w.type}-${S}`)),r&&r.definitions.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.hooks.empty")})]})]})}const ft={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]},yt=[{value:"local",labelKey:"settings.plugins.scope.local",descriptionKey:"settings.plugins.scope.localDesc"},{value:"project",labelKey:"settings.plugins.scope.project",descriptionKey:"settings.plugins.scope.projectDesc"},{value:"global",labelKey:"settings.plugins.scope.global",descriptionKey:"settings.plugins.scope.globalDesc"}],Re={local:"settings.plugins.scope.local",project:"settings.plugins.scope.project",global:"settings.plugins.scope.global",invocation:"settings.plugins.scope.invocation",default:"settings.plugins.scope.default"};function jt(){const t=ce(),g=be(a=>{var v;return(v=a.currentSessionRef)==null?void 0:v.projectPath}),k=be(a=>a.selectedProjectPath),b=n.useMemo(()=>g??k??new URLSearchParams(window.location.search).get("project")??"",[k,g]),[l,U]=n.useState([]),[L,D]=n.useState([]),[y,i]=n.useState(ft),[M,o]=n.useState(!1),[f,R]=n.useState(""),[c,E]=n.useState(""),[m,N]=n.useState(""),[K,h]=n.useState(""),[x,O]=n.useState(!1),[A,I]=n.useState(null),[P,r]=n.useState(null),[u,Y]=n.useState(""),[z,Q]=n.useState(""),[G,_]=n.useState(!1),[J,w]=n.useState(null),[S,B]=n.useState("local"),V=n.useRef(0),q=n.useRef(b);q.current=b;const le=K===b?l:[],d=K===b?L:[],F=n.useCallback(async()=>{const a=++V.current;if(!b){U([]),h(""),r(null);return}O(!0),r(null);try{const[v,X,H]=await Promise.all([$(`/plugins?projectPath=${encodeURIComponent(b)}`),$(`/plugins/catalog?projectPath=${encodeURIComponent(b)}`),$(`/plugins/policy?projectPath=${encodeURIComponent(b)}`)]);if(a!==V.current)return;U(v),D(X),i(H.policy),o(H.environmentRequiresSha),R(H.policy.allowedGitHosts.join(", ")),E(H.policy.allowedMarketplaces.join(", ")),N(H.policy.allowedLocalRoots.join(", ")),h(b)}catch(v){if(a!==V.current)return;r(v instanceof Error?v.message:t("settings.plugins.loadFailed"))}finally{a===V.current&&O(!1)}},[b,t]);n.useEffect(()=>(F(),()=>{V.current+=1}),[F]);const se=async(a,v)=>{const X=b;I(a.name),r(null);try{await $(`/plugins/${encodeURIComponent(a.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:X,enabled:v,scope:S})}),q.current===X&&await F()}catch(H){q.current===X&&r(H instanceof Error?H.message:t("settings.plugins.updateFailed"))}finally{I(null)}},xe=a=>[...new Set(a.split(",").map(v=>v.trim()).filter(Boolean))],pe=async()=>{await ee("policy:save",()=>$("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:b,scope:"local",policy:{...y,allowedGitHosts:xe(f),allowedMarketplaces:xe(c),allowedLocalRoots:xe(m)}})}))},ee=async(a,v,X)=>{const H=b;I(a),r(null);try{await v(),q.current===H&&(X==null||X(),w(null),await F())}catch(oe){q.current===H&&r(oe instanceof Error?oe.message:t("settings.plugins.actionFailed"))}finally{I(null)}},me=async()=>{const a=u.trim();!a||!G||await ee("install",()=>$("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:b,source:a,trust:!0})}),()=>{Y(""),_(!1)})},je=async a=>{const v=`update:${a.name}`;if(J!==v){w(v);return}await ee(v,()=>$(`/plugins/${encodeURIComponent(a.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:b,trust:!0})}))},ae=async a=>{const v=`uninstall:${a.name}`;if(J!==v){w(v);return}await ee(v,()=>$(`/plugins/${encodeURIComponent(a.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:b,confirm:!0})}))},Pe=async()=>{const a=z.trim();a&&await ee("marketplace:add",()=>$("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:b,source:a})}),()=>Q(""))},ge=async a=>{await ee(`marketplace:refresh:${a.name}`,()=>$(`/plugins/marketplaces/${encodeURIComponent(a.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:b})}))},re=async a=>{const v=`marketplace:remove:${a.name}`;if(J!==v){w(v);return}await ee(v,()=>$(`/plugins/marketplaces/${encodeURIComponent(a.name)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:b,confirm:!0})}))};return b?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(rt,{className:"h-4 w-4"}),t("settings.plugins.heading"),x&&e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:b}),e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:t("settings.plugins.changesNote")})]}),e.jsxs("button",{type:"button",onClick:()=>void F(),disabled:x||A!==null,"aria-label":t("settings.plugins.reloadAria"),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(fe,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]})]}),P&&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:P}),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(Ae,{className:"h-3.5 w-3.5"}),t("settings.plugins.sourcePolicy")]}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.savePolicyAria"),onClick:()=>void pe(),disabled:A!==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:t(A==="policy:save"?"settings.plugins.saving":"settings.plugins.saveForProject")})]}),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":t("settings.plugins.restrictAria"),"aria-checked":y.restrictToAllowedSources,onClick:()=>i(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",y.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",y.restrictToAllowedSources&&"translate-x-2.5")})}),t("settings.plugins.restrictAllowlists")]}),e.jsxs("button",{type:"button",role:"switch","aria-label":t("settings.plugins.requireShaAria"),"aria-checked":y.requireGitCommitSha,disabled:M,onClick:()=>i(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",y.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",y.requireGitCommitSha&&"translate-x-2.5")})}),t("settings.plugins.requireSha"),M?t("settings.plugins.environmentLocked"):""]})]}),e.jsxs("div",{className:"mt-2 grid gap-1.5 sm:grid-cols-3",children:[e.jsx("input",{"aria-label":t("settings.plugins.gitHostsAria"),value:f,onChange:a=>R(a.target.value),placeholder:"github.com, *.corp.test",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.marketplacesAria"),value:c,onChange:a=>E(a.target.value),placeholder:"team-market, official",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.localRootsAria"),value:m,onChange:a=>N(a.target.value),placeholder:"/opt/approved/plugins",className:"field h-7 px-2 text-[9.5px]"})]}),y.restrictToAllowedSources&&!f.trim()&&!c.trim()&&!m.trim()&&e.jsx("p",{className:"mt-1.5 text-[9px] text-amber-700 dark:text-amber-400",children:t("settings.plugins.emptyAllowlists")})]}),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(Te,{className:"h-3.5 w-3.5"}),t("settings.plugins.installHeading")]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("input",{"aria-label":t("settings.plugins.sourceAria"),value:u,onChange:a=>Y(a.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:A!==null,className:"field h-8 min-w-0 flex-1 px-2 text-[10.5px]"}),e.jsxs("button",{type:"button",onClick:()=>void me(),disabled:!u.trim()||!G||A!==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:[A==="install"?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Te,{className:"h-3.5 w-3.5"}),t("settings.plugins.install")]})]}),e.jsxs("button",{type:"button",role:"checkbox","aria-checked":G,onClick:()=>_(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",G?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:G?"✓":""}),t("settings.plugins.trustSource")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.plugins.activationScope")}),e.jsx("div",{className:"mt-0.5 text-[9px] text-[#9CA3AF]",children:t("settings.plugins.activationScopeHint")})]}),e.jsx("div",{role:"radiogroup","aria-label":t("settings.plugins.scopeAria"),className:"flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]",children:yt.map(a=>e.jsx("button",{type:"button",role:"radio","aria-checked":S===a.value,title:t(a.descriptionKey),onClick:()=>B(a.value),className:T("rounded px-2 py-1 text-[9.5px] transition-colors",S===a.value?"bg-white font-semibold text-[#111827] shadow-sm dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#71717a] hover:text-[#374151] dark:hover:text-[#d4d4d8]"),children:t(a.labelKey)},a.value))})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[le.map(a=>{var oe;const v=A===a.name,X=[a.commands?t("settings.plugins.capability.commands",{count:a.commands}):"",a.skills?t("settings.plugins.capability.skills",{count:a.skills}):"",a.agents?t("settings.plugins.capability.agents",{count:a.agents}):"",a.hooks?t("settings.plugins.capability.hooks",{count:a.hooks}):"",a.mcpServers?t("settings.plugins.capability.mcp",{count:a.mcpServers}):""].filter(Boolean),H=["global","project","local","invocation"].filter(te=>{var he;return((he=a.settingLayers)==null?void 0:he[te])!==void 0}).map(te=>`${t(Re[te])} ${t(a.settingLayers[te]?"settings.plugins.layer.on":"settings.plugins.layer.off")}`);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("span",{className:"rounded bg-sky-50 px-1.5 py-0.5 text-[9px] text-sky-700 dark:bg-sky-950/40 dark:text-sky-300",children:t("settings.plugins.effective",{scope:t(Re[a.effectiveScope])})})]}),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:X.join(" · ")||t("settings.plugins.noResources")}),H.length>0&&e.jsx("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:H.join(" · ")}),a.managed&&e.jsxs("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:[t("settings.plugins.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:t("settings.plugins.invocationScoped")}),(oe=a.compatibilityIssues)==null?void 0:oe.map(te=>e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:te.message},`${te.code}:${te.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"?t("settings.plugins.unavailableAria",{name:a.name}):a.enabled?t("settings.plugins.disableAria",{name:a.name}):t("settings.plugins.enableAria",{name:a.name}),"aria-checked":a.enabled,disabled:a.status==="error"||!a.configurable||v||A!==null,onClick:()=>void se(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":t("settings.plugins.updateAria",{name:a.name}),onClick:()=>void je(a),disabled:A!==null,className:T("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",J===`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:A===`update:${a.name}`?e.jsx(Z,{className:"h-3 w-3 animate-spin"}):J===`update:${a.name}`?t("settings.plugins.confirmUpdate"):t("settings.plugins.update")}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.uninstallAria",{name:a.name}),onClick:()=>void ae(a),disabled:A!==null,className:T("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",J===`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:A===`uninstall:${a.name}`?e.jsx(Z,{className:"h-3 w-3 animate-spin"}):J===`uninstall:${a.name}`?t("settings.plugins.confirmRemove"):e.jsx(ye,{className:"h-3 w-3"})})]})]})]},a.name)}),!x&&le.length===0&&!P&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.plugins.empty")})]}),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(ot,{className:"h-3.5 w-3.5"}),t("settings.plugins.marketplaces")]}),e.jsx("span",{className:"text-[9px] text-[#9CA3AF]",children:t("settings.plugins.configuredCount",{count:d.length})})]}),e.jsxs("div",{className:"flex gap-2 border-b border-[#E5E7EB] p-2 dark:border-[#27272a]",children:[e.jsx("input",{"aria-label":t("settings.plugins.marketplaceSourceAria"),value:z,onChange:a=>Q(a.target.value),placeholder:"owner/repo, HTTPS Git URL, or ./path",disabled:A!==null,className:"field h-7 min-w-0 flex-1 px-2 text-[10px]"}),e.jsxs("button",{type:"button","aria-label":t("settings.plugins.addMarketplaceAria"),onClick:()=>void Pe(),disabled:!z.trim()||A!==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:[A==="marketplace:add"?e.jsx(Z,{className:"h-3 w-3 animate-spin"}):e.jsx(it,{className:"h-3 w-3"}),t("settings.plugins.add")]})]}),d.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||t("settings.plugins.noDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.refreshMarketplaceAria",{name:a.name}),disabled:A!==null,onClick:()=>void ge(a),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:A===`marketplace:refresh:${a.name}`?e.jsx(Z,{className:"h-3 w-3 animate-spin"}):e.jsx(fe,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.removeMarketplaceAria",{name:a.name}),disabled:A!==null,onClick:()=>void re(a),className:T("rounded p-1 text-[#9CA3AF] disabled:opacity-40",J===`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:J===`marketplace:remove:${a.name}`?e.jsx("span",{className:"px-1 text-[8.5px]",children:t("settings.plugins.confirm")}):e.jsx(ye,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[a.plugins.slice(0,12).map(v=>e.jsxs("button",{type:"button",disabled:v.installed||A!==null,onClick:()=>{Y(`${v.name}@${a.name}`),_(!1)},title:v.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:[v.name,v.installed?t("settings.plugins.installedSuffix"):""]},v.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)),!x&&d.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-[10px] text-[#9CA3AF]",children:t("settings.plugins.marketplaceEmpty")})]})]}):e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.plugins.selectProject")})}const vt={not_required:"settings.trust.state.notRequired",trusted:"settings.trust.state.trusted",untrusted:"settings.trust.state.review",error:"settings.trust.state.error"};function kt(){const t=ce(),g=be(P=>{var r;return(r=P.currentSessionRef)==null?void 0:r.projectPath}),k=n.useMemo(()=>g??new URLSearchParams(window.location.search).get("project")??"",[g]),[b,l]=n.useState(null),[U,L]=n.useState(""),[D,y]=n.useState(!1),[i,M]=n.useState(null),[o,f]=n.useState(null),[R,c]=n.useState(null),[E,m]=n.useState(!1),N=n.useRef(0),K=n.useRef(k);K.current=k;const h=U===k?b:null,x=n.useCallback(async()=>{const P=++N.current;if(!k){l(null),L(""),c(null);return}y(!0),c(null);try{const r=await $(`/workspace-trust?projectPath=${encodeURIComponent(k)}`);if(P!==N.current)return;l(r),L(k)}catch(r){if(P!==N.current)return;c(r instanceof Error?r.message:t("settings.trust.loadFailed"))}finally{P===N.current&&y(!1)}},[k,t]);n.useEffect(()=>(f(null),m(!1),x(),()=>{N.current+=1}),[x]);const O=async P=>{if(!h)return;const r=k;M(P),c(null);try{const u=await $("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:r,action:P})});K.current===r&&(l(u),L(r),f(null),m(u.reloadRequired===!0))}catch(u){K.current===r&&c(u instanceof Error?u.message:t("settings.trust.updateFailed"))}finally{M(null)}};if(!k)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.trust.selectSession")});const A=(h==null?void 0:h.state)==="trusted",I=(h==null?void 0:h.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:[A?e.jsx(Ae,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Oe,{className:T("h-4 w-4",I?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(h?vt[h.state]:"settings.trust.heading")}),D&&e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:k}),h&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[h.decision,h.inheritedFrom?t("settings.trust.inheritedFrom",{source:h.inheritedFrom}):""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void x(),disabled:D||i!==null,"aria-label":t("settings.trust.reloadAria"),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(fe,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),A?e.jsx("button",{type:"button",onClick:()=>f("revoke"),disabled:i!==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:t("settings.trust.revoke")}):e.jsx("button",{type:"button",onClick:()=>f("trust"),disabled:i!==null||(h==null?void 0:h.state)==="error"||!h||h.sensitiveSources===0,className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:t("settings.trust.trustWorkspace")})]})]}),(R||(h==null?void 0:h.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:R||(h==null?void 0:h.error)}),E&&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:t("settings.trust.restartNotice")}),o&&h&&e.jsxs("div",{role:"alertdialog","aria-label":t(o==="trust"?"settings.trust.trustWorkspace":"settings.trust.revokeAria"),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:o==="trust"?t("settings.trust.confirmTrust",{count:h.sensitiveSources}):t("settings.trust.confirmRevoke")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void O(o),disabled:i!==null,className:T("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",o==="trust"?"bg-emerald-600":"bg-red-600"),children:t(i?"settings.trust.saving":o==="trust"?"settings.trust.trustReviewed":"settings.trust.revokeTrust")})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((h==null?void 0:h.sources)??[]).map(P=>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:P.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:P.kind})]}),P.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:P.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:P.effects.map((r,u)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:r.kind})," · ",r.name,r.target?` → ${r.target}`:""]},`${r.kind}-${r.name}-${u}`))})]},`${P.kind}-${P.path}`)),h&&h.sources.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.trust.empty")})]})]})}const Nt={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}},Et={searchTasks:"settings.shortcuts.action.searchTasks",openCommands:"settings.shortcuts.action.openCommands",newTask:"settings.shortcuts.action.newTask",focusComposer:"settings.shortcuts.action.focusComposer",toggleSidebar:"settings.shortcuts.action.toggleSidebar"},Ke={auto:"settings.style.auto",pragmatic:"settings.style.pragmatic",friendly:"settings.style.friendly",explanatory:"settings.style.explanatory"},$e={Global:"settings.shortcuts.scope.global",Chat:"settings.shortcuts.scope.chat",Layout:"settings.shortcuts.scope.layout"};function Pt(){var Be,Me;const t=ce(),{locale:g}=Xe(),{isSettingsOpen:k,settingsSection:b,toggleSettings:l,isSidebarOpen:U,setSidebarOpen:L}=ve(),{configuredModels:D,loadModels:y,isLoading:i,error:M}=Ze(),o=et(),[f,R]=n.useState("general"),[c,E]=n.useState(!1),[m,N]=n.useState(null),[K,h]=n.useState(null),[x,O]=n.useState(null),[A,I]=n.useState([]),[P,r]=n.useState(null),[u,Y]=n.useState(null),[z,Q]=n.useState(null),[G,_]=n.useState(null),[J,w]=n.useState({}),[S,B]=n.useState(null),[V,q]=n.useState(null),[le,d]=n.useState(""),[F,se]=n.useState("all"),xe=n.useRef(null),pe=n.useRef(null),ee=n.useRef(0),[me,je]=n.useState(typeof Notification>"u"?"unsupported":Notification.permission),ae=[{value:"general",label:t("settings.tab.general"),category:t("settings.category.settings")},{value:"trust",label:t("settings.tab.trust"),category:t("settings.category.settings")},{value:"models",label:t("settings.tab.models"),category:t("settings.category.settings")},{value:"shortcuts",label:t("settings.tab.shortcuts"),category:t("settings.category.settings")},{value:"mcp",label:t("settings.tab.mcp"),category:t("settings.category.integrations")},{value:"skills",label:t("settings.tab.skills"),category:t("settings.category.integrations")},{value:"plugins",label:t("settings.tab.plugins"),category:t("settings.category.integrations")},{value:"hooks",label:t("settings.tab.hooks"),category:t("settings.category.integrations")}],ge=n.useMemo(()=>tt.map(s=>({action:t(Et[s.id]),combo:st(s),scope:s.scope})),[g]).filter(s=>{const p=s.action.toLowerCase().includes(le.toLowerCase()),j=F==="all"||s.scope.toLowerCase()===F;return p&&j}),re=D.reduce((s,p)=>{const j=p.provider||"unknown";return s[j]||(s[j]=[]),s[j].push(p),s},{}),a=new Map(A.map(s=>[s.id,s]));for(const s of A)s.custom&&!re[s.id]&&(re[s.id]=[]);const v=n.useCallback(async()=>{try{I(await $("/providers")),_(null)}catch(s){_(s instanceof Error?s.message:t("settings.models.loadChannelsFailed"))}},[t]);n.useEffect(()=>{k&&(R(b),y(),v(),o.loadSettings())},[k,y,v,o.loadSettings,b]);const X=()=>{const s=pe.current,p=s!=null&&s.isConnected?s:document.querySelector("[data-settings-trigger]");p==null||p.focus({preventScroll:!0})},H=()=>{l(),requestAnimationFrame(X)};n.useLayoutEffect(()=>{if(!k)return;const s=document.activeElement instanceof HTMLElement?document.activeElement:null;s&&s!==document.body&&s!==document.documentElement&&!s.closest("[data-settings-panel]")&&(pe.current=s);const p=requestAnimationFrame(()=>{var j;(j=xe.current)==null||j.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(p),requestAnimationFrame(X)}},[k]);const oe=async s=>{B("save"),q(null);try{return await $("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s.provider,displayName:s.displayName,model:s.model,apiKey:s.apiKey,modelProvider:s.modelProvider,overrides:s.overrides})}),await y(),await v(),!0}catch(p){return q(p instanceof Error?p.message:t("settings.models.saveFailed")),!1}finally{B(null)}},te=async()=>{typeof Notification>"u"||je(await Notification.requestPermission())},he=async s=>{B("delete"),q(null);try{await $(`/models/${s}`,{method:"DELETE"}),await y(),O(null)}catch(p){q(p instanceof Error?p.message:t("settings.models.deleteFailed"))}finally{B(null)}},Ue=async(s,p)=>{B("update"),q(null);try{return await $(`/models/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)}),await y(),!0}catch(j){return q(j instanceof Error?j.message:t("settings.models.updateFailed")),!1}finally{B(null)}},Ie=async(s,p)=>{Q({providerId:s,type:"update"}),_(null);try{return await $(`/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)}),await Promise.all([y(),v()]),!0}catch(j){return _(j instanceof Error?j.message:t("settings.models.updateChannelFailed")),!1}finally{Q(null)}},ze=async(s,p)=>{Q({providerId:s.id,type:"probe"}),_(null);try{const j=await $(`/providers/${s.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:p})});w(C=>({...C,[s.id]:j}))}catch(j){_(j instanceof Error?j.message:t("settings.models.probeFailed"))}finally{Q(null)}},_e=async s=>{Q({providerId:s.id,type:"delete"}),_(null);try{await $(`/providers/${s.id}?removeModels=true`,{method:"DELETE"}),Y(null),N(null),w(p=>{const j={...p};return delete j[s.id],j}),await Promise.all([y(),v()])}catch(p){_(p instanceof Error?p.message:t("settings.models.deleteChannelFailed"))}finally{Q(null)}},qe=(s,p)=>{var ue,ne;const j=s.key==="ArrowRight"||s.key==="ArrowDown"?1:s.key==="ArrowLeft"||s.key==="ArrowUp"?-1:0;if(j===0&&s.key!=="Home"&&s.key!=="End")return;s.preventDefault();const C=s.key==="Home"?0:s.key==="End"?ae.length-1:(p+j+ae.length)%ae.length;R(ae[C].value),(ne=(ue=s.currentTarget.closest('[role="tablist"]'))==null?void 0:ue.querySelectorAll('[role="tab"]')[C])==null||ne.focus()},He=s=>{N(m===s?null:s)},Ge=s=>{if(!k||s.key!=="Escape"||!(s.target instanceof Node)||!s.currentTarget.contains(s.target)||c||K||P||Date.now()-ee.current<250)return;const p=s.target instanceof Element?s.target:null;if(!(s.defaultPrevented||p!=null&&p.closest('[role="dialog"]'))){if(s.preventDefault(),x){O(null);return}if(u){Y(null);return}H()}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-settings-panel":!0,onKeyDown:Ge,className:"flex h-full min-h-0 bg-white dark:bg-[#09090b]",children:[e.jsxs("nav",{role:"tablist","aria-label":t("settings.nav.aria"),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:xe,type:"button",onClick:H,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(dt,{className:"h-3.5 w-3.5"}),t("settings.action.back")]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-3 pb-4",children:Object.entries(ae.reduce((s,p)=>(s[p.category]||(s[p.category]=[]),s[p.category].push(p),s),{})).map(([s,p])=>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:s}),p.map(j=>e.jsx("button",{onClick:()=>R(j.value),onKeyDown:C=>qe(C,ae.indexOf(j)),role:"tab",id:`settings-tab-${j.value}`,"aria-controls":`settings-panel-${j.value}`,"aria-selected":f===j.value,tabIndex:f===j.value?0:-1,className:T("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",f===j.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:j.label},j.value))]},s))})]}),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:((Be=ae.find(s=>s.value===f))==null?void 0:Be.label)??t("settings.title")}),o.isLoading&&f==="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(Z,{className:"h-3.5 w-3.5 animate-spin"}),t("settings.general.loading")]}),o.error&&f==="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(ke,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:o.error}),e.jsx("button",{type:"button",onClick:()=>void o.loadSettings(),className:"shrink-0 underline",children:t("settings.common.retry")})]}),f==="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:t("settings.models.description")}),(M||V||G)&&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(ke,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:G||V||M}),e.jsx("button",{type:"button",onClick:()=>{q(null),_(null),M&&y()},className:"shrink-0 underline",children:t(M?"settings.common.retry":"settings.common.dismiss")})]}),x&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteModelAria",{name:x.displayName||x.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.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:t("settings.models.deleteModelPrompt",{name:x.displayName||x.model})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>O(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void he(x.id),disabled:S!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:t(S==="delete"?"settings.models.deleting":"settings.models.deleteModel")})]})]}),u&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteChannelAria",{name:u.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.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:t("settings.models.deleteChannelPrompt",{name:u.name,count:((Me=re[u.id])==null?void 0:Me.length)??0})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Y(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void _e(u),disabled:z!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(z==null?void 0:z.type)==="delete"?t("settings.models.deleting"):t("settings.models.deleteChannel")})]})]}),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:[i&&D.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(Z,{className:"h-4 w-4 animate-spin"}),t("settings.models.loading")]}),Object.entries(re).map(([s,p])=>{const j=Nt[s]||{bg:"#71717a",label:"?"},C=a.get(s),ue=m===s,ne=J[s],Je=(z==null?void 0:z.providerId)===s&&z.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:()=>He(s),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:j.bg},children:j.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:(C==null?void 0:C.name)??s.replace(/-/g," ")}),e.jsxs("span",{className:"truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[p.length===1?t("settings.models.modelCountOne",{count:p.length}):t("settings.models.modelCountMany",{count:p.length}),C!=null&&C.custom?` · ${C.wireApi}`:""]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[e.jsxs("span",{className:T("text-xs font-mono",(C==null?void 0:C.configured)===!1?"text-amber-600":"text-[#16A34A]"),children:["●"," ",(C==null?void 0:C.configured)===!1?t("settings.models.missingCredential"):t("settings.models.configured")]}),e.jsx(Le,{className:T("h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]",ue&&"rotate-180")})]})]}),(C==null?void 0:C.custom)&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pr-3",children:[e.jsx("button",{type:"button",onClick:()=>{var W;return void ze(C,(W=p[0])==null?void 0:W.id)},disabled:z!==null||p.length===0,"aria-label":t("settings.models.testChannelAria",{name:C.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:Je?e.jsx(Z,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ct,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":C.id,onClick:()=>{_(null),r(C)},disabled:z!==null,"aria-label":t("settings.models.editChannelAria",{name:C.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(De,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>Y(C),disabled:z!==null,"aria-label":t("settings.models.deleteChannelActionAria",{name:C.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(ye,{className:"h-3.5 w-3.5"})})]})]}),ne&&e.jsxs("div",{role:"status",className:T("border-t px-4 py-2 font-mono text-[11px]",ne.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:[ne.message," · ",ne.latencyMs,"ms · ",ne.wireApi]}),ue&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:[(C==null?void 0:C.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:C.id})," ","· ",C.defaultBaseUrl]}),p.map(W=>{var Fe;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:W.displayName||W.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[W.displayName&&`${W.model} · `,((Fe=W.overrides)==null?void 0:Fe.baseUrl)||t("settings.models.defaultEndpoint")]})]}),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":W.id,onClick:()=>{q(null),h(W)},disabled:S!==null,"aria-label":t("settings.models.editModelAria",{name:W.displayName||W.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(De,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>O(W),disabled:S!==null,"aria-label":t("settings.models.deleteModelAria",{name:W.displayName||W.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(ye,{className:"h-3.5 w-3.5"})})]})]},W.id)})]})]},s)}),!i&&!M&&Object.keys(re).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:t("settings.models.empty")})]})}),e.jsx("button",{"data-add-model-trigger":!0,onClick:()=>{q(null),E(!0)},disabled:S!==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:t("settings.models.add")})]}),f==="general"&&e.jsxs("div",{id:"settings-panel-general",role:"tabpanel","aria-labelledby":"settings-tab-general","aria-busy":o.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:t("settings.tab.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:t("settings.general.responseLanguage")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.general.responseLanguageHint")})]}),e.jsx(de,{"aria-label":t("settings.general.responseLanguage"),value:o.language,onChange:s=>o.updateSettings({language:s}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:[{value:"en-US",label:"English (US)"},{value:"zh-CN",label:"简体中文"},{value:"zh-TW",label:"繁體中文"},{value:"ja-JP",label:"日本語"},{value:"ko-KR",label:"한국어"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"},{value:"de-DE",label:"Deutsch"},{value:"pt-BR",label:"Português (BR)"},{value:"ru-RU",label:"Русский"}]})]}),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:t("settings.general.autoSave")}),e.jsx(ie,{label:t("settings.general.autoSave"),enabled:o.autoSaveSessions,onChange:s=>o.updateSettings({autoSaveSessions:s})})]}),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:t("settings.general.communicationStyle")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.general.communicationStyleHint")})]}),e.jsx(de,{"aria-label":t("settings.general.communicationStyle"),value:o.communicationStyle??"auto",onChange:s=>o.updateSettings({communicationStyle:s}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:xt.map(s=>({value:s.id,label:Ke[s.id]?t(Ke[s.id]):s.name}))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.appearance.heading")}),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:t("settings.appearance.theme")}),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(s=>e.jsx("button",{onClick:()=>o.updateSettings({uiTheme:s}),className:T("px-3 py-1 rounded text-[12px] font-mono transition-colors",o.uiTheme===s?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t(s==="dark"?"settings.appearance.theme.dark":s==="light"?"settings.appearance.theme.light":"settings.appearance.theme.system")},s))})]}),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:t("settings.appearance.compactSidebar")}),e.jsx(ie,{label:t("settings.appearance.compactSidebar"),enabled:!U,onChange:s=>L(!s)})]}),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:t("settings.appearance.codeTheme")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.appearance.codeThemeHint")})]}),e.jsx(de,{"aria-label":t("settings.appearance.codeTheme"),value:o.theme,onChange:s=>o.updateSettings({theme:s}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:[{value:"dracula",label:"Dracula"},{value:"monokai",label:"Monokai"},{value:"nord",label:"Nord"},{value:"tokyo-night",label:"Tokyo Night"},{value:"one-dark",label:"One Dark"},{value:"catppuccin",label:"Catppuccin"},{value:"gruvbox",label:"Gruvbox"},{value:"github",label:"GitHub"},{value:"solarized-light",label:"Solarized Light"},{value:"solarized-dark",label:"Solarized Dark"},{value:"ayu-dark",label:"Ayu Dark"},{value:"rose-pine",label:"Rose Pine"},{value:"kanagawa",label:"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:t("settings.notifications.heading")}),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:t("settings.notifications.buildFinished")}),e.jsx(ie,{label:t("settings.notifications.buildFinished"),enabled:o.notifyBuild,onChange:s=>o.updateSettings({notifyBuild:s})})]}),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:t("settings.notifications.errorsOnly")}),e.jsx(ie,{label:t("settings.notifications.errorsOnly"),enabled:o.notifyErrors,onChange:s=>o.updateSettings({notifyErrors:s})})]}),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:t("settings.notifications.systemSounds")}),e.jsx(ie,{label:t("settings.notifications.systemSounds"),enabled:o.notifySounds,onChange:s=>o.updateSettings({notifySounds:s})})]}),(o.notifyBuild||o.notifyErrors)&&me!=="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:t(me==="denied"?"settings.notifications.blocked":me==="unsupported"?"settings.notifications.unavailable":"settings.notifications.enablePrompt")}),me==="default"&&e.jsx("button",{type:"button",onClick:()=>void te(),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:t("settings.common.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:t("settings.privacy.heading")}),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:t("settings.privacy.telemetry")}),e.jsx(ie,{label:t("settings.privacy.telemetry"),enabled:o.privacyTelemetry,onChange:s=>o.updateSettings({privacyTelemetry:s})})]}),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:t("settings.privacy.crash")}),e.jsx(ie,{label:t("settings.privacy.crash"),enabled:o.privacyCrash,onChange:s=>o.updateSettings({privacyCrash:s})})]})]})]}),f==="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":t("settings.shortcuts.searchPlaceholder"),value:le,onChange:s=>d(s.target.value),placeholder:t("settings.shortcuts.searchPlaceholder"),className:"field flex-1 text-[12px]"}),e.jsx(de,{"aria-label":t("settings.shortcuts.col.scope"),value:F,onChange:s=>se(s),className:"w-auto min-w-[120px] text-[12px]",options:[{value:"all",label:t("settings.shortcuts.scope.all")},{value:"global",label:t("settings.shortcuts.scope.global")},{value:"chat",label:t("settings.shortcuts.scope.chat")},{value:"layout",label:t("settings.shortcuts.scope.layout")}]}),e.jsx("button",{onClick:()=>{d(""),se("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:t("settings.shortcuts.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:t("settings.shortcuts.col.action")}),e.jsx("span",{children:t("settings.shortcuts.col.shortcut")}),e.jsx("span",{children:t("settings.shortcuts.col.scope")})]}),ge.map((s,p)=>e.jsxs("div",{className:T("grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",p%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:s.action}),e.jsx("div",{className:"flex items-center gap-1",children:s.combo.map(j=>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:j},j))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:$e[s.scope]?t($e[s.scope]):s.scope})]},`${s.action}-${s.scope}`)),ge.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:t("settings.shortcuts.empty")})]})]}),f==="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:t("settings.mcp.description")}),e.jsx("button",{type:"button",onClick:()=>{ve.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:t("settings.mcp.open")})]}),f==="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:t("settings.skills.description")}),e.jsx("button",{type:"button",onClick:()=>{ve.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:t("settings.skills.open")})]}),f==="hooks"&&e.jsx("div",{id:"settings-panel-hooks",role:"tabpanel","aria-labelledby":"settings-tab-hooks",className:"min-h-0 flex-1",children:e.jsx(bt,{})}),f==="plugins"&&e.jsx("div",{id:"settings-panel-plugins",role:"tabpanel","aria-labelledby":"settings-tab-plugins",className:"min-h-0 flex-1",children:e.jsx(jt,{})}),f==="trust"&&e.jsx("div",{id:"settings-panel-trust",role:"tabpanel","aria-labelledby":"settings-tab-trust",className:"min-h-0 flex-1",children:e.jsx(kt,{})})]})})})]}),c&&e.jsx(ut,{open:!0,onOpenChange:s=>{s||(ee.current=Date.now()),E(s)},onSave:oe,saveError:V}),K&&e.jsx(pt,{open:!0,onOpenChange:s=>{s||(ee.current=Date.now(),h(null))},model:K,onSave:Ue,saveError:V}),P&&e.jsx(gt,{provider:P,onOpenChange:s=>{s||(ee.current=Date.now(),r(null))},onSave:Ie,saveError:G})]})}function ie({label:t,enabled:g,onChange:k}){return e.jsx("button",{type:"button",role:"switch","aria-label":t,"aria-checked":g,onClick:()=>k(!g),className:T("flex h-6 w-11 items-center rounded-full px-1 transition-colors",g?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:T("h-4 w-4 rounded-full transition-transform",g?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{Pt as SettingsModal};
|