@chenpu17/cc-gw 0.7.18 → 0.7.20

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 (29) hide show
  1. package/package.json +1 -1
  2. package/src/web/dist/assets/{About-DiMtBAOL.js → About-CE2fqYju.js} +2 -2
  3. package/src/web/dist/assets/ApiKeys-jnqKcfat.js +16 -0
  4. package/src/web/dist/assets/{Dashboard-C6Uai54P.js → Dashboard-B61eM9AQ.js} +1 -1
  5. package/src/web/dist/assets/{Events-CP1K4Di7.js → Events-DXUNZen5.js} +1 -1
  6. package/src/web/dist/assets/{Help-D9w8Z7bi.js → Help-DTQVUeCR.js} +1 -1
  7. package/src/web/dist/assets/{Login-LyOFmFDM.js → Login-BcTP1zb_.js} +1 -1
  8. package/src/web/dist/assets/{Logs-qMkJ_LnZ.js → Logs-Cy6rL2PL.js} +1 -1
  9. package/src/web/dist/assets/{ModelManagement-JuXIL4nJ.js → ModelManagement-D2ZQEDua.js} +2 -2
  10. package/src/web/dist/assets/{PageHeader-C2Un_Eq9.js → PageHeader-D2Zq1K4t.js} +1 -1
  11. package/src/web/dist/assets/{PageSection-B9yrPBCN.js → PageSection-wWtyIp2D.js} +1 -1
  12. package/src/web/dist/assets/{Settings-yxuIaovZ.js → Settings-Bz_Hag2N.js} +1 -1
  13. package/src/web/dist/assets/{Skeleton-BLdvXQnT.js → Skeleton-BRSmcxNh.js} +1 -1
  14. package/src/web/dist/assets/{card-CtgEZD37.js → card-Dl49soGw.js} +1 -1
  15. package/src/web/dist/assets/{dialog-DRP_IQxH.js → dialog-CW6Z62O9.js} +3 -3
  16. package/src/web/dist/assets/index-B1EJcuR-.css +1 -0
  17. package/src/web/dist/assets/{index-B_ZdlwhD.js → index-Bdp0nMlR.js} +2 -2
  18. package/src/web/dist/assets/{index-D3x39AFW.js → index-Cu1IXjrr.js} +1 -1
  19. package/src/web/dist/assets/{info-B8rDg1M6.js → info-Yuz8DmBH.js} +1 -1
  20. package/src/web/dist/assets/{input-BJXToHiR.js → input-B6w5gzdL.js} +1 -1
  21. package/src/web/dist/assets/{label-CzVczRHt.js → label-CuU6RIsU.js} +1 -1
  22. package/src/web/dist/assets/{refresh-cw-BvguPOQm.js → refresh-cw-Duv0QKyb.js} +1 -1
  23. package/src/web/dist/assets/{select-B1I4kItt.js → select-Cfzsn-JK.js} +1 -1
  24. package/src/web/dist/assets/{shield-DceCQI6h.js → shield--mDWO-No.js} +1 -1
  25. package/src/web/dist/assets/{switch-DteEzH7T.js → switch-DoT-Ur3p.js} +1 -1
  26. package/src/web/dist/assets/{useApiQuery-DNDJWhHp.js → useApiQuery-CL9_n4sn.js} +1 -1
  27. package/src/web/dist/index.html +2 -2
  28. package/src/web/dist/assets/ApiKeys-DcKwRUMu.js +0 -16
  29. package/src/web/dist/assets/index-yEbjdbzX.css +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenpu17/cc-gw",
