@chenpu17/cc-gw 0.8.13 → 0.8.15

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 (58) hide show
  1. package/package.json +5 -5
  2. package/src/web/dist/assets/{About-BtrUwqVl.js → About-BGBg2q_J.js} +1 -1
  3. package/src/web/dist/assets/{ApiKeys-BgtU9Z5t.js → ApiKeys-DUuKvZ5b.js} +1 -1
  4. package/src/web/dist/assets/{ConfirmDialog-BHrsB4gR.js → ConfirmDialog-BHfhtrze.js} +1 -1
  5. package/src/web/dist/assets/{Dashboard-DIguazuF.js → Dashboard-DZdfzGEK.js} +1 -1
  6. package/src/web/dist/assets/{DialogShell-DcG-SXEV.js → DialogShell-BpzUpswv.js} +1 -1
  7. package/src/web/dist/assets/{Events-mZNIWc7c.js → Events-9Yq8nG75.js} +1 -1
  8. package/src/web/dist/assets/Help-qSGvYIjs.js +5 -0
  9. package/src/web/dist/assets/{Login-DugtPFxy.js → Login-CJwzn0Sh.js} +1 -1
  10. package/src/web/dist/assets/{Logs-BJBm-efJ.js → Logs--D9Xm5KV.js} +1 -1
  11. package/src/web/dist/assets/ModelManagement-zi8mFqEf.js +1 -0
  12. package/src/web/dist/assets/{PageHeader--Lg_YQVw.js → PageHeader-DLI9m-gU.js} +1 -1
  13. package/src/web/dist/assets/{PageSection-DIAhP18t.js → PageSection-Mw-tAM8I.js} +1 -1
  14. package/src/web/dist/assets/{PageState-DKba6Ew1.js → PageState-Bb3fEov-.js} +1 -1
  15. package/src/web/dist/assets/{Profiler-DTPqRwx7.js → Profiler-D6Akb9_x.js} +1 -1
  16. package/src/web/dist/assets/RoutingManagement-CeIC-QD2.js +1 -0
  17. package/src/web/dist/assets/{Settings-Ddx0C5eQ.js → Settings-G5Pswxtq.js} +1 -1
  18. package/src/web/dist/assets/{Skeleton-cyuMRxwQ.js → Skeleton-DEv_MFPR.js} +1 -1
  19. package/src/web/dist/assets/app-CfipX5HX.js +61 -0
  20. package/src/web/dist/assets/{card-CwTuH2Iq.js → card-BE_b5SvI.js} +1 -1
  21. package/src/web/dist/assets/{charts-core-D9OugzV_.js → charts-core-DzWzxST6.js} +1 -1
  22. package/src/web/dist/assets/{charts-engine-DleyglMn.js → charts-engine-Ds7lwC51.js} +1 -1
  23. package/src/web/dist/assets/{charts-react-BqhUp1x_.js → charts-react-D0nWbUCA.js} +1 -1
  24. package/src/web/dist/assets/{gateway-CExOTXeI.js → gateway-Zpcl3bpd.js} +1 -1
  25. package/src/web/dist/assets/global-D8jT4xUX.css +1 -0
  26. package/src/web/dist/assets/{global-CKvMKvrn.js → global-xoXYOIOz.js} +1 -1
  27. package/src/web/dist/assets/{i18n-B3N4Df3E.js → i18n-Bl2BcCDG.js} +1 -1
  28. package/src/web/dist/assets/{input-scp9nKJc.js → input-Brr3avKW.js} +1 -1
  29. package/src/web/dist/assets/{label-fMXEnAEx.js → label-Bc4vkpLF.js} +1 -1
  30. package/src/web/dist/assets/landing-D9E0GJD9.js +17 -0
  31. package/src/web/dist/assets/live-en-api-keys-Bx8N-eoh.png +0 -0
  32. package/src/web/dist/assets/live-en-dashboard-CJoX7IQT.png +0 -0
  33. package/src/web/dist/assets/live-en-events-DJwaP-WW.png +0 -0
  34. package/src/web/dist/assets/live-en-logs-BGGL53ab.png +0 -0
  35. package/src/web/dist/assets/live-en-model-management-BpjNblfR.png +0 -0
  36. package/src/web/dist/assets/package-GpB9DOR2.js +1 -0
  37. package/src/web/dist/assets/{popover-BGSWKBlu.js → popover-D8l2FwYm.js} +1 -1
  38. package/src/web/dist/assets/{query-Cpxr1dul.js → query-BbGWgOFk.js} +1 -1
  39. package/src/web/dist/assets/{queryKeys-DTnZc8Yy.js → queryKeys-DifG1fTh.js} +1 -1
  40. package/src/web/dist/assets/{radix-bG5h1Ymq.js → radix-mHySgtou.js} +1 -1
  41. package/src/web/dist/assets/{router-DspBTS8b.js → router-CL3rf_uf.js} +1 -1
  42. package/src/web/dist/assets/{select-BjYpeVvo.js → select-zM5TPRdZ.js} +1 -1
  43. package/src/web/dist/assets/{switch-CgwYcn5P.js → switch-fb9u33D-.js} +1 -1
  44. package/src/web/dist/assets/{table-BtnjYcvG.js → table-BpLpq7tJ.js} +1 -1
  45. package/src/web/dist/assets/{useApiQuery-jSeDDFuv.js → useApiQuery-DCgUtGKI.js} +1 -1
  46. package/src/web/dist/assets/{useAppMutation-ChCrgiP6.js → useAppMutation-BjZN2gaQ.js} +1 -1
  47. package/src/web/dist/assets/useModelManagementState-1NXqPQ5M.js +1 -0
  48. package/src/web/dist/assets/{vendor-LWJeAdU1.js → vendor-z22RpOY0.js} +86 -66
  49. package/src/web/dist/index.html +8 -8
  50. package/src/web/dist/landing.html +11 -11
  51. package/src/web/dist/assets/Help-BHbnZJeo.js +0 -5
  52. package/src/web/dist/assets/ModelManagement-C32W7nDe.js +0 -1
  53. package/src/web/dist/assets/RoutingManagement-B9Z0l4LZ.js +0 -1
  54. package/src/web/dist/assets/app-BG16DmZH.js +0 -61
  55. package/src/web/dist/assets/global-CUpRxoFd.css +0 -1
  56. package/src/web/dist/assets/landing-CHY6qfgq.js +0 -5
  57. package/src/web/dist/assets/package-BMIMFcQR.js +0 -1
  58. package/src/web/dist/assets/useModelManagementState-9RhvWh8Y.js +0 -1
@@ -8,14 +8,14 @@
8
8
  <link rel="apple-touch-icon" href="/cc-gw-mark.svg" />
9
9
  <link rel="manifest" href="/site.webmanifest" />
10
10
  <title>cc-gw 控制台</title>
11
- <script type="module" crossorigin src="/assets/app-BG16DmZH.js"></script>
12
- <link rel="modulepreload" crossorigin href="/assets/vendor-LWJeAdU1.js">
13
- <link rel="modulepreload" crossorigin href="/assets/global-CKvMKvrn.js">
14
- <link rel="modulepreload" crossorigin href="/assets/query-Cpxr1dul.js">
15
- <link rel="modulepreload" crossorigin href="/assets/i18n-B3N4Df3E.js">
16
- <link rel="modulepreload" crossorigin href="/assets/router-DspBTS8b.js">
17
- <link rel="modulepreload" crossorigin href="/assets/radix-bG5h1Ymq.js">
18
- <link rel="stylesheet" crossorigin href="/assets/global-CUpRxoFd.css">
11
+ <script type="module" crossorigin src="/assets/app-CfipX5HX.js"></script>
12
+ <link rel="modulepreload" crossorigin href="/assets/vendor-z22RpOY0.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/global-xoXYOIOz.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/query-BbGWgOFk.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/i18n-Bl2BcCDG.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/router-CL3rf_uf.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/radix-mHySgtou.js">
18
+ <link rel="stylesheet" crossorigin href="/assets/global-D8jT4xUX.css">
19
19
  </head>
20
20
  <body class="bg-slate-50 text-slate-900 dark:bg-slate-900 dark:text-slate-50">
21
21
  <div id="root"></div>
@@ -8,25 +8,25 @@
8
8
  <meta name="apple-mobile-web-app-title" content="cc-gw" />
9
9
  <meta
10
10
  name="description"
11
- content="cc-gw 帮个人开发者和小团队把 AI 调用从项目里收回来:统一 OpenAI / Anthropic 协议入口,集中管理模型路由、日志、Profiler API Key。"
11
+ content="cc-gw is a local-first AI gateway. 把 Claude Code、OpenAI SDK、Anthropic SDK 全部指向同一个本地入口,换模型、换 provider、查日志,再也不用翻业务代码。"
12
12
  />
13
13
  <meta name="theme-color" content="#0f172a" />
14
14
  <link rel="icon" type="image/svg+xml" href="/cc-gw-mark.svg" />
15
15
  <link rel="apple-touch-icon" href="/cc-gw-mark.svg" />
16
16
  <link rel="manifest" href="/site.webmanifest" />
17
- <meta property="og:title" content="cc-gw | 别再让 AI 配置散落在每个项目里" />
17
+ <meta property="og:title" content="cc-gw | 你的 API Key 不该躺在 30 个 .env 里" />
18
18
  <meta
19
19
  property="og:description"
20
- content=" Claude CodeOpenAI SDKAnthropic SDK 和内部工具统一到一个本地优先入口,Key、路由、日志和排查回到控制台里管理。"
20
+ content="A local-first AI gateway. One endpoint for Claude Code, OpenAI SDK, and Anthropic SDK. Switch models, swap providers, and trace requests without touching your code."
21
21
  />
22
22
  <meta property="og:type" content="website" />
23
23
  <meta property="og:image" content="/cc-gw-social-card.png" />
24
24
  <meta property="og:image:alt" content="cc-gw landing share card showing a local-first AI gateway and daily control console" />
25
25
  <meta name="twitter:card" content="summary_large_image" />
26
- <meta name="twitter:title" content="cc-gw | 别再让 AI 配置散落在每个项目里" />
26
+ <meta name="twitter:title" content="cc-gw | 你的 API Key 不该躺在 30 个 .env 里" />
27
27
  <meta
28
28
  name="twitter:description"
29
- content=" Claude CodeOpenAI SDKAnthropic SDK 和内部工具统一到一个本地优先入口,Key、路由、日志和排查回到控制台里管理。"
29
+ content="A local-first AI gateway. One endpoint for Claude Code, OpenAI SDK, and Anthropic SDK. Switch models, swap providers, and trace requests without touching your code."
30
30
  />
31
31
  <meta name="twitter:image" content="/cc-gw-social-card.png" />
32
32
  <meta name="twitter:image:alt" content="cc-gw landing share card showing a local-first AI gateway and daily control console" />
