omniroute 2.7.5 → 2.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/build-manifest.json +2 -2
  3. package/app/.next/prerender-manifest.json +3 -3
  4. package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
  5. package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
  33. package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
  36. package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
  39. package/app/.next/server/app/_global-error.html +2 -2
  40. package/app/.next/server/app/_global-error.rsc +1 -1
  41. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  42. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  43. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  44. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  45. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  46. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/api/v1/chat/completions/route.js +2 -2
  48. package/app/.next/server/app/api/v1/completions/route.js +2 -2
  49. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  54. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  59. package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
  60. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  61. package/app/.next/server/chunks/[root-of-the-server]__09c944b3._.js +1 -1
  62. package/app/.next/server/chunks/[root-of-the-server]__12e1b68b._.js +1 -1
  63. package/app/.next/server/chunks/[root-of-the-server]__167585da._.js +1 -1
  64. package/app/.next/server/chunks/[root-of-the-server]__7d9b23e7._.js +1 -1
  65. package/app/.next/server/chunks/[root-of-the-server]__80e3bfc3._.js +2 -2
  66. package/app/.next/server/chunks/[root-of-the-server]__84e445b2._.js +1 -1
  67. package/app/.next/server/chunks/[root-of-the-server]__92cb0def._.js +1 -1
  68. package/app/.next/server/chunks/[root-of-the-server]__db2f9fe0._.js +1 -1
  69. package/app/.next/server/chunks/[root-of-the-server]__dc47ee64._.js +1 -1
  70. package/app/.next/server/chunks/_05c48915._.js +1 -1
  71. package/app/.next/server/chunks/_2115d8de._.js +1 -1
  72. package/app/.next/server/chunks/_3ac953eb._.js +1 -1
  73. package/app/.next/server/chunks/_4b8fd853._.js +1 -1
  74. package/app/.next/server/chunks/_68683848._.js +1 -1
  75. package/app/.next/server/chunks/_ee9b677b._.js +1 -1
  76. package/app/.next/server/chunks/open-sse_services_826884e1._.js +2 -2
  77. package/app/.next/server/chunks/ssr/[root-of-the-server]__9affb65e._.js +1 -1
  78. package/app/.next/server/chunks/ssr/[root-of-the-server]__a6942102._.js +1 -1
  79. package/app/.next/server/chunks/ssr/src_55fa8e28._.js +1 -1
  80. package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_cc92bcad._.js +1 -1
  81. package/app/.next/server/pages/500.html +2 -2
  82. package/app/.next/server/server-reference-manifest.js +1 -1
  83. package/app/.next/server/server-reference-manifest.json +1 -1
  84. package/app/.next/static/chunks/{78578600bdb6c280.js → 31d265d1cd5222f3.js} +1 -1
  85. package/app/.next/static/chunks/{cd0b93c0ed63a487.js → 3423ff268c85cc05.js} +1 -1
  86. package/app/.next/static/chunks/8c9234a3ed7f8c07.js +1 -0
  87. package/app/CHANGELOG.md +30 -0
  88. package/app/Dockerfile +4 -0
  89. package/app/docs/openapi.yaml +1 -1
  90. package/app/open-sse/services/comboAgentMiddleware.ts +19 -0
  91. package/app/package-lock.json +2 -2
  92. package/app/package.json +1 -1
  93. package/app/src/app/(dashboard)/dashboard/combos/page.tsx +80 -0
  94. package/app/src/app/(dashboard)/dashboard/usage/components/BudgetTab.tsx +7 -2
  95. package/app/src/app/api/v1/responses/route.ts +9 -12
  96. package/package.json +1 -1
  97. package/app/.next/static/chunks/c089b7e37ffa02b7.js +0 -1
  98. /package/app/.next/static/{sr8mILxXxauNpSSzV2kMh → V_vOqF97lGIlKgf2kSlun}/_buildManifest.js +0 -0
  99. /package/app/.next/static/{sr8mILxXxauNpSSzV2kMh → V_vOqF97lGIlKgf2kSlun}/_clientMiddlewareManifest.json +0 -0
  100. /package/app/.next/static/{sr8mILxXxauNpSSzV2kMh → V_vOqF97lGIlKgf2kSlun}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