3
- "version": "0.7.18",
3
+ "version": "0.7.20",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
- import{c as j,u as g,b as v,r as i,j as e,e as d,aa as N}from"./index-B_ZdlwhD.js";import{u as y}from"./useApiQuery-DNDJWhHp.js";import{P as E}from"./PageHeader-C2Un_Eq9.js";import{P as n}from"./PageSection-B9yrPBCN.js";import{C as m,a as p}from"./card-CtgEZD37.js";import{I}from"./info-B8rDg1M6.js";import{R as T}from"./refresh-cw-BvguPOQm.js";/**
1
+ import{c as j,u as g,b as v,r as i,j as e,e as d,aa as N}from"./index-Bdp0nMlR.js";import{u as y}from"./useApiQuery-CL9_n4sn.js";import{P as E}from"./PageHeader-D2Zq1K4t.js";import{P as n}from"./PageSection-wWtyIp2D.js";import{C as m,a as p}from"./card-Dl49soGw.js";import{I}from"./info-Yuz8DmBH.js";import{R as T}from"./refresh-cw-Duv0QKyb.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const k=j("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),_="0.7.18",w={version:_},L={VITE_BUILD_TIME:"2026-02-14T01:36:48.121Z",VITE_NODE_VERSION:"v22.16.0"};function u({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:t.map(a=>e.jsx(m,{children:e.jsxs(p,{className:"pt-4",children:[e.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a.label}),e.jsx("dd",{className:"mt-1 text-sm font-semibold",children:a.value}),a.hint&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.hint})]})},a.label))})}function D(){const{t}=g(),{pushToast:a}=v(),s=y(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});i.useEffect(()=>{s.isError&&s.error&&a({title:t("about.toast.statusError.title"),description:s.error.message,variant:"error"})},[s.isError,s.error,a,t]);const o=w.version,r=i.useMemo(()=>{const c=L,b=c.VITE_BUILD_TIME,f=c.VITE_NODE_VERSION;return{buildTime:b,nodeVersion:f}},[]),x=i.useMemo(()=>[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{className:"font-mono text-primary",children:["v",o]})},{label:t("about.app.labels.buildTime"),value:r.buildTime,hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.node"),value:e.jsx("span",{className:"font-mono",children:r.nodeVersion})}],[o,r.buildTime,r.nodeVersion,t]),l=i.useMemo(()=>s.data?[{label:t("about.status.labels.host"),value:s.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:s.data.port.toLocaleString()},{label:t("about.status.labels.providers"),value:s.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(s.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")}]:[],[s.data,t]),h=()=>{a({title:t("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{icon:e.jsx(I,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:`v${o}`,actions:e.jsxs(d,{onClick:h,children:[e.jsx(k,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(n,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(u,{items:x})}),e.jsx(n,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(d,{variant:"outline",size:"sm",onClick:()=>s.refetch(),disabled:s.isFetching,children:[e.jsx(T,{className:`mr-2 h-4 w-4 ${s.isFetching?"animate-spin":""}`,"aria-hidden":"true"}),s.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:s.isLoading?e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-2 text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.status.loading")})]}):l.length>0?e.jsx(u,{items:l}):e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-1 rounded-lg border border-dashed p-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:t("about.status.empty")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("common.actions.refresh")})]})})]}),e.jsx(n,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),children:e.jsx(m,{children:e.jsxs(p,{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"flex-1 text-sm text-muted-foreground",children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-md bg-muted px-3 py-1.5 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}export{D as default};
6
+ */const k=j("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),_="0.7.20",w={version:_},L={VITE_BUILD_TIME:"2026-02-14T03:02:35.091Z",VITE_NODE_VERSION:"v22.16.0"};function u({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:t.map(a=>e.jsx(m,{children:e.jsxs(p,{className:"pt-4",children:[e.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a.label}),e.jsx("dd",{className:"mt-1 text-sm font-semibold",children:a.value}),a.hint&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.hint})]})},a.label))})}function D(){const{t}=g(),{pushToast:a}=v(),s=y(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});i.useEffect(()=>{s.isError&&s.error&&a({title:t("about.toast.statusError.title"),description:s.error.message,variant:"error"})},[s.isError,s.error,a,t]);const o=w.version,r=i.useMemo(()=>{const c=L,b=c.VITE_BUILD_TIME,f=c.VITE_NODE_VERSION;return{buildTime:b,nodeVersion:f}},[]),x=i.useMemo(()=>[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{className:"font-mono text-primary",children:["v",o]})},{label:t("about.app.labels.buildTime"),value:r.buildTime,hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.node"),value:e.jsx("span",{className:"font-mono",children:r.nodeVersion})}],[o,r.buildTime,r.nodeVersion,t]),l=i.useMemo(()=>s.data?[{label:t("about.status.labels.host"),value:s.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:s.data.port.toLocaleString()},{label:t("about.status.labels.providers"),value:s.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(s.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")}]:[],[s.data,t]),h=()=>{a({title:t("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{icon:e.jsx(I,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:`v${o}`,actions:e.jsxs(d,{onClick:h,children:[e.jsx(k,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(n,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(u,{items:x})}),e.jsx(n,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(d,{variant:"outline",size:"sm",onClick:()=>s.refetch(),disabled:s.isFetching,children:[e.jsx(T,{className:`mr-2 h-4 w-4 ${s.isFetching?"animate-spin":""}`,"aria-hidden":"true"}),s.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:s.isLoading?e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-2 text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.status.loading")})]}):l.length>0?e.jsx(u,{items:l}):e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-1 rounded-lg border border-dashed p-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:t("about.status.empty")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("common.actions.refresh")})]})})]}),e.jsx(n,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),children:e.jsx(m,{children:e.jsxs(p,{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"flex-1 text-sm text-muted-foreground",children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-md bg-muted px-3 py-1.5 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}export{D as default};
@@ -0,0 +1,16 @@
1
+ import{c as z,r as n,j as e,a as ne,u as q,b as Ne,W as be,e as c,Y as we,Z as ke,d as v,t as b}from"./index-Bdp0nMlR.js";import{E as Ee}from"./index-Cu1IXjrr.js";import{u as L}from"./useApiQuery-CL9_n4sn.js";import{P as Ce,B as C}from"./PageHeader-D2Zq1K4t.js";import{P as ee}from"./PageSection-wWtyIp2D.js";import{c as Se}from"./clipboard-CALi6bTW.js";import{I as De}from"./input-B6w5gzdL.js";import{L as M}from"./label-CuU6RIsU.js";import{C as H,a as U}from"./card-Dl49soGw.js";import{P as Te,D as O,a as W,b as P,c as R,d as se,e as F}from"./dialog-CW6Z62O9.js";import{C as ae,S as Ae}from"./shield--mDWO-No.js";/**
2
+ * @license lucide-react v0.344.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Le=z("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
7
+ * @license lucide-react v0.344.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Me=z("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
12
+ * @license lucide-react v0.344.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Oe=z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),re=n.forwardRef(({className:s,...i},o)=>e.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:o,...i}));re.displayName="Textarea";function We(){const[s,i]=n.useState([]);return n.useEffect(()=>{const o=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}];v.get("/api/custom-endpoints").then(m=>{const u=(m.data.endpoints??[]).map(d=>({id:d.id,label:d.label}));i([...o,...u])}).catch(()=>{i(o)})},[]),s}function te({available:s,selected:i,onChange:o,hint:m}){const{t:u}=q(),d=i.length===0,w=()=>{o([])},f=l=>{i.includes(l)?o(i.filter(K=>K!==l)):o([...i,l])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 transition-colors hover:bg-muted/50",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:w,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:u("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:s.map(l=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md border px-3 py-2 transition-colors hover:bg-muted/50",children:[e.jsx("input",{type:"checkbox",checked:!d&&i.includes(l.id),onChange:()=>f(l.id),className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm",children:l.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",l.id,")"]})]},l.id))})]})}const Pe=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function Be(){const{t:s}=q(),{pushToast:i}=Ne(),[o,m]=n.useState(!1),[u,d]=n.useState(""),[w,f]=n.useState(""),[l,K]=n.useState([]),[p,S]=n.useState(null),[le,V]=n.useState(null),[h,ce]=n.useState(7),[G,Q]=n.useState(new Map),[oe,$]=n.useState(null),[y,k]=n.useState(null),[D,B]=n.useState([]),Z=We(),g=L(["api-keys"],{url:"/api/keys",method:"GET"}),E=L(["api-keys","overview",h],{url:"/api/stats/api-keys/overview",method:"GET",params:{days:h}}),N=L(["api-keys","usage",h],{url:"/api/stats/api-keys/usage",method:"GET",params:{days:h,limit:10}}),T=g.data??[],j=E.data,x=N.data??[],de=T.some(a=>a.isWildcard),pe=j?j.totalKeys.toLocaleString():"-",me=j?j.enabledKeys.toLocaleString():"-",ue=j?j.activeKeys.toLocaleString():"-",Y=async()=>{if(!u.trim()){i({title:s("apiKeys.errors.nameRequired"),variant:"error"});return}try{const a=await v.post("/api/keys",{name:u.trim(),description:w.trim()||void 0,allowedEndpoints:l.length>0?l:void 0});S(a.data),m(!1),d(""),f(""),K([]),g.refetch(),E.refetch(),N.refetch(),i({title:s("apiKeys.toast.keyCreated"),variant:"success"})}catch(a){const t=b(a);i({title:s("apiKeys.toast.createFailure",{message:t.message}),variant:"error"})}},xe=async(a,t)=>{try{await v.patch(`/api/keys/${a}`,{enabled:!t}),g.refetch(),E.refetch(),i({title:s("apiKeys.toast.keyUpdated"),variant:"success"})}catch(r){const A=b(r);i({title:s("apiKeys.toast.updateFailure",{message:A.message}),variant:"error"})}},he=async a=>{if(confirm(s("apiKeys.confirmDelete"))){V(a);try{await v.delete(`/api/keys/${a}`),g.refetch(),E.refetch(),N.refetch(),i({title:s("apiKeys.toast.keyDeleted"),variant:"success"})}catch(t){const r=b(t);i({title:s("apiKeys.toast.deleteFailure",{message:r.message}),variant:"error"})}finally{V(null)}}},ye=async a=>{if(!G.has(a)){$(a);try{const t=await v.get(`/api/keys/${a}/reveal`);Q(r=>new Map(r).set(a,t.data.key))}catch(t){const r=b(t);i({title:s("apiKeys.toast.revealFailure"),description:r.message,variant:"error"})}finally{$(null)}}},ge=a=>{Q(t=>{const r=new Map(t);return r.delete(a),r})},_=async a=>{try{await Se(a),i({title:s("apiKeys.toast.keyCopied"),variant:"success"})}catch(t){i({title:s("apiKeys.toast.copyFailure"),description:t instanceof Error?t.message:s("common.unknownError"),variant:"error"})}},je=n.useCallback(a=>{k(a),B(a.allowedEndpoints??[])},[]),ve=async()=>{if(y)try{await v.patch(`/api/keys/${y.id}`,{allowedEndpoints:D.length>0?D:null}),k(null),g.refetch(),i({title:s("apiKeys.toast.keyUpdated"),variant:"success"})}catch(a){const t=b(a);i({title:s("apiKeys.toast.updateFailure",{message:t.message}),variant:"error"})}},J=a=>a?new Date(a).toLocaleString():s("common.noData"),fe=n.useMemo(()=>{const a=x.map(t=>t.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:a,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.requestsSeries"),type:"bar",data:x.map(t=>t.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[x,s]),Ke=n.useMemo(()=>{const a=x.map(t=>t.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[s("apiKeys.analytics.tokens.input"),s("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:a,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:x.map(t=>t.inputTokens)},{name:s("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:x.map(t=>t.outputTokens)}]}},[x,s]);return g.isLoading?e.jsx(be,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Ce,{icon:e.jsx(we,{className:"h-5 w-5","aria-hidden":"true"}),title:s("apiKeys.title"),description:s("apiKeys.description"),actions:e.jsxs(c,{onClick:()=>m(!0),children:[e.jsx(Te,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("apiKeys.createNew")]})}),e.jsx(ee,{title:s("apiKeys.analytics.title"),description:s("apiKeys.analytics.description",{days:h}),actions:e.jsx("div",{className:"flex items-center gap-1 rounded-lg border p-1",children:Pe.map(a=>{const t=h===a.value;return e.jsx("button",{type:"button",onClick:()=>ce(a.value),className:ne("inline-flex h-7 items-center rounded-md px-3 text-xs font-medium transition-colors",t?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:s(a.labelKey)},a.value)})}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(I,{label:s("apiKeys.analytics.cards.total"),value:pe}),e.jsx(I,{label:s("apiKeys.analytics.cards.enabled"),value:me}),e.jsx(I,{label:s("apiKeys.analytics.cards.active",{days:h}),value:ue})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(ie,{title:s("apiKeys.analytics.charts.requests"),loading:N.isLoading,empty:x.length===0,emptyText:s("apiKeys.analytics.empty"),option:fe}),e.jsx(ie,{title:s("apiKeys.analytics.charts.tokens"),loading:N.isLoading,empty:x.length===0,emptyText:s("apiKeys.analytics.empty"),option:Ke})]})]})}),e.jsx(ee,{title:s("apiKeys.list.title"),description:de?s("apiKeys.wildcardHint"):void 0,children:T.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:s("apiKeys.list.empty")})}):e.jsx("div",{className:"grid gap-4",children:T.map(a=>{const t=(a.totalInputTokens+a.totalOutputTokens).toLocaleString(),r=G.get(a.id),A=oe===a.id;return e.jsx(H,{children:e.jsx(U,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:a.name}),a.isWildcard&&e.jsx(C,{variant:"secondary",children:s("apiKeys.wildcard")}),e.jsx(C,{variant:a.enabled?"default":"outline",children:a.enabled?s("apiKeys.status.enabled"):s("apiKeys.status.disabled")}),!a.isWildcard&&a.allowedEndpoints&&a.allowedEndpoints.length>0?a.allowedEndpoints.map(X=>e.jsx(C,{variant:"outline",className:"text-xs",children:X},X)):a.isWildcard?null:e.jsx(C,{variant:"secondary",className:"text-xs opacity-60",children:s("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"rounded-md bg-muted px-3 py-1.5 font-mono text-sm",children:a.isWildcard?s("apiKeys.wildcard"):r??a.maskedKey??"********"}),!a.isWildcard&&e.jsx("div",{className:"flex items-center gap-1",children:r?e.jsxs(e.Fragment,{children:[e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void _(r),"aria-label":s("common.actions.copy"),title:s("common.actions.copy"),children:e.jsx(ae,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ge(a.id),"aria-label":s("apiKeys.actions.hide"),title:s("apiKeys.actions.hide"),children:e.jsx(Le,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void ye(a.id),disabled:A,"aria-label":s("apiKeys.actions.reveal"),title:s("apiKeys.actions.reveal"),children:e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"})})})]}),a.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("apiKeys.wildcardHint")}):a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null,e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:J(a.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:J(a.lastUsedAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.requestCount")}),e.jsx("p",{className:"font-medium",children:a.requestCount.toLocaleString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("apiKeys.totalTokens")}),e.jsx("p",{className:"font-medium",children:t})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!a.isWildcard&&e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>je(a),children:[e.jsx(Ae,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),s("apiKeys.editEndpoints")]}),e.jsx(c,{variant:a.enabled?"outline":"default",size:"sm",onClick:()=>xe(a.id,a.enabled),children:a.enabled?s("apiKeys.actions.disable"):s("apiKeys.actions.enable")}),!a.isWildcard&&e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>he(a.id),disabled:le===a.id,"aria-label":s("apiKeys.actions.delete"),children:e.jsx(Oe,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})},a.id)})})}),e.jsx(O,{open:o,onOpenChange:m,children:e.jsxs(W,{children:[e.jsxs(P,{children:[e.jsx(R,{children:s("apiKeys.createNew")}),e.jsx(se,{children:s("apiKeys.createDescription")})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{htmlFor:"keyName",children:[s("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(De,{id:"keyName",value:u,onChange:a=>d(a.target.value),placeholder:s("apiKeys.keyNamePlaceholder"),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Y())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"keyDescription",children:s("apiKeys.descriptionLabel")}),e.jsx(re,{id:"keyDescription",value:w,onChange:a=>f(a.target.value),placeholder:s("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:s("apiKeys.allowedEndpoints")}),e.jsx(te,{available:Z,selected:l,onChange:K,hint:s("apiKeys.selectEndpoints")})]})]}),e.jsxs(F,{children:[e.jsx(c,{variant:"outline",onClick:()=>{m(!1),d(""),f(""),K([])},children:s("common.actions.cancel")}),e.jsx(c,{onClick:()=>void Y(),children:s("apiKeys.createAction")})]})]})}),e.jsx(O,{open:!!p,onOpenChange:()=>S(null),children:e.jsxs(W,{children:[e.jsx(P,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600",children:e.jsx(ke,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(R,{children:s("apiKeys.keyCreated")})]})}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:s("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-md bg-muted px-4 py-3 font-mono text-sm",children:p==null?void 0:p.key}),(p==null?void 0:p.description)&&e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:p.description}),e.jsxs(F,{children:[e.jsxs(c,{onClick:()=>void _((p==null?void 0:p.key)??""),children:[e.jsx(ae,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("common.actions.copy")]}),e.jsx(c,{variant:"outline",onClick:()=>S(null),children:s("common.actions.close")})]})]})}),e.jsx(O,{open:!!y,onOpenChange:a=>{a||k(null)},children:e.jsxs(W,{children:[e.jsxs(P,{children:[e.jsx(R,{children:s("apiKeys.editEndpoints")}),e.jsx(se,{children:y==null?void 0:y.name})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto",children:e.jsx(te,{available:Z,selected:D,onChange:B,hint:s("apiKeys.selectEndpoints")})}),e.jsxs(F,{children:[e.jsx(c,{variant:"outline",onClick:()=>k(null),children:s("common.actions.cancel")}),e.jsx(c,{onClick:()=>void ve(),children:s("common.save")})]})]})})]})}function I({label:s,value:i}){return e.jsx(H,{children:e.jsxs(U,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:i})]})})}function ie({title:s,option:i,loading:o,empty:m,emptyText:u}){const{t:d}=q();return e.jsx(H,{children:e.jsxs(U,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:s}),o?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:d("common.loadingShort")})}):m?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-lg border border-dashed",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u})}):e.jsx(Ee,{option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}export{Be as default};
@@ -1,4 +1,4 @@
1
- import{c as _,r as n,j as e,a as y,u as D,b as le,d as ce,t as me,B as I,e as he}from"./index-B_ZdlwhD.js";import{E as ue}from"./index-D3x39AFW.js";import{S as xe,C as pe,T as be}from"./Skeleton-BLdvXQnT.js";import{P as X,B as w}from"./PageHeader-C2Un_Eq9.js";import{P as Z}from"./PageSection-B9yrPBCN.js";import{u as k}from"./useApiQuery-DNDJWhHp.js";import{C as G,a as Q}from"./card-CtgEZD37.js";import{S as ge,a as fe,b as ye,c as je,d as M}from"./select-B1I4kItt.js";/**
1
+ import{c as _,r as n,j as e,a as y,u as D,b as le,d as ce,t as me,B as I,e as he}from"./index-Bdp0nMlR.js";import{E as ue}from"./index-Cu1IXjrr.js";import{S as xe,C as pe,T as be}from"./Skeleton-BRSmcxNh.js";import{P as X,B as w}from"./PageHeader-D2Zq1K4t.js";import{P as Z}from"./PageSection-wWtyIp2D.js";import{u as k}from"./useApiQuery-CL9_n4sn.js";import{C as G,a as Q}from"./card-Dl49soGw.js";import{S as ge,a as fe,b as ye,c as je,d as M}from"./select-Cfzsn-JK.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as N,u as L,b as E,r as i,j as e,e as h,C as R,a as $,L as I,g as T,t as P}from"./index-B_ZdlwhD.js";import{P as z,B as j}from"./PageHeader-C2Un_Eq9.js";import{I as F}from"./input-BJXToHiR.js";import{C as w,a as C,b as V}from"./card-CtgEZD37.js";import{S as B,a as D,b as K,c as H,d as f}from"./select-B1I4kItt.js";import{R as J}from"./refresh-cw-BvguPOQm.js";/**
1
+ import{c as N,u as L,b as E,r as i,j as e,e as h,C as R,a as $,L as I,g as T,t as P}from"./index-Bdp0nMlR.js";import{P as z,B as j}from"./PageHeader-D2Zq1K4t.js";import{I as F}from"./input-B6w5gzdL.js";import{C as w,a as C,b as V}from"./card-Dl49soGw.js";import{S as B,a as D,b as K,c as H,d as f}from"./select-Cfzsn-JK.js";import{R as J}from"./refresh-cw-Duv0QKyb.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as x,u,r as g,j as e,e as h}from"./index-B_ZdlwhD.js";import{P as N}from"./PageHeader-C2Un_Eq9.js";import{P as d}from"./PageSection-B9yrPBCN.js";import{c as p}from"./clipboard-CALi6bTW.js";import{C as j,a as f}from"./card-CtgEZD37.js";import{I as v}from"./info-B8rDg1M6.js";/**
1
+ import{c as x,u,r as g,j as e,e as h}from"./index-Bdp0nMlR.js";import{P as N}from"./PageHeader-D2Zq1K4t.js";import{P as d}from"./PageSection-wWtyIp2D.js";import{c as p}from"./clipboard-CALi6bTW.js";import{C as j,a as f}from"./card-Dl49soGw.js";import{I as v}from"./info-Yuz8DmBH.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{u as C,an as E,ao as F,ap as S,r as n,j as e,W as L,e as k}from"./index-B_ZdlwhD.js";import{I as j}from"./input-BJXToHiR.js";import{L as b}from"./label-CzVczRHt.js";import{C as v,a as w,b as P,c as T,d as A,e as D}from"./card-CtgEZD37.js";function G(){const{t:s}=C(),l=E(),u=F(),{authEnabled:i,isAuthenticated:m,loading:o,login:N,error:x}=S(),[t,f]=n.useState({username:"",password:""}),[p,d]=n.useState(null),[h,g]=n.useState(!1),c=n.useMemo(()=>{var r;const a=u.state;return((r=a==null?void 0:a.from)==null?void 0:r.pathname)??"/"},[u.state]);n.useEffect(()=>{if(!i&&!o){l(c,{replace:!0});return}i&&m&&!o&&l(c,{replace:!0})},[i,m,o,l,c]);const y=async a=>{if(a.preventDefault(),d(null),!t.username.trim()||!t.password){d(s("login.validation.required"));return}g(!0);try{await N(t.username.trim(),t.password),l(c,{replace:!0})}catch(r){d(r instanceof Error?r.message:s("login.validation.failed"))}finally{g(!1)}};return o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx(v,{className:"w-full max-w-md",children:e.jsx(w,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(L,{})})})}):i?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsxs(v,{className:"w-full max-w-md",children:[e.jsxs(P,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-xl bg-primary text-lg font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-2xl",children:s("login.title")}),e.jsx(A,{className:"text-sm",children:s("login.description")})]}),e.jsx(w,{children:e.jsxs("form",{className:"space-y-4",onSubmit:y,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(j,{id:"username",value:t.username,autoComplete:"username",autoFocus:!0,onChange:a=>f(r=>({...r,username:a.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(j,{id:"password",type:"password",value:t.password,autoComplete:"current-password",onChange:a=>f(r=>({...r,password:a.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),(p||x)&&e.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:p||x}),e.jsx(k,{type:"submit",className:"w-full",disabled:h,children:s(h?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(D,{className:"justify-center",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})}):null}export{G as default};
1
+ import{u as C,an as E,ao as F,ap as S,r as n,j as e,W as L,e as k}from"./index-Bdp0nMlR.js";import{I as j}from"./input-B6w5gzdL.js";import{L as b}from"./label-CuU6RIsU.js";import{C as v,a as w,b as P,c as T,d as A,e as D}from"./card-Dl49soGw.js";function G(){const{t:s}=C(),l=E(),u=F(),{authEnabled:i,isAuthenticated:m,loading:o,login:N,error:x}=S(),[t,f]=n.useState({username:"",password:""}),[p,d]=n.useState(null),[h,g]=n.useState(!1),c=n.useMemo(()=>{var r;const a=u.state;return((r=a==null?void 0:a.from)==null?void 0:r.pathname)??"/"},[u.state]);n.useEffect(()=>{if(!i&&!o){l(c,{replace:!0});return}i&&m&&!o&&l(c,{replace:!0})},[i,m,o,l,c]);const y=async a=>{if(a.preventDefault(),d(null),!t.username.trim()||!t.password){d(s("login.validation.required"));return}g(!0);try{await N(t.username.trim(),t.password),l(c,{replace:!0})}catch(r){d(r instanceof Error?r.message:s("login.validation.failed"))}finally{g(!1)}};return o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx(v,{className:"w-full max-w-md",children:e.jsx(w,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(L,{})})})}):i?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsxs(v,{className:"w-full max-w-md",children:[e.jsxs(P,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-xl bg-primary text-lg font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-2xl",children:s("login.title")}),e.jsx(A,{className:"text-sm",children:s("login.description")})]}),e.jsx(w,{children:e.jsxs("form",{className:"space-y-4",onSubmit:y,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(j,{id:"username",value:t.username,autoComplete:"username",autoFocus:!0,onChange:a=>f(r=>({...r,username:a.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(j,{id:"password",type:"password",value:t.password,autoComplete:"current-password",onChange:a=>f(r=>({...r,password:a.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),(p||x)&&e.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:p||x}),e.jsx(k,{type:"submit",className:"w-full",disabled:h,children:s(h?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(D,{className:"justify-center",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})}):null}export{G as default};
@@ -1,4 +1,4 @@
1
- import{c as $e,u as H,b as ve,r,d as Fe,t as Ke,j as e,e as k,a as D,F as Me,X as Ne,f as Ae}from"./index-B_ZdlwhD.js";import{u as M}from"./useApiQuery-DNDJWhHp.js";import{T as Pe,a as K}from"./Skeleton-BLdvXQnT.js";import{P as ze,B as ee}from"./PageHeader-C2Un_Eq9.js";import{c as Oe}from"./clipboard-CALi6bTW.js";import{I as Z}from"./input-BJXToHiR.js";import{L as C}from"./label-CzVczRHt.js";import{C as he,a as fe}from"./card-CtgEZD37.js";import{C as Ie,e as qe,S as I,a as q,b as U,c as B,d as w}from"./select-B1I4kItt.js";import{R as Ue}from"./refresh-cw-BvguPOQm.js";/**
1
+ import{c as $e,u as H,b as ve,r,d as Fe,t as Ke,j as e,e as k,a as D,F as Me,X as Ne,f as Ae}from"./index-Bdp0nMlR.js";import{u as M}from"./useApiQuery-CL9_n4sn.js";import{T as Pe,a as K}from"./Skeleton-BRSmcxNh.js";import{P as ze,B as ee}from"./PageHeader-D2Zq1K4t.js";import{c as Oe}from"./clipboard-CALi6bTW.js";import{I as Z}from"./input-B6w5gzdL.js";import{L as C}from"./label-CuU6RIsU.js";import{C as he,a as fe}from"./card-Dl49soGw.js";import{C as Ie,e as qe,S as I,a as q,b as U,c as B,d as w}from"./select-Cfzsn-JK.js";import{R as Ue}from"./refresh-cw-Duv0QKyb.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,6 +1,6 @@
1
- var dt=t=>{throw TypeError(t)};var Ve=(t,a,o)=>a.has(t)||dt("Cannot "+o);var O=(t,a,o)=>(Ve(t,a,"read from private field"),o?o.call(t):a.get(t)),ue=(t,a,o)=>a.has(t)?dt("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(t):a.set(t,o),me=(t,a,o,c)=>(Ve(t,a,"write to private field"),c?c.call(t,o):a.set(t,o),o),pe=(t,a,o)=>(Ve(t,a,"access private method"),o);import{c as vs,S as js,s as ys,h as ct,i as Ns,n as bt,k as vt,r as f,l as ks,m as ws,o as jt,p as Ms,j as e,R as Cs,q as Es,v as Ps,w as yt,P as Nt,x as Ne,A as kt,y as wt,z as Rs,D as Ss,E as Ds,G as Os,H as As,I as Ts,J as Is,K as Us,M as Fs,a as ke,u as ge,b as Mt,e as I,N as _s,X as Te,d as W,O as we,t as Ie,C as Ls,T as $s,Q as Ks,U as zs,V as Bs}from"./index-B_ZdlwhD.js";import{u as Vs,a as qs}from"./useApiQuery-DNDJWhHp.js";import{P as Hs,B as Q}from"./PageHeader-C2Un_Eq9.js";import{I as xe}from"./input-BJXToHiR.js";import{L as de}from"./label-CzVczRHt.js";import{C as qe,a as He}from"./card-CtgEZD37.js";import{S as Ct}from"./switch-DteEzH7T.js";import{S as Gs,a as Qs,b as Js,c as Xs,d as ut,e as Ws}from"./select-B1I4kItt.js";import{P as Je,D as Et,a as Pt,b as Rt,c as St,d as Dt,e as Ot}from"./dialog-DRP_IQxH.js";import{R as Ys}from"./refresh-cw-BvguPOQm.js";/**
1
+ var dt=t=>{throw TypeError(t)};var Ve=(t,a,o)=>a.has(t)||dt("Cannot "+o);var O=(t,a,o)=>(Ve(t,a,"read from private field"),o?o.call(t):a.get(t)),ue=(t,a,o)=>a.has(t)?dt("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(t):a.set(t,o),me=(t,a,o,c)=>(Ve(t,a,"write to private field"),c?c.call(t,o):a.set(t,o),o),pe=(t,a,o)=>(Ve(t,a,"access private method"),o);import{c as vs,S as js,s as ys,h as ct,i as Ns,n as bt,k as vt,r as f,l as ks,m as ws,o as jt,p as Ms,j as e,R as Cs,q as Es,v as Ps,w as yt,P as Nt,x as Ne,A as kt,y as wt,z as Rs,D as Ss,E as Ds,G as Os,H as As,I as Ts,J as Is,K as Us,M as Fs,a as ke,u as ge,b as Mt,e as I,N as _s,X as Te,d as W,O as we,t as Ie,C as Ls,T as $s,Q as Ks,U as zs,V as Bs}from"./index-Bdp0nMlR.js";import{u as Vs,a as qs}from"./useApiQuery-CL9_n4sn.js";import{P as Hs,B as Q}from"./PageHeader-D2Zq1K4t.js";import{I as xe}from"./input-B6w5gzdL.js";import{L as de}from"./label-CuU6RIsU.js";import{C as qe,a as He}from"./card-Dl49soGw.js";import{S as Ct}from"./switch-DoT-Ur3p.js";import{S as Gs,a as Qs,b as Js,c as Xs,d as ut,e as Ws}from"./select-Cfzsn-JK.js";import{P as Je,D as Et,a as Pt,b as Rt,c as St,d as Dt,e as Ot}from"./dialog-CW6Z62O9.js";import{R as Ys}from"./refresh-cw-Duv0QKyb.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const he=vs("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var Z,re,z,ee,te,Ae,Xe,gt,Zs=(gt=class extends js{constructor(a,o){super();ue(this,te);ue(this,Z);ue(this,re);ue(this,z);ue(this,ee);me(this,Z,a),this.setOptions(o),this.bindMethods(),pe(this,te,Ae).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(a){var c;const o=this.options;this.options=O(this,Z).defaultMutationOptions(a),ys(this.options,o)||O(this,Z).getMutationCache().notify({type:"observerOptionsUpdated",mutation:O(this,z),observer:this}),o!=null&&o.mutationKey&&this.options.mutationKey&&ct(o.mutationKey)!==ct(this.options.mutationKey)?this.reset():((c=O(this,z))==null?void 0:c.state.status)==="pending"&&O(this,z).setOptions(this.options)}onUnsubscribe(){var a;this.hasListeners()||(a=O(this,z))==null||a.removeObserver(this)}onMutationUpdate(a){pe(this,te,Ae).call(this),pe(this,te,Xe).call(this,a)}getCurrentResult(){return O(this,re)}reset(){var a;(a=O(this,z))==null||a.removeObserver(this),me(this,z,void 0),pe(this,te,Ae).call(this),pe(this,te,Xe).call(this)}mutate(a,o){var c;return me(this,ee,o),(c=O(this,z))==null||c.removeObserver(this),me(this,z,O(this,Z).getMutationCache().build(O(this,Z),this.options)),O(this,z).addObserver(this),O(this,z).execute(a)}},Z=new WeakMap,re=new WeakMap,z=new WeakMap,ee=new WeakMap,te=new WeakSet,Ae=function(){var o;const a=((o=O(this,z))==null?void 0:o.state)??Ns();me(this,re,{...a,isPending:a.status==="pending",isSuccess:a.status==="success",isError:a.status==="error",isIdle:a.status==="idle",mutate:this.mutate,reset:this.reset})},Xe=function(a){bt.batch(()=>{var o,c,d,x,r,u,v,p;if(O(this,ee)&&this.hasListeners()){const C=O(this,re).variables,D=O(this,re).context,P={client:O(this,Z),meta:this.options.meta,mutationKey:this.options.mutationKey};(a==null?void 0:a.type)==="success"?((c=(o=O(this,ee)).onSuccess)==null||c.call(o,a.data,C,D,P),(x=(d=O(this,ee)).onSettled)==null||x.call(d,a.data,null,C,D,P)):(a==null?void 0:a.type)==="error"&&((u=(r=O(this,ee)).onError)==null||u.call(r,a.error,C,D,P),(p=(v=O(this,ee)).onSettled)==null||p.call(v,void 0,a.error,C,D,P))}this.listeners.forEach(C=>{C(O(this,re))})})},gt);function mt(t,a){const o=vt(),[c]=f.useState(()=>new Zs(o,t));f.useEffect(()=>{c.setOptions(t)},[c,t]);const d=f.useSyncExternalStore(f.useCallback(r=>c.subscribe(bt.batchCalls(r)),[c]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),x=f.useCallback((r,u)=>{c.mutate(r,u).catch(ks)},[c]);if(d.error&&ws(c.options.throwOnError,[d.error]))throw d.error;return{...d,mutate:x,mutateAsync:d.mutate}}var Ue="Popover",[At]=Es(Ue,[jt]),Me=jt(),[ea,oe]=At(Ue),Tt=t=>{const{__scopePopover:a,children:o,open:c,defaultOpen:d,onOpenChange:x,modal:r=!1}=t,u=Me(a),v=f.useRef(null),[p,C]=f.useState(!1),[D,P]=Ms({prop:c,defaultProp:d??!1,onChange:x,caller:Ue});return e.jsx(Cs,{...u,children:e.jsx(ea,{scope:a,contentId:Ps(),triggerRef:v,open:D,onOpenChange:P,onOpenToggle:f.useCallback(()=>P(M=>!M),[P]),hasCustomAnchor:p,onCustomAnchorAdd:f.useCallback(()=>C(!0),[]),onCustomAnchorRemove:f.useCallback(()=>C(!1),[]),modal:r,children:o})})};Tt.displayName=Ue;var It="PopoverAnchor",ta=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=oe(It,o),x=Me(o),{onCustomAnchorAdd:r,onCustomAnchorRemove:u}=d;return f.useEffect(()=>(r(),()=>u()),[r,u]),e.jsx(kt,{...x,...c,ref:a})});ta.displayName=It;var Ut="PopoverTrigger",Ft=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=oe(Ut,o),x=Me(o),r=yt(a,d.triggerRef),u=e.jsx(Nt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":d.open,"aria-controls":d.contentId,"data-state":zt(d.open),...c,ref:r,onClick:Ne(t.onClick,d.onOpenToggle)});return d.hasCustomAnchor?u:e.jsx(kt,{asChild:!0,...x,children:u})});Ft.displayName=Ut;var Ye="PopoverPortal",[sa,aa]=At(Ye,{forceMount:void 0}),_t=t=>{const{__scopePopover:a,forceMount:o,children:c,container:d}=t,x=oe(Ye,a);return e.jsx(sa,{scope:a,forceMount:o,children:e.jsx(wt,{present:o||x.open,children:e.jsx(Rs,{asChild:!0,container:d,children:c})})})};_t.displayName=Ye;var fe="PopoverContent",Lt=f.forwardRef((t,a)=>{const o=aa(fe,t.__scopePopover),{forceMount:c=o.forceMount,...d}=t,x=oe(fe,t.__scopePopover);return e.jsx(wt,{present:c||x.open,children:x.modal?e.jsx(oa,{...d,ref:a}):e.jsx(na,{...d,ref:a})})});Lt.displayName=fe;var ra=Os("PopoverContent.RemoveScroll"),oa=f.forwardRef((t,a)=>{const o=oe(fe,t.__scopePopover),c=f.useRef(null),d=yt(a,c),x=f.useRef(!1);return f.useEffect(()=>{const r=c.current;if(r)return Ss(r)},[]),e.jsx(Ds,{as:ra,allowPinchZoom:!0,children:e.jsx($t,{...t,ref:d,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ne(t.onCloseAutoFocus,r=>{var u;r.preventDefault(),x.current||(u=o.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ne(t.onPointerDownOutside,r=>{const u=r.detail.originalEvent,v=u.button===0&&u.ctrlKey===!0,p=u.button===2||v;x.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:Ne(t.onFocusOutside,r=>r.preventDefault(),{checkForDefaultPrevented:!1})})})}),na=f.forwardRef((t,a)=>{const o=oe(fe,t.__scopePopover),c=f.useRef(!1),d=f.useRef(!1);return e.jsx($t,{...t,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:x=>{var r,u;(r=t.onCloseAutoFocus)==null||r.call(t,x),x.defaultPrevented||(c.current||(u=o.triggerRef.current)==null||u.focus(),x.preventDefault()),c.current=!1,d.current=!1},onInteractOutside:x=>{var v,p;(v=t.onInteractOutside)==null||v.call(t,x),x.defaultPrevented||(c.current=!0,x.detail.originalEvent.type==="pointerdown"&&(d.current=!0));const r=x.target;((p=o.triggerRef.current)==null?void 0:p.contains(r))&&x.preventDefault(),x.detail.originalEvent.type==="focusin"&&d.current&&x.preventDefault()}})}),$t=f.forwardRef((t,a)=>{const{__scopePopover:o,trapFocus:c,onOpenAutoFocus:d,onCloseAutoFocus:x,disableOutsidePointerEvents:r,onEscapeKeyDown:u,onPointerDownOutside:v,onFocusOutside:p,onInteractOutside:C,...D}=t,P=oe(fe,o),M=Me(o);return As(),e.jsx(Ts,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:d,onUnmountAutoFocus:x,children:e.jsx(Is,{asChild:!0,disableOutsidePointerEvents:r,onInteractOutside:C,onEscapeKeyDown:u,onPointerDownOutside:v,onFocusOutside:p,onDismiss:()=>P.onOpenChange(!1),children:e.jsx(Us,{"data-state":zt(P.open),role:"dialog",id:P.contentId,...M,...D,ref:a,style:{...D.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Kt="PopoverClose",la=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=oe(Kt,o);return e.jsx(Nt.button,{type:"button",...c,ref:a,onClick:Ne(t.onClick,()=>d.onOpenChange(!1))})});la.displayName=Kt;var ia="PopoverArrow",da=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=Me(o);return e.jsx(Fs,{...d,...c,ref:a})});da.displayName=ia;function zt(t){return t?"open":"closed"}var ca=Tt,ua=Ft,ma=_t,Bt=Lt;const pa=ca,ha=ua,Vt=f.forwardRef(({className:t,align:a="center",sideOffset:o=4,...c},d)=>e.jsx(ma,{children:e.jsx(Bt,{ref:d,align:a,sideOffset:o,className:ke("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...c})}));Vt.displayName=Bt.displayName;function Ze(){return typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,10)}function xa(){return{_key:Ze(),id:"",label:""}}const Ge={openai:{baseUrl:"https://api.openai.com/v1"},deepseek:{baseUrl:"https://api.deepseek.com/v1"},huawei:{baseUrl:"https://api.modelarts-maas.com/v1"},kimi:{baseUrl:"https://api.moonshot.cn/v1"},anthropic:{baseUrl:"https://api.anthropic.com/v1"},custom:{}};function pt(t){return t?{id:t.id,label:t.label??t.id,baseUrl:t.baseUrl,apiKey:t.apiKey??"",type:t.type??"custom",defaultModel:t.defaultModel??"",models:(t.models??[]).map(a=>({...a,_key:Ze()})),authMode:t.authMode??"apiKey"}:{id:"",label:"",baseUrl:"",apiKey:"",type:"custom",defaultModel:"",models:[],authMode:"apiKey"}}function fa(t){return{_key:Ze(),id:t.id,label:t.label}}function ga({open:t,mode:a,provider:o,existingProviderIds:c,onClose:d,onSubmit:x}){const{t:r}=ge(),[u,v]=f.useState(()=>pt(o)),[p,C]=f.useState({}),[D,P]=f.useState(!1),[M,N]=f.useState(null),j=f.useRef(null),E=f.useRef(null),_=f.useRef(null),[L,Ce]=f.useState(a==="edit");f.useEffect(()=>{t&&(v(pt(o)),C({}),N(null),P(!1),Ce(a==="edit"))},[t,o,a]),f.useEffect(()=>{if(!t)return;const b=y=>{y.key==="Escape"&&d()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t,d]),f.useEffect(()=>{if(t){if(a==="create"&&_.current){_.current.focus();return}E.current&&E.current.focus()}},[t,a]);const Ee=f.useMemo(()=>u.models.filter(b=>b.id.trim().length>0),[u.models]),be=b=>y=>{v(S=>({...S,[b]:y}))},Pe=b=>{v(y=>{const w=!L||y.label.trim().length===0||y.label===y.id?b:y.label;return{...y,id:b,label:w}})},J=b=>{v(y=>{var De;const w=Ge[b??"custom"]??Ge.custom,A=Object.values(Ge).map(se=>se.baseUrl).filter(se=>!!se),H=!y.baseUrl||A.includes(y.baseUrl),K=a==="create"&&(y.models.length===0||y.models.every(se=>se.id.trim().length===0)),X={...y,type:b,authMode:y.authMode??"apiKey"};return w!=null&&w.baseUrl&&H&&(X.baseUrl=w.baseUrl),w!=null&&w.models&&K&&(X.models=w.models.map(fa),X.defaultModel=w.defaultModel??((De=w.models[0])==null?void 0:De.id)??""),X})},$=(b,y)=>{v(S=>{const w=[...S.models];return w[b]={...w[b],...y},{...S,models:w}})},Fe=(b,y)=>{v(S=>{const w=[...S.models],A=w[b];if(!A)return S;const H=!L||!A.label||A.label===A.id,K={...A,id:y,label:H?y:A.label};w[b]=K;const X=S.defaultModel===A.id?y:S.defaultModel;return{...S,models:w,defaultModel:X}})},V=b=>{v(y=>{if(b<0||b>=y.models.length)return y;const S=y.models.filter((A,H)=>H!==b);let w=y.defaultModel;return S.some(A=>A.id===w)||(w=""),{...y,models:S,defaultModel:w}})},_e=()=>{v(b=>({...b,models:[...b.models,xa()]}))},ce=b=>{v(y=>({...y,authMode:b}))},Re=()=>{const b={},y=u.id.trim(),S=u.baseUrl.trim();if(a==="create"&&(y.length===0?b.id=r("providers.drawer.errors.idRequired"):c.includes(y)&&(b.id=r("providers.drawer.errors.idDuplicate"))),a==="edit"&&y.length===0&&(b.id=r("providers.drawer.errors.idRequired")),S.length===0)b.baseUrl=r("providers.drawer.errors.baseUrlInvalid");else try{new URL(S)}catch{b.baseUrl=r("providers.drawer.errors.baseUrlInvalid")}if(u.models.length>0){const w=new Set;u.models.some(H=>{const K=H.id.trim();return K.length===0||w.has(K)?!0:(w.add(K),!1)})&&(b.models=r("providers.drawer.errors.modelInvalid"))}return u.defaultModel&&!u.models.some(w=>w.id===u.defaultModel)&&(b.models=r("providers.drawer.errors.defaultInvalid")),C(b),Object.keys(b).length===0},ve=()=>{const b=u.models.map(w=>{var A;return{id:w.id.trim(),label:(A=w.label)!=null&&A.trim()?w.label.trim():void 0}}).filter(w=>w.id.length>0),y=o!=null&&o.extraHeaders&&Object.keys(o.extraHeaders).length>0?o.extraHeaders:void 0,S=u.authMode!=="apiKey"?u.authMode:void 0;return{id:u.id.trim(),label:u.label.trim()||u.id.trim(),baseUrl:u.baseUrl.trim(),apiKey:u.apiKey.trim()||void 0,type:u.type??"custom",defaultModel:u.defaultModel||void 0,models:b.length>0?b:void 0,extraHeaders:y,authMode:S}},Se=async()=>{if(N(null),!!Re()){P(!0);try{const b=ve();await x(b)}catch(b){N(r("providers.drawer.toast.saveFailure",{message:b instanceof Error?b.message:"unknown"})),P(!1);return}P(!1),d()}},je=a==="create";return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-slate-900/60",onClick:d,"aria-hidden":"true"}),e.jsxs("aside",{ref:j,role:"dialog","aria-modal":"true","aria-labelledby":"provider-drawer-title","aria-describedby":"provider-drawer-desc",className:"flex h-full w-full max-w-3xl flex-col border-l border-slate-200 bg-white shadow-xl dark:border-slate-800 dark:bg-slate-900",children:[e.jsxs("header",{className:"flex items-center justify-between border-b border-slate-200 px-6 py-4 dark:border-slate-800",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"provider-drawer-title",className:"text-lg font-semibold",children:r(je?"providers.drawer.createTitle":"providers.drawer.editTitle")}),e.jsx("p",{id:"provider-drawer-desc",className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.description")})]}),e.jsx("button",{type:"button",ref:E,onClick:d,className:"rounded-md border border-slate-200 px-3 py-1 text-sm transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:r("common.actions.close")})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:[e.jsxs("section",{className:"space-y-4","aria-labelledby":"provider-basic-fields",children:[e.jsx("div",{id:"provider-basic-fields",className:"sr-only",children:r("providers.drawer.description")}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx("button",{type:"button",onClick:()=>Ce(b=>!b),className:"rounded-md border border-slate-200 px-3 py-1 text-xs transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:r(L?"providers.drawer.fields.hideAdvanced":"providers.drawer.fields.showAdvanced")})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.id")}),e.jsx("input",{value:u.id,ref:_,onChange:b=>Pe(b.target.value),disabled:!je,placeholder:r("providers.drawer.fields.idPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60","aria-invalid":!!p.id}),p.id?e.jsx("span",{className:"text-xs text-red-500",children:p.id}):null]}),L?e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.label")}),e.jsx("input",{value:u.label,onChange:b=>be("label")(b.target.value),placeholder:r("providers.drawer.fields.labelPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}):null]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.baseUrl")}),e.jsx("input",{value:u.baseUrl,onChange:b=>be("baseUrl")(b.target.value),placeholder:r("providers.drawer.fields.baseUrlPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60","aria-invalid":!!p.baseUrl}),p.baseUrl?e.jsx("span",{className:"text-xs text-red-500",children:p.baseUrl}):null]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.type")}),e.jsxs("select",{value:u.type??"custom",onChange:b=>J(b.target.value),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60",children:[e.jsx("option",{value:"openai",children:"OpenAI"}),e.jsx("option",{value:"deepseek",children:"DeepSeek"}),e.jsx("option",{value:"huawei",children:"华为云"}),e.jsx("option",{value:"kimi",children:"Kimi"}),e.jsx("option",{value:"anthropic",children:"Anthropic (Claude)"}),e.jsx("option",{value:"custom",children:"Custom"})]})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.apiKey")}),e.jsx("input",{value:u.apiKey,onChange:b=>be("apiKey")(b.target.value),placeholder:r("providers.drawer.fields.apiKeyPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}),e.jsxs("fieldset",{className:"grid gap-2 rounded-lg border border-slate-200 p-3 text-xs dark:border-slate-700",children:[e.jsx("legend",{className:"px-1 text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.authMode")}),e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.authModeHint")}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"apiKey",checked:u.authMode==="apiKey",onChange:()=>ce("apiKey")}),e.jsx("span",{children:r("providers.drawer.fields.authModeApiKey")})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"authToken",checked:u.authMode==="authToken",onChange:()=>ce("authToken")}),e.jsx("span",{children:r("providers.drawer.fields.authModeAuthToken")})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"xAuthToken",checked:u.authMode==="xAuthToken",onChange:()=>ce("xAuthToken")}),e.jsx("span",{children:r("providers.drawer.fields.authModeXAuthToken")})]})]})]}),e.jsxs("section",{className:"mt-6 space-y-3","aria-labelledby":"provider-model-fields",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"provider-model-fields",className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.models")}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.modelsDescription")})]}),e.jsx("button",{type:"button",onClick:_e,className:"rounded-md border border-slate-200 px-3 py-1 text-xs transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:r("providers.drawer.fields.addModel")})]}),p.models?e.jsx("p",{className:"text-xs text-red-500",children:p.models}):null,e.jsxs("div",{className:"space-y-4",children:[u.models.map((b,y)=>e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-800/40",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.modelId")}),e.jsx("input",{value:b.id,onChange:S=>Fe(y,S.target.value),placeholder:r("providers.drawer.fields.modelIdPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}),L?e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.modelLabel")}),e.jsx("input",{value:b.label??"",onChange:S=>$(y,{label:S.target.value}),placeholder:r("providers.drawer.fields.modelLabelPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}):null]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2 text-slate-600 dark:text-slate-300",children:[e.jsx("input",{type:"radio",name:"defaultModel",value:b.id,checked:u.defaultModel===b.id,onChange:()=>v(S=>({...S,defaultModel:b.id})),disabled:b.id.trim().length===0}),r("providers.drawer.fields.setDefault")]}),e.jsx("button",{type:"button",className:"text-red-500 transition hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>V(y),disabled:u.models.length===0,children:r("providers.drawer.fields.removeModel")})]})]},b._key)),u.models.length===0?e.jsx("div",{className:"rounded-xl border-2 border-amber-300 bg-gradient-to-br from-amber-50 to-yellow-50 p-5 shadow-md dark:border-amber-600/60 dark:from-amber-900/20 dark:to-yellow-900/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 text-2xl",children:"💡"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:r("providers.drawer.noModelsTitle")}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-800 dark:text-amber-300",children:r("providers.drawer.noModelsHint",{providerId:u.id||"provider-id"})}),e.jsxs("div",{className:"rounded-md bg-amber-100/80 p-2.5 dark:bg-amber-800/40",children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-amber-900 dark:text-amber-200",children:r("providers.drawer.routeExample")}),e.jsxs("code",{className:"block rounded bg-white px-2.5 py-1.5 font-mono text-xs text-amber-900 shadow-sm dark:bg-slate-900 dark:text-amber-100",children:['"claude-*": "',(u.id||"provider-id").trim()||"provider-id",':*"']})]})]})]})}):null]}),Ee.length>1?e.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.defaultHint",{model:u.defaultModel||r("providers.card.noDefault")})}):null]})]}),e.jsxs("footer",{className:"flex items-center justify-between gap-3 border-t border-slate-200 px-6 py-4 text-sm dark:border-slate-800",children:[e.jsx("div",{className:"flex flex-col text-xs text-red-500","aria-live":"polite",children:M?e.jsx("span",{children:M}):null}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:d,className:"rounded-md border border-slate-200 px-4 py-2 transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",disabled:D,children:r("common.actions.cancel")}),e.jsx("button",{type:"button",onClick:Se,className:"rounded-md bg-blue-600 px-4 py-2 text-white transition hover:bg-blue-700 disabled:opacity-60",disabled:D,children:r(D?"common.actions.saving":"common.actions.save")})]})]})]})]}):null}const ba=["claude-sonnet-4-5-20250929","claude-sonnet-4-5-20250929-thinking","claude-sonnet-4-20250514","claude-opus-4-1-20250805","claude-opus-4-1-20250805-thinking","claude-haiku-4-5-20251001","claude-haiku-4-5-20251001-thinking","claude-3-5-haiku-20241022"],va=["gpt-4o-mini","gpt-4o","o4-mini","o4-large","gpt-5-codex"];function We(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2,10)}function Y(t){return t?Object.entries(t).map(([a,o])=>({id:We(),source:a,target:o})):[]}function Qe(t,a){var d,x,r;if(!t)return{};const o={},c=t.endpointRouting??{};o.anthropic=Y(((d=c.anthropic)==null?void 0:d.modelRoutes)??t.modelRoutes??{}),o.openai=Y(((x=c.openai)==null?void 0:x.modelRoutes)??{});for(const u of a)(r=u.routing)!=null&&r.modelRoutes?o[u.id]=Y(u.routing.modelRoutes):o[u.id]=[];return o}function ht(t,a,o){var x,r,u;const c=a.find(v=>v.id===o);if(c)return((x=c.routing)==null?void 0:x.modelRoutes)??{};const d=t.endpointRouting??{};return o==="anthropic"?((r=d.anthropic)==null?void 0:r.modelRoutes)??t.modelRoutes??{}:o==="openai"?((u=d.openai)==null?void 0:u.modelRoutes)??{}:{}}function ja(t){const a={};for(const o of t){const c=o.source.trim(),d=o.target.trim();c&&d&&(a[c]=d)}return a}function xt(t,a){return JSON.stringify(ja(t))!==JSON.stringify(a)}function ya(t,a){if(t==="anthropic")return!0;const o=a.find(c=>c.id===t);return o?o.paths&&o.paths.length>0?o.paths.some(c=>c.protocol==="anthropic"):o.protocol==="anthropic":!1}function Na(t,a,o){var d,x,r;if(!a)return;if(t==="anthropic"||t==="openai")return(x=(d=a.endpointRouting)==null?void 0:d[t])==null?void 0:x.validation;const c=o.find(u=>u.id===t);return(r=c==null?void 0:c.routing)==null?void 0:r.validation}function La(){const{t}=ge(),{pushToast:a}=Mt(),o=vt(),c=Vs(["config","full"],{url:"/api/config",method:"GET"}),{data:d}=qs({queryKey:["custom-endpoints"],queryFn:we.list,refetchInterval:1e4}),x=(d==null?void 0:d.endpoints)??[],r=f.useMemo(()=>{const s=[{key:"providers",label:t("modelManagement.tabs.providers"),description:t("modelManagement.tabs.providersDesc"),isSystem:!0,canDelete:!1},{key:"anthropic",label:t("modelManagement.tabs.anthropic"),description:t("modelManagement.tabs.anthropicDesc"),isSystem:!0,canDelete:!1,protocols:["anthropic"]},{key:"openai",label:t("modelManagement.tabs.openai"),description:t("modelManagement.tabs.openaiDesc"),isSystem:!0,canDelete:!1,protocols:["openai-auto","openai-chat","openai-responses"]}],l=x.map(n=>{let i,m=[];if(n.paths&&n.paths.length>0){const h=n.paths.map(g=>`${g.path} (${g.protocol})`).join(", ");i=`${t("modelManagement.tabs.customEndpoint")}: ${h}`,m=[...new Set(n.paths.map(g=>g.protocol))]}else if(n.path){const h=n.protocol||"anthropic";i=`${t("modelManagement.tabs.customEndpoint")}: ${n.path} (${h})`,m=[h]}else i=t("modelManagement.tabs.customEndpoint");return{key:n.id,label:n.label,description:i,isSystem:!1,canDelete:n.deletable!==!1,protocols:m}});return[...s,...l]},[t,x]),[u,v]=f.useState("providers"),[p,C]=f.useState(null),[D,P]=f.useState(!1),[M,N]=f.useState("create"),[j,E]=f.useState(void 0),[_,L]=f.useState(null),[Ce,Ee]=f.useState(!1),[be,Pe]=f.useState(void 0),[J,$]=f.useState({}),[Fe,V]=f.useState({}),[_e,ce]=f.useState(null),[Re,ve]=f.useState({}),[Se,je]=f.useState({}),[b,y]=f.useState({}),[S,w]=f.useState(null),[A,H]=f.useState(null),[K,X]=f.useState(null),[De,se]=f.useState(!1),[Le,et]=f.useState(null),[Oe,$e]=f.useState(!0),[tt,st]=f.useState({}),[qt,at]=f.useState(!1),[Ht,Gt]=f.useState({}),[Ke,ze]=f.useState(null),q=(p==null?void 0:p.providers)??[],Qt=q.length,ye=f.useMemo(()=>[{key:"anthropic-beta",value:"claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",label:t("providers.testDialog.options.beta.label"),description:t("providers.testDialog.options.beta.description")}],[t]);f.useEffect(()=>{var s,l;if(c.data){const n=c.data;C(n),$(m=>{const h=Qe(n,x);if(!m||Object.keys(m).length===0)return h;const g={...h};for(const[k,R]of Object.entries(m)){if(!(k in h))continue;const F=ht(n,x,k);xt(R,F)&&(g[k]=R)}return g}),V({});const i={anthropic:((s=n.routingPresets)==null?void 0:s.anthropic)??[],openai:((l=n.routingPresets)==null?void 0:l.openai)??[]};for(const m of x)i[m.id]=m.routingPresets??[];ve(i)}},[c.data,x]),f.useEffect(()=>{c.isError&&c.error&&a({title:t("providers.toast.loadFailure",{message:c.error.message}),variant:"error"})},[c.isError,c.error,a,t]);const Jt=f.useMemo(()=>{const s=new Map;for(const l of q){if(!l.defaultModel||!l.models)continue;const n=l.models.find(i=>i.id===l.defaultModel);n&&s.set(l.id,ft(n))}return s},[q]),Xt=f.useMemo(()=>{const s=[],l=new Set;for(const i of q){const m=i.label&&i.label!==i.id?`${i.label} (${i.id})`:i.id,h=i.models??[];if(h.length>0)for(const k of h){const R=`${i.id}:${k.id}`;l.has(R)||(l.add(R),s.push({value:R,label:`${m} · ${k.label??k.id}`}))}else if(i.defaultModel){const k=`${i.id}:${i.defaultModel}`;l.has(k)||(l.add(k),s.push({value:k,label:`${m} · ${i.defaultModel}`}))}const g=`${i.id}:*`;l.has(g)||(l.add(g),s.push({value:g,label:t("settings.routing.providerPassthroughOption",{provider:m})}))}const n=Object.values(J).flat();for(const i of n){const m=i.target.trim();m&&!l.has(m)&&(l.add(m),s.push({value:m,label:m}))}return s},[q,J,t]),Wt=s=>p?ht(p,x,s):{},Yt=(s,l)=>xt(s,l),rt=f.useMemo(()=>{const s={};for(const l of r){if(l.key==="providers")continue;const n=J[l.key]||[],i=Wt(l.key);s[l.key]=Yt(n,i)}return s},[J,p,x,r]),ot=(s,l)=>{ve(n=>({...n,[s]:l})),C(n=>{if(!n)return n;if(s==="anthropic"||s==="openai")return{...n,routingPresets:{...n.routingPresets,[s]:l}};const i=n.customEndpoints??[],m=i.findIndex(g=>g.id===s);if(m===-1)return n;const h=[...i];return h[m]={...h[m],routingPresets:l},{...n,customEndpoints:h}})},ae=()=>p?!0:(a({title:t("settings.toast.missingConfig"),variant:"error"}),c.refetch(),!1),Zt=(s,l)=>{je(n=>({...n,[s]:l})),l.trim()&&y(n=>({...n,[s]:null}))},es=async s=>{if(!ae())return;const l=Se[s].trim();if(!l){y(n=>({...n,[s]:t("modelManagement.validation.presetName")}));return}if(Re[s].some(n=>n.name.toLowerCase()===l.toLowerCase())){y(n=>({...n,[s]:t("modelManagement.validation.presetDuplicate",{name:l})}));return}w(s);try{const i=(await W.post(`/api/routing-presets/${s}`,{name:l})).data.presets??[];ot(s,i),je(m=>({...m,[s]:""})),y(m=>({...m,[s]:null})),a({title:t("modelManagement.toast.presetSaved",{name:l}),variant:"success"})}catch(n){a({title:t("modelManagement.toast.presetSaveFailure",{message:n instanceof Error?n.message:"unknown"}),variant:"error"})}finally{w(null),c.refetch()}},ts=async(s,l)=>{var n,i,m;if(ae()){H({endpoint:s,name:l.name});try{const g=(await W.post(`/api/routing-presets/${s}/apply`,{name:l.name})).data.config;if(g){C(g),$(Qe(g,x));const k={anthropic:((n=g.routingPresets)==null?void 0:n.anthropic)??[],openai:((i=g.routingPresets)==null?void 0:i.openai)??[]};for(const R of x){const F=(m=g.customEndpoints)==null?void 0:m.find(U=>U.id===R.id);k[R.id]=(F==null?void 0:F.routingPresets)??[]}ve(k)}else $(k=>({...k,[s]:Y(l.modelRoutes)}));a({title:t("modelManagement.toast.presetApplySuccess",{name:l.name}),variant:"success"})}catch(h){a({title:t("modelManagement.toast.presetApplyFailure",{message:h instanceof Error?h.message:"unknown"}),variant:"error"})}finally{H(null),c.refetch()}}},ss=async(s,l)=>{if(!(!ae()||!window.confirm(t("modelManagement.confirm.deletePreset",{name:l.name})))){X({endpoint:s,name:l.name});try{const m=(await W.delete(`/api/routing-presets/${s}/${encodeURIComponent(l.name)}`)).data.presets??[];ot(s,m),a({title:t("modelManagement.toast.presetDeleteSuccess",{name:l.name}),variant:"success"})}catch(i){a({title:t("modelManagement.toast.presetDeleteFailure",{message:i instanceof Error?i.message:"unknown"}),variant:"error"})}finally{X(null),c.refetch()}}},as=()=>{ae()&&(N("create"),E(void 0),P(!0))},rs=s=>{ae()&&(N("edit"),E(s),P(!0))},os=async s=>{if(!p)throw new Error(t("settings.toast.missingConfig"));const l=M==="create"?[...q,s]:q.map(m=>j&&m.id===j.id?{...s,id:j.id}:m),n={...p,providers:l};await W.put("/api/config",n),C(n),$(Qe(n,x)),c.refetch();const i=M==="create"?t("providers.toast.createSuccess",{name:s.label||s.id}):t("providers.toast.updateSuccess",{name:s.label||s.id});a({title:i,variant:"success"})},ns=async s=>{const l=x.find(n=>n.id===s);if(l&&l.deletable!==!1&&confirm(t("modelManagement.deleteEndpointConfirm",{label:l.label})))try{await we.delete(s),o.invalidateQueries({queryKey:["custom-endpoints"]}),a({title:t("modelManagement.deleteEndpointSuccess"),variant:"success"}),u===s&&v("providers")}catch(n){const i=Ie(n);a({title:t("modelManagement.deleteEndpointError",{error:i.message}),variant:"error"})}},nt=async(s,l)=>{L(s.id);try{const n=l&&(l.headers||l.query)?{headers:l.headers&&Object.keys(l.headers).length>0?l.headers:void 0,query:l.query&&l.query.trim().length>0?l.query.trim():void 0}:void 0,i=await W.post(`/api/providers/${s.id}/test`,n);i.data.ok?a({title:t("providers.toast.testSuccess"),description:t("providers.toast.testSuccessDesc",{status:i.data.status,duration:i.data.durationMs?`${i.data.durationMs} ms`:"—"}),variant:"success"}):a({title:t("providers.toast.testFailure",{message:`${i.data.status} ${i.data.statusText}`}),variant:"error"})}catch(n){a({title:t("providers.toast.testFailure",{message:n instanceof Error?n.message:"unknown"}),variant:"error"})}finally{L(null)}},ls=s=>{if(s.type==="anthropic"){const l=s.extraHeaders??{},n=new Map(ye.map(h=>[h.key.toLowerCase(),h])),i={};let m=!0;for(const h of ye){const g=Object.entries(l).find(([k])=>k.toLowerCase()===h.key.toLowerCase());if(g){const[k,R]=g;String(R??"")===h.value||(m=!1,i[k]=String(R??""))}}for(const[h,g]of Object.entries(l))n.has(h.toLowerCase())||(i[h]=String(g??""));st(i),$e(m),et(s),se(!0);return}nt(s)},lt=()=>{se(!1),et(null),$e(!0),st({})},is=async()=>{if(!Le)return;const s={};if(Oe)for(const i of ye)s[i.key]=i.value;const l=new Map(ye.map(i=>[i.key.toLowerCase(),i]));for(const[i,m]of Object.entries(tt)){const h=i.toLowerCase();l.get(h)&&Oe||(s[i]=m)}const n=Le;lt(),await nt(n,{headers:Object.keys(s).length>0?s:void 0,query:Oe?"beta=true":void 0})},ds=async s=>{var R,F,U,G;if(!ae()||!window.confirm(t("providers.confirm.delete",{name:s.label||s.id})))return;const n=q.filter(B=>B.id!==s.id),i=B=>{const ne={};if(!B)return ne;for(const[Be,le]of Object.entries(B)){if(!le)continue;const[T]=le.split(":");T&&T===s.id||le===s.id||(ne[Be]=le)}return ne},m=(p==null?void 0:p.endpointRouting)??{},h=i(((R=m.anthropic)==null?void 0:R.modelRoutes)??(p==null?void 0:p.modelRoutes)??{}),g=i(((F=m.openai)==null?void 0:F.modelRoutes)??{}),k={...p,providers:n,modelRoutes:h,endpointRouting:{anthropic:{defaults:((U=m.anthropic)==null?void 0:U.defaults)??p.defaults,modelRoutes:h},openai:{defaults:((G=m.openai)==null?void 0:G.defaults)??p.defaults,modelRoutes:g}}};try{await W.put("/api/config",k),C(k),$({anthropic:Y(h),openai:Y(g)}),a({title:t("providers.toast.deleteSuccess",{name:s.label||s.id}),variant:"success"}),c.refetch()}catch(B){a({title:t("providers.toast.deleteFailure",{message:B instanceof Error?B.message:"unknown"}),variant:"error"})}},cs=s=>{$(l=>({...l,[s]:[...l[s]||[],{id:We(),source:"",target:""}]})),V(l=>({...l,[s]:null}))},us=async(s,l)=>{if(ae()){at(!0);try{if(s==="anthropic"||s==="openai"){const n=p.endpointRouting?{...p.endpointRouting}:{},i=n[s]??{defaults:p.defaults,modelRoutes:(s==="anthropic"?p.modelRoutes:{})??{}},m={defaults:i.defaults??p.defaults,modelRoutes:i.modelRoutes??{}};let h=i.validation;l?(h={...h??{},mode:"claude-code"},h.allowExperimentalBlocks===void 0&&(h.allowExperimentalBlocks=!0)):h=void 0;const g=h?{...m,validation:h}:{...m},k={...n,[s]:g},R={...p,endpointRouting:k};await W.put("/api/config",R),C(R)}else{const n=p.customEndpoints??[],i=n.findIndex(G=>G.id===s);if(i===-1)throw new Error(t("modelManagement.toast.endpointNotFound"));const m=n[i],h=m.routing??{defaults:p.defaults,modelRoutes:{}};let g=h.validation;l?(g={...g??{},mode:"claude-code"},g.allowExperimentalBlocks===void 0&&(g.allowExperimentalBlocks=!0)):g=void 0;const k=g?{...h,validation:g}:{...h},R={...m,routing:k},F=[...n];F[i]=R;const U={...p,customEndpoints:F};await W.put("/api/config",U),C(U)}a({title:t(l?"modelManagement.toast.claudeValidationEnabled":"modelManagement.toast.claudeValidationDisabled"),variant:"success"}),c.refetch()}catch(n){const i=Ie(n);a({title:t("modelManagement.toast.claudeValidationFailure",{message:i.message}),variant:"error"})}finally{at(!1)}}},ms=(s,l)=>{$(n=>{const i=n[s]||[];return i.some(m=>m.source.trim()===l.trim())?n:{...n,[s]:[...i,{id:We(),source:l,target:""}]}}),V(n=>({...n,[s]:null}))},it=(s,l,n,i)=>{$(m=>({...m,[s]:(m[s]||[]).map(h=>h.id===l?{...h,[n]:i}:h)})),V(m=>({...m,[s]:null}))},ps=(s,l)=>{$(n=>({...n,[s]:(n[s]||[]).filter(i=>i.id!==l)})),V(n=>({...n,[s]:null}))},hs=s=>{var n,i;if(!p)return;const l=x.find(m=>m.id===s);if(l){const m=((n=l.routing)==null?void 0:n.modelRoutes)??{};$(h=>({...h,[s]:Y(m)}))}else{const m=p.endpointRouting??{},h=s,g=h==="anthropic"?p.modelRoutes??{}:{},k=((i=m[h])==null?void 0:i.modelRoutes)??g;$(R=>({...R,[s]:Y(k)}))}V(m=>({...m,[s]:null}))},xs=async s=>{var i;if(!ae())return;const l=J[s]||[],n={};for(const m of l){const h=m.source.trim(),g=m.target.trim();if(!(!h&&!g)){if(!h||!g){V(k=>({...k,[s]:t("settings.validation.routePair")}));return}if(n[h]){V(k=>({...k,[s]:t("settings.validation.routeDuplicate",{model:h})}));return}n[h]=g}}V(m=>({...m,[s]:null})),ce(s);try{const m=x.find(h=>h.id===s);if(m){const h={...m.routing||{},modelRoutes:n,defaults:((i=m.routing)==null?void 0:i.defaults)||p.defaults};await we.update(s,{routing:h}),o.invalidateQueries({queryKey:["custom-endpoints"]}),a({title:t("modelManagement.toast.routesSaved"),variant:"success"})}else{const h=p.endpointRouting?{...p.endpointRouting}:{},g=s,k=h[g]??{defaults:p.defaults,modelRoutes:g==="anthropic"?p.modelRoutes??{}:{}},R={...k,defaults:k.defaults??p.defaults,modelRoutes:n},F={...h,[g]:R},U={...p,endpointRouting:F,modelRoutes:g==="anthropic"?n:p.modelRoutes??{}};await W.put("/api/config",U),C(U),a({title:t("modelManagement.toast.routesSaved"),variant:"success"}),c.refetch()}$(h=>({...h,[s]:Y(n)}))}catch(m){a({title:t("modelManagement.toast.routesSaveFailure",{message:m instanceof Error?m.message:"unknown"}),variant:"error"})}finally{ce(null)}},fs=()=>e.jsx(qe,{children:e.jsxs(He,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:t("providers.title")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t("providers.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(Q,{variant:"secondary",children:t("providers.count",{count:Qt})}),e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>c.refetch(),disabled:c.isFetching,children:[e.jsx(Ys,{className:ke("mr-2 h-4 w-4",c.isFetching&&"animate-spin")}),c.isFetching?t("common.actions.refreshing"):t("providers.actions.refresh")]}),e.jsxs(I,{size:"sm",onClick:as,children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),t("providers.actions.add")]})]})]}),c.isPending||!p&&c.isFetching?e.jsx("div",{className:"flex min-h-[200px] items-center justify-center rounded-lg border bg-muted/50 text-sm text-muted-foreground",children:t("common.loading")}):q.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:t("providers.emptyState")}),e.jsx("p",{className:"mt-2 text-xs",children:t("providers.emptyStateSub",{default:"点击上方按钮添加您的第一个提供商"})})]}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:q.map(s=>e.jsx(qe,{className:"flex flex-col",children:e.jsxs(He,{className:"flex flex-1 flex-col gap-4 pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:s.label||s.id}),s.type&&e.jsx(Ca,{type:s.type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["ID: ",s.id]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",children:s.baseUrl})]}),s.defaultModel?e.jsx(Q,{variant:"default",className:"text-xs",children:Jt.get(s.id)??s.defaultModel}):e.jsx(Q,{variant:"secondary",className:"text-xs",children:t("providers.card.noDefault")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-xs",children:t("providers.card.modelsTitle")}),s.models&&s.models.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:s.models.map(l=>e.jsx(Q,{variant:"outline",className:"text-xs",children:ft(l)},l.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:t("providers.card.noModels")})]}),e.jsxs("div",{className:"mt-auto flex flex-wrap gap-2 pt-4 border-t",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:()=>rs(s),children:t("providers.actions.edit")}),e.jsx(I,{variant:"outline",size:"sm",onClick:()=>ls(s),disabled:_===s.id,children:_===s.id?t("common.actions.testingConnection"):t("providers.actions.test")}),e.jsx(I,{variant:"destructive",size:"sm",onClick:()=>ds(s),children:t("providers.actions.delete")})]})]})},s.id))})]})}),gs=s=>{const l=Re[s]??[],n=Se[s]??"",i=b[s],m=S===s,h=Ht[s]===!0;return e.jsxs("div",{className:"rounded-lg border border-dashed bg-muted/30",children:[e.jsx("button",{type:"button",className:"flex w-full items-center justify-between gap-3 p-4 text-left hover:bg-muted/50 transition-colors",onClick:()=>Gt(g=>({...g,[s]:!h})),children:e.jsxs("div",{className:"flex items-center gap-2",children:[h?e.jsx(Ws,{className:"h-4 w-4"}):e.jsx(Ls,{className:"h-4 w-4"}),e.jsx("h3",{className:"font-medium",children:t("modelManagement.presets.title")}),e.jsx(Q,{variant:"secondary",className:"text-xs",children:l.length})]})}),h&&e.jsxs("div",{className:"border-t px-4 pb-4 pt-3 space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("modelManagement.presets.description")}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center",children:[e.jsx(xe,{value:n,onChange:g=>Zt(s,g.target.value),placeholder:t("modelManagement.presets.namePlaceholder"),disabled:m,className:"w-full md:w-48"}),e.jsx(I,{onClick:()=>void es(s),disabled:m,children:t(m?"modelManagement.presets.saving":"modelManagement.presets.save")})]}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:t("modelManagement.presets.empty")}):e.jsx($s,{children:e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(g=>{const k=(A==null?void 0:A.endpoint)===s&&(A==null?void 0:A.name)===g.name,R=(K==null?void 0:K.endpoint)===s&&(K==null?void 0:K.name)===g.name,F=Object.entries(g.modelRoutes??{}),U=F.length;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-card px-4 py-3",children:[e.jsxs(Ks,{children:[e.jsx(zs,{asChild:!0,children:e.jsxs("div",{className:"min-w-0 flex-1 cursor-default",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:g.name}),e.jsx(Q,{variant:"outline",className:"mt-1 text-xs",children:U>0?t("modelManagement.presets.rulesCount",{count:U}):t("modelManagement.presets.noRules")})]})}),U>0&&e.jsx(Bs,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[F.slice(0,5).map(([G,B])=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"truncate",children:G}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:B})]},G)),U>5&&e.jsxs("div",{className:"text-muted-foreground",children:["…+",U-5]})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(I,{size:"sm",onClick:()=>ze({endpoint:s,preset:g}),disabled:k||R,children:t(k?"modelManagement.presets.applying":"modelManagement.presets.apply")}),e.jsx(I,{variant:"destructive",size:"sm",onClick:()=>void ss(s,g),disabled:R||k,children:t(R?"modelManagement.presets.deleting":"modelManagement.presets.delete")})]})]},g.name)})})})]})]})},bs=s=>{var le;const l=J[s]||[],n=Fe[s],i=r.find(T=>T.key===s),h=((le=i==null?void 0:i.protocols)==null?void 0:le.includes("anthropic"))??s==="anthropic"?ba:va,g=_e===s,k=rt[s]??!1,R=(i==null?void 0:i.label)??t(`modelManagement.tabs.${s}`),F=(i==null?void 0:i.isSystem)===!1?i.description:t(`settings.routing.descriptionByEndpoint.${s}`),U=`route-source-${s}`,G=ya(s,x),B=Na(s,p,x),ne=G&&(B==null?void 0:B.mode)==="claude-code",Be=new Set(l.map(T=>T.source.trim()).filter(Boolean));return e.jsx(qe,{children:e.jsxs(He,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-semibold",children:t("settings.routing.titleByEndpoint",{endpoint:R})}),e.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:F}),e.jsx("p",{className:"max-w-3xl text-xs text-muted-foreground",children:t("settings.routing.wildcardHint")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:()=>cs(s),disabled:g,children:t("settings.routing.add")}),e.jsx(I,{variant:"outline",size:"sm",onClick:()=>hs(s),disabled:g,children:t("common.actions.reset")}),e.jsxs(I,{size:"sm",onClick:()=>void xs(s),disabled:g,className:"relative",children:[t(g?"common.actions.saving":"modelManagement.actions.saveRoutes"),k&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-amber-500"})]})]})]}),G&&e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:t("modelManagement.claudeValidation.title")}),e.jsx("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:t("modelManagement.claudeValidation.description")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ct,{checked:ne,onCheckedChange:T=>void us(s,T),disabled:qt}),e.jsx("span",{className:ke("text-xs font-medium",ne?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:t(ne?"modelManagement.claudeValidation.statusEnabled":"modelManagement.claudeValidation.statusDisabled")})]})]})}),gs(s),n&&e.jsx("p",{className:"text-sm text-destructive",children:n}),l.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:t("settings.routing.empty")}),e.jsx("p",{className:"mt-2 text-xs",children:t("settings.routing.emptySub",{default:"点击上方按钮添加路由规则"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] items-center gap-3 px-1 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{children:t("settings.routing.source")}),e.jsx("span",{}),e.jsx("span",{children:t("settings.routing.target")}),e.jsx("span",{})]}),l.map(T=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] items-center gap-3",children:[e.jsx(xe,{value:T.source,onChange:ie=>it(s,T.id,"source",ie.target.value),placeholder:t("settings.routing.sourcePlaceholder"),list:U,disabled:g}),e.jsx(he,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(wa,{value:T.target,onChange:ie=>it(s,T.id,"target",ie),options:Xt,disabled:g,placeholder:t("settings.routing.targetPlaceholder")}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>ps(s,T.id),disabled:g,children:e.jsx(Te,{className:"h-4 w-4"})})]},T.id))]}),e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-3",children:[e.jsx(de,{children:t("settings.routing.suggested")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(T=>{const ie=Be.has(T);return e.jsx(I,{variant:ie?"ghost":"outline",size:"sm",onClick:()=>ms(s,T),disabled:g||ie,className:ie?"opacity-50":"",children:T},`${s}-${T}`)})})]}),e.jsx("datalist",{id:U,children:h.map(T=>e.jsx("option",{value:T},`${U}-${T}`))})]})})};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Hs,{icon:e.jsx(_s,{className:"h-5 w-5","aria-hidden":"true"}),title:t("modelManagement.title"),description:t("modelManagement.description"),actions:e.jsxs(I,{onClick:()=>{Pe(void 0),Ee(!0)},children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),t("modelManagement.addEndpoint")]})}),e.jsx("div",{className:"flex flex-wrap gap-3",children:r.map(s=>{const l=u===s.key,n=s.key!=="providers"&&rt[s.key];return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>v(s.key),className:ke("flex min-w-[200px] flex-col gap-1 rounded-lg border px-4 py-3 text-left transition-all",l?"border-primary bg-primary/5 text-primary":"border-border bg-card hover:bg-accent"),children:[e.jsxs("span",{className:"font-medium flex items-center gap-2",children:[s.label,n&&e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.description})]}),s.canDelete&&e.jsx("button",{onClick:i=>{i.stopPropagation(),ns(s.key)},className:"absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground text-xs hover:bg-destructive/90",title:t("common.delete"),children:e.jsx(Te,{className:"h-3 w-3"})})]},s.key)})}),u==="providers"?fs():bs(u),e.jsx(ga,{open:D,mode:M,provider:M==="edit"?j:void 0,existingProviderIds:q.map(s=>s.id).filter(s=>M==="edit"&&j?s!==j.id:!0),onClose:()=>{P(!1),E(void 0),N("create")},onSubmit:os}),e.jsx(Ea,{open:Ce,endpoint:be,onClose:()=>{Ee(!1),Pe(void 0)},onSuccess:()=>{o.invalidateQueries({queryKey:["custom-endpoints"]})}}),e.jsx(ka,{open:De,provider:Le,options:ye,preservedExtras:tt,usePreset:Oe,onPresetChange:$e,onConfirm:is,onClose:lt}),e.jsx(Ma,{dialog:Ke,currentRoutes:Ke?J[Ke.endpoint]||[]:[],onConfirm:(s,l)=>{ze(null),ts(s,l)},onClose:()=>ze(null)})]})}function ka({open:t,provider:a,options:o,usePreset:c,preservedExtras:d,onPresetChange:x,onConfirm:r,onClose:u}){const{t:v}=ge();return a?e.jsx(Et,{open:t,onOpenChange:p=>!p&&u(),children:e.jsxs(Pt,{children:[e.jsxs(Rt,{children:[e.jsx(St,{children:v("providers.testDialog.title")}),e.jsx(Dt,{children:v("providers.testDialog.subtitle",{name:a.label||a.id})})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v("providers.testDialog.description")}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-4",children:[e.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border",checked:c,onChange:p=>x(p.target.checked)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:v("providers.testDialog.presetLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v("providers.testDialog.presetDescription")}),e.jsxs("details",{className:"rounded-md bg-muted p-2 text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-primary hover:underline",children:v("providers.testDialog.presetPreviewSummary")}),e.jsx("div",{className:"mt-2 space-y-1",children:o.map(p=>e.jsxs("code",{className:"block rounded bg-background px-2 py-1 text-xs",children:[p.key,": ",p.value]},p.key))})]})]})]}),Object.keys(d).length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted p-4 text-xs space-y-2",children:[e.jsx("p",{className:"font-medium",children:v("providers.testDialog.preservedInfo")}),Object.entries(d).map(([p,C])=>e.jsxs("code",{className:"block rounded bg-background px-2 py-1",children:[p,": ",C]},p))]}),e.jsxs(Ot,{children:[e.jsx(I,{variant:"outline",onClick:u,children:v("providers.testDialog.cancel")}),e.jsx(I,{onClick:()=>void r(),children:v("providers.testDialog.primary")})]})]})}):null}function wa({value:t,onChange:a,options:o,disabled:c,placeholder:d}){const{t:x}=ge(),[r,u]=f.useState(!1),[v,p]=f.useState(""),C=f.useRef(null),D=f.useMemo(()=>{if(!v.trim())return o;const M=v.toLowerCase();return o.filter(N=>N.label.toLowerCase().includes(M)||N.value.toLowerCase().includes(M))},[o,v]),P=M=>{a(M),p(""),u(!1)};return e.jsxs(pa,{open:r,onOpenChange:M=>{u(M),M&&p("")},children:[e.jsx(ha,{asChild:!0,children:e.jsx(xe,{ref:C,value:t,onChange:M=>{a(M.target.value),p(M.target.value),r||u(!0)},onFocus:()=>{p(""),u(!0)},onClick:()=>{r||u(!0)},placeholder:d,disabled:c,autoComplete:"off"})}),e.jsx(Vt,{className:"w-[var(--radix-popover-trigger-width)] max-h-60 overflow-y-auto p-1",align:"start",onOpenAutoFocus:M=>M.preventDefault(),children:D.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:x("common.noMatches")}):D.map(M=>e.jsx("button",{type:"button",className:ke("flex w-full items-center rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent",M.value===t.trim()&&"bg-accent"),onMouseDown:N=>{N.preventDefault(),P(M.value)},children:e.jsx("span",{className:"truncate",children:M.label})},M.value))})]})}function Ma({dialog:t,currentRoutes:a,onConfirm:o,onClose:c}){const{t:d}=ge();if(!t)return null;const{endpoint:x,preset:r}=t,u=r.modelRoutes??{},v={};for(const N of a){const j=N.source.trim(),E=N.target.trim();j&&E&&(v[j]=E)}const p=new Set([...Object.keys(v),...Object.keys(u)]),C=[],D=[],P=[];for(const N of p){const j=N in v,E=N in u;E&&!j?C.push([N,u[N]]):j&&!E?D.push([N,v[N]]):j&&E&&v[N]!==u[N]&&P.push([N,v[N],u[N]])}const M=C.length>0||D.length>0||P.length>0;return e.jsx(Et,{open:!0,onOpenChange:N=>!N&&c(),children:e.jsxs(Pt,{className:"max-w-lg",children:[e.jsxs(Rt,{children:[e.jsx(St,{children:d("modelManagement.presets.diffTitle")}),e.jsx(Dt,{children:d("modelManagement.presets.diffDescription",{name:r.name})})]}),M?e.jsxs("div",{className:"max-h-72 overflow-y-auto space-y-2 text-sm",children:[C.map(([N,j])=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 bg-emerald-50 dark:bg-emerald-950 text-emerald-800 dark:text-emerald-200",children:[e.jsx(Q,{variant:"outline",className:"text-xs border-emerald-300 dark:border-emerald-700",children:d("modelManagement.presets.diffAdded")}),e.jsx("span",{className:"truncate",children:N}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:j})]},`add-${N}`)),D.map(([N,j])=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 bg-red-50 dark:bg-red-950 text-red-800 dark:text-red-200",children:[e.jsx(Q,{variant:"outline",className:"text-xs border-red-300 dark:border-red-700",children:d("modelManagement.presets.diffRemoved")}),e.jsx("span",{className:"truncate",children:N}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:j})]},`rm-${N}`)),P.map(([N,j,E])=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 bg-amber-50 dark:bg-amber-950 text-amber-800 dark:text-amber-200",children:[e.jsx(Q,{variant:"outline",className:"text-xs border-amber-300 dark:border-amber-700",children:d("modelManagement.presets.diffChanged")}),e.jsx("span",{className:"truncate",children:N}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate line-through opacity-60",children:j}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:E})]},`chg-${N}`))]}):e.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:d("modelManagement.presets.diffEmpty")}),e.jsxs(Ot,{children:[e.jsx(I,{variant:"outline",onClick:c,children:d("common.cancel")}),e.jsx(I,{onClick:()=>o(x,r),disabled:!M,children:d("modelManagement.presets.diffConfirm")})]})]})})}function ft(t){return t.label&&t.label.trim().length>0?`${t.label} (${t.id})`:t.id}function Ca({type:t}){const a={openai:{label:"OpenAI",variant:"success"},deepseek:{label:"DeepSeek",variant:"info"},huawei:{label:"华为云",variant:"warning"},kimi:{label:"Kimi",variant:"purple"},anthropic:{label:"Anthropic",variant:"pink"},custom:{label:"Custom",variant:"secondary"}},{label:o,variant:c}=a[t]||a.custom;return e.jsx(Q,{variant:c,className:"text-xs",children:o})}function Ea({open:t,endpoint:a,onClose:o,onSuccess:c}){const{t:d}=ge(),{pushToast:x}=Mt(),[r,u]=f.useState({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0});f.useEffect(()=>{if(a){let j;a.paths&&a.paths.length>0?j=a.paths:a.path&&a.protocol?j=[{path:a.path,protocol:a.protocol}]:j=[{path:"",protocol:"openai-auto"}],u({id:a.id,label:a.label,paths:j,enabled:a.enabled!==!1})}else u({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0})},[a,t]);const v=mt({mutationFn:we.create,onSuccess:()=>{x({title:d("modelManagement.createEndpointSuccess"),variant:"success"}),c(),o()},onError:j=>{const E=Ie(j);x({title:d("modelManagement.createEndpointError",{error:E.message}),variant:"error"})}}),p=mt({mutationFn:j=>we.update(j.id,j.updates),onSuccess:()=>{x({title:d("modelManagement.updateEndpointSuccess"),variant:"success"}),c(),o()},onError:j=>{const E=Ie(j);x({title:d("modelManagement.updateEndpointError",{error:E.message}),variant:"error"})}}),C=()=>{u({...r,paths:[...r.paths,{path:"",protocol:"anthropic"}]})},D=j=>{if(r.paths.length===1){x({title:d("modelManagement.atLeastOnePath"),variant:"error"});return}const E=r.paths.filter((_,L)=>L!==j);u({...r,paths:E})},P=(j,E,_)=>{const L=[...r.paths];L[j]={...L[j],[E]:_},u({...r,paths:L})},M=j=>{if(j.preventDefault(),!r.id.trim()||!r.label.trim()){x({title:d("modelManagement.endpointValidationError"),variant:"error"});return}for(const _ of r.paths)if(!_.path.trim()){x({title:d("modelManagement.pathValidationError"),variant:"error"});return}const E=r.paths.map(_=>({path:_.path.trim(),protocol:_.protocol}));a?p.mutate({id:a.id,updates:{label:r.label.trim(),paths:E,enabled:r.enabled}}):v.mutate({id:r.id.trim(),label:r.label.trim(),paths:E,enabled:r.enabled})},N=v.isPending||p.isPending;return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-40",onClick:o}),e.jsx("div",{className:"fixed inset-y-0 right-0 w-full max-w-md bg-card border-l shadow-xl z-50 overflow-y-auto",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b",children:[e.jsx("h2",{className:"text-lg font-semibold",children:d(a?"modelManagement.editEndpoint":"modelManagement.createEndpoint")}),e.jsx(I,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(Te,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:M,className:"flex-1 p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{children:[d("modelManagement.endpointId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(xe,{value:r.id,onChange:j=>u({...r,id:j.target.value}),placeholder:d("modelManagement.endpointIdPlaceholder"),disabled:!!a,required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d("modelManagement.endpointIdHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{children:[d("modelManagement.endpointLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(xe,{value:r.label,onChange:j=>u({...r,label:j.target.value}),placeholder:d("modelManagement.endpointLabelPlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(de,{children:[d("modelManagement.endpointPaths")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(I,{type:"button",variant:"ghost",size:"sm",onClick:C,children:[e.jsx(Je,{className:"mr-1 h-3 w-3"}),d("modelManagement.addPath")]})]}),e.jsx("div",{className:"space-y-3",children:r.paths.map((j,E)=>e.jsxs("div",{className:"rounded-lg border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(xe,{value:j.path,onChange:_=>P(E,"path",_.target.value),placeholder:d("modelManagement.endpointPathPlaceholder"),required:!0}),e.jsxs(Gs,{value:j.protocol,onValueChange:_=>P(E,"protocol",_),children:[e.jsx(Qs,{children:e.jsx(Js,{})}),e.jsxs(Xs,{children:[e.jsx(ut,{value:"anthropic",children:d("modelManagement.protocolAnthropic")}),e.jsx(ut,{value:"openai-auto",children:d("modelManagement.protocolOpenAI")})]})]})]}),r.paths.length>1&&e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>D(E),className:"text-destructive",children:e.jsx(Te,{className:"h-4 w-4"})})]}),E===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:d("modelManagement.endpointPathHint")})]},E))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ct,{id:"enabled",checked:r.enabled,onCheckedChange:j=>u({...r,enabled:j})}),e.jsx(de,{htmlFor:"enabled",children:d("modelManagement.endpointEnabled")})]}),!a&&e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:d("modelManagement.endpointRoutingHint")})})]}),e.jsxs("div",{className:"flex gap-3 p-6 border-t",children:[e.jsx(I,{variant:"outline",className:"flex-1",onClick:o,disabled:N,children:d("common.cancel")}),e.jsx(I,{className:"flex-1",onClick:M,disabled:N,children:d(N?"common.saving":a?"common.save":"common.create")})]})]})})]}):null}export{La as default};
6
+ */const he=vs("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var Z,re,z,ee,te,Ae,Xe,gt,Zs=(gt=class extends js{constructor(a,o){super();ue(this,te);ue(this,Z);ue(this,re);ue(this,z);ue(this,ee);me(this,Z,a),this.setOptions(o),this.bindMethods(),pe(this,te,Ae).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(a){var c;const o=this.options;this.options=O(this,Z).defaultMutationOptions(a),ys(this.options,o)||O(this,Z).getMutationCache().notify({type:"observerOptionsUpdated",mutation:O(this,z),observer:this}),o!=null&&o.mutationKey&&this.options.mutationKey&&ct(o.mutationKey)!==ct(this.options.mutationKey)?this.reset():((c=O(this,z))==null?void 0:c.state.status)==="pending"&&O(this,z).setOptions(this.options)}onUnsubscribe(){var a;this.hasListeners()||(a=O(this,z))==null||a.removeObserver(this)}onMutationUpdate(a){pe(this,te,Ae).call(this),pe(this,te,Xe).call(this,a)}getCurrentResult(){return O(this,re)}reset(){var a;(a=O(this,z))==null||a.removeObserver(this),me(this,z,void 0),pe(this,te,Ae).call(this),pe(this,te,Xe).call(this)}mutate(a,o){var c;return me(this,ee,o),(c=O(this,z))==null||c.removeObserver(this),me(this,z,O(this,Z).getMutationCache().build(O(this,Z),this.options)),O(this,z).addObserver(this),O(this,z).execute(a)}},Z=new WeakMap,re=new WeakMap,z=new WeakMap,ee=new WeakMap,te=new WeakSet,Ae=function(){var o;const a=((o=O(this,z))==null?void 0:o.state)??Ns();me(this,re,{...a,isPending:a.status==="pending",isSuccess:a.status==="success",isError:a.status==="error",isIdle:a.status==="idle",mutate:this.mutate,reset:this.reset})},Xe=function(a){bt.batch(()=>{var o,c,d,x,r,u,v,p;if(O(this,ee)&&this.hasListeners()){const C=O(this,re).variables,D=O(this,re).context,P={client:O(this,Z),meta:this.options.meta,mutationKey:this.options.mutationKey};(a==null?void 0:a.type)==="success"?((c=(o=O(this,ee)).onSuccess)==null||c.call(o,a.data,C,D,P),(x=(d=O(this,ee)).onSettled)==null||x.call(d,a.data,null,C,D,P)):(a==null?void 0:a.type)==="error"&&((u=(r=O(this,ee)).onError)==null||u.call(r,a.error,C,D,P),(p=(v=O(this,ee)).onSettled)==null||p.call(v,void 0,a.error,C,D,P))}this.listeners.forEach(C=>{C(O(this,re))})})},gt);function mt(t,a){const o=vt(),[c]=f.useState(()=>new Zs(o,t));f.useEffect(()=>{c.setOptions(t)},[c,t]);const d=f.useSyncExternalStore(f.useCallback(r=>c.subscribe(bt.batchCalls(r)),[c]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),x=f.useCallback((r,u)=>{c.mutate(r,u).catch(ks)},[c]);if(d.error&&ws(c.options.throwOnError,[d.error]))throw d.error;return{...d,mutate:x,mutateAsync:d.mutate}}var Ue="Popover",[At]=Es(Ue,[jt]),Me=jt(),[ea,oe]=At(Ue),Tt=t=>{const{__scopePopover:a,children:o,open:c,defaultOpen:d,onOpenChange:x,modal:r=!1}=t,u=Me(a),v=f.useRef(null),[p,C]=f.useState(!1),[D,P]=Ms({prop:c,defaultProp:d??!1,onChange:x,caller:Ue});return e.jsx(Cs,{...u,children:e.jsx(ea,{scope:a,contentId:Ps(),triggerRef:v,open:D,onOpenChange:P,onOpenToggle:f.useCallback(()=>P(M=>!M),[P]),hasCustomAnchor:p,onCustomAnchorAdd:f.useCallback(()=>C(!0),[]),onCustomAnchorRemove:f.useCallback(()=>C(!1),[]),modal:r,children:o})})};Tt.displayName=Ue;var It="PopoverAnchor",ta=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=oe(It,o),x=Me(o),{onCustomAnchorAdd:r,onCustomAnchorRemove:u}=d;return f.useEffect(()=>(r(),()=>u()),[r,u]),e.jsx(kt,{...x,...c,ref:a})});ta.displayName=It;var Ut="PopoverTrigger",Ft=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=oe(Ut,o),x=Me(o),r=yt(a,d.triggerRef),u=e.jsx(Nt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":d.open,"aria-controls":d.contentId,"data-state":zt(d.open),...c,ref:r,onClick:Ne(t.onClick,d.onOpenToggle)});return d.hasCustomAnchor?u:e.jsx(kt,{asChild:!0,...x,children:u})});Ft.displayName=Ut;var Ye="PopoverPortal",[sa,aa]=At(Ye,{forceMount:void 0}),_t=t=>{const{__scopePopover:a,forceMount:o,children:c,container:d}=t,x=oe(Ye,a);return e.jsx(sa,{scope:a,forceMount:o,children:e.jsx(wt,{present:o||x.open,children:e.jsx(Rs,{asChild:!0,container:d,children:c})})})};_t.displayName=Ye;var fe="PopoverContent",Lt=f.forwardRef((t,a)=>{const o=aa(fe,t.__scopePopover),{forceMount:c=o.forceMount,...d}=t,x=oe(fe,t.__scopePopover);return e.jsx(wt,{present:c||x.open,children:x.modal?e.jsx(oa,{...d,ref:a}):e.jsx(na,{...d,ref:a})})});Lt.displayName=fe;var ra=Os("PopoverContent.RemoveScroll"),oa=f.forwardRef((t,a)=>{const o=oe(fe,t.__scopePopover),c=f.useRef(null),d=yt(a,c),x=f.useRef(!1);return f.useEffect(()=>{const r=c.current;if(r)return Ss(r)},[]),e.jsx(Ds,{as:ra,allowPinchZoom:!0,children:e.jsx($t,{...t,ref:d,trapFocus:o.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ne(t.onCloseAutoFocus,r=>{var u;r.preventDefault(),x.current||(u=o.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ne(t.onPointerDownOutside,r=>{const u=r.detail.originalEvent,v=u.button===0&&u.ctrlKey===!0,p=u.button===2||v;x.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:Ne(t.onFocusOutside,r=>r.preventDefault(),{checkForDefaultPrevented:!1})})})}),na=f.forwardRef((t,a)=>{const o=oe(fe,t.__scopePopover),c=f.useRef(!1),d=f.useRef(!1);return e.jsx($t,{...t,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:x=>{var r,u;(r=t.onCloseAutoFocus)==null||r.call(t,x),x.defaultPrevented||(c.current||(u=o.triggerRef.current)==null||u.focus(),x.preventDefault()),c.current=!1,d.current=!1},onInteractOutside:x=>{var v,p;(v=t.onInteractOutside)==null||v.call(t,x),x.defaultPrevented||(c.current=!0,x.detail.originalEvent.type==="pointerdown"&&(d.current=!0));const r=x.target;((p=o.triggerRef.current)==null?void 0:p.contains(r))&&x.preventDefault(),x.detail.originalEvent.type==="focusin"&&d.current&&x.preventDefault()}})}),$t=f.forwardRef((t,a)=>{const{__scopePopover:o,trapFocus:c,onOpenAutoFocus:d,onCloseAutoFocus:x,disableOutsidePointerEvents:r,onEscapeKeyDown:u,onPointerDownOutside:v,onFocusOutside:p,onInteractOutside:C,...D}=t,P=oe(fe,o),M=Me(o);return As(),e.jsx(Ts,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:d,onUnmountAutoFocus:x,children:e.jsx(Is,{asChild:!0,disableOutsidePointerEvents:r,onInteractOutside:C,onEscapeKeyDown:u,onPointerDownOutside:v,onFocusOutside:p,onDismiss:()=>P.onOpenChange(!1),children:e.jsx(Us,{"data-state":zt(P.open),role:"dialog",id:P.contentId,...M,...D,ref:a,style:{...D.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Kt="PopoverClose",la=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=oe(Kt,o);return e.jsx(Nt.button,{type:"button",...c,ref:a,onClick:Ne(t.onClick,()=>d.onOpenChange(!1))})});la.displayName=Kt;var ia="PopoverArrow",da=f.forwardRef((t,a)=>{const{__scopePopover:o,...c}=t,d=Me(o);return e.jsx(Fs,{...d,...c,ref:a})});da.displayName=ia;function zt(t){return t?"open":"closed"}var ca=Tt,ua=Ft,ma=_t,Bt=Lt;const pa=ca,ha=ua,Vt=f.forwardRef(({className:t,align:a="center",sideOffset:o=4,...c},d)=>e.jsx(ma,{children:e.jsx(Bt,{ref:d,align:a,sideOffset:o,className:ke("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...c})}));Vt.displayName=Bt.displayName;function Ze(){return typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,10)}function xa(){return{_key:Ze(),id:"",label:""}}const Ge={openai:{baseUrl:"https://api.openai.com/v1"},deepseek:{baseUrl:"https://api.deepseek.com/v1"},huawei:{baseUrl:"https://api.modelarts-maas.com/v1"},kimi:{baseUrl:"https://api.moonshot.cn/v1"},anthropic:{baseUrl:"https://api.anthropic.com/v1"},custom:{}};function pt(t){return t?{id:t.id,label:t.label??t.id,baseUrl:t.baseUrl,apiKey:t.apiKey??"",type:t.type??"custom",defaultModel:t.defaultModel??"",models:(t.models??[]).map(a=>({...a,_key:Ze()})),authMode:t.authMode??"apiKey"}:{id:"",label:"",baseUrl:"",apiKey:"",type:"custom",defaultModel:"",models:[],authMode:"apiKey"}}function fa(t){return{_key:Ze(),id:t.id,label:t.label}}function ga({open:t,mode:a,provider:o,existingProviderIds:c,onClose:d,onSubmit:x}){const{t:r}=ge(),[u,v]=f.useState(()=>pt(o)),[p,C]=f.useState({}),[D,P]=f.useState(!1),[M,N]=f.useState(null),j=f.useRef(null),E=f.useRef(null),_=f.useRef(null),[L,Ce]=f.useState(a==="edit");f.useEffect(()=>{t&&(v(pt(o)),C({}),N(null),P(!1),Ce(a==="edit"))},[t,o,a]),f.useEffect(()=>{if(!t)return;const b=y=>{y.key==="Escape"&&d()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t,d]),f.useEffect(()=>{if(t){if(a==="create"&&_.current){_.current.focus();return}E.current&&E.current.focus()}},[t,a]);const Ee=f.useMemo(()=>u.models.filter(b=>b.id.trim().length>0),[u.models]),be=b=>y=>{v(S=>({...S,[b]:y}))},Pe=b=>{v(y=>{const w=!L||y.label.trim().length===0||y.label===y.id?b:y.label;return{...y,id:b,label:w}})},J=b=>{v(y=>{var De;const w=Ge[b??"custom"]??Ge.custom,A=Object.values(Ge).map(se=>se.baseUrl).filter(se=>!!se),H=!y.baseUrl||A.includes(y.baseUrl),K=a==="create"&&(y.models.length===0||y.models.every(se=>se.id.trim().length===0)),X={...y,type:b,authMode:y.authMode??"apiKey"};return w!=null&&w.baseUrl&&H&&(X.baseUrl=w.baseUrl),w!=null&&w.models&&K&&(X.models=w.models.map(fa),X.defaultModel=w.defaultModel??((De=w.models[0])==null?void 0:De.id)??""),X})},$=(b,y)=>{v(S=>{const w=[...S.models];return w[b]={...w[b],...y},{...S,models:w}})},Fe=(b,y)=>{v(S=>{const w=[...S.models],A=w[b];if(!A)return S;const H=!L||!A.label||A.label===A.id,K={...A,id:y,label:H?y:A.label};w[b]=K;const X=S.defaultModel===A.id?y:S.defaultModel;return{...S,models:w,defaultModel:X}})},V=b=>{v(y=>{if(b<0||b>=y.models.length)return y;const S=y.models.filter((A,H)=>H!==b);let w=y.defaultModel;return S.some(A=>A.id===w)||(w=""),{...y,models:S,defaultModel:w}})},_e=()=>{v(b=>({...b,models:[...b.models,xa()]}))},ce=b=>{v(y=>({...y,authMode:b}))},Re=()=>{const b={},y=u.id.trim(),S=u.baseUrl.trim();if(a==="create"&&(y.length===0?b.id=r("providers.drawer.errors.idRequired"):c.includes(y)&&(b.id=r("providers.drawer.errors.idDuplicate"))),a==="edit"&&y.length===0&&(b.id=r("providers.drawer.errors.idRequired")),S.length===0)b.baseUrl=r("providers.drawer.errors.baseUrlInvalid");else try{new URL(S)}catch{b.baseUrl=r("providers.drawer.errors.baseUrlInvalid")}if(u.models.length>0){const w=new Set;u.models.some(H=>{const K=H.id.trim();return K.length===0||w.has(K)?!0:(w.add(K),!1)})&&(b.models=r("providers.drawer.errors.modelInvalid"))}return u.defaultModel&&!u.models.some(w=>w.id===u.defaultModel)&&(b.models=r("providers.drawer.errors.defaultInvalid")),C(b),Object.keys(b).length===0},ve=()=>{const b=u.models.map(w=>{var A;return{id:w.id.trim(),label:(A=w.label)!=null&&A.trim()?w.label.trim():void 0}}).filter(w=>w.id.length>0),y=o!=null&&o.extraHeaders&&Object.keys(o.extraHeaders).length>0?o.extraHeaders:void 0,S=u.authMode!=="apiKey"?u.authMode:void 0;return{id:u.id.trim(),label:u.label.trim()||u.id.trim(),baseUrl:u.baseUrl.trim(),apiKey:u.apiKey.trim()||void 0,type:u.type??"custom",defaultModel:u.defaultModel||void 0,models:b.length>0?b:void 0,extraHeaders:y,authMode:S}},Se=async()=>{if(N(null),!!Re()){P(!0);try{const b=ve();await x(b)}catch(b){N(r("providers.drawer.toast.saveFailure",{message:b instanceof Error?b.message:"unknown"})),P(!1);return}P(!1),d()}},je=a==="create";return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-slate-900/60",onClick:d,"aria-hidden":"true"}),e.jsxs("aside",{ref:j,role:"dialog","aria-modal":"true","aria-labelledby":"provider-drawer-title","aria-describedby":"provider-drawer-desc",className:"flex h-full w-full max-w-3xl flex-col border-l border-slate-200 bg-white shadow-xl dark:border-slate-800 dark:bg-slate-900",children:[e.jsxs("header",{className:"flex items-center justify-between border-b border-slate-200 px-6 py-4 dark:border-slate-800",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"provider-drawer-title",className:"text-lg font-semibold",children:r(je?"providers.drawer.createTitle":"providers.drawer.editTitle")}),e.jsx("p",{id:"provider-drawer-desc",className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.description")})]}),e.jsx("button",{type:"button",ref:E,onClick:d,className:"rounded-md border border-slate-200 px-3 py-1 text-sm transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:r("common.actions.close")})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:[e.jsxs("section",{className:"space-y-4","aria-labelledby":"provider-basic-fields",children:[e.jsx("div",{id:"provider-basic-fields",className:"sr-only",children:r("providers.drawer.description")}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx("button",{type:"button",onClick:()=>Ce(b=>!b),className:"rounded-md border border-slate-200 px-3 py-1 text-xs transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:r(L?"providers.drawer.fields.hideAdvanced":"providers.drawer.fields.showAdvanced")})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.id")}),e.jsx("input",{value:u.id,ref:_,onChange:b=>Pe(b.target.value),disabled:!je,placeholder:r("providers.drawer.fields.idPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60","aria-invalid":!!p.id}),p.id?e.jsx("span",{className:"text-xs text-red-500",children:p.id}):null]}),L?e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.label")}),e.jsx("input",{value:u.label,onChange:b=>be("label")(b.target.value),placeholder:r("providers.drawer.fields.labelPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}):null]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.baseUrl")}),e.jsx("input",{value:u.baseUrl,onChange:b=>be("baseUrl")(b.target.value),placeholder:r("providers.drawer.fields.baseUrlPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60","aria-invalid":!!p.baseUrl}),p.baseUrl?e.jsx("span",{className:"text-xs text-red-500",children:p.baseUrl}):null]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.type")}),e.jsxs("select",{value:u.type??"custom",onChange:b=>J(b.target.value),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60",children:[e.jsx("option",{value:"openai",children:"OpenAI"}),e.jsx("option",{value:"deepseek",children:"DeepSeek"}),e.jsx("option",{value:"huawei",children:"华为云"}),e.jsx("option",{value:"kimi",children:"Kimi"}),e.jsx("option",{value:"anthropic",children:"Anthropic (Claude)"}),e.jsx("option",{value:"custom",children:"Custom"})]})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.apiKey")}),e.jsx("input",{value:u.apiKey,onChange:b=>be("apiKey")(b.target.value),placeholder:r("providers.drawer.fields.apiKeyPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}),e.jsxs("fieldset",{className:"grid gap-2 rounded-lg border border-slate-200 p-3 text-xs dark:border-slate-700",children:[e.jsx("legend",{className:"px-1 text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.authMode")}),e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.authModeHint")}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"apiKey",checked:u.authMode==="apiKey",onChange:()=>ce("apiKey")}),e.jsx("span",{children:r("providers.drawer.fields.authModeApiKey")})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"authToken",checked:u.authMode==="authToken",onChange:()=>ce("authToken")}),e.jsx("span",{children:r("providers.drawer.fields.authModeAuthToken")})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 transition hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"xAuthToken",checked:u.authMode==="xAuthToken",onChange:()=>ce("xAuthToken")}),e.jsx("span",{children:r("providers.drawer.fields.authModeXAuthToken")})]})]})]}),e.jsxs("section",{className:"mt-6 space-y-3","aria-labelledby":"provider-model-fields",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"provider-model-fields",className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.models")}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.modelsDescription")})]}),e.jsx("button",{type:"button",onClick:_e,className:"rounded-md border border-slate-200 px-3 py-1 text-xs transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",children:r("providers.drawer.fields.addModel")})]}),p.models?e.jsx("p",{className:"text-xs text-red-500",children:p.models}):null,e.jsxs("div",{className:"space-y-4",children:[u.models.map((b,y)=>e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-800/40",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.modelId")}),e.jsx("input",{value:b.id,onChange:S=>Fe(y,S.target.value),placeholder:r("providers.drawer.fields.modelIdPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}),L?e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.fields.modelLabel")}),e.jsx("input",{value:b.label??"",onChange:S=>$(y,{label:S.target.value}),placeholder:r("providers.drawer.fields.modelLabelPlaceholder"),className:"rounded-md border border-slate-200 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:bg-slate-100 disabled:text-slate-400 dark:border-slate-700 dark:bg-slate-800 dark:focus:border-blue-400 dark:focus:ring-blue-400/40 dark:disabled:bg-slate-800/60"})]}):null]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2 text-slate-600 dark:text-slate-300",children:[e.jsx("input",{type:"radio",name:"defaultModel",value:b.id,checked:u.defaultModel===b.id,onChange:()=>v(S=>({...S,defaultModel:b.id})),disabled:b.id.trim().length===0}),r("providers.drawer.fields.setDefault")]}),e.jsx("button",{type:"button",className:"text-red-500 transition hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>V(y),disabled:u.models.length===0,children:r("providers.drawer.fields.removeModel")})]})]},b._key)),u.models.length===0?e.jsx("div",{className:"rounded-xl border-2 border-amber-300 bg-gradient-to-br from-amber-50 to-yellow-50 p-5 shadow-md dark:border-amber-600/60 dark:from-amber-900/20 dark:to-yellow-900/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 text-2xl",children:"💡"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:r("providers.drawer.noModelsTitle")}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-800 dark:text-amber-300",children:r("providers.drawer.noModelsHint",{providerId:u.id||"provider-id"})}),e.jsxs("div",{className:"rounded-md bg-amber-100/80 p-2.5 dark:bg-amber-800/40",children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-amber-900 dark:text-amber-200",children:r("providers.drawer.routeExample")}),e.jsxs("code",{className:"block rounded bg-white px-2.5 py-1.5 font-mono text-xs text-amber-900 shadow-sm dark:bg-slate-900 dark:text-amber-100",children:['"claude-*": "',(u.id||"provider-id").trim()||"provider-id",':*"']})]})]})]})}):null]}),Ee.length>1?e.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400",children:r("providers.drawer.defaultHint",{model:u.defaultModel||r("providers.card.noDefault")})}):null]})]}),e.jsxs("footer",{className:"flex items-center justify-between gap-3 border-t border-slate-200 px-6 py-4 text-sm dark:border-slate-800",children:[e.jsx("div",{className:"flex flex-col text-xs text-red-500","aria-live":"polite",children:M?e.jsx("span",{children:M}):null}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:d,className:"rounded-md border border-slate-200 px-4 py-2 transition hover:bg-slate-100 dark:border-slate-700 dark:hover:bg-slate-800",disabled:D,children:r("common.actions.cancel")}),e.jsx("button",{type:"button",onClick:Se,className:"rounded-md bg-blue-600 px-4 py-2 text-white transition hover:bg-blue-700 disabled:opacity-60",disabled:D,children:r(D?"common.actions.saving":"common.actions.save")})]})]})]})]}):null}const ba=["claude-sonnet-4-5-20250929","claude-sonnet-4-5-20250929-thinking","claude-sonnet-4-20250514","claude-opus-4-1-20250805","claude-opus-4-1-20250805-thinking","claude-haiku-4-5-20251001","claude-haiku-4-5-20251001-thinking","claude-3-5-haiku-20241022"],va=["gpt-4o-mini","gpt-4o","o4-mini","o4-large","gpt-5-codex"];function We(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2,10)}function Y(t){return t?Object.entries(t).map(([a,o])=>({id:We(),source:a,target:o})):[]}function Qe(t,a){var d,x,r;if(!t)return{};const o={},c=t.endpointRouting??{};o.anthropic=Y(((d=c.anthropic)==null?void 0:d.modelRoutes)??t.modelRoutes??{}),o.openai=Y(((x=c.openai)==null?void 0:x.modelRoutes)??{});for(const u of a)(r=u.routing)!=null&&r.modelRoutes?o[u.id]=Y(u.routing.modelRoutes):o[u.id]=[];return o}function ht(t,a,o){var x,r,u;const c=a.find(v=>v.id===o);if(c)return((x=c.routing)==null?void 0:x.modelRoutes)??{};const d=t.endpointRouting??{};return o==="anthropic"?((r=d.anthropic)==null?void 0:r.modelRoutes)??t.modelRoutes??{}:o==="openai"?((u=d.openai)==null?void 0:u.modelRoutes)??{}:{}}function ja(t){const a={};for(const o of t){const c=o.source.trim(),d=o.target.trim();c&&d&&(a[c]=d)}return a}function xt(t,a){return JSON.stringify(ja(t))!==JSON.stringify(a)}function ya(t,a){if(t==="anthropic")return!0;const o=a.find(c=>c.id===t);return o?o.paths&&o.paths.length>0?o.paths.some(c=>c.protocol==="anthropic"):o.protocol==="anthropic":!1}function Na(t,a,o){var d,x,r;if(!a)return;if(t==="anthropic"||t==="openai")return(x=(d=a.endpointRouting)==null?void 0:d[t])==null?void 0:x.validation;const c=o.find(u=>u.id===t);return(r=c==null?void 0:c.routing)==null?void 0:r.validation}function La(){const{t}=ge(),{pushToast:a}=Mt(),o=vt(),c=Vs(["config","full"],{url:"/api/config",method:"GET"}),{data:d}=qs({queryKey:["custom-endpoints"],queryFn:we.list,refetchInterval:1e4}),x=(d==null?void 0:d.endpoints)??[],r=f.useMemo(()=>{const s=[{key:"providers",label:t("modelManagement.tabs.providers"),description:t("modelManagement.tabs.providersDesc"),isSystem:!0,canDelete:!1},{key:"anthropic",label:t("modelManagement.tabs.anthropic"),description:t("modelManagement.tabs.anthropicDesc"),isSystem:!0,canDelete:!1,protocols:["anthropic"]},{key:"openai",label:t("modelManagement.tabs.openai"),description:t("modelManagement.tabs.openaiDesc"),isSystem:!0,canDelete:!1,protocols:["openai-auto","openai-chat","openai-responses"]}],l=x.map(n=>{let i,m=[];if(n.paths&&n.paths.length>0){const h=n.paths.map(g=>`${g.path} (${g.protocol})`).join(", ");i=`${t("modelManagement.tabs.customEndpoint")}: ${h}`,m=[...new Set(n.paths.map(g=>g.protocol))]}else if(n.path){const h=n.protocol||"anthropic";i=`${t("modelManagement.tabs.customEndpoint")}: ${n.path} (${h})`,m=[h]}else i=t("modelManagement.tabs.customEndpoint");return{key:n.id,label:n.label,description:i,isSystem:!1,canDelete:n.deletable!==!1,protocols:m}});return[...s,...l]},[t,x]),[u,v]=f.useState("providers"),[p,C]=f.useState(null),[D,P]=f.useState(!1),[M,N]=f.useState("create"),[j,E]=f.useState(void 0),[_,L]=f.useState(null),[Ce,Ee]=f.useState(!1),[be,Pe]=f.useState(void 0),[J,$]=f.useState({}),[Fe,V]=f.useState({}),[_e,ce]=f.useState(null),[Re,ve]=f.useState({}),[Se,je]=f.useState({}),[b,y]=f.useState({}),[S,w]=f.useState(null),[A,H]=f.useState(null),[K,X]=f.useState(null),[De,se]=f.useState(!1),[Le,et]=f.useState(null),[Oe,$e]=f.useState(!0),[tt,st]=f.useState({}),[qt,at]=f.useState(!1),[Ht,Gt]=f.useState({}),[Ke,ze]=f.useState(null),q=(p==null?void 0:p.providers)??[],Qt=q.length,ye=f.useMemo(()=>[{key:"anthropic-beta",value:"claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",label:t("providers.testDialog.options.beta.label"),description:t("providers.testDialog.options.beta.description")}],[t]);f.useEffect(()=>{var s,l;if(c.data){const n=c.data;C(n),$(m=>{const h=Qe(n,x);if(!m||Object.keys(m).length===0)return h;const g={...h};for(const[k,R]of Object.entries(m)){if(!(k in h))continue;const F=ht(n,x,k);xt(R,F)&&(g[k]=R)}return g}),V({});const i={anthropic:((s=n.routingPresets)==null?void 0:s.anthropic)??[],openai:((l=n.routingPresets)==null?void 0:l.openai)??[]};for(const m of x)i[m.id]=m.routingPresets??[];ve(i)}},[c.data,x]),f.useEffect(()=>{c.isError&&c.error&&a({title:t("providers.toast.loadFailure",{message:c.error.message}),variant:"error"})},[c.isError,c.error,a,t]);const Jt=f.useMemo(()=>{const s=new Map;for(const l of q){if(!l.defaultModel||!l.models)continue;const n=l.models.find(i=>i.id===l.defaultModel);n&&s.set(l.id,ft(n))}return s},[q]),Xt=f.useMemo(()=>{const s=[],l=new Set;for(const i of q){const m=i.label&&i.label!==i.id?`${i.label} (${i.id})`:i.id,h=i.models??[];if(h.length>0)for(const k of h){const R=`${i.id}:${k.id}`;l.has(R)||(l.add(R),s.push({value:R,label:`${m} · ${k.label??k.id}`}))}else if(i.defaultModel){const k=`${i.id}:${i.defaultModel}`;l.has(k)||(l.add(k),s.push({value:k,label:`${m} · ${i.defaultModel}`}))}const g=`${i.id}:*`;l.has(g)||(l.add(g),s.push({value:g,label:t("settings.routing.providerPassthroughOption",{provider:m})}))}const n=Object.values(J).flat();for(const i of n){const m=i.target.trim();m&&!l.has(m)&&(l.add(m),s.push({value:m,label:m}))}return s},[q,J,t]),Wt=s=>p?ht(p,x,s):{},Yt=(s,l)=>xt(s,l),rt=f.useMemo(()=>{const s={};for(const l of r){if(l.key==="providers")continue;const n=J[l.key]||[],i=Wt(l.key);s[l.key]=Yt(n,i)}return s},[J,p,x,r]),ot=(s,l)=>{ve(n=>({...n,[s]:l})),C(n=>{if(!n)return n;if(s==="anthropic"||s==="openai")return{...n,routingPresets:{...n.routingPresets,[s]:l}};const i=n.customEndpoints??[],m=i.findIndex(g=>g.id===s);if(m===-1)return n;const h=[...i];return h[m]={...h[m],routingPresets:l},{...n,customEndpoints:h}})},ae=()=>p?!0:(a({title:t("settings.toast.missingConfig"),variant:"error"}),c.refetch(),!1),Zt=(s,l)=>{je(n=>({...n,[s]:l})),l.trim()&&y(n=>({...n,[s]:null}))},es=async s=>{if(!ae())return;const l=Se[s].trim();if(!l){y(n=>({...n,[s]:t("modelManagement.validation.presetName")}));return}if(Re[s].some(n=>n.name.toLowerCase()===l.toLowerCase())){y(n=>({...n,[s]:t("modelManagement.validation.presetDuplicate",{name:l})}));return}w(s);try{const i=(await W.post(`/api/routing-presets/${s}`,{name:l})).data.presets??[];ot(s,i),je(m=>({...m,[s]:""})),y(m=>({...m,[s]:null})),a({title:t("modelManagement.toast.presetSaved",{name:l}),variant:"success"})}catch(n){a({title:t("modelManagement.toast.presetSaveFailure",{message:n instanceof Error?n.message:"unknown"}),variant:"error"})}finally{w(null),c.refetch()}},ts=async(s,l)=>{var n,i,m;if(ae()){H({endpoint:s,name:l.name});try{const g=(await W.post(`/api/routing-presets/${s}/apply`,{name:l.name})).data.config;if(g){C(g),$(Qe(g,x));const k={anthropic:((n=g.routingPresets)==null?void 0:n.anthropic)??[],openai:((i=g.routingPresets)==null?void 0:i.openai)??[]};for(const R of x){const F=(m=g.customEndpoints)==null?void 0:m.find(U=>U.id===R.id);k[R.id]=(F==null?void 0:F.routingPresets)??[]}ve(k)}else $(k=>({...k,[s]:Y(l.modelRoutes)}));a({title:t("modelManagement.toast.presetApplySuccess",{name:l.name}),variant:"success"})}catch(h){a({title:t("modelManagement.toast.presetApplyFailure",{message:h instanceof Error?h.message:"unknown"}),variant:"error"})}finally{H(null),c.refetch()}}},ss=async(s,l)=>{if(!(!ae()||!window.confirm(t("modelManagement.confirm.deletePreset",{name:l.name})))){X({endpoint:s,name:l.name});try{const m=(await W.delete(`/api/routing-presets/${s}/${encodeURIComponent(l.name)}`)).data.presets??[];ot(s,m),a({title:t("modelManagement.toast.presetDeleteSuccess",{name:l.name}),variant:"success"})}catch(i){a({title:t("modelManagement.toast.presetDeleteFailure",{message:i instanceof Error?i.message:"unknown"}),variant:"error"})}finally{X(null),c.refetch()}}},as=()=>{ae()&&(N("create"),E(void 0),P(!0))},rs=s=>{ae()&&(N("edit"),E(s),P(!0))},os=async s=>{if(!p)throw new Error(t("settings.toast.missingConfig"));const l=M==="create"?[...q,s]:q.map(m=>j&&m.id===j.id?{...s,id:j.id}:m),n={...p,providers:l};await W.put("/api/config",n),C(n),$(Qe(n,x)),c.refetch();const i=M==="create"?t("providers.toast.createSuccess",{name:s.label||s.id}):t("providers.toast.updateSuccess",{name:s.label||s.id});a({title:i,variant:"success"})},ns=async s=>{const l=x.find(n=>n.id===s);if(l&&l.deletable!==!1&&confirm(t("modelManagement.deleteEndpointConfirm",{label:l.label})))try{await we.delete(s),o.invalidateQueries({queryKey:["custom-endpoints"]}),a({title:t("modelManagement.deleteEndpointSuccess"),variant:"success"}),u===s&&v("providers")}catch(n){const i=Ie(n);a({title:t("modelManagement.deleteEndpointError",{error:i.message}),variant:"error"})}},nt=async(s,l)=>{L(s.id);try{const n=l&&(l.headers||l.query)?{headers:l.headers&&Object.keys(l.headers).length>0?l.headers:void 0,query:l.query&&l.query.trim().length>0?l.query.trim():void 0}:void 0,i=await W.post(`/api/providers/${s.id}/test`,n);i.data.ok?a({title:t("providers.toast.testSuccess"),description:t("providers.toast.testSuccessDesc",{status:i.data.status,duration:i.data.durationMs?`${i.data.durationMs} ms`:"—"}),variant:"success"}):a({title:t("providers.toast.testFailure",{message:`${i.data.status} ${i.data.statusText}`}),variant:"error"})}catch(n){a({title:t("providers.toast.testFailure",{message:n instanceof Error?n.message:"unknown"}),variant:"error"})}finally{L(null)}},ls=s=>{if(s.type==="anthropic"){const l=s.extraHeaders??{},n=new Map(ye.map(h=>[h.key.toLowerCase(),h])),i={};let m=!0;for(const h of ye){const g=Object.entries(l).find(([k])=>k.toLowerCase()===h.key.toLowerCase());if(g){const[k,R]=g;String(R??"")===h.value||(m=!1,i[k]=String(R??""))}}for(const[h,g]of Object.entries(l))n.has(h.toLowerCase())||(i[h]=String(g??""));st(i),$e(m),et(s),se(!0);return}nt(s)},lt=()=>{se(!1),et(null),$e(!0),st({})},is=async()=>{if(!Le)return;const s={};if(Oe)for(const i of ye)s[i.key]=i.value;const l=new Map(ye.map(i=>[i.key.toLowerCase(),i]));for(const[i,m]of Object.entries(tt)){const h=i.toLowerCase();l.get(h)&&Oe||(s[i]=m)}const n=Le;lt(),await nt(n,{headers:Object.keys(s).length>0?s:void 0,query:Oe?"beta=true":void 0})},ds=async s=>{var R,F,U,G;if(!ae()||!window.confirm(t("providers.confirm.delete",{name:s.label||s.id})))return;const n=q.filter(B=>B.id!==s.id),i=B=>{const ne={};if(!B)return ne;for(const[Be,le]of Object.entries(B)){if(!le)continue;const[T]=le.split(":");T&&T===s.id||le===s.id||(ne[Be]=le)}return ne},m=(p==null?void 0:p.endpointRouting)??{},h=i(((R=m.anthropic)==null?void 0:R.modelRoutes)??(p==null?void 0:p.modelRoutes)??{}),g=i(((F=m.openai)==null?void 0:F.modelRoutes)??{}),k={...p,providers:n,modelRoutes:h,endpointRouting:{anthropic:{defaults:((U=m.anthropic)==null?void 0:U.defaults)??p.defaults,modelRoutes:h},openai:{defaults:((G=m.openai)==null?void 0:G.defaults)??p.defaults,modelRoutes:g}}};try{await W.put("/api/config",k),C(k),$({anthropic:Y(h),openai:Y(g)}),a({title:t("providers.toast.deleteSuccess",{name:s.label||s.id}),variant:"success"}),c.refetch()}catch(B){a({title:t("providers.toast.deleteFailure",{message:B instanceof Error?B.message:"unknown"}),variant:"error"})}},cs=s=>{$(l=>({...l,[s]:[...l[s]||[],{id:We(),source:"",target:""}]})),V(l=>({...l,[s]:null}))},us=async(s,l)=>{if(ae()){at(!0);try{if(s==="anthropic"||s==="openai"){const n=p.endpointRouting?{...p.endpointRouting}:{},i=n[s]??{defaults:p.defaults,modelRoutes:(s==="anthropic"?p.modelRoutes:{})??{}},m={defaults:i.defaults??p.defaults,modelRoutes:i.modelRoutes??{}};let h=i.validation;l?(h={...h??{},mode:"claude-code"},h.allowExperimentalBlocks===void 0&&(h.allowExperimentalBlocks=!0)):h=void 0;const g=h?{...m,validation:h}:{...m},k={...n,[s]:g},R={...p,endpointRouting:k};await W.put("/api/config",R),C(R)}else{const n=p.customEndpoints??[],i=n.findIndex(G=>G.id===s);if(i===-1)throw new Error(t("modelManagement.toast.endpointNotFound"));const m=n[i],h=m.routing??{defaults:p.defaults,modelRoutes:{}};let g=h.validation;l?(g={...g??{},mode:"claude-code"},g.allowExperimentalBlocks===void 0&&(g.allowExperimentalBlocks=!0)):g=void 0;const k=g?{...h,validation:g}:{...h},R={...m,routing:k},F=[...n];F[i]=R;const U={...p,customEndpoints:F};await W.put("/api/config",U),C(U)}a({title:t(l?"modelManagement.toast.claudeValidationEnabled":"modelManagement.toast.claudeValidationDisabled"),variant:"success"}),c.refetch()}catch(n){const i=Ie(n);a({title:t("modelManagement.toast.claudeValidationFailure",{message:i.message}),variant:"error"})}finally{at(!1)}}},ms=(s,l)=>{$(n=>{const i=n[s]||[];return i.some(m=>m.source.trim()===l.trim())?n:{...n,[s]:[...i,{id:We(),source:l,target:""}]}}),V(n=>({...n,[s]:null}))},it=(s,l,n,i)=>{$(m=>({...m,[s]:(m[s]||[]).map(h=>h.id===l?{...h,[n]:i}:h)})),V(m=>({...m,[s]:null}))},ps=(s,l)=>{$(n=>({...n,[s]:(n[s]||[]).filter(i=>i.id!==l)})),V(n=>({...n,[s]:null}))},hs=s=>{var n,i;if(!p)return;const l=x.find(m=>m.id===s);if(l){const m=((n=l.routing)==null?void 0:n.modelRoutes)??{};$(h=>({...h,[s]:Y(m)}))}else{const m=p.endpointRouting??{},h=s,g=h==="anthropic"?p.modelRoutes??{}:{},k=((i=m[h])==null?void 0:i.modelRoutes)??g;$(R=>({...R,[s]:Y(k)}))}V(m=>({...m,[s]:null}))},xs=async s=>{var i;if(!ae())return;const l=J[s]||[],n={};for(const m of l){const h=m.source.trim(),g=m.target.trim();if(!(!h&&!g)){if(!h||!g){V(k=>({...k,[s]:t("settings.validation.routePair")}));return}if(n[h]){V(k=>({...k,[s]:t("settings.validation.routeDuplicate",{model:h})}));return}n[h]=g}}V(m=>({...m,[s]:null})),ce(s);try{const m=x.find(h=>h.id===s);if(m){const h={...m.routing||{},modelRoutes:n,defaults:((i=m.routing)==null?void 0:i.defaults)||p.defaults};await we.update(s,{routing:h}),o.invalidateQueries({queryKey:["custom-endpoints"]}),a({title:t("modelManagement.toast.routesSaved"),variant:"success"})}else{const h=p.endpointRouting?{...p.endpointRouting}:{},g=s,k=h[g]??{defaults:p.defaults,modelRoutes:g==="anthropic"?p.modelRoutes??{}:{}},R={...k,defaults:k.defaults??p.defaults,modelRoutes:n},F={...h,[g]:R},U={...p,endpointRouting:F,modelRoutes:g==="anthropic"?n:p.modelRoutes??{}};await W.put("/api/config",U),C(U),a({title:t("modelManagement.toast.routesSaved"),variant:"success"}),c.refetch()}$(h=>({...h,[s]:Y(n)}))}catch(m){a({title:t("modelManagement.toast.routesSaveFailure",{message:m instanceof Error?m.message:"unknown"}),variant:"error"})}finally{ce(null)}},fs=()=>e.jsx(qe,{children:e.jsxs(He,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:t("providers.title")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t("providers.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(Q,{variant:"secondary",children:t("providers.count",{count:Qt})}),e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>c.refetch(),disabled:c.isFetching,children:[e.jsx(Ys,{className:ke("mr-2 h-4 w-4",c.isFetching&&"animate-spin")}),c.isFetching?t("common.actions.refreshing"):t("providers.actions.refresh")]}),e.jsxs(I,{size:"sm",onClick:as,children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),t("providers.actions.add")]})]})]}),c.isPending||!p&&c.isFetching?e.jsx("div",{className:"flex min-h-[200px] items-center justify-center rounded-lg border bg-muted/50 text-sm text-muted-foreground",children:t("common.loading")}):q.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:t("providers.emptyState")}),e.jsx("p",{className:"mt-2 text-xs",children:t("providers.emptyStateSub",{default:"点击上方按钮添加您的第一个提供商"})})]}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:q.map(s=>e.jsx(qe,{className:"flex flex-col",children:e.jsxs(He,{className:"flex flex-1 flex-col gap-4 pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:s.label||s.id}),s.type&&e.jsx(Ca,{type:s.type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["ID: ",s.id]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",children:s.baseUrl})]}),s.defaultModel?e.jsx(Q,{variant:"default",className:"text-xs",children:Jt.get(s.id)??s.defaultModel}):e.jsx(Q,{variant:"secondary",className:"text-xs",children:t("providers.card.noDefault")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{className:"text-xs",children:t("providers.card.modelsTitle")}),s.models&&s.models.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:s.models.map(l=>e.jsx(Q,{variant:"outline",className:"text-xs",children:ft(l)},l.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:t("providers.card.noModels")})]}),e.jsxs("div",{className:"mt-auto flex flex-wrap gap-2 pt-4 border-t",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:()=>rs(s),children:t("providers.actions.edit")}),e.jsx(I,{variant:"outline",size:"sm",onClick:()=>ls(s),disabled:_===s.id,children:_===s.id?t("common.actions.testingConnection"):t("providers.actions.test")}),e.jsx(I,{variant:"destructive",size:"sm",onClick:()=>ds(s),children:t("providers.actions.delete")})]})]})},s.id))})]})}),gs=s=>{const l=Re[s]??[],n=Se[s]??"",i=b[s],m=S===s,h=Ht[s]===!0;return e.jsxs("div",{className:"rounded-lg border border-dashed bg-muted/30",children:[e.jsx("button",{type:"button",className:"flex w-full items-center justify-between gap-3 p-4 text-left hover:bg-muted/50 transition-colors",onClick:()=>Gt(g=>({...g,[s]:!h})),children:e.jsxs("div",{className:"flex items-center gap-2",children:[h?e.jsx(Ws,{className:"h-4 w-4"}):e.jsx(Ls,{className:"h-4 w-4"}),e.jsx("h3",{className:"font-medium",children:t("modelManagement.presets.title")}),e.jsx(Q,{variant:"secondary",className:"text-xs",children:l.length})]})}),h&&e.jsxs("div",{className:"border-t px-4 pb-4 pt-3 space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("modelManagement.presets.description")}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center",children:[e.jsx(xe,{value:n,onChange:g=>Zt(s,g.target.value),placeholder:t("modelManagement.presets.namePlaceholder"),disabled:m,className:"w-full md:w-48"}),e.jsx(I,{onClick:()=>void es(s),disabled:m,children:t(m?"modelManagement.presets.saving":"modelManagement.presets.save")})]}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:t("modelManagement.presets.empty")}):e.jsx($s,{children:e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(g=>{const k=(A==null?void 0:A.endpoint)===s&&(A==null?void 0:A.name)===g.name,R=(K==null?void 0:K.endpoint)===s&&(K==null?void 0:K.name)===g.name,F=Object.entries(g.modelRoutes??{}),U=F.length;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border bg-card px-4 py-3",children:[e.jsxs(Ks,{children:[e.jsx(zs,{asChild:!0,children:e.jsxs("div",{className:"min-w-0 flex-1 cursor-default",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:g.name}),e.jsx(Q,{variant:"outline",className:"mt-1 text-xs",children:U>0?t("modelManagement.presets.rulesCount",{count:U}):t("modelManagement.presets.noRules")})]})}),U>0&&e.jsx(Bs,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[F.slice(0,5).map(([G,B])=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"truncate",children:G}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:B})]},G)),U>5&&e.jsxs("div",{className:"text-muted-foreground",children:["…+",U-5]})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(I,{size:"sm",onClick:()=>ze({endpoint:s,preset:g}),disabled:k||R,children:t(k?"modelManagement.presets.applying":"modelManagement.presets.apply")}),e.jsx(I,{variant:"destructive",size:"sm",onClick:()=>void ss(s,g),disabled:R||k,children:t(R?"modelManagement.presets.deleting":"modelManagement.presets.delete")})]})]},g.name)})})})]})]})},bs=s=>{var le;const l=J[s]||[],n=Fe[s],i=r.find(T=>T.key===s),h=((le=i==null?void 0:i.protocols)==null?void 0:le.includes("anthropic"))??s==="anthropic"?ba:va,g=_e===s,k=rt[s]??!1,R=(i==null?void 0:i.label)??t(`modelManagement.tabs.${s}`),F=(i==null?void 0:i.isSystem)===!1?i.description:t(`settings.routing.descriptionByEndpoint.${s}`),U=`route-source-${s}`,G=ya(s,x),B=Na(s,p,x),ne=G&&(B==null?void 0:B.mode)==="claude-code",Be=new Set(l.map(T=>T.source.trim()).filter(Boolean));return e.jsx(qe,{children:e.jsxs(He,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-semibold",children:t("settings.routing.titleByEndpoint",{endpoint:R})}),e.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:F}),e.jsx("p",{className:"max-w-3xl text-xs text-muted-foreground",children:t("settings.routing.wildcardHint")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:()=>cs(s),disabled:g,children:t("settings.routing.add")}),e.jsx(I,{variant:"outline",size:"sm",onClick:()=>hs(s),disabled:g,children:t("common.actions.reset")}),e.jsxs(I,{size:"sm",onClick:()=>void xs(s),disabled:g,className:"relative",children:[t(g?"common.actions.saving":"modelManagement.actions.saveRoutes"),k&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-amber-500"})]})]})]}),G&&e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:t("modelManagement.claudeValidation.title")}),e.jsx("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:t("modelManagement.claudeValidation.description")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ct,{checked:ne,onCheckedChange:T=>void us(s,T),disabled:qt}),e.jsx("span",{className:ke("text-xs font-medium",ne?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:t(ne?"modelManagement.claudeValidation.statusEnabled":"modelManagement.claudeValidation.statusDisabled")})]})]})}),gs(s),n&&e.jsx("p",{className:"text-sm text-destructive",children:n}),l.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:t("settings.routing.empty")}),e.jsx("p",{className:"mt-2 text-xs",children:t("settings.routing.emptySub",{default:"点击上方按钮添加路由规则"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] items-center gap-3 px-1 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{children:t("settings.routing.source")}),e.jsx("span",{}),e.jsx("span",{children:t("settings.routing.target")}),e.jsx("span",{})]}),l.map(T=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] items-center gap-3",children:[e.jsx(xe,{value:T.source,onChange:ie=>it(s,T.id,"source",ie.target.value),placeholder:t("settings.routing.sourcePlaceholder"),list:U,disabled:g}),e.jsx(he,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(wa,{value:T.target,onChange:ie=>it(s,T.id,"target",ie),options:Xt,disabled:g,placeholder:t("settings.routing.targetPlaceholder")}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>ps(s,T.id),disabled:g,children:e.jsx(Te,{className:"h-4 w-4"})})]},T.id))]}),e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-3",children:[e.jsx(de,{children:t("settings.routing.suggested")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(T=>{const ie=Be.has(T);return e.jsx(I,{variant:ie?"ghost":"outline",size:"sm",onClick:()=>ms(s,T),disabled:g||ie,className:ie?"opacity-50":"",children:T},`${s}-${T}`)})})]}),e.jsx("datalist",{id:U,children:h.map(T=>e.jsx("option",{value:T},`${U}-${T}`))})]})})};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Hs,{icon:e.jsx(_s,{className:"h-5 w-5","aria-hidden":"true"}),title:t("modelManagement.title"),description:t("modelManagement.description"),actions:e.jsxs(I,{onClick:()=>{Pe(void 0),Ee(!0)},children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),t("modelManagement.addEndpoint")]})}),e.jsx("div",{className:"flex flex-wrap gap-3",children:r.map(s=>{const l=u===s.key,n=s.key!=="providers"&&rt[s.key];return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>v(s.key),className:ke("flex min-w-[200px] flex-col gap-1 rounded-lg border px-4 py-3 text-left transition-all",l?"border-primary bg-primary/5 text-primary":"border-border bg-card hover:bg-accent"),children:[e.jsxs("span",{className:"font-medium flex items-center gap-2",children:[s.label,n&&e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.description})]}),s.canDelete&&e.jsx("button",{onClick:i=>{i.stopPropagation(),ns(s.key)},className:"absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground text-xs hover:bg-destructive/90",title:t("common.delete"),children:e.jsx(Te,{className:"h-3 w-3"})})]},s.key)})}),u==="providers"?fs():bs(u),e.jsx(ga,{open:D,mode:M,provider:M==="edit"?j:void 0,existingProviderIds:q.map(s=>s.id).filter(s=>M==="edit"&&j?s!==j.id:!0),onClose:()=>{P(!1),E(void 0),N("create")},onSubmit:os}),e.jsx(Ea,{open:Ce,endpoint:be,onClose:()=>{Ee(!1),Pe(void 0)},onSuccess:()=>{o.invalidateQueries({queryKey:["custom-endpoints"]})}}),e.jsx(ka,{open:De,provider:Le,options:ye,preservedExtras:tt,usePreset:Oe,onPresetChange:$e,onConfirm:is,onClose:lt}),e.jsx(Ma,{dialog:Ke,currentRoutes:Ke?J[Ke.endpoint]||[]:[],onConfirm:(s,l)=>{ze(null),ts(s,l)},onClose:()=>ze(null)})]})}function ka({open:t,provider:a,options:o,usePreset:c,preservedExtras:d,onPresetChange:x,onConfirm:r,onClose:u}){const{t:v}=ge();return a?e.jsx(Et,{open:t,onOpenChange:p=>!p&&u(),children:e.jsxs(Pt,{children:[e.jsxs(Rt,{children:[e.jsx(St,{children:v("providers.testDialog.title")}),e.jsx(Dt,{children:v("providers.testDialog.subtitle",{name:a.label||a.id})})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:v("providers.testDialog.description")}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-4",children:[e.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border",checked:c,onChange:p=>x(p.target.checked)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{children:v("providers.testDialog.presetLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v("providers.testDialog.presetDescription")}),e.jsxs("details",{className:"rounded-md bg-muted p-2 text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-primary hover:underline",children:v("providers.testDialog.presetPreviewSummary")}),e.jsx("div",{className:"mt-2 space-y-1",children:o.map(p=>e.jsxs("code",{className:"block rounded bg-background px-2 py-1 text-xs",children:[p.key,": ",p.value]},p.key))})]})]})]}),Object.keys(d).length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted p-4 text-xs space-y-2",children:[e.jsx("p",{className:"font-medium",children:v("providers.testDialog.preservedInfo")}),Object.entries(d).map(([p,C])=>e.jsxs("code",{className:"block rounded bg-background px-2 py-1",children:[p,": ",C]},p))]})]}),e.jsxs(Ot,{children:[e.jsx(I,{variant:"outline",onClick:u,children:v("providers.testDialog.cancel")}),e.jsx(I,{onClick:()=>void r(),children:v("providers.testDialog.primary")})]})]})}):null}function wa({value:t,onChange:a,options:o,disabled:c,placeholder:d}){const{t:x}=ge(),[r,u]=f.useState(!1),[v,p]=f.useState(""),C=f.useRef(null),D=f.useMemo(()=>{if(!v.trim())return o;const M=v.toLowerCase();return o.filter(N=>N.label.toLowerCase().includes(M)||N.value.toLowerCase().includes(M))},[o,v]),P=M=>{a(M),p(""),u(!1)};return e.jsxs(pa,{open:r,onOpenChange:M=>{u(M),M&&p("")},children:[e.jsx(ha,{asChild:!0,children:e.jsx(xe,{ref:C,value:t,onChange:M=>{a(M.target.value),p(M.target.value),r||u(!0)},onFocus:()=>{p(""),u(!0)},onClick:()=>{r||u(!0)},placeholder:d,disabled:c,autoComplete:"off"})}),e.jsx(Vt,{className:"w-[var(--radix-popover-trigger-width)] max-h-60 overflow-y-auto p-1",align:"start",onOpenAutoFocus:M=>M.preventDefault(),children:D.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:x("common.noMatches")}):D.map(M=>e.jsx("button",{type:"button",className:ke("flex w-full items-center rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent",M.value===t.trim()&&"bg-accent"),onMouseDown:N=>{N.preventDefault(),P(M.value)},children:e.jsx("span",{className:"truncate",children:M.label})},M.value))})]})}function Ma({dialog:t,currentRoutes:a,onConfirm:o,onClose:c}){const{t:d}=ge();if(!t)return null;const{endpoint:x,preset:r}=t,u=r.modelRoutes??{},v={};for(const N of a){const j=N.source.trim(),E=N.target.trim();j&&E&&(v[j]=E)}const p=new Set([...Object.keys(v),...Object.keys(u)]),C=[],D=[],P=[];for(const N of p){const j=N in v,E=N in u;E&&!j?C.push([N,u[N]]):j&&!E?D.push([N,v[N]]):j&&E&&v[N]!==u[N]&&P.push([N,v[N],u[N]])}const M=C.length>0||D.length>0||P.length>0;return e.jsx(Et,{open:!0,onOpenChange:N=>!N&&c(),children:e.jsxs(Pt,{className:"max-w-lg",children:[e.jsxs(Rt,{children:[e.jsx(St,{children:d("modelManagement.presets.diffTitle")}),e.jsx(Dt,{children:d("modelManagement.presets.diffDescription",{name:r.name})})]}),M?e.jsxs("div",{className:"max-h-72 overflow-y-auto space-y-2 text-sm",children:[C.map(([N,j])=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 bg-emerald-50 dark:bg-emerald-950 text-emerald-800 dark:text-emerald-200",children:[e.jsx(Q,{variant:"outline",className:"text-xs border-emerald-300 dark:border-emerald-700",children:d("modelManagement.presets.diffAdded")}),e.jsx("span",{className:"truncate",children:N}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:j})]},`add-${N}`)),D.map(([N,j])=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 bg-red-50 dark:bg-red-950 text-red-800 dark:text-red-200",children:[e.jsx(Q,{variant:"outline",className:"text-xs border-red-300 dark:border-red-700",children:d("modelManagement.presets.diffRemoved")}),e.jsx("span",{className:"truncate",children:N}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:j})]},`rm-${N}`)),P.map(([N,j,E])=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 bg-amber-50 dark:bg-amber-950 text-amber-800 dark:text-amber-200",children:[e.jsx(Q,{variant:"outline",className:"text-xs border-amber-300 dark:border-amber-700",children:d("modelManagement.presets.diffChanged")}),e.jsx("span",{className:"truncate",children:N}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate line-through opacity-60",children:j}),e.jsx(he,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:E})]},`chg-${N}`))]}):e.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:d("modelManagement.presets.diffEmpty")}),e.jsxs(Ot,{children:[e.jsx(I,{variant:"outline",onClick:c,children:d("common.cancel")}),e.jsx(I,{onClick:()=>o(x,r),disabled:!M,children:d("modelManagement.presets.diffConfirm")})]})]})})}function ft(t){return t.label&&t.label.trim().length>0?`${t.label} (${t.id})`:t.id}function Ca({type:t}){const a={openai:{label:"OpenAI",variant:"success"},deepseek:{label:"DeepSeek",variant:"info"},huawei:{label:"华为云",variant:"warning"},kimi:{label:"Kimi",variant:"purple"},anthropic:{label:"Anthropic",variant:"pink"},custom:{label:"Custom",variant:"secondary"}},{label:o,variant:c}=a[t]||a.custom;return e.jsx(Q,{variant:c,className:"text-xs",children:o})}function Ea({open:t,endpoint:a,onClose:o,onSuccess:c}){const{t:d}=ge(),{pushToast:x}=Mt(),[r,u]=f.useState({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0});f.useEffect(()=>{if(a){let j;a.paths&&a.paths.length>0?j=a.paths:a.path&&a.protocol?j=[{path:a.path,protocol:a.protocol}]:j=[{path:"",protocol:"openai-auto"}],u({id:a.id,label:a.label,paths:j,enabled:a.enabled!==!1})}else u({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0})},[a,t]);const v=mt({mutationFn:we.create,onSuccess:()=>{x({title:d("modelManagement.createEndpointSuccess"),variant:"success"}),c(),o()},onError:j=>{const E=Ie(j);x({title:d("modelManagement.createEndpointError",{error:E.message}),variant:"error"})}}),p=mt({mutationFn:j=>we.update(j.id,j.updates),onSuccess:()=>{x({title:d("modelManagement.updateEndpointSuccess"),variant:"success"}),c(),o()},onError:j=>{const E=Ie(j);x({title:d("modelManagement.updateEndpointError",{error:E.message}),variant:"error"})}}),C=()=>{u({...r,paths:[...r.paths,{path:"",protocol:"anthropic"}]})},D=j=>{if(r.paths.length===1){x({title:d("modelManagement.atLeastOnePath"),variant:"error"});return}const E=r.paths.filter((_,L)=>L!==j);u({...r,paths:E})},P=(j,E,_)=>{const L=[...r.paths];L[j]={...L[j],[E]:_},u({...r,paths:L})},M=j=>{if(j.preventDefault(),!r.id.trim()||!r.label.trim()){x({title:d("modelManagement.endpointValidationError"),variant:"error"});return}for(const _ of r.paths)if(!_.path.trim()){x({title:d("modelManagement.pathValidationError"),variant:"error"});return}const E=r.paths.map(_=>({path:_.path.trim(),protocol:_.protocol}));a?p.mutate({id:a.id,updates:{label:r.label.trim(),paths:E,enabled:r.enabled}}):v.mutate({id:r.id.trim(),label:r.label.trim(),paths:E,enabled:r.enabled})},N=v.isPending||p.isPending;return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-40",onClick:o}),e.jsx("div",{className:"fixed inset-y-0 right-0 w-full max-w-md bg-card border-l shadow-xl z-50",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b",children:[e.jsx("h2",{className:"text-lg font-semibold",children:d(a?"modelManagement.editEndpoint":"modelManagement.createEndpoint")}),e.jsx(I,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(Te,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{children:[d("modelManagement.endpointId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(xe,{value:r.id,onChange:j=>u({...r,id:j.target.value}),placeholder:d("modelManagement.endpointIdPlaceholder"),disabled:!!a,required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d("modelManagement.endpointIdHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(de,{children:[d("modelManagement.endpointLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(xe,{value:r.label,onChange:j=>u({...r,label:j.target.value}),placeholder:d("modelManagement.endpointLabelPlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(de,{children:[d("modelManagement.endpointPaths")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(I,{type:"button",variant:"ghost",size:"sm",onClick:C,children:[e.jsx(Je,{className:"mr-1 h-3 w-3"}),d("modelManagement.addPath")]})]}),e.jsx("div",{className:"space-y-3",children:r.paths.map((j,E)=>e.jsxs("div",{className:"rounded-lg border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(xe,{value:j.path,onChange:_=>P(E,"path",_.target.value),placeholder:d("modelManagement.endpointPathPlaceholder"),required:!0}),e.jsxs(Gs,{value:j.protocol,onValueChange:_=>P(E,"protocol",_),children:[e.jsx(Qs,{children:e.jsx(Js,{})}),e.jsxs(Xs,{children:[e.jsx(ut,{value:"anthropic",children:d("modelManagement.protocolAnthropic")}),e.jsx(ut,{value:"openai-auto",children:d("modelManagement.protocolOpenAI")})]})]})]}),r.paths.length>1&&e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>D(E),className:"text-destructive",children:e.jsx(Te,{className:"h-4 w-4"})})]}),E===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:d("modelManagement.endpointPathHint")})]},E))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ct,{id:"enabled",checked:r.enabled,onCheckedChange:j=>u({...r,enabled:j})}),e.jsx(de,{htmlFor:"enabled",children:d("modelManagement.endpointEnabled")})]}),!a&&e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:d("modelManagement.endpointRoutingHint")})})]}),e.jsxs("div",{className:"flex gap-3 p-6 border-t",children:[e.jsx(I,{variant:"outline",className:"flex-1",onClick:o,disabled:N,children:d("common.cancel")}),e.jsx(I,{className:"flex-1",onClick:M,disabled:N,children:d(N?"common.saving":a?"common.save":"common.create")})]})]})})]}):null}export{La as default};
@@ -1 +1 @@
1
- import{j as r,a as s,am as n}from"./index-B_ZdlwhD.js";const l=n("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 shadow-sm",{variants:{variant:{default:"border-primary/20 bg-primary/10 text-primary hover:bg-primary/15 dark:border-primary/30 dark:bg-primary/20 dark:text-primary-foreground",secondary:"border-slate-200 bg-slate-100 text-slate-700 hover:bg-slate-200 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300",destructive:"border-red-200 bg-gradient-to-r from-red-50 to-red-100 text-red-700 hover:from-red-100 hover:to-red-150 dark:border-red-800 dark:from-red-950 dark:to-red-900 dark:text-red-300",outline:"border-slate-300 bg-transparent text-slate-600 hover:bg-slate-50 dark:border-slate-600 dark:text-slate-400 dark:hover:bg-slate-800",success:"border-emerald-200 bg-gradient-to-r from-emerald-50 to-emerald-100 text-emerald-700 hover:from-emerald-100 hover:to-emerald-150 dark:border-emerald-800 dark:from-emerald-950 dark:to-emerald-900 dark:text-emerald-300",warning:"border-amber-200 bg-gradient-to-r from-amber-50 to-amber-100 text-amber-700 hover:from-amber-100 hover:to-amber-150 dark:border-amber-800 dark:from-amber-950 dark:to-amber-900 dark:text-amber-300",info:"border-cyan-200 bg-gradient-to-r from-cyan-50 to-cyan-100 text-cyan-700 hover:from-cyan-100 hover:to-cyan-150 dark:border-cyan-800 dark:from-cyan-950 dark:to-cyan-900 dark:text-cyan-300",purple:"border-violet-200 bg-gradient-to-r from-violet-50 to-violet-100 text-violet-700 hover:from-violet-100 hover:to-violet-150 dark:border-violet-800 dark:from-violet-950 dark:to-violet-900 dark:text-violet-300",pink:"border-pink-200 bg-gradient-to-r from-pink-50 to-pink-100 text-pink-700 hover:from-pink-100 hover:to-pink-150 dark:border-pink-800 dark:from-pink-950 dark:to-pink-900 dark:text-pink-300"}},defaultVariants:{variant:"default"}});function m({className:e,variant:t,...a}){return r.jsx("div",{className:s(l({variant:t}),e),...a})}function f({icon:e,title:t,description:a,badge:o,actions:d,className:i}){return r.jsxs("div",{className:s("flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",i),children:[r.jsxs("div",{className:"flex flex-1 flex-wrap items-start gap-4",children:[e&&r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t}),o&&r.jsx(m,{variant:"secondary",children:o})]}),a&&r.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:a})]})]}),d&&r.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:d})]})}export{m as B,f as P};
1
+ import{j as r,a as s,am as n}from"./index-Bdp0nMlR.js";const l=n("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 shadow-sm",{variants:{variant:{default:"border-primary/20 bg-primary/10 text-primary hover:bg-primary/15 dark:border-primary/30 dark:bg-primary/20 dark:text-primary-foreground",secondary:"border-slate-200 bg-slate-100 text-slate-700 hover:bg-slate-200 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300",destructive:"border-red-200 bg-gradient-to-r from-red-50 to-red-100 text-red-700 hover:from-red-100 hover:to-red-150 dark:border-red-800 dark:from-red-950 dark:to-red-900 dark:text-red-300",outline:"border-slate-300 bg-transparent text-slate-600 hover:bg-slate-50 dark:border-slate-600 dark:text-slate-400 dark:hover:bg-slate-800",success:"border-emerald-200 bg-gradient-to-r from-emerald-50 to-emerald-100 text-emerald-700 hover:from-emerald-100 hover:to-emerald-150 dark:border-emerald-800 dark:from-emerald-950 dark:to-emerald-900 dark:text-emerald-300",warning:"border-amber-200 bg-gradient-to-r from-amber-50 to-amber-100 text-amber-700 hover:from-amber-100 hover:to-amber-150 dark:border-amber-800 dark:from-amber-950 dark:to-amber-900 dark:text-amber-300",info:"border-cyan-200 bg-gradient-to-r from-cyan-50 to-cyan-100 text-cyan-700 hover:from-cyan-100 hover:to-cyan-150 dark:border-cyan-800 dark:from-cyan-950 dark:to-cyan-900 dark:text-cyan-300",purple:"border-violet-200 bg-gradient-to-r from-violet-50 to-violet-100 text-violet-700 hover:from-violet-100 hover:to-violet-150 dark:border-violet-800 dark:from-violet-950 dark:to-violet-900 dark:text-violet-300",pink:"border-pink-200 bg-gradient-to-r from-pink-50 to-pink-100 text-pink-700 hover:from-pink-100 hover:to-pink-150 dark:border-pink-800 dark:from-pink-950 dark:to-pink-900 dark:text-pink-300"}},defaultVariants:{variant:"default"}});function m({className:e,variant:t,...a}){return r.jsx("div",{className:s(l({variant:t}),e),...a})}function f({icon:e,title:t,description:a,badge:o,actions:d,className:i}){return r.jsxs("div",{className:s("flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",i),children:[r.jsxs("div",{className:"flex flex-1 flex-wrap items-start gap-4",children:[e&&r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-primary/10 text-primary",children:e}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t}),o&&r.jsx(m,{variant:"secondary",children:o})]}),a&&r.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:a})]})]}),d&&r.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:d})]})}export{m as B,f as P};
@@ -1 +1 @@
1
- import{j as s,a as d}from"./index-B_ZdlwhD.js";import{C as m,b as l,c as i,d as j,a as f}from"./card-CtgEZD37.js";function p({title:a,description:e,actions:r,className:n,contentClassName:x,children:c}){const t=a||e||r;return s.jsxs(m,{className:n,children:[t&&s.jsxs(l,{className:"flex flex-row items-start justify-between space-y-0",children:[s.jsxs("div",{className:"space-y-1.5",children:[typeof a=="string"?s.jsx(i,{className:"text-base",children:a}):a,e&&(typeof e=="string"?s.jsx(j,{children:e}):s.jsx("div",{className:"text-sm text-muted-foreground",children:e}))]}),r&&s.jsx("div",{className:"flex shrink-0 items-center gap-2",children:r})]}),s.jsx(f,{className:d(!t&&"pt-6",x),children:c})]})}export{p as P};
1
+ import{j as s,a as d}from"./index-Bdp0nMlR.js";import{C as m,b as l,c as i,d as j,a as f}from"./card-Dl49soGw.js";function p({title:a,description:e,actions:r,className:n,contentClassName:x,children:c}){const t=a||e||r;return s.jsxs(m,{className:n,children:[t&&s.jsxs(l,{className:"flex flex-row items-start justify-between space-y-0",children:[s.jsxs("div",{className:"space-y-1.5",children:[typeof a=="string"?s.jsx(i,{className:"text-base",children:a}):a,e&&(typeof e=="string"?s.jsx(j,{children:e}):s.jsx("div",{className:"text-sm text-muted-foreground",children:e}))]}),r&&s.jsx("div",{className:"flex shrink-0 items-center gap-2",children:r})]}),s.jsx(f,{className:d(!t&&"pt-6",x),children:c})]})}export{p as P};
@@ -1,4 +1,4 @@
1
- import{c as Oe,u as Be,b as _e,r as m,j as e,e as S,a3 as Ge,W as be,a as Qe,d as O}from"./index-B_ZdlwhD.js";import{u as fe}from"./useApiQuery-DNDJWhHp.js";import{P as We}from"./PageHeader-C2Un_Eq9.js";import{c as ze}from"./clipboard-CALi6bTW.js";import{I as j}from"./input-BJXToHiR.js";import{L as c}from"./label-CzVczRHt.js";import{C as E,a as F}from"./card-CtgEZD37.js";import{S as L}from"./switch-DteEzH7T.js";import{S as $e,a as Je,b as Ue,c as Xe,d as Ye}from"./select-B1I4kItt.js";import{S as Ze,C as et}from"./shield-DceCQI6h.js";/**
1
+ import{c as Oe,u as Be,b as _e,r as m,j as e,e as S,a3 as Ge,W as be,a as Qe,d as O}from"./index-Bdp0nMlR.js";import{u as fe}from"./useApiQuery-CL9_n4sn.js";import{P as We}from"./PageHeader-D2Zq1K4t.js";import{c as ze}from"./clipboard-CALi6bTW.js";import{I as j}from"./input-B6w5gzdL.js";import{L as c}from"./label-CuU6RIsU.js";import{C as E,a as F}from"./card-Dl49soGw.js";import{S as L}from"./switch-DoT-Ur3p.js";import{S as $e,a as Je,b as Ue,c as Xe,d as Ye}from"./select-Cfzsn-JK.js";import{S as Ze,C as et}from"./shield--mDWO-No.js";/**
2
2
  * @license lucide-react v0.344.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{j as s,a as n}from"./index-B_ZdlwhD.js";function e({className:a}){return s.jsx("div",{role:"status","aria-label":"Loading",className:n("animate-pulse rounded-md bg-muted",a)})}function d(){return s.jsxs("div",{className:"rounded-xl border bg-card p-5 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(e,{className:"h-3 w-24"}),s.jsx(e,{className:"h-10 w-10 rounded-xl"})]}),s.jsx(e,{className:"h-8 w-32"})]})}function o(){return s.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(e,{className:"h-4 w-32"}),s.jsx(e,{className:"h-3 w-48"})]}),s.jsx(e,{className:"h-[320px] w-full rounded-lg"})]})}function m({columns:a=6}){const r=["w-24","w-16","w-20","w-28","w-14","w-12","w-20","w-16","w-14","w-12"];return s.jsx("tr",{className:"border-b",children:Array.from({length:a}).map((t,l)=>s.jsx("td",{className:"px-3 py-3",children:s.jsx(e,{className:n("h-4",r[l%r.length])})},l))})}export{o as C,d as S,m as T,e as a};
1
+ import{j as s,a as n}from"./index-Bdp0nMlR.js";function e({className:a}){return s.jsx("div",{role:"status","aria-label":"Loading",className:n("animate-pulse rounded-md bg-muted",a)})}function d(){return s.jsxs("div",{className:"rounded-xl border bg-card p-5 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(e,{className:"h-3 w-24"}),s.jsx(e,{className:"h-10 w-10 rounded-xl"})]}),s.jsx(e,{className:"h-8 w-32"})]})}function o(){return s.jsxs("div",{className:"rounded-xl border bg-card p-4 space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(e,{className:"h-4 w-32"}),s.jsx(e,{className:"h-3 w-48"})]}),s.jsx(e,{className:"h-[320px] w-full rounded-lg"})]})}function m({columns:a=6}){const r=["w-24","w-16","w-20","w-28","w-14","w-12","w-20","w-16","w-14","w-12"];return s.jsx("tr",{className:"border-b",children:Array.from({length:a}).map((t,l)=>s.jsx("td",{className:"px-3 py-3",children:s.jsx(e,{className:n("h-4",r[l%r.length])})},l))})}export{o as C,d as S,m as T,e as a};
@@ -1 +1 @@
1
- import{r as s,j as t,a as d,am as n}from"./index-B_ZdlwhD.js";const i=n("rounded-xl border bg-card text-card-foreground transition-all duration-200",{variants:{variant:{default:"shadow-sm hover:shadow-md",elevated:"shadow-md hover:shadow-lg",outline:"shadow-none border-2",ghost:"border-transparent shadow-none bg-transparent",interactive:"shadow-sm hover:shadow-lg hover:-translate-y-0.5 cursor-pointer"}},defaultVariants:{variant:"default"}}),l=s.forwardRef(({className:a,variant:e,...r},o)=>t.jsx("div",{ref:o,className:d(i({variant:e}),a),...r}));l.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-5",a),...e}));c.displayName="CardHeader";const m=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("text-lg font-semibold leading-none tracking-tight",a),...e}));m.displayName="CardTitle";const f=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("text-sm text-muted-foreground",a),...e}));f.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-5 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center p-5 pt-0",a),...e}));x.displayName="CardFooter";export{l as C,p as a,c as b,m as c,f as d,x as e};
1
+ import{r as s,j as t,a as d,am as n}from"./index-Bdp0nMlR.js";const i=n("rounded-xl border bg-card text-card-foreground transition-all duration-200",{variants:{variant:{default:"shadow-sm hover:shadow-md",elevated:"shadow-md hover:shadow-lg",outline:"shadow-none border-2",ghost:"border-transparent shadow-none bg-transparent",interactive:"shadow-sm hover:shadow-lg hover:-translate-y-0.5 cursor-pointer"}},defaultVariants:{variant:"default"}}),l=s.forwardRef(({className:a,variant:e,...r},o)=>t.jsx("div",{ref:o,className:d(i({variant:e}),a),...r}));l.displayName="Card";const c=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex flex-col space-y-1.5 p-5",a),...e}));c.displayName="CardHeader";const m=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("text-lg font-semibold leading-none tracking-tight",a),...e}));m.displayName="CardTitle";const f=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("text-sm text-muted-foreground",a),...e}));f.displayName="CardDescription";const p=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("p-5 pt-0",a),...e}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...e},r)=>t.jsx("div",{ref:r,className:d("flex items-center p-5 pt-0",a),...e}));x.displayName="CardFooter";export{l as C,p as a,c as b,m as c,f as d,x as e};