@@ -41,13 +41,13 @@
41
41
  "description": "Local-first AI gateway for personal developers and small teams who want to centralize provider configuration, routing, logs, profiler, and API key management."
42
42
  }
43
43
  </script>
44
- <title>cc-gw | 别再让 AI 配置散落在每个项目里</title>
45
- <script type="module" crossorigin src="/assets/landing-CHY6qfgq.js"></script>
46
- <link rel="modulepreload" crossorigin href="/assets/vendor-LWJeAdU1.js">
47
- <link rel="modulepreload" crossorigin href="/assets/global-CKvMKvrn.js">
44
+ <title>cc-gw | 你的 API Key 不该躺在 30 个 .env 里 · local-first AI gateway</title>
45
+ <script type="module" crossorigin src="/assets/landing-D9E0GJD9.js"></script>
46
+ <link rel="modulepreload" crossorigin href="/assets/vendor-z22RpOY0.js">
47
+ <link rel="modulepreload" crossorigin href="/assets/global-xoXYOIOz.js">
48
48
  <link rel="modulepreload" crossorigin href="/assets/clipboard-CALi6bTW.js">
49
- <link rel="modulepreload" crossorigin href="/assets/package-BMIMFcQR.js">
50
- <link rel="stylesheet" crossorigin href="/assets/global-CUpRxoFd.css">
49
+ <link rel="modulepreload" crossorigin href="/assets/package-GpB9DOR2.js">
50
+ <link rel="stylesheet" crossorigin href="/assets/global-D8jT4xUX.css">
51
51
  </head>
52
52
  <body class="bg-slate-50 text-slate-900">
53
53
  <div id="landing-root"></div>
