blade-code 0.10.7 → 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-vafn0spm.js → chunk-2thg3fq1.js} +1 -1
- package/dist/chunk-2zn5en0w.js +1 -0
- package/dist/{chunk-1v7hpr34.js → chunk-33ave20b.js} +1 -1
- package/dist/chunk-3w1z6fwm.js +1 -0
- package/dist/chunk-43x4qbvt.js +1 -0
- package/dist/{chunk-e9ckf8e7.js → chunk-4h9ff923.js} +1 -1
- package/dist/chunk-52csdk21.js +3 -0
- package/dist/{chunk-ahxc3n3g.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-tp9zk241.js → chunk-7hbw6q6d.js} +1 -1
- package/dist/chunk-7zsyejr1.js +22 -0
- package/dist/{chunk-x3780wpy.js → chunk-8gcg2z3y.js} +16 -16
- package/dist/{chunk-p3ahf1fh.js → chunk-8gcvpmwk.js} +1 -1
- package/dist/{chunk-w01sec4f.js → chunk-8gnfj89a.js} +2 -2
- package/dist/{chunk-7a200q5g.js → chunk-8h0yxh6y.js} +2 -2
- package/dist/chunk-8sfycn3y.js +194 -0
- package/dist/{chunk-847e0sk9.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-tc83e1b0.js → chunk-cbpqcdga.js} +1 -1
- package/dist/{chunk-qycwavck.js → chunk-cf8e7e92.js} +2 -2
- package/dist/{chunk-kqpwz9b7.js → chunk-d0g4t8fw.js} +2 -2
- package/dist/{chunk-1sw9z975.js → chunk-eq2qj9ja.js} +1 -1
- package/dist/{chunk-p0j8994h.js → chunk-fj8v7pep.js} +1 -1
- package/dist/{chunk-tcc3v4n2.js → chunk-fxpq9nh6.js} +1 -1
- package/dist/chunk-g00wj2we.js +4 -0
- package/dist/{chunk-3fdyzgpv.js → chunk-h28ptrrt.js} +1 -1
- package/dist/{chunk-qk2z6gag.js → chunk-h421wzbm.js} +2 -2
- package/dist/{chunk-4hhkbyja.js → chunk-j4tttsaz.js} +2 -2
- package/dist/{chunk-wrbm6rch.js → chunk-kagpk2x5.js} +2 -2
- package/dist/chunk-kvnwhwx3.js +1 -0
- package/dist/{chunk-mt4328yf.js → chunk-m2xrx1je.js} +1 -1
- package/dist/{chunk-g3wgzyhx.js → chunk-nhc49pan.js} +48 -48
- package/dist/{chunk-jpy61wna.js → chunk-nymm525r.js} +1 -1
- package/dist/{chunk-rz9yh6e4.js → chunk-nz57y1ad.js} +3 -3
- package/dist/{chunk-wmdgb5pz.js → chunk-p2m56new.js} +2 -2
- package/dist/{chunk-43j2f1b5.js → chunk-pv9sw79c.js} +1 -1
- package/dist/chunk-qgp08qmz.js +6 -0
- package/dist/{chunk-7pkrwh10.js → chunk-r7tsa2zv.js} +1 -1
- package/dist/{chunk-zjf1z27e.js → chunk-rkvfsx8e.js} +1 -1
- package/dist/{chunk-y573s5r8.js → chunk-rxqft6td.js} +2 -2
- package/dist/{chunk-rn908m3v.js → chunk-s9aj3p11.js} +2 -2
- package/dist/{chunk-0z7q89w7.js → chunk-senkwdh6.js} +1 -1
- package/dist/chunk-v1c58sm6.js +1 -0
- package/dist/{chunk-m86ekqp0.js → chunk-v8pq6qmv.js} +2 -2
- package/dist/chunk-van4ysq6.js +1466 -0
- package/dist/chunk-vgp8m9fg.js +2 -0
- package/dist/{chunk-ne7zdjrh.js → chunk-vsg8f0e6.js} +1 -1
- package/dist/{chunk-0n04bmta.js → chunk-w0nscjd2.js} +2 -2
- package/dist/chunk-w26jhcj9.js +1 -0
- package/dist/{chunk-qqwgb9ja.js → chunk-wmnszjmv.js} +2 -2
- package/dist/chunk-x6wgh726.js +1 -0
- package/dist/{chunk-yyvx1avz.js → chunk-xa05phpw.js} +3 -3
- package/dist/{chunk-0xm8hn2h.js → chunk-xmcsn7y0.js} +2 -2
- package/dist/{chunk-az4b6106.js → chunk-y4c3wwpa.js} +1 -1
- package/dist/{chunk-vcq624qv.js → chunk-yfs9tq3y.js} +2 -2
- package/dist/chunk-ymzcxryf.js +1 -0
- package/dist/{chunk-akev4wsz.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-CC4e9nFc.js → CodeBlockHighlighter-EgdsVoMQ.js} +1 -1
- package/dist/web/assets/{FilePreview-C3HEoLYS.js → FilePreview-xicd9-Sl.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-COycrGUX.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-DqQ-7CTG.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-4rhssb85.js +0 -2
- package/dist/chunk-598egka3.js +0 -22
- package/dist/chunk-5ak9tw83.js +0 -100
- package/dist/chunk-738pkjf8.js +0 -1
- package/dist/chunk-7xfmzvxp.js +0 -1
- package/dist/chunk-867rz2ss.js +0 -1
- package/dist/chunk-a3e97syg.js +0 -3
- package/dist/chunk-f7854pbx.js +0 -187
- package/dist/chunk-fwt0kje3.js +0 -1
- package/dist/chunk-g1q27q6q.js +0 -2
- package/dist/chunk-g4snq0dx.js +0 -1
- package/dist/chunk-ggm04adj.js +0 -1
- package/dist/chunk-hpytxsge.js +0 -1
- package/dist/chunk-htr91q9c.js +0 -1
- package/dist/chunk-hwcp940f.js +0 -1
- package/dist/chunk-j5ysjbyr.js +0 -10
- package/dist/chunk-m8k1mv0j.js +0 -4
- package/dist/chunk-pt659n0v.js +0 -1466
- package/dist/chunk-q1gfeadm.js +0 -1
- package/dist/chunk-rk1w5pry.js +0 -2
- package/dist/chunk-rz2ftt6h.js +0 -5
- package/dist/chunk-tzh4ahry.js +0 -6
- package/dist/chunk-v0rn831t.js +0 -1
- package/dist/chunk-vynsgc2g.js +0 -1
- package/dist/chunk-w0ena7fe.js +0 -9
- package/dist/chunk-ydwjttdz.js +0 -1
- package/dist/chunk-z9fsh3kn.js +0 -1
- package/dist/web/assets/ChatView-BYfHmxKJ.js +0 -7
- package/dist/web/assets/McpModal-CDgr9kVq.js +0 -5
- package/dist/web/assets/SettingsModal-CvdVIbeG.js +0 -1
- package/dist/web/assets/SkillsModal-lSX1ZKTu.js +0 -1
- package/dist/web/assets/TaskSwitcher-peKi9KvN.js +0 -1
- package/dist/web/assets/index-BF5HEN_f.js +0 -32
- package/dist/web/assets/index-BrkTYxtS.css +0 -1
- package/dist/web/assets/useRequest-BvqVDnKl.js +0 -1
|
@@ -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-BF5HEN_f.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-DG5dkZ_t.js";import{e as J}from"./useRequest-BvqVDnKl.js";import{b as ee,a as te,D as U,e as P,G as se,g as M,j as g,x as F,y as ae}from"./index-BF5HEN_f.js";import{i as le,a as ne,X as Q,f as oe,L as W,T as re}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";const O=n=>n?{"x-blade-directory":n}:void 0,de=async n=>F("/skills",{headers:O(n)}),ie=async()=>F("/skills/catalog");function ue(){const{isSkillsOpen:n,toggleSkills:d}=ee(),i=te(t=>{var j,y;return((j=t.currentSessionRef)==null?void 0:j.projectPath)??t.selectedProjectPath??((y=t.taskWorkspaceInfo)==null?void 0:y.cwd)??null}),[x,f]=l.useState(null),[c,h]=l.useState(""),[w,o]=l.useState(null),[r,N]=l.useState(null),[A,m]=l.useState(null),[S,p]=l.useState(!1),[B,b]=l.useState(!1),[I,k]=l.useState("confirm"),[D,v]=l.useState(null),[C,a]=l.useState(null),{data:u=[],loading:E,error:R,run:q,runAsync:$}=J(()=>de(i),{refreshDeps:[n,i],ready:n,onSuccess:t=>{t.length>0&&!x&&f(t[0].id)}}),{data:X=[],loading:K,error:T,run:V}=J(ie,{refreshDeps:[n],ready:n}),z=u.filter(t=>t.name.toLowerCase().includes(c.toLowerCase())),s=l.useMemo(()=>u.find(t=>t.id===x)??u[0],[u,x]),G=async(t,j,y)=>{N({type:t,name:j.name}),o(null);try{await F(t==="delete"?`/skills/${encodeURIComponent(j.name)}`:`/skills/${encodeURIComponent(j.name)}/toggle`,{method:t==="delete"?"DELETE":"POST",headers:{...O(i),...t==="toggle"?{"Content-Type":"application/json"}:{}},body:t==="toggle"?JSON.stringify({enabled:y}):void 0}),await $(),t==="delete"&&(m(null),f(null))}catch(H){o(H instanceof Error?H.message:`Failed to ${t} skill`)}finally{N(null)}},Y=()=>{p(!0)},Z=t=>{a(t),v(null),k("confirm"),b(!0)},_=async()=>{if(C){k("installing"),v(null);try{const t=await F("/skills/install",{method:"POST",headers:{"Content-Type":"application/json",...O(i)},body:JSON.stringify(C)});if(t.success===!1)throw new Error(t.error||"Failed to install skill");await $(),b(!1),p(!1)}catch(t){v(t instanceof Error?t.message:"Failed to install skill"),k("failed")}}};return e.jsxs(l.Fragment,{children:[e.jsx(U,{open:n,onOpenChange:d,children:e.jsxs(P,{onCloseAutoFocus:se,className:"flex h-[min(620px,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-[820px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(M,{className:"sr-only",children:"Skills"}),e.jsx("div",{className:"flex h-full min-h-0 min-w-0",children:e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 p-4 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{"data-skill-install-trigger":!0,onClick:Y,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(le,{className:"h-3.5 w-3.5"}),"Install skill"]}),e.jsx("button",{onClick:q,"aria-label":"Refresh skills",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:E,children:e.jsx(ne,{className:g("h-4 w-4",E&&"animate-spin")})}),e.jsx("button",{onClick:d,"aria-label":"Close skills",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(Q,{className:"h-4 w-4"})})]})]}),w&&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(oe,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:w}),e.jsx("button",{type:"button",onClick:()=>o(null),className:"shrink-0 underline",children:"Dismiss"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden 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("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Installed"}),e.jsx("input",{type:"search","aria-label":"Search installed skills",value:c,onChange:t=>h(t.target.value),placeholder:"Search skills...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[E&&u.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(W,{className:"h-4 w-4 animate-spin"}),"Loading skills..."]}),R&&!E&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:R.message}),e.jsx("button",{type:"button",onClick:q,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!R&&z.length===0&&!E&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:c?"No skills match your search":"No skills installed"}),z.map(t=>e.jsxs("button",{onClick:()=>{f(t.id),m(null),o(null)},className:g("flex w-full min-w-0 flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",t.id===x?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:g("text-[11px] font-mono font-semibold",t.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:t.enabled?"Enabled":"Disabled"})]}),e.jsx("span",{className:"block w-full min-w-0 truncate text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:t.description||"No description"})]},t.id))]})]}),s?e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:s.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",s.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:s.description||"No description available"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void G("toggle",s,!s.enabled),disabled:r!==null,className:g("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",s.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",r&&"opacity-60 cursor-not-allowed"),children:(r==null?void 0:r.type)==="toggle"&&r.name===s.name?"Saving...":s.enabled?"Disable":"Enable"}),e.jsxs("button",{onClick:()=>m(s.name),disabled:!s.removable||r!==null,title:s.removable?void 0:"Only Blade user skills can be uninstalled",className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(re,{className:"h-3 w-3"}),s.removable?"Uninstall":"Managed"]})]}),A===s.name&&e.jsxs("div",{role:"alertdialog","aria-label":`Uninstall ${s.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:"Remove this skill from ~/.blade/skills?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>m(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 G("delete",s),disabled:r!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(r==null?void 0:r.type)==="delete"?"Uninstalling...":"Uninstall skill"})]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Provider"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:s.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Location"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:s.location})]})]}),s.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Capabilities"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.capabilities.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))})]}),s.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Allowed Tools (",s.allowedTools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.allowedTools.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("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a skill to view details"})})]})]})})]})}),e.jsx(xe,{open:S,catalog:X,installed:u.map(t=>t.name),catalogLoading:K,catalogError:(T==null?void 0:T.message)??null,onRetryCatalog:V,onOpenChange:p,onInstall:Z}),e.jsx(ce,{open:B,status:I,error:D,onCancel:()=>b(!1),onConfirm:_,onRetry:()=>k("confirm")})]})}function L({active:n,children:d,onClick:i}){return e.jsx("button",{onClick:i,className:g("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:d})}function xe({open:n,onOpenChange:d,onInstall:i,catalog:x,installed:f,catalogLoading:c,catalogError:h,onRetryCatalog:w}){const[o,r]=l.useState("catalog"),[N,A]=l.useState(""),[m,S]=l.useState(null),[p,B]=l.useState(""),[b,I]=l.useState(""),k=x.filter(a=>a.name.toLowerCase().includes(N.toLowerCase())),D=()=>{if(o==="catalog"){if(!m)return;i({source:"catalog",name:m});return}if(o==="repo"){if(!p)return;i({source:"repo",url:p});return}b&&i({source:"local",path:b})},v=m?f.includes(m):!1,C=o==="catalog"&&(!m||v||c||!!h)||o==="repo"&&!p||o==="local"&&!b;return e.jsx(U,{open:n,onOpenChange:d,children:e.jsxs(P,{onCloseAutoFocus:a=>ae("[data-skill-install-trigger]",a),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(M,{className:"sr-only",children:"Install Skill"}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install Skill"}),e.jsx("button",{onClick:()=>d(!1),"aria-label":"Close skill 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(Q,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(L,{active:o==="catalog",onClick:()=>r("catalog"),children:"Catalog"}),e.jsx(L,{active:o==="repo",onClick:()=>r("repo"),children:"Repo"}),e.jsx(L,{active:o==="local",onClick:()=>r("local"),children:"Local"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[o==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{"aria-label":"Search skill catalog",value:N,onChange:a=>A(a.target.value),placeholder:"Search catalog...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex max-h-[min(240px,30dvh)] flex-col gap-2 overflow-y-auto",children:[c&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-6 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(W,{className:"h-4 w-4 animate-spin"}),"Loading catalog..."]}),h&&!c&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",onClick:w,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!c&&!h&&k.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills found"}),!c&&!h&&k.map(a=>{const u=f.includes(a.name),E=m===a.name;return e.jsxs("button",{onClick:()=>S(a.name),className:g("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",E?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),e.jsx("span",{className:g("text-[10px] font-mono px-2 py-0.5 rounded",a.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:a.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:a.description}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["by ",a.author]}),u&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:"Installed"})]},a.name)})]})]}),o==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"GitHub URL"}),e.jsx("input",{"aria-label":"Skill repository URL",value:p,onChange:a=>B(a.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Uses Git credentials available to the Blade process"})]}),o==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Local path"}),e.jsx("input",{"aria-label":"Local skill path",value:b,onChange:a=>I(a.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>d(!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:D,disabled:C,className:g("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",C?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:"Install"})]})]})]})})}function ce({open:n,status:d,error:i,onCancel:x,onConfirm:f,onRetry:c}){return e.jsx(U,{open:n,onOpenChange:h=>!h&&x(),children:e.jsxs(P,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(M,{className:"sr-only",children:"Install Status"}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[d==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Confirm Install"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Install selected skill?"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:x,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:f,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Install"})]})]}),d==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Installing"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Downloading and verifying…"}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:x,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Hide"})]}),d==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Install Failed"}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:i||"Installation failed."}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Check access and try again."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:x,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Close"}),e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Retry"})]})]})]})]})})}export{ue as SkillsModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as n,r as d}from"./vendor-react-DG5dkZ_t.js";import{j as S,H as De,d as U,c as R,I as Ae,J as E,L as _,M as Ie,u as Fe,b as m,a as o,N as L,r as Le,D as Pe,e as Re,G as Ee,g as Me,h as qe,s as Be}from"./index-BF5HEN_f.js";import{ac as he,i as Ke,F as Oe,j as $e,h as Qe,ad as We,ae as He,o as ze,af as Ge,ag as Ue,k as G,f as ue,ah as _e,Q as Je,ai as Ve,G as Xe,aj as Ye,L as P,S as Ze,R as et}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";function tt(t,r){const s=r.trim().toLocaleLowerCase();return s?t.filter(i=>`${i.label} ${i.description} ${i.keywords}`.toLocaleLowerCase().includes(s)):t}function nt({actions:t,selectedIndex:r,onSelect:s,onRun:i}){return t.map((c,h)=>{const k=h===r,u=c.icon;return n.jsx("div",{id:`command-center-result-${h}`,"data-task-result-index":h,role:"option","aria-selected":k,onMouseEnter:()=>s(h),className:S("group flex min-h-[58px] w-full items-center rounded-lg border border-transparent text-left transition-colors",k?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:n.jsxs("button",{type:"button",onClick:()=>i(c),className:"flex min-h-[58px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-accent))]",children:n.jsx(u,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:c.label}),n.jsx("span",{className:"mt-0.5 block truncate text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:c.description})]}),c.shortcut&&n.jsx("span",{className:"shrink-0 rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:c.shortcut}),n.jsx(he,{className:S("h-3.5 w-3.5 shrink-0 transition-all",k?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]})},c.id)})}const st={running:"running active 进行中 运行中",queued:"queued waiting 排队中 等待中",interrupted:"interrupted paused 已暂停 已中断",failed:"failed error 已失败 错误",cancelled:"cancelled canceled 已取消",completed:"completed done finished 已完成 完成"};function J(t){return Ae(t,Ie)}function at(t){const r=t.lastMessageTime||t.firstMessageTime;if(!r)return"";const s=new Date(r);return Number.isNaN(s.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}function M(t){return t.normalize("NFKC").toLocaleLowerCase().trim()}function rt(t,r){var i,c;const s=E(t,r);return M([J(t),_(s),s,t.projectPath,t.gitBranch,t.taskWorktreeBranch,t.taskStatus,st[t.taskStatus],((i=t.pendingInteraction)==null?void 0:i.type)==="question"?"needs answer question attention 等待回答 需要回答":((c=t.pendingInteraction)==null?void 0:c.type)==="elicitation"?"mcp input elicitation attention MCP 输入 等待输入":t.pendingInteraction?"needs approval permission attention 等待审批 需要授权":"",t.sessionId].filter(Boolean).join(" "))}function pe(t,r,s){if(!r)return 0;const i=M(J(t)),c=M(_(E(t,s)));return i===r?500:i.startsWith(r)?400:i.includes(r)?300:c===r?250:c.startsWith(r)?200:100}function it(t,r,s,i=50){const c=M(r),h=c.split(/\s+/).filter(Boolean),k=new Set;return t.filter(u=>{if(h.length===0)return!0;const p=rt(u,s);return h.every(g=>p.includes(g))}).sort((u,p)=>{const g=+!!p.pendingInteraction-+!!u.pendingInteraction;return g!==0?g:pe(p,c,s)-pe(u,c,s)||De(u,p)}).filter(u=>{const p=U(R(u));return k.has(p)?!1:(k.add(p),!0)}).slice(0,i)}const ct={running:"sidebar.group.running",queued:"sidebar.group.queued",interrupted:"sidebar.group.interrupted",failed:"sidebar.group.failed",cancelled:"sidebar.group.cancelled",completed:"sidebar.group.done"};function ut(){const t=Fe(),r=m(e=>e.isTaskSwitcherOpen),s=m(e=>e.taskSwitcherMode),i=m(e=>e.setTaskSwitcherOpen),c=m(e=>e.setTaskSwitcherMode),h=m(e=>e.toggleSidebar),k=m(e=>e.isFilePreviewOpen),u=m(e=>e.setFilePreviewOpen),p=m(e=>e.openFilePreview),g=m(e=>e.toggleTerminal),N=m(e=>e.openSettings),V=m(e=>e.toggleMcp),X=m(e=>e.toggleSkills),b=o(e=>e.sessions),ke=o(e=>e.isLoading),C=o(e=>e.catalogLoadState),q=C==="loading"||C==="hydrating",B=o(e=>e.currentSessionRef),Y=o(e=>e.isTemporarySession),Z=o(e=>e.startTemporarySession),K=o(e=>e.unreadTaskKeys),xe=o(e=>e.boundProjects),A=o(e=>{var a;return e.selectedProjectPath??((a=e.taskWorkspaceInfo)==null?void 0:a.cwd)??null}),fe=o(e=>e.selectProject),ge=o(e=>e.selectSession),be=o(e=>e.cancelTask),ve=o(e=>e.retryTask),we=o(e=>e.cancellingTaskKeys),ye=o(e=>e.retryingTaskKeys),[v,ee]=d.useState(""),[f,y]=d.useState(0),[je,O]=d.useState(null),[te,I]=d.useState(null),ne=d.useRef(null),se=d.useRef(null),ae=d.useMemo(()=>[{id:"new-task",label:t("commandCenter.action.newTask"),description:t("commandCenter.action.newTaskDescription"),keywords:"create compose session",icon:Ke,shortcut:L("newTask"),run:()=>{Z(),requestAnimationFrame(()=>Le())}},{id:"toggle-preview",label:t("commandCenter.action.preview"),description:t("commandCenter.action.previewDescription"),keywords:"diff files logs artifact review",icon:Oe,run:()=>{k?u(!1):p((!B||Y)&&m.getState().previewRequestId===0?{tab:"files"}:void 0)}},{id:"toggle-terminal",label:t("commandCenter.action.terminal"),description:t("commandCenter.action.terminalDescription"),keywords:"shell console command line",icon:$e,run:g},{id:"open-settings",label:t("commandCenter.action.settings"),description:t("commandCenter.action.settingsDescription"),keywords:"preferences general",icon:Qe,run:()=>N("general")},{id:"open-models",label:t("commandCenter.action.models"),description:t("commandCenter.action.modelsDescription"),keywords:"provider llm api configuration",icon:We,run:()=>N("models")},{id:"open-shortcuts",label:t("commandCenter.action.shortcuts"),description:t("commandCenter.action.shortcutsDescription"),keywords:"keyboard hotkey key binding",icon:He,shortcut:L("openCommands"),run:()=>N("shortcuts")},{id:"open-skills",label:t("commandCenter.action.skills"),description:t("commandCenter.action.skillsDescription"),keywords:"capabilities workflow",icon:ze,run:X},{id:"open-mcp",label:t("commandCenter.action.mcp"),description:t("commandCenter.action.mcpDescription"),keywords:"server tools protocol integration",icon:Ge,run:V},{id:"toggle-sidebar",label:t("commandCenter.action.sidebar"),description:t("commandCenter.action.sidebarDescription"),keywords:"navigation layout panel projects",icon:Ue,shortcut:L("toggleSidebar"),run:h}],[B,k,Y,p,N,u,Z,t,V,h,X,g]),w=d.useMemo(()=>it(b,v,A),[A,v,b]),T=d.useMemo(()=>tt(ae,v),[ae,v]),D=s==="tasks"?w.length:T.length,re=d.useMemo(()=>b.filter(e=>!!e.pendingInteraction).length,[b]),$=s==="tasks"?w[f]??null:null,Q=s==="commands"?T[f]??null:null;d.useEffect(()=>{r&&(ee(""),y(0),O(null),I(null))},[s,r]),d.useEffect(()=>{y(0)},[v]),d.useEffect(()=>{var a,l;const e=(a=se.current)==null?void 0:a.querySelector(`[data-task-result-index="${f}"]`);(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})},[f]);const ie=async e=>{const a=R(e),l=U(a),x=E(e,A);O(l),xe.some(j=>j.path===x)&&fe(x);try{await ge(a),i(!1)}catch(j){I(j instanceof Error?j.message:t("taskSwitcher.action.failed"))}finally{O(null)}},ce=async(e,a)=>{I(null);try{const l=R(a);e==="cancel"?await be(l):(await ve(l),i(!1))}catch(l){I(l instanceof Error?l.message:t("taskSwitcher.action.failed"))}},oe=e=>{i(!1),requestAnimationFrame(e.run)},Se=e=>{e.key==="ArrowDown"?(e.preventDefault(),y(a=>D===0?0:(a+1)%D)):e.key==="ArrowUp"?(e.preventDefault(),y(a=>D===0?0:(a-1+D)%D)):e.key==="Enter"&&$?(e.preventDefault(),ie($)):e.key==="Enter"&&Q?(e.preventDefault(),oe(Q)):e.key==="Escape"&&(e.preventDefault(),i(!1))};return n.jsx(Pe,{open:r,onOpenChange:i,children:n.jsxs(Re,{hideCloseButton:!0,onCloseAutoFocus:Ee,className:"top-3 w-[min(680px,calc(100vw-32px))] max-w-none translate-y-0 gap-0 overflow-hidden rounded-xl border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-canvas))] p-0 shadow-2xl sm:top-[18%]",children:[n.jsx(Me,{className:"sr-only",children:t("commandCenter.title")}),n.jsx(qe,{className:"sr-only",children:t("commandCenter.description")}),n.jsxs("div",{className:"flex h-14 items-center gap-3 border-b border-[hsl(var(--deck-hairline))] px-4",children:[n.jsx(G,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),n.jsx("input",{ref:ne,autoFocus:!0,role:"combobox","aria-expanded":"true","aria-controls":"task-switcher-results","aria-activedescendant":$?`task-switcher-result-${f}`:Q?`command-center-result-${f}`:void 0,"aria-label":t(s==="tasks"?"taskSwitcher.searchAria":"commandCenter.searchAria"),placeholder:t(s==="tasks"?"taskSwitcher.placeholder":"commandCenter.placeholder"),value:v,onChange:e=>ee(e.target.value),onKeyDown:Se,className:"h-full min-w-0 flex-1 bg-transparent font-mono text-[14px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),n.jsx("span",{className:"rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:"ESC"})]}),n.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 pb-2 pt-3",children:[n.jsx("div",{role:"tablist","aria-label":t("commandCenter.modeAria"),className:"flex items-center gap-0.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0.5",children:["tasks","commands"].map(e=>n.jsx("button",{type:"button",role:"tab","aria-selected":s===e,onClick:()=>{c(e),requestAnimationFrame(()=>{var a;return(a=ne.current)==null?void 0:a.focus()})},className:S("rounded-[5px] px-2.5 py-1 font-mono text-[9.5px] uppercase tracking-[0.1em] transition-colors",s===e?"bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))] shadow-sm":"text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]"),children:t(e==="tasks"?"commandCenter.mode.tasks":"commandCenter.mode.commands")},e))}),n.jsx("span",{children:n.jsx("span",{className:"font-mono text-[9.5px] uppercase tracking-[0.14em] text-[hsl(var(--deck-ink-faint))]",children:s==="commands"?t("commandCenter.actions",{count:T.length}):v?t("taskSwitcher.results",{count:w.length}):q?b.length===0?t("taskSwitcher.indexing"):t("taskSwitcher.indexingLoaded",{count:b.length}):C==="error"?t("sidebar.catalog.incomplete"):re>0?t("taskSwitcher.needsAction",{count:re}):K.length>0?t("taskSwitcher.unread",{count:K.length}):t("taskSwitcher.scope",{count:b.length})})})]}),te&&n.jsx("div",{role:"alert",className:"mx-4 mb-2 rounded-md border border-red-300/70 bg-red-50 px-3 py-2 font-mono text-[10.5px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:te}),n.jsxs("div",{id:"task-switcher-results",ref:se,role:"listbox","aria-label":t(s==="tasks"?"taskSwitcher.resultsAria":"commandCenter.resultsAria"),className:"max-h-[min(460px,60vh)] overflow-y-auto px-2 pb-2",children:[s==="commands"&&n.jsx(nt,{actions:T,selectedIndex:f,onSelect:y,onRun:oe}),s==="tasks"&&w.map((e,a)=>{const l=R(e),x=U(l),j=E(e,A),Ne=_(j),le=Be(l,B),W=a===f,Ce=je===x,Te=K.includes(x),F=J(e),de=e.taskStatus==="running"||e.taskStatus==="queued",me=!!e.taskRetryAvailable&&(e.taskStatus==="failed"||e.taskStatus==="interrupted"||e.taskStatus==="cancelled"),H=we.includes(x),z=ye.includes(x);return n.jsxs("div",{id:`task-switcher-result-${a}`,"data-task-result-index":a,"data-session-ref":x,role:"option","aria-selected":W,onMouseEnter:()=>y(a),className:S("group flex min-h-[68px] w-full items-center rounded-lg border border-transparent text-left transition-colors",W?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:[n.jsxs("button",{type:"button",onClick:()=>void ie(e),"aria-label":t("session.action.select",{title:F}),className:"flex min-h-[68px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:S("flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-[hsl(var(--deck-canvas))]",le?"border-[hsl(var(--deck-accent)/0.5)] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))]"),children:e.pendingInteraction?n.jsx(ue,{className:"h-3.5 w-3.5 animate-pulse text-amber-600 dark:text-amber-400"}):e.taskStatus==="running"?n.jsx(_e,{className:"h-3.5 w-3.5 animate-pulse"}):n.jsx(Je,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:F}),le&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.current")}),Te&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.new")}),e.pendingInteraction&&n.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.08em] text-amber-800 dark:bg-amber-950/60 dark:text-amber-300",children:t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission")}),e.taskRetriedFrom&&n.jsx("span",{title:`${t("session.retriedFrom")} ${e.taskRetriedFrom.sessionId.slice(0,6)}`,className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] text-[hsl(var(--deck-accent))]",children:t("session.retryShort")})]}),n.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Ve,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:Ne})]}),(e.taskWorktreeBranch||e.gitBranch)&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Xe,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:e.taskWorktreeBranch||e.gitBranch})]}),n.jsx("span",{className:"shrink-0",children:e.taskStatus==="queued"&&e.taskQueuePosition!==void 0&&e.taskQueueDepth!==void 0?t("session.queued",{position:e.taskQueuePosition,depth:e.taskQueueDepth}):e.pendingInteraction?t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission"):t(ct[e.taskStatus])}),n.jsxs("span",{className:"ml-auto inline-flex shrink-0 items-center gap-1",children:[n.jsx(Ye,{className:"h-2.5 w-2.5"}),at(e)]})]})]}),Ce?n.jsx(P,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):n.jsx(he,{className:S("h-3.5 w-3.5 shrink-0 transition-all",W?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]}),(de||me)&&n.jsxs("div",{className:"flex shrink-0 items-center pr-2",children:[de&&n.jsx("button",{type:"button","aria-label":t(H?"session.action.stopping":"session.action.stop",{title:F}),disabled:H,onClick:()=>void ce("cancel",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60",children:H?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(Ze,{className:"h-3.5 w-3.5"})}),me&&n.jsx("button",{type:"button","aria-label":t(z?"session.action.retrying":"session.action.retry",{title:F}),disabled:z,onClick:()=>void ce("retry",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-60",children:z?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(et,{className:"h-3.5 w-3.5"})})]})]},x)}),s==="tasks"&&w.length===0&&q&&n.jsxs("div",{className:"flex min-h-36 items-center justify-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsx(P,{className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("taskSwitcher.indexing")]}),s==="tasks"&&w.length===0&&!q&&C!=="error"&&!ke&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(G,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("taskSwitcher.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("taskSwitcher.emptyHint")})]}),s==="tasks"&&w.length===0&&C==="error"&&n.jsxs("div",{role:"alert",className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(ue,{className:"mb-3 h-5 w-5 text-amber-500"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("sidebar.catalog.incomplete")})]}),s==="commands"&&T.length===0&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(G,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("commandCenter.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("commandCenter.emptyHint")})]})]}),n.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-4 py-2 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{children:["↑↓ ",t("taskSwitcher.hint.navigate")]}),n.jsxs("span",{children:["↵ ",t("taskSwitcher.hint.open")]}),n.jsxs("span",{className:"ml-auto",children:[L(s==="tasks"?"openCommands":"searchTasks")," ",t(s==="tasks"?"commandCenter.mode.commands":"commandCenter.mode.tasks")]})]})]})})}export{ut as TaskSwitcher};
|