@kaitranntt/ccs 7.65.3-dev.3 → 7.65.3-dev.4

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.
Files changed (35) hide show
  1. package/dist/ui/assets/{accounts-Dh95PibK.js → accounts-CemN5nog.js} +1 -1
  2. package/dist/ui/assets/{alert-dialog-C5RdUHi9.js → alert-dialog-0MtCFagW.js} +1 -1
  3. package/dist/ui/assets/{api-C0ROFLme.js → api-DxQMem2l.js} +1 -1
  4. package/dist/ui/assets/{auth-section-M2azTP3G.js → auth-section-Cba_3FxM.js} +1 -1
  5. package/dist/ui/assets/{backups-section-DIDUVa0t.js → backups-section-mFWKWlhP.js} +1 -1
  6. package/dist/ui/assets/{channels-D_5uerEp.js → channels-DY509mDD.js} +1 -1
  7. package/dist/ui/assets/{checkbox-CgMg7fDH.js → checkbox-Dy-Nrqsq.js} +1 -1
  8. package/dist/ui/assets/{claude-extension-DA9wMzPz.js → claude-extension-BUzKDREG.js} +1 -1
  9. package/dist/ui/assets/{cliproxy-4yUL1fQw.js → cliproxy-DB67FlcF.js} +1 -1
  10. package/dist/ui/assets/{cliproxy-ai-providers-DedMcdcc.js → cliproxy-ai-providers-D8JqO6UG.js} +1 -1
  11. package/dist/ui/assets/cliproxy-control-panel-ntzrlFk-.js +1 -0
  12. package/dist/ui/assets/{codex-CAWw4ZNl.js → codex-BjRRRJM-.js} +1 -1
  13. package/dist/ui/assets/{confirm-dialog-Ds0PYz2R.js → confirm-dialog-X8zTaDqZ.js} +1 -1
  14. package/dist/ui/assets/{copilot-m6i00mFy.js → copilot-DXUoVYrt.js} +1 -1
  15. package/dist/ui/assets/{cursor-COeD0Dgq.js → cursor-DDXV1lf-.js} +1 -1
  16. package/dist/ui/assets/{droid-CznUyiRx.js → droid-Dox6AdnB.js} +1 -1
  17. package/dist/ui/assets/{globalenv-section-FgK1eGWk.js → globalenv-section-1__klYkz.js} +1 -1
  18. package/dist/ui/assets/{health-Cpu6bD6K.js → health-DJNOB7S7.js} +1 -1
  19. package/dist/ui/assets/{index-Bhz6T039.js → index-9YLbkNWo.js} +1 -1
  20. package/dist/ui/assets/{index-C7sG68Mi.js → index-C7icNfH6.js} +1 -1
  21. package/dist/ui/assets/{index-DampXntj.js → index-CpPFeQVN.js} +1 -1
  22. package/dist/ui/assets/{index-DgnxlKNk.js → index-DGXfUrnG.js} +1 -1
  23. package/dist/ui/assets/{index-rTSyskt3.js → index-ODiakL1L.js} +1 -1
  24. package/dist/ui/assets/{index-CcKb4PL_.js → index-hqC_y7jI.js} +2 -2
  25. package/dist/ui/assets/{masked-input-B_l4FMkE.js → masked-input-DR7oSJEW.js} +1 -1
  26. package/dist/ui/assets/{proxy-status-widget-C7wSbfPC.js → proxy-status-widget-VjpKO_Ln.js} +1 -1
  27. package/dist/ui/assets/{raw-json-settings-editor-panel-CViWFt6t.js → raw-json-settings-editor-panel-CL2ri7tc.js} +1 -1
  28. package/dist/ui/assets/{searchable-select-7-yJbbw2.js → searchable-select-5Qj9OrB5.js} +1 -1
  29. package/dist/ui/assets/{separator-DApM4Wa5.js → separator-CsRumPD9.js} +1 -1
  30. package/dist/ui/assets/{shared-Blmm7sMd.js → shared-DMViB39W.js} +1 -1
  31. package/dist/ui/assets/{table-BwM4zncv.js → table-7BLaplhc.js} +1 -1
  32. package/dist/ui/assets/{updates-DJ0ofB67.js → updates-CFPId79D.js} +1 -1
  33. package/dist/ui/index.html +1 -1
  34. package/package.json +1 -1
  35. package/dist/ui/assets/cliproxy-control-panel-B0kwxgNi.js +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-C98W0NRG.js";import{r as j,h as fe}from"./react-vendor-CNOkPC89.js";import{u as ye,a as L,b as z,e as be,f as B,g as Ne}from"./tanstack-CfKik0yL.js";import{T as Ce,a as ve,b as V,c as Pe,d as Ae,e as Se}from"./table-BwM4zncv.js";import{Y as T,a as G,af as oe,ag as re,ah as ie,ai as le,aj as de,L as v,r as Z,s as I,t as Q,v as X,w as O,I as $,ax as De,d as u,C as A,j as S,k as D,_ as w,B as F,b as k,M as ue,N as xe,c as M,O as me,n as ke,x as W}from"./index-CcKb4PL_.js";import{A as Te,a as _e,b as we,c as Me,d as Le,e as ze,f as Ge,g as Oe}from"./alert-dialog-C5RdUHi9.js";import{t as y}from"./notifications-B2HqRBj7.js";import{aT as Fe,aU as He,l as q,am as Re,N as $e,Y as qe,n as Y,aV as Ee,at as H,aW as Ue,aX as Ke,r as he,aY as Be,aM as Ve,U as Ze,a6 as J,Z as ee,T as Ie}from"./icons-CeH5899d.js";import{C as te}from"./checkbox-CgMg7fDH.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Qe(){return ye({queryKey:["accounts"],queryFn:()=>T.accounts.list(),select:s=>{const a=s.accounts.filter(i=>i.type!=="cliproxy"),t=s.accounts.length-a.length,c=a.filter(i=>i.context_mode==="shared").length,o=a.filter(i=>i.context_mode==="shared"&&i.continuity_mode==="deeper").length,x=Math.max(c-o,0),l=a.length-c,m=a.filter(i=>i.context_inferred).length,g=a.filter(i=>i.context_mode==="shared"&&i.continuity_mode!=="deeper"&&i.continuity_inferred).length,p=a.some(i=>i.name===s.default)?s.default:null;return{accounts:a,default:p,cliproxyCount:t,legacyContextCount:m,legacyContinuityCount:g,sharedCount:c,sharedStandardCount:x,deeperSharedCount:o,isolatedCount:l}}})}function Xe(){const s=L();return z({mutationFn:a=>T.accounts.setDefault(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),y.success(`Default account set to "${t}"`)},onError:a=>{y.error(a.message)}})}function We(){const s=L();return z({mutationFn:()=>T.accounts.resetDefault(),onSuccess:()=>{s.invalidateQueries({queryKey:["accounts"]}),y.success("Default account reset to CCS")},onError:a=>{y.error(a.message)}})}function Ye(){const s=L();return z({mutationFn:a=>T.accounts.delete(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),y.success(`Account "${t}" deleted`)},onError:a=>{y.error(a.message)}})}function ge(){const s=L();return z({mutationFn:({name:a,context_mode:t,context_group:c,continuity_mode:o})=>T.accounts.updateContext(a,{context_mode:t,context_group:c,continuity_mode:o}),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]});const c=t.context_mode==="shared"?t.continuity_mode==="deeper"?`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, deeper continuity)`:`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, standard)`:"isolated";y.success(`Updated "${t.name}" context to ${c}`)},onError:a=>{y.error(a.message)}})}function Je(){const s=L();return z({mutationFn:async a=>{const t=a.filter(c=>c.context_inferred||c.continuity_inferred);for(const c of t){const o=c.context_mode==="shared";await T.accounts.updateContext(c.name,{context_mode:o?"shared":"isolated",context_group:o?c.context_group||"default":void 0,continuity_mode:o?c.continuity_mode==="deeper"?"deeper":"standard":void 0})}return{updatedCount:t.length}},onSuccess:({updatedCount:a})=>{if(s.invalidateQueries({queryKey:["accounts"]}),a>0){y.success(`Confirmed explicit sync mode for ${a} legacy account${a>1?"s":""}`);return}y.info("No legacy accounts need confirmation")},onError:a=>{y.error(a.message)}})}const se=64,et=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function tt({account:s,onClose:a}){const{t}=G(),c=ge(),[o,x]=j.useState(s.context_mode==="shared"?"shared":"isolated"),[l,m]=j.useState(s.context_group||"default"),[g,p]=j.useState(s.continuity_mode==="deeper"?"deeper":"standard"),i=j.useMemo(()=>l.trim().toLowerCase().replace(/\s+/g,"-"),[l]),b=i.length>0&&i.length<=se&&et.test(i),f=o==="isolated"||b,n=()=>{f&&c.mutate({name:s.name,context_mode:o,context_group:o==="shared"?i:void 0,continuity_mode:o==="shared"?g:void 0},{onSuccess:()=>{a()}})},r=d=>{d||a()};return e.jsx(oe,{open:!0,onOpenChange:r,children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(ie,{children:[e.jsx(le,{children:t("editAccountContext.title")}),e.jsx(de,{children:t("editAccountContext.description",{name:s.name})})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"context-mode",children:t("editAccountContext.syncMode")}),e.jsxs(Z,{value:o,onValueChange:d=>x(d),children:[e.jsx(I,{id:"context-mode",children:e.jsx(Q,{placeholder:t("editAccountContext.selectContextMode")})}),e.jsxs(X,{children:[e.jsx(O,{value:"isolated",children:t("editAccountContext.isolatedOption")}),e.jsx(O,{value:"shared",children:t("editAccountContext.sharedOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(o==="shared"?"editAccountContext.sharedModeHint":"editAccountContext.isolatedModeHint")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"context-group",children:t("editAccountContext.historySyncGroup")}),e.jsx($,{id:"context-group",value:l,onChange:d=>m(d.target.value),placeholder:t("editAccountContext.groupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.groupHint",{max:se})}),!b&&e.jsx("p",{className:"text-xs text-destructive",children:t("editAccountContext.invalidGroup")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"continuity-mode",children:t("editAccountContext.continuityDepth")}),e.jsxs(Z,{value:g,onValueChange:d=>p(d),children:[e.jsx(I,{id:"continuity-mode",children:e.jsx(Q,{placeholder:t("editAccountContext.selectContinuityDepth")})}),e.jsxs(X,{children:[e.jsx(O,{value:"standard",children:t("editAccountContext.standardOption")}),e.jsx(O,{value:"deeper",children:t("editAccountContext.deeperOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(g==="deeper"?"editAccountContext.deeperHint":"editAccountContext.standardHint")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.credentialsIsolated")})]}),e.jsxs(De,{children:[e.jsx(u,{variant:"outline",onClick:a,disabled:c.isPending,children:t("editAccountContext.cancel")}),e.jsx(u,{onClick:n,disabled:!f||c.isPending,children:c.isPending?t("editAccountContext.saving"):t("editAccountContext.save")})]})]})})}function ae({data:s,defaultAccount:a}){const{t}=G(),c=Xe(),o=Ye(),x=We(),l=ge(),[m,g]=j.useState(null),[p,i]=j.useState(null),b=[{accessorKey:"name",header:t("accountsTable.name"),size:200,cell:({row:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n.original.name}),n.original.name===a&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:t("accountsTable.defaultBadge")})]})},{accessorKey:"type",header:t("accountsTable.type"),size:100,cell:({row:n})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:n.original.type||"oauth"})},{accessorKey:"created",header:t("accountsTable.created"),size:150,cell:({row:n})=>{const r=new Date(n.original.created);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{accessorKey:"last_used",header:t("accountsTable.lastUsed"),size:150,cell:({row:n})=>{if(!n.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const r=new Date(n.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{id:"context",header:t("accountsTable.historySync"),size:170,cell:({row:n})=>{if(n.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((n.original.context_mode||"isolated")==="shared"){const d=n.original.context_group||"default";return n.original.continuity_mode==="deeper"?e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupDeeper",{group:d})}):n.original.continuity_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.sharedGroupLegacy",{group:d})}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupStandard",{group:d})})}return n.original.context_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.isolatedLegacy")}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.isolated")})}},{id:"actions",header:t("accountsTable.actions"),size:220,cell:({row:n})=>{const r=n.original.name===a,d=c.isPending||o.isPending||l.isPending,N=n.original.type==="cliproxy",P=n.original.context_inferred||n.original.continuity_inferred;return e.jsxs("div",{className:"flex items-center gap-1",children:[!N&&e.jsxs(u,{variant:"outline",size:"sm",className:"h-8 px-2",disabled:d,onClick:()=>i(n.original),title:t("accountsTable.syncTitle"),children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1"}),t("accountsTable.sync")]}),!N&&P&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-8 px-2 text-amber-700 hover:text-amber-700 hover:bg-amber-500/10 dark:text-amber-400 dark:hover:text-amber-400",disabled:d,onClick:()=>l.mutate({name:n.original.name,context_mode:n.original.context_mode==="shared"?"shared":"isolated",context_group:n.original.context_mode==="shared"?n.original.context_group||"default":void 0,continuity_mode:n.original.context_mode==="shared"?n.original.continuity_mode==="deeper"?"deeper":"standard":void 0}),title:t("accountsTable.confirmLegacyTitle"),children:[e.jsx(He,{className:"w-3 h-3 mr-1"}),t("accountsTable.confirm")]}),e.jsxs(u,{variant:r?"secondary":"default",size:"sm",className:"h-8 px-2",disabled:r||d,onClick:()=>c.mutate(n.original.name),children:[e.jsx(q,{className:`w-3 h-3 mr-1 ${r?"opacity-50":""}`}),t(r?"accountsTable.active":"accountsTable.setDefault")]}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",disabled:r||d,onClick:()=>g(n.original.name),title:t(r?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(Re,{className:"w-4 h-4"})})]})}}],f=be({data:s,columns:b,getCoreRowModel:Ne()});return s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:t("accountsTable.noAccounts")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border rounded-md",children:e.jsxs(Ce,{children:[e.jsx(ve,{children:f.getHeaderGroups().map(n=>e.jsx(V,{children:n.headers.map(r=>{const d={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",context:"w-[170px]",actions:"w-[290px]"}[r.id]||"w-auto";return e.jsx(Pe,{className:d,children:r.isPlaceholder?null:B(r.column.columnDef.header,r.getContext())},r.id)})},n.id))}),e.jsx(Ae,{children:f.getRowModel().rows.map(n=>e.jsx(V,{children:n.getVisibleCells().map(r=>e.jsx(Se,{children:B(r.column.columnDef.cell,r.getContext())},r.id))},n.id))})]})}),a&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[e.jsx($e,{className:"w-4 h-4 mr-2"}),t("accountsTable.resetToDefault")]})})]}),p&&e.jsx(tt,{account:p,onClose:()=>i(null)}),e.jsx(Te,{open:!!m,onOpenChange:n=>!n&&g(null),children:e.jsxs(_e,{children:[e.jsxs(we,{children:[e.jsx(Me,{children:t("accountsTable.deleteDialogTitle")}),e.jsx(Le,{children:t("accountsTable.deleteDialogDesc",{name:m??""})})]}),e.jsxs(ze,{children:[e.jsx(Ge,{children:t("accountsTable.cancel")}),e.jsx(Oe,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{m&&(o.mutate(m),g(null))},children:t("accountsTable.delete")})]})]})})]})}const ne=64;function st({open:s,onClose:a}){const{t}=G(),[c,o]=j.useState(""),[x,l]=j.useState(!1),[m,g]=j.useState(""),[p,i]=j.useState(!1),[b,f]=j.useState(!1),n=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(c),r=m.trim().toLowerCase().replace(/\s+/g,"-"),d=r.length===0||r.length<=ne&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(r),N=c&&n?[`ccs auth create ${c}`,x?r.length>0?`--context-group ${r}`:"--share-context":"",x&&p?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),P=async()=>{!n||x&&!d||(await navigator.clipboard.writeText(N),f(!0),setTimeout(()=>f(!1),2e3))},_=()=>{o(""),l(!1),g(""),i(!1),f(!1),a()};return e.jsx(oe,{open:s,onOpenChange:h=>!h&&_(),children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(ie,{children:[e.jsx(le,{children:t("createAuthProfileDialog.title")}),e.jsx(de,{children:t("createAuthProfileDialog.description")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx($,{id:"profile-name",value:c,onChange:h=>o(h.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),c&&!n&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidProfileName")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{id:"share-context",checked:x,onCheckedChange:h=>l(h===!0)}),e.jsx(v,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),x&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(v,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx($,{id:"context-group",value:m,onChange:h=>g(h.target.value),placeholder:t("createAuthProfileDialog.historySyncGroupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.historySyncGroupHint")}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(te,{id:"deeper-continuity",checked:p,onCheckedChange:h=>i(h===!0)}),e.jsx(v,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),m.trim().length>0&&!d&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:ne})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:t("createAuthProfileDialog.command")}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-md font-mono text-sm",children:[e.jsx(qe,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("code",{className:"flex-1 break-all",children:N}),e.jsx(u,{variant:"ghost",size:"sm",className:"shrink-0 h-8 px-2",onClick:P,disabled:!n||x&&!d,children:b?e.jsx(q,{className:"w-4 h-4 text-green-500"}):e.jsx(Y,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsx("p",{children:t("createAuthProfileDialog.afterRunPrefix")}),e.jsxs("ol",{className:"list-decimal list-inside pl-2 space-y-0.5",children:[e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep1")}),e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep2")})]}),e.jsx("p",{className:"pt-1",children:t("createAuthProfileDialog.poolingHint")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(u,{variant:"ghost",onClick:_,children:t("createAuthProfileDialog.close")}),e.jsx(u,{onClick:P,disabled:!n||x&&!d,children:b?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copyCommand")]})})]})]})]})})}function R({title:s,count:a,icon:t,tone:c}){const o={isolated:{border:"border-blue-300/60 bg-blue-50/40 dark:border-blue-900/40 dark:bg-blue-900/10",icon:"text-blue-700 dark:text-blue-400",count:"text-blue-700 dark:text-blue-400"},shared:{border:"border-emerald-300/60 bg-emerald-50/40 dark:border-emerald-900/40 dark:bg-emerald-900/10",icon:"text-emerald-700 dark:text-emerald-400",count:"text-emerald-700 dark:text-emerald-400"},deeper:{border:"border-indigo-300/60 bg-indigo-50/40 dark:border-indigo-900/40 dark:bg-indigo-900/10",icon:"text-indigo-700 dark:text-indigo-400",count:"text-indigo-700 dark:text-indigo-400"}};return e.jsxs("div",{className:M("rounded-md border p-2.5",o[c].border),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:s}),e.jsx(t,{className:M("h-3.5 w-3.5",o[c].icon)})]}),e.jsx("p",{className:M("mt-1 text-lg font-mono font-semibold",o[c].count),children:a})]})}function ce({isolatedCount:s,sharedStandardCount:a,deeperSharedCount:t,sharedGroups:c,legacyTargetCount:o,cliproxyCount:x}){const{t:l}=G(),[m,g]=j.useState(!1),p=c.length>0?c:["default"];return e.jsxs(A,{className:"border-dashed",children:[e.jsx(S,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(D,{className:"text-base",children:l("historySyncLearningMap.title")}),e.jsx(w,{className:"mt-1",children:l("historySyncLearningMap.description")})]}),e.jsx(F,{variant:"outline",children:l("historySyncLearningMap.learningMap")})]})}),e.jsxs(k,{className:"space-y-3",children:[x>0&&e.jsx("div",{className:"rounded-md border border-blue-300/60 bg-blue-50/40 px-3 py-2 text-xs text-blue-800 dark:border-blue-900/40 dark:bg-blue-900/10 dark:text-blue-300",children:l("historySyncLearningMap.cliproxyManaged",{count:x})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto_1fr_auto_1fr] sm:items-center",children:[e.jsx(R,{title:l("historySyncLearningMap.isolated"),count:s,icon:Ee,tone:"isolated"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(H,{className:"h-4 w-4"})}),e.jsx(R,{title:l("historySyncLearningMap.shared"),count:a,icon:Ue,tone:"shared"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(H,{className:"h-4 w-4"})}),e.jsx(R,{title:l("historySyncLearningMap.deeper"),count:t,icon:Ke,tone:"deeper"})]}),e.jsxs(ue,{open:m,onOpenChange:g,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-8 w-full justify-between rounded-md px-2 text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",children:[e.jsx("span",{children:l("historySyncLearningMap.showDetails")}),e.jsx(he,{className:M("h-4 w-4 transition-transform",m&&"rotate-180")})]})}),e.jsxs(me,{className:"pt-2",children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:l("historySyncLearningMap.modeSwitch")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:l("historySyncLearningMap.modeSwitchDesc")})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:l("historySyncLearningMap.historySyncGroup")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:l("historySyncLearningMap.historySyncGroupDesc")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:p.map(i=>e.jsx(F,{variant:"outline",className:"font-mono text-[10px]",children:i},i))})]})]}),o>0&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-300",children:l("historySyncLearningMap.legacyConfirmation",{count:o})})]})]})]})]})}function gt(){const{t:s}=G(),a=fe(),{data:t,isLoading:c}=Qe(),o=Je(),[x,l]=j.useState(!1),[m,g]=j.useState(!1),p=t?.accounts||[],i=t?.cliproxyCount||0,b=t?.legacyContextCount||0,f=t?.legacyContinuityCount||0,n=t?.sharedCount||0,r=t?.sharedStandardCount||0,d=t?.deeperSharedCount||0,N=t?.isolatedCount||0,P=Array.from(new Set(p.filter(C=>C.context_mode==="shared").map(C=>C.context_group||"default"))).sort((C,je)=>C.localeCompare(je)),_=p.filter(C=>C.context_inferred||C.continuity_inferred),h=_.length,pe=h>0,E=()=>a("/cliproxy?provider=claude"),U=()=>a("/cliproxy?provider=claude&action=auth"),K=()=>o.mutate(_);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden h-full min-h-0 lg:flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/20 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("accountsPage.title")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.manageSuffix")]})]}),e.jsx(ke,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("accountsPage.primaryActions")}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:()=>l(!0),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:U,children:[e.jsx(ee,{className:"w-4 h-4 mr-2"}),s("accountsPage.authClaudeInPool")]}),e.jsxs(u,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:E,children:[s("accountsPage.openClaudePoolSettings"),e.jsx(H,{className:"w-4 h-4 ml-auto"})]})]}),pe?e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("accountsPage.migrationFollowup")}),e.jsxs("div",{className:"rounded-md border border-amber-500/50 bg-amber-500/10 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ie,{className:"h-4 w-4 mt-0.5 text-amber-700 dark:text-amber-400 shrink-0"}),e.jsxs("div",{className:"space-y-1 text-xs",children:[b>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContextPending",{count:b})}),f>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContinuityPending",{count:f})})]})]}),e.jsx(u,{variant:"secondary",size:"sm",className:"w-full justify-start",onClick:K,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:s("accountsPage.noLegacyFollowup")}),e.jsx(ue,{open:m,onOpenChange:g,children:e.jsxs(A,{children:[e.jsx(S,{className:"pb-2",children:e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-auto w-full justify-between px-0 py-0",children:[e.jsxs("div",{className:"text-left",children:[e.jsx(D,{className:"text-sm",children:s("accountsPage.continuityGuide")}),e.jsx(w,{className:"mt-1",children:s("accountsPage.expandWhenNeeded")})]}),e.jsx(he,{className:M("h-4 w-4 transition-transform",m&&"rotate-180")})]})})}),e.jsx(me,{children:e.jsxs(k,{className:"space-y-3 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedStandard")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.sharedStandardDesc")})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedDeeper")}),e.jsxs("p",{className:"mt-1",children:[s("accountsPage.sharedDeeperPrefix")," ",e.jsx("code",{children:"session-env"}),","," ",e.jsx("code",{children:"file-history"}),", ",e.jsx("code",{children:"shell-snapshots"}),","," ",e.jsx("code",{children:"todos"}),"."]})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.isolated")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.isolatedDesc")})]})]})})]})}),e.jsxs(A,{children:[e.jsxs(S,{className:"pb-2",children:[e.jsx(D,{className:"text-sm",children:s("accountsPage.quickCommands")}),e.jsx(w,{children:s("accountsPage.quickCommandsDesc")})]}),e.jsxs(k,{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth create work --context-group sprint-a --deeper-continuity"}),e.jsx(W,{value:"ccs auth create work --context-group sprint-a --deeper-continuity",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs cliproxy auth claude"}),e.jsx(W,{value:"ccs cliproxy auth claude",size:"icon"})]})]})]})]})})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col bg-background",children:[e.jsxs("div",{className:"px-5 py-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{variant:"outline",children:s("accountsPage.workspaceBadge")}),e.jsx(F,{variant:"secondary",children:s("accountsPage.historySyncBadge")})]}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:s("accountsPage.authAccounts")}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[s("accountsPage.tableScopePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.tableScopeMiddle"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:s("accountsTable.sync")}),s("accountsPage.tableScopeSuffix")]})]}),e.jsxs("div",{className:"flex-1 min-h-0 p-5 space-y-4 overflow-y-auto",children:[e.jsx(ce,{isolatedCount:N,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:P,legacyTargetCount:h,cliproxyCount:i}),e.jsxs(A,{className:"flex flex-col",children:[e.jsxs(S,{className:"pb-3",children:[e.jsx(D,{className:"text-lg",children:s("accountsPage.accountMatrix")}),e.jsx(w,{children:s("accountsPage.sharedTotalDesc",{count:n})})]}),e.jsx(k,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(A,{children:[e.jsxs(S,{children:[e.jsx(D,{className:"text-lg",children:s("accountsPage.title")}),e.jsxs(w,{children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.mobileManageSuffix")]})]}),e.jsxs(k,{className:"space-y-2",children:[e.jsxs(u,{className:"w-full",onClick:()=>l(!0),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:E,children:[s("accountsPage.openCliProxyClaudePool"),e.jsx(H,{className:"w-4 h-4 ml-2"})]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:U,children:[s("accountsPage.authClaudeInPool"),e.jsx(ee,{className:"w-4 h-4 ml-2"})]}),e.jsx(u,{variant:"outline",className:"w-full",onClick:K,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}),e.jsx(ce,{isolatedCount:N,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:P,legacyTargetCount:h,cliproxyCount:i}),e.jsxs(A,{children:[e.jsx(S,{className:"pb-3",children:e.jsx(D,{className:"text-base",children:s("accountsPage.accountMatrix")})}),e.jsx(k,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]}),e.jsx(st,{open:x,onClose:()=>l(!1)})]})}export{gt as AccountsPage};
1
+ import{j as e}from"./radix-ui-C98W0NRG.js";import{r as j,h as fe}from"./react-vendor-CNOkPC89.js";import{u as ye,a as L,b as z,e as be,f as B,g as Ne}from"./tanstack-CfKik0yL.js";import{T as Ce,a as ve,b as V,c as Pe,d as Ae,e as Se}from"./table-7BLaplhc.js";import{Y as T,a as G,af as oe,ag as re,ah as ie,ai as le,aj as de,L as v,r as Z,s as I,t as Q,v as X,w as O,I as $,ax as De,d as u,C as A,j as S,k as D,_ as w,B as F,b as k,M as ue,N as xe,c as M,O as me,n as ke,x as W}from"./index-hqC_y7jI.js";import{A as Te,a as _e,b as we,c as Me,d as Le,e as ze,f as Ge,g as Oe}from"./alert-dialog-0MtCFagW.js";import{t as y}from"./notifications-B2HqRBj7.js";import{aT as Fe,aU as He,l as q,am as Re,N as $e,Y as qe,n as Y,aV as Ee,at as H,aW as Ue,aX as Ke,r as he,aY as Be,aM as Ve,U as Ze,a6 as J,Z as ee,T as Ie}from"./icons-CeH5899d.js";import{C as te}from"./checkbox-Dy-Nrqsq.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Qe(){return ye({queryKey:["accounts"],queryFn:()=>T.accounts.list(),select:s=>{const a=s.accounts.filter(i=>i.type!=="cliproxy"),t=s.accounts.length-a.length,c=a.filter(i=>i.context_mode==="shared").length,o=a.filter(i=>i.context_mode==="shared"&&i.continuity_mode==="deeper").length,x=Math.max(c-o,0),l=a.length-c,m=a.filter(i=>i.context_inferred).length,g=a.filter(i=>i.context_mode==="shared"&&i.continuity_mode!=="deeper"&&i.continuity_inferred).length,p=a.some(i=>i.name===s.default)?s.default:null;return{accounts:a,default:p,cliproxyCount:t,legacyContextCount:m,legacyContinuityCount:g,sharedCount:c,sharedStandardCount:x,deeperSharedCount:o,isolatedCount:l}}})}function Xe(){const s=L();return z({mutationFn:a=>T.accounts.setDefault(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),y.success(`Default account set to "${t}"`)},onError:a=>{y.error(a.message)}})}function We(){const s=L();return z({mutationFn:()=>T.accounts.resetDefault(),onSuccess:()=>{s.invalidateQueries({queryKey:["accounts"]}),y.success("Default account reset to CCS")},onError:a=>{y.error(a.message)}})}function Ye(){const s=L();return z({mutationFn:a=>T.accounts.delete(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),y.success(`Account "${t}" deleted`)},onError:a=>{y.error(a.message)}})}function ge(){const s=L();return z({mutationFn:({name:a,context_mode:t,context_group:c,continuity_mode:o})=>T.accounts.updateContext(a,{context_mode:t,context_group:c,continuity_mode:o}),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]});const c=t.context_mode==="shared"?t.continuity_mode==="deeper"?`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, deeper continuity)`:`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, standard)`:"isolated";y.success(`Updated "${t.name}" context to ${c}`)},onError:a=>{y.error(a.message)}})}function Je(){const s=L();return z({mutationFn:async a=>{const t=a.filter(c=>c.context_inferred||c.continuity_inferred);for(const c of t){const o=c.context_mode==="shared";await T.accounts.updateContext(c.name,{context_mode:o?"shared":"isolated",context_group:o?c.context_group||"default":void 0,continuity_mode:o?c.continuity_mode==="deeper"?"deeper":"standard":void 0})}return{updatedCount:t.length}},onSuccess:({updatedCount:a})=>{if(s.invalidateQueries({queryKey:["accounts"]}),a>0){y.success(`Confirmed explicit sync mode for ${a} legacy account${a>1?"s":""}`);return}y.info("No legacy accounts need confirmation")},onError:a=>{y.error(a.message)}})}const se=64,et=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function tt({account:s,onClose:a}){const{t}=G(),c=ge(),[o,x]=j.useState(s.context_mode==="shared"?"shared":"isolated"),[l,m]=j.useState(s.context_group||"default"),[g,p]=j.useState(s.continuity_mode==="deeper"?"deeper":"standard"),i=j.useMemo(()=>l.trim().toLowerCase().replace(/\s+/g,"-"),[l]),b=i.length>0&&i.length<=se&&et.test(i),f=o==="isolated"||b,n=()=>{f&&c.mutate({name:s.name,context_mode:o,context_group:o==="shared"?i:void 0,continuity_mode:o==="shared"?g:void 0},{onSuccess:()=>{a()}})},r=d=>{d||a()};return e.jsx(oe,{open:!0,onOpenChange:r,children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(ie,{children:[e.jsx(le,{children:t("editAccountContext.title")}),e.jsx(de,{children:t("editAccountContext.description",{name:s.name})})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"context-mode",children:t("editAccountContext.syncMode")}),e.jsxs(Z,{value:o,onValueChange:d=>x(d),children:[e.jsx(I,{id:"context-mode",children:e.jsx(Q,{placeholder:t("editAccountContext.selectContextMode")})}),e.jsxs(X,{children:[e.jsx(O,{value:"isolated",children:t("editAccountContext.isolatedOption")}),e.jsx(O,{value:"shared",children:t("editAccountContext.sharedOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(o==="shared"?"editAccountContext.sharedModeHint":"editAccountContext.isolatedModeHint")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"context-group",children:t("editAccountContext.historySyncGroup")}),e.jsx($,{id:"context-group",value:l,onChange:d=>m(d.target.value),placeholder:t("editAccountContext.groupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.groupHint",{max:se})}),!b&&e.jsx("p",{className:"text-xs text-destructive",children:t("editAccountContext.invalidGroup")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"continuity-mode",children:t("editAccountContext.continuityDepth")}),e.jsxs(Z,{value:g,onValueChange:d=>p(d),children:[e.jsx(I,{id:"continuity-mode",children:e.jsx(Q,{placeholder:t("editAccountContext.selectContinuityDepth")})}),e.jsxs(X,{children:[e.jsx(O,{value:"standard",children:t("editAccountContext.standardOption")}),e.jsx(O,{value:"deeper",children:t("editAccountContext.deeperOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(g==="deeper"?"editAccountContext.deeperHint":"editAccountContext.standardHint")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.credentialsIsolated")})]}),e.jsxs(De,{children:[e.jsx(u,{variant:"outline",onClick:a,disabled:c.isPending,children:t("editAccountContext.cancel")}),e.jsx(u,{onClick:n,disabled:!f||c.isPending,children:c.isPending?t("editAccountContext.saving"):t("editAccountContext.save")})]})]})})}function ae({data:s,defaultAccount:a}){const{t}=G(),c=Xe(),o=Ye(),x=We(),l=ge(),[m,g]=j.useState(null),[p,i]=j.useState(null),b=[{accessorKey:"name",header:t("accountsTable.name"),size:200,cell:({row:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n.original.name}),n.original.name===a&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:t("accountsTable.defaultBadge")})]})},{accessorKey:"type",header:t("accountsTable.type"),size:100,cell:({row:n})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:n.original.type||"oauth"})},{accessorKey:"created",header:t("accountsTable.created"),size:150,cell:({row:n})=>{const r=new Date(n.original.created);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{accessorKey:"last_used",header:t("accountsTable.lastUsed"),size:150,cell:({row:n})=>{if(!n.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const r=new Date(n.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{id:"context",header:t("accountsTable.historySync"),size:170,cell:({row:n})=>{if(n.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((n.original.context_mode||"isolated")==="shared"){const d=n.original.context_group||"default";return n.original.continuity_mode==="deeper"?e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupDeeper",{group:d})}):n.original.continuity_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.sharedGroupLegacy",{group:d})}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupStandard",{group:d})})}return n.original.context_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.isolatedLegacy")}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.isolated")})}},{id:"actions",header:t("accountsTable.actions"),size:220,cell:({row:n})=>{const r=n.original.name===a,d=c.isPending||o.isPending||l.isPending,N=n.original.type==="cliproxy",P=n.original.context_inferred||n.original.continuity_inferred;return e.jsxs("div",{className:"flex items-center gap-1",children:[!N&&e.jsxs(u,{variant:"outline",size:"sm",className:"h-8 px-2",disabled:d,onClick:()=>i(n.original),title:t("accountsTable.syncTitle"),children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1"}),t("accountsTable.sync")]}),!N&&P&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-8 px-2 text-amber-700 hover:text-amber-700 hover:bg-amber-500/10 dark:text-amber-400 dark:hover:text-amber-400",disabled:d,onClick:()=>l.mutate({name:n.original.name,context_mode:n.original.context_mode==="shared"?"shared":"isolated",context_group:n.original.context_mode==="shared"?n.original.context_group||"default":void 0,continuity_mode:n.original.context_mode==="shared"?n.original.continuity_mode==="deeper"?"deeper":"standard":void 0}),title:t("accountsTable.confirmLegacyTitle"),children:[e.jsx(He,{className:"w-3 h-3 mr-1"}),t("accountsTable.confirm")]}),e.jsxs(u,{variant:r?"secondary":"default",size:"sm",className:"h-8 px-2",disabled:r||d,onClick:()=>c.mutate(n.original.name),children:[e.jsx(q,{className:`w-3 h-3 mr-1 ${r?"opacity-50":""}`}),t(r?"accountsTable.active":"accountsTable.setDefault")]}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",disabled:r||d,onClick:()=>g(n.original.name),title:t(r?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(Re,{className:"w-4 h-4"})})]})}}],f=be({data:s,columns:b,getCoreRowModel:Ne()});return s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:t("accountsTable.noAccounts")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border rounded-md",children:e.jsxs(Ce,{children:[e.jsx(ve,{children:f.getHeaderGroups().map(n=>e.jsx(V,{children:n.headers.map(r=>{const d={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",context:"w-[170px]",actions:"w-[290px]"}[r.id]||"w-auto";return e.jsx(Pe,{className:d,children:r.isPlaceholder?null:B(r.column.columnDef.header,r.getContext())},r.id)})},n.id))}),e.jsx(Ae,{children:f.getRowModel().rows.map(n=>e.jsx(V,{children:n.getVisibleCells().map(r=>e.jsx(Se,{children:B(r.column.columnDef.cell,r.getContext())},r.id))},n.id))})]})}),a&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[e.jsx($e,{className:"w-4 h-4 mr-2"}),t("accountsTable.resetToDefault")]})})]}),p&&e.jsx(tt,{account:p,onClose:()=>i(null)}),e.jsx(Te,{open:!!m,onOpenChange:n=>!n&&g(null),children:e.jsxs(_e,{children:[e.jsxs(we,{children:[e.jsx(Me,{children:t("accountsTable.deleteDialogTitle")}),e.jsx(Le,{children:t("accountsTable.deleteDialogDesc",{name:m??""})})]}),e.jsxs(ze,{children:[e.jsx(Ge,{children:t("accountsTable.cancel")}),e.jsx(Oe,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{m&&(o.mutate(m),g(null))},children:t("accountsTable.delete")})]})]})})]})}const ne=64;function st({open:s,onClose:a}){const{t}=G(),[c,o]=j.useState(""),[x,l]=j.useState(!1),[m,g]=j.useState(""),[p,i]=j.useState(!1),[b,f]=j.useState(!1),n=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(c),r=m.trim().toLowerCase().replace(/\s+/g,"-"),d=r.length===0||r.length<=ne&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(r),N=c&&n?[`ccs auth create ${c}`,x?r.length>0?`--context-group ${r}`:"--share-context":"",x&&p?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),P=async()=>{!n||x&&!d||(await navigator.clipboard.writeText(N),f(!0),setTimeout(()=>f(!1),2e3))},_=()=>{o(""),l(!1),g(""),i(!1),f(!1),a()};return e.jsx(oe,{open:s,onOpenChange:h=>!h&&_(),children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(ie,{children:[e.jsx(le,{children:t("createAuthProfileDialog.title")}),e.jsx(de,{children:t("createAuthProfileDialog.description")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx($,{id:"profile-name",value:c,onChange:h=>o(h.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),c&&!n&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidProfileName")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{id:"share-context",checked:x,onCheckedChange:h=>l(h===!0)}),e.jsx(v,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),x&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(v,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx($,{id:"context-group",value:m,onChange:h=>g(h.target.value),placeholder:t("createAuthProfileDialog.historySyncGroupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.historySyncGroupHint")}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(te,{id:"deeper-continuity",checked:p,onCheckedChange:h=>i(h===!0)}),e.jsx(v,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),m.trim().length>0&&!d&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:ne})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:t("createAuthProfileDialog.command")}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-md font-mono text-sm",children:[e.jsx(qe,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("code",{className:"flex-1 break-all",children:N}),e.jsx(u,{variant:"ghost",size:"sm",className:"shrink-0 h-8 px-2",onClick:P,disabled:!n||x&&!d,children:b?e.jsx(q,{className:"w-4 h-4 text-green-500"}):e.jsx(Y,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsx("p",{children:t("createAuthProfileDialog.afterRunPrefix")}),e.jsxs("ol",{className:"list-decimal list-inside pl-2 space-y-0.5",children:[e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep1")}),e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep2")})]}),e.jsx("p",{className:"pt-1",children:t("createAuthProfileDialog.poolingHint")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(u,{variant:"ghost",onClick:_,children:t("createAuthProfileDialog.close")}),e.jsx(u,{onClick:P,disabled:!n||x&&!d,children:b?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copyCommand")]})})]})]})]})})}function R({title:s,count:a,icon:t,tone:c}){const o={isolated:{border:"border-blue-300/60 bg-blue-50/40 dark:border-blue-900/40 dark:bg-blue-900/10",icon:"text-blue-700 dark:text-blue-400",count:"text-blue-700 dark:text-blue-400"},shared:{border:"border-emerald-300/60 bg-emerald-50/40 dark:border-emerald-900/40 dark:bg-emerald-900/10",icon:"text-emerald-700 dark:text-emerald-400",count:"text-emerald-700 dark:text-emerald-400"},deeper:{border:"border-indigo-300/60 bg-indigo-50/40 dark:border-indigo-900/40 dark:bg-indigo-900/10",icon:"text-indigo-700 dark:text-indigo-400",count:"text-indigo-700 dark:text-indigo-400"}};return e.jsxs("div",{className:M("rounded-md border p-2.5",o[c].border),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:s}),e.jsx(t,{className:M("h-3.5 w-3.5",o[c].icon)})]}),e.jsx("p",{className:M("mt-1 text-lg font-mono font-semibold",o[c].count),children:a})]})}function ce({isolatedCount:s,sharedStandardCount:a,deeperSharedCount:t,sharedGroups:c,legacyTargetCount:o,cliproxyCount:x}){const{t:l}=G(),[m,g]=j.useState(!1),p=c.length>0?c:["default"];return e.jsxs(A,{className:"border-dashed",children:[e.jsx(S,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(D,{className:"text-base",children:l("historySyncLearningMap.title")}),e.jsx(w,{className:"mt-1",children:l("historySyncLearningMap.description")})]}),e.jsx(F,{variant:"outline",children:l("historySyncLearningMap.learningMap")})]})}),e.jsxs(k,{className:"space-y-3",children:[x>0&&e.jsx("div",{className:"rounded-md border border-blue-300/60 bg-blue-50/40 px-3 py-2 text-xs text-blue-800 dark:border-blue-900/40 dark:bg-blue-900/10 dark:text-blue-300",children:l("historySyncLearningMap.cliproxyManaged",{count:x})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto_1fr_auto_1fr] sm:items-center",children:[e.jsx(R,{title:l("historySyncLearningMap.isolated"),count:s,icon:Ee,tone:"isolated"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(H,{className:"h-4 w-4"})}),e.jsx(R,{title:l("historySyncLearningMap.shared"),count:a,icon:Ue,tone:"shared"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(H,{className:"h-4 w-4"})}),e.jsx(R,{title:l("historySyncLearningMap.deeper"),count:t,icon:Ke,tone:"deeper"})]}),e.jsxs(ue,{open:m,onOpenChange:g,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-8 w-full justify-between rounded-md px-2 text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",children:[e.jsx("span",{children:l("historySyncLearningMap.showDetails")}),e.jsx(he,{className:M("h-4 w-4 transition-transform",m&&"rotate-180")})]})}),e.jsxs(me,{className:"pt-2",children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:l("historySyncLearningMap.modeSwitch")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:l("historySyncLearningMap.modeSwitchDesc")})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:l("historySyncLearningMap.historySyncGroup")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:l("historySyncLearningMap.historySyncGroupDesc")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:p.map(i=>e.jsx(F,{variant:"outline",className:"font-mono text-[10px]",children:i},i))})]})]}),o>0&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-300",children:l("historySyncLearningMap.legacyConfirmation",{count:o})})]})]})]})]})}function gt(){const{t:s}=G(),a=fe(),{data:t,isLoading:c}=Qe(),o=Je(),[x,l]=j.useState(!1),[m,g]=j.useState(!1),p=t?.accounts||[],i=t?.cliproxyCount||0,b=t?.legacyContextCount||0,f=t?.legacyContinuityCount||0,n=t?.sharedCount||0,r=t?.sharedStandardCount||0,d=t?.deeperSharedCount||0,N=t?.isolatedCount||0,P=Array.from(new Set(p.filter(C=>C.context_mode==="shared").map(C=>C.context_group||"default"))).sort((C,je)=>C.localeCompare(je)),_=p.filter(C=>C.context_inferred||C.continuity_inferred),h=_.length,pe=h>0,E=()=>a("/cliproxy?provider=claude"),U=()=>a("/cliproxy?provider=claude&action=auth"),K=()=>o.mutate(_);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden h-full min-h-0 lg:flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/20 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("accountsPage.title")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.manageSuffix")]})]}),e.jsx(ke,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("accountsPage.primaryActions")}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:()=>l(!0),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:U,children:[e.jsx(ee,{className:"w-4 h-4 mr-2"}),s("accountsPage.authClaudeInPool")]}),e.jsxs(u,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:E,children:[s("accountsPage.openClaudePoolSettings"),e.jsx(H,{className:"w-4 h-4 ml-auto"})]})]}),pe?e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("accountsPage.migrationFollowup")}),e.jsxs("div",{className:"rounded-md border border-amber-500/50 bg-amber-500/10 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ie,{className:"h-4 w-4 mt-0.5 text-amber-700 dark:text-amber-400 shrink-0"}),e.jsxs("div",{className:"space-y-1 text-xs",children:[b>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContextPending",{count:b})}),f>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContinuityPending",{count:f})})]})]}),e.jsx(u,{variant:"secondary",size:"sm",className:"w-full justify-start",onClick:K,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:s("accountsPage.noLegacyFollowup")}),e.jsx(ue,{open:m,onOpenChange:g,children:e.jsxs(A,{children:[e.jsx(S,{className:"pb-2",children:e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-auto w-full justify-between px-0 py-0",children:[e.jsxs("div",{className:"text-left",children:[e.jsx(D,{className:"text-sm",children:s("accountsPage.continuityGuide")}),e.jsx(w,{className:"mt-1",children:s("accountsPage.expandWhenNeeded")})]}),e.jsx(he,{className:M("h-4 w-4 transition-transform",m&&"rotate-180")})]})})}),e.jsx(me,{children:e.jsxs(k,{className:"space-y-3 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedStandard")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.sharedStandardDesc")})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedDeeper")}),e.jsxs("p",{className:"mt-1",children:[s("accountsPage.sharedDeeperPrefix")," ",e.jsx("code",{children:"session-env"}),","," ",e.jsx("code",{children:"file-history"}),", ",e.jsx("code",{children:"shell-snapshots"}),","," ",e.jsx("code",{children:"todos"}),"."]})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.isolated")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.isolatedDesc")})]})]})})]})}),e.jsxs(A,{children:[e.jsxs(S,{className:"pb-2",children:[e.jsx(D,{className:"text-sm",children:s("accountsPage.quickCommands")}),e.jsx(w,{children:s("accountsPage.quickCommandsDesc")})]}),e.jsxs(k,{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth create work --context-group sprint-a --deeper-continuity"}),e.jsx(W,{value:"ccs auth create work --context-group sprint-a --deeper-continuity",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs cliproxy auth claude"}),e.jsx(W,{value:"ccs cliproxy auth claude",size:"icon"})]})]})]})]})})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col bg-background",children:[e.jsxs("div",{className:"px-5 py-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{variant:"outline",children:s("accountsPage.workspaceBadge")}),e.jsx(F,{variant:"secondary",children:s("accountsPage.historySyncBadge")})]}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:s("accountsPage.authAccounts")}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[s("accountsPage.tableScopePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.tableScopeMiddle"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:s("accountsTable.sync")}),s("accountsPage.tableScopeSuffix")]})]}),e.jsxs("div",{className:"flex-1 min-h-0 p-5 space-y-4 overflow-y-auto",children:[e.jsx(ce,{isolatedCount:N,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:P,legacyTargetCount:h,cliproxyCount:i}),e.jsxs(A,{className:"flex flex-col",children:[e.jsxs(S,{className:"pb-3",children:[e.jsx(D,{className:"text-lg",children:s("accountsPage.accountMatrix")}),e.jsx(w,{children:s("accountsPage.sharedTotalDesc",{count:n})})]}),e.jsx(k,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(A,{children:[e.jsxs(S,{children:[e.jsx(D,{className:"text-lg",children:s("accountsPage.title")}),e.jsxs(w,{children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.mobileManageSuffix")]})]}),e.jsxs(k,{className:"space-y-2",children:[e.jsxs(u,{className:"w-full",onClick:()=>l(!0),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:E,children:[s("accountsPage.openCliProxyClaudePool"),e.jsx(H,{className:"w-4 h-4 ml-2"})]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:U,children:[s("accountsPage.authClaudeInPool"),e.jsx(ee,{className:"w-4 h-4 ml-2"})]}),e.jsx(u,{variant:"outline",className:"w-full",onClick:K,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}),e.jsx(ce,{isolatedCount:N,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:P,legacyTargetCount:h,cliproxyCount:i}),e.jsxs(A,{children:[e.jsx(S,{className:"pb-3",children:e.jsx(D,{className:"text-base",children:s("accountsPage.accountMatrix")})}),e.jsx(k,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]}),e.jsx(st,{open:x,onClose:()=>l(!1)})]})}export{gt as AccountsPage};
@@ -1 +1 @@
1
- import{j as e,a3 as s,a4 as r,a5 as n,a6 as i,a7 as d,a8 as c,a9 as u,aa as f}from"./radix-ui-C98W0NRG.js";import"./react-vendor-CNOkPC89.js";import{c as o,bC as l}from"./index-CcKb4PL_.js";function A({...a}){return e.jsx(s,{"data-slot":"alert-dialog",...a})}function g({...a}){return e.jsx(u,{"data-slot":"alert-dialog-portal",...a})}function m({className:a,...t}){return e.jsx(f,{"data-slot":"alert-dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...t})}function D({className:a,...t}){return e.jsxs(g,{children:[e.jsx(m,{}),e.jsx(r,{"data-slot":"alert-dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...t})]})}function b({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...t})}function N({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...t})}function v({className:a,...t}){return e.jsx(n,{"data-slot":"alert-dialog-title",className:o("text-lg font-semibold",a),...t})}function w({className:a,...t}){return e.jsx(i,{"data-slot":"alert-dialog-description",className:o("text-muted-foreground text-sm",a),...t})}function y({className:a,...t}){return e.jsx(c,{className:o(l(),a),...t})}function C({className:a,...t}){return e.jsx(d,{className:o(l({variant:"outline"}),a),...t})}export{A,D as a,b,v as c,w as d,N as e,C as f,y as g};
1
+ import{j as e,a3 as s,a4 as r,a5 as n,a6 as i,a7 as d,a8 as c,a9 as u,aa as f}from"./radix-ui-C98W0NRG.js";import"./react-vendor-CNOkPC89.js";import{c as o,bC as l}from"./index-hqC_y7jI.js";function A({...a}){return e.jsx(s,{"data-slot":"alert-dialog",...a})}function g({...a}){return e.jsx(u,{"data-slot":"alert-dialog-portal",...a})}function m({className:a,...t}){return e.jsx(f,{"data-slot":"alert-dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...t})}function D({className:a,...t}){return e.jsxs(g,{children:[e.jsx(m,{}),e.jsx(r,{"data-slot":"alert-dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...t})]})}function b({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...t})}function N({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...t})}function v({className:a,...t}){return e.jsx(n,{"data-slot":"alert-dialog-title",className:o("text-lg font-semibold",a),...t})}function w({className:a,...t}){return e.jsx(i,{"data-slot":"alert-dialog-description",className:o("text-muted-foreground text-sm",a),...t})}function y({className:a,...t}){return e.jsx(c,{className:o(l(),a),...t})}function C({className:a,...t}){return e.jsx(d,{className:o(l({variant:"outline"}),a),...t})}export{A,D as a,b,v as c,w as d,N as e,C as f,y as g};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./radix-ui-C98W0NRG.js";import{r as u,h as Ke}from"./react-vendor-CNOkPC89.js";import{B as L,c as D,T as Je,p as Be,q as qe,r as Ve,s as Ye,t as We,v as Ge,w as me,d as v,a as B,n as ae,L as R,I as U,x as J,y as Oe,z as Xe,A as Ze,D as es,E as ss,S as je,F as Z,G as xe,H as Te,J as ts,K as as,M as Ee,N as Ae,O as _e,Q as rs,R as ns,U as Ne,V as ve,W as ee,X as is,Y as os,Z as ge,C as Re,b as Me,j as ls,k as cs,_ as ds,$ as ms,a0 as us,a1 as xs,a2 as hs,a3 as ps,a4 as gs,a5 as fs,a6 as js,a7 as Ns}from"./index-CcKb4PL_.js";import{a as vs,u as be,b as we}from"./tanstack-CfKik0yL.js";import{C as he}from"./confirm-dialog-Ds0PYz2R.js";import{t as T}from"./notifications-B2HqRBj7.js";import{L as se,R as G,am as De,an as bs,a6 as te,V as ws,ao as Le,a7 as fe,C as Ie,ap as Cs,a4 as ys,aq as Ps,o as pe,X as ks,Z as Fe,ar as Ce,m as ye,as as Ue,at as Ss,aa as Os,au as Ts,v as He,av as Es,w as Qe,n as As,aw as _s}from"./icons-CeH5899d.js";import{M as $e}from"./masked-input-B_l4FMkE.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-C5RdUHi9.js";function Rs({className:s,showTooltip:r=!0}){const n=e.jsxs(L,{variant:"outline",className:D("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return r?e.jsxs(Je,{children:[e.jsx(Be,{asChild:!0,children:n}),e.jsx(qe,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Pe(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function ze(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Ms(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Ds(s,r){const n={...s};return r.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ls({profileName:s,target:r,data:n,settings:m,isLoading:c,isSaving:g,isTargetSaving:a,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:h,onDelete:b,onSave:w}){const k=g||a,j=c||k;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),ze(m)&&e.jsx(Rs,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ve,{value:r,onValueChange:S=>{j||p(S)},disabled:j,children:[e.jsx(Ye,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(We,{})}),e.jsxs(Ge,{children:[e.jsx(me,{value:"claude",children:"Claude Code"}),e.jsx(me,{value:"droid",children:"Factory Droid"}),e.jsx(me,{value:"codex",children:"Codex CLI"})]})]}),a&&e.jsx(se,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:h,disabled:j,children:e.jsx(G,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),b&&e.jsx(v,{variant:"ghost",size:"sm",onClick:b,disabled:k,children:e.jsx(De,{className:"w-4 h-4 text-destructive"})}),e.jsx(v,{size:"sm",onClick:w,disabled:k||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Is({currentSettings:s,newEnvKey:r,newEnvValue:n,onNewEnvKeyChange:m,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:a}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([t,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(R,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Pe(t)&&e.jsx(L,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Pe(t)?e.jsx($e,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"}):e.jsx(U,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"})]},t))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>m(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(U,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:a,disabled:!r.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]})}function Fs({profileName:s,target:r,data:n}){const{t:m}=B(),c=r==="droid";return e.jsx(ae,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ws,{className:"w-4 h-4"}),m("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(J,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:m("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(J,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:`ccs-droid ${s} "prompt"`}),e.jsx(J,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.overrideToClaude":"profileEditor.runOnDroidWithFlag")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s," --target ",c?"claude":"droid",' "prompt"']}),e.jsx(J,{value:`ccs ${s} --target ${c?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(J,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Us({value:s,onChange:r,placeholder:n="Search models...",className:m}){const[c,g]=u.useState(""),[a,f]=u.useState(null),{models:t,isLoading:p,isError:h,isFetching:b}=Oe(),w=Xe(),k=u.useMemo(()=>Ze(t,c,{category:a??void 0}),[t,c,a]),j=u.useMemo(()=>es(t,2),[t]),S=!c.trim()&&!a,H=u.useMemo(()=>{const d={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(x=>{d[x.category].push(x)});for(const x of Object.keys(d))d[x]=ss(d[x]);return d},[k]),C=u.useCallback(()=>{w()},[w]),M=t.find(d=>d.id===s);return p&&t.length===0?e.jsxs("div",{className:D("space-y-2",m),children:[e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-32 w-full"})]}):e.jsxs("div",{className:D("space-y-2 w-full min-w-0 overflow-hidden",m),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Le,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(U,{value:c,onChange:d=>g(d.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:b,title:"Refresh models",children:b?e.jsx(se,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(L,{variant:a===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(Z).map(d=>{const x=H[d].length;return x===0?null:e.jsxs(L,{variant:a===d?"default":"outline",className:"cursor-pointer",onClick:()=>f(d),children:[Z[d]," (",x,")"]},d)})]}),M&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:M.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[xe(M.pricing)," |"," ",Te(M.context_length)]})]}),e.jsx(ae,{className:"h-72 w-full rounded-md border",children:h?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(v,{variant:"link",onClick:C,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',c,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[S&&j.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(fe,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(d=>e.jsx(ke,{model:d,isSelected:d.id===s,onClick:()=>r(d.id),showAge:!0},d.id))})]}),Object.keys(Z).map(d=>{const x=H[d];return x.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:Z[d]}),e.jsx("div",{className:"space-y-1",children:x.map(l=>e.jsx(ke,{model:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id))})]},d)})]})})]})}function ke({model:s,isSelected:r,onClick:n,showAge:m=!1}){return e.jsxs("button",{type:"button",onClick:n,className:D("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",r&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:D("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",r?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[m&&s.created&&e.jsx(L,{variant:"outline",className:D("text-[10px] px-1",r?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:ts(s.created)}),s.isFree?e.jsx(L,{variant:"secondary",className:D("text-[10px] px-1",r?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"outline",className:D("text-[10px] px-1 border-emerald-500/50 text-emerald-600",r?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Te(s.context_length)})]})]})}function Hs({selectedModel:s,value:r,onChange:n,className:m}){const{t:c}=B(),{models:g}=Oe(),a=u.useMemo(()=>s?as(s,g):{},[s,g]),f=()=>{n(a)},t=(h,b)=>{n({...r,[h]:b||void 0})},p=s&&Object.keys(a).length>0;return e.jsxs(Ee,{className:D("group",m),children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ie,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),c("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",c("modelTierMapping.advanced"),")"]})]}),e.jsxs(_e,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(Cs,{className:"mr-1 h-4 w-4"}),c("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(U,{id:"tier-opus",value:r.opus??"",onChange:h=>t("opus",h.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(U,{id:"tier-sonnet",value:r.sonnet??"",onChange:h=>t("sonnet",h.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(U,{id:"tier-haiku",value:r.haiku??"",onChange:h=>t("haiku",h.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Qs({profileName:s,target:r,data:n,currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:h}){const b=ze(m),w=m?.env,k=u.useMemo(()=>Ms(w??{}),[w]),j=w??{},S=l=>{if(h){const Q={...j,ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};h(Q)}else t("ANTHROPIC_MODEL",l),t("ANTHROPIC_DEFAULT_OPUS_MODEL",l),t("ANTHROPIC_DEFAULT_SONNET_MODEL",l),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l);T.success(ee.t("commonToast.appliedModelAllTiers"),{duration:2e3})},H=l=>{if(h){const Q=Ds(j,l);h(Q)}else l.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",l.opus||""),l.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",l.sonnet||""),l.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l.haiku||"")},[C,M]=u.useState(!1),d=new Set(["ANTHROPIC_AUTH_TOKEN"]),x=Object.entries(j).filter(([l])=>!d.has(l));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(rs,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ns,{className:"w-full",children:[e.jsx(Ne,{value:"env",className:"flex-1",children:b?"Configuration":"Environment Variables"}),e.jsx(Ne,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(ve,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(R,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Us,{value:j.ANTHROPIC_MODEL,onChange:S,placeholder:"Search OpenRouter models..."})]}),e.jsx(Hs,{selectedModel:j.ANTHROPIC_MODEL,value:k,onChange:H}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"API Key"}),e.jsx($e,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:l=>t("ANTHROPIC_AUTH_TOKEN",l.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),x.length>0&&e.jsxs(Ee,{open:C,onOpenChange:M,children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ie,{className:D("h-4 w-4 transition-transform",C&&"rotate-90")}),e.jsx(ys,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",x.length,")"]})]}),e.jsx(_e,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:x.map(([l,Q])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:l}),e.jsx(U,{value:Q,onChange:$=>t(l,$.target.value),className:"font-mono text-xs h-8"})]},l))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:"VARIABLE_NAME",value:c,onChange:l=>a(l.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(U,{placeholder:"value",value:g,onChange:l=>f(l.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]}):e.jsx(Is,{currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(ve,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Fs,{profileName:s,target:r,data:n})})]})]})})}function $s({profileName:s,profileTarget:r,onDelete:n,onHasChangesUpdate:m}){const[c,g]=u.useState({}),[a,f]=u.useState(!1),[t,p]=u.useState(null),[h,b]=u.useState(""),[w,k]=u.useState(""),j=vs(),{data:S,isLoading:H,isError:C,refetch:M}=be({queryKey:["settings",s],queryFn:async()=>{const o=await fetch(`/api/settings/${s}/raw`);if(!o.ok)throw new Error(`Failed to load settings: ${o.status}`);return o.json()}}),d=S?.settings,x=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(d)return{...d,env:{...d.env,...c}}},[d,c,t]),l=u.useMemo(()=>t!==null?t:d?JSON.stringify(d,null,2):"",[t,d]),Q=u.useCallback(o=>{p(o)},[]),$=u.useCallback(o=>{const N={...x??{}},A=N.ccs_image&&typeof N.ccs_image=="object"?{...N.ccs_image}:{};o?A.native_read=!0:delete A.native_read,Object.keys(A).length>0?N.ccs_image=A:delete N.ccs_image,p(JSON.stringify(N,null,2))},[x]),q=(o,N)=>{const A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2))},K=o=>{const N={...x?.env||{},...o};g(A=>({...A,...o})),p(JSON.stringify({...x,env:N},null,2))},X=()=>{if(!h.trim())return;const o=h.trim(),N=w,A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2)),b(""),k("")},y=u.useMemo(()=>{try{return JSON.parse(l),!0}catch{return!1}},[l]),I=u.useMemo(()=>t!==null?t!==JSON.stringify(d,null,2):Object.keys(c).length>0,[t,c,d]),O=u.useDeferredValue(l),z=u.useMemo(()=>{if(!I||!y)return null;try{return JSON.parse(O)}catch{return null}},[I,y,O]),{data:V,isFetching:re,isError:Y,isPlaceholderData:ne}=be({queryKey:["settings",s,"image-analysis-status-preview",O],enabled:z!==null,placeholderData:o=>o,queryFn:async()=>{const o=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:z})});if(!o.ok)throw new Error(`Failed to preview image-analysis status: ${o.status}`);return o.json()}}),ie=I&&y&&!Y?V?.imageAnalysisStatus??S?.imageAnalysisStatus:S?.imageAnalysisStatus,oe=I&&y&&!Y&&V?.imageAnalysisStatus?"editor":"saved",le=I?y?Y?"saved":re&&(!V?.imageAnalysisStatus||ne)?"refreshing":"preview":"invalid":"saved",ce=x?.ccs_image?.native_read===!0,de=u.useMemo(()=>{const o=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],N=x?.env||{};return o.filter(A=>!N[A]?.trim())},[x]);u.useEffect(()=>{m?.(I)},[I,m]);const i=we({mutationFn:async()=>{let o;try{o=JSON.parse(l)}catch{o={...S?.settings,env:{...S?.settings?.env,...c}}}const N=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:o,expectedMtime:S?.mtime})});if(N.status===409)throw new Error("CONFLICT");if(!N.ok)throw new Error("Failed to save");return N.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),T.success(ee.t("commonToast.settingsSaved"))},onError:o=>{o.message==="CONFLICT"?f(!0):T.error(o.message)}}),E=we({mutationFn:async o=>(await os.profiles.update(s,{target:o}),o),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),T.success(ee.t("commonToast.defaultTargetUpdated"))},onError:(o,N)=>{const A=N==="droid"?"Factory Droid":N==="codex"?"Codex CLI":"Claude Code",W=o.message.trim()?`: ${o.message}`:"";T.error(ee.t("commonToast.failedUpdateDefaultTarget",{target:A,suffix:W}))}}),P=r||"claude",F=i.isPending||E.isPending,_=async o=>{f(!1),o?(await M(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ls,{profileName:s,target:P,data:S,settings:x,isLoading:H,isSaving:i.isPending,isTargetSaving:E.isPending,hasChanges:I,isRawJsonValid:y,onTargetChange:o=>{F||o!==P&&E.mutate(o)},onRefresh:()=>{F||M()},onDelete:n,onSave:()=>{F||i.mutate()}}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(se,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):C?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>M(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsx(Qs,{profileName:s,target:P,data:S,currentSettings:x,newEnvKey:h,newEnvValue:w,onNewEnvKeyChange:b,onNewEnvValueChange:k,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:X})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(is,{rawJsonContent:l,isRawJsonValid:y,rawJsonEdits:t,settings:d,profileTarget:P,imageAnalysisStatus:ie,imageAnalysisStatusSource:oe,imageAnalysisStatusPreviewState:le,nativeReadPreferenceOverride:ce,onToggleNativeRead:$,onChange:Q,missingRequiredFields:de})]})]}),e.jsx(he,{open:a,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>_(!0),onCancel:()=>_(!1)})]},s)}const Se="ccs:openrouter-banner-dismissed";function zs({onCreateClick:s}){const[r,n]=u.useState(!0),{modelCount:m,isLoading:c}=ge();u.useEffect(()=>{const a=localStorage.getItem(Se)==="true";n(a)},[]);const g=()=>{localStorage.setItem(Se,"true"),n(!0)};return r?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(fe,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",c?"300+":`${m}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(v,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(pe,{className:"w-3 h-3"})]}),e.jsxs(v,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ue({badge:s,badgeClassName:r,className:n,title:m,description:c,visual:g,highlights:a,actionLabel:f,actionClassName:t,onAction:p,footer:h}){return e.jsxs(Re,{className:D("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(ls,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(L,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(cs,{className:"text-base",children:m}),e.jsx(ds,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Me,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:a.map(b=>e.jsxs("div",{className:"flex items-center gap-2",children:[b.icon,e.jsx("span",{children:b.label})]},b.label))}),e.jsxs(v,{onClick:p,className:t,children:[f,e.jsx(Ss,{className:"ml-2 h-4 w-4"})]}),h?e.jsx("div",{className:"text-xs text-muted-foreground",children:h}):null]})]})}function Ks({hasProfiles:s,profileCount:r,onOpenRouterClick:n,onAlibabaCodingPlanClick:m,onCliproxyClick:c,onCustomClick:g}){const{t:a}=B(),{modelCount:f,isLoading:t}=ge(),p=t?"300+":`${f}+`,h=s?a("openrouterQuickStart.profileCount",{count:r}):a("openrouterQuickStart.recommended"),b=a(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),w=s?a("openrouterQuickStart.summaryDescriptionWithProfiles",{count:r}):a("openrouterQuickStart.summaryDescriptionNoProfiles");return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-4",children:[e.jsx(Re,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Me,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:h}),e.jsx(L,{variant:"outline",children:a("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:b}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:w})]})]}),e.jsx(v,{variant:"outline",onClick:g,className:"shrink-0",children:a("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ue,{badge:a("openrouterQuickStart.recommended"),title:a("openrouterQuickStart.title"),description:a("openrouterQuickStart.description",{modelCountLabel:p}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureOneApi")},{icon:e.jsx(fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureTierMapping")}],actionLabel:a("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[a("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(pe,{className:"h-3 w-3"})]})]})}),e.jsx(ue,{badge:a("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:a("openrouterQuickStart.runtimeProviderTitle"),description:a("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(Ce,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(Ce,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:a("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:c,footer:e.jsx("span",{children:a("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ue,{badge:a("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",className:"lg:col-span-2",title:a("alibabaCodingPlanQuickStart.title"),description:a("alibabaCodingPlanQuickStart.description"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Ue,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:a("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:m,footer:e.jsxs(e.Fragment,{children:[a("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(pe,{className:"h-3 w-3"})]})]})})]})]})})}function Js({onCreateClick:s}){const{modelCount:r,isLoading:n}=ge();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${r}+`," models available"]})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(Fe,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Bs({onCreateClick:s}){const{t:r}=B();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:r("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function it(){const{t:s}=B(),r=Ke(),{data:n,isLoading:m,isError:c,refetch:g}=ms(),a=us(),f=xs(),t=hs(),p=ps(),h=gs(),b=fs(),[w,k]=u.useState(null),[j,S]=u.useState(""),[H,C]=u.useState(!1),[M,d]=u.useState("normal"),[x,l]=u.useState(null),[Q,$]=u.useState(!1),[q,K]=u.useState(null),X=u.useRef(null);js();const y=u.useMemo(()=>n?.profiles||[],[n?.profiles]),I=u.useMemo(()=>y.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[y,j]),O=w?y.find(i=>i.name===w):null,z=i=>{Q&&w!==i?K(i):k(i)},V=i=>{a.mutate(i,{onSuccess:()=>{w===i&&(k(null),$(!1),K(null)),l(null)}})},re=i=>{C(!1),z(i)},Y=i=>{z(i)},ne=(i,E)=>{const P=JSON.stringify(E,null,2)+`
1
+ import{j as e}from"./radix-ui-C98W0NRG.js";import{r as u,h as Ke}from"./react-vendor-CNOkPC89.js";import{B as L,c as D,T as Je,p as Be,q as qe,r as Ve,s as Ye,t as We,v as Ge,w as me,d as v,a as B,n as ae,L as R,I as U,x as J,y as Oe,z as Xe,A as Ze,D as es,E as ss,S as je,F as Z,G as xe,H as Te,J as ts,K as as,M as Ee,N as Ae,O as _e,Q as rs,R as ns,U as Ne,V as ve,W as ee,X as is,Y as os,Z as ge,C as Re,b as Me,j as ls,k as cs,_ as ds,$ as ms,a0 as us,a1 as xs,a2 as hs,a3 as ps,a4 as gs,a5 as fs,a6 as js,a7 as Ns}from"./index-hqC_y7jI.js";import{a as vs,u as be,b as we}from"./tanstack-CfKik0yL.js";import{C as he}from"./confirm-dialog-X8zTaDqZ.js";import{t as T}from"./notifications-B2HqRBj7.js";import{L as se,R as G,am as De,an as bs,a6 as te,V as ws,ao as Le,a7 as fe,C as Ie,ap as Cs,a4 as ys,aq as Ps,o as pe,X as ks,Z as Fe,ar as Ce,m as ye,as as Ue,at as Ss,aa as Os,au as Ts,v as He,av as Es,w as Qe,n as As,aw as _s}from"./icons-CeH5899d.js";import{M as $e}from"./masked-input-DR7oSJEW.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-0MtCFagW.js";function Rs({className:s,showTooltip:r=!0}){const n=e.jsxs(L,{variant:"outline",className:D("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return r?e.jsxs(Je,{children:[e.jsx(Be,{asChild:!0,children:n}),e.jsx(qe,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Pe(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function ze(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Ms(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Ds(s,r){const n={...s};return r.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ls({profileName:s,target:r,data:n,settings:m,isLoading:c,isSaving:g,isTargetSaving:a,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:h,onDelete:b,onSave:w}){const k=g||a,j=c||k;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),ze(m)&&e.jsx(Rs,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ve,{value:r,onValueChange:S=>{j||p(S)},disabled:j,children:[e.jsx(Ye,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(We,{})}),e.jsxs(Ge,{children:[e.jsx(me,{value:"claude",children:"Claude Code"}),e.jsx(me,{value:"droid",children:"Factory Droid"}),e.jsx(me,{value:"codex",children:"Codex CLI"})]})]}),a&&e.jsx(se,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:h,disabled:j,children:e.jsx(G,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),b&&e.jsx(v,{variant:"ghost",size:"sm",onClick:b,disabled:k,children:e.jsx(De,{className:"w-4 h-4 text-destructive"})}),e.jsx(v,{size:"sm",onClick:w,disabled:k||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Is({currentSettings:s,newEnvKey:r,newEnvValue:n,onNewEnvKeyChange:m,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:a}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([t,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(R,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Pe(t)&&e.jsx(L,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Pe(t)?e.jsx($e,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"}):e.jsx(U,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"})]},t))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>m(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(U,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:a,disabled:!r.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]})}function Fs({profileName:s,target:r,data:n}){const{t:m}=B(),c=r==="droid";return e.jsx(ae,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ws,{className:"w-4 h-4"}),m("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(J,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:m("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(J,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:`ccs-droid ${s} "prompt"`}),e.jsx(J,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.overrideToClaude":"profileEditor.runOnDroidWithFlag")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s," --target ",c?"claude":"droid",' "prompt"']}),e.jsx(J,{value:`ccs ${s} --target ${c?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(J,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Us({value:s,onChange:r,placeholder:n="Search models...",className:m}){const[c,g]=u.useState(""),[a,f]=u.useState(null),{models:t,isLoading:p,isError:h,isFetching:b}=Oe(),w=Xe(),k=u.useMemo(()=>Ze(t,c,{category:a??void 0}),[t,c,a]),j=u.useMemo(()=>es(t,2),[t]),S=!c.trim()&&!a,H=u.useMemo(()=>{const d={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(x=>{d[x.category].push(x)});for(const x of Object.keys(d))d[x]=ss(d[x]);return d},[k]),C=u.useCallback(()=>{w()},[w]),M=t.find(d=>d.id===s);return p&&t.length===0?e.jsxs("div",{className:D("space-y-2",m),children:[e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-32 w-full"})]}):e.jsxs("div",{className:D("space-y-2 w-full min-w-0 overflow-hidden",m),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Le,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(U,{value:c,onChange:d=>g(d.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:b,title:"Refresh models",children:b?e.jsx(se,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(L,{variant:a===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(Z).map(d=>{const x=H[d].length;return x===0?null:e.jsxs(L,{variant:a===d?"default":"outline",className:"cursor-pointer",onClick:()=>f(d),children:[Z[d]," (",x,")"]},d)})]}),M&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:M.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[xe(M.pricing)," |"," ",Te(M.context_length)]})]}),e.jsx(ae,{className:"h-72 w-full rounded-md border",children:h?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(v,{variant:"link",onClick:C,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',c,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[S&&j.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(fe,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(d=>e.jsx(ke,{model:d,isSelected:d.id===s,onClick:()=>r(d.id),showAge:!0},d.id))})]}),Object.keys(Z).map(d=>{const x=H[d];return x.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:Z[d]}),e.jsx("div",{className:"space-y-1",children:x.map(l=>e.jsx(ke,{model:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id))})]},d)})]})})]})}function ke({model:s,isSelected:r,onClick:n,showAge:m=!1}){return e.jsxs("button",{type:"button",onClick:n,className:D("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",r&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:D("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",r?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[m&&s.created&&e.jsx(L,{variant:"outline",className:D("text-[10px] px-1",r?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:ts(s.created)}),s.isFree?e.jsx(L,{variant:"secondary",className:D("text-[10px] px-1",r?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"outline",className:D("text-[10px] px-1 border-emerald-500/50 text-emerald-600",r?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Te(s.context_length)})]})]})}function Hs({selectedModel:s,value:r,onChange:n,className:m}){const{t:c}=B(),{models:g}=Oe(),a=u.useMemo(()=>s?as(s,g):{},[s,g]),f=()=>{n(a)},t=(h,b)=>{n({...r,[h]:b||void 0})},p=s&&Object.keys(a).length>0;return e.jsxs(Ee,{className:D("group",m),children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ie,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),c("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",c("modelTierMapping.advanced"),")"]})]}),e.jsxs(_e,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(Cs,{className:"mr-1 h-4 w-4"}),c("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(U,{id:"tier-opus",value:r.opus??"",onChange:h=>t("opus",h.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(U,{id:"tier-sonnet",value:r.sonnet??"",onChange:h=>t("sonnet",h.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(U,{id:"tier-haiku",value:r.haiku??"",onChange:h=>t("haiku",h.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Qs({profileName:s,target:r,data:n,currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:h}){const b=ze(m),w=m?.env,k=u.useMemo(()=>Ms(w??{}),[w]),j=w??{},S=l=>{if(h){const Q={...j,ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};h(Q)}else t("ANTHROPIC_MODEL",l),t("ANTHROPIC_DEFAULT_OPUS_MODEL",l),t("ANTHROPIC_DEFAULT_SONNET_MODEL",l),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l);T.success(ee.t("commonToast.appliedModelAllTiers"),{duration:2e3})},H=l=>{if(h){const Q=Ds(j,l);h(Q)}else l.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",l.opus||""),l.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",l.sonnet||""),l.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l.haiku||"")},[C,M]=u.useState(!1),d=new Set(["ANTHROPIC_AUTH_TOKEN"]),x=Object.entries(j).filter(([l])=>!d.has(l));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(rs,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ns,{className:"w-full",children:[e.jsx(Ne,{value:"env",className:"flex-1",children:b?"Configuration":"Environment Variables"}),e.jsx(Ne,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(ve,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(R,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Us,{value:j.ANTHROPIC_MODEL,onChange:S,placeholder:"Search OpenRouter models..."})]}),e.jsx(Hs,{selectedModel:j.ANTHROPIC_MODEL,value:k,onChange:H}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"API Key"}),e.jsx($e,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:l=>t("ANTHROPIC_AUTH_TOKEN",l.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),x.length>0&&e.jsxs(Ee,{open:C,onOpenChange:M,children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ie,{className:D("h-4 w-4 transition-transform",C&&"rotate-90")}),e.jsx(ys,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",x.length,")"]})]}),e.jsx(_e,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:x.map(([l,Q])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:l}),e.jsx(U,{value:Q,onChange:$=>t(l,$.target.value),className:"font-mono text-xs h-8"})]},l))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:"VARIABLE_NAME",value:c,onChange:l=>a(l.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(U,{placeholder:"value",value:g,onChange:l=>f(l.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]}):e.jsx(Is,{currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(ve,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Fs,{profileName:s,target:r,data:n})})]})]})})}function $s({profileName:s,profileTarget:r,onDelete:n,onHasChangesUpdate:m}){const[c,g]=u.useState({}),[a,f]=u.useState(!1),[t,p]=u.useState(null),[h,b]=u.useState(""),[w,k]=u.useState(""),j=vs(),{data:S,isLoading:H,isError:C,refetch:M}=be({queryKey:["settings",s],queryFn:async()=>{const o=await fetch(`/api/settings/${s}/raw`);if(!o.ok)throw new Error(`Failed to load settings: ${o.status}`);return o.json()}}),d=S?.settings,x=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(d)return{...d,env:{...d.env,...c}}},[d,c,t]),l=u.useMemo(()=>t!==null?t:d?JSON.stringify(d,null,2):"",[t,d]),Q=u.useCallback(o=>{p(o)},[]),$=u.useCallback(o=>{const N={...x??{}},A=N.ccs_image&&typeof N.ccs_image=="object"?{...N.ccs_image}:{};o?A.native_read=!0:delete A.native_read,Object.keys(A).length>0?N.ccs_image=A:delete N.ccs_image,p(JSON.stringify(N,null,2))},[x]),q=(o,N)=>{const A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2))},K=o=>{const N={...x?.env||{},...o};g(A=>({...A,...o})),p(JSON.stringify({...x,env:N},null,2))},X=()=>{if(!h.trim())return;const o=h.trim(),N=w,A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2)),b(""),k("")},y=u.useMemo(()=>{try{return JSON.parse(l),!0}catch{return!1}},[l]),I=u.useMemo(()=>t!==null?t!==JSON.stringify(d,null,2):Object.keys(c).length>0,[t,c,d]),O=u.useDeferredValue(l),z=u.useMemo(()=>{if(!I||!y)return null;try{return JSON.parse(O)}catch{return null}},[I,y,O]),{data:V,isFetching:re,isError:Y,isPlaceholderData:ne}=be({queryKey:["settings",s,"image-analysis-status-preview",O],enabled:z!==null,placeholderData:o=>o,queryFn:async()=>{const o=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:z})});if(!o.ok)throw new Error(`Failed to preview image-analysis status: ${o.status}`);return o.json()}}),ie=I&&y&&!Y?V?.imageAnalysisStatus??S?.imageAnalysisStatus:S?.imageAnalysisStatus,oe=I&&y&&!Y&&V?.imageAnalysisStatus?"editor":"saved",le=I?y?Y?"saved":re&&(!V?.imageAnalysisStatus||ne)?"refreshing":"preview":"invalid":"saved",ce=x?.ccs_image?.native_read===!0,de=u.useMemo(()=>{const o=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],N=x?.env||{};return o.filter(A=>!N[A]?.trim())},[x]);u.useEffect(()=>{m?.(I)},[I,m]);const i=we({mutationFn:async()=>{let o;try{o=JSON.parse(l)}catch{o={...S?.settings,env:{...S?.settings?.env,...c}}}const N=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:o,expectedMtime:S?.mtime})});if(N.status===409)throw new Error("CONFLICT");if(!N.ok)throw new Error("Failed to save");return N.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),T.success(ee.t("commonToast.settingsSaved"))},onError:o=>{o.message==="CONFLICT"?f(!0):T.error(o.message)}}),E=we({mutationFn:async o=>(await os.profiles.update(s,{target:o}),o),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),T.success(ee.t("commonToast.defaultTargetUpdated"))},onError:(o,N)=>{const A=N==="droid"?"Factory Droid":N==="codex"?"Codex CLI":"Claude Code",W=o.message.trim()?`: ${o.message}`:"";T.error(ee.t("commonToast.failedUpdateDefaultTarget",{target:A,suffix:W}))}}),P=r||"claude",F=i.isPending||E.isPending,_=async o=>{f(!1),o?(await M(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ls,{profileName:s,target:P,data:S,settings:x,isLoading:H,isSaving:i.isPending,isTargetSaving:E.isPending,hasChanges:I,isRawJsonValid:y,onTargetChange:o=>{F||o!==P&&E.mutate(o)},onRefresh:()=>{F||M()},onDelete:n,onSave:()=>{F||i.mutate()}}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(se,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):C?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>M(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsx(Qs,{profileName:s,target:P,data:S,currentSettings:x,newEnvKey:h,newEnvValue:w,onNewEnvKeyChange:b,onNewEnvValueChange:k,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:X})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(is,{rawJsonContent:l,isRawJsonValid:y,rawJsonEdits:t,settings:d,profileTarget:P,imageAnalysisStatus:ie,imageAnalysisStatusSource:oe,imageAnalysisStatusPreviewState:le,nativeReadPreferenceOverride:ce,onToggleNativeRead:$,onChange:Q,missingRequiredFields:de})]})]}),e.jsx(he,{open:a,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>_(!0),onCancel:()=>_(!1)})]},s)}const Se="ccs:openrouter-banner-dismissed";function zs({onCreateClick:s}){const[r,n]=u.useState(!0),{modelCount:m,isLoading:c}=ge();u.useEffect(()=>{const a=localStorage.getItem(Se)==="true";n(a)},[]);const g=()=>{localStorage.setItem(Se,"true"),n(!0)};return r?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(fe,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",c?"300+":`${m}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(v,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(pe,{className:"w-3 h-3"})]}),e.jsxs(v,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ue({badge:s,badgeClassName:r,className:n,title:m,description:c,visual:g,highlights:a,actionLabel:f,actionClassName:t,onAction:p,footer:h}){return e.jsxs(Re,{className:D("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(ls,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(L,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(cs,{className:"text-base",children:m}),e.jsx(ds,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Me,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:a.map(b=>e.jsxs("div",{className:"flex items-center gap-2",children:[b.icon,e.jsx("span",{children:b.label})]},b.label))}),e.jsxs(v,{onClick:p,className:t,children:[f,e.jsx(Ss,{className:"ml-2 h-4 w-4"})]}),h?e.jsx("div",{className:"text-xs text-muted-foreground",children:h}):null]})]})}function Ks({hasProfiles:s,profileCount:r,onOpenRouterClick:n,onAlibabaCodingPlanClick:m,onCliproxyClick:c,onCustomClick:g}){const{t:a}=B(),{modelCount:f,isLoading:t}=ge(),p=t?"300+":`${f}+`,h=s?a("openrouterQuickStart.profileCount",{count:r}):a("openrouterQuickStart.recommended"),b=a(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),w=s?a("openrouterQuickStart.summaryDescriptionWithProfiles",{count:r}):a("openrouterQuickStart.summaryDescriptionNoProfiles");return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-4",children:[e.jsx(Re,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Me,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:h}),e.jsx(L,{variant:"outline",children:a("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:b}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:w})]})]}),e.jsx(v,{variant:"outline",onClick:g,className:"shrink-0",children:a("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ue,{badge:a("openrouterQuickStart.recommended"),title:a("openrouterQuickStart.title"),description:a("openrouterQuickStart.description",{modelCountLabel:p}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureOneApi")},{icon:e.jsx(fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureTierMapping")}],actionLabel:a("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[a("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(pe,{className:"h-3 w-3"})]})]})}),e.jsx(ue,{badge:a("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:a("openrouterQuickStart.runtimeProviderTitle"),description:a("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(Ce,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(Ce,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:a("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:c,footer:e.jsx("span",{children:a("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ue,{badge:a("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",className:"lg:col-span-2",title:a("alibabaCodingPlanQuickStart.title"),description:a("alibabaCodingPlanQuickStart.description"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Ue,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:a("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:m,footer:e.jsxs(e.Fragment,{children:[a("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(pe,{className:"h-3 w-3"})]})]})})]})]})})}function Js({onCreateClick:s}){const{modelCount:r,isLoading:n}=ge();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${r}+`," models available"]})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(Fe,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Bs({onCreateClick:s}){const{t:r}=B();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:r("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function it(){const{t:s}=B(),r=Ke(),{data:n,isLoading:m,isError:c,refetch:g}=ms(),a=us(),f=xs(),t=hs(),p=ps(),h=gs(),b=fs(),[w,k]=u.useState(null),[j,S]=u.useState(""),[H,C]=u.useState(!1),[M,d]=u.useState("normal"),[x,l]=u.useState(null),[Q,$]=u.useState(!1),[q,K]=u.useState(null),X=u.useRef(null);js();const y=u.useMemo(()=>n?.profiles||[],[n?.profiles]),I=u.useMemo(()=>y.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[y,j]),O=w?y.find(i=>i.name===w):null,z=i=>{Q&&w!==i?K(i):k(i)},V=i=>{a.mutate(i,{onSuccess:()=>{w===i&&(k(null),$(!1),K(null)),l(null)}})},re=i=>{C(!1),z(i)},Y=i=>{z(i)},ne=(i,E)=>{const P=JSON.stringify(E,null,2)+`
2
2
  `,F=new Blob([P],{type:"application/json"}),_=URL.createObjectURL(F),o=document.createElement("a");o.href=_,o.download=i,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(_)},ie=async()=>{try{const i=await f.mutateAsync();if(i.orphans.length===0){T.success("No orphan profile settings found");return}const E=i.orphans.filter(o=>o.validation.valid).length;if(!window.confirm(`Found ${i.orphans.length} orphan settings file(s). Register ${E} valid profile(s) now?`))return;const F=await t.mutateAsync({}),_=F.skipped.length>0?`, skipped ${F.skipped.length}`:"";T.success(`Registered ${F.registered.length} profile(s)${_}`)}catch(i){T.error(i.message)}},oe=async()=>{if(!O)return;const i=window.prompt(`Copy profile "${O.name}" to new profile name:`,`${O.name}-copy`);if(!i)return;const E=i.trim();if(!E){T.error("Destination profile name cannot be empty");return}try{const P=await p.mutateAsync({name:O.name,data:{destination:E}});z(E),P.warnings&&P.warnings.length>0&&T.info(P.warnings.join(`
3
3
  `))}catch(P){T.error(P.message)}},le=async()=>{if(O)try{const i=await h.mutateAsync({name:O.name});ne(`${O.name}.ccs-profile.json`,i.bundle),i.redacted?T.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):T.success("Profile export downloaded")}catch(i){T.error(i.message)}},ce=()=>{X.current?.click()},de=async i=>{const E=i.target.files?.[0];if(i.target.value="",!!E)try{const P=await E.text(),F=JSON.parse(P),_=await b.mutateAsync({bundle:F});_.name&&z(_.name),_.warnings&&_.warnings.length>0&&T.info(_.warnings.join(`
4
4
  `))}catch(P){T.error(P.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx(zs,{onCreateClick:()=>C(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Os,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.title")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(v,{size:"sm",variant:"outline",onClick:()=>void ie(),disabled:f.isPending||t.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(G,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(v,{size:"sm",variant:"outline",onClick:ce,disabled:b.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(Ts,{className:"w-4 h-4"})}),e.jsxs(v,{size:"sm",onClick:()=>{C(!0)},children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:j,onChange:i=>S(i.target.value)})]})]}),e.jsx(ae,{className:"flex-1 min-h-0",children:m?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):c?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(He,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.failedLoadTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.failedLoadDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):I.length===0?e.jsx("div",{className:"p-4 text-center",children:y.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Es,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.noProfilesYet")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.noProfilesDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>{C(!0)},children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),s("apiProfiles.createProfile")]})]}):e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:s("apiProfiles.noProfileMatch",{query:j})})}):e.jsx("div",{className:"p-2 space-y-1",children:I.map(i=>e.jsx(qs,{profile:i,isSelected:w===i.name,onSelect:()=>Y(i.name),onDelete:()=>l(i.name)},i.name))})}),y.length>0&&e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("apiProfiles.profileCount",{count:y.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Qe,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:y.filter(i=>i.configured).length})]})]})}),e.jsx(Js,{onCreateClick:()=>{d("openrouter"),C(!0)}}),e.jsx(Bs,{onCreateClick:()=>{d("alibaba-coding-plan"),C(!0)}})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col min-w-0 overflow-hidden",children:O?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-2 border-b bg-background flex items-center justify-end gap-2",children:[e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>void oe(),disabled:p.isPending,children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>void le(),disabled:h.isPending,children:[e.jsx(_s,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx($s,{profileName:O.name,profileTarget:O.target,onDelete:()=>l(O.name),onHasChangesUpdate:$},O.name)]}):e.jsx(Ks,{hasProfiles:y.length>0,profileCount:y.length,onCliproxyClick:()=>{r("/cliproxy/ai-providers")},onOpenRouterClick:()=>{d("openrouter"),C(!0)},onAlibabaCodingPlanClick:()=>{d("alibaba-coding-plan"),C(!0)},onCustomClick:()=>{d("normal"),C(!0)}})})]}),e.jsx("input",{ref:X,type:"file",accept:".json,application/json",className:"hidden",onChange:i=>void de(i)}),e.jsx(Ns,{open:H,onOpenChange:C,onSuccess:re,initialMode:M}),e.jsx(he,{open:!!x,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:x??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>x&&V(x),onCancel:()=>l(null)}),e.jsx(he,{open:!!q,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:w??"",next:q??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{$(!1),k(q),K(null)},onCancel:()=>K(null)})]})}function qs({profile:s,isSelected:r,onSelect:n,onDelete:m}){return e.jsxs("div",{className:D("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",r?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(Qe,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(He,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(L,{variant:"outline",className:"text-[10px] h-4 px-1.5 uppercase",children:s.target||"claude"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(J,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),m()},children:e.jsx(De,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{it as ApiPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-C98W0NRG.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bl as W,b5 as X,b7 as Y,n as Z,I as C,d as c}from"./index-CcKb4PL_.js";import{R as E,v as _,w as ee,m as se,E as K,f as T,l as R,n as z,aG as te,a7 as ae,N as ne,an as re}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function pe(){const{t:s}=V(),{fetchRawConfig:o}=W(),[a,D]=n.useState(null),[j,S]=n.useState(!0),[i,m]=n.useState(!1),[p,r]=n.useState(null),[g,f]=n.useState(null),[w,P]=n.useState(!1),[y,O]=n.useState(!1),[d,N]=n.useState(null),[u,v]=n.useState(null),[$,b]=n.useState(!1),[F,k]=n.useState(!1),h=n.useCallback(async()=>{try{S(!0),r(null);const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error(s("settingsAuth.failedFetchTokens"));const l=await t.json();D(l)}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{S(!1)}},[s]);n.useEffect(()=>{h(),o()},[h,o]),n.useEffect(()=>{if(g){const t=setTimeout(()=>f(null),3e3);return()=>clearTimeout(t)}},[g]),n.useEffect(()=>{if(p){const t=setTimeout(()=>r(null),5e3);return()=>clearTimeout(t)}},[p]);const I=async()=>{const t=d!==null&&d!==a?.apiKey.value,l=u!==null&&u!==a?.managementSecret.value;if(!(!t&&!l))try{m(!0),r(null);const x={};t&&(x.apiKey=d),l&&(x.managementSecret=u);const A=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!A.ok){const Q=await A.json();throw new Error(Q.error||s("settingsAuth.failedSaveTokens"))}f(s("settingsAuth.tokensUpdated")),N(null),v(null),await h(),await o()}catch(x){r(x instanceof Error?x.message:s("settings.unknownError"))}finally{m(!1)}},U=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedRegenerate"))}f(s("settingsAuth.secretRegenerated")),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},B=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedReset"))}f(s("settingsAuth.tokensReset")),N(null),v(null),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},G=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),b(!0),setTimeout(()=>b(!1),2e3))},J=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),k(!0),setTimeout(()=>k(!1),2e3))},L=async()=>{j||i||(r(null),f(null),await Promise.all([h(),o()]))};if(j||!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(E,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const q=d??a.apiKey.value,H=u??a.managementSecret.value,M=d!==null&&d!==a.apiKey.value||u!==null&&u!==a.managementSecret.value;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${p||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[p&&e.jsxs(X,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(Y,{children:p})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(Z,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsAuth.description")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.apiKey")}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.apiKeyDesc")}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:w?"text":"password",value:q,onChange:t=>N(t.target.value),placeholder:s("settingsAuth.apiKeyPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P(!w),children:w?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:G,disabled:!a.apiKey.value,children:$?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.managementSecret")}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.managementSecretDesc")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:y?"text":"password",value:H,onChange:t=>v(t.target.value),placeholder:s("settingsAuth.managementSecretPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>O(!y),children:y?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:J,disabled:!a.managementSecret.value,children:F?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]}),e.jsx(c,{variant:"outline",size:"sm",onClick:U,disabled:i,title:s("settingsAuth.generateSecret"),children:e.jsx(ae,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:B,disabled:i||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),s("settingsAuth.resetDefaults")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:s("settingsAuth.resetDesc")})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:L,disabled:j||i,className:"flex-1",children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),s("settings.refresh")]}),e.jsxs(c,{variant:"default",size:"sm",onClick:I,disabled:!M||i,className:"flex-1",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${i?"animate-pulse":""}`}),s(i?"settingsAuth.saving":"settingsAuth.save")]})]})]})}export{pe as default};