- module.exports=[11002,a=>{"use strict";var b=a.i(187924),c=a.i(572131);function d({children:a,content:d,position:e="top",className:f="",delayMs:g=200}){let h,[i,j]=(0,c.useState)(!1),k=(0,c.useId)(),l=(0,c.useRef)(null),m=(0,c.useCallback)(()=>{clearTimeout(l.current),l.current=setTimeout(()=>j(!0),g)},[g]),n=(0,c.useCallback)(()=>{clearTimeout(l.current),j(!1)},[]);(0,c.useEffect)(()=>()=>{clearTimeout(l.current)},[]);let o={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},p=d?k:void 0,q=(0,c.isValidElement)(a)?(h=[a.props["aria-describedby"],p].filter(Boolean).join(" "),(0,c.cloneElement)(a,{"aria-describedby":h||void 0})):(0,b.jsx)("span",{tabIndex:0,"aria-describedby":p,children:a});return(0,b.jsxs)("span",{className:`relative inline-flex ${f}`,onMouseEnter:m,onMouseLeave:n,onFocus:m,onBlur:n,onKeyDown:a=>{"Escape"===a.key&&n()},children:[q,i&&d&&(0,b.jsx)("span",{id:k,role:"tooltip",className:`absolute z-50 px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900/95 rounded-md shadow-lg whitespace-nowrap pointer-events-none animate-in fade-in duration-150 motion-reduce:transition-none motion-reduce:animate-none border border-white/10 ${o[e]||o.top}`,children:d})]})}a.s(["default",()=>d])},560314,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(292216),h=a.i(294023),i=a.i(563203),j=a.i(489108),k=a.i(709918),l=a.i(831097),m=a.i(959852),n=a.i(248172),o=a.i(609754),p=a.i(11002),q=a.i(386592),r=a.i(240246),s=a.i(415925),t=b([f,m]);[f,m]=t.then?(await t)():t;let L=/^[a-zA-Z0-9_/.-]+$/,M=[{value:"priority",labelKey:"priority",descKey:"priorityDesc",icon:"sort"},{value:"weighted",labelKey:"weighted",descKey:"weightedDesc",icon:"percent"},{value:"round-robin",labelKey:"roundRobin",descKey:"roundRobinDesc",icon:"autorenew"},{value:"random",labelKey:"random",descKey:"randomDesc",icon:"shuffle"},{value:"least-used",labelKey:"leastUsed",descKey:"leastUsedDesc",icon:"low_priority"},{value:"cost-optimized",labelKey:"costOpt",descKey:"costOptimizedDesc",icon:"savings"},{value:"fill-first",labelKey:"fillFirst",descKey:"fillFirstDesc",icon:"stacked_bar_chart"},{value:"p2c",labelKey:"p2c",descKey:"p2cDesc",icon:"compare_arrows"},{value:"strict-random",labelKey:"strictRandom",descKey:"strictRandomDesc",icon:"casino"}],N={priority:{when:"Use when you have one preferred model and only want fallback on failure.",avoid:"Avoid when you need balanced load between models.",example:"Example: Primary coding model with cheaper backup for outages."},weighted:{when:"Use when you need controlled traffic split across models.",avoid:"Avoid when weights are not maintained or you need strict fairness.",example:"Example: 80% stable model and 20% canary model for safe rollout."},"round-robin":{when:"Use when you need predictable, even request distribution.",avoid:"Avoid when model latency/cost differs significantly.",example:"Example: Same model across multiple accounts to spread throughput."},random:{when:"Use when you want a simple spread with low configuration effort.",avoid:"Avoid when requests must be distributed with strict guarantees.",example:"Example: Prototyping with equivalent models and no traffic policy."},"least-used":{when:"Use when you want adaptive balancing based on recent demand.",avoid:"Avoid when your traffic is too low to benefit from usage balancing.",example:"Example: Mixed workloads where one model tends to get overloaded."},"cost-optimized":{when:"Use when minimizing cost is the top priority.",avoid:"Avoid when pricing data is missing or outdated.",example:"Example: Batch or background jobs where lower cost matters most."},"fill-first":{when:"Use when you want to drain one provider's quota fully before moving to the next.",avoid:"Avoid when you need request-level load balancing across providers.",example:"Example: Use all $200 Deepgram credits before falling to Groq."},p2c:{when:"Use when you want low-latency selection using Power-of-Two-Choices algorithm.",avoid:"Avoid for small combos with 2 or fewer models — no benefit over round-robin.",example:"Example: High-throughput inference across 4+ equivalent model endpoints."},"strict-random":{when:"Use when you want perfectly even spread — each model used once before repeating.",avoid:"Avoid when models have different quality or latency and order matters.",example:"Example: Multiple accounts of the same model to distribute usage evenly."}},O={priority:{title:"Fail-safe baseline",description:"Use one primary model and keep fallback chain short and reliable.",tips:["Put your most reliable model first.","Keep 1-2 backup models with similar quality.","Use safe retries to absorb transient provider failures."]},weighted:{title:"Controlled traffic split",description:"Great for canary rollouts and gradual migration between models.",tips:["Start with conservative split like 90/10.","Keep the total at 100% and auto-balance after changes.","Monitor success and latency before increasing canary weight."]},"round-robin":{title:"Predictable load sharing",description:"Best when models are equivalent and you need smooth distribution.",tips:["Use at least 2 models.","Set concurrency limits to avoid burst overload.","Use queue timeout to fail fast under saturation."]},random:{title:"Quick spread with low setup",description:"Use when you need simple distribution without strict guarantees.",tips:["Use models with similar latency profiles.","Keep retries enabled to absorb random misses.","Prefer this for experimentation, not strict SLAs."]},"least-used":{title:"Adaptive balancing",description:"Routes to less-used models to reduce hotspots over time.",tips:["Works better under continuous traffic.","Combine with health checks for safer balancing.","Track per-model usage to validate distribution gains."]},"cost-optimized":{title:"Budget-first routing",description:"Routes to lower-cost models when pricing metadata is available.",tips:["Ensure pricing coverage for all selected models.","Keep a quality fallback for hard prompts.","Use for batch/background jobs where cost is the main KPI."]},"fill-first":{title:"Quota drain strategy",description:"Exhausts one provider's quota before moving to the next in chain.",tips:["Order models by free quota size — biggest first.","Enable health checks to skip drained providers.","Ideal for free-tier stacking (Deepgram → Groq → NIM)."]},p2c:{title:"Power-of-Two-Choices",description:"Picks the less-loaded of two random candidates per request — low latency at scale.",tips:["Use with 4+ models for best effect.","Requires latency telemetry enabled in Settings.","Great replacement for round-robin in high-throughput combos."]},"strict-random":{title:"Shuffle deck distribution",description:"Each model is used exactly once per cycle before reshuffling.",tips:["Use at least 2 models for meaningful distribution.","Ideal for same-model accounts to evenly spread quota.","Guarantees no model is skipped or repeated within a cycle."]}},P="omniroute:combos:hide-usage-guide",Q=[{id:"free-stack",icon:"volunteer_activism",titleKey:"templateFreeStack",descKey:"templateFreeStackDesc",fallbackTitle:"Free Stack ($0)",fallbackDesc:"Round-robin across all free providers: Kiro, iFlow, Qwen, Gemini CLI. Zero cost, never stops.",strategy:"round-robin",suggestedName:"free-stack",isFeatured:!0,config:{maxRetries:3,retryDelayMs:500,healthCheckEnabled:!0}},{id:"high-availability",icon:"shield",titleKey:"templateHighAvailability",descKey:"templateHighAvailabilityDesc",fallbackTitle:"High availability",fallbackDesc:"Priority routing with health checks and safe retries.",strategy:"priority",suggestedName:"high-availability",config:{maxRetries:2,retryDelayMs:1500,healthCheckEnabled:!0}},{id:"cost-saver",icon:"savings",titleKey:"templateCostSaver",descKey:"templateCostSaverDesc",fallbackTitle:"Cost saver",fallbackDesc:"Cost-optimized routing for budget-first workloads.",strategy:"cost-optimized",suggestedName:"cost-saver",config:{maxRetries:1,retryDelayMs:500,healthCheckEnabled:!0}},{id:"balanced",icon:"balance",titleKey:"templateBalanced",descKey:"templateBalancedDesc",fallbackTitle:"Balanced load",fallbackDesc:"Least-used routing to spread demand over time.",strategy:"least-used",suggestedName:"balanced-load",config:{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0}}];function u(a){return M.find(b=>b.value===a)||M[0]}function v(a,b){return a(u(b).labelKey)}function w(a,b){return a(u(b).descKey)}function x(a,b,c){return"function"==typeof a.has&&a.has(b)?a(b):c}function y(a,b,c){let d=N[b]||N.priority,e=`strategyGuide.${b}.${c}`;return x(a,e,d[c])}function z(a,b,c){let d=O[b]||O.priority;return"tips"===c?d.tips.map((c,d)=>x(a,`strategyRecommendations.${b}.tip${d+1}`,c)):x(a,`strategyRecommendations.${b}.${c}`,d[c])}function A(a){return"string"==typeof a?{model:a,weight:0}:{model:a.model,weight:a.weight||0}}function B(){let a=(0,s.useTranslations)("combos"),b=(0,s.useTranslations)("common"),[c,f]=(0,e.useState)([]),[j,k]=(0,e.useState)(!0),[m,p]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)([]),[y,z]=(0,e.useState)({}),[A,B]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),{copied:F,copy:G}=(0,q.useCopyToClipboard)(),K=(0,r.useNotificationStore)(),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(null),[Q,R]=(0,e.useState)([]),[S,T]=(0,e.useState)(!0),[U,V]=(0,e.useState)("");(0,e.useEffect)(()=>{W(),fetch("/api/settings/proxy").then(a=>a.ok?a.json():null).then(a=>O(a)).catch(()=>{})},[]),(0,e.useEffect)(()=>{try{globalThis.localStorage?.getItem(P)==="1"&&T(!1)}catch{}},[]);let W=async()=>{try{let[a,b,c,d]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/combos/metrics"),fetch("/api/provider-nodes")]),e=await a.json(),g=await b.json(),h=await c.json(),i=d.ok?await d.json():{nodes:[]};if(a.ok&&f(e.combos||[]),b.ok){let a=(g.connections||[]).filter(a=>"active"===a.testStatus||"success"===a.testStatus);w(a)}c.ok&&z(h.metrics||{}),R(i.nodes||[])}catch(a){console.log("Error fetching data:",a)}finally{k(!1)}},X=async b=>{try{let c=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(c.ok)await W(),p(!1),V(b.name?.trim()||""),K.success(a("comboCreated"));else{let b=await c.json();K.error(b.error?.message||b.error||a("failedCreate"))}}catch(b){K.error(a("errorCreating"))}},Y=async(b,c)=>{try{let d=await fetch(`/api/combos/${b}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(d.ok)await W(),u(null),K.success(a("comboUpdated"));else{let b=await d.json();K.error(b.error?.message||b.error||a("failedUpdate"))}}catch(b){K.error(a("errorUpdating"))}},Z=async b=>{if(confirm(a("deleteConfirm")))try{(await fetch(`/api/combos/${b}`,{method:"DELETE"})).ok&&(f(c.filter(a=>a.id!==b)),K.success(a("comboDeleted")))}catch(b){K.error(a("errorDeleting"))}},$=async a=>{let b=a.name.replace(/-copy(-\d+)?$/,""),d=c.map(a=>a.name),e=`${b}-copy`,f=1;for(;d.includes(e);)f++,e=`${b}-copy-${f}`;let g={name:e,models:a.models,strategy:a.strategy||"priority",config:a.config||{}};await X(g)},_=async b=>{E(b.name),B(null);try{let a=await fetch("/api/combos/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:b.name})}),c=await a.json();B(c)}catch(b){B({error:a("testFailed")}),K.error(a("testFailed"))}},aa=async b=>{let c=!1===b.isActive;f(a=>a.map(a=>a.id===b.id?{...a,isActive:c}:a));try{await fetch(`/api/combos/${b.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:c})})}catch(d){f(a=>a.map(a=>a.id===b.id?{...a,isActive:!c}:a)),K.error(a("failedToggle"))}};return j?(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(l.CardSkeleton,{}),(0,d.jsx)(l.CardSkeleton,{})]}):(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-semibold",children:a("title")}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-1",children:a("description")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[!S&&(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:()=>{T(!0);try{globalThis.localStorage?.removeItem(P)}catch{}},children:x(a,"usageGuideShow","Show guide")}),(0,d.jsx)(h.Button,{icon:"add",onClick:()=>p(!0),children:a("createCombo")})]})]}),S&&(0,d.jsx)(C,{onHide:()=>T(!1),onHideForever:()=>{T(!1);try{globalThis.localStorage?.setItem(P,"1")}catch{}}}),U&&(0,d.jsx)(g.Card,{padding:"sm",className:"border border-emerald-500/20 bg-emerald-500/[0.04] dark:bg-emerald-500/[0.08]",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-emerald-700 dark:text-emerald-300",children:x(a,"quickTestTitle",`Combo "${U}" ready to validate`)}),(0,d.jsx)("code",{className:"inline-block text-[11px] mt-0.5 px-1.5 py-0.5 rounded bg-emerald-500/15 text-emerald-700 dark:text-emerald-300",children:U}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:x(a,"quickTestDescription","Run a test now to confirm fallback and latency behavior.")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"play_arrow",onClick:()=>{_({name:U}),V("")},children:x(a,"testNow","Test now")}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:()=>V(""),children:b("close")})]})]})}),0===c.length?(0,d.jsx)(o.EmptyState,{icon:"🧩",title:a("noCombosYet"),description:a("description"),actionLabel:a("createCombo"),onAction:()=>p(!0)}):(0,d.jsx)("div",{className:"flex flex-col gap-4",children:c.map(a=>(0,d.jsx)(H,{combo:a,metrics:y[a.name],providerNodes:Q,copied:F,onCopy:G,onEdit:()=>u(a),onDelete:()=>Z(a.id),onDuplicate:()=>$(a),onTest:()=>_(a),testing:D===a.name,onProxy:()=>M(a),hasProxy:!!N?.combos?.[a.id],onToggle:()=>aa(a)},a.id))}),A&&(0,d.jsx)(i.Modal,{isOpen:!!A,onClose:()=>{B(null),E(null)},title:a("testResults",{name:D}),children:(0,d.jsx)(I,{results:A})}),(0,d.jsx)(J,{isOpen:m,onClose:()=>p(!1),onSave:X,activeProviders:v,combo:null},"create"),(0,d.jsx)(J,{isOpen:!!t,combo:t,onClose:()=>u(null),onSave:a=>Y(t.id,a),activeProviders:v},t?.id||"new"),L&&(0,d.jsx)(n.ProxyConfigModal,{isOpen:!!L,onClose:()=>M(null),level:"combo",levelId:L.id,levelLabel:L.name})]})}function C({onHide:a,onHideForever:b}){let c=(0,s.useTranslations)("combos");return(0,d.jsxs)(g.Card,{padding:"sm",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("div",{className:"size-7 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[16px]",children:"tips_and_updates"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-semibold",children:c("routingStrategy")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:c("description")})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:a,className:"!h-6 px-2 text-[10px]",children:x(c,"usageGuideHide","Hide")}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:b,className:"!h-6 px-2 text-[10px]",children:x(c,"usageGuideDontShowAgain","Don't show again")})]})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2 mt-3",children:["priority","cost-optimized","least-used"].map(a=>{let b=u(a);return(0,d.jsxs)("div",{className:"rounded-lg border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.02] p-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:b.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:v(c,a)})]}),(0,d.jsx)("p",{className:"text-[11px] leading-4 text-text-muted mt-1.5",children:w(c,a)})]},a)})})]})}function D({strategy:a}){let b=(0,s.useTranslations)("combos");return(0,d.jsxs)("div",{className:"rounded-lg border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.02] p-2.5",children:[(0,d.jsx)("div",{className:"text-[11px] text-text-muted",children:x(b,"strategyGuideTitle","How to use this strategy")}),(0,d.jsxs)("div",{className:"mt-1.5 flex flex-col gap-1.5 text-[11px]",children:[(0,d.jsxs)("p",{className:"text-text-main",children:[(0,d.jsxs)("span",{className:"font-semibold",children:[x(b,"strategyGuideWhen","When to use"),":"]})," ",y(b,a,"when")]}),(0,d.jsxs)("p",{className:"text-text-main",children:[(0,d.jsxs)("span",{className:"font-semibold",children:[x(b,"strategyGuideAvoid","Avoid when"),":"]})," ",y(b,a,"avoid")]}),(0,d.jsxs)("p",{className:"text-text-main",children:[(0,d.jsxs)("span",{className:"font-semibold",children:[x(b,"strategyGuideExample","Example"),":"]})," ",y(b,a,"example")]})]})]})}function E({strategy:a,onApply:b,showNudge:c}){let e=(0,s.useTranslations)("combos"),f=v(e,a),g=z(e,a,"title"),i=z(e,a,"description"),j=z(e,a,"tips");return(0,d.jsxs)("div",{className:"rounded-lg border border-black/10 dark:border-white/10 bg-white/70 dark:bg-white/[0.02] p-2.5",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[11px] text-text-muted",children:x(e,"recommendationsLabel","Recommended setup")}),(0,d.jsxs)("p",{className:"text-xs font-semibold text-text-main mt-0.5",children:[g," · ",(0,d.jsx)("span",{className:"text-primary",children:f})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:i})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:b,className:"!h-6 px-2 text-[10px]",children:x(e,"applyRecommendations","Apply recommendations")})]}),(0,d.jsx)("div",{className:"mt-2 grid grid-cols-1 gap-1",children:j.map((b,c)=>(0,d.jsxs)("div",{className:"flex items-start gap-1 rounded-md bg-black/[0.02] dark:bg-white/[0.03] px-1.5 py-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary mt-0.5",children:"check"}),(0,d.jsx)("p",{className:"text-[10px] text-text-main",children:b})]},`${a}-tip-${c+1}`))}),c&&(0,d.jsx)("div",{"data-testid":"strategy-change-nudge",className:"mt-2 rounded-md border border-primary/20 bg-primary/10 px-2 py-1 text-[10px] text-primary",children:x(e,"recommendationsUpdated","Recommendations updated for {strategy}.").replace("{strategy}",f)})]})}function F({label:a,help:b}){return(0,d.jsxs)("div",{className:"flex items-center gap-1 mb-0.5",children:[(0,d.jsx)("label",{className:"text-[10px] text-text-muted",children:a}),(0,d.jsx)(p.default,{content:b,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-text-muted cursor-help",children:"help"})})]})}function G({checks:a,blockers:b}){let c=(0,s.useTranslations)("combos"),e=b.length>0;return(0,d.jsxs)("div",{"data-testid":"combo-readiness-panel",className:`rounded-lg border px-2.5 py-2 ${e?"border-amber-500/30 bg-amber-500/5":"border-emerald-500/20 bg-emerald-500/[0.04]"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${e?"text-amber-600 dark:text-amber-400":"text-emerald-600 dark:text-emerald-400"}`,children:e?"rule":"check_circle"}),(0,d.jsx)("p",{className:"text-[11px] font-medium text-text-main",children:x(c,"readinessTitle","Ready to save?")})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:x(c,"readinessDescription","Review the checklist before creating or updating this combo.")}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1 mt-2",children:a.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-1 rounded-md px-1.5 py-1 bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[12px] ${a.ok?"text-emerald-500":"text-amber-500"}`,children:a.ok?"task_alt":"pending"}),(0,d.jsx)("span",{className:"text-[10px] text-text-main",children:a.label})]},a.id))}),e&&(0,d.jsxs)("div",{"data-testid":"combo-save-blockers",className:"mt-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1.5",children:[(0,d.jsx)("p",{className:"text-[10px] font-medium text-amber-700 dark:text-amber-300",children:x(c,"saveBlockedTitle","Save is blocked until the following items are fixed:")}),(0,d.jsx)("div",{className:"mt-1 flex flex-col gap-0.5",children:b.map((a,b)=>(0,d.jsxs)("p",{className:"text-[10px] text-amber-700 dark:text-amber-300",children:["• ",a]},`${a}-${b}`))})]})]})}function H({combo:a,metrics:b,copied:c,onCopy:e,onEdit:f,onDelete:h,onDuplicate:i,onTest:j,testing:l,onProxy:m,hasProxy:n,onToggle:o,providerNodes:q}){let r=a.strategy||"priority",t=a.models||[],u=!1===a.isActive,x=(0,s.useTranslations)("combos"),y=(0,s.useTranslations)("common"),z=w(x,r);return(0,d.jsx)(g.Card,{padding:"sm",className:`group ${u?"opacity-50":""}`,children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"text-sm font-medium font-mono truncate",children:a.name}),(0,d.jsx)(p.default,{content:z,children:(0,d.jsx)("span",{className:`text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full ${"weighted"===r?"bg-amber-500/15 text-amber-600 dark:text-amber-400":"round-robin"===r?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"random"===r?"bg-purple-500/15 text-purple-600 dark:text-purple-400":"least-used"===r?"bg-cyan-500/15 text-cyan-600 dark:text-cyan-400":"cost-optimized"===r?"bg-teal-500/15 text-teal-600 dark:text-teal-400":"fill-first"===r?"bg-orange-500/15 text-orange-600 dark:text-orange-400":"p2c"===r?"bg-indigo-500/15 text-indigo-600 dark:text-indigo-400":"bg-blue-500/15 text-blue-600 dark:text-blue-400"}`,children:v(x,r)})}),n&&(0,d.jsxs)("span",{className:"text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full bg-primary/15 text-primary flex items-center gap-0.5",title:x("proxyConfigured"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"vpn_lock"}),"proxy"]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),e(a.name,`combo-${a.id}`)},className:"p-0.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors opacity-100 md:opacity-0 md:group-hover:opacity-100",title:x("copyComboName"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:c===`combo-${a.id}`?"check":"content_copy"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[0===t.length?(0,d.jsx)("span",{className:"text-xs text-text-muted italic",children:x("noModels")}):t.slice(0,3).map((a,b)=>{let{model:c,weight:e}=A(a);return(0,d.jsxs)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1.5 py-0.5 rounded text-text-muted",children:[(a=>{let b=a.split("/");if(2!==b.length)return a;let[c,d]=b,e=(q||[]).find(a=>a.id===c||a.prefix===c);return e?`${e.name}/${d}`:a})(c),"weighted"===r&&e>0?` (${e}%)`:""]},b)}),t.length>3&&(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:x("more",{count:t.length-3})})]}),b&&(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1",children:[(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[(0,d.jsx)("span",{className:"text-emerald-500",children:b.totalSuccesses}),"/",b.totalRequests," ",x("reqs")]}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[b.successRate,"% ",x("success")]}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:["~",b.avgLatencyMs,"ms"]}),b.fallbackRate>0&&(0,d.jsxs)("span",{className:"text-[10px] text-amber-500",children:[b.fallbackRate,"% fallback"]})]})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[(0,d.jsx)(k.Toggle,{size:"sm",checked:!u,onChange:o,title:x(u?"enableCombo":"disableCombo")}),(0,d.jsxs)("div",{className:"flex items-center gap-1 transition-opacity",children:[(0,d.jsx)("button",{onClick:j,disabled:l,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-emerald-500 transition-colors",title:x("testCombo"),children:(0,d.jsx)("span",{className:`material-symbols-outlined text-[16px] ${l?"animate-spin":""}`,children:l?"progress_activity":"play_arrow"})}),(0,d.jsx)("button",{onClick:i,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:x("duplicate"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})}),(0,d.jsx)("button",{onClick:m,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:x("proxyConfig"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"vpn_lock"})}),(0,d.jsx)("button",{onClick:f,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:y("edit"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),(0,d.jsx)("button",{onClick:h,className:"p-1.5 hover:bg-red-500/10 rounded text-red-500 transition-colors",title:y("delete"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]})]})})}function I({results:a}){return a.error?(0,d.jsxs)("div",{className:"flex items-center gap-2 text-red-500 text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"error"}),"string"==typeof a.error?a.error:JSON.stringify(a.error)]}):(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.resolvedBy&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-emerald-500 text-[18px]",children:"check_circle"}),(0,d.jsxs)("span",{children:["Resolved by:"," ",(0,d.jsx)("code",{className:"text-xs bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 px-1.5 py-0.5 rounded",children:a.resolvedBy})]})]}),a.results?.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs px-2 py-1.5 rounded bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${"ok"===a.status?"text-emerald-500":"skipped"===a.status?"text-text-muted":"text-red-500"}`,children:"ok"===a.status?"check_circle":"skipped"===a.status?"skip_next":"error"}),(0,d.jsx)("code",{className:"font-mono flex-1",children:a.model}),void 0!==a.latencyMs&&(0,d.jsxs)("span",{className:"text-text-muted",children:[a.latencyMs,"ms"]}),(0,d.jsx)("span",{className:`text-[10px] uppercase font-medium ${"ok"===a.status?"text-emerald-500":"skipped"===a.status?"text-text-muted":"text-red-500"}`,children:a.status})]},b))]})}function J({isOpen:a,combo:b,onClose:c,onSave:f,activeProviders:g}){let k=(0,s.useTranslations)("combos"),l=(0,s.useTranslations)("common"),n=(0,r.useNotificationStore)(),[o,q]=(0,e.useState)(b?.name||""),[t,u]=(0,e.useState)(()=>(b?.models||[]).map(a=>A(a))),[y,z]=(0,e.useState)(b?.strategy||"priority"),[B,C]=(0,e.useState)(!1),[H,I]=(0,e.useState)(!1),[J,N]=(0,e.useState)(""),[O,P]=(0,e.useState)({}),[R,S]=(0,e.useState)({}),[T,U]=(0,e.useState)([]),[V,W]=(0,e.useState)(!1),[X,Y]=(0,e.useState)(b?.config||{}),[Z,$]=(0,e.useState)(!1),_=(0,e.useRef)(!1),aa=(0,e.useCallback)(a=>{let b=a.split("/");if(2!==b.length)return!1;let[c,d]=b,e=T.find(a=>a.id===c||a.prefix===c),f=[c];return e?.apiType&&f.push(e.apiType),e?.name&&f.push(String(e.name).toLowerCase()),f.some(a=>!!O?.[a]?.[d])},[O,T]),[ab,ac]=(0,e.useState)(null),[ad,ae]=(0,e.useState)(null),af=t.reduce((a,b)=>a+(b.weight||0),0),ag=t.reduce((a,b)=>a+ +!!aa(b.model),0),ah=t.length>0?Math.round(ag/t.length*100):0,ai=0===t.length,aj="round-robin"===y&&1===t.length,ak="cost-optimized"===y&&t.length>0&&0===ag,al="cost-optimized"===y&&t.length>0&&ag>0&&ag<t.length,am="weighted"===y&&t.length>0&&100!==af,an=!o.trim()||!!J||H||ai||am||ak,ao=[{id:"name",ok:!!o.trim()&&!J,label:x(k,"readinessCheckName","Combo name is valid")},{id:"models",ok:!ai,label:x(k,"readinessCheckModels","At least one model is selected")},{id:"weights",ok:"weighted"!==y||!am,label:"weighted"===y?x(k,"readinessCheckWeights","Weighted total is 100%"):x(k,"readinessCheckWeightsOptional","Weight rule not required")},{id:"pricing",ok:"cost-optimized"!==y||!ak,label:"cost-optimized"===y?x(k,"readinessCheckPricing","Pricing data is available"):x(k,"readinessCheckPricingOptional","Pricing rule not required")}],ap=[];o.trim()?J&&ap.push(J):ap.push(x(k,"saveBlockName","Define a combo name.")),ai&&ap.push(x(k,"saveBlockModels","Add at least one model.")),am&&ap.push("function"==typeof k.has&&k.has("saveBlockWeighted")?k("saveBlockWeighted",{total:af}):`Set weights to 100% (current: ${af}%).`),ak&&ap.push(x(k,"saveBlockPricing","Add pricing for at least one model or choose a different strategy."));let aq=async()=>{try{let[a,b,c]=await Promise.all([fetch("/api/models/alias"),fetch("/api/provider-nodes"),fetch("/api/pricing")]);if(!a.ok||!b.ok)throw Error(`Failed to fetch data: aliases=${a.status}, nodes=${b.status}`);let d=c.ok?await c.json():{},[e,f]=await Promise.all([a.json(),b.json()]);P(d&&"object"==typeof d&&!Array.isArray(d)?d:{}),S(e.aliases||{}),U(f.nodes||[])}catch(a){console.error("Error fetching modal data:",a)}};(0,e.useEffect)(()=>{a&&aq()},[a]),(0,e.useEffect)(()=>{if(!_.current){_.current=!0;return}$(!0);let a=setTimeout(()=>$(!1),2600);return()=>clearTimeout(a)},[y]);let ar=a=>a.trim()?L.test(a)?(N(""),!0):(N(k("nameInvalid")),!1):(N(k("nameRequired")),!1),as=()=>{let a=t.length;if(0===a)return;let b=Math.floor(100/a),c=100-b*a;u(t.map((a,d)=>({...a,weight:b+(0===d?c:0)})))},at=[{model:"gc/gemini-3-flash-preview",weight:0},{model:"kr/claude-sonnet-4.5",weight:0},{model:"if/kimi-k2-thinking",weight:0},{model:"if/qwen3-coder-plus",weight:0},{model:"qw/qwen3-coder-plus",weight:0},{model:"nvidia/llama-3.3-70b-instruct",weight:0},{model:"groq/llama-3.3-70b-versatile",weight:0}],au=(0,e.useCallback)(a=>{let b=a.split("/");if(2!==b.length)return a;let[c,d]=b,e=T.find(a=>a.id===c||a.prefix===c);return e?`${e.name}/${d}`:a},[T]),av=a=>{a.target&&(a.currentTarget.style.opacity="1"),ac(null),ae(null)},aw=async()=>{if(!ar(o)||ai||am||ak)return;I(!0);let a={name:o.trim(),models:"weighted"===y?t:t.map(a=>a.model),strategy:y},b={...X};"round-robin"===y&&(void 0!==X.concurrencyPerModel&&(b.concurrencyPerModel=X.concurrencyPerModel),void 0!==X.queueTimeoutMs&&(b.queueTimeoutMs=X.queueTimeoutMs)),Object.keys(b).length>0&&(a.config=b),await f(a),I(!1)},ax=!!b;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.Modal,{isOpen:a,onClose:c,title:ax?k("editCombo"):k("createCombo"),size:"full",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)(j.Input,{label:k("comboName"),value:o,onChange:a=>{let b=a.target.value;q(b),b?ar(b):N("")},placeholder:k("comboNamePlaceholder"),error:J}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:k("nameHint")})]}),!ax&&(0,d.jsxs)("div",{className:"rounded-lg border border-black/8 dark:border-white/8 bg-black/[0.02] dark:bg-white/[0.02] p-3",children:[(0,d.jsxs)("div",{className:"mb-2",children:[(0,d.jsx)("p",{className:"text-xs font-medium",children:x(k,"templatesTitle","Quick templates")}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:x(k,"templatesDescription","Apply a starting profile, then adjust models and config.")})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mt-1",children:Q.map(a=>(0,d.jsxs)("button",{type:"button",onClick:()=>{z(a.strategy),Y(b=>({...b,...a.config})),!o.trim()&&q(a.suggestedName),"free-stack"===a.id&&u(at)},className:`text-left rounded-md border px-3 py-2 transition-all ${a.isFeatured?"border-emerald-500/50 bg-emerald-500/5 hover:border-emerald-500/80 hover:bg-emerald-500/10 ring-1 ring-emerald-500/20":"border-black/10 dark:border-white/10 bg-white/70 dark:bg-white/[0.03] hover:border-primary/40 hover:bg-primary/5"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[16px] ${a.isFeatured?"text-emerald-500":"text-primary"}`,children:a.icon}),(0,d.jsx)("span",{className:"text-[12px] font-semibold text-text-main",children:x(k,a.titleKey,a.fallbackTitle)}),a.isFeatured&&(0,d.jsx)("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 px-1.5 py-0.5 rounded",children:"FREE"})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-1.5 leading-[1.5]",children:x(k,a.descKey,a.fallbackDesc)}),(0,d.jsxs)("p",{className:`text-[10px] mt-1.5 font-medium ${a.isFeatured?"text-emerald-500":"text-primary"}`,children:[x(k,"templateApply","Apply template")," →"]})]},a.id))})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,d.jsx)("label",{className:"text-sm font-medium",children:k("routingStrategy")}),(0,d.jsx)(p.default,{content:w(k,y),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[13px] text-text-muted cursor-help",children:"help"})})]}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-1 p-0.5 bg-black/5 dark:bg-white/5 rounded-lg",children:M.map(a=>(0,d.jsxs)("button",{onClick:()=>z(a.value),"data-testid":`strategy-option-${a.value}`,title:k(a.descKey),"aria-label":`${v(k,a.value)}. ${k(a.descKey)}`,className:`py-1.5 px-2 rounded-md text-xs font-medium transition-all ${y===a.value?"bg-white dark:bg-bg-main shadow-sm text-primary":"text-text-muted hover:text-text-main"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] align-middle mr-0.5",children:a.icon}),v(k,a.value)]},a.value))}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:w(k,y)}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(D,{strategy:y})}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(E,{strategy:y,onApply:()=>{let a={priority:{maxRetries:2,retryDelayMs:1500,healthCheckEnabled:!0},weighted:{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0},"round-robin":{maxRetries:1,retryDelayMs:750,healthCheckEnabled:!0,concurrencyPerModel:3,queueTimeoutMs:3e4},random:{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0},"least-used":{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0},"cost-optimized":{maxRetries:1,retryDelayMs:500,healthCheckEnabled:!0}},b=a[y]||a.priority;Y(a=>{let c={...a};for(let[a,d]of Object.entries(b))(void 0===c[a]||null===c[a]||""===c[a])&&(c[a]=d);return c}),"weighted"===y&&t.length>1&&as(),"round-robin"===y&&W(!0),n.success(x(k,"recommendationsApplied","Recommendations applied to this combo."))},showNudge:Z})})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("label",{className:"text-sm font-medium",children:k("models")}),"weighted"===y&&t.length>1&&(0,d.jsx)("button",{onClick:as,className:"text-[10px] text-primary hover:text-primary/80 transition-colors",children:k("autoBalance")})]}),0===t.length?(0,d.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:k("noModelsYet")})]}):(0,d.jsx)("div",{className:"flex flex-col gap-1 max-h-[240px] overflow-y-auto",children:t.map((a,b)=>(0,d.jsxs)("div",{draggable:!0,onDragStart:a=>{ac(b),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.toString()),a.target&&setTimeout(()=>a.currentTarget.style.opacity="0.5",0)},onDragEnd:av,onDragOver:a=>{a.preventDefault(),a.dataTransfer.dropEffect="move",ae(b)},onDrop:a=>((a,b)=>{if(a.preventDefault(),null===ab||ab===b)return;let c=[...t],[d]=c.splice(ab,1);c.splice(b,0,d),u(c),ac(null),ae(null)})(a,b),className:`group/item flex items-center gap-1.5 px-2 py-1.5 rounded-md transition-all cursor-grab active:cursor-grabbing ${ad===b&&ab!==b?"bg-primary/10 border border-primary/30":"bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] border border-transparent"} ${ab===b?"opacity-50":""}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted/40 cursor-grab shrink-0",children:"drag_indicator"}),(0,d.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:b+1}),(0,d.jsx)("div",{className:"flex-1 min-w-0 px-1 text-xs text-text-main truncate",children:au(a.model)}),"cost-optimized"===y&&(0,d.jsx)("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase font-semibold ${aa(a.model)?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-amber-500/15 text-amber-600 dark:text-amber-400"}`,title:aa(a.model)?x(k,"pricingAvailable","Pricing available"):x(k,"pricingMissing","No pricing"),children:aa(a.model)?x(k,"pricingAvailableShort","priced"):x(k,"pricingMissingShort","no-price")}),"weighted"===y&&(0,d.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[(0,d.jsx)("input",{type:"number",min:"0",max:"100",value:a.weight,onChange:a=>{var c;let d;return c=a.target.value,void((d=[...t])[b]={...d[b],weight:Math.max(0,Math.min(100,Number(c)||0))},u(d))},className:"w-10 text-[11px] text-center py-0.5 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"%"})]}),"priority"===y&&(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)("button",{onClick:()=>(a=>{if(0===a)return;let b=[...t];[b[a-1],b[a]]=[b[a],b[a-1]],u(b)})(b),disabled:0===b,className:`p-0.5 rounded ${0===b?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:k("moveUp"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,d.jsx)("button",{onClick:()=>(a=>{if(a===t.length-1)return;let b=[...t];[b[a],b[a+1]]=[b[a+1],b[a]],u(b)})(b),disabled:b===t.length-1,className:`p-0.5 rounded ${b===t.length-1?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:k("moveDown"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,d.jsx)("button",{onClick:()=>{u(t.filter((a,c)=>c!==b))},className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:k("removeModel"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},`${a.model}-${b}`))}),"weighted"===y&&t.length>0&&(0,d.jsx)(K,{models:t}),"cost-optimized"===y&&t.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.02] px-2 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,d.jsx)("span",{className:"text-text-muted",children:x(k,"pricingCoverage","Pricing coverage")}),(0,d.jsxs)("span",{className:"font-medium text-text-main",children:[ag,"/",t.length," (",ah,"%)"]})]}),(0,d.jsx)("div",{className:"h-1.5 mt-1 rounded-full bg-black/10 dark:bg-white/10 overflow-hidden",children:(0,d.jsx)("div",{className:`h-full transition-all duration-300 ${100===ah?"bg-emerald-500":ah>0?"bg-amber-500":"bg-red-500"}`,style:{width:`${ah}%`}})}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-1",children:x(k,"pricingCoverageHint","Cost-optimized works best when all combo models have pricing.")})]}),ai&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsx)("span",{children:k("noModelsYet")})]}),am&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsxs)("span",{children:[k("weighted")," ",af,"% ","≠"," 100%. ",k("autoBalance")]})]}),aj&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-blue-500/20 bg-blue-500/10 px-2 py-1.5 text-[10px] text-blue-700 dark:text-blue-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"info"}),(0,d.jsx)("span",{children:x(k,"warningRoundRobinSingleModel","Round-robin is most useful with at least 2 models.")})]}),al&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsx)("span",{children:"function"==typeof k.has&&k.has("warningCostOptimizedPartialPricing")?k("warningCostOptimizedPartialPricing",{priced:ag,total:t.length}):`Only ${ag} of ${t.length} models have pricing. Routing may be partially cost-aware.`})]}),ak&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsx)("span",{children:x(k,"warningCostOptimizedNoPricing","No pricing data found for this combo. Cost-optimized may route unexpectedly.")})]}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(G,{checks:ao,blockers:ap})}),(0,d.jsxs)("button",{onClick:()=>C(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-text-muted hover:text-primary hover:border-primary/30 transition-colors flex items-center justify-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),k("addModel")]})]}),(0,d.jsxs)("button",{onClick:()=>W(!V),className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-main transition-colors self-start",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:V?"expand_less":"expand_more"}),k("advancedSettings")]}),V&&(0,d.jsxs)("div",{className:"flex flex-col gap-2 p-3 bg-black/[0.02] dark:bg-white/[0.02] rounded-lg border border-black/5 dark:border-white/5",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("maxRetries"),help:x(k,"advancedHelp.maxRetries","How many retries are attempted before failing the request.")}),(0,d.jsx)("input",{type:"number",min:"0",max:"10",value:X.maxRetries??"",placeholder:"1",onChange:a=>Y({...X,maxRetries:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("retryDelay"),help:x(k,"advancedHelp.retryDelay","Initial delay between retries. Higher values reduce burst pressure.")}),(0,d.jsx)("input",{type:"number",min:"0",max:"60000",step:"500",value:X.retryDelayMs??"",placeholder:"2000",onChange:a=>Y({...X,retryDelayMs:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("timeout"),help:x(k,"advancedHelp.timeout","Maximum request time before aborting. Set higher for long generations.")}),(0,d.jsx)("input",{type:"number",min:"1000",max:"600000",step:"1000",value:X.timeoutMs??"",placeholder:"120000",onChange:a=>Y({...X,timeoutMs:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)(F,{label:k("healthcheck"),help:x(k,"advancedHelp.healthcheck","Skips unhealthy models/providers from routing decisions when enabled.")}),(0,d.jsx)("input",{type:"checkbox",checked:!1!==X.healthCheckEnabled,onChange:a=>Y({...X,healthCheckEnabled:a.target.checked}),className:"accent-primary"})]})]}),"round-robin"===y&&(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2 pt-2 border-t border-black/5 dark:border-white/5",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("concurrencyPerModel"),help:x(k,"advancedHelp.concurrencyPerModel","Max simultaneous requests sent to each model in round-robin.")}),(0,d.jsx)("input",{type:"number",min:"1",max:"20",value:X.concurrencyPerModel??"",placeholder:"3",onChange:a=>Y({...X,concurrencyPerModel:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("queueTimeout"),help:x(k,"advancedHelp.queueTimeout","How long a request can wait in queue before timeout in round-robin.")}),(0,d.jsx)("input",{type:"number",min:"1000",max:"120000",step:"1000",value:X.queueTimeoutMs??"",placeholder:"30000",onChange:a=>Y({...X,queueTimeoutMs:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted",children:k("advancedHint")})]}),(0,d.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,d.jsx)(h.Button,{onClick:c,variant:"ghost",fullWidth:!0,size:"sm",children:l("cancel")}),(0,d.jsx)(h.Button,{onClick:aw,fullWidth:!0,size:"sm",disabled:an,children:H?k("saving"):ax?l("save"):k("createCombo")})]})]})}),(0,d.jsx)(m.ModelSelectModal,{isOpen:B,onClose:()=>C(!1),onSelect:a=>{t.find(b=>b.model===a.value)||u([...t,{model:a.value,weight:0}])},activeProviders:g,modelAliases:R,title:k("addModelToCombo"),selectedModel:null,addedModelValues:t.map(a=>a.model)})]})}function K({models:a}){let b=a.reduce((a,b)=>a+(b.weight||0),0),c=100===b,e=["bg-blue-500","bg-emerald-500","bg-amber-500","bg-purple-500","bg-rose-500","bg-cyan-500","bg-orange-500","bg-indigo-500"];return(0,d.jsxs)("div",{className:"mt-1.5",children:[(0,d.jsx)("div",{className:"h-1.5 rounded-full bg-black/5 dark:bg-white/5 overflow-hidden flex",children:a.map((a,b)=>a.weight?(0,d.jsx)("div",{className:`${e[b%e.length]} transition-all duration-300`,style:{width:`${Math.min(a.weight,100)}%`}},b):null)}),(0,d.jsxs)("div",{className:"flex items-center justify-between mt-0.5",children:[(0,d.jsx)("div",{className:"flex gap-1",children:a.map((a,b)=>a.weight>0&&(0,d.jsxs)("span",{className:"flex items-center gap-0.5 text-[9px] text-text-muted",children:[(0,d.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${e[b%e.length]}`}),a.weight,"%"]},b))}),(0,d.jsxs)("span",{className:`text-[10px] font-medium ${c?"text-emerald-500":b>100?"text-red-500":"text-amber-500"}`,children:[b,"%",!c&&b>0&&" ≠ 100%"]})]})]})}a.s(["default",()=>B]),c()}catch(a){c(a)}},!1)];
1
+ module.exports=[11002,a=>{"use strict";var b=a.i(187924),c=a.i(572131);function d({children:a,content:d,position:e="top",className:f="",delayMs:g=200}){let h,[i,j]=(0,c.useState)(!1),k=(0,c.useId)(),l=(0,c.useRef)(null),m=(0,c.useCallback)(()=>{clearTimeout(l.current),l.current=setTimeout(()=>j(!0),g)},[g]),n=(0,c.useCallback)(()=>{clearTimeout(l.current),j(!1)},[]);(0,c.useEffect)(()=>()=>{clearTimeout(l.current)},[]);let o={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},p=d?k:void 0,q=(0,c.isValidElement)(a)?(h=[a.props["aria-describedby"],p].filter(Boolean).join(" "),(0,c.cloneElement)(a,{"aria-describedby":h||void 0})):(0,b.jsx)("span",{tabIndex:0,"aria-describedby":p,children:a});return(0,b.jsxs)("span",{className:`relative inline-flex ${f}`,onMouseEnter:m,onMouseLeave:n,onFocus:m,onBlur:n,onKeyDown:a=>{"Escape"===a.key&&n()},children:[q,i&&d&&(0,b.jsx)("span",{id:k,role:"tooltip",className:`absolute z-50 px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900/95 rounded-md shadow-lg whitespace-nowrap pointer-events-none animate-in fade-in duration-150 motion-reduce:transition-none motion-reduce:animate-none border border-white/10 ${o[e]||o.top}`,children:d})]})}a.s(["default",()=>d])},560314,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(292216),h=a.i(294023),i=a.i(563203),j=a.i(489108),k=a.i(709918),l=a.i(831097),m=a.i(959852),n=a.i(248172),o=a.i(609754),p=a.i(11002),q=a.i(386592),r=a.i(240246),s=a.i(415925),t=b([f,m]);[f,m]=t.then?(await t)():t;let L=/^[a-zA-Z0-9_/.-]+$/,M=[{value:"priority",labelKey:"priority",descKey:"priorityDesc",icon:"sort"},{value:"weighted",labelKey:"weighted",descKey:"weightedDesc",icon:"percent"},{value:"round-robin",labelKey:"roundRobin",descKey:"roundRobinDesc",icon:"autorenew"},{value:"random",labelKey:"random",descKey:"randomDesc",icon:"shuffle"},{value:"least-used",labelKey:"leastUsed",descKey:"leastUsedDesc",icon:"low_priority"},{value:"cost-optimized",labelKey:"costOpt",descKey:"costOptimizedDesc",icon:"savings"},{value:"fill-first",labelKey:"fillFirst",descKey:"fillFirstDesc",icon:"stacked_bar_chart"},{value:"p2c",labelKey:"p2c",descKey:"p2cDesc",icon:"compare_arrows"},{value:"strict-random",labelKey:"strictRandom",descKey:"strictRandomDesc",icon:"casino"}],N={priority:{when:"Use when you have one preferred model and only want fallback on failure.",avoid:"Avoid when you need balanced load between models.",example:"Example: Primary coding model with cheaper backup for outages."},weighted:{when:"Use when you need controlled traffic split across models.",avoid:"Avoid when weights are not maintained or you need strict fairness.",example:"Example: 80% stable model and 20% canary model for safe rollout."},"round-robin":{when:"Use when you need predictable, even request distribution.",avoid:"Avoid when model latency/cost differs significantly.",example:"Example: Same model across multiple accounts to spread throughput."},random:{when:"Use when you want a simple spread with low configuration effort.",avoid:"Avoid when requests must be distributed with strict guarantees.",example:"Example: Prototyping with equivalent models and no traffic policy."},"least-used":{when:"Use when you want adaptive balancing based on recent demand.",avoid:"Avoid when your traffic is too low to benefit from usage balancing.",example:"Example: Mixed workloads where one model tends to get overloaded."},"cost-optimized":{when:"Use when minimizing cost is the top priority.",avoid:"Avoid when pricing data is missing or outdated.",example:"Example: Batch or background jobs where lower cost matters most."},"fill-first":{when:"Use when you want to drain one provider's quota fully before moving to the next.",avoid:"Avoid when you need request-level load balancing across providers.",example:"Example: Use all $200 Deepgram credits before falling to Groq."},p2c:{when:"Use when you want low-latency selection using Power-of-Two-Choices algorithm.",avoid:"Avoid for small combos with 2 or fewer models — no benefit over round-robin.",example:"Example: High-throughput inference across 4+ equivalent model endpoints."},"strict-random":{when:"Use when you want perfectly even spread — each model used once before repeating.",avoid:"Avoid when models have different quality or latency and order matters.",example:"Example: Multiple accounts of the same model to distribute usage evenly."}},O={priority:{title:"Fail-safe baseline",description:"Use one primary model and keep fallback chain short and reliable.",tips:["Put your most reliable model first.","Keep 1-2 backup models with similar quality.","Use safe retries to absorb transient provider failures."]},weighted:{title:"Controlled traffic split",description:"Great for canary rollouts and gradual migration between models.",tips:["Start with conservative split like 90/10.","Keep the total at 100% and auto-balance after changes.","Monitor success and latency before increasing canary weight."]},"round-robin":{title:"Predictable load sharing",description:"Best when models are equivalent and you need smooth distribution.",tips:["Use at least 2 models.","Set concurrency limits to avoid burst overload.","Use queue timeout to fail fast under saturation."]},random:{title:"Quick spread with low setup",description:"Use when you need simple distribution without strict guarantees.",tips:["Use models with similar latency profiles.","Keep retries enabled to absorb random misses.","Prefer this for experimentation, not strict SLAs."]},"least-used":{title:"Adaptive balancing",description:"Routes to less-used models to reduce hotspots over time.",tips:["Works better under continuous traffic.","Combine with health checks for safer balancing.","Track per-model usage to validate distribution gains."]},"cost-optimized":{title:"Budget-first routing",description:"Routes to lower-cost models when pricing metadata is available.",tips:["Ensure pricing coverage for all selected models.","Keep a quality fallback for hard prompts.","Use for batch/background jobs where cost is the main KPI."]},"fill-first":{title:"Quota drain strategy",description:"Exhausts one provider's quota before moving to the next in chain.",tips:["Order models by free quota size — biggest first.","Enable health checks to skip drained providers.","Ideal for free-tier stacking (Deepgram → Groq → NIM)."]},p2c:{title:"Power-of-Two-Choices",description:"Picks the less-loaded of two random candidates per request — low latency at scale.",tips:["Use with 4+ models for best effect.","Requires latency telemetry enabled in Settings.","Great replacement for round-robin in high-throughput combos."]},"strict-random":{title:"Shuffle deck distribution",description:"Each model is used exactly once per cycle before reshuffling.",tips:["Use at least 2 models for meaningful distribution.","Ideal for same-model accounts to evenly spread quota.","Guarantees no model is skipped or repeated within a cycle."]}},P="omniroute:combos:hide-usage-guide",Q=[{id:"free-stack",icon:"volunteer_activism",titleKey:"templateFreeStack",descKey:"templateFreeStackDesc",fallbackTitle:"Free Stack ($0)",fallbackDesc:"Round-robin across all free providers: Kiro, iFlow, Qwen, Gemini CLI. Zero cost, never stops.",strategy:"round-robin",suggestedName:"free-stack",isFeatured:!0,config:{maxRetries:3,retryDelayMs:500,healthCheckEnabled:!0}},{id:"high-availability",icon:"shield",titleKey:"templateHighAvailability",descKey:"templateHighAvailabilityDesc",fallbackTitle:"High availability",fallbackDesc:"Priority routing with health checks and safe retries.",strategy:"priority",suggestedName:"high-availability",config:{maxRetries:2,retryDelayMs:1500,healthCheckEnabled:!0}},{id:"cost-saver",icon:"savings",titleKey:"templateCostSaver",descKey:"templateCostSaverDesc",fallbackTitle:"Cost saver",fallbackDesc:"Cost-optimized routing for budget-first workloads.",strategy:"cost-optimized",suggestedName:"cost-saver",config:{maxRetries:1,retryDelayMs:500,healthCheckEnabled:!0}},{id:"balanced",icon:"balance",titleKey:"templateBalanced",descKey:"templateBalancedDesc",fallbackTitle:"Balanced load",fallbackDesc:"Least-used routing to spread demand over time.",strategy:"least-used",suggestedName:"balanced-load",config:{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0}}];function u(a){return M.find(b=>b.value===a)||M[0]}function v(a,b){return a(u(b).labelKey)}function w(a,b){return a(u(b).descKey)}function x(a,b,c){return"function"==typeof a.has&&a.has(b)?a(b):c}function y(a,b,c){let d=N[b]||N.priority,e=`strategyGuide.${b}.${c}`;return x(a,e,d[c])}function z(a,b,c){let d=O[b]||O.priority;return"tips"===c?d.tips.map((c,d)=>x(a,`strategyRecommendations.${b}.tip${d+1}`,c)):x(a,`strategyRecommendations.${b}.${c}`,d[c])}function A(a){return"string"==typeof a?{model:a,weight:0}:{model:a.model,weight:a.weight||0}}function B(){let a=(0,s.useTranslations)("combos"),b=(0,s.useTranslations)("common"),[c,f]=(0,e.useState)([]),[j,k]=(0,e.useState)(!0),[m,p]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)([]),[y,z]=(0,e.useState)({}),[A,B]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),{copied:F,copy:G}=(0,q.useCopyToClipboard)(),K=(0,r.useNotificationStore)(),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(null),[Q,R]=(0,e.useState)([]),[S,T]=(0,e.useState)(!0),[U,V]=(0,e.useState)("");(0,e.useEffect)(()=>{W(),fetch("/api/settings/proxy").then(a=>a.ok?a.json():null).then(a=>O(a)).catch(()=>{})},[]),(0,e.useEffect)(()=>{try{globalThis.localStorage?.getItem(P)==="1"&&T(!1)}catch{}},[]);let W=async()=>{try{let[a,b,c,d]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/combos/metrics"),fetch("/api/provider-nodes")]),e=await a.json(),g=await b.json(),h=await c.json(),i=d.ok?await d.json():{nodes:[]};if(a.ok&&f(e.combos||[]),b.ok){let a=(g.connections||[]).filter(a=>"active"===a.testStatus||"success"===a.testStatus);w(a)}c.ok&&z(h.metrics||{}),R(i.nodes||[])}catch(a){console.log("Error fetching data:",a)}finally{k(!1)}},X=async b=>{try{let c=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(c.ok)await W(),p(!1),V(b.name?.trim()||""),K.success(a("comboCreated"));else{let b=await c.json();K.error(b.error?.message||b.error||a("failedCreate"))}}catch(b){K.error(a("errorCreating"))}},Y=async(b,c)=>{try{let d=await fetch(`/api/combos/${b}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(d.ok)await W(),u(null),K.success(a("comboUpdated"));else{let b=await d.json();K.error(b.error?.message||b.error||a("failedUpdate"))}}catch(b){K.error(a("errorUpdating"))}},Z=async b=>{if(confirm(a("deleteConfirm")))try{(await fetch(`/api/combos/${b}`,{method:"DELETE"})).ok&&(f(c.filter(a=>a.id!==b)),K.success(a("comboDeleted")))}catch(b){K.error(a("errorDeleting"))}},$=async a=>{let b=a.name.replace(/-copy(-\d+)?$/,""),d=c.map(a=>a.name),e=`${b}-copy`,f=1;for(;d.includes(e);)f++,e=`${b}-copy-${f}`;let g={name:e,models:a.models,strategy:a.strategy||"priority",config:a.config||{}};await X(g)},_=async b=>{E(b.name),B(null);try{let a=await fetch("/api/combos/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:b.name})}),c=await a.json();B(c)}catch(b){B({error:a("testFailed")}),K.error(a("testFailed"))}},aa=async b=>{let c=!1===b.isActive;f(a=>a.map(a=>a.id===b.id?{...a,isActive:c}:a));try{await fetch(`/api/combos/${b.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:c})})}catch(d){f(a=>a.map(a=>a.id===b.id?{...a,isActive:!c}:a)),K.error(a("failedToggle"))}};return j?(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(l.CardSkeleton,{}),(0,d.jsx)(l.CardSkeleton,{})]}):(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-semibold",children:a("title")}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-1",children:a("description")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[!S&&(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:()=>{T(!0);try{globalThis.localStorage?.removeItem(P)}catch{}},children:x(a,"usageGuideShow","Show guide")}),(0,d.jsx)(h.Button,{icon:"add",onClick:()=>p(!0),children:a("createCombo")})]})]}),S&&(0,d.jsx)(C,{onHide:()=>T(!1),onHideForever:()=>{T(!1);try{globalThis.localStorage?.setItem(P,"1")}catch{}}}),U&&(0,d.jsx)(g.Card,{padding:"sm",className:"border border-emerald-500/20 bg-emerald-500/[0.04] dark:bg-emerald-500/[0.08]",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-emerald-700 dark:text-emerald-300",children:x(a,"quickTestTitle",`Combo "${U}" ready to validate`)}),(0,d.jsx)("code",{className:"inline-block text-[11px] mt-0.5 px-1.5 py-0.5 rounded bg-emerald-500/15 text-emerald-700 dark:text-emerald-300",children:U}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:x(a,"quickTestDescription","Run a test now to confirm fallback and latency behavior.")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"play_arrow",onClick:()=>{_({name:U}),V("")},children:x(a,"testNow","Test now")}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:()=>V(""),children:b("close")})]})]})}),0===c.length?(0,d.jsx)(o.EmptyState,{icon:"🧩",title:a("noCombosYet"),description:a("description"),actionLabel:a("createCombo"),onAction:()=>p(!0)}):(0,d.jsx)("div",{className:"flex flex-col gap-4",children:c.map(a=>(0,d.jsx)(H,{combo:a,metrics:y[a.name],providerNodes:Q,copied:F,onCopy:G,onEdit:()=>u(a),onDelete:()=>Z(a.id),onDuplicate:()=>$(a),onTest:()=>_(a),testing:D===a.name,onProxy:()=>M(a),hasProxy:!!N?.combos?.[a.id],onToggle:()=>aa(a)},a.id))}),A&&(0,d.jsx)(i.Modal,{isOpen:!!A,onClose:()=>{B(null),E(null)},title:a("testResults",{name:D}),children:(0,d.jsx)(I,{results:A})}),(0,d.jsx)(J,{isOpen:m,onClose:()=>p(!1),onSave:X,activeProviders:v,combo:null},"create"),(0,d.jsx)(J,{isOpen:!!t,combo:t,onClose:()=>u(null),onSave:a=>Y(t.id,a),activeProviders:v},t?.id||"new"),L&&(0,d.jsx)(n.ProxyConfigModal,{isOpen:!!L,onClose:()=>M(null),level:"combo",levelId:L.id,levelLabel:L.name})]})}function C({onHide:a,onHideForever:b}){let c=(0,s.useTranslations)("combos");return(0,d.jsxs)(g.Card,{padding:"sm",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("div",{className:"size-7 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[16px]",children:"tips_and_updates"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("h2",{className:"text-sm font-semibold",children:c("routingStrategy")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:c("description")})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:a,className:"!h-6 px-2 text-[10px]",children:x(c,"usageGuideHide","Hide")}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:b,className:"!h-6 px-2 text-[10px]",children:x(c,"usageGuideDontShowAgain","Don't show again")})]})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2 mt-3",children:["priority","cost-optimized","least-used"].map(a=>{let b=u(a);return(0,d.jsxs)("div",{className:"rounded-lg border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.02] p-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:b.icon}),(0,d.jsx)("span",{className:"text-xs font-medium",children:v(c,a)})]}),(0,d.jsx)("p",{className:"text-[11px] leading-4 text-text-muted mt-1.5",children:w(c,a)})]},a)})})]})}function D({strategy:a}){let b=(0,s.useTranslations)("combos");return(0,d.jsxs)("div",{className:"rounded-lg border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.02] p-2.5",children:[(0,d.jsx)("div",{className:"text-[11px] text-text-muted",children:x(b,"strategyGuideTitle","How to use this strategy")}),(0,d.jsxs)("div",{className:"mt-1.5 flex flex-col gap-1.5 text-[11px]",children:[(0,d.jsxs)("p",{className:"text-text-main",children:[(0,d.jsxs)("span",{className:"font-semibold",children:[x(b,"strategyGuideWhen","When to use"),":"]})," ",y(b,a,"when")]}),(0,d.jsxs)("p",{className:"text-text-main",children:[(0,d.jsxs)("span",{className:"font-semibold",children:[x(b,"strategyGuideAvoid","Avoid when"),":"]})," ",y(b,a,"avoid")]}),(0,d.jsxs)("p",{className:"text-text-main",children:[(0,d.jsxs)("span",{className:"font-semibold",children:[x(b,"strategyGuideExample","Example"),":"]})," ",y(b,a,"example")]})]})]})}function E({strategy:a,onApply:b,showNudge:c}){let e=(0,s.useTranslations)("combos"),f=v(e,a),g=z(e,a,"title"),i=z(e,a,"description"),j=z(e,a,"tips");return(0,d.jsxs)("div",{className:"rounded-lg border border-black/10 dark:border-white/10 bg-white/70 dark:bg-white/[0.02] p-2.5",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[11px] text-text-muted",children:x(e,"recommendationsLabel","Recommended setup")}),(0,d.jsxs)("p",{className:"text-xs font-semibold text-text-main mt-0.5",children:[g," · ",(0,d.jsx)("span",{className:"text-primary",children:f})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:i})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:b,className:"!h-6 px-2 text-[10px]",children:x(e,"applyRecommendations","Apply recommendations")})]}),(0,d.jsx)("div",{className:"mt-2 grid grid-cols-1 gap-1",children:j.map((b,c)=>(0,d.jsxs)("div",{className:"flex items-start gap-1 rounded-md bg-black/[0.02] dark:bg-white/[0.03] px-1.5 py-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary mt-0.5",children:"check"}),(0,d.jsx)("p",{className:"text-[10px] text-text-main",children:b})]},`${a}-tip-${c+1}`))}),c&&(0,d.jsx)("div",{"data-testid":"strategy-change-nudge",className:"mt-2 rounded-md border border-primary/20 bg-primary/10 px-2 py-1 text-[10px] text-primary",children:x(e,"recommendationsUpdated","Recommendations updated for {strategy}.").replace("{strategy}",f)})]})}function F({label:a,help:b}){return(0,d.jsxs)("div",{className:"flex items-center gap-1 mb-0.5",children:[(0,d.jsx)("label",{className:"text-[10px] text-text-muted",children:a}),(0,d.jsx)(p.default,{content:b,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-text-muted cursor-help",children:"help"})})]})}function G({checks:a,blockers:b}){let c=(0,s.useTranslations)("combos"),e=b.length>0;return(0,d.jsxs)("div",{"data-testid":"combo-readiness-panel",className:`rounded-lg border px-2.5 py-2 ${e?"border-amber-500/30 bg-amber-500/5":"border-emerald-500/20 bg-emerald-500/[0.04]"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${e?"text-amber-600 dark:text-amber-400":"text-emerald-600 dark:text-emerald-400"}`,children:e?"rule":"check_circle"}),(0,d.jsx)("p",{className:"text-[11px] font-medium text-text-main",children:x(c,"readinessTitle","Ready to save?")})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:x(c,"readinessDescription","Review the checklist before creating or updating this combo.")}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1 mt-2",children:a.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-1 rounded-md px-1.5 py-1 bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[12px] ${a.ok?"text-emerald-500":"text-amber-500"}`,children:a.ok?"task_alt":"pending"}),(0,d.jsx)("span",{className:"text-[10px] text-text-main",children:a.label})]},a.id))}),e&&(0,d.jsxs)("div",{"data-testid":"combo-save-blockers",className:"mt-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1.5",children:[(0,d.jsx)("p",{className:"text-[10px] font-medium text-amber-700 dark:text-amber-300",children:x(c,"saveBlockedTitle","Save is blocked until the following items are fixed:")}),(0,d.jsx)("div",{className:"mt-1 flex flex-col gap-0.5",children:b.map((a,b)=>(0,d.jsxs)("p",{className:"text-[10px] text-amber-700 dark:text-amber-300",children:["• ",a]},`${a}-${b}`))})]})]})}function H({combo:a,metrics:b,copied:c,onCopy:e,onEdit:f,onDelete:h,onDuplicate:i,onTest:j,testing:l,onProxy:m,hasProxy:n,onToggle:o,providerNodes:q}){let r=a.strategy||"priority",t=a.models||[],u=!1===a.isActive,x=(0,s.useTranslations)("combos"),y=(0,s.useTranslations)("common"),z=w(x,r);return(0,d.jsx)(g.Card,{padding:"sm",className:`group ${u?"opacity-50":""}`,children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"text-sm font-medium font-mono truncate",children:a.name}),(0,d.jsx)(p.default,{content:z,children:(0,d.jsx)("span",{className:`text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full ${"weighted"===r?"bg-amber-500/15 text-amber-600 dark:text-amber-400":"round-robin"===r?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"random"===r?"bg-purple-500/15 text-purple-600 dark:text-purple-400":"least-used"===r?"bg-cyan-500/15 text-cyan-600 dark:text-cyan-400":"cost-optimized"===r?"bg-teal-500/15 text-teal-600 dark:text-teal-400":"fill-first"===r?"bg-orange-500/15 text-orange-600 dark:text-orange-400":"p2c"===r?"bg-indigo-500/15 text-indigo-600 dark:text-indigo-400":"bg-blue-500/15 text-blue-600 dark:text-blue-400"}`,children:v(x,r)})}),n&&(0,d.jsxs)("span",{className:"text-[9px] uppercase font-semibold px-1.5 py-0.5 rounded-full bg-primary/15 text-primary flex items-center gap-0.5",title:x("proxyConfigured"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"vpn_lock"}),"proxy"]}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),e(a.name,`combo-${a.id}`)},className:"p-0.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors opacity-100 md:opacity-0 md:group-hover:opacity-100",title:x("copyComboName"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:c===`combo-${a.id}`?"check":"content_copy"})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[0===t.length?(0,d.jsx)("span",{className:"text-xs text-text-muted italic",children:x("noModels")}):t.slice(0,3).map((a,b)=>{let{model:c,weight:e}=A(a);return(0,d.jsxs)("code",{className:"text-[10px] font-mono bg-black/5 dark:bg-white/5 px-1.5 py-0.5 rounded text-text-muted",children:[(a=>{let b=a.split("/");if(2!==b.length)return a;let[c,d]=b,e=(q||[]).find(a=>a.id===c||a.prefix===c);return e?`${e.name}/${d}`:a})(c),"weighted"===r&&e>0?` (${e}%)`:""]},b)}),t.length>3&&(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:x("more",{count:t.length-3})})]}),b&&(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1",children:[(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[(0,d.jsx)("span",{className:"text-emerald-500",children:b.totalSuccesses}),"/",b.totalRequests," ",x("reqs")]}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[b.successRate,"% ",x("success")]}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:["~",b.avgLatencyMs,"ms"]}),b.fallbackRate>0&&(0,d.jsxs)("span",{className:"text-[10px] text-amber-500",children:[b.fallbackRate,"% fallback"]})]})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[(0,d.jsx)(k.Toggle,{size:"sm",checked:!u,onChange:o,title:x(u?"enableCombo":"disableCombo")}),(0,d.jsxs)("div",{className:"flex items-center gap-1 transition-opacity",children:[(0,d.jsx)("button",{onClick:j,disabled:l,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-emerald-500 transition-colors",title:x("testCombo"),children:(0,d.jsx)("span",{className:`material-symbols-outlined text-[16px] ${l?"animate-spin":""}`,children:l?"progress_activity":"play_arrow"})}),(0,d.jsx)("button",{onClick:i,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:x("duplicate"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"content_copy"})}),(0,d.jsx)("button",{onClick:m,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:x("proxyConfig"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"vpn_lock"})}),(0,d.jsx)("button",{onClick:f,className:"p-1.5 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary transition-colors",title:y("edit"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),(0,d.jsx)("button",{onClick:h,className:"p-1.5 hover:bg-red-500/10 rounded text-red-500 transition-colors",title:y("delete"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]})]})})}function I({results:a}){return a.error?(0,d.jsxs)("div",{className:"flex items-center gap-2 text-red-500 text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"error"}),"string"==typeof a.error?a.error:JSON.stringify(a.error)]}):(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.resolvedBy&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-emerald-500 text-[18px]",children:"check_circle"}),(0,d.jsxs)("span",{children:["Resolved by:"," ",(0,d.jsx)("code",{className:"text-xs bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 px-1.5 py-0.5 rounded",children:a.resolvedBy})]})]}),a.results?.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs px-2 py-1.5 rounded bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] ${"ok"===a.status?"text-emerald-500":"skipped"===a.status?"text-text-muted":"text-red-500"}`,children:"ok"===a.status?"check_circle":"skipped"===a.status?"skip_next":"error"}),(0,d.jsx)("code",{className:"font-mono flex-1",children:a.model}),void 0!==a.latencyMs&&(0,d.jsxs)("span",{className:"text-text-muted",children:[a.latencyMs,"ms"]}),(0,d.jsx)("span",{className:`text-[10px] uppercase font-medium ${"ok"===a.status?"text-emerald-500":"skipped"===a.status?"text-text-muted":"text-red-500"}`,children:a.status})]},b))]})}function J({isOpen:a,combo:b,onClose:c,onSave:f,activeProviders:g}){let k=(0,s.useTranslations)("combos"),l=(0,s.useTranslations)("common"),n=(0,r.useNotificationStore)(),[o,q]=(0,e.useState)(b?.name||""),[t,u]=(0,e.useState)(()=>(b?.models||[]).map(a=>A(a))),[y,z]=(0,e.useState)(b?.strategy||"priority"),[B,C]=(0,e.useState)(!1),[H,I]=(0,e.useState)(!1),[J,N]=(0,e.useState)(""),[O,P]=(0,e.useState)({}),[R,S]=(0,e.useState)({}),[T,U]=(0,e.useState)([]),[V,W]=(0,e.useState)(!1),[X,Y]=(0,e.useState)(b?.config||{}),[Z,$]=(0,e.useState)(!1),_=(0,e.useRef)(!1),[aa,ab]=(0,e.useState)(b?.system_message||""),[ac,ad]=(0,e.useState)(b?.tool_filter_regex||""),[ae,af]=(0,e.useState)(!!b?.context_cache_protection),ag=(0,e.useCallback)(a=>{let b=a.split("/");if(2!==b.length)return!1;let[c,d]=b,e=T.find(a=>a.id===c||a.prefix===c),f=[c];return e?.apiType&&f.push(e.apiType),e?.name&&f.push(String(e.name).toLowerCase()),f.some(a=>!!O?.[a]?.[d])},[O,T]),[ah,ai]=(0,e.useState)(null),[aj,ak]=(0,e.useState)(null),al=t.reduce((a,b)=>a+(b.weight||0),0),am=t.reduce((a,b)=>a+ +!!ag(b.model),0),an=t.length>0?Math.round(am/t.length*100):0,ao=0===t.length,ap="round-robin"===y&&1===t.length,aq="cost-optimized"===y&&t.length>0&&0===am,ar="cost-optimized"===y&&t.length>0&&am>0&&am<t.length,as="weighted"===y&&t.length>0&&100!==al,at=!o.trim()||!!J||H||ao||as||aq,au=[{id:"name",ok:!!o.trim()&&!J,label:x(k,"readinessCheckName","Combo name is valid")},{id:"models",ok:!ao,label:x(k,"readinessCheckModels","At least one model is selected")},{id:"weights",ok:"weighted"!==y||!as,label:"weighted"===y?x(k,"readinessCheckWeights","Weighted total is 100%"):x(k,"readinessCheckWeightsOptional","Weight rule not required")},{id:"pricing",ok:"cost-optimized"!==y||!aq,label:"cost-optimized"===y?x(k,"readinessCheckPricing","Pricing data is available"):x(k,"readinessCheckPricingOptional","Pricing rule not required")}],av=[];o.trim()?J&&av.push(J):av.push(x(k,"saveBlockName","Define a combo name.")),ao&&av.push(x(k,"saveBlockModels","Add at least one model.")),as&&av.push("function"==typeof k.has&&k.has("saveBlockWeighted")?k("saveBlockWeighted",{total:al}):`Set weights to 100% (current: ${al}%).`),aq&&av.push(x(k,"saveBlockPricing","Add pricing for at least one model or choose a different strategy."));let aw=async()=>{try{let[a,b,c]=await Promise.all([fetch("/api/models/alias"),fetch("/api/provider-nodes"),fetch("/api/pricing")]);if(!a.ok||!b.ok)throw Error(`Failed to fetch data: aliases=${a.status}, nodes=${b.status}`);let d=c.ok?await c.json():{},[e,f]=await Promise.all([a.json(),b.json()]);P(d&&"object"==typeof d&&!Array.isArray(d)?d:{}),S(e.aliases||{}),U(f.nodes||[])}catch(a){console.error("Error fetching modal data:",a)}};(0,e.useEffect)(()=>{a&&aw()},[a]),(0,e.useEffect)(()=>{if(!_.current){_.current=!0;return}$(!0);let a=setTimeout(()=>$(!1),2600);return()=>clearTimeout(a)},[y]);let ax=a=>a.trim()?L.test(a)?(N(""),!0):(N(k("nameInvalid")),!1):(N(k("nameRequired")),!1),ay=()=>{let a=t.length;if(0===a)return;let b=Math.floor(100/a),c=100-b*a;u(t.map((a,d)=>({...a,weight:b+(0===d?c:0)})))},az=[{model:"gc/gemini-3-flash-preview",weight:0},{model:"kr/claude-sonnet-4.5",weight:0},{model:"if/kimi-k2-thinking",weight:0},{model:"if/qwen3-coder-plus",weight:0},{model:"qw/qwen3-coder-plus",weight:0},{model:"nvidia/llama-3.3-70b-instruct",weight:0},{model:"groq/llama-3.3-70b-versatile",weight:0}],aA=(0,e.useCallback)(a=>{let b=a.split("/");if(2!==b.length)return a;let[c,d]=b,e=T.find(a=>a.id===c||a.prefix===c);return e?`${e.name}/${d}`:a},[T]),aB=a=>{a.target&&(a.currentTarget.style.opacity="1"),ai(null),ak(null)},aC=async()=>{if(!ax(o)||ao||as||aq)return;I(!0);let a={name:o.trim(),models:"weighted"===y?t:t.map(a=>a.model),strategy:y},b={...X};"round-robin"===y&&(void 0!==X.concurrencyPerModel&&(b.concurrencyPerModel=X.concurrencyPerModel),void 0!==X.queueTimeoutMs&&(b.queueTimeoutMs=X.queueTimeoutMs)),Object.keys(b).length>0&&(a.config=b),aa.trim()?a.system_message=aa.trim():delete a.system_message,ac.trim()?a.tool_filter_regex=ac.trim():delete a.tool_filter_regex,ae?a.context_cache_protection=!0:delete a.context_cache_protection,await f(a),I(!1)},aD=!!b;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.Modal,{isOpen:a,onClose:c,title:aD?k("editCombo"):k("createCombo"),size:"full",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)(j.Input,{label:k("comboName"),value:o,onChange:a=>{let b=a.target.value;q(b),b?ax(b):N("")},placeholder:k("comboNamePlaceholder"),error:J}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:k("nameHint")})]}),!aD&&(0,d.jsxs)("div",{className:"rounded-lg border border-black/8 dark:border-white/8 bg-black/[0.02] dark:bg-white/[0.02] p-3",children:[(0,d.jsxs)("div",{className:"mb-2",children:[(0,d.jsx)("p",{className:"text-xs font-medium",children:x(k,"templatesTitle","Quick templates")}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:x(k,"templatesDescription","Apply a starting profile, then adjust models and config.")})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mt-1",children:Q.map(a=>(0,d.jsxs)("button",{type:"button",onClick:()=>{z(a.strategy),Y(b=>({...b,...a.config})),!o.trim()&&q(a.suggestedName),"free-stack"===a.id&&u(az)},className:`text-left rounded-md border px-3 py-2 transition-all ${a.isFeatured?"border-emerald-500/50 bg-emerald-500/5 hover:border-emerald-500/80 hover:bg-emerald-500/10 ring-1 ring-emerald-500/20":"border-black/10 dark:border-white/10 bg-white/70 dark:bg-white/[0.03] hover:border-primary/40 hover:bg-primary/5"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[16px] ${a.isFeatured?"text-emerald-500":"text-primary"}`,children:a.icon}),(0,d.jsx)("span",{className:"text-[12px] font-semibold text-text-main",children:x(k,a.titleKey,a.fallbackTitle)}),a.isFeatured&&(0,d.jsx)("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 px-1.5 py-0.5 rounded",children:"FREE"})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-1.5 leading-[1.5]",children:x(k,a.descKey,a.fallbackDesc)}),(0,d.jsxs)("p",{className:`text-[10px] mt-1.5 font-medium ${a.isFeatured?"text-emerald-500":"text-primary"}`,children:[x(k,"templateApply","Apply template")," →"]})]},a.id))})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,d.jsx)("label",{className:"text-sm font-medium",children:k("routingStrategy")}),(0,d.jsx)(p.default,{content:w(k,y),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[13px] text-text-muted cursor-help",children:"help"})})]}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-1 p-0.5 bg-black/5 dark:bg-white/5 rounded-lg",children:M.map(a=>(0,d.jsxs)("button",{onClick:()=>z(a.value),"data-testid":`strategy-option-${a.value}`,title:k(a.descKey),"aria-label":`${v(k,a.value)}. ${k(a.descKey)}`,className:`py-1.5 px-2 rounded-md text-xs font-medium transition-all ${y===a.value?"bg-white dark:bg-bg-main shadow-sm text-primary":"text-text-muted hover:text-text-main"}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] align-middle mr-0.5",children:a.icon}),v(k,a.value)]},a.value))}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:w(k,y)}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(D,{strategy:y})}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(E,{strategy:y,onApply:()=>{let a={priority:{maxRetries:2,retryDelayMs:1500,healthCheckEnabled:!0},weighted:{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0},"round-robin":{maxRetries:1,retryDelayMs:750,healthCheckEnabled:!0,concurrencyPerModel:3,queueTimeoutMs:3e4},random:{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0},"least-used":{maxRetries:1,retryDelayMs:1e3,healthCheckEnabled:!0},"cost-optimized":{maxRetries:1,retryDelayMs:500,healthCheckEnabled:!0}},b=a[y]||a.priority;Y(a=>{let c={...a};for(let[a,d]of Object.entries(b))(void 0===c[a]||null===c[a]||""===c[a])&&(c[a]=d);return c}),"weighted"===y&&t.length>1&&ay(),"round-robin"===y&&W(!0),n.success(x(k,"recommendationsApplied","Recommendations applied to this combo."))},showNudge:Z})})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,d.jsx)("label",{className:"text-sm font-medium",children:k("models")}),"weighted"===y&&t.length>1&&(0,d.jsx)("button",{onClick:ay,className:"text-[10px] text-primary hover:text-primary/80 transition-colors",children:k("autoBalance")})]}),0===t.length?(0,d.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:k("noModelsYet")})]}):(0,d.jsx)("div",{className:"flex flex-col gap-1 max-h-[240px] overflow-y-auto",children:t.map((a,b)=>(0,d.jsxs)("div",{draggable:!0,onDragStart:a=>{ai(b),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.toString()),a.target&&setTimeout(()=>a.currentTarget.style.opacity="0.5",0)},onDragEnd:aB,onDragOver:a=>{a.preventDefault(),a.dataTransfer.dropEffect="move",ak(b)},onDrop:a=>((a,b)=>{if(a.preventDefault(),null===ah||ah===b)return;let c=[...t],[d]=c.splice(ah,1);c.splice(b,0,d),u(c),ai(null),ak(null)})(a,b),className:`group/item flex items-center gap-1.5 px-2 py-1.5 rounded-md transition-all cursor-grab active:cursor-grabbing ${aj===b&&ah!==b?"bg-primary/10 border border-primary/30":"bg-black/[0.02] dark:bg-white/[0.02] hover:bg-black/[0.04] dark:hover:bg-white/[0.04] border border-transparent"} ${ah===b?"opacity-50":""}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted/40 cursor-grab shrink-0",children:"drag_indicator"}),(0,d.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:b+1}),(0,d.jsx)("div",{className:"flex-1 min-w-0 px-1 text-xs text-text-main truncate",children:aA(a.model)}),"cost-optimized"===y&&(0,d.jsx)("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full uppercase font-semibold ${ag(a.model)?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400":"bg-amber-500/15 text-amber-600 dark:text-amber-400"}`,title:ag(a.model)?x(k,"pricingAvailable","Pricing available"):x(k,"pricingMissing","No pricing"),children:ag(a.model)?x(k,"pricingAvailableShort","priced"):x(k,"pricingMissingShort","no-price")}),"weighted"===y&&(0,d.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[(0,d.jsx)("input",{type:"number",min:"0",max:"100",value:a.weight,onChange:a=>{var c;let d;return c=a.target.value,void((d=[...t])[b]={...d[b],weight:Math.max(0,Math.min(100,Number(c)||0))},u(d))},className:"w-10 text-[11px] text-center py-0.5 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"%"})]}),"priority"===y&&(0,d.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,d.jsx)("button",{onClick:()=>(a=>{if(0===a)return;let b=[...t];[b[a-1],b[a]]=[b[a],b[a-1]],u(b)})(b),disabled:0===b,className:`p-0.5 rounded ${0===b?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:k("moveUp"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,d.jsx)("button",{onClick:()=>(a=>{if(a===t.length-1)return;let b=[...t];[b[a],b[a+1]]=[b[a+1],b[a]],u(b)})(b),disabled:b===t.length-1,className:`p-0.5 rounded ${b===t.length-1?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:k("moveDown"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,d.jsx)("button",{onClick:()=>{u(t.filter((a,c)=>c!==b))},className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:k("removeModel"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},`${a.model}-${b}`))}),"weighted"===y&&t.length>0&&(0,d.jsx)(K,{models:t}),"cost-optimized"===y&&t.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-black/10 dark:border-white/10 bg-black/[0.02] dark:bg-white/[0.02] px-2 py-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,d.jsx)("span",{className:"text-text-muted",children:x(k,"pricingCoverage","Pricing coverage")}),(0,d.jsxs)("span",{className:"font-medium text-text-main",children:[am,"/",t.length," (",an,"%)"]})]}),(0,d.jsx)("div",{className:"h-1.5 mt-1 rounded-full bg-black/10 dark:bg-white/10 overflow-hidden",children:(0,d.jsx)("div",{className:`h-full transition-all duration-300 ${100===an?"bg-emerald-500":an>0?"bg-amber-500":"bg-red-500"}`,style:{width:`${an}%`}})}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-1",children:x(k,"pricingCoverageHint","Cost-optimized works best when all combo models have pricing.")})]}),ao&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsx)("span",{children:k("noModelsYet")})]}),as&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsxs)("span",{children:[k("weighted")," ",al,"% ","≠"," 100%. ",k("autoBalance")]})]}),ap&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-blue-500/20 bg-blue-500/10 px-2 py-1.5 text-[10px] text-blue-700 dark:text-blue-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"info"}),(0,d.jsx)("span",{children:x(k,"warningRoundRobinSingleModel","Round-robin is most useful with at least 2 models.")})]}),ar&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsx)("span",{children:"function"==typeof k.has&&k.has("warningCostOptimizedPartialPricing")?k("warningCostOptimizedPartialPricing",{priced:am,total:t.length}):`Only ${am} of ${t.length} models have pricing. Routing may be partially cost-aware.`})]}),aq&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-700 dark:text-amber-300 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),(0,d.jsx)("span",{children:x(k,"warningCostOptimizedNoPricing","No pricing data found for this combo. Cost-optimized may route unexpectedly.")})]}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(G,{checks:au,blockers:av})}),(0,d.jsxs)("button",{onClick:()=>C(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-text-muted hover:text-primary hover:border-primary/30 transition-colors flex items-center justify-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),k("addModel")]})]}),(0,d.jsxs)("button",{onClick:()=>W(!V),className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-main transition-colors self-start",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:V?"expand_less":"expand_more"}),k("advancedSettings")]}),V&&(0,d.jsxs)("div",{className:"flex flex-col gap-2 p-3 bg-black/[0.02] dark:bg-white/[0.02] rounded-lg border border-black/5 dark:border-white/5",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("maxRetries"),help:x(k,"advancedHelp.maxRetries","How many retries are attempted before failing the request.")}),(0,d.jsx)("input",{type:"number",min:"0",max:"10",value:X.maxRetries??"",placeholder:"1",onChange:a=>Y({...X,maxRetries:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("retryDelay"),help:x(k,"advancedHelp.retryDelay","Initial delay between retries. Higher values reduce burst pressure.")}),(0,d.jsx)("input",{type:"number",min:"0",max:"60000",step:"500",value:X.retryDelayMs??"",placeholder:"2000",onChange:a=>Y({...X,retryDelayMs:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("timeout"),help:x(k,"advancedHelp.timeout","Maximum request time before aborting. Set higher for long generations.")}),(0,d.jsx)("input",{type:"number",min:"1000",max:"600000",step:"1000",value:X.timeoutMs??"",placeholder:"120000",onChange:a=>Y({...X,timeoutMs:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)(F,{label:k("healthcheck"),help:x(k,"advancedHelp.healthcheck","Skips unhealthy models/providers from routing decisions when enabled.")}),(0,d.jsx)("input",{type:"checkbox",checked:!1!==X.healthCheckEnabled,onChange:a=>Y({...X,healthCheckEnabled:a.target.checked}),className:"accent-primary"})]})]}),"round-robin"===y&&(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2 pt-2 border-t border-black/5 dark:border-white/5",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("concurrencyPerModel"),help:x(k,"advancedHelp.concurrencyPerModel","Max simultaneous requests sent to each model in round-robin.")}),(0,d.jsx)("input",{type:"number",min:"1",max:"20",value:X.concurrencyPerModel??"",placeholder:"3",onChange:a=>Y({...X,concurrencyPerModel:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)(F,{label:k("queueTimeout"),help:x(k,"advancedHelp.queueTimeout","How long a request can wait in queue before timeout in round-robin.")}),(0,d.jsx)("input",{type:"number",min:"1000",max:"120000",step:"1000",value:X.queueTimeoutMs??"",placeholder:"30000",onChange:a=>Y({...X,queueTimeoutMs:a.target.value?Number(a.target.value):void 0}),className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none"})]})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted",children:k("advancedHint")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 p-3 bg-black/[0.02] dark:bg-white/[0.02] rounded-lg border border-black/5 dark:border-white/5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"smart_toy"}),(0,d.jsx)("p",{className:"text-xs font-medium",children:"Agent Features"}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"— optional, for agent/tool workflows"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[11px] font-medium text-text-muted block mb-0.5",children:"System Message Override"}),(0,d.jsx)("textarea",{rows:2,value:aa,onChange:a=>ab(a.target.value),placeholder:"Override the system prompt for all requests routed through this combo…",className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none resize-none"}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Replaces any system message sent by the client. Leave empty to pass through client system messages."})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[11px] font-medium text-text-muted block mb-0.5",children:"Tool Filter Regex"}),(0,d.jsx)("input",{type:"text",value:ac,onChange:a=>ad(a.target.value),placeholder:"e.g. ^(bash|computer)$",className:"w-full text-xs py-1.5 px-2 rounded border border-black/10 dark:border-white/10 bg-transparent focus:border-primary focus:outline-none font-mono"}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only tools whose name matches this regex are forwarded to the provider. Leave empty to forward all tools."})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[11px] font-medium text-text-muted block",children:"Context Cache Protection"}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted",children:"Pins the provider/model across turns to preserve cache sessions. Internal tags are stripped before forwarding to the provider."})]}),(0,d.jsx)("input",{type:"checkbox",checked:ae,onChange:a=>af(a.target.checked),className:"accent-primary shrink-0"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,d.jsx)(h.Button,{onClick:c,variant:"ghost",fullWidth:!0,size:"sm",children:l("cancel")}),(0,d.jsx)(h.Button,{onClick:aC,fullWidth:!0,size:"sm",disabled:at,children:H?k("saving"):aD?l("save"):k("createCombo")})]})]})}),(0,d.jsx)(m.ModelSelectModal,{isOpen:B,onClose:()=>C(!1),onSelect:a=>{t.find(b=>b.model===a.value)||u([...t,{model:a.value,weight:0}])},activeProviders:g,modelAliases:R,title:k("addModelToCombo"),selectedModel:null,addedModelValues:t.map(a=>a.model)})]})}function K({models:a}){let b=a.reduce((a,b)=>a+(b.weight||0),0),c=100===b,e=["bg-blue-500","bg-emerald-500","bg-amber-500","bg-purple-500","bg-rose-500","bg-cyan-500","bg-orange-500","bg-indigo-500"];return(0,d.jsxs)("div",{className:"mt-1.5",children:[(0,d.jsx)("div",{className:"h-1.5 rounded-full bg-black/5 dark:bg-white/5 overflow-hidden flex",children:a.map((a,b)=>a.weight?(0,d.jsx)("div",{className:`${e[b%e.length]} transition-all duration-300`,style:{width:`${Math.min(a.weight,100)}%`}},b):null)}),(0,d.jsxs)("div",{className:"flex items-center justify-between mt-0.5",children:[(0,d.jsx)("div",{className:"flex gap-1",children:a.map((a,b)=>a.weight>0&&(0,d.jsxs)("span",{className:"flex items-center gap-0.5 text-[9px] text-text-muted",children:[(0,d.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${e[b%e.length]}`}),a.weight,"%"]},b))}),(0,d.jsxs)("span",{className:`text-[10px] font-medium ${c?"text-emerald-500":b>100?"text-red-500":"text-amber-500"}`,children:[b,"%",!c&&b>0&&" ≠ 100%"]})]})]})}a.s(["default",()=>B]),c()}catch(a){c(a)}},!1)];
2
2
 