@@ -1,5 +0,0 @@
1
- import{r as g,j as e,aP as v,aM as f,aQ as k,ac as C}from"./vendor-LWJeAdU1.js";import{P as $}from"./PageHeader--Lg_YQVw.js";import{P as o}from"./PageSection-DIAhP18t.js";import{c as q}from"./clipboard-CALi6bTW.js";import{c as h}from"./global-CKvMKvrn.js";import{C as j,a as b}from"./card-CwTuH2Iq.js";import{B as S}from"./app-BG16DmZH.js";import{u as y}from"./i18n-B3N4Df3E.js";import"./query-Cpxr1dul.js";import"./router-DspBTS8b.js";import"./radix-bG5h1Ymq.js";const P="group rounded-[1rem] border border-white/70 bg-card/95 p-3.5 shadow-[0_18px_42px_-38px_rgba(15,23,42,0.24)] transition hover:-translate-y-0.5 hover:shadow-[0_22px_48px_-40px_rgba(59,130,246,0.18)]";function R(){const{t:s}=y(),t=g.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),r=s("help.sections.codexConfig.items",{returnObjects:!0}),d=s("help.sections.usage.items",{returnObjects:!0}),_=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:r},{title:s("help.sections.usage.title"),items:d},{title:s("help.sections.tips.title"),items:_}]},[s]),l=s("help.faq.items",{returnObjects:!0}),a=t[0].items.slice(0,3),c=g.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:p(t[0].items[0]??"")},{id:"claude",title:t[1].title,subtitle:p(t[1].items[0]??"")},{id:"codex",title:t[2].title,subtitle:p(t[2].items[0]??"")},{id:"faq",title:s("help.faq.title"),subtitle:s("help.meta.faqCount",{count:l.length})}],[l.length,t,s]);return e.jsxs("div",{className:"space-y-5",children:[e.jsx($,{icon:e.jsx(v,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro"),breadcrumb:s("help.meta.breadcrumb"),helper:s("help.helper"),badge:s("help.meta.guides",{count:t.length})}),e.jsx(j,{className:"rounded-[1.2rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)] xl:hidden",children:e.jsxs(b,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-[0.95rem] bg-accent text-primary",children:e.jsx(f,{className:"h-4.5 w-4.5","aria-hidden":"true"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("help.note")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("help.helper")})]})]}),e.jsxs("div",{className:"rounded-[0.95rem] bg-secondary/55 p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)]",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:s("help.meta.recommendedFlow")}),e.jsx("div",{className:"-mx-1 mt-2 flex gap-2 overflow-x-auto px-1 pb-1",children:c.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"w-[190px] shrink-0 rounded-[0.95rem] border border-white/65 bg-background/82 px-3 py-2.5 shadow-[0_10px_24px_-20px_rgba(15,23,42,0.18)]",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground",children:i.title}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:a.map((i,n)=>e.jsxs("span",{className:"inline-flex items-center rounded-full bg-background/78 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"mr-1.5 inline-flex h-4.5 w-4.5 items-center justify-center rounded-full bg-primary text-[10px] font-semibold text-primary-foreground",children:n+1}),e.jsx("span",{className:"line-clamp-1",children:p(i)})]},`${n}-${i}`))})]})]})}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[280px_minmax(0,1fr)] xl:items-start",children:[e.jsxs("aside",{className:"hidden space-y-4 xl:sticky xl:top-24 xl:block",children:[e.jsx(j,{className:"rounded-[1.25rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)]",children:e.jsxs(b,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[1rem] bg-accent text-primary",children:e.jsx(f,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("help.note")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("help.helper")})]})]}),e.jsxs("div",{className:"rounded-[1rem] bg-secondary/55 p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)]",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:s("help.meta.recommendedFlow")}),e.jsx("ol",{className:"mt-2.5 space-y-2",children:a.map((i,n)=>e.jsxs("li",{className:"flex gap-2.5 text-xs leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary text-[10px] font-semibold text-primary-foreground",children:n+1}),e.jsx("span",{children:p(i)})]},`${n}-${i}`))})]})]})}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-1",children:c.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:P,children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-1.5 line-clamp-2 text-xs leading-5 text-muted-foreground",children:i.subtitle})]},i.id))})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(o,{title:e.jsx(x,{eyebrow:"01",title:t[0].title}),description:s("help.clientConfig.subtitle"),children:e.jsx(m,{items:t[0].items,compact:!0})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(o,{title:e.jsx(x,{eyebrow:"02",title:t[1].title}),className:"rounded-[1.35rem]",children:[e.jsx(N,{icon:e.jsx(k,{className:"h-4 w-4"}),iconClassName:"bg-primary text-primary-foreground",title:"Claude Code",subtitle:s("help.meta.claudeWorkflow")}),e.jsx(m,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(o,{title:e.jsx(x,{eyebrow:"03",title:t[2].title}),className:"rounded-[1.35rem]",children:[e.jsx(N,{icon:e.jsx(C,{className:"h-4 w-4"}),iconClassName:"bg-emerald-600 text-white",title:"Codex CLI",subtitle:s("help.meta.codexWorkflow")}),e.jsx(m,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(o,{title:e.jsx(x,{eyebrow:"04",title:t[3].title}),children:e.jsx(m,{items:t[3].items})}),e.jsx(o,{title:e.jsx(x,{eyebrow:"05",title:t[4].title}),children:e.jsx(m,{items:t[4].items})})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(o,{title:e.jsx(x,{eyebrow:"FAQ",title:s("help.faq.title")}),children:e.jsx(W,{items:l})})})]})]})]})}function x({eyebrow:s,title:t}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground/80",children:s}),e.jsx("h2",{className:"text-base font-semibold text-foreground",children:t})]})}function N({icon:s,iconClassName:t,title:l,subtitle:a}){return e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-[1rem] bg-secondary/78 p-3.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)] dark:bg-slate-900/[0.56] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",children:[e.jsx("div",{className:h("flex h-10 w-10 items-center justify-center rounded-[0.95rem]",t),children:s}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function m({items:s,compact:t=!1}){return e.jsx("ol",{className:h("flex flex-col",t?"gap-2":"gap-2.5"),children:s.map((l,a)=>e.jsxs("li",{className:h("flex gap-3 rounded-[1.05rem] border border-border/50 bg-card/92 shadow-[0_16px_36px_-30px_rgba(15,23,42,0.24)] dark:border-white/10 dark:bg-slate-950/[0.38] dark:shadow-[0_16px_36px_-30px_rgba(0,0,0,0.32)]",t?"p-3":"p-3.5"),children:[e.jsx("span",{className:h("flex shrink-0 items-center justify-center rounded-[0.95rem] bg-primary text-xs font-semibold text-primary-foreground shadow-[0_10px_22px_-14px_hsl(var(--primary)/0.7)]",t?"h-7 w-7 text-[11px]":"h-8 w-8"),children:a+1}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:e.jsx(w,{content:l})})]},`${a}-${l}`))})}function w({content:s}){const{t}=y(),l=s.split("```");return e.jsx("div",{className:"space-y-3",children:l.map((a,c)=>{if(!a.trim())return null;if(c%2===1){const[i,...n]=a.split(`
2
- `),r=n.join(`
3
- `).trim();return e.jsxs("div",{className:"overflow-hidden rounded-[0.95rem] border border-border/55 bg-secondary/60 dark:border-white/10 dark:bg-slate-900/[0.52]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/55 px-3 py-2 dark:border-white/10",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:i||"bash"}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>q(r),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-3 font-mono text-[12px] leading-6 text-foreground",children:e.jsx("code",{className:"block min-w-full whitespace-pre",children:r})})]},c)}return e.jsx(O,{content:a},c)})})}function O({content:s}){const t=s.split(`
4
- `).map(r=>r.trimEnd()).filter(r=>r.trim().length>0);if(t.length===0)return null;const l=t.filter(r=>/^[-•*]\s+/.test(r.trim())),a=t.filter(r=>/^\d+[).]\s+/.test(r.trim())),c=t.filter(r=>!/^([-•*]|\d+[).])\s+/.test(r.trim())),i=l.map(r=>r.replace(/^[-•*]\s+/,"")),n=a.map(r=>{const d=r.trim().match(/^(\d+)[).]\s+(.*)$/);return{index:(d==null?void 0:d[1])??"",text:(d==null?void 0:d[2])??r.trim()}});return e.jsxs("div",{className:"space-y-2.5",children:[c.length>0?e.jsx("div",{className:"space-y-2",children:c.map((r,d)=>e.jsx("p",{className:"leading-6",children:u(r)},`${r}-${d}`))}):null,i.length>0?e.jsx("ul",{className:"space-y-1.5 rounded-[0.95rem] bg-secondary/38 px-3 py-2.5 dark:bg-slate-900/[0.34]",children:i.map((r,d)=>e.jsxs("li",{className:"flex gap-2 text-sm leading-6",children:[e.jsx("span",{className:"mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-primary"}),e.jsx("span",{children:u(r)})]},`${r}-${d}`))}):null,n.length>0?e.jsx("ol",{className:"space-y-2 rounded-[0.95rem] bg-secondary/38 px-3 py-2.5 dark:bg-slate-900/[0.34]",children:n.map(r=>e.jsxs("li",{className:"flex gap-2.5 text-sm leading-6",children:[e.jsx("span",{className:"mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary/12 px-1.5 text-[11px] font-semibold text-primary",children:r.index}),e.jsx("span",{children:u(r.text)})]},`${r.index}-${r.text}`))}):null]})}function u(s){return s.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((l,a)=>l.startsWith("`")&&l.endsWith("`")?e.jsx("code",{className:"rounded-md bg-secondary/72 px-1.5 py-0.5 text-[0.95em] text-foreground dark:bg-slate-900/[0.58]",children:l.slice(1,-1)},a):l.startsWith("**")&&l.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:l.slice(2,-2)},a):e.jsx("span",{children:l},a))}function W({items:s}){return s.length===0?null:e.jsx("dl",{className:"space-y-2",children:s.map((t,l)=>e.jsxs("details",{className:"group overflow-hidden rounded-[1rem] border border-border/50 bg-card/92 shadow-[0_16px_36px_-30px_rgba(15,23,42,0.24)]",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-foreground",children:[e.jsx("span",{children:t.q}),e.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[11px] text-muted-foreground transition group-open:bg-primary/10 group-open:text-primary",children:l+1})]}),e.jsx("div",{className:"border-t border-border/50 px-4 py-3",children:e.jsx("dd",{className:"text-sm text-muted-foreground",children:e.jsx(B,{content:t.a})})})]},t.q))})}function B({content:s}){return e.jsx(w,{content:s})}function p(s){var t;return((t=s.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/^[-•*]\s+/gm,"").replace(/^\d+[).]\s+/gm,"").split(`
5
- `).map(l=>l.trim()).filter(Boolean)[0])==null?void 0:t.replace(/\s+/g," "))??""}export{R as default};
@@ -1 +0,0 @@
1
- import{j as e,ax as ce,aB as me,aC as ue,N as xe,r as f,aa as pe,S as he}from"./vendor-LWJeAdU1.js";import{L as fe}from"./router-DspBTS8b.js";import{C as be}from"./ConfirmDialog-BHrsB4gR.js";import{P as ge}from"./PageHeader--Lg_YQVw.js";import{B as b}from"./app-BG16DmZH.js";import{B as W}from"./queryKeys-DTnZc8Yy.js";import{C as J,a as Z}from"./card-CwTuH2Iq.js";import{I as M}from"./input-scp9nKJc.js";import{u as E}from"./i18n-B3N4Df3E.js";import{D as ve,A as je,a as ye,b as we,c as Ne,d as ke,e as Me}from"./DialogShell-DcG-SXEV.js";import{L as C}from"./label-fMXEnAEx.js";import{S as Ce}from"./switch-CgwYcn5P.js";import{u as De}from"./useModelManagementState-9RhvWh8Y.js";import{c as Te}from"./global-CKvMKvrn.js";import"./query-Cpxr1dul.js";import"./radix-bG5h1Ymq.js";import"./gateway-CExOTXeI.js";import"./useAppMutation-ChCrgiP6.js";import"./useApiQuery-jSeDDFuv.js";function Pe({providersLength:d,filteredProviders:a,defaultLabels:c,providerSearch:g,providerTypeFilter:p,configPending:y,testingProviderId:s,onOpenEdit:t,onTestConnection:i,onRequestDelete:m,onProviderSearchChange:v,onResetFilters:w}){const{t:h}=E(),A=u=>{const D=u.authMode??(u.type==="anthropic"?"authToken":"apiKey");return D==="authToken"?"Bearer":D==="xAuthToken"?"X-Auth-Token":u.type==="anthropic"?"X-API-Key":h("providers.card.providerDefault")};return e.jsx(J,{className:"rounded-[1.35rem] border border-white/70 bg-card/95 shadow-[0_22px_56px_-46px_rgba(15,23,42,0.24)]",children:e.jsxs(Z,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-[1.1rem] bg-secondary/60 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(M,{value:g,onChange:u=>v(u.target.value),placeholder:h("providers.filters.searchPlaceholder"),className:"h-10 bg-card/90 sm:max-w-[520px]"})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(W,{variant:"secondary",className:"rounded-full px-3 py-1 text-xs",children:h("providers.count",{count:a.length})}),e.jsx(b,{variant:"ghost",size:"sm",onClick:w,disabled:!g.trim()&&p==="all",className:"h-8 rounded-full px-3 text-xs",children:h("common.actions.reset")})]})]}),y?e.jsx("div",{className:"flex min-h-[200px] items-center justify-center rounded-lg bg-secondary text-sm text-muted-foreground",children:h("common.loading")}):d===0?e.jsxs("div",{className:"rounded-lg border-2 border-dashed border-border/30 p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:h("providers.emptyState")}),e.jsx("p",{className:"mt-2 text-xs",children:h("providers.emptyStateSub",{default:"点击上方按钮添加您的第一个提供商"})})]}):a.length===0?e.jsx("div",{className:"rounded-lg border-2 border-dashed border-border/30 p-12 text-center text-sm text-muted-foreground",children:e.jsx("p",{className:"font-medium",children:h("providers.emptyFiltered")})}):e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"grid gap-2.5 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:a.map(u=>{var j;const D=A(u),T=((j=u.models)==null?void 0:j.length)??0,P=c.get(u.id);return e.jsx(Ue,{provider:u,authMode:D,modelCount:T,defaultModel:P,isTesting:s===u.id,onEdit:()=>t(u),onTest:()=>i(u),onDelete:()=>m(u),t:h},u.id)})})})]})})}function Ue({provider:d,authMode:a,modelCount:c,defaultModel:g,isTesting:p,onEdit:y,onTest:s,onDelete:t,t:i}){const m=!!g,v=m?"success":"warning",w=i(m?"providers.status.ready":"providers.status.needsDefault");return e.jsx(J,{"data-testid":"provider-card",className:"overflow-hidden rounded-[1rem] border border-border/60 bg-[linear-gradient(180deg,rgba(255,255,255,0.97)_0%,rgba(250,251,253,0.94)_100%)] shadow-[0_14px_32px_-30px_rgba(15,23,42,0.2)] transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_20px_38px_-32px_rgba(59,130,246,0.18)] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.92)_0%,rgba(2,6,23,0.88)_100%)]",children:e.jsxs(Z,{className:"space-y-2.5 p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2.5",children:e.jsx("h3",{className:"truncate text-[14px] font-semibold tracking-[-0.02em] text-foreground",title:d.label||d.id,children:d.label||d.id})}),e.jsx("code",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",title:d.id,children:d.id})]}),e.jsx(W,{variant:v,className:"shrink-0 rounded-full px-2 py-0.5 text-[10px]",children:w})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 text-[11px]",children:[e.jsx(Q,{icon:e.jsx(ce,{className:"h-3.5 w-3.5"}),label:i("providers.card.authMode"),value:a}),e.jsx(Q,{icon:e.jsx(me,{className:"h-3.5 w-3.5"}),label:i("providers.card.modelsTitle"),value:c>0?i("providers.card.modelCount",{count:c}):i("providers.card.passthrough")})]}),e.jsxs("div",{className:"space-y-1.5 rounded-[0.85rem] bg-secondary/45 p-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] dark:bg-slate-900/[0.42]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("code",{className:"truncate",title:d.baseUrl,children:d.baseUrl})]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground/70",children:i("providers.card.defaultModelLabel")}),g?e.jsx("code",{className:"min-w-0 truncate rounded-full border border-border/65 bg-background/82 px-2 py-0.5 text-[10px] text-foreground dark:border-white/10 dark:bg-slate-950/[0.58]",title:g,children:g}):e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:i("providers.card.noDefault")})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1 border-t border-border/45 pt-2",children:[e.jsx(b,{variant:"ghost",size:"sm",onClick:y,className:"h-7 rounded-full px-2 text-[11px]",children:i("providers.actions.edit")}),e.jsx(b,{variant:"ghost",size:"sm",onClick:s,disabled:p,className:"h-7 rounded-full px-2 text-[11px]",children:p?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"mr-1 h-3 w-3 animate-spin"}),i("common.actions.testingConnection")]}):i("providers.actions.test")}),e.jsx(b,{variant:"ghost",size:"sm",onClick:t,className:"h-7 rounded-full px-2 text-[11px] text-destructive hover:bg-destructive/10 hover:text-destructive",children:i("providers.actions.delete")})]})]})})}function Q({icon:d,label:a,value:c}){return e.jsxs("div",{className:"min-w-0 rounded-[0.75rem] bg-secondary/55 px-2 py-1.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.58)] dark:bg-slate-900/[0.5]",children:[e.jsxs("div",{className:"mb-0.5 flex min-w-0 items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[d,e.jsx("span",{className:"truncate",children:a})]}),e.jsx("p",{className:"truncate text-[11px] font-medium text-foreground",title:c,children:c})]})}function Ae({open:d,provider:a,options:c,usePreset:g,preservedExtras:p,onPresetChange:y,onConfirm:s,onClose:t}){const{t:i}=E();return a?e.jsx(ve,{open:d,onOpenChange:m=>!m&&t(),children:e.jsxs(je,{className:"max-w-2xl",children:[e.jsxs(ye,{children:[e.jsx(we,{children:i("providers.testDialog.title")}),e.jsx(Ne,{children:i("providers.testDialog.subtitle",{name:a.label||a.id})})]}),e.jsxs(ke,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-xl bg-accent p-4 text-sm text-primary",children:i("providers.testDialog.description")}),e.jsxs("div",{className:"space-y-4 rounded-xl bg-secondary/50 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"provider-test-preset",children:i("providers.testDialog.presetLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("providers.testDialog.presetDescription")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Ce,{id:"provider-test-preset",checked:g,onCheckedChange:y})})]}),g?e.jsx("div",{className:"space-y-2",children:e.jsxs("details",{className:"rounded-xl border border-transparent bg-card p-2 text-xs shadow-[var(--surface-shadow)]",children:[e.jsx("summary",{className:"cursor-pointer text-primary hover:underline",children:i("providers.testDialog.presetPreviewSummary")}),e.jsx("div",{className:"mt-2 space-y-1",children:c.map(m=>e.jsxs("code",{className:"block rounded-lg bg-secondary px-2 py-1 text-xs",children:[m.key,": ",m.value]},m.key))})]})}):e.jsx("p",{className:"text-xs text-muted-foreground",children:i("providers.testDialog.presetDescription")})]}),Object.keys(p).length>0&&e.jsxs("div",{className:"space-y-2 rounded-xl bg-secondary/50 p-4 text-xs",children:[e.jsx("p",{className:"font-medium",children:i("providers.testDialog.preservedInfo")}),Object.entries(p).map(([m,v])=>e.jsxs("code",{className:"block rounded-lg border border-transparent bg-card px-2 py-1 shadow-[var(--surface-shadow)]",children:[m,": ",v]},m))]})]}),e.jsxs(Me,{children:[e.jsx(b,{variant:"outline",onClick:t,children:i("providers.testDialog.cancel")}),e.jsx(b,{onClick:()=>void s(),children:i("providers.testDialog.primary")})]})]})}):null}function F(){return typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,10)}function Se(){return{_key:F(),id:"",label:""}}const _={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:{}},V=[{value:"openai",label:"OpenAI"},{value:"deepseek",label:"DeepSeek"},{value:"huawei",label:"Huawei Cloud"},{value:"kimi",label:"Kimi"},{value:"anthropic",label:"Anthropic"},{value:"custom",label:"Custom"}];function I(d){return d==="anthropic"?"authToken":"apiKey"}function Y(d){return d?{id:d.id,label:d.label??d.id,baseUrl:d.baseUrl,apiKey:d.apiKey??"",type:d.type??"custom",defaultModel:d.defaultModel??"",models:(d.models??[]).map(a=>({...a,_key:F()})),authMode:d.authMode??I(d.type??"custom")}:{id:"",label:"",baseUrl:"",apiKey:"",type:"custom",defaultModel:"",models:[],authMode:I("custom")}}function _e(d){return{_key:F(),id:d.id,label:d.label}}function Ie({open:d,mode:a,provider:c,existingProviderIds:g,onClose:p,onSubmit:y}){const{t:s}=E(),[t,i]=f.useState(()=>Y(c)),[m,v]=f.useState({}),[w,h]=f.useState(!1),[A,u]=f.useState(null),D=f.useRef(null),T=f.useRef(null),P=f.useRef(null),[j,H]=f.useState(a==="edit");f.useEffect(()=>{d&&(i(Y(c)),v({}),u(null),h(!1),H(a==="edit"))},[d,c,a]),f.useEffect(()=>{if(!d)return;const r=l=>{l.key==="Escape"&&p()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[d,p]),f.useEffect(()=>{if(d){if(a==="create"&&P.current){P.current.focus();return}T.current&&T.current.focus()}},[d,a]);const L=a==="create",K=f.useMemo(()=>t.models.filter(r=>r.id.trim().length>0),[t.models]),z=f.useMemo(()=>{var r;return((r=V.find(l=>l.value===t.type))==null?void 0:r.label)??"Custom"},[t.type]),q=(r,l)=>s(l==="authToken"?"providers.drawer.fields.authModeAuthToken":l==="xAuthToken"?"providers.drawer.fields.authModeXAuthToken":r==="anthropic"?"providers.drawer.fields.authModeApiKey":"providers.drawer.fields.authModeProviderDefault"),$=t.label.trim()||t.id.trim()||s("providers.drawer.summary.untitled"),X=f.useMemo(()=>[{label:s("providers.drawer.summary.type"),value:z},{label:s("providers.drawer.summary.auth"),value:q(t.type,t.authMode)},{label:s("providers.drawer.summary.models"),value:K.length.toLocaleString()}],[K.length,t.authMode,t.type,z,s]),R=r=>l=>{i(n=>({...n,[r]:l}))},ee=r=>{i(l=>{const o=!j||l.label.trim().length===0||l.label===l.id?r:l.label;return{...l,id:r,label:o}})},re=r=>{i(l=>{var G;const o=_[r??"custom"]??_.custom,x=I(l.type),N=I(r),k=Object.values(_).map(U=>U.baseUrl).filter(U=>!!U),B=!l.baseUrl||k.includes(l.baseUrl),ne=a==="create"&&(l.models.length===0||l.models.every(U=>U.id.trim().length===0)),S={...l,type:r,authMode:l.authMode===x?N:l.authMode};return o!=null&&o.baseUrl&&B&&(S.baseUrl=o.baseUrl),o!=null&&o.models&&ne&&(S.models=o.models.map(_e),S.defaultModel=o.defaultModel??((G=o.models[0])==null?void 0:G.id)??""),S})},se=(r,l)=>{i(n=>{const o=[...n.models];return o[r]={...o[r],...l},{...n,models:o}})},ae=(r,l)=>{i(n=>{const o=[...n.models],x=o[r];if(!x)return n;const N=!j||!x.label||x.label===x.id,k={...x,id:l,label:N?l:x.label};o[r]=k;const B=n.defaultModel===x.id?l:n.defaultModel;return{...n,models:o,defaultModel:B}})},te=r=>{i(l=>{if(r<0||r>=l.models.length)return l;const n=l.models.filter((x,N)=>N!==r);let o=l.defaultModel;return n.some(x=>x.id===o)||(o=""),{...l,models:n,defaultModel:o}})},de=()=>{i(r=>({...r,models:[...r.models,Se()]}))},O=r=>{i(l=>({...l,authMode:r}))},le=()=>{const r={},l=t.id.trim(),n=t.baseUrl.trim();if(a==="create"&&(l.length===0?r.id=s("providers.drawer.errors.idRequired"):g.includes(l)&&(r.id=s("providers.drawer.errors.idDuplicate"))),a==="edit"&&l.length===0&&(r.id=s("providers.drawer.errors.idRequired")),n.length===0)r.baseUrl=s("providers.drawer.errors.baseUrlInvalid");else try{new URL(n)}catch{r.baseUrl=s("providers.drawer.errors.baseUrlInvalid")}if(t.models.length>0){const o=new Set;t.models.some(N=>{const k=N.id.trim();return k.length===0||o.has(k)?!0:(o.add(k),!1)})&&(r.models=s("providers.drawer.errors.modelInvalid"))}return t.defaultModel&&!t.models.some(o=>o.id===t.defaultModel)&&(r.models=s("providers.drawer.errors.defaultInvalid")),v(r),Object.keys(r).length===0},ie=()=>{const r=t.models.map(o=>{var x;return{id:o.id.trim(),label:(x=o.label)!=null&&x.trim()?o.label.trim():void 0}}).filter(o=>o.id.length>0),l=c!=null&&c.extraHeaders&&Object.keys(c.extraHeaders).length>0?c.extraHeaders:void 0,n=t.authMode==="apiKey"&&t.type!=="anthropic"?void 0:t.authMode;return{id:t.id.trim(),label:t.label.trim()||t.id.trim(),baseUrl:t.baseUrl.trim(),apiKey:t.apiKey.trim()||void 0,type:t.type??"custom",defaultModel:t.defaultModel||void 0,models:r.length>0?r:void 0,extraHeaders:l,authMode:n}},oe=async()=>{if(u(null),!!le()){h(!0);try{const r=ie();await y(r)}catch(r){u(s("providers.drawer.toast.saveFailure",{message:r instanceof Error?r.message:"unknown"})),h(!1);return}h(!1),p()}};return d?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm",onClick:p,"aria-hidden":"true"}),e.jsxs("aside",{ref:D,role:"dialog","aria-modal":"true","aria-labelledby":"provider-drawer-title","aria-describedby":"provider-drawer-desc",className:"flex h-full min-h-0 w-full max-w-5xl flex-col border-l border-border/45 bg-background/96 shadow-[var(--surface-shadow-lg)] backdrop-blur",children:[e.jsxs("header",{className:"border-b border-border/45 bg-secondary/45 px-6 py-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"inline-flex rounded-full border border-primary/20 bg-primary/10 px-3 py-1 text-[11px] font-medium uppercase tracking-[0.18em] text-primary",children:s(L?"providers.drawer.quickStart":"providers.drawer.editTitle")}),e.jsxs("div",{children:[e.jsx("h2",{id:"provider-drawer-title",className:"text-lg font-semibold tracking-[-0.02em]",children:s(L?"providers.drawer.createTitle":"providers.drawer.editTitle")}),e.jsx("p",{id:"provider-drawer-desc",className:"text-sm text-muted-foreground",children:s("providers.drawer.description")})]})]}),e.jsx(b,{type:"button",ref:T,variant:"outline",onClick:p,className:"bg-card",children:s("common.actions.close")})]}),e.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:X.map(r=>e.jsxs("div",{className:"rounded-xl border border-transparent bg-card px-4 py-3 shadow-[var(--surface-shadow)]",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:r.label}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-foreground",children:r.value})]},r.label))})]}),e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden xl:grid-cols-[minmax(0,1fr)_280px]",children:[e.jsxs("div",{className:"min-h-0 overflow-y-auto px-6 py-5 pb-10",children:[e.jsxs("section",{className:"space-y-5","aria-labelledby":"provider-type-fields",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-type-fields",className:"text-sm font-semibold",children:s("providers.drawer.sections.type")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.type")})]}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:V.map(r=>{var n;const l=r.value===t.type;return e.jsxs("button",{type:"button",onClick:()=>re(r.value),className:Te("rounded-2xl border px-4 py-3 text-left transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",l?"border-primary bg-primary/10 text-primary shadow-sm":"border-border bg-card text-foreground hover:border-primary/20 hover:bg-accent/50"),children:[e.jsx("div",{className:"text-sm font-semibold",children:r.label}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:((n=_[r.value??"custom"])==null?void 0:n.baseUrl)??s("providers.drawer.hints.customProvider")})]},r.value??"custom")})})]}),e.jsxs("section",{className:"mt-8 space-y-4","aria-labelledby":"provider-basic-info",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-basic-info",className:"text-sm font-semibold",children:s("providers.drawer.sections.basic")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.basic")})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>H(r=>!r),className:"bg-card text-xs",children:s(j?"providers.drawer.fields.hideAdvanced":"providers.drawer.fields.showAdvanced")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.id")}),e.jsx(M,{value:t.id,ref:P,onChange:r=>ee(r.target.value),disabled:!L,placeholder:s("providers.drawer.fields.idPlaceholder"),"aria-invalid":!!m.id}),m.id?e.jsx("span",{className:"text-xs text-destructive",children:m.id}):null]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.label")}),e.jsx(M,{value:t.label,onChange:r=>R("label")(r.target.value),placeholder:s("providers.drawer.fields.labelPlaceholder")})]})]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.baseUrl")}),e.jsx(M,{value:t.baseUrl,onChange:r=>R("baseUrl")(r.target.value),placeholder:s("providers.drawer.fields.baseUrlPlaceholder"),"aria-invalid":!!m.baseUrl}),m.baseUrl?e.jsx("span",{className:"text-xs text-destructive",children:m.baseUrl}):null]})]}),e.jsxs("section",{className:"mt-8 space-y-4","aria-labelledby":"provider-auth-fields",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-auth-fields",className:"text-sm font-semibold",children:s("providers.drawer.sections.auth")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.auth")})]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.apiKey")}),e.jsx(M,{value:t.apiKey,onChange:r=>R("apiKey")(r.target.value),placeholder:s("providers.drawer.fields.apiKeyPlaceholder")})]}),e.jsxs("fieldset",{className:"grid gap-2 rounded-xl border border-transparent bg-card p-4 text-xs shadow-[var(--surface-shadow)]",children:[e.jsx("legend",{className:"px-1 text-muted-foreground",children:s("providers.drawer.fields.authMode")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("providers.drawer.fields.authModeHint")}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-transparent px-3 py-2 transition hover:bg-accent focus-within:bg-accent",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"apiKey",checked:t.authMode==="apiKey",onChange:()=>O("apiKey"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:q(t.type,"apiKey")})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-transparent px-3 py-2 transition hover:bg-accent focus-within:bg-accent",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"authToken",checked:t.authMode==="authToken",onChange:()=>O("authToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:s("providers.drawer.fields.authModeAuthToken")})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-transparent px-3 py-2 transition hover:bg-accent focus-within:bg-accent",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"xAuthToken",checked:t.authMode==="xAuthToken",onChange:()=>O("xAuthToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:s("providers.drawer.fields.authModeXAuthToken")})]})]})]}),e.jsxs("section",{className:"mt-8 space-y-4","aria-labelledby":"provider-model-fields",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-model-fields",className:"text-sm font-semibold",children:s("providers.drawer.fields.models")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.modelsDescription")})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:de,className:"bg-card text-xs",children:s("providers.drawer.fields.addModel")})]}),m.models?e.jsx("p",{className:"text-xs text-destructive",children:m.models}):null,e.jsxs("div",{className:"space-y-4",children:[t.models.map((r,l)=>e.jsxs("div",{className:"rounded-xl border border-transparent bg-card p-4 shadow-[var(--surface-shadow)]",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.modelId")}),e.jsx(M,{value:r.id,onChange:n=>ae(l,n.target.value),placeholder:s("providers.drawer.fields.modelIdPlaceholder")})]}),j?e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.modelLabel")}),e.jsx(M,{value:r.label??"",onChange:n=>se(l,{label:n.target.value}),placeholder:s("providers.drawer.fields.modelLabelPlaceholder")})]}):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-muted-foreground",children:[e.jsx("input",{type:"radio",name:"defaultModel",value:r.id,checked:t.defaultModel===r.id,onChange:()=>i(n=>({...n,defaultModel:r.id})),disabled:r.id.trim().length===0,className:"h-4 w-4 accent-[hsl(var(--primary))]"}),s("providers.drawer.fields.setDefault")]}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",className:"h-auto px-2 text-destructive",onClick:()=>te(l),disabled:t.models.length===0,children:s("providers.drawer.fields.removeModel")})]})]},r._key)),t.models.length===0?e.jsx("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-5 dark:border-amber-800 dark:bg-amber-950/30",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:s("providers.drawer.noModelsTitle")}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-800 dark:text-amber-300",children:s("providers.drawer.noModelsHint",{providerId:t.id||"provider-id"})}),e.jsxs("div",{className:"rounded-lg bg-secondary/50 p-2.5",children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-foreground",children:s("providers.drawer.routeExample")}),e.jsxs("code",{className:"block rounded-lg border border-transparent bg-card px-2.5 py-1.5 font-mono text-xs text-foreground shadow-[var(--surface-shadow)]",children:['"claude-*": "',(t.id||"provider-id").trim()||"provider-id",':*"']})]})]})}):null]}),K.length>1?e.jsx("div",{className:"text-xs text-muted-foreground",children:s("providers.drawer.defaultHint",{model:t.defaultModel||s("providers.card.noDefault")})}):null]})]}),e.jsx("aside",{className:"hidden min-h-0 overflow-y-auto border-l border-border/45 bg-secondary/40 px-5 py-5 xl:block",children:e.jsxs("div",{className:"sticky top-0 space-y-5",children:[e.jsxs("div",{className:"rounded-xl border border-transparent bg-card p-4 shadow-[var(--surface-shadow)]",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:s("providers.drawer.formSummary")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:$}),e.jsx("div",{className:"mt-4 space-y-3 text-sm",children:X.map(r=>e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:r.label}),e.jsx("span",{className:"text-right font-medium",children:r.value})]},r.label))})]}),e.jsxs("div",{className:"rounded-xl border border-transparent bg-card p-4 shadow-[var(--surface-shadow)]",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:s("providers.drawer.sections.checklist")}),e.jsxs("ul",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("providers.drawer.hints.checkUrl")}),e.jsx("li",{children:s("providers.drawer.hints.checkAuth")}),e.jsx("li",{children:s("providers.drawer.hints.checkModels")})]})]}),j&&e.jsxs("div",{className:"rounded-xl bg-accent p-4 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium text-primary",children:s("providers.drawer.hints.advancedTitle")}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("providers.drawer.hints.advancedBody")})]})]})})]}),e.jsxs("footer",{className:"flex items-center justify-between gap-3 border-t border-border/45 bg-secondary/45 px-6 py-4 text-sm backdrop-blur-sm",children:[e.jsx("div",{className:"flex flex-col text-xs text-destructive","aria-live":"polite",children:A?e.jsx("span",{children:A}):null}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{type:"button",variant:"outline",onClick:p,disabled:w,className:"bg-card",children:s("common.actions.cancel")}),e.jsx(b,{type:"button",onClick:oe,disabled:w,children:s(w?"common.actions.saving":"common.actions.save")})]})]})]})]}):null}function er(){const{t:d}=E(),a=De();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ge,{icon:e.jsx(he,{className:"h-5 w-5","aria-hidden":"true"}),title:d("providers.title"),description:d("providers.description"),eyebrow:d("modelManagement.providersEyebrow"),breadcrumb:"Gateway / Providers",badge:d("providers.count",{count:a.providerCount}),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx(b,{asChild:!0,variant:"outline",className:"w-full sm:w-auto",children:e.jsxs(fe,{to:"/routing",children:[d("nav.routing"),e.jsx(pe,{className:"h-4 w-4","aria-hidden":"true"})]})}),e.jsx(b,{onClick:a.handleOpenCreate,className:"w-full sm:w-auto",children:d("providers.actions.add")})]})}),e.jsx(Pe,{configPending:a.configQuery.isPending||!a.config&&a.configQuery.isFetching,defaultLabels:a.defaultLabels,filteredProviders:a.filteredProviders,onOpenEdit:a.handleOpenEdit,onRequestDelete:c=>a.setConfirmAction({kind:"provider",provider:c}),onResetFilters:()=>{a.setProviderSearch(""),a.setProviderTypeFilter("all")},onProviderSearchChange:a.setProviderSearch,onProviderTypeChange:a.setProviderTypeFilter,onTestConnection:a.initiateTestConnection,providerSearch:a.providerSearch,providerTypeFilter:a.providerTypeFilter,providersLength:a.providers.length,testingProviderId:a.testingProviderId}),e.jsx(Ie,{open:a.drawerOpen,mode:a.drawerMode,provider:a.drawerMode==="edit"?a.editingProvider:void 0,existingProviderIds:a.providers.map(c=>c.id).filter(c=>a.drawerMode==="edit"&&a.editingProvider?c!==a.editingProvider.id:!0),onClose:()=>{a.setDrawerOpen(!1),a.setEditingProvider(void 0),a.setDrawerMode("create")},onSubmit:a.handleProviderSubmit}),e.jsx(Ae,{open:a.testDialogOpen,provider:a.testDialogProvider,options:a.anthropicTestHeaderOptions,preservedExtras:a.testDialogPreservedExtras,usePreset:a.testDialogUsePreset,onPresetChange:a.setTestDialogUsePreset,onConfirm:a.confirmTestDialog,onClose:a.closeTestDialog}),e.jsx(be,{open:!!a.confirmAction,onOpenChange:c=>{!c&&!a.confirmingAction&&a.setConfirmAction(null)},title:a.confirmDialogTitle,description:a.confirmDialogDescription,confirmLabel:a.confirmingAction?d("common.actions.loading"):d("common.delete"),cancelLabel:d("common.actions.cancel"),loading:a.confirmingAction,onConfirm:a.handleConfirmDialog,children:a.confirmDialogName?e.jsx("div",{className:"rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2 font-mono text-xs text-foreground",children:a.confirmDialogName}):null})]})}export{er as default};
@@ -1 +0,0 @@
1
- import{r as A,j as e,a7 as T,aD as je,aE as F,aa as D,af as be,a0 as ve,S as Ne,T as ye}from"./vendor-LWJeAdU1.js";import{L as we}from"./router-DspBTS8b.js";import{C as ke}from"./ConfirmDialog-BHrsB4gR.js";import{P as Me}from"./PageHeader--Lg_YQVw.js";import{B as v,c as X,T as Ce,d as Ee,e as Pe,f as De}from"./app-BG16DmZH.js";import{u as J}from"./useAppMutation-ChCrgiP6.js";import{I as S}from"./input-scp9nKJc.js";import{L as w}from"./label-fMXEnAEx.js";import{S as Z,a as ee,b as se,c as ae,d as R}from"./select-BjYpeVvo.js";import{S as te}from"./switch-CgwYcn5P.js";import{q as Y,B as k}from"./queryKeys-DTnZc8Yy.js";import{u as E}from"./i18n-B3N4Df3E.js";import{C as ne,a as re}from"./card-CwTuH2Iq.js";import{c as O}from"./global-CKvMKvrn.js";import{D as Ae,A as Se,a as Te,b as Oe,c as Re,d as _e,e as Le}from"./DialogShell-DcG-SXEV.js";import{P as $e,a as Ve,b as Be}from"./popover-BGSWKBlu.js";import{i as He,g as ze,a as Fe,C as qe,O as Ie,u as Ge}from"./useModelManagementState-9RhvWh8Y.js";import"./query-Cpxr1dul.js";import"./radix-bG5h1Ymq.js";import"./gateway-CExOTXeI.js";import"./useApiQuery-jSeDDFuv.js";const Ke=["anthropic","openai-auto","openai-chat","openai-responses"];function Ue({open:l,endpoint:s,onClose:h,onSuccess:r}){const{t:a}=E(),[p,m]=A.useState({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0});A.useEffect(()=>{if(s){const n=s.paths&&s.paths.length>0?s.paths:s.path&&s.protocol?[{path:s.path,protocol:s.protocol}]:[{path:"",protocol:"openai-auto"}];m({id:s.id,label:s.label,paths:n,enabled:s.enabled!==!1});return}m({id:"",label:"",paths:[{path:"",protocol:"openai-auto"}],enabled:!0})},[s,l]);const t=J({mutationFn:X.create,invalidateKeys:[Y.customEndpoints.all()],successToast:()=>({title:a("modelManagement.createEndpointSuccess")}),errorToast:n=>({title:a("modelManagement.createEndpointError",{error:n.message})}),onSuccess:async()=>{r(),h()}}),x=J({mutationFn:n=>X.update(n.id,n.updates),invalidateKeys:[Y.customEndpoints.all()],successToast:()=>({title:a("modelManagement.updateEndpointSuccess")}),errorToast:n=>({title:a("modelManagement.updateEndpointError",{error:n.message})}),onSuccess:async()=>{r(),h()}}),N=()=>{m(n=>({...n,paths:[...n.paths,{path:"",protocol:"anthropic"}]}))},d=n=>{p.paths.length!==1&&m(g=>({...g,paths:g.paths.filter((f,M)=>M!==n)}))},b=(n,g,f)=>{m(M=>{const C=[...M.paths];return C[n]={...C[n],[g]:f},{...M,paths:C}})},o=n=>{if(n==null||n.preventDefault(),!p.id.trim()||!p.label.trim())return;for(const f of p.paths)if(!f.path.trim())return;const g=p.paths.map(f=>({path:f.path.trim(),protocol:f.protocol}));if(s){x.mutate({id:s.id,updates:{label:p.label.trim(),paths:g,enabled:p.enabled}});return}t.mutate({id:p.id.trim(),label:p.label.trim(),paths:g,enabled:p.enabled})},c=t.isPending||x.isPending,i=p.paths.length===0?a("modelManagement.atLeastOnePath"):!p.id.trim()||!p.label.trim()?a("modelManagement.endpointValidationError"):p.paths.some(n=>!n.path.trim())?a("modelManagement.pathValidationError"):null;return l?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-background/80 backdrop-blur-sm",onClick:h}),e.jsx("div",{className:"fixed inset-y-0 right-0 z-50 w-full max-w-md border-l border-border/45 bg-background/96 shadow-[var(--surface-shadow-lg)] backdrop-blur",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/45 bg-secondary/45 p-6 backdrop-blur-sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-[-0.02em]",children:a(s?"modelManagement.editEndpoint":"modelManagement.createEndpoint")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s?s.id:a("modelManagement.endpointRoutingHint")})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:h,className:"rounded-2xl bg-white/70",children:e.jsx(T,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:o,className:"flex-1 space-y-6 overflow-y-auto p-6",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary/50 p-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:a("modelManagement.endpointId")}),e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:(s==null?void 0:s.id)||"new-endpoint"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:a("modelManagement.endpointEnabled")}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:p.enabled?a("common.status.enabled"):a("common.status.disabled")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(w,{children:[a("modelManagement.endpointId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(S,{value:p.id,onChange:n=>m(g=>({...g,id:n.target.value})),placeholder:a("modelManagement.endpointIdPlaceholder"),disabled:!!s,required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("modelManagement.endpointIdHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(w,{children:[a("modelManagement.endpointLabel")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(S,{value:p.label,onChange:n=>m(g=>({...g,label:n.target.value})),placeholder:a("modelManagement.endpointLabelPlaceholder"),required:!0})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(w,{children:[a("modelManagement.endpointPaths")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(v,{type:"button",variant:"ghost",size:"sm",onClick:N,children:[e.jsx(je,{className:"mr-1 h-3 w-3"}),a("modelManagement.addPath")]})]}),e.jsx("div",{className:"space-y-3",children:p.paths.map((n,g)=>e.jsxs("div",{className:"space-y-2 rounded-xl border border-transparent bg-card p-3 shadow-[var(--surface-shadow)]",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(S,{value:n.path,onChange:f=>b(g,"path",f.target.value),placeholder:a("modelManagement.endpointPathPlaceholder"),required:!0}),e.jsxs(Z,{value:n.protocol,onValueChange:f=>b(g,"protocol",f),children:[e.jsx(ee,{children:e.jsx(se,{})}),e.jsx(ae,{children:Ke.map(f=>e.jsx(R,{value:f,children:a(f==="anthropic"?"modelManagement.protocolAnthropic":f==="openai-auto"?"modelManagement.protocolOpenAI":f==="openai-chat"?"modelManagement.protocolOpenAIChat":"modelManagement.protocolOpenAIResponses")},f))})]})]}),p.paths.length>1?e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(g),className:"text-destructive",children:e.jsx(T,{className:"h-4 w-4"})}):null]}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[g===0?e.jsx("p",{children:a("modelManagement.endpointPathHint")}):null,e.jsx("p",{children:a(`modelManagement.protocolHints.${n.protocol}`)})]})]},`${n.protocol}-${g}`))}),i?e.jsx("p",{className:"text-xs text-destructive",children:i}):null]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(te,{id:"enabled",checked:p.enabled,onCheckedChange:n=>m(g=>({...g,enabled:n}))}),e.jsx(w,{htmlFor:"enabled",children:a("modelManagement.endpointEnabled")})]}),s?null:e.jsx("div",{className:"rounded-xl bg-accent p-4",children:e.jsx("p",{className:"text-sm text-primary",children:a("modelManagement.endpointRoutingHint")})})]}),e.jsxs("div",{className:"flex gap-3 border-t border-border/45 bg-secondary/45 p-6 backdrop-blur-sm",children:[e.jsx(v,{variant:"outline",className:"flex-1",onClick:h,disabled:c,children:a("common.cancel")}),e.jsx(v,{className:"flex-1",onClick:()=>o(),disabled:c,children:a(c?"common.saving":s?"common.save":"common.create")})]})]})})]}):null}function _(l,s){return s(l==="anthropic"?"modelManagement.protocolAnthropic":l==="openai-chat"?"modelManagement.protocolOpenAIChat":l==="openai-responses"?"modelManagement.protocolOpenAIResponses":"modelManagement.protocolOpenAI")}function We({activeTab:l,customEndpoints:s,customTabs:h,isDirtyByEndpoint:r,onDeleteEndpoint:a,onEditEndpoint:p,onSelectTab:m,systemTabs:t}){const{t:x}=E(),N=[...t,...h].find(d=>d.key===l)??null;return e.jsx(ne,{className:"overflow-hidden rounded-[1.35rem] border border-white/70 bg-card/95 shadow-[0_22px_56px_-46px_rgba(15,23,42,0.22)]",children:e.jsxs(re,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.6fr)]",children:[e.jsxs("div",{className:"rounded-[1.1rem] bg-secondary/60 p-2.5",children:[e.jsx("div",{className:"mb-2 flex items-center justify-between px-1",children:e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/75",children:x("modelManagement.overview.providerAndSystem")})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3",children:t.map(d=>{const b=l===d.key,o=d.key!=="providers"&&r[d.key];return e.jsxs("button",{type:"button",onClick:()=>m(d.key),"aria-pressed":b,className:O("group flex min-h-[76px] flex-col justify-between rounded-[0.95rem] px-3 py-3 text-left transition-all",b?"bg-card text-foreground shadow-[0_14px_34px_-28px_rgba(15,23,42,0.3)] ring-1 ring-primary/10":"bg-transparent text-muted-foreground hover:bg-card/58 hover:text-foreground"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[15px] font-semibold text-foreground",children:d.label}),e.jsx("div",{className:"mt-0.5 text-[10px] uppercase tracking-[0.14em] text-muted-foreground/70",children:d.key==="providers"?x("modelManagement.overview.providerPoolTag"):x("modelManagement.overview.systemEndpointTag")})]}),o?e.jsx("span",{className:"mt-1 h-2.5 w-2.5 rounded-full bg-amber-500"}):null]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[e.jsx("span",{className:"line-clamp-1 text-xs text-muted-foreground/70",children:d.description}),b?e.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:e.jsx(F,{className:"h-3.5 w-3.5"})}):null]})]},d.key)})})]}),N?e.jsxs("div",{className:"flex min-h-[116px] flex-col justify-between rounded-[1.1rem] bg-[linear-gradient(135deg,hsl(var(--primary)/0.1),rgba(255,255,255,0.78))] p-4 ring-1 ring-primary/10 dark:bg-[linear-gradient(135deg,rgba(14,165,233,0.14),rgba(15,23,42,0.72))] dark:ring-white/10",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/75",children:"Active workspace"}),e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:N.label})]})]}),e.jsx("p",{className:"mt-3 line-clamp-2 text-xs leading-5 text-muted-foreground",children:N.description})]}):null]}),h.length>0?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/75",children:x("modelManagement.overview.customEndpoints")}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 2xl:grid-cols-3",children:h.map(d=>{const b=l===d.key,o=r[d.key],c=s.find(i=>i.id===d.key);return e.jsxs("div",{className:O("group relative flex min-w-0 flex-col gap-2.5 overflow-hidden rounded-[1.05rem] border px-3 py-3 text-left transition-all sm:px-3.5",b?"border-primary/20 bg-secondary/80 text-foreground shadow-[0_14px_34px_-30px_rgba(59,130,246,0.32)]":"border-border/55 bg-background/42 hover:bg-secondary/50"),children:[e.jsxs("button",{type:"button",onClick:()=>m(d.key),"aria-pressed":b,className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-foreground sm:text-[15px]",title:d.label,children:d.label}),o?e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"}):null]}),e.jsxs("div",{className:"mt-1.5 flex items-end justify-between gap-3",children:[e.jsx("p",{className:"line-clamp-2 text-[11px] leading-4.5 text-muted-foreground/72 sm:line-clamp-1 sm:text-xs",children:d.description}),b?e.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:e.jsx(F,{className:"h-3.5 w-3.5"})}):null]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(k,{variant:(c==null?void 0:c.enabled)===!1?"secondary":"success",className:"rounded-full border-0 px-2 py-0.5 text-[10px]",children:(c==null?void 0:c.enabled)===!1?x("modelManagement.overview.endpointDisabled"):x("modelManagement.overview.endpointEnabled")}),(d.protocols??[]).slice(0,2).map(i=>e.jsx(k,{variant:"outline",className:"max-w-[130px] truncate rounded-full text-[10px]",title:_(i,x),children:_(i,x)},`${d.key}-${i}`))]}),e.jsxs("div",{className:"min-w-0 rounded-[0.8rem] bg-secondary/55 px-2.5 py-2",children:[e.jsx("p",{className:"mb-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground/70",children:x("modelManagement.overview.endpointPaths")}),e.jsx("div",{className:"space-y-1",children:Qe(c,x).map(i=>e.jsx("p",{className:"truncate text-xs font-medium text-foreground",title:i,children:i},i))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",className:"h-7 justify-start rounded-full px-2 text-[11px]",disabled:!c,onClick:()=>{c&&p(c)},children:x("common.edit")}),d.canDelete?e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),c&&a({kind:"endpoint",endpoint:c})},className:"flex h-7 w-full items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive sm:w-7",title:x("common.delete"),children:e.jsx(T,{className:"h-3.5 w-3.5"})}):null]}),d.canDelete?null:e.jsx("div",{className:"text-[11px] text-muted-foreground/70",children:x("modelManagement.overview.endpointManagedExternally")})]},d.key)})})]}):null]})})}function Qe(l,s){var h;if(!l)return[s("common.noData")];if((h=l.paths)!=null&&h.length){const r=l.paths.slice(0,2).map(a=>`${a.path} · ${_(a.protocol,s)}`);return l.paths.length>2&&r.push(s("modelManagement.overview.endpointMorePaths",{count:l.paths.length-2})),r}return l.path?[`${l.path} · ${_(l.protocol??"anthropic",s)}`]:[s("common.noData")]}function Xe({dialog:l,currentRoutes:s,onConfirm:h,onClose:r}){const{t:a}=E();if(!l)return null;const{endpoint:p,preset:m}=l,t=m.modelRoutes??{},x={};for(const i of s){const n=i.source.trim(),g=i.target.trim();n&&g&&(x[n]=g)}const N=new Set([...Object.keys(x),...Object.keys(t)]),d=[],b=[],o=[];for(const i of N){const n=i in x,g=i in t;g&&!n?d.push([i,t[i]]):n&&!g?b.push([i,x[i]]):n&&g&&x[i]!==t[i]&&o.push([i,x[i],t[i]])}const c=d.length>0||b.length>0||o.length>0;return e.jsx(Ae,{open:!0,onOpenChange:i=>!i&&r(),children:e.jsxs(Se,{className:"max-w-2xl",children:[e.jsxs(Te,{children:[e.jsx(Oe,{children:a("modelManagement.presets.diffTitle")}),e.jsx(Re,{children:a("modelManagement.presets.diffDescription",{name:m.name})})]}),e.jsx(_e,{children:c?e.jsxs("div",{className:"max-h-80 space-y-2 rounded-xl bg-secondary/50 p-3 text-sm",children:[d.map(([i,n])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-emerald-50 px-2 py-1.5 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200",children:[e.jsx(k,{variant:"outline",className:"border-emerald-300 text-xs dark:border-emerald-700",children:a("modelManagement.presets.diffAdded")}),e.jsx("span",{className:"truncate",children:i}),e.jsx(D,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n})]},`add-${i}`)),b.map(([i,n])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-red-50 px-2 py-1.5 text-red-800 dark:bg-red-950 dark:text-red-200",children:[e.jsx(k,{variant:"outline",className:"border-red-300 text-xs dark:border-red-700",children:a("modelManagement.presets.diffRemoved")}),e.jsx("span",{className:"truncate",children:i}),e.jsx(D,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n})]},`rm-${i}`)),o.map(([i,n,g])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-amber-50 px-2 py-1.5 text-amber-800 dark:bg-amber-950 dark:text-amber-200",children:[e.jsx(k,{variant:"outline",className:"border-amber-300 text-xs dark:border-amber-700",children:a("modelManagement.presets.diffChanged")}),e.jsx("span",{className:"truncate",children:i}),e.jsx(D,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate line-through opacity-60",children:n}),e.jsx(D,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:g})]},`chg-${i}`))]}):e.jsx("p",{className:"rounded-xl bg-secondary/50 py-8 text-center text-sm text-muted-foreground",children:a("modelManagement.presets.diffEmpty")})}),e.jsxs(Le,{children:[e.jsx(v,{variant:"outline",onClick:r,children:a("common.cancel")}),e.jsx(v,{onClick:()=>h(p,m),disabled:!c,children:a("modelManagement.presets.diffConfirm")})]})]})})}function Je({value:l,onChange:s,options:h,disabled:r,placeholder:a}){const{t:p}=E(),[m,t]=A.useState(!1),[x,N]=A.useState(""),d=A.useMemo(()=>{if(!x.trim())return h;const o=x.toLowerCase();return h.filter(c=>c.label.toLowerCase().includes(o)||c.value.toLowerCase().includes(o))},[h,x]),b=o=>{s(o),N(""),t(!1)};return e.jsxs($e,{open:m,onOpenChange:o=>{t(o),o&&N("")},children:[e.jsx(Ve,{asChild:!0,children:e.jsx(S,{value:l,onChange:o=>{s(o.target.value),N(o.target.value),m||t(!0)},onFocus:()=>{N(""),t(!0)},onClick:()=>{m||t(!0)},placeholder:a,disabled:r,autoComplete:"off"})}),e.jsx(Be,{className:"max-h-60 w-[var(--radix-popover-trigger-width)] overflow-y-auto rounded-xl border border-[color:var(--surface-border)] bg-popover/96 p-1.5 shadow-[var(--surface-shadow-lg)] backdrop-blur",align:"start",onOpenAutoFocus:o=>o.preventDefault(),children:d.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:p("common.noMatches")}):d.map(o=>e.jsx("button",{type:"button",className:O("flex w-full items-center rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-accent/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",o.value===l.trim()&&"bg-accent/90 text-accent-foreground"),onMouseDown:c=>{c.preventDefault(),b(o.value)},children:e.jsx("span",{className:"truncate",children:o.label})},o.value))})]})}function Ye({endpoint:l,tabs:s,customEndpoints:h,config:r,routes:a,routeError:p,savingRoute:m,isDirty:t,presets:x,presetName:N,presetError:d,savingPreset:b,applyingPreset:o,deletingPreset:c,presetsExpanded:i,savingClaudeValidation:n,savingCompatibilityPolicy:g,providerModelOptions:f,onTogglePresetsExpanded:M,onPresetNameChange:C,onSavePreset:le,onRequestPresetDiff:ie,onRequestDeletePreset:oe,onValidationModeChange:de,onCompatibilityEnabledChange:ce,onRouteChange:q,onRemoveRoute:I,onAddSuggestion:me,onAddRoute:xe,onResetRoutes:pe,onSaveRoutes:ue}){var W,Q;const{t:u}=E(),y=s.find(j=>j.key===l),L=((W=y==null?void 0:y.protocols)==null?void 0:W.includes("anthropic"))??l==="anthropic"?qe:Ie,ge=(y==null?void 0:y.label)??l;(y==null?void 0:y.isSystem)===!1?y.description:u(`settings.routing.descriptionByEndpoint.${l}`);const $=`route-source-${l}`,G=He(l,h),K=((Q=y==null?void 0:y.protocols)==null?void 0:Q.some(j=>j.startsWith("openai")))??l==="openai",V=ze(l,r,h),B=Fe(l,r,h),H=G?(V==null?void 0:V.mode)??"off":"off",U=K?(B==null?void 0:B.enabled)??!1:!1,he=new Set(a.map(j=>j.source.trim()).filter(Boolean)),fe=`modelManagement.claudeValidation.options.${H}.description`;return e.jsx(ne,{children:e.jsxs(re,{className:"space-y-6 pt-6",children:[e.jsx("div",{className:"rounded-full bg-secondary px-4 py-3 text-xs text-muted-foreground",children:u("settings.routing.wildcardHint")}),G?e.jsx("div",{className:"rounded-xl border border-primary/12 bg-[linear-gradient(135deg,hsl(var(--primary)/0.08),hsl(var(--accent)/0.72))] p-4 shadow-[var(--surface-shadow)] dark:border-sky-300/12 dark:bg-[linear-gradient(135deg,rgba(14,165,233,0.12),rgba(15,23,42,0.72))]",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-primary dark:text-sky-100",children:u("modelManagement.claudeValidation.title")}),e.jsx("p",{className:"max-w-2xl text-xs leading-5 text-muted-foreground dark:text-slate-300",children:u("modelManagement.claudeValidation.description")})]}),e.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-2 self-start sm:self-auto",children:[e.jsx(w,{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/70 dark:text-sky-200/75",children:u("modelManagement.claudeValidation.modeLabel")}),e.jsxs(Z,{value:H,onValueChange:j=>de(j),disabled:n,children:[e.jsx(ee,{className:"border-primary/15 bg-card/90 dark:border-white/10 dark:bg-slate-950/50",children:e.jsx(se,{})}),e.jsxs(ae,{children:[e.jsx(R,{value:"off",children:u("modelManagement.claudeValidation.options.off.label")}),e.jsx(R,{value:"anthropic-strict",children:u("modelManagement.claudeValidation.options.anthropic-strict.label")}),e.jsx(R,{value:"claude-code",children:u("modelManagement.claudeValidation.options.claude-code.label")})]})]}),e.jsx("span",{className:O("text-xs",H==="off"?"text-muted-foreground dark:text-slate-400":"text-primary/80 dark:text-sky-200/80"),children:u(fe)})]})]})}):null,K?e.jsx("div",{className:"rounded-xl border border-primary/12 bg-[linear-gradient(135deg,hsl(var(--primary)/0.08),hsl(var(--accent)/0.72))] p-4 shadow-[var(--surface-shadow)] dark:border-sky-300/12 dark:bg-[linear-gradient(135deg,rgba(14,165,233,0.12),rgba(15,23,42,0.72))]",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-primary dark:text-sky-100",children:u("modelManagement.openaiCompatibility.title")}),e.jsx("p",{className:"max-w-2xl text-xs leading-5 text-muted-foreground dark:text-slate-300",children:u("modelManagement.openaiCompatibility.description")})]}),e.jsx("div",{className:"flex w-full max-w-xs flex-col gap-2 self-start sm:self-auto",children:e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-primary/12 bg-card/85 px-3 py-2 dark:border-white/10 dark:bg-slate-950/50",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/70 dark:text-sky-200/75",children:u("modelManagement.openaiCompatibility.toggleLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground dark:text-slate-300",children:u(U?"modelManagement.openaiCompatibility.enabledHint":"modelManagement.openaiCompatibility.disabledHint")})]}),e.jsx(te,{checked:U,onCheckedChange:ce,disabled:g,"aria-label":u("modelManagement.openaiCompatibility.toggleLabel")})]})})]})}):null,p?e.jsx("p",{className:"text-sm text-destructive",children:p}):null,e.jsx(Ze,{presets:x,presetName:N,presetError:d,savingPreset:b,applyingPreset:o,deletingPreset:c,expanded:i,onToggleExpanded:M,onPresetNameChange:C,onSavePreset:le,onRequestPresetDiff:ie,onRequestDeletePreset:oe}),e.jsxs("div",{className:"space-y-3 rounded-xl bg-secondary/50 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(w,{className:"text-sm font-semibold text-foreground",children:u("modelManagement.routesEditorTitle")}),e.jsxs(k,{variant:"outline",children:[a.length," active"]})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:u("modelManagement.overview.routesEditorHint")})]}),e.jsxs("div",{className:"self-start rounded-full bg-card px-3 py-2 text-[11px] font-medium text-muted-foreground",children:["Active workspace · ",ge]})]}),a.length===0?e.jsxs("div",{className:"rounded-xl border-2 border-dashed border-border/30 bg-background/60 p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:u("settings.routing.empty")}),e.jsx("p",{className:"mt-2 text-xs",children:u("modelManagement.emptyRoutesHint")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"hidden grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] items-center gap-3 px-1 text-xs font-medium text-muted-foreground md:grid",children:[e.jsx("span",{children:u("settings.routing.source")}),e.jsx("span",{}),e.jsx("span",{children:u("settings.routing.target")}),e.jsx("span",{})]}),a.map((j,P)=>e.jsxs("div",{className:"rounded-xl bg-card p-3 shadow-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between md:hidden",children:[e.jsxs(k,{variant:"outline",className:"text-[11px]",children:["#",P+1]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>I(j.id),disabled:m,children:e.jsx(T,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{className:"text-[11px] uppercase tracking-[0.16em] text-muted-foreground md:hidden",children:u("settings.routing.source")}),e.jsx(S,{value:j.source,onChange:z=>q(j.id,"source",z.target.value),placeholder:u("settings.routing.sourcePlaceholder"),list:$,disabled:m,"aria-label":`route-source-${P+1}`})]}),e.jsx(D,{className:"hidden h-4 w-4 flex-shrink-0 text-muted-foreground md:block"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(w,{className:"text-[11px] uppercase tracking-[0.16em] text-muted-foreground md:hidden",children:u("settings.routing.target")}),e.jsx(Je,{value:j.target,onChange:z=>q(j.id,"target",z),options:f,disabled:m,placeholder:u("settings.routing.targetPlaceholder")})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 text-muted-foreground hover:text-destructive md:inline-flex",onClick:()=>I(j.id),disabled:m,children:e.jsx(T,{className:"h-4 w-4"})})]})]},j.id))]})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl bg-card p-4 shadow-[var(--surface-shadow)] md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:u("modelManagement.actions.footerTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u(t?"modelManagement.actions.footerDirtyHint":"modelManagement.actions.footerSavedHint")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3 md:flex md:flex-wrap md:items-center",children:[e.jsx(v,{variant:"outline",size:"sm",onClick:xe,disabled:m,className:"w-full",children:u("settings.routing.add")}),e.jsx(v,{variant:"outline",size:"sm",onClick:pe,disabled:m||!t,className:"w-full",children:u("common.actions.reset")}),e.jsxs(v,{size:"sm",onClick:ue,disabled:m,className:"relative w-full",children:[u(m?"common.actions.saving":"modelManagement.actions.saveRoutes"),t?e.jsx("span",{className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-amber-500"}):null]})]})]}),e.jsxs("div",{className:"space-y-3 rounded-xl bg-secondary/50 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(w,{className:"text-sm font-medium text-foreground",children:u("settings.routing.suggested")}),e.jsx(k,{variant:"outline",className:"text-[11px]",children:L.length})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:u("modelManagement.overview.suggestionHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:L.map(j=>{const P=he.has(j);return e.jsx(v,{variant:P?"ghost":"outline",size:"sm",onClick:()=>me(j),disabled:m||P,className:O("h-7 rounded-md px-2.5 text-[11px] font-normal",P?"opacity-45":"bg-background/70"),children:j},`${l}-${j}`)})})]}),e.jsx("datalist",{id:$,children:L.map(j=>e.jsx("option",{value:j},`${$}-${j}`))})]})})}function Ze({presets:l,presetName:s,presetError:h,savingPreset:r,applyingPreset:a,deletingPreset:p,expanded:m,onToggleExpanded:t,onPresetNameChange:x,onSavePreset:N,onRequestPresetDiff:d,onRequestDeletePreset:b}){const{t:o}=E();return e.jsxs("div",{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:[e.jsx("button",{type:"button",className:"flex w-full items-center justify-between gap-3 rounded-xl p-4 text-left transition-colors hover:bg-accent",onClick:t,children:e.jsxs("div",{className:"flex items-center gap-2",children:[m?e.jsx(be,{className:"h-4 w-4"}):e.jsx(ve,{className:"h-4 w-4"}),e.jsx("h3",{className:"font-medium",children:o("modelManagement.presets.title")}),e.jsx(k,{variant:"secondary",className:"text-xs",children:l.length})]})}),m?e.jsxs("div",{className:"space-y-4 border-t border-border/45 px-4 pb-4 pt-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:o("modelManagement.presets.description")}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center",children:[e.jsx(S,{value:s,onChange:c=>x(c.target.value),placeholder:o("modelManagement.presets.namePlaceholder"),disabled:r,className:"w-full md:w-48"}),e.jsx(v,{onClick:N,disabled:r,className:"w-full md:w-auto",children:o(r?"modelManagement.presets.saving":"modelManagement.presets.save")})]}),h?e.jsx("p",{className:"text-sm text-destructive",children:h}):null,l.length===0?e.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:o("modelManagement.presets.empty")}):e.jsx(Ce,{children:e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(c=>{const i=a===c.name,n=p===c.name,g=Object.entries(c.modelRoutes??{}),f=g.length;return e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl bg-secondary/50 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs(Ee,{children:[e.jsx(Pe,{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:c.name}),e.jsx(k,{variant:"outline",className:"mt-1 text-xs",children:f>0?o("modelManagement.presets.rulesCount",{count:f}):o("modelManagement.presets.noRules")})]})}),f>0?e.jsx(De,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[g.slice(0,5).map(([M,C])=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"truncate",children:M}),e.jsx(D,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:C})]},M)),f>5?e.jsxs("div",{className:"text-muted-foreground",children:["…+",f-5]}):null]})}):null]}),e.jsxs("div",{className:"grid flex-shrink-0 gap-2 sm:flex sm:items-center",children:[e.jsx(v,{size:"sm",onClick:()=>d(c),disabled:i||n,className:"w-full sm:w-auto",children:o(i?"modelManagement.presets.applying":"modelManagement.presets.apply")}),e.jsx(v,{variant:"destructive",size:"sm",onClick:()=>b(c),disabled:n||i,className:"w-full sm:w-auto",children:o(n?"modelManagement.presets.deleting":"modelManagement.presets.delete")})]})]},c.name)})})})]}):null]})}function ys(){var p,m;const{t:l}=E(),s=Ge(),h=s.systemTabs.filter(t=>t.key!=="providers"),r=s.activeTab==="providers"?"anthropic":s.activeTab,a=s.tabs.find(t=>t.key===r)??null;return A.useEffect(()=>{s.activeTab==="providers"&&s.setActiveTab("anthropic")},[s.activeTab,s.setActiveTab]),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Me,{icon:e.jsx(ye,{className:"h-5 w-5","aria-hidden":"true"}),title:l("routingManagement.title"),description:l("routingManagement.description"),eyebrow:l("routingManagement.eyebrow"),breadcrumb:"Gateway / Routing",badge:(a==null?void 0:a.label)??r,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx(v,{asChild:!0,variant:"outline",className:"w-full sm:w-auto",children:e.jsxs(we,{to:"/models",children:[e.jsx(Ne,{className:"h-4 w-4","aria-hidden":"true"}),l("nav.models")]})}),e.jsx(v,{onClick:s.handleOpenCreateEndpoint,className:"w-full sm:w-auto",children:l("modelManagement.addEndpoint")})]})}),e.jsx(We,{activeTab:r,customEndpoints:s.customEndpoints,customTabs:s.customTabs,isDirtyByEndpoint:s.isDirtyByEndpoint,onDeleteEndpoint:s.setConfirmAction,onEditEndpoint:s.handleOpenEditEndpoint,onSelectTab:s.setActiveTab,systemTabs:h}),e.jsx(Ye,{endpoint:r,applyingPreset:((p=s.applyingPreset)==null?void 0:p.endpoint)===r?s.applyingPreset.name:null,config:s.config,customEndpoints:s.customEndpoints,deletingPreset:((m=s.deletingPreset)==null?void 0:m.endpoint)===r?s.deletingPreset.name:null,isDirty:s.isDirtyByEndpoint[r]??!1,onAddRoute:()=>s.handleAddRoute(r),onAddSuggestion:t=>s.handleAddSuggestion(r,t),onPresetNameChange:t=>s.handlePresetNameChange(r,t),onRequestDeletePreset:t=>s.setConfirmAction({kind:"preset",endpoint:r,preset:t}),onRequestPresetDiff:t=>s.setPresetDiffDialog({endpoint:r,preset:t}),onRemoveRoute:t=>s.handleRemoveRoute(r,t),onResetRoutes:()=>s.handleResetRoutes(r),onRouteChange:(t,x,N)=>s.handleRouteChange(r,t,x,N),onSavePreset:()=>void s.handleSavePreset(r),onSaveRoutes:()=>void s.handleSaveRoutes(r),onCompatibilityEnabledChange:t=>void s.handleCompatibilityEnabledChange(r,t),onValidationModeChange:t=>void s.handleValidationModeChange(r,t),onTogglePresetsExpanded:()=>s.setPresetsExpanded(t=>({...t,[r]:!t[r]})),presetError:s.presetErrorByEndpoint[r],presetName:s.presetNameByEndpoint[r]??"",presets:s.presetsByEndpoint[r]??[],presetsExpanded:s.presetsExpanded[r]===!0,providerModelOptions:s.providerModelOptions,routeError:s.routeError[r],routes:s.routesByEndpoint[r]||[],savingClaudeValidation:s.savingClaudeValidation,savingCompatibilityPolicy:s.savingCompatibilityPolicy,savingPreset:s.savingPresetFor===r,savingRoute:s.savingRouteFor===r,tabs:s.tabs.filter(t=>t.key!=="providers")}),e.jsx(Ue,{open:s.endpointDrawerOpen,endpoint:s.editingEndpoint,onClose:()=>{s.setEndpointDrawerOpen(!1),s.setEditingEndpoint(void 0)},onSuccess:()=>{s.configQuery.refetch()}}),e.jsx(Xe,{dialog:s.presetDiffDialog,currentRoutes:s.presetDiffDialog?s.routesByEndpoint[s.presetDiffDialog.endpoint]||[]:[],onConfirm:(t,x)=>{s.setPresetDiffDialog(null),s.handleApplyPreset(t,x)},onClose:()=>s.setPresetDiffDialog(null)}),e.jsx(ke,{open:!!s.confirmAction,onOpenChange:t=>{!t&&!s.confirmingAction&&s.setConfirmAction(null)},title:s.confirmDialogTitle,description:s.confirmDialogDescription,confirmLabel:s.confirmingAction?l("common.actions.loading"):l("common.delete"),cancelLabel:l("common.actions.cancel"),loading:s.confirmingAction,onConfirm:s.handleConfirmDialog,children:s.confirmDialogName?e.jsx("div",{className:"rounded-lg bg-destructive/5 px-3 py-2 font-mono text-xs text-foreground ring-1 ring-destructive/20",children:s.confirmDialogName}):null})]})}export{ys as default};