1
+ import{j as e}from"./radix-ui-C98W0NRG.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bl as W,b5 as X,b7 as Y,n as Z,I as C,d as c}from"./index-hqC_y7jI.js";import{R as E,v as _,w as ee,m as se,E as K,f as T,l as R,n as z,aG as te,a7 as ae,N as ne,an as re}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function pe(){const{t:s}=V(),{fetchRawConfig:o}=W(),[a,D]=n.useState(null),[j,S]=n.useState(!0),[i,m]=n.useState(!1),[p,r]=n.useState(null),[g,f]=n.useState(null),[w,P]=n.useState(!1),[y,O]=n.useState(!1),[d,N]=n.useState(null),[u,v]=n.useState(null),[$,b]=n.useState(!1),[F,k]=n.useState(!1),h=n.useCallback(async()=>{try{S(!0),r(null);const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error(s("settingsAuth.failedFetchTokens"));const l=await t.json();D(l)}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{S(!1)}},[s]);n.useEffect(()=>{h(),o()},[h,o]),n.useEffect(()=>{if(g){const t=setTimeout(()=>f(null),3e3);return()=>clearTimeout(t)}},[g]),n.useEffect(()=>{if(p){const t=setTimeout(()=>r(null),5e3);return()=>clearTimeout(t)}},[p]);const I=async()=>{const t=d!==null&&d!==a?.apiKey.value,l=u!==null&&u!==a?.managementSecret.value;if(!(!t&&!l))try{m(!0),r(null);const x={};t&&(x.apiKey=d),l&&(x.managementSecret=u);const A=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!A.ok){const Q=await A.json();throw new Error(Q.error||s("settingsAuth.failedSaveTokens"))}f(s("settingsAuth.tokensUpdated")),N(null),v(null),await h(),await o()}catch(x){r(x instanceof Error?x.message:s("settings.unknownError"))}finally{m(!1)}},U=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedRegenerate"))}f(s("settingsAuth.secretRegenerated")),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},B=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedReset"))}f(s("settingsAuth.tokensReset")),N(null),v(null),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},G=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),b(!0),setTimeout(()=>b(!1),2e3))},J=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),k(!0),setTimeout(()=>k(!1),2e3))},L=async()=>{j||i||(r(null),f(null),await Promise.all([h(),o()]))};if(j||!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(E,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const q=d??a.apiKey.value,H=u??a.managementSecret.value,M=d!==null&&d!==a.apiKey.value||u!==null&&u!==a.managementSecret.value;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${p||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[p&&e.jsxs(X,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(Y,{children:p})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(Z,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsAuth.description")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.apiKey")}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.apiKeyDesc")}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:w?"text":"password",value:q,onChange:t=>N(t.target.value),placeholder:s("settingsAuth.apiKeyPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P(!w),children:w?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:G,disabled:!a.apiKey.value,children:$?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.managementSecret")}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.managementSecretDesc")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:y?"text":"password",value:H,onChange:t=>v(t.target.value),placeholder:s("settingsAuth.managementSecretPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>O(!y),children:y?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:J,disabled:!a.managementSecret.value,children:F?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]}),e.jsx(c,{variant:"outline",size:"sm",onClick:U,disabled:i,title:s("settingsAuth.generateSecret"),children:e.jsx(ae,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:B,disabled:i||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),s("settingsAuth.resetDefaults")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:s("settingsAuth.resetDesc")})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:L,disabled:j||i,className:"flex-1",children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),s("settings.refresh")]}),e.jsxs(c,{variant:"default",size:"sm",onClick:I,disabled:!M||i,className:"flex-1",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${i?"animate-pulse":""}`}),s(i?"settingsAuth.saving":"settingsAuth.save")]})]})]})}export{pe as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-C98W0NRG.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bl as E,n as k,S as n,C as g,b5 as R,b7 as D,B as T,d as C}from"./index-CcKb4PL_.js";import{A as O,a as _,b as F,c as I,d as P,e as z,f as L,g as U}from"./alert-dialog-C5RdUHi9.js";import{v as $,w as H,ab as v,u as M,N as Y,R as J}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q=3e3,G=5e3;function ae(){const{t}=S(),{fetchRawConfig:p}=E(),m=r.useRef(null),d=r.useRef(null),[j,y]=r.useState([]),[f,N]=r.useState(!0),[u,w]=r.useState(null),[i,l]=r.useState(null),[c,b]=r.useState(null),[x,h]=r.useState(null),o=r.useCallback(async()=>{m.current?.abort(),m.current=new AbortController;try{N(!0),l(null);const s=await fetch("/api/persist/backups",{signal:m.current.signal});if(!s.ok)throw new Error(t("settingsBackups.failedFetch"));const a=await s.json();y(a.backups||[])}catch(s){if(s instanceof Error&&s.name==="AbortError")return;l(s instanceof Error?s.message:t("settings.unknownError"))}finally{N(!1)}},[t]),A=r.useCallback(async s=>{d.current?.abort(),d.current=new AbortController;try{w(s),l(null);const a=await fetch("/api/persist/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timestamp:s}),signal:d.current.signal});if(!a.ok){const B=await a.json();throw new Error(B.error||t("settingsBackups.failedRestore"))}b(t("settingsBackups.restoreSuccess")),await o(),await p()}catch(a){if(a instanceof Error&&a.name==="AbortError")return;l(a instanceof Error?a.message:t("settings.unknownError"))}finally{w(null)}},[o,p,t]);return r.useEffect(()=>{o()},[o]),r.useEffect(()=>()=>{m.current?.abort(),d.current?.abort()},[]),r.useEffect(()=>{if(c){const s=setTimeout(()=>b(null),q);return()=>clearTimeout(s)}},[c]),r.useEffect(()=>{if(i){const s=setTimeout(()=>l(null),G);return()=>clearTimeout(s)}},[i]),f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"h-6 w-40"}),e.jsx(n,{className:"h-4 w-full"})]}),[1,2,3].map(s=>e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(n,{className:"h-4 w-32"}),e.jsx(n,{className:"h-3 w-48"})]}),e.jsx(n,{className:"h-8 w-20"})]})},s))]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsx(n,{className:"h-9 w-full"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${i||c?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[i&&e.jsxs(R,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx(D,{children:i})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(H,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:c})]})]}),e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold",children:t("settingsBackups.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.description")})]}),j.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-3 opacity-30 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.none")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("settingsBackups.noneHint")})]})}):e.jsx("div",{className:"space-y-2",children:j.map((s,a)=>e.jsx(g,{className:"p-4 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(M,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium font-mono",children:s.timestamp}),a===0&&e.jsx(T,{variant:"secondary",className:"text-xs",children:t("settingsBackups.latest")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.date})]})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>h(s.timestamp),disabled:u!==null,className:"gap-2 shrink-0",children:[e.jsx(Y,{className:`w-4 h-4 ${u===s.timestamp?"animate-spin":""}`}),u===s.timestamp?t("settingsBackups.restoring"):t("settingsBackups.restore")]})]})},s.timestamp))})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{o(),p()},disabled:f||u!==null,className:"w-full",children:[e.jsx(J,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),t("settings.refresh")]})}),e.jsx(O,{open:!!x,onOpenChange:()=>h(null),children:e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsx(I,{children:t("settingsBackups.restoreConfirmTitle")}),e.jsxs(P,{children:[t("settingsBackups.restoreConfirmPrefix")," ",e.jsx("code",{className:"font-mono bg-muted px-1.5 py-0.5 rounded text-foreground",children:x}),". ",t("settingsBackups.restoreConfirmSuffix")]})]}),e.jsxs(z,{children:[e.jsx(L,{children:t("settingsBackups.cancel")}),e.jsx(U,{onClick:()=>{x&&A(x),h(null)},children:t("settingsBackups.restore")})]})]})})]})}export{ae as default};
1
+ import{j as e}from"./radix-ui-C98W0NRG.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bl as E,n as k,S as n,C as g,b5 as R,b7 as D,B as T,d as C}from"./index-hqC_y7jI.js";import{A as O,a as _,b as F,c as I,d as P,e as z,f as L,g as U}from"./alert-dialog-0MtCFagW.js";import{v as $,w as H,ab as v,u as M,N as Y,R as J}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q=3e3,G=5e3;function ae(){const{t}=S(),{fetchRawConfig:p}=E(),m=r.useRef(null),d=r.useRef(null),[j,y]=r.useState([]),[f,N]=r.useState(!0),[u,w]=r.useState(null),[i,l]=r.useState(null),[c,b]=r.useState(null),[x,h]=r.useState(null),o=r.useCallback(async()=>{m.current?.abort(),m.current=new AbortController;try{N(!0),l(null);const s=await fetch("/api/persist/backups",{signal:m.current.signal});if(!s.ok)throw new Error(t("settingsBackups.failedFetch"));const a=await s.json();y(a.backups||[])}catch(s){if(s instanceof Error&&s.name==="AbortError")return;l(s instanceof Error?s.message:t("settings.unknownError"))}finally{N(!1)}},[t]),A=r.useCallback(async s=>{d.current?.abort(),d.current=new AbortController;try{w(s),l(null);const a=await fetch("/api/persist/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timestamp:s}),signal:d.current.signal});if(!a.ok){const B=await a.json();throw new Error(B.error||t("settingsBackups.failedRestore"))}b(t("settingsBackups.restoreSuccess")),await o(),await p()}catch(a){if(a instanceof Error&&a.name==="AbortError")return;l(a instanceof Error?a.message:t("settings.unknownError"))}finally{w(null)}},[o,p,t]);return r.useEffect(()=>{o()},[o]),r.useEffect(()=>()=>{m.current?.abort(),d.current?.abort()},[]),r.useEffect(()=>{if(c){const s=setTimeout(()=>b(null),q);return()=>clearTimeout(s)}},[c]),r.useEffect(()=>{if(i){const s=setTimeout(()=>l(null),G);return()=>clearTimeout(s)}},[i]),f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"h-6 w-40"}),e.jsx(n,{className:"h-4 w-full"})]}),[1,2,3].map(s=>e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(n,{className:"h-4 w-32"}),e.jsx(n,{className:"h-3 w-48"})]}),e.jsx(n,{className:"h-8 w-20"})]})},s))]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsx(n,{className:"h-9 w-full"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${i||c?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[i&&e.jsxs(R,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx(D,{children:i})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(H,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:c})]})]}),e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold",children:t("settingsBackups.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.description")})]}),j.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-3 opacity-30 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.none")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("settingsBackups.noneHint")})]})}):e.jsx("div",{className:"space-y-2",children:j.map((s,a)=>e.jsx(g,{className:"p-4 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(M,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium font-mono",children:s.timestamp}),a===0&&e.jsx(T,{variant:"secondary",className:"text-xs",children:t("settingsBackups.latest")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.date})]})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>h(s.timestamp),disabled:u!==null,className:"gap-2 shrink-0",children:[e.jsx(Y,{className:`w-4 h-4 ${u===s.timestamp?"animate-spin":""}`}),u===s.timestamp?t("settingsBackups.restoring"):t("settingsBackups.restore")]})]})},s.timestamp))})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{o(),p()},disabled:f||u!==null,className:"w-full",children:[e.jsx(J,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),t("settings.refresh")]})}),e.jsx(O,{open:!!x,onOpenChange:()=>h(null),children:e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsx(I,{children:t("settingsBackups.restoreConfirmTitle")}),e.jsxs(P,{children:[t("settingsBackups.restoreConfirmPrefix")," ",e.jsx("code",{className:"font-mono bg-muted px-1.5 py-0.5 rounded text-foreground",children:x}),". ",t("settingsBackups.restoreConfirmSuffix")]})]}),e.jsxs(z,{children:[e.jsx(L,{children:t("settingsBackups.cancel")}),e.jsx(U,{onClick:()=>{x&&A(x),h(null)},children:t("settingsBackups.restore")})]})]})})]})}export{ae as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-C98W0NRG.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{bl as F,b5 as b,b7 as w,n as L,B as $,L as A,aA as M,I as O,d as P}from"./index-CcKb4PL_.js";import{R as U,v as N,w as B,a8 as V,an as K,am as _,ay as q}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const R={selected:[],unattended:!1};async function k(t,a){try{const c=await t.json();return typeof c.error=="string"&&c.error.trim().length>0?c.error:a}catch{return a}}function J(){const[t,a]=i.useState(R),[c,o]=i.useState(null),[v,g]=i.useState(!0),[j,x]=i.useState(!1),[C,u]=i.useState(null),[h,y]=i.useState(null),m=i.useCallback(r=>{y(r),window.setTimeout(()=>y(null),1500)},[]),f=i.useCallback(async()=>{try{g(!0),u(null);const r=await fetch("/api/channels");if(!r.ok)throw new Error(await k(r,"Failed to load Official Channels settings"));const n=await r.json();return a(n.config??R),o(n.status??null),!0}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{g(!1)}},[]),S=i.useCallback(async(r,n="Settings saved")=>{try{x(!0),u(null);const s=await fetch("/api/channels",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await k(s,"Failed to save Official Channels settings"));const d=await s.json();return a(l=>d.config??{...l,...r}),m(n),!0}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[m]),T=i.useCallback(async(r,n)=>{try{x(!0),u(null);const s=await fetch(`/api/channels/${r}/token`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:n})});if(!s.ok)throw new Error(await k(s,`Failed to save ${r} token`));return await f()?(m(`${r} token saved`),!0):!1}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[f,m]),E=i.useCallback(async r=>{try{x(!0),u(null);const n=await fetch(`/api/channels/${r}/token`,{method:"DELETE"});if(!n.ok)throw new Error(await k(n,`Failed to clear ${r} token`));return await f()?(m(`${r} token cleared`),!0):!1}catch(n){return u(n instanceof Error?n.message:"Unknown error"),!1}finally{x(!1)}},[f,m]);return{config:t,status:c,loading:v,saving:j,error:C,success:h,fetchConfig:f,updateConfig:S,saveToken:T,clearToken:E}}const Y={telegram:"",discord:"",imessage:""};function z(t){return t==="ready"?"border-green-200 bg-green-50 text-green-900 dark:border-green-900/60 dark:bg-green-950/40 dark:text-green-100":t==="limited"?"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100":"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/60 dark:bg-blue-950/40 dark:text-blue-100"}function G(t){return t==="ready"?"default":t==="not_selected"?"secondary":t==="unavailable"?"destructive":"outline"}function H(t){return t==="ready"?"default":t==="partial"?"outline":t==="blocked"?"destructive":"secondary"}function Q(t,a){return t.length===0?"None selected":t.map(c=>a?.find(o=>o.id===c)?.displayName??c).join(", ")}function ne(){const{config:t,status:a,loading:c,saving:o,error:v,success:g,fetchConfig:j,updateConfig:x,saveToken:C,clearToken:u}=J(),{fetchRawConfig:h}=F(),[y,m]=i.useState(Y),f=Q(t.selected,a?.channels);i.useEffect(()=>{j(),h()},[j,h]);const S=async()=>{await Promise.all([j(),h()])},T=async(s,d)=>{const l=d?[...new Set([...t.selected,s])]:t.selected.filter(D=>D!==s);await x({selected:l},d?`${s} selected for auto-enable`:`${s} removed from auto-enable`)&&await Promise.all([j(),h()])},E=(s,d)=>{m(l=>({...l,[s]:d}))},r=async s=>{await C(s,y[s])&&(m(l=>({...l,[s]:""})),await h())},n=async s=>{await u(s)&&(m(l=>({...l,[s]:""})),await h())};return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(U,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${v||g?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[v&&e.jsxs(b,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:v})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(B,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(L,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(V,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Official Channels"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure official Claude channels here, then run ",e.jsx("code",{children:"ccs"})," normally on a supported native Claude session."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["CCS stores only channel selection in ",e.jsx("code",{children:"config.yaml"}),". Claude keeps the machine-level channel state under ",e.jsx("code",{children:"~/.claude/channels/"}),"."]})]})]}),a&&e.jsxs("div",{className:`rounded-xl border p-4 ${z(a.summary.state)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:a.summary.state==="ready"?"default":"outline",children:a.summary.title}),e.jsx("span",{className:"text-sm font-medium",children:f})]}),e.jsx("p",{className:"text-sm",children:a.summary.message}),e.jsx("p",{className:"text-sm opacity-90",children:a.summary.nextStep})]}),e.jsxs("div",{className:"min-w-[220px] rounded-lg border border-current/10 bg-background/60 p-3 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium",children:"Machine checks"}),e.jsxs("div",{className:"mt-2 space-y-1 text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Bun"}),e.jsx("span",{children:a.bunInstalled?"Installed":"Missing"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude Code"}),e.jsx("span",{children:a.claudeVersion.current?`v${a.claudeVersion.current}`:"Unknown"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude auth"}),e.jsx("span",{children:a.auth.authMethod??"Unknown"})]})]})]})]}),a.summary.blockers.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm",children:a.summary.blockers.map(s=>e.jsx("p",{children:s},s))})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("p",{className:"font-medium",children:"Fastest path"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"1. Turn on the channels you want below."}),e.jsx("p",{children:"2. Save Telegram or Discord bot tokens here if that channel needs one."}),e.jsxs("p",{children:["3. Run ",e.jsx("code",{children:"ccs"})," or a native Claude account profile. CCS adds"," ",e.jsx("code",{children:"--channels"})," for you on supported runs."]}),e.jsx("p",{children:a.supportMessage})]}),e.jsxs("details",{className:"mt-3 rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Advanced notes and scope"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:a.accountStatusCaveat}),e.jsx("p",{children:a.stateScopeMessage})]})]})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["If you run ",e.jsx("code",{children:"ccs"})," now"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.launchPreview.detail})]}),e.jsx($,{variant:H(a.launchPreview.state),children:a.launchPreview.title})]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"You type:"})," ",a.launchPreview.command]}),e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:[e.jsx("span",{className:"text-muted-foreground",children:"CCS adds:"})," ",a.launchPreview.appendedArgs.length>0?a.launchPreview.appendedArgs.join(" "):"(nothing yet)"]})]}),a.launchPreview.skippedMessages.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm text-muted-foreground",children:a.launchPreview.skippedMessages.map(s=>e.jsx("p",{children:s},s))})]}),a?.claudeVersion.message&&a.claudeVersion.state!=="supported"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.claudeVersion.message})]}),a?.auth.message&&a.auth.state!=="eligible"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.message})]}),a?.auth.orgRequirementMessage&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.orgRequirementMessage})]}),e.jsx("div",{className:"space-y-4",children:a?.channels.map(s=>{const d=t.selected.includes(s.id),l=y[s.id];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(A,{className:"text-base font-medium",children:s.displayName}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.summary}),e.jsx("p",{className:"mt-2 font-mono text-xs text-muted-foreground",children:s.pluginSpec})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{variant:G(s.setup.state),children:s.setup.label}),e.jsx(M,{checked:d,disabled:o||!!s.unavailableReason&&!d,onCheckedChange:p=>void T(s.id,p)})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:s.setup.detail}),e.jsx("p",{children:s.setup.nextStep})]}),s.requiresToken&&e.jsxs("div",{className:"space-y-3 rounded-lg bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:!s.tokenConfigured&&s.tokenSource==="process_env"?`The current CCS process already has ${s.envKey}. Save it here only if you want persistent Claude channel state.`:s.tokenConfigured&&s.processEnvAvailable?`${s.envKey} is saved in Claude channel state, and the current CCS process env also provides it.`:`Save ${s.envKey} in Claude's official channel env file. The dashboard never reads the token value back after save.`}),s.tokenConfigured&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Saving here writes the same ",e.jsx("code",{children:".env"})," file as"," ",e.jsxs("code",{children:["/",s.id,":configure"]}),", so you do not need to run the configure command again after a successful save."]}),e.jsx(O,{type:"password",value:l,onChange:p=>E(s.id,p.target.value),placeholder:s.tokenConfigured?`Configured. Enter a new ${s.envKey} to replace it.`:!s.tokenConfigured&&s.tokenSource==="process_env"?`Using current CCS process env. Enter a new ${s.envKey} to save it for Claude.`:`Paste ${s.envKey}`,disabled:o}),s.tokenPath&&s.tokenSource!=="process_env"&&e.jsx("div",{className:"text-xs text-muted-foreground break-all",children:s.tokenPath}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(P,{onClick:()=>void r(s.id),disabled:o||!l.trim(),children:[e.jsx(K,{className:"mr-2 h-4 w-4"}),"Save Token"]}),e.jsxs(P,{variant:"outline",onClick:()=>void n(s.id),disabled:o||!s.tokenConfigured,children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Clear Saved Token"]})]})]}),e.jsxs("details",{className:"rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Claude-side setup commands"}),e.jsx("div",{className:"mt-3 space-y-2",children:(s.manualSetupCommands??[]).map(p=>e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:p},p))})]})]},s.id)})}),e.jsx(b,{children:e.jsxs(w,{children:["CCS injects ",e.jsx("code",{children:"--channels"})," only for the current Claude session. Telegram, Discord, and iMessage stop receiving messages when that Claude session exits."]})}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg bg-muted/30 p-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(q,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{children:[e.jsx(A,{className:"text-sm font-medium",children:"Skip permission prompts on launch"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Optional advanced behavior. CCS adds ",e.jsx("code",{children:"--dangerously-skip-permissions"})," ","only when at least one selected channel is being auto-enabled and you did not already pass a permission flag yourself."]})]})]}),e.jsx(M,{checked:t.unattended,disabled:o,onCheckedChange:s=>void(async()=>{await x({unattended:s},s?"Unattended mode enabled":"Unattended mode disabled")&&await h()})()})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(P,{variant:"outline",onClick:()=>void S(),disabled:o,children:[e.jsx(U,{className:`mr-2 h-4 w-4 ${o?"animate-spin":""}`}),"Refresh"]})})]})})]})}export{ne as default};
1
+ import{j as e}from"./radix-ui-C98W0NRG.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{bl as F,b5 as b,b7 as w,n as L,B as $,L as A,aA as M,I as O,d as P}from"./index-hqC_y7jI.js";import{R as U,v as N,w as B,a8 as V,an as K,am as _,ay as q}from"./icons-CeH5899d.js";import"./tanstack-CfKik0yL.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const R={selected:[],unattended:!1};async function k(t,a){try{const c=await t.json();return typeof c.error=="string"&&c.error.trim().length>0?c.error:a}catch{return a}}function J(){const[t,a]=i.useState(R),[c,o]=i.useState(null),[v,g]=i.useState(!0),[j,x]=i.useState(!1),[C,u]=i.useState(null),[h,y]=i.useState(null),m=i.useCallback(r=>{y(r),window.setTimeout(()=>y(null),1500)},[]),f=i.useCallback(async()=>{try{g(!0),u(null);const r=await fetch("/api/channels");if(!r.ok)throw new Error(await k(r,"Failed to load Official Channels settings"));const n=await r.json();return a(n.config??R),o(n.status??null),!0}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{g(!1)}},[]),S=i.useCallback(async(r,n="Settings saved")=>{try{x(!0),u(null);const s=await fetch("/api/channels",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await k(s,"Failed to save Official Channels settings"));const d=await s.json();return a(l=>d.config??{...l,...r}),m(n),!0}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[m]),T=i.useCallback(async(r,n)=>{try{x(!0),u(null);const s=await fetch(`/api/channels/${r}/token`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:n})});if(!s.ok)throw new Error(await k(s,`Failed to save ${r} token`));return await f()?(m(`${r} token saved`),!0):!1}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[f,m]),E=i.useCallback(async r=>{try{x(!0),u(null);const n=await fetch(`/api/channels/${r}/token`,{method:"DELETE"});if(!n.ok)throw new Error(await k(n,`Failed to clear ${r} token`));return await f()?(m(`${r} token cleared`),!0):!1}catch(n){return u(n instanceof Error?n.message:"Unknown error"),!1}finally{x(!1)}},[f,m]);return{config:t,status:c,loading:v,saving:j,error:C,success:h,fetchConfig:f,updateConfig:S,saveToken:T,clearToken:E}}const Y={telegram:"",discord:"",imessage:""};function z(t){return t==="ready"?"border-green-200 bg-green-50 text-green-900 dark:border-green-900/60 dark:bg-green-950/40 dark:text-green-100":t==="limited"?"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100":"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/60 dark:bg-blue-950/40 dark:text-blue-100"}function G(t){return t==="ready"?"default":t==="not_selected"?"secondary":t==="unavailable"?"destructive":"outline"}function H(t){return t==="ready"?"default":t==="partial"?"outline":t==="blocked"?"destructive":"secondary"}function Q(t,a){return t.length===0?"None selected":t.map(c=>a?.find(o=>o.id===c)?.displayName??c).join(", ")}function ne(){const{config:t,status:a,loading:c,saving:o,error:v,success:g,fetchConfig:j,updateConfig:x,saveToken:C,clearToken:u}=J(),{fetchRawConfig:h}=F(),[y,m]=i.useState(Y),f=Q(t.selected,a?.channels);i.useEffect(()=>{j(),h()},[j,h]);const S=async()=>{await Promise.all([j(),h()])},T=async(s,d)=>{const l=d?[...new Set([...t.selected,s])]:t.selected.filter(D=>D!==s);await x({selected:l},d?`${s} selected for auto-enable`:`${s} removed from auto-enable`)&&await Promise.all([j(),h()])},E=(s,d)=>{m(l=>({...l,[s]:d}))},r=async s=>{await C(s,y[s])&&(m(l=>({...l,[s]:""})),await h())},n=async s=>{await u(s)&&(m(l=>({...l,[s]:""})),await h())};return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(U,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${v||g?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[v&&e.jsxs(b,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:v})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(B,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(L,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(V,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Official Channels"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure official Claude channels here, then run ",e.jsx("code",{children:"ccs"})," normally on a supported native Claude session."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["CCS stores only channel selection in ",e.jsx("code",{children:"config.yaml"}),". Claude keeps the machine-level channel state under ",e.jsx("code",{children:"~/.claude/channels/"}),"."]})]})]}),a&&e.jsxs("div",{className:`rounded-xl border p-4 ${z(a.summary.state)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:a.summary.state==="ready"?"default":"outline",children:a.summary.title}),e.jsx("span",{className:"text-sm font-medium",children:f})]}),e.jsx("p",{className:"text-sm",children:a.summary.message}),e.jsx("p",{className:"text-sm opacity-90",children:a.summary.nextStep})]}),e.jsxs("div",{className:"min-w-[220px] rounded-lg border border-current/10 bg-background/60 p-3 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium",children:"Machine checks"}),e.jsxs("div",{className:"mt-2 space-y-1 text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Bun"}),e.jsx("span",{children:a.bunInstalled?"Installed":"Missing"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude Code"}),e.jsx("span",{children:a.claudeVersion.current?`v${a.claudeVersion.current}`:"Unknown"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude auth"}),e.jsx("span",{children:a.auth.authMethod??"Unknown"})]})]})]})]}),a.summary.blockers.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm",children:a.summary.blockers.map(s=>e.jsx("p",{children:s},s))})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("p",{className:"font-medium",children:"Fastest path"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"1. Turn on the channels you want below."}),e.jsx("p",{children:"2. Save Telegram or Discord bot tokens here if that channel needs one."}),e.jsxs("p",{children:["3. Run ",e.jsx("code",{children:"ccs"})," or a native Claude account profile. CCS adds"," ",e.jsx("code",{children:"--channels"})," for you on supported runs."]}),e.jsx("p",{children:a.supportMessage})]}),e.jsxs("details",{className:"mt-3 rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Advanced notes and scope"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:a.accountStatusCaveat}),e.jsx("p",{children:a.stateScopeMessage})]})]})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["If you run ",e.jsx("code",{children:"ccs"})," now"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.launchPreview.detail})]}),e.jsx($,{variant:H(a.launchPreview.state),children:a.launchPreview.title})]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"You type:"})," ",a.launchPreview.command]}),e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:[e.jsx("span",{className:"text-muted-foreground",children:"CCS adds:"})," ",a.launchPreview.appendedArgs.length>0?a.launchPreview.appendedArgs.join(" "):"(nothing yet)"]})]}),a.launchPreview.skippedMessages.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm text-muted-foreground",children:a.launchPreview.skippedMessages.map(s=>e.jsx("p",{children:s},s))})]}),a?.claudeVersion.message&&a.claudeVersion.state!=="supported"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.claudeVersion.message})]}),a?.auth.message&&a.auth.state!=="eligible"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.message})]}),a?.auth.orgRequirementMessage&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.orgRequirementMessage})]}),e.jsx("div",{className:"space-y-4",children:a?.channels.map(s=>{const d=t.selected.includes(s.id),l=y[s.id];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(A,{className:"text-base font-medium",children:s.displayName}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.summary}),e.jsx("p",{className:"mt-2 font-mono text-xs text-muted-foreground",children:s.pluginSpec})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{variant:G(s.setup.state),children:s.setup.label}),e.jsx(M,{checked:d,disabled:o||!!s.unavailableReason&&!d,onCheckedChange:p=>void T(s.id,p)})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:s.setup.detail}),e.jsx("p",{children:s.setup.nextStep})]}),s.requiresToken&&e.jsxs("div",{className:"space-y-3 rounded-lg bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:!s.tokenConfigured&&s.tokenSource==="process_env"?`The current CCS process already has ${s.envKey}. Save it here only if you want persistent Claude channel state.`:s.tokenConfigured&&s.processEnvAvailable?`${s.envKey} is saved in Claude channel state, and the current CCS process env also provides it.`:`Save ${s.envKey} in Claude's official channel env file. The dashboard never reads the token value back after save.`}),s.tokenConfigured&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Saving here writes the same ",e.jsx("code",{children:".env"})," file as"," ",e.jsxs("code",{children:["/",s.id,":configure"]}),", so you do not need to run the configure command again after a successful save."]}),e.jsx(O,{type:"password",value:l,onChange:p=>E(s.id,p.target.value),placeholder:s.tokenConfigured?`Configured. Enter a new ${s.envKey} to replace it.`:!s.tokenConfigured&&s.tokenSource==="process_env"?`Using current CCS process env. Enter a new ${s.envKey} to save it for Claude.`:`Paste ${s.envKey}`,disabled:o}),s.tokenPath&&s.tokenSource!=="process_env"&&e.jsx("div",{className:"text-xs text-muted-foreground break-all",children:s.tokenPath}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(P,{onClick:()=>void r(s.id),disabled:o||!l.trim(),children:[e.jsx(K,{className:"mr-2 h-4 w-4"}),"Save Token"]}),e.jsxs(P,{variant:"outline",onClick:()=>void n(s.id),disabled:o||!s.tokenConfigured,children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Clear Saved Token"]})]})]}),e.jsxs("details",{className:"rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Claude-side setup commands"}),e.jsx("div",{className:"mt-3 space-y-2",children:(s.manualSetupCommands??[]).map(p=>e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:p},p))})]})]},s.id)})}),e.jsx(b,{children:e.jsxs(w,{children:["CCS injects ",e.jsx("code",{children:"--channels"})," only for the current Claude session. Telegram, Discord, and iMessage stop receiving messages when that Claude session exits."]})}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg bg-muted/30 p-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(q,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{children:[e.jsx(A,{className:"text-sm font-medium",children:"Skip permission prompts on launch"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Optional advanced behavior. CCS adds ",e.jsx("code",{children:"--dangerously-skip-permissions"})," ","only when at least one selected channel is being auto-enabled and you did not already pass a permission flag yourself."]})]})]}),e.jsx(M,{checked:t.unattended,disabled:o,onCheckedChange:s=>void(async()=>{await x({unattended:s},s?"Unattended mode enabled":"Unattended mode disabled")&&await h()})()})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(P,{variant:"outline",onClick:()=>void S(),disabled:o,children:[e.jsx(U,{className:`mr-2 h-4 w-4 ${o?"animate-spin":""}`}),"Refresh"]})})]})})]})}export{ne as default};
@@ -1 +1 @@
1
- import{j as r,a1 as i,a2 as t}from"./radix-ui-C98W0NRG.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-CcKb4PL_.js";import{l as o}from"./icons-CeH5899d.js";function b({className:e,...a}){return r.jsx(i,{"data-slot":"checkbox",className:s("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(t,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(o,{className:"size-3.5"})})})}export{b as C};
1
+ import{j as r,a1 as i,a2 as t}from"./radix-ui-C98W0NRG.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-hqC_y7jI.js";import{l as o}from"./icons-CeH5899d.js";function b({className:e,...a}){return r.jsx(i,{"data-slot":"checkbox",className:s("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(t,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(o,{className:"size-3.5"})})})}export{b as C};