3
3
  //# sourceMappingURL=src_55fa8e28._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[489602,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(32886),f=a.i(415925),g=a.i(572131),h=a.i(442308),i=a.i(292216),j=a.i(294023),k=a.i(489108),l=a.i(609754),m=a.i(240246),n=b([h]);function o({value:a,max:b,warningAt:c=.8,formatCurrency:e}){let f=b>0?Math.min(a/b*100,100):0,g=b>0?a/b:0;return(0,d.jsxs)("div",{className:"w-full",children:[(0,d.jsxs)("div",{className:"flex justify-between text-xs mb-1",children:[(0,d.jsx)("span",{className:"text-text-muted",children:e(a)}),(0,d.jsx)("span",{className:"text-text-muted",children:e(b)})]}),(0,d.jsx)("div",{className:"w-full h-2 rounded-full bg-surface/50 overflow-hidden",children:(0,d.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${f}%`,backgroundColor:g>=1?"#ef4444":g>=c?"#f59e0b":"#22c55e"}})})]})}function p(){let a=(0,f.useTranslations)("usage"),b=(0,e.useLocale)(),[c,h]=(0,g.useState)([]),[n,p]=(0,g.useState)(null),[q,r]=(0,g.useState)(null),[s,t]=(0,g.useState)(!0),[u,v]=(0,g.useState)(!1),[w,x]=(0,g.useState)({dailyLimitUsd:"",monthlyLimitUsd:"",warningThreshold:"80"}),y=(0,m.useNotificationStore)(),z=a=>new Intl.NumberFormat(b,{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(a||0));(0,g.useEffect)(()=>{fetch("/api/keys").then(a=>a.json()).then(a=>{let b=Array.isArray(a)?a:a.keys||[];h(b),b.length>0&&p(b[0].id),t(!1)}).catch(()=>t(!1))},[]);let A=(0,g.useCallback)(async()=>{if(n)try{let a=await fetch(`/api/usage/budget?apiKeyId=${n}`);if(a.ok){let b=await a.json();r(b),b.dailyLimitUsd&&x(a=>({...a,dailyLimitUsd:String(b.dailyLimitUsd)})),b.monthlyLimitUsd&&x(a=>({...a,monthlyLimitUsd:String(b.monthlyLimitUsd)})),b.warningThreshold&&x(a=>({...a,warningThreshold:String(b.warningThreshold)}))}}catch{}},[n]);(0,g.useEffect)(()=>{A()},[A]);let B=async()=>{v(!0);try{(await fetch("/api/usage/budget",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKeyId:n,dailyLimitUsd:w.dailyLimitUsd?parseFloat(w.dailyLimitUsd):null,monthlyLimitUsd:w.monthlyLimitUsd?parseFloat(w.monthlyLimitUsd):null,warningThreshold:parseInt(w.warningThreshold)||80})})).ok?(y.success(a("budgetSaved")),await A()):y.error(a("budgetSaveFailed"))}catch{y.error(a("budgetSaveFailed"))}finally{v(!1)}};if(s)return(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted p-8 animate-pulse",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"account_balance_wallet"}),a("loadingBudgetData")]});if(0===c.length)return(0,d.jsx)(l.EmptyState,{icon:"vpn_key",title:a("noApiKeysTitle"),description:a("noApiKeysDescription")});let C=q?.dailyLimitUsd||parseFloat(w.dailyLimitUsd)||0,D=q?.monthlyLimitUsd||parseFloat(w.monthlyLimitUsd)||0,E=q?.totalCostToday||0,F=q?.totalCostMonth||0,G=(parseInt(w.warningThreshold)||80)/100;return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)(i.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"account_balance_wallet"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:a("budgetManagement")})]}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("label",{className:"text-sm text-text-muted mb-1 block",children:a("apiKey")}),(0,d.jsx)("select",{value:n||"",onChange:a=>p(a.target.value),className:"w-full md:w-auto px-3 py-2 rounded-lg border border-border/50 bg-surface/30 text-text-main text-sm focus:outline-none focus:ring-1 focus:ring-primary",children:c.map(a=>(0,d.jsxs)("option",{value:a.id,children:[a.name||a.id," ",a.provider?`(${a.provider})`:""]},a.id))})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[(0,d.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-2",children:a("todaysSpend")}),(0,d.jsx)("p",{className:"text-2xl font-bold text-text-main",children:z(E)}),C>0&&(0,d.jsx)(o,{value:E,max:C,warningAt:G,formatCurrency:z})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-2",children:a("thisMonth")}),(0,d.jsx)("p",{className:"text-2xl font-bold text-text-main",children:z(F)}),D>0&&(0,d.jsx)(o,{value:F,max:D,warningAt:G,formatCurrency:z})]})]}),(0,d.jsxs)("div",{className:"border-t border-border/30 pt-4",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-3",children:a("setLimits")}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[(0,d.jsx)(k.Input,{label:a("dailyLimitUsd"),type:"number",step:"0.01",min:"0",placeholder:a("dailyLimitPlaceholder"),value:w.dailyLimitUsd,onChange:a=>x({...w,dailyLimitUsd:a.target.value})}),(0,d.jsx)(k.Input,{label:a("monthlyLimitUsd"),type:"number",step:"0.01",min:"0",placeholder:a("monthlyLimitPlaceholder"),value:w.monthlyLimitUsd,onChange:a=>x({...w,monthlyLimitUsd:a.target.value})}),(0,d.jsx)(k.Input,{label:a("warningThresholdPercent"),type:"number",min:"1",max:"100",placeholder:a("warningThresholdPlaceholder"),value:w.warningThreshold,onChange:a=>x({...w,warningThreshold:a.target.value})})]}),(0,d.jsx)(j.Button,{variant:"primary",onClick:B,loading:u,children:a("saveLimits")})]})]}),q?.budgetCheck&&(0,d.jsx)(i.Card,{className:"p-4",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",style:{color:q.budgetCheck.allowed?"#22c55e":"#ef4444"},children:q.budgetCheck.allowed?"check_circle":"block"}),(0,d.jsx)("span",{className:"text-sm",children:q.budgetCheck.allowed?a("budgetOk",{remaining:z(q.budgetCheck.remaining||0)}):a("budgetExceeded")})]})})]})}[h]=n.then?(await n)():n,a.s(["default",()=>p]),c()}catch(a){c(a)}},!1),737574,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(292216),h=a.i(415925),i=b([f]);[f]=i.then?(await i)():i;let m=["input","output","cached","reasoning","cache_creation"],n={input:"input",output:"output",cached:"cached",reasoning:"reasoning",cache_creation:"cacheCreation"};function j(){let[a,b]=(0,e.useState)({}),[c,f]=(0,e.useState)({}),[i,j]=(0,e.useState)(!0),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(new Set),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)(new Set),x=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{y()},[]);let y=async()=>{j(!0);try{let[a,c]=await Promise.all([fetch("/api/pricing/models"),fetch("/api/pricing")]);a.ok&&b(await a.json()),c.ok&&f(await c.json())}catch(a){console.error("Failed to load pricing data:",a)}finally{j(!1)}},z=(0,e.useMemo)(()=>Object.entries(a).map(([a,b])=>({alias:a,...b,pricedModels:c[a]?Object.keys(c[a]).length:0})).sort((a,b)=>b.modelCount-a.modelCount),[a,c]),A=(0,e.useMemo)(()=>{if(!t.trim())return z;let a=t.toLowerCase();return z.filter(b=>b.alias.toLowerCase().includes(a)||b.id.toLowerCase().includes(a)||b.models.some(b=>b.id.toLowerCase().includes(a)||b.name.toLowerCase().includes(a)))},[z,t]),B=(0,e.useMemo)(()=>{let a=z.reduce((a,b)=>a+b.modelCount,0),b=Object.values(c).reduce((a,b)=>a+Object.keys(b).length,0);return{providers:z.length,totalModels:a,pricedCount:b}},[z,c]),C=(0,e.useCallback)(a=>{s(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),D=(0,e.useCallback)((a,b,c,d)=>{let e=parseFloat(d);isNaN(e)||e<0||(f(d=>{let f={...d};return f[a]||(f[a]={}),f[a][b]||(f[a][b]={input:0,output:0,cached:0,reasoning:0,cache_creation:0}),f[a][b]={...f[a][b],[c]:e},f}),w(b=>new Set(b).add(a)))},[]),E=(0,e.useCallback)(async a=>{m(!0),o("");try{let b=c[a]||{},d=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})});if(d.ok)o(`✅ ${a.toUpperCase()} ${x("saved")}`),w(b=>{let c=new Set(b);return c.delete(a),c}),setTimeout(()=>o(""),3e3);else{let a=await d.json();o(`❌ ${x("errorOccurred")}: ${a.error}`)}}catch(a){o(`❌ ${x("saveFailed")}: ${a.message}`)}finally{m(!1)}},[c,x]),F=(0,e.useCallback)(async a=>{if(confirm(x("resetPricingConfirm",{provider:a.toUpperCase()})))try{let b=await fetch(`/api/pricing?provider=${a}`,{method:"DELETE"});if(b.ok){let c=await b.json();f(c),o(`🔄 ${a.toUpperCase()} ${x("resetDefaults")}`),w(b=>{let c=new Set(b);return c.delete(a),c}),setTimeout(()=>o(""),3e3)}}catch(a){o(`❌ ${x("resetFailed")}: ${a.message}`)}},[x]),G=(0,e.useCallback)(a=>{q(b=>b===a?null:a)},[]),H=(0,e.useMemo)(()=>p?A.filter(a=>a.alias===p):A,[A,p]);return i?(0,d.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,d.jsx)("div",{className:"text-text-muted animate-pulse",children:x("loadingPricing")})}):(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:x("modelPricing")}),(0,d.jsx)("p",{className:"text-text-muted text-sm mt-1",children:x("modelPricingDesc")})]}),(0,d.jsxs)("div",{className:"flex gap-3 text-sm",children:[(0,d.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,d.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:x("providers")}),(0,d.jsx)("div",{className:"text-lg font-bold",children:B.providers})]}),(0,d.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,d.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:x("registry")}),(0,d.jsx)("div",{className:"text-lg font-bold",children:B.totalModels})]}),(0,d.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,d.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:x("priced")}),(0,d.jsx)("div",{className:"text-lg font-bold text-success",children:B.pricedCount})]})]})]}),n&&(0,d.jsx)("div",{className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm",children:n}),(0,d.jsxs)("div",{className:"flex gap-3 items-center flex-wrap",children:[(0,d.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-lg",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:x("searchProvidersModels"),value:t,onChange:a=>u(a.target.value),className:"w-full pl-10 pr-3 py-2 bg-bg-base border border-border rounded-lg focus:outline-none focus:border-primary text-sm"})]}),p&&(0,d.jsxs)("button",{onClick:()=>q(null),className:"px-3 py-2 text-xs bg-primary/10 text-primary border border-primary/20 rounded-lg hover:bg-primary/20 transition-colors flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"}),p.toUpperCase()," — ",x("showAll")]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:z.map(a=>(0,d.jsxs)("button",{onClick:()=>G(a.alias),className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${p===a.alias?"bg-primary text-white shadow-sm":v.has(a.alias)?"bg-yellow-500/15 text-yellow-400 border border-yellow-500/30":"bg-bg-subtle text-text-muted hover:bg-bg-hover border border-transparent"}`,children:[a.alias.toUpperCase()," ",(0,d.jsxs)("span",{className:"opacity-60",children:["(",a.modelCount,")"]})]},a.alias))}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[H.map(a=>(0,d.jsx)(k,{provider:a,pricingData:c[a.alias]||{},isExpanded:r.has(a.alias),isEdited:v.has(a.alias),onToggle:()=>C(a.alias),onPricingChange:(b,c,d)=>D(a.alias,b,c,d),onSave:()=>E(a.alias),onReset:()=>F(a.alias),saving:l},a.alias)),0===H.length&&(0,d.jsx)("div",{className:"text-center py-12 text-text-muted",children:x("noProvidersMatch")})]}),(0,d.jsxs)(g.Card,{className:"p-4 mt-2",children:[(0,d.jsxs)("h3",{className:"text-sm font-semibold mb-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),x("howPricingWorks")]}),(0,d.jsxs)("div",{className:"text-xs text-text-muted space-y-1",children:[(0,d.jsxs)("p",{children:[x("pricingDescInput")," • ",x("pricingDescOutput")," • ",x("pricingDescCached")," •"," ",x("pricingDescReasoning")," • ",x("pricingDescCacheWrite")]}),(0,d.jsx)("p",{children:x("pricingDescFormula")})]})]})]})}function k({provider:a,pricingData:b,isExpanded:c,isEdited:e,onToggle:f,onPricingChange:g,onSave:i,onReset:j,saving:k}){let o=(0,h.useTranslations)("settings"),p=(0,h.useTranslations)(),q=Object.keys(b).length,r="oauth"===a.authType?p("providers.oauthLabel"):"apikey"===a.authType?p("providers.apiKeyLabel"):a.authType;return(0,d.jsxs)("div",{className:`border rounded-lg overflow-hidden transition-colors ${e?"border-yellow-500/40 bg-yellow-500/5":"border-border"}`,children:[(0,d.jsxs)("button",{onClick:f,className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-hover/50 transition-colors text-left",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-lg transition-transform ${c?"rotate-90":""}`,children:"chevron_right"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"font-semibold text-sm",children:a.id.charAt(0).toUpperCase()+a.id.slice(1)}),(0,d.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",a.alias.toUpperCase(),")"]})]}),(0,d.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:r}),(0,d.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:a.format})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[e&&(0,d.jsx)("span",{className:"text-yellow-500 text-xs font-medium",children:o("unsaved")}),(0,d.jsxs)("span",{className:"text-text-muted text-xs",children:[q,"/",a.modelCount," ",o("withPricing")]}),(0,d.jsx)("div",{className:"w-16 h-1.5 bg-bg-subtle rounded-full overflow-hidden",children:(0,d.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${a.modelCount>0?Math.round(q/a.modelCount*100):0}%`}})})]})]}),c&&(0,d.jsxs)("div",{className:"border-t border-border",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 bg-bg-subtle/50",children:[(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:[a.modelCount," ",o("models")," • ",q," ",o("withPricing")]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),j()},className:"px-2.5 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",children:o("resetDefaults")}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),i()},disabled:k||!e,className:"px-2.5 py-1 text-[11px] bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-40",children:k?o("saving"):o("saveProvider")})]})]}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-[11px] text-text-muted uppercase bg-bg-subtle/30",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-4 py-2 text-left font-semibold",children:o("model")}),m.map(a=>(0,d.jsx)("th",{className:"px-2 py-2 text-right font-semibold w-24",children:o(n[a])},a))]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/50",children:a.models.map(a=>(0,d.jsx)(l,{model:a,pricing:b[a.id],onPricingChange:(b,c)=>g(a.id,b,c)},a.id))})]})})]})]})}function l({model:a,pricing:b,onPricingChange:c}){let e=(0,h.useTranslations)("settings"),f=b&&Object.values(b).some(a=>a>0);return(0,d.jsxs)("tr",{className:"hover:bg-bg-hover/30 group",children:[(0,d.jsx)("td",{className:"px-4 py-1.5",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${f?"bg-success":"bg-text-muted/30"}`}),(0,d.jsx)("span",{className:"font-medium text-xs",children:a.name}),a.custom&&(0,d.jsx)("span",{className:"px-1 py-0.5 text-[8px] font-bold bg-blue-500/15 text-blue-400 border border-blue-500/20 rounded uppercase",children:e("custom")}),(0,d.jsx)("span",{className:"text-text-muted text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:a.id})]})}),m.map(a=>(0,d.jsx)("td",{className:"px-2 py-1.5",children:(0,d.jsx)("input",{type:"number",step:"0.01",min:"0",value:b?.[a]||0,onChange:b=>c(a,b.target.value),className:"w-full px-2 py-1 text-right text-xs bg-transparent border border-transparent hover:border-border focus:border-primary focus:bg-bg-base rounded transition-colors outline-none tabular-nums"})},a))]})}a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),232946,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(260860),h=a.i(489602),i=a.i(737574),j=a.i(415925),k=b([f,h,i]);function l(){let[a,b]=(0,e.useState)("budget"),c=(0,j.useTranslations)("costs"),f=(0,j.useTranslations)("settings");return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(g.SegmentedControl,{options:[{value:"budget",label:c("budget")},{value:"pricing",label:f("pricing")}],value:a,onChange:b}),"budget"===a&&(0,d.jsx)(h.default,{}),"pricing"===a&&(0,d.jsx)(i.default,{})]})}[f,h,i]=k.then?(await k)():k,a.s(["default",()=>l]),c()}catch(a){c(a)}},!1)];
