@kaitranntt/ccs 7.56.0-dev.2 → 7.56.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -11
- package/dist/bin/droid-runtime.d.ts +1 -0
- package/dist/bin/droid-runtime.d.ts.map +1 -0
- package/dist/bin/droid-runtime.js +5 -0
- package/dist/bin/droid-runtime.js.map +1 -0
- package/dist/commands/api-command/create-command.d.ts.map +1 -1
- package/dist/commands/api-command/create-command.js +8 -4
- package/dist/commands/api-command/create-command.js.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +12 -6
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +9 -7
- package/dist/commands/help-command.js.map +1 -1
- package/dist/targets/target-resolver.d.ts +2 -2
- package/dist/targets/target-resolver.d.ts.map +1 -1
- package/dist/targets/target-resolver.js +68 -18
- package/dist/targets/target-resolver.js.map +1 -1
- package/dist/ui/assets/{accounts-BikRyqcT.js → accounts-_HKzUYeW.js} +1 -1
- package/dist/ui/assets/{alert-dialog-CwEJfEUX.js → alert-dialog-7NHGF_Xe.js} +1 -1
- package/dist/ui/assets/api-DOfVbQ1z.js +4 -0
- package/dist/ui/assets/{auth-section-CrFrby6w.js → auth-section-DqMIwU7c.js} +1 -1
- package/dist/ui/assets/{backups-section-CdMvSnSm.js → backups-section-D4um8aUY.js} +1 -1
- package/dist/ui/assets/{checkbox-CC0rU-9-.js → checkbox-BOeXuNDh.js} +1 -1
- package/dist/ui/assets/{claude-extension-CzGeZYz8.js → claude-extension-CelZ8ku0.js} +1 -1
- package/dist/ui/assets/{cliproxy-BSNSGNOv.js → cliproxy-CzJfXgOZ.js} +2 -2
- package/dist/ui/assets/{cliproxy-ai-providers-D-U6NKfV.js → cliproxy-ai-providers-BYWaYXvO.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-BCexyz40.js → cliproxy-control-panel-77ZZmJI4.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-Bee0kh6i.js → confirm-dialog-Bz3IbucG.js} +1 -1
- package/dist/ui/assets/{copilot-BZRAvPLD.js → copilot-DzskqpA-.js} +1 -1
- package/dist/ui/assets/{cursor-CO2rCNKC.js → cursor-C8f14wrT.js} +1 -1
- package/dist/ui/assets/{droid-CcKqoQtO.js → droid-DR0b5dXu.js} +1 -1
- package/dist/ui/assets/{globalenv-section-CBRvmZbS.js → globalenv-section-O2tusa4k.js} +1 -1
- package/dist/ui/assets/{health-DgrTQESI.js → health-BPuHhvGU.js} +1 -1
- package/dist/ui/assets/{index-DJCPwAoe.js → index-3azdVT3y.js} +1 -1
- package/dist/ui/assets/{index-CursmDny.js → index-BxTb3XSE.js} +1 -1
- package/dist/ui/assets/{index-D90gSn57.js → index-D0r4vaLi.js} +1 -1
- package/dist/ui/assets/index-ZlUC3TcJ.js +47 -0
- package/dist/ui/assets/{index-BOhcsuQK.js → index-eQOk8v6I.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-C8cOlsqE.js → proxy-status-widget-CU9RtUUZ.js} +1 -1
- package/dist/ui/assets/{searchable-select-CF22qEzz.js → searchable-select-DltMdKve.js} +1 -1
- package/dist/ui/assets/{separator-CAoIlNuN.js → separator-DvmULQuv.js} +1 -1
- package/dist/ui/assets/{shared-zeFjETE6.js → shared-3KjBmAma.js} +1 -1
- package/dist/ui/assets/{switch-BeqpDfK5.js → switch-WfgHsT03.js} +1 -1
- package/dist/ui/assets/{updates-By9S46EJ.js → updates-DEb1kb0C.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +3 -2
- package/scripts/add-shebang.js +33 -20
- package/dist/ui/assets/api-BYSEdQYh.js +0 -4
- package/dist/ui/assets/index-sCtK1kDn.js +0 -47
package/scripts/add-shebang.js
CHANGED
|
@@ -4,36 +4,49 @@
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
|
+
function getExecutablePaths() {
|
|
8
|
+
const packageJsonPath = path.join(__dirname, '../package.json');
|
|
9
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
10
|
+
const binEntries = packageJson.bin || {};
|
|
11
|
+
const uniqueRelativePaths = [...new Set(Object.values(binEntries))];
|
|
12
|
+
|
|
13
|
+
return uniqueRelativePaths.map((relativePath) => path.join(__dirname, '..', relativePath));
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
|
-
* Add
|
|
17
|
+
* Add shebangs to all published bin entrypoints and make them executable.
|
|
9
18
|
* Run after: tsc
|
|
10
19
|
*/
|
|
11
20
|
function addShebang() {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
console.error(
|
|
21
|
+
const executablePaths = getExecutablePaths();
|
|
22
|
+
const missingPaths = executablePaths.filter((executablePath) => !fs.existsSync(executablePath));
|
|
23
|
+
if (missingPaths.length > 0) {
|
|
24
|
+
console.error(`[X] Missing built executable(s): ${missingPaths.join(', ')}. Run tsc first.`);
|
|
16
25
|
process.exit(1);
|
|
17
26
|
}
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
for (const executablePath of executablePaths) {
|
|
29
|
+
let content = fs.readFileSync(executablePath, 'utf8');
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
31
|
+
if (!content.startsWith('#!/usr/bin/env node')) {
|
|
32
|
+
content = '#!/usr/bin/env node\n' + content;
|
|
33
|
+
fs.writeFileSync(executablePath, content);
|
|
34
|
+
console.log(`[OK] Shebang added to ${path.relative(path.join(__dirname, '..'), executablePath)}`);
|
|
35
|
+
}
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
if (process.platform !== 'win32') {
|
|
38
|
+
try {
|
|
39
|
+
fs.chmodSync(executablePath, 0o755);
|
|
40
|
+
console.log(
|
|
41
|
+
`[OK] ${path.relative(path.join(__dirname, '..'), executablePath)} is now executable`
|
|
42
|
+
);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.warn(
|
|
45
|
+
`[!] Could not chmod ${path.relative(path.join(__dirname, '..'), executablePath)}: ${err.message}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
35
48
|
}
|
|
36
49
|
}
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
addShebang();
|
|
52
|
+
addShebang();
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as x,h as He}from"./react-vendor-CNOkPC89.js";import{B as R,c as _,T as Qe,p as $e,q as ze,r as Ke,s as Je,t as Be,v as qe,w as xe,d as j,I as M,a as q,n as ne,L as T,x as B,y as we,z as Ye,A as Ve,D as Ge,E as We,S as ue,F as se,G as le,H as Ce,J as Xe,K as Ze,M as ye,N as ke,O as Pe,Q as es,R as ss,U as he,V as pe,W as te,X as ts,Y as as,Z as de,C as Se,b as Oe,j as rs,k as ns,_ as is,$ as ls,a0 as os,a1 as cs,a2 as ds,a3 as ms,a4 as xs,a5 as us,a6 as hs,a7 as ps}from"./index-sCtK1kDn.js";import{a as gs,u as fs,b as ge}from"./tanstack-B8i0evp-.js";import{C as oe}from"./confirm-dialog-Bee0kh6i.js";import{t as P}from"./notifications-B2HqRBj7.js";import{L as ae,R as X,ai as Te,aj as js,E as Ns,f as vs,a3 as re,O as bs,ak as Ee,a4 as me,C as Ae,al as ws,a2 as Cs,am as ys,o as ce,X as ks,Z as _e,an as fe,m as je,ao as Re,ap as Ps,a6 as Ss,aq as Os,x as Me,ar as Ts,v as De,n as Es,as as As}from"./icons-DR-ORtNe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CwEJfEUX.js";function _s({className:s,showTooltip:t=!0}){const n=e.jsxs(R,{variant:"outline",className:_("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 t?e.jsxs(Qe,{children:[e.jsx($e,{asChild:!0,children:n}),e.jsx(ze,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Ne(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function Le(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Rs(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 Ms(s,t){const n={...s};return t.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=t.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,t.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=t.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,t.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=t.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ds({profileName:s,target:t,data:n,settings:d,isLoading:l,isSaving:g,isTargetSaving:r,hasChanges:f,isRawJsonValid:a,onTargetChange:p,onRefresh:u,onDelete:v,onSave:b}){const k=g||r,N=l||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(R,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),Le(d)&&e.jsx(_s,{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(Ke,{value:t,onValueChange:S=>{N||p(S)},disabled:N,children:[e.jsx(Je,{className:"h-7 w-[170px] text-xs",disabled:N,children:e.jsx(Be,{})}),e.jsxs(qe,{children:[e.jsx(xe,{value:"claude",children:"Claude Code"}),e.jsx(xe,{value:"droid",children:"Factory Droid"})]})]}),r&&e.jsx(ae,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:"ghost",size:"sm",onClick:u,disabled:N,children:e.jsx(X,{className:`w-4 h-4 ${l?"animate-spin":""}`})}),v&&e.jsx(j,{variant:"ghost",size:"sm",onClick:v,disabled:k,children:e.jsx(Te,{className:"w-4 h-4 text-destructive"})}),e.jsx(j,{size:"sm",onClick:b,disabled:k||!f||!a,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(js,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ie({label:s,...t}){const[n,d]=x.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(M,{type:n?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>d(!n),tabIndex:-1,children:n?e.jsx(Ns,{className:"w-4 h-4"}):e.jsx(vs,{className:"w-4 h-4"})})]})]})}function Ls({currentSettings:s,newEnvKey:t,newEnvValue:n,onNewEnvKeyChange:d,onNewEnvValueChange:l,onEnvValueChange:g,onAddEnvVar:r}){const{t:f}=q();return e.jsxs(e.Fragment,{children:[e.jsx(ne,{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(([a,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(T,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[a,Ne(a)&&e.jsx(R,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Ne(a)?e.jsx(Ie,{value:p,onChange:u=>g(a,u.target.value),className:"font-mono text-sm h-8"}):e.jsx(M,{value:p,onChange:u=>g(a,u.target.value),className:"font-mono text-sm h-8"})]},a))}):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(T,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(M,{placeholder:f("envEditor.keyPlaceholder"),value:t,onChange:a=>d(a.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:a=>a.key==="Enter"&&t.trim()&&r()}),e.jsx(M,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:a=>l(a.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:a=>a.key==="Enter"&&t.trim()&&r()}),e.jsx(j,{variant:"outline",size:"sm",className:"h-8",onClick:r,disabled:!t.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]})}function Is({profileName:s,target:t,data:n}){const{t:d}=q(),l=t==="droid";return e.jsx(ne,{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(bs,{className:"w-4 h-4"}),d("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:d("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:d("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(B,{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:d("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:d("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:t})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:d("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(T,{className:"text-xs text-muted-foreground",children:d("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(B,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d(l?"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:l?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`}),e.jsx(B,{value:l?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d(l?"profileEditor.overrideToClaude":"profileEditor.overrideToClaudeExplicit")}),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 claude "prompt"']}),e.jsx(B,{value:`ccs ${s} --target claude "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d("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(B,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Fs({value:s,onChange:t,placeholder:n="Search models...",className:d}){const[l,g]=x.useState(""),[r,f]=x.useState(null),{models:a,isLoading:p,isError:u,isFetching:v}=we(),b=Ye(),k=x.useMemo(()=>Ve(a,l,{category:r??void 0}),[a,l,r]),N=x.useMemo(()=>Ge(a,2),[a]),S=!l.trim()&&!r,F=x.useMemo(()=>{const c={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(h=>{c[h.category].push(h)});for(const h of Object.keys(c))c[h]=We(c[h]);return c},[k]),w=x.useCallback(()=>{b()},[b]),E=a.find(c=>c.id===s);return p&&a.length===0?e.jsxs("div",{className:_("space-y-2",d),children:[e.jsx(ue,{className:"h-10 w-full"}),e.jsx(ue,{className:"h-32 w-full"})]}):e.jsxs("div",{className:_("space-y-2 w-full min-w-0 overflow-hidden",d),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ee,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(M,{value:l,onChange:c=>g(c.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(j,{variant:"outline",size:"icon",onClick:w,disabled:v,title:"Refresh models",children:v?e.jsx(ae,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(R,{variant:r===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",a.length,")"]}),Object.keys(se).map(c=>{const h=F[c].length;return h===0?null:e.jsxs(R,{variant:r===c?"default":"outline",className:"cursor-pointer",onClick:()=>f(c),children:[se[c]," (",h,")"]},c)})]}),E&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:E.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[le(E.pricing)," |"," ",Ce(E.context_length)]})]}),e.jsx(ne,{className:"h-72 w-full rounded-md border",children:u?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(j,{variant:"link",onClick:w,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',l,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[S&&N.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(me,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:N.map(c=>e.jsx(ve,{model:c,isSelected:c.id===s,onClick:()=>t(c.id),showAge:!0},c.id))})]}),Object.keys(se).map(c=>{const h=F[c];return h.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:se[c]}),e.jsx("div",{className:"space-y-1",children:h.map(i=>e.jsx(ve,{model:i,isSelected:i.id===s,onClick:()=>t(i.id)},i.id))})]},c)})]})})]})}function ve({model:s,isSelected:t,onClick:n,showAge:d=!1}){return e.jsxs("button",{type:"button",onClick:n,className:_("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",t&&"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:_("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",t?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[d&&s.created&&e.jsx(R,{variant:"outline",className:_("text-[10px] px-1",t?"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:Xe(s.created)}),s.isFree?e.jsx(R,{variant:"secondary",className:_("text-[10px] px-1",t?"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(R,{variant:"outline",className:_("text-[10px] px-1 border-emerald-500/50 text-emerald-600",t?"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:le(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:le(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Ce(s.context_length)})]})]})}function Us({selectedModel:s,value:t,onChange:n,className:d}){const{t:l}=q(),{models:g}=we(),r=x.useMemo(()=>s?Ze(s,g):{},[s,g]),f=()=>{n(r)},a=(u,v)=>{n({...t,[u]:v||void 0})},p=s&&Object.keys(r).length>0;return e.jsxs(ye,{className:_("group",d),children:[e.jsxs(ke,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ae,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),l("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",l("modelTierMapping.advanced"),")"]})]}),e.jsxs(Pe,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:l("modelTierMapping.description")}),p&&e.jsxs(j,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(ws,{className:"mr-1 h-4 w-4"}),l("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(T,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(M,{id:"tier-opus",value:t.opus??"",onChange:u=>a("opus",u.target.value),placeholder:l("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(M,{id:"tier-sonnet",value:t.sonnet??"",onChange:u=>a("sonnet",u.target.value),placeholder:l("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(M,{id:"tier-haiku",value:t.haiku??"",onChange:u=>a("haiku",u.target.value),placeholder:l("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:l("modelTierMapping.footer")})]})]})}function Hs({profileName:s,target:t,data:n,currentSettings:d,newEnvKey:l,newEnvValue:g,onNewEnvKeyChange:r,onNewEnvValueChange:f,onEnvValueChange:a,onAddEnvVar:p,onEnvBulkChange:u}){const v=Le(d),b=d?.env,k=x.useMemo(()=>Rs(b??{}),[b]),N=b??{},S=i=>{if(u){const U={...N,ANTHROPIC_MODEL:i,ANTHROPIC_DEFAULT_OPUS_MODEL:i,ANTHROPIC_DEFAULT_SONNET_MODEL:i,ANTHROPIC_DEFAULT_HAIKU_MODEL:i};u(U)}else a("ANTHROPIC_MODEL",i),a("ANTHROPIC_DEFAULT_OPUS_MODEL",i),a("ANTHROPIC_DEFAULT_SONNET_MODEL",i),a("ANTHROPIC_DEFAULT_HAIKU_MODEL",i);P.success(te.t("commonToast.appliedModelAllTiers"),{duration:2e3})},F=i=>{if(u){const U=Ms(N,i);u(U)}else i.opus!==void 0&&a("ANTHROPIC_DEFAULT_OPUS_MODEL",i.opus||""),i.sonnet!==void 0&&a("ANTHROPIC_DEFAULT_SONNET_MODEL",i.sonnet||""),i.haiku!==void 0&&a("ANTHROPIC_DEFAULT_HAIKU_MODEL",i.haiku||"")},[w,E]=x.useState(!1),c=new Set(["ANTHROPIC_AUTH_TOKEN"]),h=Object.entries(N).filter(([i])=>!c.has(i));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(es,{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(ss,{className:"w-full",children:[e.jsx(he,{value:"env",className:"flex-1",children:v?"Configuration":"Environment Variables"}),e.jsx(he,{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(pe,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:v?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(T,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Fs,{value:N.ANTHROPIC_MODEL,onChange:S,placeholder:"Search OpenRouter models..."})]}),e.jsx(Us,{selectedModel:N.ANTHROPIC_MODEL,value:k,onChange:F}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"API Key"}),e.jsx(Ie,{value:N.ANTHROPIC_AUTH_TOKEN||"",onChange:i=>a("ANTHROPIC_AUTH_TOKEN",i.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"})]})]}),h.length>0&&e.jsxs(ye,{open:w,onOpenChange:E,children:[e.jsxs(ke,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ae,{className:_("h-4 w-4 transition-transform",w&&"rotate-90")}),e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",h.length,")"]})]}),e.jsx(Pe,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:h.map(([i,U])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:i}),e.jsx(M,{value:U,onChange:Q=>a(i,Q.target.value),className:"font-mono text-xs h-8"})]},i))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(M,{placeholder:"VARIABLE_NAME",value:l,onChange:i=>r(i.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:i=>i.key==="Enter"&&l.trim()&&p()}),e.jsx(M,{placeholder:"value",value:g,onChange:i=>f(i.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:i=>i.key==="Enter"&&l.trim()&&p()}),e.jsx(j,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!l.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]}):e.jsx(Ls,{currentSettings:d,newEnvKey:l,newEnvValue:g,onNewEnvKeyChange:r,onNewEnvValueChange:f,onEnvValueChange:a,onAddEnvVar:p})}),e.jsx(pe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Is,{profileName:s,target:t,data:n})})]})]})})}function Qs({profileName:s,profileTarget:t,onDelete:n,onHasChangesUpdate:d}){const[l,g]=x.useState({}),[r,f]=x.useState(!1),[a,p]=x.useState(null),[u,v]=x.useState(""),[b,k]=x.useState(""),N=gs(),{data:S,isLoading:F,isError:w,refetch:E}=fs({queryKey:["settings",s],queryFn:async()=>{const m=await fetch(`/api/settings/${s}/raw`);if(!m.ok)throw new Error(`Failed to load settings: ${m.status}`);return m.json()}}),c=S?.settings,h=x.useMemo(()=>{if(a!==null)try{return JSON.parse(a)}catch{}if(c)return{...c,env:{...c.env,...l}}},[c,l,a]),i=x.useMemo(()=>a!==null?a:c?JSON.stringify(c,null,2):"",[a,c]),U=x.useCallback(m=>{p(m)},[]),Q=(m,y)=>{const D={...h?.env||{},[m]:y};g($=>({...$,[m]:y})),p(JSON.stringify({...h,env:D},null,2))},Y=m=>{const y={...h?.env||{},...m};g(D=>({...D,...m})),p(JSON.stringify({...h,env:y},null,2))},J=()=>{if(!u.trim())return;const m=u.trim(),y=b,D={...h?.env||{},[m]:y};g($=>({...$,[m]:y})),p(JSON.stringify({...h,env:D},null,2)),v(""),k("")},V=x.useMemo(()=>{try{return JSON.parse(i),!0}catch{return!1}},[i]),O=x.useMemo(()=>a!==null?a!==JSON.stringify(c,null,2):Object.keys(l).length>0,[a,l,c]),Z=x.useMemo(()=>{const m=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],y=h?.env||{};return m.filter(D=>!y[D]?.trim())},[h]);x.useEffect(()=>{d?.(O)},[O,d]);const C=ge({mutationFn:async()=>{let m;try{m=JSON.parse(i)}catch{m={...S?.settings,env:{...S?.settings?.env,...l}}}const y=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:m,expectedMtime:S?.mtime})});if(y.status===409)throw new Error("CONFLICT");if(!y.ok)throw new Error("Failed to save");return y.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["settings",s]}),N.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),P.success(te.t("commonToast.settingsSaved"))},onError:m=>{m.message==="CONFLICT"?f(!0):P.error(m.message)}}),H=ge({mutationFn:async m=>(await as.profiles.update(s,{target:m}),m),onSuccess:()=>{N.invalidateQueries({queryKey:["profiles"]}),P.success(te.t("commonToast.defaultTargetUpdated"))},onError:(m,y)=>{const D=y==="droid"?"Factory Droid":"Claude Code",$=m.message.trim()?`: ${m.message}`:"";P.error(te.t("commonToast.failedUpdateDefaultTarget",{target:D,suffix:$}))}}),G=t||"claude",W=C.isPending||H.isPending,ee=async m=>{f(!1),m?(await E(),C.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ds,{profileName:s,target:G,data:S,settings:h,isLoading:F,isSaving:C.isPending,isTargetSaving:H.isPending,hasChanges:O,isRawJsonValid:V,onTargetChange:m=>{W||m!==G&&H.mutate(m)},onRefresh:()=>{W||E()},onDelete:n,onSave:()=>{W||C.mutate()}}),F?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ae,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):w?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(j,{variant:"outline",size:"sm",onClick:()=>E(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5 min-w-0",children:e.jsx(Hs,{profileName:s,target:G,data:S,currentSettings:h,newEnvKey:u,newEnvValue:b,onNewEnvKeyChange:v,onNewEnvValueChange:k,onEnvValueChange:Q,onEnvBulkChange:Y,onAddEnvVar:J})}),e.jsxs("div",{className:"flex 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(ys,{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(ts,{rawJsonContent:i,isRawJsonValid:V,rawJsonEdits:a,settings:c,onChange:U,missingRequiredFields:Z})]})]}),e.jsx(oe,{open:r,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ee(!0),onCancel:()=>ee(!1)})]},s)}const be="ccs:openrouter-banner-dismissed";function $s({onCreateClick:s}){const[t,n]=x.useState(!0),{modelCount:d,isLoading:l}=de();x.useEffect(()=>{const r=localStorage.getItem(be)==="true";n(r)},[]);const g=()=>{localStorage.setItem(be,"true"),n(!0)};return t?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(me,{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 ",l?"300+":`${d}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(j,{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(ce,{className:"w-3 h-3"})]}),e.jsxs(j,{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 ie({badge:s,badgeClassName:t,className:n,title:d,description:l,visual:g,highlights:r,actionLabel:f,actionClassName:a,onAction:p,footer:u}){return e.jsxs(Se,{className:_("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(rs,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(R,{variant:"secondary",className:t,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ns,{className:"text-base",children:d}),e.jsx(is,{className:"text-sm leading-6",children:l})]})]}),e.jsxs(Oe,{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:r.map(v=>e.jsxs("div",{className:"flex items-center gap-2",children:[v.icon,e.jsx("span",{children:v.label})]},v.label))}),e.jsxs(j,{onClick:p,className:a,children:[f,e.jsx(Ps,{className:"ml-2 h-4 w-4"})]}),u?e.jsx("div",{className:"text-xs text-muted-foreground",children:u}):null]})]})}function zs({hasProfiles:s,profileCount:t,onOpenRouterClick:n,onAlibabaCodingPlanClick:d,onCliproxyClick:l,onCustomClick:g}){const{t:r}=q(),{modelCount:f,isLoading:a}=de(),p=a?"300+":`${f}+`,u=s?r("openrouterQuickStart.profileCount",{count:t}):r("openrouterQuickStart.recommended"),v=r(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),b=s?r("openrouterQuickStart.summaryDescriptionWithProfiles",{count:t}):r("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(Se,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Oe,{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(R,{variant:"secondary",children:u}),e.jsx(R,{variant:"outline",children:r("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:v}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:b})]})]}),e.jsx(j,{variant:"outline",onClick:g,className:"shrink-0",children:r("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ie,{badge:r("openrouterQuickStart.recommended"),title:r("openrouterQuickStart.title"),description:r("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(_e,{className:"h-3.5 w-3.5 text-accent"}),label:r("openrouterQuickStart.featureOneApi")},{icon:e.jsx(me,{className:"h-3.5 w-3.5 text-accent"}),label:r("openrouterQuickStart.featureTierMapping")}],actionLabel:r("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[r("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(ce,{className:"h-3 w-3"})]})]})}),e.jsx(ie,{badge:r("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:r("openrouterQuickStart.runtimeProviderTitle"),description:r("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(fe,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(fe,{className:"h-3.5 w-3.5 text-emerald-600"}),label:r("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(je,{className:"h-3.5 w-3.5 text-emerald-600"}),label:r("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:r("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:l,footer:e.jsx("span",{children:r("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ie,{badge:r("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:r("alibabaCodingPlanQuickStart.title"),description:r("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(Re,{className:"h-3.5 w-3.5 text-orange-600"}),label:r("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(je,{className:"h-3.5 w-3.5 text-orange-600"}),label:r("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:r("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:d,footer:e.jsxs(e.Fragment,{children:[r("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(ce,{className:"h-3 w-3"})]})]})})]})]})})}function Ks({onCreateClick:s}){const{modelCount:t,isLoading:n}=de();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+":`${t}+`," models available"]})]}),e.jsxs(j,{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(_e,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Js({onCreateClick:s}){const{t}=q();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:t("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:t("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(j,{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(Re,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:t("alibabaCodingPlanPromo.add")})]})]})})}function rt(){const{t:s}=q(),t=He(),{data:n,isLoading:d,isError:l,refetch:g}=ls(),r=os(),f=cs(),a=ds(),p=ms(),u=xs(),v=us(),[b,k]=x.useState(null),[N,S]=x.useState(""),[F,w]=x.useState(!1),[E,c]=x.useState("normal"),[h,i]=x.useState(null),[U,Q]=x.useState(!1),[Y,J]=x.useState(null),V=x.useRef(null);hs();const O=x.useMemo(()=>n?.profiles||[],[n?.profiles]),Z=x.useMemo(()=>O.filter(o=>o.name.toLowerCase().includes(N.toLowerCase())),[O,N]),C=b?O.find(o=>o.name===b):null,H=o=>{U&&b!==o?J(o):k(o)},G=o=>{r.mutate(o,{onSuccess:()=>{b===o&&(k(null),Q(!1),J(null)),i(null)}})},W=o=>{w(!1),H(o)},ee=o=>{H(o)},m=(o,L)=>{const A=JSON.stringify(L,null,2)+`
|
|
2
|
-
`,z=new Blob([A],{type:"application/json"}),I=URL.createObjectURL(z),K=document.createElement("a");K.href=I,K.download=o,document.body.appendChild(K),K.click(),K.remove(),URL.revokeObjectURL(I)},y=async()=>{try{const o=await f.mutateAsync();if(o.orphans.length===0){P.success("No orphan profile settings found");return}const L=o.orphans.filter(K=>K.validation.valid).length;if(!window.confirm(`Found ${o.orphans.length} orphan settings file(s). Register ${L} valid profile(s) now?`))return;const z=await a.mutateAsync({}),I=z.skipped.length>0?`, skipped ${z.skipped.length}`:"";P.success(`Registered ${z.registered.length} profile(s)${I}`)}catch(o){P.error(o.message)}},D=async()=>{if(!C)return;const o=window.prompt(`Copy profile "${C.name}" to new profile name:`,`${C.name}-copy`);if(!o)return;const L=o.trim();if(!L){P.error("Destination profile name cannot be empty");return}try{const A=await p.mutateAsync({name:C.name,data:{destination:L}});H(L),A.warnings&&A.warnings.length>0&&P.info(A.warnings.join(`
|
|
3
|
-
`))}catch(A){P.error(A.message)}},$=async()=>{if(C)try{const o=await u.mutateAsync({name:C.name});m(`${C.name}.ccs-profile.json`,o.bundle),o.redacted?P.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):P.success("Profile export downloaded")}catch(o){P.error(o.message)}},Fe=()=>{V.current?.click()},Ue=async o=>{const L=o.target.files?.[0];if(o.target.value="",!!L)try{const A=await L.text(),z=JSON.parse(A),I=await v.mutateAsync({bundle:z});I.name&&H(I.name),I.warnings&&I.warnings.length>0&&P.info(I.warnings.join(`
|
|
4
|
-
`))}catch(A){P.error(A.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx($s,{onCreateClick:()=>w(!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(Ss,{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(j,{size:"sm",variant:"outline",onClick:()=>void y(),disabled:f.isPending||a.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(X,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(j,{size:"sm",variant:"outline",onClick:Fe,disabled:v.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(Os,{className:"w-4 h-4"})}),e.jsxs(j,{size:"sm",onClick:()=>{w(!0)},children:[e.jsx(re,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ee,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(M,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:N,onChange:o=>S(o.target.value)})]})]}),e.jsx(ne,{className:"flex-1 min-h-0",children:d?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):l?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Me,{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(j,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):Z.length===0?e.jsx("div",{className:"p-4 text-center",children:O.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ts,{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(j,{size:"sm",variant:"outline",onClick:()=>{w(!0)},children:[e.jsx(re,{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:N})})}):e.jsx("div",{className:"p-2 space-y-1",children:Z.map(o=>e.jsx(Bs,{profile:o,isSelected:b===o.name,onSelect:()=>ee(o.name),onDelete:()=>i(o.name)},o.name))})}),O.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:O.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(De,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:O.filter(o=>o.configured).length})]})]})}),e.jsx(Ks,{onCreateClick:()=>{c("openrouter"),w(!0)}}),e.jsx(Js,{onCreateClick:()=>{c("alibaba-coding-plan"),w(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:C?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(j,{size:"sm",variant:"outline",onClick:()=>void D(),disabled:p.isPending,children:[e.jsx(Es,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>void $(),disabled:u.isPending,children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx(Qs,{profileName:C.name,profileTarget:C.target,onDelete:()=>i(C.name),onHasChangesUpdate:Q},C.name)]}):e.jsx(zs,{hasProfiles:O.length>0,profileCount:O.length,onCliproxyClick:()=>{t("/cliproxy/ai-providers")},onOpenRouterClick:()=>{c("openrouter"),w(!0)},onAlibabaCodingPlanClick:()=>{c("alibaba-coding-plan"),w(!0)},onCustomClick:()=>{c("normal"),w(!0)}})})]}),e.jsx("input",{ref:V,type:"file",accept:".json,application/json",className:"hidden",onChange:o=>void Ue(o)}),e.jsx(ps,{open:F,onOpenChange:w,onSuccess:W,initialMode:E}),e.jsx(oe,{open:!!h,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:h??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>h&&G(h),onCancel:()=>i(null)}),e.jsx(oe,{open:!!Y,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:b??"",next:Y??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{Q(!1),k(Y),J(null)},onCancel:()=>J(null)})]})}function Bs({profile:s,isSelected:t,onSelect:n,onDelete:d}){return e.jsxs("div",{className:_("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(De,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(Me,{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(R,{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(B,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(j,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:l=>{l.stopPropagation(),d()},children:e.jsx(Te,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{rt as ApiPage};
|