1
+ module.exports=[489602,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(32886),f=a.i(415925),g=a.i(572131),h=a.i(442308),i=a.i(292216),j=a.i(294023),k=a.i(489108),l=a.i(609754),m=a.i(240246),n=b([h]);function o({value:a,max:b,warningAt:c=.8,formatCurrency:e}){let f=b>0?Math.min(a/b*100,100):0,g=b>0?a/b:0;return(0,d.jsxs)("div",{className:"w-full",children:[(0,d.jsxs)("div",{className:"flex justify-between text-xs mb-1",children:[(0,d.jsx)("span",{className:"text-text-muted",children:e(a)}),(0,d.jsx)("span",{className:"text-text-muted",children:e(b)})]}),(0,d.jsx)("div",{className:"w-full h-2 rounded-full bg-surface/50 overflow-hidden",children:(0,d.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${f}%`,backgroundColor:g>=1?"#ef4444":g>=c?"#f59e0b":"#22c55e"}})})]})}function p(){let a=(0,f.useTranslations)("usage"),b=(0,e.useLocale)(),[c,h]=(0,g.useState)([]),[n,p]=(0,g.useState)(null),[q,r]=(0,g.useState)(null),[s,t]=(0,g.useState)(!0),[u,v]=(0,g.useState)(!1),[w,x]=(0,g.useState)({dailyLimitUsd:"",monthlyLimitUsd:"",warningThreshold:"80"}),y=(0,m.useNotificationStore)(),z=a=>new Intl.NumberFormat(b,{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(a||0));(0,g.useEffect)(()=>{fetch("/api/keys").then(a=>a.json()).then(a=>{let b=Array.isArray(a)?a:a.keys||[];h(b),b.length>0&&p(b[0].id),t(!1)}).catch(()=>t(!1))},[]);let A=(0,g.useCallback)(async()=>{if(n)try{let a=await fetch(`/api/usage/budget?apiKeyId=${n}`);if(a.ok){let b=await a.json();r(b),b.dailyLimitUsd&&x(a=>({...a,dailyLimitUsd:String(b.dailyLimitUsd)})),b.monthlyLimitUsd&&x(a=>({...a,monthlyLimitUsd:String(b.monthlyLimitUsd)})),b.warningThreshold&&x(a=>({...a,warningThreshold:String(Math.round(100*b.warningThreshold))}))}}catch{}},[n]);(0,g.useEffect)(()=>{A()},[A]);let B=async()=>{v(!0);try{(await fetch("/api/usage/budget",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKeyId:n,dailyLimitUsd:w.dailyLimitUsd?parseFloat(w.dailyLimitUsd):null,monthlyLimitUsd:w.monthlyLimitUsd?parseFloat(w.monthlyLimitUsd):null,warningThreshold:(parseInt(w.warningThreshold)||80)/100})})).ok?(y.success(a("budgetSaved")),await A()):y.error(a("budgetSaveFailed"))}catch{y.error(a("budgetSaveFailed"))}finally{v(!1)}};if(s)return(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted p-8 animate-pulse",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"account_balance_wallet"}),a("loadingBudgetData")]});if(0===c.length)return(0,d.jsx)(l.EmptyState,{icon:"vpn_key",title:a("noApiKeysTitle"),description:a("noApiKeysDescription")});let C=q?.dailyLimitUsd||parseFloat(w.dailyLimitUsd)||0,D=q?.monthlyLimitUsd||parseFloat(w.monthlyLimitUsd)||0,E=q?.totalCostToday||0,F=q?.totalCostMonth||0,G=(parseInt(w.warningThreshold)||80)/100;return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)(i.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"account_balance_wallet"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:a("budgetManagement")})]}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("label",{className:"text-sm text-text-muted mb-1 block",children:a("apiKey")}),(0,d.jsx)("select",{value:n||"",onChange:a=>p(a.target.value),className:"w-full md:w-auto px-3 py-2 rounded-lg border border-border/50 bg-surface/30 text-text-main text-sm focus:outline-none focus:ring-1 focus:ring-primary",children:c.map(a=>(0,d.jsxs)("option",{value:a.id,children:[a.name||a.id," ",a.provider?`(${a.provider})`:""]},a.id))})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[(0,d.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-2",children:a("todaysSpend")}),(0,d.jsx)("p",{className:"text-2xl font-bold text-text-main",children:z(E)}),C>0&&(0,d.jsx)(o,{value:E,max:C,warningAt:G,formatCurrency:z})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-2",children:a("thisMonth")}),(0,d.jsx)("p",{className:"text-2xl font-bold text-text-main",children:z(F)}),D>0&&(0,d.jsx)(o,{value:F,max:D,warningAt:G,formatCurrency:z})]})]}),(0,d.jsxs)("div",{className:"border-t border-border/30 pt-4",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-3",children:a("setLimits")}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[(0,d.jsx)(k.Input,{label:a("dailyLimitUsd"),type:"number",step:"0.01",min:"0",placeholder:a("dailyLimitPlaceholder"),value:w.dailyLimitUsd,onChange:a=>x({...w,dailyLimitUsd:a.target.value})}),(0,d.jsx)(k.Input,{label:a("monthlyLimitUsd"),type:"number",step:"0.01",min:"0",placeholder:a("monthlyLimitPlaceholder"),value:w.monthlyLimitUsd,onChange:a=>x({...w,monthlyLimitUsd:a.target.value})}),(0,d.jsx)(k.Input,{label:a("warningThresholdPercent"),type:"number",min:"1",max:"100",placeholder:a("warningThresholdPlaceholder"),value:w.warningThreshold,onChange:a=>x({...w,warningThreshold:a.target.value})})]}),(0,d.jsx)(j.Button,{variant:"primary",onClick:B,loading:u,children:a("saveLimits")})]})]}),q?.budgetCheck&&(0,d.jsx)(i.Card,{className:"p-4",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",style:{color:q.budgetCheck.allowed?"#22c55e":"#ef4444"},children:q.budgetCheck.allowed?"check_circle":"block"}),(0,d.jsx)("span",{className:"text-sm",children:q.budgetCheck.allowed?a("budgetOk",{remaining:z(q.budgetCheck.remaining||0)}):a("budgetExceeded")})]})})]})}[h]=n.then?(await n)():n,a.s(["default",()=>p]),c()}catch(a){c(a)}},!1),737574,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(292216),h=a.i(415925),i=b([f]);[f]=i.then?(await i)():i;let m=["input","output","cached","reasoning","cache_creation"],n={input:"input",output:"output",cached:"cached",reasoning:"reasoning",cache_creation:"cacheCreation"};function j(){let[a,b]=(0,e.useState)({}),[c,f]=(0,e.useState)({}),[i,j]=(0,e.useState)(!0),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(new Set),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)(new Set),x=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{y()},[]);let y=async()=>{j(!0);try{let[a,c]=await Promise.all([fetch("/api/pricing/models"),fetch("/api/pricing")]);a.ok&&b(await a.json()),c.ok&&f(await c.json())}catch(a){console.error("Failed to load pricing data:",a)}finally{j(!1)}},z=(0,e.useMemo)(()=>Object.entries(a).map(([a,b])=>({alias:a,...b,pricedModels:c[a]?Object.keys(c[a]).length:0})).sort((a,b)=>b.modelCount-a.modelCount),[a,c]),A=(0,e.useMemo)(()=>{if(!t.trim())return z;let a=t.toLowerCase();return z.filter(b=>b.alias.toLowerCase().includes(a)||b.id.toLowerCase().includes(a)||b.models.some(b=>b.id.toLowerCase().includes(a)||b.name.toLowerCase().includes(a)))},[z,t]),B=(0,e.useMemo)(()=>{let a=z.reduce((a,b)=>a+b.modelCount,0),b=Object.values(c).reduce((a,b)=>a+Object.keys(b).length,0);return{providers:z.length,totalModels:a,pricedCount:b}},[z,c]),C=(0,e.useCallback)(a=>{s(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),D=(0,e.useCallback)((a,b,c,d)=>{let e=parseFloat(d);isNaN(e)||e<0||(f(d=>{let f={...d};return f[a]||(f[a]={}),f[a][b]||(f[a][b]={input:0,output:0,cached:0,reasoning:0,cache_creation:0}),f[a][b]={...f[a][b],[c]:e},f}),w(b=>new Set(b).add(a)))},[]),E=(0,e.useCallback)(async a=>{m(!0),o("");try{let b=c[a]||{},d=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})});if(d.ok)o(`✅ ${a.toUpperCase()} ${x("saved")}`),w(b=>{let c=new Set(b);return c.delete(a),c}),setTimeout(()=>o(""),3e3);else{let a=await d.json();o(`❌ ${x("errorOccurred")}: ${a.error}`)}}catch(a){o(`❌ ${x("saveFailed")}: ${a.message}`)}finally{m(!1)}},[c,x]),F=(0,e.useCallback)(async a=>{if(confirm(x("resetPricingConfirm",{provider:a.toUpperCase()})))try{let b=await fetch(`/api/pricing?provider=${a}`,{method:"DELETE"});if(b.ok){let c=await b.json();f(c),o(`🔄 ${a.toUpperCase()} ${x("resetDefaults")}`),w(b=>{let c=new Set(b);return c.delete(a),c}),setTimeout(()=>o(""),3e3)}}catch(a){o(`❌ ${x("resetFailed")}: ${a.message}`)}},[x]),G=(0,e.useCallback)(a=>{q(b=>b===a?null:a)},[]),H=(0,e.useMemo)(()=>p?A.filter(a=>a.alias===p):A,[A,p]);return i?(0,d.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,d.jsx)("div",{className:"text-text-muted animate-pulse",children:x("loadingPricing")})}):(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:x("modelPricing")}),(0,d.jsx)("p",{className:"text-text-muted text-sm mt-1",children:x("modelPricingDesc")})]}),(0,d.jsxs)("div",{className:"flex gap-3 text-sm",children:[(0,d.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,d.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:x("providers")}),(0,d.jsx)("div",{className:"text-lg font-bold",children:B.providers})]}),(0,d.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,d.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:x("registry")}),(0,d.jsx)("div",{className:"text-lg font-bold",children:B.totalModels})]}),(0,d.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,d.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:x("priced")}),(0,d.jsx)("div",{className:"text-lg font-bold text-success",children:B.pricedCount})]})]})]}),n&&(0,d.jsx)("div",{className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm",children:n}),(0,d.jsxs)("div",{className:"flex gap-3 items-center flex-wrap",children:[(0,d.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-lg",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:x("searchProvidersModels"),value:t,onChange:a=>u(a.target.value),className:"w-full pl-10 pr-3 py-2 bg-bg-base border border-border rounded-lg focus:outline-none focus:border-primary text-sm"})]}),p&&(0,d.jsxs)("button",{onClick:()=>q(null),className:"px-3 py-2 text-xs bg-primary/10 text-primary border border-primary/20 rounded-lg hover:bg-primary/20 transition-colors flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"}),p.toUpperCase()," — ",x("showAll")]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:z.map(a=>(0,d.jsxs)("button",{onClick:()=>G(a.alias),className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${p===a.alias?"bg-primary text-white shadow-sm":v.has(a.alias)?"bg-yellow-500/15 text-yellow-400 border border-yellow-500/30":"bg-bg-subtle text-text-muted hover:bg-bg-hover border border-transparent"}`,children:[a.alias.toUpperCase()," ",(0,d.jsxs)("span",{className:"opacity-60",children:["(",a.modelCount,")"]})]},a.alias))}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[H.map(a=>(0,d.jsx)(k,{provider:a,pricingData:c[a.alias]||{},isExpanded:r.has(a.alias),isEdited:v.has(a.alias),onToggle:()=>C(a.alias),onPricingChange:(b,c,d)=>D(a.alias,b,c,d),onSave:()=>E(a.alias),onReset:()=>F(a.alias),saving:l},a.alias)),0===H.length&&(0,d.jsx)("div",{className:"text-center py-12 text-text-muted",children:x("noProvidersMatch")})]}),(0,d.jsxs)(g.Card,{className:"p-4 mt-2",children:[(0,d.jsxs)("h3",{className:"text-sm font-semibold mb-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),x("howPricingWorks")]}),(0,d.jsxs)("div",{className:"text-xs text-text-muted space-y-1",children:[(0,d.jsxs)("p",{children:[x("pricingDescInput")," • ",x("pricingDescOutput")," • ",x("pricingDescCached")," •"," ",x("pricingDescReasoning")," • ",x("pricingDescCacheWrite")]}),(0,d.jsx)("p",{children:x("pricingDescFormula")})]})]})]})}function k({provider:a,pricingData:b,isExpanded:c,isEdited:e,onToggle:f,onPricingChange:g,onSave:i,onReset:j,saving:k}){let o=(0,h.useTranslations)("settings"),p=(0,h.useTranslations)(),q=Object.keys(b).length,r="oauth"===a.authType?p("providers.oauthLabel"):"apikey"===a.authType?p("providers.apiKeyLabel"):a.authType;return(0,d.jsxs)("div",{className:`border rounded-lg overflow-hidden transition-colors ${e?"border-yellow-500/40 bg-yellow-500/5":"border-border"}`,children:[(0,d.jsxs)("button",{onClick:f,className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-hover/50 transition-colors text-left",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-lg transition-transform ${c?"rotate-90":""}`,children:"chevron_right"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"font-semibold text-sm",children:a.id.charAt(0).toUpperCase()+a.id.slice(1)}),(0,d.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",a.alias.toUpperCase(),")"]})]}),(0,d.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:r}),(0,d.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:a.format})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[e&&(0,d.jsx)("span",{className:"text-yellow-500 text-xs font-medium",children:o("unsaved")}),(0,d.jsxs)("span",{className:"text-text-muted text-xs",children:[q,"/",a.modelCount," ",o("withPricing")]}),(0,d.jsx)("div",{className:"w-16 h-1.5 bg-bg-subtle rounded-full overflow-hidden",children:(0,d.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${a.modelCount>0?Math.round(q/a.modelCount*100):0}%`}})})]})]}),c&&(0,d.jsxs)("div",{className:"border-t border-border",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 bg-bg-subtle/50",children:[(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:[a.modelCount," ",o("models")," • ",q," ",o("withPricing")]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),j()},className:"px-2.5 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",children:o("resetDefaults")}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),i()},disabled:k||!e,className:"px-2.5 py-1 text-[11px] bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-40",children:k?o("saving"):o("saveProvider")})]})]}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-[11px] text-text-muted uppercase bg-bg-subtle/30",children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{className:"px-4 py-2 text-left font-semibold",children:o("model")}),m.map(a=>(0,d.jsx)("th",{className:"px-2 py-2 text-right font-semibold w-24",children:o(n[a])},a))]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/50",children:a.models.map(a=>(0,d.jsx)(l,{model:a,pricing:b[a.id],onPricingChange:(b,c)=>g(a.id,b,c)},a.id))})]})})]})]})}function l({model:a,pricing:b,onPricingChange:c}){let e=(0,h.useTranslations)("settings"),f=b&&Object.values(b).some(a=>a>0);return(0,d.jsxs)("tr",{className:"hover:bg-bg-hover/30 group",children:[(0,d.jsx)("td",{className:"px-4 py-1.5",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${f?"bg-success":"bg-text-muted/30"}`}),(0,d.jsx)("span",{className:"font-medium text-xs",children:a.name}),a.custom&&(0,d.jsx)("span",{className:"px-1 py-0.5 text-[8px] font-bold bg-blue-500/15 text-blue-400 border border-blue-500/20 rounded uppercase",children:e("custom")}),(0,d.jsx)("span",{className:"text-text-muted text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:a.id})]})}),m.map(a=>(0,d.jsx)("td",{className:"px-2 py-1.5",children:(0,d.jsx)("input",{type:"number",step:"0.01",min:"0",value:b?.[a]||0,onChange:b=>c(a,b.target.value),className:"w-full px-2 py-1 text-right text-xs bg-transparent border border-transparent hover:border-border focus:border-primary focus:bg-bg-base rounded transition-colors outline-none tabular-nums"})},a))]})}a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),232946,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(260860),h=a.i(489602),i=a.i(737574),j=a.i(415925),k=b([f,h,i]);function l(){let[a,b]=(0,e.useState)("budget"),c=(0,j.useTranslations)("costs"),f=(0,j.useTranslations)("settings");return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(g.SegmentedControl,{options:[{value:"budget",label:c("budget")},{value:"pricing",label:f("pricing")}],value:a,onChange:b}),"budget"===a&&(0,d.jsx)(h.default,{}),"pricing"===a&&(0,d.jsx)(i.default,{})]})}[f,h,i]=k.then?(await k)():k,a.s(["default",()=>l]),c()}catch(a){c(a)}},!1)];
2
2
 
3
3
  //# sourceMappingURL=src_app_%28dashboard%29_dashboard_cc92bcad._.js.map
@@ -1,2 +1,2 @@
1
- <!DOCTYPE html><!--sr8mILxXxauNpSSzV2kMh--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/e22b90cf374c3818.js"/><script src="/_next/static/chunks/3dd6d23a48e5d078.js" async=""></script><script src="/_next/static/chunks/726579f2940c2a2f.js" async=""></script><script src="/_next/static/chunks/b133d1854532ff8c.js" async=""></script><script src="/_next/static/chunks/c88fcc5f8b21ff92.js" async=""></script><script src="/_next/static/chunks/turbopack-858efc89e955ca00.js" async=""></script><script src="/_next/static/chunks/d96012bcfc98706a.js" async=""></script><script src="/_next/static/chunks/16ea27c3b926bc31.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
- @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/e22b90cf374c3818.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[339756,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n3:I[837457,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n4:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"ViewportBoundary\"]\n9:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"MetadataBoundary\"]\nb:I[168027,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"sr8mILxXxauNpSSzV2kMh\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/d96012bcfc98706a.js\",\"async\":true,\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-1\",{\"src\":\"/_next/static/chunks/16ea27c3b926bc31.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\na:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><!--V_vOqF97lGIlKgf2kSlun--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/e22b90cf374c3818.js"/><script src="/_next/static/chunks/3dd6d23a48e5d078.js" async=""></script><script src="/_next/static/chunks/726579f2940c2a2f.js" async=""></script><script src="/_next/static/chunks/b133d1854532ff8c.js" async=""></script><script src="/_next/static/chunks/c88fcc5f8b21ff92.js" async=""></script><script src="/_next/static/chunks/turbopack-858efc89e955ca00.js" async=""></script><script src="/_next/static/chunks/d96012bcfc98706a.js" async=""></script><script src="/_next/static/chunks/16ea27c3b926bc31.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
+ @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/e22b90cf374c3818.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[339756,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n3:I[837457,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n4:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"ViewportBoundary\"]\n9:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"MetadataBoundary\"]\nb:I[168027,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"V_vOqF97lGIlKgf2kSlun\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/d96012bcfc98706a.js\",\"async\":true,\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-1\",{\"src\":\"/_next/static/chunks/16ea27c3b926bc31.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\na:[]\n"])</script></body></html>
@@ -1 +1 @@
1
- self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"/I9giW1M8n+IhdORze3fum8Xo1KMiPXcduagdT8+uqI=\"\n}"
1
+ self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"h40H2nT1lNFGr4yaL8BmLFjpNXYxbmMzozTYxkgxOD0=\"\n}"
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "node": {},
3
3
  "edge": {},
4
- "encryptionKey": "/I9giW1M8n+IhdORze3fum8Xo1KMiPXcduagdT8+uqI="
4
+ "encryptionKey": "h40H2nT1lNFGr4yaL8BmLFjpNXYxbmMzozTYxkgxOD0="
5
5
  }
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,804730,t=>{t.v({name:"omniroute",version:"2.7.5",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"next build","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.1.6","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10","@swc/helpers":"0.5.19"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"16.1.6",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]}})},175696,t=>{"use strict";var e=t.i(861745),s=t.i(843476);function n({locale:t,...n}){if(!t)throw Error(void 0);return(0,s.jsx)(e.IntlProvider,{locale:t,...n})}t.s(["default",()=>n])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,804730,t=>{t.v({name:"omniroute",version:"2.7.8",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"next build","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.1.6","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10","@swc/helpers":"0.5.19"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"16.1.6",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]}})},175696,t=>{"use strict";var e=t.i(861745),s=t.i(843476);function n({locale:t,...n}){if(!t)throw Error(void 0);return(0,s.jsx)(e.IntlProvider,{locale:t,...n})}t.s(["default",()=>n])}]);