omniroute 3.0.6 → 3.0.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.
- package/app/.next/BUILD_ID +1 -1
- package/app/.next/build-manifest.json +2 -2
- package/app/.next/prerender-manifest.json +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/agents/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/agents/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/costs/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/costs/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/health/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/health/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/limits/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/limits/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/logs/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/logs/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/media/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/playground/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/playground/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/search-tools/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/search-tools/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/settings/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/400/page.js +2 -2
- package/app/.next/server/app/400/page.js.nft.json +1 -1
- package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/401/page.js +2 -2
- package/app/.next/server/app/401/page.js.nft.json +1 -1
- package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/403/page.js +2 -2
- package/app/.next/server/app/403/page.js.nft.json +1 -1
- package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/408/page.js +2 -2
- package/app/.next/server/app/408/page.js.nft.json +1 -1
- package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/429/page.js +2 -2
- package/app/.next/server/app/429/page.js.nft.json +1 -1
- package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/500/page.js +2 -2
- package/app/.next/server/app/500/page.js.nft.json +1 -1
- package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/502/page.js +2 -2
- package/app/.next/server/app/502/page.js.nft.json +1 -1
- package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/503/page.js +2 -2
- package/app/.next/server/app/503/page.js.nft.json +1 -1
- package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page.js +1 -1
- package/app/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/app/.next/server/app/_global-error.html +2 -2
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page.js +2 -2
- package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/api/logs/console/route.js +1 -1
- package/app/.next/server/app/api/logs/console/route.js.nft.json +1 -1
- package/app/.next/server/app/api/openapi/spec/route.js +1 -1
- package/app/.next/server/app/api/openapi/spec/route.js.nft.json +1 -1
- package/app/.next/server/app/api/settings/proxy/test/route.js +7 -2
- package/app/.next/server/app/api/settings/proxy/test/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/load/route.js +1 -1
- package/app/.next/server/app/api/translator/load/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/save/route.js +1 -1
- package/app/.next/server/app/api/translator/save/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/route.js +6 -5
- package/app/.next/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
- package/app/.next/server/app/callback/page.js +2 -2
- package/app/.next/server/app/callback/page.js.nft.json +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/docs/page.js +2 -2
- package/app/.next/server/app/docs/page.js.nft.json +1 -1
- package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forbidden/page.js +2 -2
- package/app/.next/server/app/forbidden/page.js.nft.json +1 -1
- package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forgot-password/page.js +2 -2
- package/app/.next/server/app/forgot-password/page.js.nft.json +1 -1
- package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing/page.js +2 -2
- package/app/.next/server/app/landing/page.js.nft.json +1 -1
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login/page.js +2 -2
- package/app/.next/server/app/login/page.js.nft.json +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/maintenance/page.js +2 -2
- package/app/.next/server/app/maintenance/page.js.nft.json +1 -1
- package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/offline/page.js +2 -2
- package/app/.next/server/app/offline/page.js.nft.json +1 -1
- package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/page.js +2 -2
- package/app/.next/server/app/page.js.nft.json +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/privacy/page.js +2 -2
- package/app/.next/server/app/privacy/page.js.nft.json +1 -1
- package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/status/page.js +2 -2
- package/app/.next/server/app/status/page.js.nft.json +1 -1
- package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/terms/page.js +2 -2
- package/app/.next/server/app/terms/page.js.nft.json +1 -1
- package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__051203a6._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0891af92._.js +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__fea5312b._.js → [root-of-the-server]__1a67cabb._.js} +2 -2
- package/app/.next/server/chunks/[root-of-the-server]__1f2b0d89._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__228deb98._.js +6 -0
- package/app/.next/server/chunks/[root-of-the-server]__3aa1672b._.js +3 -0
- package/app/.next/server/chunks/{[root-of-the-server]__9d50d114._.js → [root-of-the-server]__3e31c0c5._.js} +2 -2
- package/app/.next/server/chunks/[root-of-the-server]__46e00e59._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__4e5a04c2._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__6e52619e._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__70a3877b._.js +5 -5
- package/app/.next/server/chunks/[root-of-the-server]__7ace0fcd._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__7d0781e8._.js +6 -0
- package/app/.next/server/chunks/[root-of-the-server]__7fa4d14e._.js +1 -1
- package/app/.next/server/chunks/{[root-of-the-server]__6ff1ab32._.js → [root-of-the-server]__ab1817d2._.js} +2 -2
- package/app/.next/server/chunks/[root-of-the-server]__b013abab._.js +6 -6
- package/app/.next/server/chunks/{[root-of-the-server]__e376e668._.js → [root-of-the-server]__b2d1faff._.js} +2 -2
- package/app/.next/server/chunks/{[root-of-the-server]__192ce3e4._.js → [root-of-the-server]__b974107a._.js} +2 -2
- package/app/.next/server/chunks/[root-of-the-server]__d49fae76._.js +3 -0
- package/app/.next/server/chunks/{[root-of-the-server]__1a89bfa5._.js → [root-of-the-server]__d6de923d._.js} +3 -3
- package/app/.next/server/chunks/_05c48915._.js +1 -1
- package/app/.next/server/chunks/_06515a8a._.js +1 -1
- package/app/.next/server/chunks/_2115d8de._.js +1 -1
- package/app/.next/server/chunks/_3ac953eb._.js +1 -1
- package/app/.next/server/chunks/_4b8fd853._.js +1 -1
- package/app/.next/server/chunks/_68683848._.js +1 -1
- package/app/.next/server/chunks/_85c0d9b3._.js +1 -1
- package/app/.next/server/chunks/_d13cbb6d._.js +3 -0
- package/app/.next/server/chunks/_ee9b677b._.js +1 -1
- package/app/.next/server/chunks/_efd5ede2._.js +1 -1
- package/app/.next/server/chunks/open-sse_config_providerModels_ts_04541468._.js +1 -1
- package/app/.next/server/chunks/open-sse_config_providerRegistry_ts_2f74ec2a._.js +1 -1
- package/app/.next/server/chunks/open-sse_config_providerRegistry_ts_dec0f840._.js +1 -1
- package/app/.next/server/chunks/open-sse_translator_index_ts_f5fd0821._.js +1 -1
- package/app/.next/server/chunks/ssr/{[root-of-the-server]__d5a9e5ee._.js → [root-of-the-server]__62183d3b._.js} +2 -2
- package/app/.next/server/chunks/ssr/{[root-of-the-server]__e4499d60._.js → [root-of-the-server]__7a1929fd._.js} +2 -2
- package/app/.next/server/chunks/ssr/{[root-of-the-server]__18da985c._.js → [root-of-the-server]__9c6249ab._.js} +2 -2
- package/app/.next/server/chunks/ssr/[root-of-the-server]__9ef96d20._.js +1 -1
- package/app/.next/server/chunks/ssr/[root-of-the-server]__a6942102._.js +1 -1
- package/app/.next/server/chunks/ssr/_19b3d5b1._.js +1 -1
- package/app/.next/server/chunks/ssr/open-sse_config_providerModels_ts_4cac55e2._.js +1 -1
- package/app/.next/server/chunks/ssr/src_608e5edc._.js +1 -1
- package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_936a9ee0._.js +1 -1
- package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_playground_page_tsx_06c08266._.js +2 -2
- package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_settings_9e20fb8d._.js +1 -1
- package/app/.next/server/middleware.js +1 -1
- package/app/.next/server/pages/500.html +2 -2
- package/app/.next/server/server-reference-manifest.js +1 -1
- package/app/.next/server/server-reference-manifest.json +1 -1
- package/app/.next/static/chunks/{c4538578367f8d6e.js → 29003ec8ef226c62.js} +2 -2
- package/app/.next/static/chunks/{98a065e472ead1c5.js → 58d319dd9faa8901.js} +1 -1
- package/app/.next/static/chunks/6350bc1d56a7114c.js +2 -0
- package/app/.next/static/chunks/{339b27cecfee41d1.js → 6d9bfb06374cbab3.js} +1 -1
- package/app/.next/static/chunks/9330486b16098458.js +1 -0
- package/app/.next/static/chunks/a622fa7a630e2dc2.js +1 -0
- package/app/CHANGELOG.md +35 -0
- package/app/docs/openapi.yaml +1 -1
- package/app/open-sse/config/providerRegistry.ts +7 -1
- package/app/open-sse/handlers/responseSanitizer.ts +58 -0
- package/app/open-sse/services/signatureCache.ts +5 -0
- package/app/open-sse/translator/response/openai-to-claude.ts +12 -1
- package/app/open-sse/utils/usageTracking.ts +44 -5
- package/app/package-lock.json +20 -20
- package/app/package.json +1 -1
- package/app/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx +40 -0
- package/app/src/app/(dashboard)/dashboard/playground/page.tsx +39 -40
- package/app/src/app/(dashboard)/dashboard/settings/components/ProxyRegistryManager.tsx +1 -2
- package/app/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/index.tsx +1 -1
- package/app/src/app/api/settings/proxy/test/route.ts +21 -1
- package/app/src/app/api/usage/[connectionId]/route.ts +83 -35
- package/app/src/lib/db/combos.ts +5 -5
- package/app/src/lib/db/models.ts +9 -9
- package/package.json +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__5dcab57b._.js +0 -6
- package/app/.next/server/chunks/[root-of-the-server]__643f87ad._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__765c4417._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__7afe1e49._.js +0 -3
- package/app/.next/static/chunks/0e39e279bf7e4cd9.js +0 -2
- package/app/.next/static/chunks/3f18998354dd49b9.js +0 -1
- package/app/.next/static/chunks/f62c550263d8bca8.js +0 -1
- /package/app/.next/static/{4vzx2qUM_tiJPdpx_Hiqj → VtLeHcThjUtEgx1Z2skPg}/_buildManifest.js +0 -0
- /package/app/.next/static/{4vzx2qUM_tiJPdpx_Hiqj → VtLeHcThjUtEgx1Z2skPg}/_clientMiddlewareManifest.json +0 -0
- /package/app/.next/static/{4vzx2qUM_tiJPdpx_Hiqj → VtLeHcThjUtEgx1Z2skPg}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[296248,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(818465),j=a.i(32886),k=a.i(415925),l=b([f]);function m(){let[a,b]=(0,e.useState)([]),[c,f]=(0,e.useState)(!1),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)({type:"",message:""}),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)({type:"",message:""}),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)({type:"",message:""}),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(null),H=(0,e.useRef)(null),I=(0,j.useLocale)(),J=(0,k.useTranslations)("settings"),K=(0,k.useTranslations)("common"),[L,M]=(0,e.useState)({driver:"sqlite",dbPath:"~/.omniroute/storage.sqlite",sizeBytes:0,retentionDays:90,lastBackupAt:null}),N=async()=>{f(!0);try{let a=await fetch("/api/db-backups"),c=await a.json();b(c.backups||[])}catch(a){console.error("Failed to fetch backups:",a)}finally{f(!1)}},O=async()=>{try{let a=await fetch("/api/storage/health");if(!a.ok)return;let b=await a.json();M(a=>({...a,...b}))}catch(a){console.error("Failed to fetch storage health:",a)}},P=async()=>{u(!0),w({type:"",message:""});try{let a=await fetch("/api/db-backups",{method:"PUT"}),b=await a.json();a.ok?(b.filename?w({type:"success",message:J("backupCreated",{file:b.filename})}):w({type:"info",message:b.message||J("noChangesSinceBackup")}),await O(),l&&await N()):w({type:"error",message:b.error||J("backupFailed")})}catch{w({type:"error",message:J("errorOccurred")})}finally{u(!1)}},Q=async a=>{q(a),o({type:"",message:""});try{let b=await fetch("/api/db-backups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({backupId:a})}),c=await b.json();b.ok?(o({type:"success",message:J("restoreSuccess",{connections:c.connectionCount,nodes:c.nodeCount,combos:c.comboCount,apiKeys:c.apiKeyCount})}),await N(),await O()):o({type:"error",message:c.error||J("restoreFailed")})}catch{o({type:"error",message:J("errorDuringRestore")})}finally{q(null),s(null)}};(0,e.useEffect)(()=>{O()},[]);let R=async()=>{y(!0);try{let a=await fetch("/api/db-backups/export");if(!a.ok){let b=await a.json();throw Error(b.error||J("exportFailed"))}let b=await a.blob(),c=URL.createObjectURL(b),d=(a.headers.get("Content-Disposition")||"").match(/filename="(.+)"/),e=d?d[1]:`omniroute-backup-${new Date().toISOString().replace(/[:.]/g,"-")}.sqlite`,f=document.createElement("a");f.href=c,f.download=e,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(c)}catch(a){console.error("Export failed:",a),C({type:"error",message:J("exportFailedWithError",{error:a.message})})}finally{y(!1)}},S=async()=>{if(F){A(!0),C({type:"",message:""}),E(!1);try{let a=new FormData;a.append("file",F);let b=await fetch("/api/db-backups/import",{method:"POST",body:a}),c=await b.json();b.ok?(C({type:"success",message:J("importSuccess",{connections:c.connectionCount,nodes:c.nodeCount,combos:c.comboCount,apiKeys:c.apiKeyCount})}),await O(),l&&await N()):C({type:"error",message:c.error||J("importFailed")})}catch{C({type:"error",message:J("errorDuringImport")})}finally{A(!1),G(null)}}},T=a=>a&&0!==a?a<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} KB`:`${(a/1048576).toFixed(1)} MB`:"0 B";return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-green-500/10 text-green-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"database"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:J("systemStorage")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:J("allDataLocal")})]}),(0,d.jsx)(i.Badge,{variant:"success",size:"sm",children:L.driver||"json"})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-4",children:[(0,d.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,d.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:J("databasePath")}),(0,d.jsx)("p",{className:"text-sm font-mono text-text-main break-all",children:L.dbPath||"~/.omniroute/storage.sqlite"})]}),(0,d.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,d.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:J("databaseSize")}),(0,d.jsx)("p",{className:"text-sm font-mono text-text-main",children:T(L.sizeBytes)})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:R,loading:x,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"download"}),J("exportDatabase")]}),(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:async()=>{y(!0);try{let a=await fetch("/api/db-backups/exportAll");if(!a.ok)throw Error(J("exportFailed"));let b=await a.blob(),c=(a.headers.get("Content-Disposition")||"").match(/filename="?([^"]+)"?/),d=c?.[1]||"omniroute-full-backup.tar.gz",e=URL.createObjectURL(b),f=document.createElement("a");f.href=e,f.download=d,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(e)}catch(a){C({type:"error",message:J("fullExportFailedWithError",{error:a.message})})}finally{y(!1)}},loading:x,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"folder_zip"}),J("exportAll")]}),(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:()=>{H.current?.click()},loading:z,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"upload"}),J("importDatabase")]}),(0,d.jsx)("input",{ref:H,type:"file",accept:".sqlite",className:"hidden",onChange:a=>{let b=a.target.files?.[0];if(b){if(!b.name.endsWith(".sqlite"))return void C({type:"error",message:J("invalidFileType")});G(b),E(!0),H.current&&(H.current.value="")}}})]}),D&&F&&(0,d.jsx)("div",{className:"p-4 rounded-lg mb-4 bg-amber-500/10 border border-amber-500/30",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px] text-amber-500 mt-0.5","aria-hidden":"true",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-500 mb-1",children:J("confirmDbImport")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:J("confirmDbImportDesc",{file:F.name})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:S,className:"!bg-amber-500 hover:!bg-amber-600",children:J("yesImport")}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:()=>{E(!1),G(null)},children:K("cancel")})]})]})]})}),B.message&&(0,d.jsx)("div",{className:`p-3 rounded-lg mb-4 text-sm ${"success"===B.type?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===B.type?"check_circle":"error"}),B.message]})}),(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-bg border border-border mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"schedule"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:J("lastBackup")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:L.lastBackupAt?`${new Date(L.lastBackupAt).toLocaleString(I)} (${(a=>{if(!a)return null;let b=new Date,c=new Date(a),d=Math.floor((b-c)/6e4);if(d<1)return J("justNow");if(d<60)return J("minutesAgo",{count:d});let e=Math.floor(d/60);if(e<24)return J("hoursAgo",{count:e});let f=Math.floor(e/24);return J("daysAgo",{count:f})})(L.lastBackupAt)})`:J("noBackupYet")})]})]}),(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:P,loading:t,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"backup"}),J("backupNow")]})]}),v.message&&(0,d.jsx)("div",{className:`p-3 rounded-lg mb-4 text-sm ${"success"===v.type?"bg-green-500/10 text-green-500 border border-green-500/20":"info"===v.type?"bg-blue-500/10 text-blue-500 border border-blue-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===v.type?"check_circle":"info"===v.type?"info":"error"}),v.message]})}),(0,d.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] text-amber-500","aria-hidden":"true",children:"restore"}),(0,d.jsx)("p",{className:"font-medium",children:J("backupRestore")})]}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:()=>{m(!l),l||0!==a.length||N()},children:l?J("hide"):J("viewBackups")})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-3",children:J("backupRetentionDesc")}),n.message&&(0,d.jsx)("div",{className:`p-3 rounded-lg mb-3 text-sm ${"success"===n.type?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===n.type?"check_circle":"error"}),n.message]})}),l&&(0,d.jsx)("div",{className:"flex flex-col gap-2",children:c?(0,d.jsxs)("div",{className:"flex items-center justify-center py-6 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px] mr-2","aria-hidden":"true",children:"progress_activity"}),J("loadingBackups")]}):0===a.length?(0,d.jsxs)("div",{className:"text-center py-6 text-text-muted text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40","aria-hidden":"true",children:"folder_off"}),J("noBackupsYet")]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted",children:J("backupsAvailable",{count:a.length})}),(0,d.jsxs)("button",{onClick:N,className:"text-xs text-primary hover:underline flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"refresh"}),J("refresh")]})]}),a.map(a=>{var b;return(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-black/[0.02] dark:bg-white/[0.02] border border-border/50 hover:border-border transition-colors",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"description"}),(0,d.jsx)("span",{className:"text-sm font-medium truncate",children:new Date(a.createdAt).toLocaleString(I)}),(0,d.jsx)(i.Badge,{variant:"pre-restore"===a.reason?"warning":"manual"===a.reason?"success":"default",size:"sm",children:(b=a.reason,"manual"===b?J("backupReasonManual"):"pre-restore"===b?J("backupReasonPreRestore"):b)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted ml-6",children:[(0,d.jsx)("span",{children:J("connectionsCount",{count:a.connectionCount})}),(0,d.jsx)("span",{children:"•"}),(0,d.jsx)("span",{children:T(a.size)})]})]}),(0,d.jsx)("div",{className:"flex items-center gap-2 ml-3",children:r===a.id?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-xs text-amber-500 font-medium",children:J("confirm")}),(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:()=>Q(a.id),loading:p===a.id,className:"!bg-amber-500 hover:!bg-amber-600",children:J("yes")}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:()=>s(null),children:J("no")})]}):(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:()=>s(a.id),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"restore"}),J("restore")]})})]},a.id)})]})})]})]})}[f]=l.then?(await l)():l,a.s(["default",()=>m]),c()}catch(a){c(a)}},!1),130361,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(489108),j=a.i(415925),k=b([f]);[f]=k.then?(await k)():k;let m=[{value:"disabled",labelKey:"ipModeDisabled",icon:"block"},{value:"blacklist",labelKey:"ipModeBlacklist",icon:"do_not_disturb"},{value:"whitelist",labelKey:"ipModeWhitelist",icon:"verified_user"},{value:"whitelist-priority",labelKey:"ipModeWhitelistPriority",icon:"priority_high"}];function l(){let[a,b]=(0,e.useState)({enabled:!1,mode:"blacklist",blacklist:[],whitelist:[],tempBans:[]}),[c,f]=(0,e.useState)(!0),[k,l]=(0,e.useState)(""),[n,o]=(0,e.useState)("blacklist"),p=(0,j.useTranslations)("settings");(0,e.useEffect)(()=>{q()},[]);let q=async()=>{try{let a=await fetch("/api/settings/ip-filter");a.ok&&b(await a.json())}catch{}finally{f(!1)}},r=async a=>{try{let c=await fetch("/api/settings/ip-filter",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});c.ok&&b(await c.json())}catch{}},s=()=>{k.trim()&&(r({["blacklist"===n?"addBlacklist":"addWhitelist"]:k.trim()}),l(""))},t=(a,b)=>{r({["blacklist"===b?"removeBlacklist":"removeWhitelist"]:a})},u=a.enabled?a.mode:"disabled";return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-red-500/10 text-red-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"security"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:p("ipAccessControl")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:p("ipAccessControlDesc")})]})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2 mb-5",children:m.map(a=>(0,d.jsxs)("button",{onClick:()=>{var b;return b=a.value,void("disabled"===b?r({enabled:!1}):r({enabled:!0,mode:b}))},disabled:c,className:`flex flex-col items-center gap-1.5 p-3 rounded-lg border text-center transition-all ${u===a.value?"border-red-500/50 bg-red-500/5 ring-1 ring-red-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[20px] ${u===a.value?"text-red-400":"text-text-muted"}`,children:a.icon}),(0,d.jsx)("span",{className:`text-xs font-medium ${u===a.value?"text-red-400":"text-text-muted"}`,children:p(a.labelKey)})]},a.value))}),a.enabled&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-end",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(i.Input,{label:p("addIpAddress"),placeholder:p("ipAddressPlaceholder"),value:k,onChange:a=>l(a.target.value),onKeyDown:a=>"Enter"===a.key&&s()})}),(0,d.jsxs)("div",{className:"flex gap-1 pb-[2px]",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"blacklist"===n?"danger":"secondary",onClick:()=>{o("blacklist"),k.trim()&&s()},children:p("block")}),(0,d.jsx)(h.Button,{size:"sm",variant:"whitelist"===n?"primary":"secondary",onClick:()=>{o("whitelist"),k.trim()&&s()},children:p("allow")})]})]}),a.blacklist.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:p("blocked",{count:a.blacklist.length})}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.blacklist.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-red-500/10 text-red-400 border border-red-500/20",children:[a,(0,d.jsx)("button",{onClick:()=>t(a,"blacklist"),className:"hover:text-red-300",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a))})]}),a.whitelist.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:p("allowed",{count:a.whitelist.length})}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.whitelist.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[a,(0,d.jsx)("button",{onClick:()=>t(a,"whitelist"),className:"hover:text-emerald-300",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a))})]}),a.tempBans.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:p("temporaryBans",{count:a.tempBans.length})}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5",children:a.tempBans.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-orange-500/5 border border-orange-500/20 text-sm",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)("span",{className:"font-mono text-xs text-orange-400 shrink-0",children:a.ip}),(0,d.jsxs)("span",{className:"text-xs text-text-muted truncate",children:["— ",a.reason]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted tabular-nums",children:p("minLeft",{min:Math.ceil(a.remainingMs/6e4)})}),(0,d.jsx)("button",{onClick:()=>{let b;return b=a.ip,r({removeBan:b})},className:"text-text-muted hover:text-orange-400",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]},a.ip))})]})]})]})}a.s(["default",()=>l]),c()}catch(a){c(a)}},!1),860500,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(415925),j=b([f]);function k(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!0),j=(0,i.useTranslations)("settings");(0,e.useEffect)(()=>{let a=!1;return async function(){let c=sessionStorage.getItem("omniroute_login_time"),d=Date.now(),e=j("unknown");if(c){let a=d-parseInt(c,10),b=Math.floor(a/36e5),f=Math.floor(a%36e5/6e4);e=b>0?`${b}h ${f}m`:`${f}m`}let g=!1;try{let a=await fetch("/api/auth/status",{method:"GET",cache:"no-store"});if(a.ok){let b=await a.json();g=!0===b.authenticated}}catch{}a||(b({authenticated:g,loginTime:c?new Date(parseInt(c,10)).toLocaleString():null,sessionAge:e,ipAddress:"—",userAgent:navigator.userAgent.split(" ").slice(-2).join(" ")||j("unknown")}),f(!1))}(),()=>{a=!0}},[]);let k=async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),sessionStorage.removeItem("omniroute_login_time"),window.location.href="/"}catch{window.location.href="/"}};return c?(0,d.jsx)(g.Card,{children:(0,d.jsx)("div",{className:"animate-pulse h-32 bg-black/5 dark:bg-white/5 rounded-lg"})}):(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"person"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:j("session")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-3",role:"list","aria-label":j("sessionDetailsAria"),children:[(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("status")}),(0,d.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full ${a?.authenticated?"bg-green-500":"bg-yellow-500"}`,"aria-hidden":"true"}),a?.authenticated?j("authenticated"):j("guest")]})]}),a?.loginTime&&(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("loginTime")}),(0,d.jsx)("span",{className:"font-mono text-xs",children:a.loginTime})]}),(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("sessionAge")}),(0,d.jsx)("span",{className:"font-mono text-xs",children:a?.sessionAge})]}),(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("browser")}),(0,d.jsx)("span",{className:"font-mono text-xs truncate max-w-[200px]",children:a?.userAgent})]})]}),(0,d.jsxs)("div",{className:"flex gap-3 mt-4 pt-4 border-t border-border/50",children:[(0,d.jsx)(h.Button,{variant:"secondary",onClick:()=>{confirm(j("clearLocalDataConfirm"))&&(localStorage.clear(),sessionStorage.clear(),window.location.reload())},children:j("clearLocalData")}),a?.authenticated&&(0,d.jsx)(h.Button,{variant:"danger",onClick:k,children:j("logout")})]})]})}[f]=j.then?(await j)():j,a.s(["default",()=>k]),c()}catch(a){c(a)}},!1),547655,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(489108),j=a.i(709918),k=a.i(662073),l=a.i(130361),m=a.i(860500),n=a.i(415925),o=b([f,k,l,m]);function p(){let[a,b]=(0,e.useState)({requireLogin:!1,hasPassword:!1}),[c,f]=(0,e.useState)(!0),[o,p]=(0,e.useState)({current:"",new:"",confirm:""}),[q,r]=(0,e.useState)({type:"",message:""}),[s,t]=(0,e.useState)(!1),u=(0,n.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let v=async a=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:a})})).ok&&b(b=>({...b,requireLogin:a}))}catch(a){console.error("Failed to update require login:",a)}},w=async(a,c)=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:c})})).ok&&b(b=>({...b,[a]:c}))}catch(b){console.error(`Failed to update ${a}:`,b)}},x=async a=>{if(a.preventDefault(),o.new!==o.confirm)return void r({type:"error",message:u("passwordsNoMatch")});t(!0),r({type:"",message:""});try{let a=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:o.current,newPassword:o.new})}),b=await a.json();a.ok?(r({type:"success",message:u("passwordUpdated")}),p({current:"",new:"",confirm:""})):r({type:"error",message:b.error||u("failedUpdatePassword")})}catch{r({type:"error",message:u("errorOccurred")})}finally{t(!1)}},y=a.blockedProviders||[];return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"shield"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:u("security")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:u("requireLogin")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:u("requireLoginDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!0===a.requireLogin,onChange:()=>v(!a.requireLogin),disabled:c})]}),!0===a.requireLogin&&(0,d.jsxs)("form",{onSubmit:x,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[a.hasPassword&&(0,d.jsx)(i.Input,{label:u("currentPassword"),type:"password",placeholder:u("enterCurrentPassword"),value:o.current,onChange:a=>p({...o,current:a.target.value}),required:!0}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsx)(i.Input,{label:u("newPassword"),type:"password",placeholder:u("enterNewPassword"),value:o.new,onChange:a=>p({...o,new:a.target.value}),required:!0}),(0,d.jsx)(i.Input,{label:u("confirmPassword"),type:"password",placeholder:u("confirmPasswordPlaceholder"),value:o.confirm,onChange:a=>p({...o,confirm:a.target.value}),required:!0})]}),q.message&&(0,d.jsx)("p",{className:`text-sm ${"error"===q.type?"text-red-500":"text-green-500"}`,children:q.message}),(0,d.jsx)("div",{className:"pt-2",children:(0,d.jsx)(h.Button,{type:"submit",variant:"primary",loading:s,children:a.hasPassword?u("updatePassword"):u("setPassword")})})]})]})]}),(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-600 dark:text-amber-400",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"api"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:u("apiEndpointProtection")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:u("requireAuthModels")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:u("requireAuthModelsDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!0===a.requireAuthForModels,onChange:()=>w("requireAuthForModels",!a.requireAuthForModels),disabled:c})]}),(0,d.jsxs)("div",{className:"pt-4 border-t border-border/50",children:[(0,d.jsxs)("div",{className:"mb-3",children:[(0,d.jsx)("p",{className:"font-medium",children:u("blockedProviders")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:u("blockedProvidersDesc")})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:Object.values(k.AI_PROVIDERS).map(b=>{let e=y.includes(b.id);return(0,d.jsxs)("button",{onClick:()=>{var c;let d,e;return c=b.id,e=(d=a.blockedProviders||[]).includes(c)?d.filter(a=>a!==c):[...d,c],void w("blockedProviders",e)},disabled:c,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all border ${e?"bg-red-500/10 border-red-500/30 text-red-600 dark:text-red-400":"bg-black/[0.02] dark:bg-white/[0.02] border-transparent text-text-muted hover:bg-black/[0.05] dark:hover:bg-white/[0.05]"}`,title:e?u("unblockProviderTitle",{provider:b.name}):u("blockProviderTitle",{provider:b.name}),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:{color:e?void 0:b.color},children:e?"block":b.icon}),b.name,e&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-red-500",children:"close"})]},b.id)})}),y.length>0&&(0,d.jsxs)("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),u("providersBlocked",{count:y.length})]})]})]})]}),(0,d.jsx)(m.default,{}),(0,d.jsx)(l.default,{})]})}[f,k,l,m]=o.then?(await o)():o,a.s(["default",()=>p]),c()}catch(a){c(a)}},!1),754828,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(489108),j=a.i(609754),k=a.i(240246),l=a.i(415925),m=b([f]);[f]=m.then?(await m)():m;let o=["#6366f1","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6"];function n(){let[a,b]=(0,e.useState)({}),[c,f]=(0,e.useState)(!0),[m,n]=(0,e.useState)(!1),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),v=(0,k.useNotificationStore)(),w=(0,l.useTranslations)("settings"),x=(0,l.useTranslations)("common"),y=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/fallback/chains");if(a.ok){let c=await a.json();b(c.chains||c||{})}}catch{}finally{f(!1)}},[]);(0,e.useEffect)(()=>{y()},[y]);let z=async()=>{if(!p.trim()||!r.trim())return void v.warning(w("fillModelAndProviders"));let a=r.split(",").map(a=>a.trim()).filter(Boolean).map((a,b)=>({provider:a,priority:b+1,enabled:!0}));if(0===a.length)return void v.warning(w("addAtLeastOneProvider"));u(!0);try{(await fetch("/api/fallback/chains",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:p.trim(),chain:a})})).ok?(v.success(w("chainCreated",{model:p.trim()})),q(""),s(""),n(!1),await y()):v.error(w("failedCreateChain"))}catch{v.error(w("failedCreateChain"))}finally{u(!1)}},A=async a=>{if(confirm(w("deleteChainConfirm",{model:a})))try{(await fetch("/api/fallback/chains",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a})})).ok?(v.success(w("chainDeleted",{model:a})),await y()):v.error(w("failedDeleteChain"))}catch{v.error(w("failedDeleteChain"))}};if(c)return(0,d.jsx)(g.Card,{className:"p-6 mt-6",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted animate-pulse",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"timeline"}),w("loadingFallbackChains")]})});let B=Object.entries(a);return(0,d.jsxs)(g.Card,{className:"mt-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4 p-6 pb-0",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-cyan-500/10 text-cyan-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"timeline"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:w("fallbackChainsTitle")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:w("fallbackChainsDesc")})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"primary",onClick:()=>n(!m),children:m?x("cancel"):w("addChain")})]}),m&&(0,d.jsxs)("div",{className:"mx-6 p-4 rounded-lg border border-border/30 bg-surface/20 mb-4",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-3",children:[(0,d.jsx)(i.Input,{label:w("modelName"),placeholder:w("modelNamePlaceholder"),value:p,onChange:a=>q(a.target.value)}),(0,d.jsx)(i.Input,{label:w("providersCommaSeparated"),placeholder:w("providersCommaSeparatedPlaceholder"),value:r,onChange:a=>s(a.target.value)})]}),(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:z,loading:t,children:w("createChain")})]}),(0,d.jsx)("div",{className:"px-6 pb-6",children:0===B.length?(0,d.jsx)(j.EmptyState,{icon:"timeline",title:w("noFallbackChains"),description:w("noFallbackChainsDesc")}):(0,d.jsx)("div",{className:"flex flex-col gap-2",children:B.map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 rounded-lg border border-border/20 bg-surface/20 hover:bg-surface/40 transition-colors",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,d.jsx)("span",{className:"font-mono text-sm text-text-main truncate max-w-[200px]",children:a}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:(Array.isArray(b)?b:[]).map((a,b)=>(0,d.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:`${o[b%o.length]}20`,color:o[b%o.length],border:`1px solid ${o[b%o.length]}40`},children:[b+1,". ",a.provider]},`${a.provider}-${b}`))})]}),(0,d.jsx)("button",{onClick:()=>A(a),className:"text-text-muted hover:text-red-400 transition-colors ml-2",title:w("deleteChain"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},a))})})]})}a.s(["default",()=>n]),c()}catch(a){c(a)}},!1),72926,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(489108),i=a.i(294023),j=a.i(754828),k=a.i(669805),l=a.i(415925),m=b([f,j]);[f,j]=m.then?(await m)():m;let o=k.ROUTING_STRATEGIES.filter(a=>k.SETTINGS_FALLBACK_STRATEGY_VALUES.includes(a.value)).map(a=>({value:a.value,labelKey:a.labelKey,descKey:a.settingsDescKey,icon:a.icon}));function n(){let[a,b]=(0,e.useState)({fallbackStrategy:"fill-first"}),[c,f]=(0,e.useState)(!0),[k,m]=(0,e.useState)([]),[n,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),s=(0,l.useTranslations)("settings"),t=o.reduce((a,b)=>(a[b.value]=b.descKey,a),{});(0,e.useEffect)(()=>{fetch("/api/settings").then(a=>a.json()).then(a=>{b(a),m(a.wildcardAliases||[]),f(!1)}).catch(()=>f(!1))},[]);let u=async a=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok&&b(b=>({...b,...a}))}catch(a){console.error("Failed to update settings:",a)}},v=async()=>{if(!n.trim()||!q.trim())return;let a=[...k,{pattern:n.trim(),target:q.trim()}];await u({wildcardAliases:a}),m(a),p(""),r("")},w=async a=>{let b=k.filter((b,c)=>c!==a);await u({wildcardAliases:b}),m(b)};return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"route"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("routingStrategy")})]}),(0,d.jsxs)("div",{className:"mb-4 rounded-lg border border-blue-500/20 bg-blue-500/5 p-3",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-blue-700 dark:text-blue-300",children:s("routingAdvancedGuideTitle")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-1",children:s("routingAdvancedGuideHint1")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:s("routingAdvancedGuideHint2")})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-2 mb-4",style:{gridAutoRows:"1fr"},children:o.map(b=>(0,d.jsxs)("button",{onClick:()=>u({fallbackStrategy:b.value}),disabled:c,className:`flex flex-col items-center gap-2 p-4 rounded-lg border text-center transition-all ${a.fallbackStrategy===b.value?"border-blue-500/50 bg-blue-500/5 ring-1 ring-blue-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[24px] ${a.fallbackStrategy===b.value?"text-blue-400":"text-text-muted"}`,children:b.icon}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:`text-sm font-medium ${a.fallbackStrategy===b.value?"text-blue-400":""}`,children:s(b.labelKey)}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:s(b.descKey)})]})]},b.value))}),"round-robin"===a.fallbackStrategy&&(0,d.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-border/30",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:s("stickyLimit")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:s("stickyLimitDesc")})]}),(0,d.jsx)(h.Input,{type:"number",min:"1",max:"10",value:a.stickyRoundRobinLimit||3,onChange:a=>u({stickyRoundRobinLimit:parseInt(a.target.value)}),disabled:c,className:"w-20 text-center"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted italic pt-3 border-t border-border/30 mt-3",children:s(t[a.fallbackStrategy]||"fillFirstDesc")})]}),(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"alt_route"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("modelAliases")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:s("modelAliasesDesc")})]})]}),k.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-1.5 mb-4",children:k.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,d.jsx)("span",{className:"font-mono text-purple-400 break-all",children:a.pattern}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("span",{className:"font-mono text-text-main break-all",children:a.target})]}),(0,d.jsx)("button",{onClick:()=>w(b),className:"shrink-0 text-text-muted hover:text-red-400 transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},b))}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-end",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(h.Input,{label:s("pattern"),placeholder:s("aliasPatternPlaceholder"),value:n,onChange:a=>p(a.target.value)})}),(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(h.Input,{label:s("targetModel"),placeholder:s("aliasTargetPlaceholder"),value:q,onChange:a=>r(a.target.value)})}),(0,d.jsx)(i.Button,{size:"sm",variant:"primary",onClick:v,className:"mb-[2px] sm:w-auto w-full",children:s("add")})]})]}),(0,d.jsx)(j.default,{})]})}a.s(["default",()=>n]),c()}catch(a){c(a)}},!1),589980,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(489108),j=a.i(709918),k=a.i(171302),l=a.i(669805),m=a.i(415925),n=b([f]);function o(){let[a,b]=(0,e.useState)({strategy:"priority",maxRetries:1,retryDelayMs:2e3,timeoutMs:12e4,healthCheckEnabled:!0,healthCheckTimeoutMs:3e3,maxComboDepth:3,trackMetrics:!0}),[c,f]=(0,e.useState)({}),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(!1),r=(0,m.useTranslations)("settings"),s=(0,m.useTranslations)("common"),t=l.ROUTING_STRATEGIES.map(a=>({value:a.value,label:r(a.labelKey),icon:a.icon})),u=[{key:"maxRetries",label:r("maxRetriesLabel"),min:0,max:5},{key:"retryDelayMs",label:r("retryDelayLabel"),min:500,max:1e4,step:500},{key:"timeoutMs",label:r("timeoutLabel"),min:5e3,max:3e5,step:5e3},{key:"maxComboDepth",label:r("maxNestingDepth"),min:1,max:10}];(0,e.useEffect)(()=>{fetch("/api/settings/combo-defaults").then(a=>a.json()).then(a=>{a.comboDefaults&&b(a.comboDefaults),a.providerOverrides&&f(a.providerOverrides)}).catch(a=>console.error("Failed to fetch combo defaults:",a))},[]);let v=async()=>{q(!0);try{await fetch("/api/settings/combo-defaults",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboDefaults:a,providerOverrides:c})})}catch(a){console.error("Failed to save combo defaults:",a)}finally{q(!1)}},w=()=>{let a=n.trim().toLowerCase();a&&!c[a]&&(f(b=>({...b,[a]:{maxRetries:1,timeoutMs:12e4}})),o(""))};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"tune"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:r("comboDefaultsTitle")}),(0,d.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:r("globalComboConfig")})]}),(0,d.jsxs)("div",{className:"mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 p-3",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:r("comboDefaultsGuideTitle")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-1",children:r("comboDefaultsGuideHint1")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("comboDefaultsGuideHint2")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium text-sm",children:r("defaultStrategy")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("defaultStrategyDesc")})]}),(0,d.jsx)("div",{role:"tablist","aria-label":r("comboStrategyAria"),className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-1 p-0.5 rounded-md bg-black/5 dark:bg-white/5",children:t.map(c=>(0,d.jsxs)("button",{role:"tab","aria-selected":a.strategy===c.value,onClick:()=>b(a=>({...a,strategy:c.value})),className:(0,k.cn)("px-2 py-1 rounded text-xs font-medium transition-all flex items-center justify-center gap-0.5",a.strategy===c.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:c.icon}),c.label]},c.value))})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:u.map(({key:c,label:e,min:f,max:g,step:h})=>(0,d.jsx)(i.Input,{label:e,type:"number",min:f,max:g,step:h||1,value:a[c]??"",onChange:a=>b(b=>({...b,[c]:parseInt(a.target.value)||0})),className:"text-sm"},c))}),"round-robin"===a.strategy&&(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:[(0,d.jsx)(i.Input,{label:r("concurrencyPerModel"),type:"number",min:1,max:20,value:a.concurrencyPerModel??"",placeholder:"3",onChange:a=>b(b=>({...b,concurrencyPerModel:parseInt(a.target.value)||0})),className:"text-sm"}),(0,d.jsx)(i.Input,{label:r("queueTimeout"),type:"number",min:1e3,max:12e4,step:1e3,value:a.queueTimeoutMs??"",placeholder:"30000",onChange:a=>b(b=>({...b,queueTimeoutMs:parseInt(a.target.value)||0})),className:"text-sm"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-3 pt-3 border-t border-border/50",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium text-sm",children:r("healthCheck")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("healthCheckDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!1!==a.healthCheckEnabled,onChange:()=>b(a=>({...a,healthCheckEnabled:!a.healthCheckEnabled}))})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium text-sm",children:r("trackMetrics")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("trackMetricsDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!1!==a.trackMetrics,onChange:()=>b(a=>({...a,trackMetrics:!a.trackMetrics}))})]})]}),(0,d.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,d.jsx)("p",{className:"font-medium text-sm mb-2",children:r("providerOverrides")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-3",children:r("providerOverridesDesc")}),Object.entries(c).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-2 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,d.jsx)("span",{className:"text-xs font-mono font-medium min-w-[80px]",children:a}),(0,d.jsx)(i.Input,{type:"number",min:"0",max:"5",value:b.maxRetries??1,onChange:b=>f(c=>({...c,[a]:{...c[a],maxRetries:parseInt(b.target.value)||0}})),className:"text-xs w-16","aria-label":r("providerMaxRetriesAria",{provider:a})}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:r("retries")}),(0,d.jsx)(i.Input,{type:"number",min:"5000",max:"300000",step:"5000",value:b.timeoutMs??12e4,onChange:b=>f(c=>({...c,[a]:{...c[a],timeoutMs:parseInt(b.target.value)||12e4}})),className:"text-xs w-24","aria-label":r("providerTimeoutAria",{provider:a})}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:r("ms")}),(0,d.jsx)("button",{onClick:()=>{f(b=>{let c={...b};return delete c[a],c})},className:"ml-auto text-red-400 hover:text-red-500 transition-colors","aria-label":r("removeProviderOverrideAria",{provider:a}),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})})]},a)),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,d.jsx)(i.Input,{type:"text",placeholder:r("newProviderNamePlaceholder"),value:n,onChange:a=>o(a.target.value),onKeyDown:a=>"Enter"===a.key&&w(),className:"text-xs flex-1","aria-label":r("newProviderNameAria")}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:w,disabled:!n.trim(),children:s("add")})]})]}),(0,d.jsx)("div",{className:"pt-3 border-t border-border/50",children:(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:v,loading:p,children:r("saveComboDefaults")})})]})]})}[f]=n.then?(await n)():n,a.s(["default",()=>o]),c()}catch(a){c(a)}},!1),928050,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(294023),h=a.i(292216),i=a.i(563203),j=b([f]);[f]=j.then?(await j)():j;let l={id:"",name:"",type:"http",host:"",port:"8080",username:"",password:"",region:"",notes:"",status:"active"};function k(){let[a,b]=(0,e.useState)([]),[c,f]=(0,e.useState)(!1),[j,k]=(0,e.useState)(null),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(l),[s,t]=(0,e.useState)({}),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)("provider"),[I,J]=(0,e.useState)(""),[K,L]=(0,e.useState)(""),M=(0,e.useMemo)(()=>q.id||"",[q.id]),N=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/settings/proxies/health?hours=24"),b=await a.json().catch(()=>({}));if(!a.ok)return;let c=Array.isArray(b?.items)?b.items:[],d=Object.fromEntries(c.map(a=>[a.proxyId,a]));v(d)}catch{}},[]),O=(0,e.useCallback)(async a=>{if(a.length)try{let b=await Promise.all(a.map(a=>fetch(`/api/settings/proxies/assignments?proxyId=${encodeURIComponent(a)}`).then(a=>a.ok?a.json():null).then(b=>{let c=Array.isArray(b?.items)?b.items:[],d=new Set,e=c.filter(a=>{let b=`${a.scope}:${a.scopeId??""}`;return!d.has(b)&&(d.add(b),!0)});return[a,{count:e.length,assignments:e}]}).catch(()=>[a,{count:0,assignments:[]}])));t(Object.fromEntries(b))}catch{}},[]),P=(0,e.useCallback)(async()=>{f(!0),k(null);try{let a=await fetch("/api/settings/proxies"),c=await a.json().catch(()=>({}));if(!a.ok){k(c?.error?.message||"Failed to load proxy registry"),b([]);return}let d=Array.isArray(c?.items)?c.items:[];b(d);let e=d.map(a=>a.id).filter(Boolean);N(),O(e)}catch(a){k(a?.message||"Failed to load proxy registry"),b([])}finally{f(!1)}},[N,O]);(0,e.useEffect)(()=>{P()},[P]),(0,e.useEffect)(()=>{a.length>0&&!K&&L(a[0].id)},[a,K]);let Q=async a=>{if(!y){z(a.id),x(b=>({...b,[a.id]:null}));try{let b=await fetch("/api/settings/proxy/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxy:{type:a.type||"http",host:a.host,port:String(a.port||8080),username:a.username,password:a.password}})}),c=await b.json().catch(()=>({}));if(!b.ok)return void x(b=>({...b,[a.id]:{success:!1,error:c?.error?.message||"Test failed"}}));x(b=>({...b,[a.id]:{success:!0,...c}}))}catch(b){x(c=>({...c,[a.id]:{success:!1,error:b?.message}}))}finally{z(null)}}},R=async()=>{if(!q.name.trim()||!q.host.trim())return void k("Name and host are required");p(!0),k(null);let a=q.username.trim(),b=q.password.trim(),c={...M?{id:M}:{},name:q.name.trim(),type:q.type,host:q.host.trim(),port:Number(q.port||8080),region:q.region.trim()||null,notes:q.notes.trim()||null,status:q.status};(!M||a.length>0)&&(c.username=a),(!M||b.length>0)&&(c.password=b);try{let a=await fetch("/api/settings/proxies",{method:M?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),b=await a.json().catch(()=>({}));if(!a.ok)return void k(b?.error?.message||"Failed to save proxy");n(!1),r(l),await P()}catch(a){k(a?.message||"Failed to save proxy")}finally{p(!1)}},S=async a=>{try{let b=await fetch(`/api/settings/proxies?id=${encodeURIComponent(a)}`,{method:"DELETE"});if(b.ok)return void await P();let c=await b.json().catch(()=>({}));if(409===b.status){if(!window.confirm("This proxy is still assigned. Force delete and remove all assignments?"))return;let b=await fetch(`/api/settings/proxies?id=${encodeURIComponent(a)}&force=1`,{method:"DELETE"});if(!b.ok){let a=await b.json().catch(()=>({}));k(a?.error?.message||"Failed to force delete proxy");return}await P();return}k(c?.error?.message||"Failed to delete proxy")}catch(a){k(a?.message||"Failed to delete proxy")}},T=async()=>{B(!0),k(null);try{let a=await fetch("/api/settings/proxies/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:!1})}),b=await a.json().catch(()=>({}));if(!a.ok)return void k(b?.error?.message||"Failed to migrate legacy proxy config");await P()}catch(a){k(a?.message||"Failed to migrate legacy proxy config")}finally{B(!1)}},U=async()=>{F(!0),k(null);try{let a="global"===G?[]:I.split(/[\n,]/g).map(a=>a.trim()).filter(Boolean),b=await fetch("/api/settings/proxies/bulk-assign",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:G,scopeIds:a,proxyId:K||null})}),c=await b.json().catch(()=>({}));if(!b.ok)return void k(c?.error?.message||"Failed to run bulk assignment");D(!1),J(""),await P()}catch(a){k(a?.message||"Failed to run bulk assignment")}finally{F(!1)}};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(h.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:"Proxy Registry"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Store reusable proxies and track assignments."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",icon:"upgrade",onClick:T,loading:A,"data-testid":"proxy-registry-import-legacy",children:"Import Legacy"}),(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",icon:"account_tree",onClick:()=>D(!0),"data-testid":"proxy-registry-open-bulk",children:"Bulk Assign"}),(0,d.jsx)(g.Button,{size:"sm",icon:"add",onClick:()=>{r(l),n(!0)},"data-testid":"proxy-registry-open-create",children:"Add Proxy"})]})]}),j&&(0,d.jsx)("div",{className:"mb-3 px-3 py-2 rounded border border-red-500/30 bg-red-500/10 text-sm text-red-400",children:j}),c?(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"Loading proxies..."}):0===a.length?(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"No saved proxies yet."}):(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"text-left text-text-muted border-b border-border",children:[(0,d.jsx)("th",{className:"py-2 pr-3",children:"Name"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Endpoint"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Status"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Health (24h)"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Usage"}),(0,d.jsx)("th",{className:"py-2",children:"Actions"})]})}),(0,d.jsx)("tbody",{children:a.map(a=>{s[a.id];let b=u[a.id];return(0,d.jsxs)("tr",{className:"border-b border-border/60",children:[(0,d.jsxs)("td",{className:"py-2 pr-3",children:[(0,d.jsx)("div",{className:"font-medium text-text-main",children:a.name}),a.region&&(0,d.jsx)("div",{className:"text-xs text-text-muted",children:a.region})]}),(0,d.jsxs)("td",{className:"py-2 pr-3 font-mono text-xs text-text-muted",children:[a.type,"://",a.host,":",a.port]}),(0,d.jsx)("td",{className:"py-2 pr-3",children:(0,d.jsx)("span",{className:"text-xs px-2 py-1 rounded border border-border bg-bg-subtle",children:a.status||"active"})}),(0,d.jsx)("td",{className:"py-2 pr-3 text-xs text-text-muted",children:(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:w[a.id]?w[a.id].success?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-emerald-400",children:["✓ ",w[a.id].publicIp]}),w[a.id].latencyMs&&(0,d.jsxs)("span",{children:[w[a.id].latencyMs,"ms"]})]}):(0,d.jsxs)("span",{className:"text-red-400",children:["✗ ",w[a.id].error||"failed"]}):b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:[b.successRate??0,"% success"]}),(0,d.jsxs)("span",{children:[b.avgLatencyMs??"-"," ms avg"]})]}):(0,d.jsx)("span",{children:"—"})})}),(0,d.jsx)("td",{className:"py-2 pr-3 text-xs text-text-muted",children:null!=s[a.id]?`${s[a.id].count} assignment(s)`:"—"}),(0,d.jsx)("td",{className:"py-2",children:(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"ghost",icon:"speed",onClick:()=>void Q(a),loading:y===a.id,children:"Test"}),(0,d.jsx)(g.Button,{size:"sm",variant:"ghost",icon:"edit",onClick:()=>{r({id:a.id,name:a.name||"",type:a.type||"http",host:a.host||"",port:String(a.port||8080),username:"",password:"",region:a.region||"",notes:a.notes||"",status:a.status||"active"}),n(!0)},children:"Edit"}),(0,d.jsx)(g.Button,{size:"sm",variant:"ghost",icon:"delete",onClick:()=>void S(a.id),className:"!text-red-400",children:"Delete"})]})})]},a.id)})})]})})]}),(0,d.jsx)(i.Modal,{isOpen:m,onClose:()=>{o||n(!1)},title:M?"Edit Proxy":"Create Proxy",maxWidth:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,d.jsx)("input",{"data-testid":"proxy-registry-name-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.name,onChange:a=>r(b=>({...b,name:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Type"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.type,onChange:a=>r(b=>({...b,type:a.target.value})),children:[(0,d.jsx)("option",{value:"http",children:"HTTP"}),(0,d.jsx)("option",{value:"https",children:"HTTPS"}),(0,d.jsx)("option",{value:"socks5",children:"SOCKS5"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Host"}),(0,d.jsx)("input",{"data-testid":"proxy-registry-host-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.host,onChange:a=>r(b=>({...b,host:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Port"}),(0,d.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.port,onChange:a=>r(b=>({...b,port:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Username"}),(0,d.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.username,placeholder:M?"Leave blank to keep current username":"",onChange:a=>r(b=>({...b,username:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Password"}),(0,d.jsx)("input",{type:"password",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.password,placeholder:M?"Leave blank to keep current password":"",onChange:a=>r(b=>({...b,password:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Region"}),(0,d.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.region,onChange:a=>r(b=>({...b,region:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Status"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.status,onChange:a=>r(b=>({...b,status:a.target.value})),children:[(0,d.jsx)("option",{value:"active",children:"active"}),(0,d.jsx)("option",{value:"inactive",children:"inactive"})]})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Notes"}),(0,d.jsx)("textarea",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.notes,onChange:a=>r(b=>({...b,notes:a.target.value})),rows:3})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",onClick:()=>n(!1),children:"Cancel"}),(0,d.jsx)(g.Button,{size:"sm",icon:"save",onClick:R,loading:o,children:"Save"})]})]})}),(0,d.jsx)(i.Modal,{isOpen:C,onClose:()=>{E||D(!1)},title:"Bulk Proxy Assignment",maxWidth:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Scope"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:G,onChange:a=>H(a.target.value),children:[(0,d.jsx)("option",{value:"global",children:"global"}),(0,d.jsx)("option",{value:"provider",children:"provider"}),(0,d.jsx)("option",{value:"account",children:"account"}),(0,d.jsx)("option",{value:"combo",children:"combo"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Proxy"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:K,onChange:a=>L(a.target.value),children:[(0,d.jsx)("option",{value:"",children:"(clear assignment)"}),a.map(a=>(0,d.jsxs)("option",{value:a.id,children:[a.name," (",a.type,"://",a.host,":",a.port,")"]},a.id))]})]})]}),"global"!==G&&(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Scope IDs (comma or newline)"}),(0,d.jsx)("textarea",{"data-testid":"proxy-registry-bulk-scopeids-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",rows:5,value:I,onChange:a=>J(a.target.value),placeholder:"provider-openai,provider-anthropic"})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",onClick:()=>D(!1),children:"Cancel"}),(0,d.jsx)(g.Button,{size:"sm",icon:"done_all",onClick:U,loading:E,"data-testid":"proxy-registry-bulk-apply",children:"Apply"})]})]})})]})}a.s(["default",()=>k]),c()}catch(a){c(a)}},!1),232327,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(248172),j=a.i(415925),k=a.i(928050),l=b([f,k]);function m(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(null),l=(0,e.useRef)(!0),m=(0,j.useTranslations)("settings"),n=(0,j.useTranslations)("common"),o=async()=>{try{let a=await fetch("/api/settings/proxy?level=global");if(a.ok){let b=await a.json();f(b.proxy||null)}}catch{}};return(0,e.useEffect)(()=>(l.current=!0,async function(){try{let a=await fetch("/api/settings/proxy?level=global");if(!l.current)return;if(a.ok){let b=await a.json();l.current&&f(b.proxy||null)}}catch{}}(),()=>{l.current=!1}),[]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"vpn_lock"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:m("globalProxy")})]}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:m("globalProxyDesc")}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[c?(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsxs)("span",{className:"px-2.5 py-1 rounded text-xs font-bold uppercase bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:[c.type,"://",c.host,":",c.port]})}):(0,d.jsx)("span",{className:"text-sm text-text-muted",children:m("noGlobalProxy")}),(0,d.jsx)(h.Button,{size:"sm",variant:c?"secondary":"primary",icon:"settings",onClick:()=>{o(),b(!0)},children:c?n("edit"):m("configure")})]})]})}),(0,d.jsx)(k.default,{})]}),(0,d.jsx)(i.ProxyConfigModal,{isOpen:a,onClose:()=>b(!1),level:"global",levelLabel:m("globalLabel"),onSaved:o})]})}[f,k]=l.then?(await l)():l,a.s(["default",()=>m]),c()}catch(a){c(a)}},!1),220584,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(294023),h=a.i(292216),i=a.i(709918),j=a.i(893711),k=a.i(788164),l=a.i(171302),m=a.i(415925),n=b([f,j,k]);function o(){let{theme:a,setTheme:b,isDark:c}=(0,j.useTheme)(),{colorTheme:f,customColor:n,setColorTheme:o,setCustomColorTheme:p}=(0,k.default)(),q=(0,m.useTranslations)("settings"),[r,s]=(0,e.useState)({}),[t,u]=(0,e.useState)(!0),[v,w]=(0,e.useState)(n||"#3b82f6"),x=/^#([0-9a-fA-F]{6})$/.test(v.startsWith("#")?v:`#${v}`);(0,e.useEffect)(()=>k.default.subscribe(a=>{a.customColor&&a.customColor!==v&&w(a.customColor)}),[]);let y={light:q("themeLight"),dark:q("themeDark"),system:q("themeSystem")};(0,e.useEffect)(()=>{fetch("/api/settings").then(a=>{if(!a.ok)throw Error(`HTTP error ${a.status}`);return a.json()}).then(a=>{s(a),u(!1)}).catch(()=>u(!1))},[]);let z=async(a,b)=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})})).ok&&s(c=>({...c,[a]:b}))}catch(b){console.error(`Failed to update ${a}:`,b)}},A=[{id:"coral",color:k.COLOR_THEMES.coral,label:q("themeCoral")},{id:"blue",color:k.COLOR_THEMES.blue,label:q("themeBlue")},{id:"red",color:k.COLOR_THEMES.red,label:q("themeRed")},{id:"green",color:k.COLOR_THEMES.green,label:q("themeGreen")},{id:"violet",color:k.COLOR_THEMES.violet,label:q("themeViolet")},{id:"orange",color:k.COLOR_THEMES.orange,label:q("themeOrange")},{id:"cyan",color:k.COLOR_THEMES.cyan,label:q("themeCyan")}];return(0,d.jsxs)(h.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"palette"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:q("appearance")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:q("darkMode")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:q("switchThemes")})]}),(0,d.jsx)(i.Toggle,{checked:c,onChange:()=>b(c?"light":"dark")})]}),(0,d.jsx)("div",{className:"pt-4 border-t border-border",children:(0,d.jsx)("div",{role:"tablist","aria-label":q("themeSelectionAria"),className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5",children:["light","dark","system"].map(c=>(0,d.jsxs)("button",{role:"tab","aria-selected":a===c,onClick:()=>b(c),className:(0,l.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all",a===c?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"light"===c?"light_mode":"dark"===c?"dark_mode":"contrast"}),(0,d.jsx)("span",{children:y[c]||c})]},c))})}),(0,d.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,d.jsx)("p",{className:"font-medium mb-1",children:q("themeAccent")}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-3",children:q("themeAccentDesc")}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mb-3",children:A.map(a=>{let b=f===a.id;return(0,d.jsx)("button",{onClick:()=>o(a.id),className:(0,l.cn)("flex items-center justify-between gap-2 p-2 rounded-lg border transition-colors",b?"border-primary bg-primary/10 text-primary":"border-border hover:bg-surface/50 text-text-main"),children:(0,d.jsxs)("span",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"size-4 rounded-full border border-black/10 dark:border-white/20",style:{backgroundColor:a.color}}),(0,d.jsx)("span",{className:"text-sm font-medium",children:a.label})]})},a.id)})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"color",value:v,onChange:a=>w(a.target.value),className:"h-10 w-12 rounded border border-border bg-surface cursor-pointer","aria-label":q("themeCustom")}),(0,d.jsx)("input",{type:"text",value:v,onChange:a=>w(a.target.value),placeholder:"#3b82f6",maxLength:7,className:`flex-1 h-10 px-3 rounded-lg bg-surface border text-sm text-text-main focus:outline-none ${x?"border-border focus:border-primary":"border-red-400 focus:border-red-500"}`}),(0,d.jsx)(g.Button,{onClick:()=>p(v),disabled:!x,children:q("themeCreate")})]})]}),(0,d.jsx)("div",{className:"pt-4 border-t border-border",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:q("hideHealthLogs")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:q("hideHealthLogsDesc")})]}),(0,d.jsx)(i.Toggle,{checked:!0===r.hideHealthCheckLogs,onChange:()=>z("hideHealthCheckLogs",!r.hideHealthCheckLogs),disabled:t})]})})]})]})}[f,j,k]=n.then?(await n)():n,a.s(["default",()=>o]),c()}catch(a){c(a)}},!1),413316,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 k=[{value:"passthrough",labelKey:"passthrough",descKey:"passthroughDesc",icon:"arrow_forward"},{value:"auto",labelKey:"auto",descKey:"autoDesc",icon:"auto_awesome"},{value:"custom",labelKey:"custom",descKey:"customDesc",icon:"tune"},{value:"adaptive",labelKey:"adaptive",descKey:"adaptiveDesc",icon:"trending_up"}],l=[{value:"none",labelKey:"effortNone"},{value:"low",labelKey:"effortLow"},{value:"medium",labelKey:"effortMedium"},{value:"high",labelKey:"effortHigh"}];function j(){let[a,b]=(0,e.useState)({mode:"passthrough",customBudget:10240,effortLevel:"medium"}),[c,f]=(0,e.useState)(!0),[i,j]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/thinking-budget").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let p=async c=>{let d={...a,...c};b(d),j(!0),n("");try{(await fetch("/api/settings/thinking-budget",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).ok?(n("saved"),setTimeout(()=>n(""),2e3)):n("error")}catch{n("error")}finally{j(!1)}};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-violet-500/10 text-violet-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"psychology"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:o("thinkingBudgetTitle")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:o("thinkingBudgetDesc")})]}),"saved"===m&&(0,d.jsxs)("span",{className:"ml-auto text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",o("saved")]})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-2 mb-5",children:k.map(b=>(0,d.jsxs)("button",{onClick:()=>p({mode:b.value}),disabled:c||i,className:`flex items-start gap-3 p-3 rounded-lg border text-left transition-all ${a.mode===b.value?"border-violet-500/50 bg-violet-500/5 ring-1 ring-violet-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[20px] mt-0.5 ${a.mode===b.value?"text-violet-500":"text-text-muted"}`,children:b.icon}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:`text-sm font-medium ${a.mode===b.value?"text-violet-400":""}`,children:o(b.labelKey)}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5 leading-relaxed",children:o(b.descKey)})]})]},b.value))}),"custom"===a.mode&&(0,d.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:o("tokenBudget")}),(0,d.jsxs)("span",{className:"text-sm font-mono tabular-nums text-violet-400",children:[a.customBudget.toLocaleString()," ",o("tokens")]})]}),(0,d.jsx)("input",{type:"range",min:"0",max:"131072",step:"1024",value:a.customBudget,onChange:a=>p({customBudget:parseInt(a.target.value)}),className:"w-full accent-violet-500"}),(0,d.jsxs)("div",{className:"flex justify-between text-xs text-text-muted mt-1",children:[(0,d.jsx)("span",{children:o("off")}),(0,d.jsx)("span",{children:"1K"}),(0,d.jsx)("span",{children:"10K"}),(0,d.jsx)("span",{children:"64K"}),(0,d.jsx)("span",{children:"128K"})]})]}),"adaptive"===a.mode&&(0,d.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-3",children:o("baseEffortLevel")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-3",children:o("adaptiveHint")}),(0,d.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:l.map(b=>(0,d.jsx)("button",{onClick:()=>p({effortLevel:b.value}),disabled:c||i,className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${a.effortLevel===b.value?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border/50 text-text-muted hover:border-border"}`,children:o(b.labelKey)},b.value))})]})]})}a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),769979,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=b([f]);function i(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(!0),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)("");(0,e.useEffect)(()=>{fetch("/api/settings/codex-service-tier").then(a=>a.json()).then(a=>{b(!!a.enabled),f(!1)}).catch(()=>f(!1))},[]);let l=async a=>{b(a),i(!0),k("");try{(await fetch("/api/settings/codex-service-tier",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})})).ok?(k("saved"),setTimeout(()=>k(""),2e3)):(k("error"),b(!a))}catch{k("error"),b(!a)}finally{i(!1)}};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-sky-500/10 text-sky-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"bolt"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:"Codex Fast Service Tier"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Inject `service_tier=fast` into Codex requests when the client leaves it unset."})]}),"saved"===j&&(0,d.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),"Saved"]}),"error"===j&&(0,d.jsxs)("span",{className:"text-xs font-medium text-rose-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),"Failed to save"]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg bg-surface/30 border border-border/30",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"Force fast tier for Codex"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Off by default. Applies only to Codex requests and does not override an explicit tier."})]}),(0,d.jsx)("button",{onClick:()=>l(!a),disabled:c||h,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-sky-500":"bg-white/10"}`,children:(0,d.jsx)("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]})]})}[f]=h.then?(await h)():h,a.s(["default",()=>i]),c()}catch(a){c(a)}},!1),847910,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(709918),i=a.i(415925),j=b([f]);function k(){let[a,b]=(0,e.useState)({enabled:!1,prompt:""}),[c,f]=(0,e.useState)(!0),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)(null),n=(0,i.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/system-prompt").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let o=async c=>{let d={...a,...c};b(d),k("");try{(await fetch("/api/settings/system-prompt",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).ok&&(k("saved"),setTimeout(()=>k(""),2e3))}catch{k("error")}};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"edit_note"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:n("globalSystemPrompt")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:n("systemPromptDesc")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:["saved"===j&&(0,d.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",n("saved")]}),(0,d.jsx)(h.Toggle,{checked:a.enabled,onChange:()=>o({enabled:!a.enabled}),disabled:c})]})]}),a.enabled&&(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("textarea",{value:a.prompt,onChange:a=>{var c;return c=a.target.value,void(b(a=>({...a,prompt:c})),l&&clearTimeout(l),m(setTimeout(()=>{o({prompt:c})},800)))},placeholder:n("systemPromptPlaceholder"),rows:5,className:"w-full px-4 py-3 rounded-lg border border-border/50 bg-surface/30 text-sm placeholder:text-text-muted/50 resize-y min-h-[120px] focus:outline-none focus:ring-1 focus:ring-amber-500/30 focus:border-amber-500/50 transition-colors",disabled:c}),(0,d.jsx)("div",{className:"absolute bottom-2 right-3 text-xs text-text-muted/60 tabular-nums",children:n("chars",{count:a.prompt.length})})]}),(0,d.jsxs)("p",{className:"text-xs text-text-muted/70 flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"}),n("systemPromptHint")]})]})]})}[f]=j.then?(await j)():j,a.s(["default",()=>k]),c()}catch(a){c(a)}},!1),876881,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]);function j(){let[a,b]=(0,e.useState)({}),[c,f]=(0,e.useState)({}),[i,j]=(0,e.useState)(!0),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),s=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/model-aliases").then(a=>a.json()).then(a=>{b(a.builtIn||{}),f(a.custom||{}),j(!1)}).catch(()=>j(!1))},[]);let t=async()=>{if(o.trim()&&q.trim()){l(!0);try{let a=await fetch("/api/settings/model-aliases",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:o.trim(),to:q.trim()})});if(a.ok){let b=await a.json();f(b.custom),p(""),r(""),n("saved"),setTimeout(()=>n(""),2e3)}}catch{n("error")}finally{l(!1)}}},u=async a=>{l(!0);try{let b=await fetch("/api/settings/model-aliases",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a})});if(b.ok){let a=await b.json();f(a.custom),n("saved"),setTimeout(()=>n(""),2e3)}}catch{n("error")}finally{l(!1)}},v=Object.entries(a),w=Object.entries(c);return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"swap_horiz"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("modelAliasesTitle")||"Model Aliases"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:s("modelAliasesDesc")||"Auto-forward deprecated model IDs to their replacements"})]}),"saved"===m&&(0,d.jsxs)("span",{className:"ml-auto text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",s("saved")||"Saved"]})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-3",children:s("addCustomAlias")||"Add Custom Alias"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",placeholder:s("deprecatedModelId")||"Deprecated model ID",value:o,onChange:a=>p(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-amber-500/50 focus:outline-none"}),(0,d.jsx)("span",{className:"text-text-muted text-lg",children:"→"}),(0,d.jsx)("input",{type:"text",placeholder:s("newModelId")||"New model ID",value:q,onChange:a=>r(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-amber-500/50 focus:outline-none"}),(0,d.jsx)("button",{onClick:t,disabled:k||!o.trim()||!q.trim(),className:"px-4 py-2 rounded-lg text-sm font-medium bg-amber-500/10 text-amber-500 hover:bg-amber-500/20 disabled:opacity-50 transition-all",children:s("add")||"Add"})]})]}),w.length>0&&(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-muted uppercase tracking-wider mb-2",children:s("customAliases")||"Custom Aliases"}),(0,d.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20",children:w.map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,d.jsx)("code",{className:"text-xs text-red-400/80 flex-1 truncate",children:a}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("code",{className:"text-xs text-emerald-400/80 flex-1 truncate",children:b}),(0,d.jsx)("button",{onClick:()=>u(a),disabled:k,className:"p-1 rounded hover:bg-red-500/10 text-text-muted hover:text-red-400 transition-all",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},a))})]}),(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"text-xs font-medium text-text-muted uppercase tracking-wider cursor-pointer flex items-center gap-1 mb-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] group-open:rotate-90 transition-transform",children:"chevron_right"}),s("builtInAliases")||"Built-in Aliases"," (",v.length,")"]}),(0,d.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20 max-h-60 overflow-y-auto",children:v.map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 opacity-60",children:[(0,d.jsx)("code",{className:"text-xs text-red-400/60 flex-1 truncate",children:a}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("code",{className:"text-xs text-emerald-400/60 flex-1 truncate",children:b}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"lock"})]},a))})]})]})}[f]=i.then?(await i)():i,a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),356962,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]);function j(){let[a,b]=(0,e.useState)({enabled:!1,degradationMap:{},detectionPatterns:[],stats:{detected:0,tokensSaved:0}}),[c,f]=(0,e.useState)(!0),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),s=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/background-degradation").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let t=async c=>{let d={...a,...c};b(d),j(!0),l("");try{let{stats:a,...c}=d,e=await fetch("/api/settings/background-degradation",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(e.ok){let a=await e.json();b(a),l("saved"),setTimeout(()=>l(""),2e3)}else l("error")}catch{l("error")}finally{j(!1)}},u=Object.entries(a.degradationMap||{});return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-sky-500/10 text-sky-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"speed"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("backgroundDegradationTitle")||"Background Task Degradation"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:s("backgroundDegradationDesc")||"Auto-redirect background requests (titles, summaries) to cheaper models"})]}),"saved"===k&&(0,d.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",s("saved")||"Saved"]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:s("enableDegradation")||"Enable Background Degradation"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:s("enableDegradationHint")||"Automatically use cheaper models for background utility tasks"})]}),(0,d.jsx)("button",{onClick:()=>t({enabled:!a.enabled}),disabled:c||i,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a.enabled?"bg-sky-500":"bg-white/10"}`,children:(0,d.jsx)("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${a.enabled?"translate-x-6":"translate-x-1"}`})})]}),a.stats&&a.stats.detected>0&&(0,d.jsx)("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-sky-500/5 border border-sky-500/20 mb-4",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-sky-400",children:"analytics"}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:[s("tasksDetected")||"Tasks detected",":"]}),(0,d.jsx)("span",{className:"text-sm font-mono font-semibold text-sky-400",children:a.stats.detected})]})}),a.enabled&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-muted uppercase tracking-wider mb-2",children:s("degradationMap")||"Model Degradation Map"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,d.jsx)("input",{type:"text",placeholder:s("premiumModel")||"Premium model",value:m,onChange:a=>n(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,d.jsx)("span",{className:"text-text-muted text-lg",children:"→"}),(0,d.jsx)("input",{type:"text",placeholder:s("cheapModel")||"Cheap model",value:o,onChange:a=>p(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,d.jsx)("button",{onClick:()=>{if(!m.trim()||!o.trim())return;let b={...a.degradationMap,[m.trim()]:o.trim()};t({degradationMap:b}),n(""),p("")},disabled:i||!m.trim()||!o.trim(),className:"px-3 py-2 rounded-lg text-sm font-medium bg-sky-500/10 text-sky-500 hover:bg-sky-500/20 disabled:opacity-50 transition-all",children:s("add")||"Add"})]}),u.length>0&&(0,d.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20 max-h-48 overflow-y-auto",children:u.map(([b,c])=>(0,d.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2",children:[(0,d.jsx)("code",{className:"text-xs text-orange-400/80 flex-1 truncate",children:b}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("code",{className:"text-xs text-sky-400/80 flex-1 truncate",children:c}),(0,d.jsx)("button",{onClick:()=>{let c;return c={...a.degradationMap},void(delete c[b],t({degradationMap:c}))},disabled:i,className:"p-1 rounded hover:bg-red-500/10 text-text-muted hover:text-red-400 transition-all",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},b))})]}),(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"text-xs font-medium text-text-muted uppercase tracking-wider cursor-pointer flex items-center gap-1 mb-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] group-open:rotate-90 transition-transform",children:"chevron_right"}),s("detectionPatterns")||"Detection Patterns"," (",a.detectionPatterns?.length||0,")"]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,d.jsx)("input",{type:"text",placeholder:s("newPattern")||'e.g. "generate a title"',value:q,onChange:a=>r(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,d.jsx)("button",{onClick:()=>{if(!q.trim())return;let b=[...a.detectionPatterns,q.trim()];t({detectionPatterns:b}),r("")},disabled:i||!q.trim(),className:"px-3 py-2 rounded-lg text-sm font-medium bg-sky-500/10 text-sky-500 hover:bg-sky-500/20 disabled:opacity-50 transition-all",children:s("add")||"Add"})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:(a.detectionPatterns||[]).map((b,c)=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs bg-sky-500/10 text-sky-400 border border-sky-500/20",children:[b,(0,d.jsx)("button",{onClick:()=>{let b;return b=a.detectionPatterns.filter((a,b)=>b!==c),void t({detectionPatterns:b})},className:"hover:text-red-400 transition-colors",disabled:i,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},c))})]})]})]})}[f]=i.then?(await i)():i,a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),976066,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]);function j(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!1),i=(0,h.useTranslations)("settings"),j=()=>{fetch("/api/cache/stats").then(a=>a.json()).then(b).catch(()=>{})};(0,e.useEffect)(j,[]);let k=async()=>{f(!0);try{await fetch("/api/cache/stats",{method:"DELETE"}),j()}finally{f(!1)}};return(0,d.jsxs)(g.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("h3",{className:"text-lg font-semibold text-text-main flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"cached"}),i("promptCache")]}),(0,d.jsx)("button",{onClick:k,disabled:c,className:"px-3 py-1.5 text-xs rounded-lg bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:i(c?"flushing":"flushCache")})]}),a?(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("size")}),(0,d.jsxs)("p",{className:"font-mono text-lg text-text-main",children:[a.size,"/",a.maxSize]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("hitRate")}),(0,d.jsxs)("p",{className:"font-mono text-lg text-text-main",children:[a.hitRate?.toFixed(1)??0,"%"]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("hits")}),(0,d.jsx)("p",{className:"font-mono text-text-main",children:a.hits??0})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("evictions")}),(0,d.jsx)("p",{className:"font-mono text-text-main",children:a.evictions??0})]})]}):(0,d.jsx)("p",{className:"text-sm text-text-muted",children:i("loadingCacheStats")})]})}[f]=i.then?(await i)():i,a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),986820,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(240246),j=a.i(32886),k=a.i(415925),l=b([f]);[f]=l.then?(await l)():l;let u={CLOSED:{bg:"bg-emerald-500/15",text:"text-emerald-400",border:"border-emerald-500/30",icon:"check_circle"},OPEN:{bg:"bg-red-500/15",text:"text-red-400",border:"border-red-500/30",icon:"error"},HALF_OPEN:{bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/30",icon:"warning"}},v={closed:{icon:"check_circle",color:"#22c55e"},"half-open":{icon:"pending",color:"#f59e0b"},open:{icon:"error",color:"#ef4444"}};function m(a,b){let c=String(a||"closed").toLowerCase().replaceAll("_","-");return b("open"===c?"breakerStateOpen":"half-open"===c?"breakerStateHalfOpen":"breakerStateClosed")}function n(a){return!a||a<=0?"—":a<1e3?`${a}ms`:a<6e4?`${(a/1e3).toFixed(1)}s`:`${(a/6e4).toFixed(1)}m`}function o(a,b){return a instanceof Error&&a.message?a.message:b}function p({profiles:a,onSave:b,saving:c}){let[f,i]=(0,e.useState)(!1),[j,l]=(0,e.useState)(a),m=(0,k.useTranslations)("settings"),n=(0,k.useTranslations)("common");(0,e.useEffect)(()=>{l(a)},[a]);let o=a=>null==a?"—":`${a}${m("ms")}`,p=[{key:"transientCooldown",label:m("transientCooldown"),format:o},{key:"rateLimitCooldown",label:m("rateLimitCooldown"),format:o},{key:"maxBackoffLevel",label:m("maxBackoffLevel")},{key:"circuitBreakerThreshold",label:m("cbThreshold"),format:a=>null==a?"—":m("failures",{count:a})},{key:"circuitBreakerReset",label:m("cbResetTime"),format:o}];return(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"tune"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:m("providerProfiles")})]}),f?(0,d.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",onClick:()=>i(!1),children:n("cancel")}),(0,d.jsx)(h.Button,{size:"sm",variant:"primary",icon:"save",onClick:()=>{b(j),i(!1)},disabled:c,children:n("save")})]}):(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>i(!0),children:n("edit")})]}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:m("providerProfilesDesc")}),(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:["oauth","apikey"].map(b=>(0,d.jsxs)("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 p-4",children:[(0,d.jsxs)("h3",{className:"text-sm font-bold uppercase tracking-wider mb-3 flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-base","aria-hidden":"true",children:"oauth"===b?"lock":"key"}),"oauth"===b?m("oauthProviders"):m("apiKeyProviders")]}),(0,d.jsx)("div",{className:"space-y-2",children:p.map(({key:c,label:e,format:g})=>(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted",children:e}),f?(0,d.jsx)("input",{type:"number",min:"0",value:j?.[b]?.[c]??0,onChange:a=>l({...j,[b]:{...j[b],[c]:Number(a.target.value)}}),className:"w-24 px-2 py-1 text-xs rounded bg-white/10 border border-white/20 text-right"}):(0,d.jsx)("span",{className:"text-sm font-mono",children:g?g(a?.[b]?.[c]):a?.[b]?.[c]??"—"})]},c))})]},b))})]})})}function q({rateLimitStatus:a,defaults:b,onSaveDefaults:c,saving:f}){let[i,j]=(0,e.useState)(!1),[l,m]=(0,e.useState)(b||{}),o=(0,k.useTranslations)("settings"),p=(0,k.useTranslations)("common");return(0,e.useEffect)(()=>{b&&m(b)},[b]),(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"speed"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:o("rateLimiting")})]}),i?(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",onClick:()=>j(!1),children:p("cancel")}),(0,d.jsx)(h.Button,{size:"sm",variant:"primary",icon:"save",onClick:()=>{c(l),j(!1)},disabled:f,children:p("save")})]}):(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>j(!0),children:p("edit")})]}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:o("rateLimitingDesc")}),(0,d.jsxs)("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 p-4 mb-4",children:[(0,d.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3 text-text-muted",children:o("defaultSafetyNet")}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[{key:"requestsPerMinute",label:o("rpm")},{key:"minTimeBetweenRequests",label:o("minGap"),format:n},{key:"concurrentRequests",label:o("maxConcurrent")}].map(({key:a,label:c,format:e})=>(0,d.jsxs)("div",{children:[i?(0,d.jsx)("input",{type:"number",min:"1",value:l[a]??0,onChange:b=>m(c=>({...c,[a]:parseInt(b.target.value)||0})),className:"w-full px-2 py-1 text-lg font-bold rounded bg-white/10 border border-white/20"}):(0,d.jsx)("div",{className:"text-lg font-bold",children:e?e(b?.[a]):b?.[a]??"—"}),(0,d.jsx)("div",{className:"text-xs text-text-muted",children:c})]},a))})]}),a&&a.length>0?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider text-text-muted",children:o("activeLimiters")}),a.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-black/5 dark:bg-white/5",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:a.provider||a.key}),(0,d.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted",children:[null!=a.reservoir&&(0,d.jsxs)("span",{children:[o("reservoir"),": ",a.reservoir]}),null!=a.running&&(0,d.jsxs)("span",{children:[o("running"),": ",a.running]}),null!=a.queued&&(0,d.jsxs)("span",{children:[o("queued"),": ",a.queued]})]})]},b))]}):(0,d.jsx)("p",{className:"text-xs text-text-muted",children:o("noActiveLimiters")})]})})}function r({breakers:a,onReset:b,loading:c}){let e=a.filter(a=>"CLOSED"!==a.state),f=a.length,i=(0,k.useTranslations)("settings");return(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"electrical_services"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:i("circuitBreakers")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted",children:e.length>0?i("tripped",{count:e.length}):i("healthy",{count:f})}),e.length>0&&(0,d.jsx)(h.Button,{size:"sm",variant:"danger",icon:"restart_alt",onClick:b,disabled:c,children:i("resetAll")})]})]}),0===a.length?(0,d.jsx)("p",{className:"text-sm text-text-muted",children:i("noCircuitBreakers")}):(0,d.jsx)("div",{className:"space-y-2",children:a.map(a=>{let b=u[a.state]||u.CLOSED;return(0,d.jsxs)("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-black/5 dark:bg-white/5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-base ${b.text}`,"aria-hidden":"true",children:b.icon}),(0,d.jsx)("span",{className:"text-sm font-medium",children:a.name.replace("combo:","")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a.failureCount>0&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:i("failures",{count:a.failureCount})}),(0,d.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-bold uppercase ${b.bg} ${b.text} border ${b.border}`,children:m(a.state,i)})]})]},a.name)})})]})})}function s(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!0),[l,n]=(0,e.useState)(null),o=(0,i.useNotificationStore)(),p=(0,j.useLocale)(),q=(0,k.useTranslations)("settings"),r=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/policies");if(a.ok){let c=await a.json();b(c)}}catch{}finally{f(!1)}},[]);(0,e.useEffect)(()=>{r();let a=setInterval(r,15e3);return()=>clearInterval(a)},[r]);let s=async a=>{n(a);try{(await fetch("/api/policies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"unlock",identifier:a})})).ok?(o.success(q("unlockedIdentifier",{identifier:a})),await r()):o.error(q("failedUnlock"))}catch{o.error(q("failedUnlock"))}finally{n(null)}},t=a?.circuitBreakers||[],u=a?.lockedIdentifiers||[],w=t.some(a=>"closed"!==a.state)||u.length>0;return c?(0,d.jsx)(g.Card,{className:"p-6",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted animate-pulse",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"policy"}),q("loadingPolicies")]})}):(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"policy"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:q("policiesLocked")})]}),w&&(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:r,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"})})]}),w?(0,d.jsxs)(d.Fragment,{children:[t.filter(a=>"closed"!==a.state).length>0&&(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text-muted mb-2",children:q("circuitBreakers")}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5",children:t.filter(a=>"closed"!==a.state).map((a,b)=>{let c=v[a.state]||v.open;return(0,d.jsx)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:c.color},children:c.icon}),(0,d.jsx)("span",{className:"text-sm text-text-main font-medium",children:a.name||a.provider||q("unknown")}),(0,d.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full",style:{backgroundColor:`${c.color}15`,color:c.color},children:m(a.state,q)}),a.failures>0&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:q("failures",{count:a.failures})})]})},a.name||b)})})]}),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text-muted mb-2",children:q("lockedIdentifiers")}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5",children:u.map((a,b)=>{let c="string"==typeof a?a:a.identifier||a.id;return(0,d.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-red-400",children:"lock"}),(0,d.jsx)("span",{className:"font-mono text-sm text-text-main",children:c}),"object"==typeof a&&a.lockedAt&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:q("sinceDate",{date:new Date(a.lockedAt).toLocaleString(p)})})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:()=>s(c),disabled:l===c,className:"text-xs",children:l===c?q("unlocking"):q("forceUnlock")})]},c||b)})})]})]}):(0,d.jsxs)("div",{className:"flex items-center gap-3",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]",children:"verified_user"})}),(0,d.jsx)("div",{children:(0,d.jsx)("p",{className:"text-sm text-text-muted",children:q("allOperational")})})]})]})})}function t(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!0),[i,j]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),n=(0,k.useTranslations)("settings"),t=(0,e.useCallback)(async()=>{try{f(!0);let a=await fetch("/api/resilience");if(!a.ok)throw Error(n("failedLoadWithStatus",{status:a.status}));let c=await a.json();b(c),m(null)}catch(a){m(o(a,n("failedLoadResilience")))}finally{f(!1)}},[n]);(0,e.useEffect)(()=>{t();let a=setInterval(t,1e4);return()=>clearInterval(a)},[t]);let u=async()=>{try{if(f(!0),!(await fetch("/api/resilience/reset",{method:"POST"})).ok)throw Error(n("resetFailed"));await t()}catch(a){m(o(a,n("resetFailed")))}finally{f(!1)}},v=async a=>{try{if(j(!0),!(await fetch("/api/resilience",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({profiles:a})})).ok)throw Error(n("saveFailed"));await t()}catch(a){m(o(a,n("saveFailed")))}finally{j(!1)}},w=async a=>{try{if(j(!0),!(await fetch("/api/resilience",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaults:a})})).ok)throw Error(n("saveFailed"));await t()}catch(a){m(o(a,n("saveFailed")))}finally{j(!1)}};return c&&!a?(0,d.jsxs)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin mr-2",children:"hourglass_empty"}),n("loadingResilience")]}):l&&!a?(0,d.jsxs)(g.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-red-400",children:[(0,d.jsx)("span",{className:"material-symbols-outlined",children:"error"}),(0,d.jsx)("span",{className:"text-sm",children:l})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"refresh",onClick:t,className:"mt-3",children:n("retry")})]}):(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(p,{profiles:a?.profiles||{},onSave:v,saving:i}),(0,d.jsx)(q,{rateLimitStatus:a?.rateLimitStatus||[],defaults:a?.defaults||{},onSaveDefaults:w,saving:i}),(0,d.jsx)(r,{breakers:a?.circuitBreakers||[],onReset:u,loading:c}),(0,d.jsx)(s,{})]})}a.s(["default",()=>t]),c()}catch(a){c(a)}},!1),415242,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(50944),g=a.i(171302),h=a.i(817648),i=a.i(415925),j=a.i(296248),k=a.i(547655),l=a.i(72926),m=a.i(589980),n=a.i(232327),o=a.i(220584),p=a.i(413316),q=a.i(769979),r=a.i(847910),s=a.i(876881),t=a.i(356962),u=a.i(976066),v=a.i(986820),w=b([h,j,k,l,m,n,o,p,q,r,s,t,u,v]);[h,j,k,l,m,n,o,p,q,r,s,t,u,v]=w.then?(await w)():w;let y=[{id:"general",labelKey:"general",icon:"settings"},{id:"ai",labelKey:"ai",icon:"smart_toy"},{id:"security",labelKey:"security",icon:"shield"},{id:"routing",labelKey:"routing",icon:"route"},{id:"resilience",labelKey:"resilience",icon:"electrical_services"},{id:"advanced",labelKey:"advanced",icon:"tune"}];function x(){let a=(0,i.useTranslations)("settings"),b=(0,f.useSearchParams)().get("tab"),[c,w]=(0,e.useState)(null),x=c||y.find(a=>a.id===b)?.id||"general";return(0,d.jsx)("div",{className:"max-w-6xl mx-auto min-w-0",children:(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)("div",{className:"w-full overflow-x-auto pb-1",children:(0,d.jsx)("div",{role:"tablist","aria-label":a("settingsSectionsAria"),className:"inline-flex items-center p-1 rounded-lg bg-black/5 dark:bg-white/5 min-w-max",children:y.map(b=>(0,d.jsxs)("button",{role:"tab","aria-selected":x===b.id,tabIndex:x===b.id?0:-1,onClick:()=>w(b.id),className:(0,g.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all text-sm",x===b.id?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:b.icon}),(0,d.jsx)("span",{className:"hidden sm:inline whitespace-nowrap",children:a(b.labelKey)})]},b.id))})}),(0,d.jsxs)("div",{role:"tabpanel","aria-label":a(y.find(a=>a.id===x)?.labelKey||"general"),children:["general"===x&&(0,d.jsx)(d.Fragment,{children:(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(j.default,{}),(0,d.jsx)(o.default,{})]})}),"ai"===x&&(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(p.default,{}),(0,d.jsx)(q.default,{}),(0,d.jsx)(r.default,{}),(0,d.jsx)(u.default,{})]}),"security"===x&&(0,d.jsx)(k.default,{}),"routing"===x&&(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(l.default,{}),(0,d.jsx)(m.default,{}),(0,d.jsx)(s.default,{}),(0,d.jsx)(t.default,{})]}),"resilience"===x&&(0,d.jsx)(v.default,{}),"advanced"===x&&(0,d.jsx)(n.default,{})]}),(0,d.jsxs)("div",{className:"text-center text-sm text-text-muted py-4",children:[(0,d.jsxs)("p",{children:[h.APP_CONFIG.name," v",h.APP_CONFIG.version]}),(0,d.jsx)("p",{className:"mt-1",children:a("localMode")})]})]})})}a.s(["default",()=>x]),c()}catch(a){c(a)}},!1)];
|
|
1
|
+
module.exports=[296248,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(818465),j=a.i(32886),k=a.i(415925),l=b([f]);function m(){let[a,b]=(0,e.useState)([]),[c,f]=(0,e.useState)(!1),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)({type:"",message:""}),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(null),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)({type:"",message:""}),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)({type:"",message:""}),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(null),H=(0,e.useRef)(null),I=(0,j.useLocale)(),J=(0,k.useTranslations)("settings"),K=(0,k.useTranslations)("common"),[L,M]=(0,e.useState)({driver:"sqlite",dbPath:"~/.omniroute/storage.sqlite",sizeBytes:0,retentionDays:90,lastBackupAt:null}),N=async()=>{f(!0);try{let a=await fetch("/api/db-backups"),c=await a.json();b(c.backups||[])}catch(a){console.error("Failed to fetch backups:",a)}finally{f(!1)}},O=async()=>{try{let a=await fetch("/api/storage/health");if(!a.ok)return;let b=await a.json();M(a=>({...a,...b}))}catch(a){console.error("Failed to fetch storage health:",a)}},P=async()=>{u(!0),w({type:"",message:""});try{let a=await fetch("/api/db-backups",{method:"PUT"}),b=await a.json();a.ok?(b.filename?w({type:"success",message:J("backupCreated",{file:b.filename})}):w({type:"info",message:b.message||J("noChangesSinceBackup")}),await O(),l&&await N()):w({type:"error",message:b.error||J("backupFailed")})}catch{w({type:"error",message:J("errorOccurred")})}finally{u(!1)}},Q=async a=>{q(a),o({type:"",message:""});try{let b=await fetch("/api/db-backups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({backupId:a})}),c=await b.json();b.ok?(o({type:"success",message:J("restoreSuccess",{connections:c.connectionCount,nodes:c.nodeCount,combos:c.comboCount,apiKeys:c.apiKeyCount})}),await N(),await O()):o({type:"error",message:c.error||J("restoreFailed")})}catch{o({type:"error",message:J("errorDuringRestore")})}finally{q(null),s(null)}};(0,e.useEffect)(()=>{O()},[]);let R=async()=>{y(!0);try{let a=await fetch("/api/db-backups/export");if(!a.ok){let b=await a.json();throw Error(b.error||J("exportFailed"))}let b=await a.blob(),c=URL.createObjectURL(b),d=(a.headers.get("Content-Disposition")||"").match(/filename="(.+)"/),e=d?d[1]:`omniroute-backup-${new Date().toISOString().replace(/[:.]/g,"-")}.sqlite`,f=document.createElement("a");f.href=c,f.download=e,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(c)}catch(a){console.error("Export failed:",a),C({type:"error",message:J("exportFailedWithError",{error:a.message})})}finally{y(!1)}},S=async()=>{if(F){A(!0),C({type:"",message:""}),E(!1);try{let a=new FormData;a.append("file",F);let b=await fetch("/api/db-backups/import",{method:"POST",body:a}),c=await b.json();b.ok?(C({type:"success",message:J("importSuccess",{connections:c.connectionCount,nodes:c.nodeCount,combos:c.comboCount,apiKeys:c.apiKeyCount})}),await O(),l&&await N()):C({type:"error",message:c.error||J("importFailed")})}catch{C({type:"error",message:J("errorDuringImport")})}finally{A(!1),G(null)}}},T=a=>a&&0!==a?a<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} KB`:`${(a/1048576).toFixed(1)} MB`:"0 B";return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-green-500/10 text-green-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"database"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:J("systemStorage")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:J("allDataLocal")})]}),(0,d.jsx)(i.Badge,{variant:"success",size:"sm",children:L.driver||"json"})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-4",children:[(0,d.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,d.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:J("databasePath")}),(0,d.jsx)("p",{className:"text-sm font-mono text-text-main break-all",children:L.dbPath||"~/.omniroute/storage.sqlite"})]}),(0,d.jsxs)("div",{className:"p-3 rounded-lg bg-bg border border-border",children:[(0,d.jsx)("p",{className:"text-[11px] text-text-muted uppercase tracking-wide mb-1",children:J("databaseSize")}),(0,d.jsx)("p",{className:"text-sm font-mono text-text-main",children:T(L.sizeBytes)})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:R,loading:x,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"download"}),J("exportDatabase")]}),(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:async()=>{y(!0);try{let a=await fetch("/api/db-backups/exportAll");if(!a.ok)throw Error(J("exportFailed"));let b=await a.blob(),c=(a.headers.get("Content-Disposition")||"").match(/filename="?([^"]+)"?/),d=c?.[1]||"omniroute-full-backup.tar.gz",e=URL.createObjectURL(b),f=document.createElement("a");f.href=e,f.download=d,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(e)}catch(a){C({type:"error",message:J("fullExportFailedWithError",{error:a.message})})}finally{y(!1)}},loading:x,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"folder_zip"}),J("exportAll")]}),(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:()=>{H.current?.click()},loading:z,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"upload"}),J("importDatabase")]}),(0,d.jsx)("input",{ref:H,type:"file",accept:".sqlite",className:"hidden",onChange:a=>{let b=a.target.files?.[0];if(b){if(!b.name.endsWith(".sqlite"))return void C({type:"error",message:J("invalidFileType")});G(b),E(!0),H.current&&(H.current.value="")}}})]}),D&&F&&(0,d.jsx)("div",{className:"p-4 rounded-lg mb-4 bg-amber-500/10 border border-amber-500/30",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px] text-amber-500 mt-0.5","aria-hidden":"true",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-500 mb-1",children:J("confirmDbImport")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:J("confirmDbImportDesc",{file:F.name})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:S,className:"!bg-amber-500 hover:!bg-amber-600",children:J("yesImport")}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:()=>{E(!1),G(null)},children:K("cancel")})]})]})]})}),B.message&&(0,d.jsx)("div",{className:`p-3 rounded-lg mb-4 text-sm ${"success"===B.type?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===B.type?"check_circle":"error"}),B.message]})}),(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-bg border border-border mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"schedule"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:J("lastBackup")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:L.lastBackupAt?`${new Date(L.lastBackupAt).toLocaleString(I)} (${(a=>{if(!a)return null;let b=new Date,c=new Date(a),d=Math.floor((b-c)/6e4);if(d<1)return J("justNow");if(d<60)return J("minutesAgo",{count:d});let e=Math.floor(d/60);if(e<24)return J("hoursAgo",{count:e});let f=Math.floor(e/24);return J("daysAgo",{count:f})})(L.lastBackupAt)})`:J("noBackupYet")})]})]}),(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:P,loading:t,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"backup"}),J("backupNow")]})]}),v.message&&(0,d.jsx)("div",{className:`p-3 rounded-lg mb-4 text-sm ${"success"===v.type?"bg-green-500/10 text-green-500 border border-green-500/20":"info"===v.type?"bg-blue-500/10 text-blue-500 border border-blue-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===v.type?"check_circle":"info"===v.type?"info":"error"}),v.message]})}),(0,d.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] text-amber-500","aria-hidden":"true",children:"restore"}),(0,d.jsx)("p",{className:"font-medium",children:J("backupRestore")})]}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:()=>{m(!l),l||0!==a.length||N()},children:l?J("hide"):J("viewBackups")})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-3",children:J("backupRetentionDesc")}),n.message&&(0,d.jsx)("div",{className:`p-3 rounded-lg mb-3 text-sm ${"success"===n.type?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,role:"alert",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"success"===n.type?"check_circle":"error"}),n.message]})}),l&&(0,d.jsx)("div",{className:"flex flex-col gap-2",children:c?(0,d.jsxs)("div",{className:"flex items-center justify-center py-6 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px] mr-2","aria-hidden":"true",children:"progress_activity"}),J("loadingBackups")]}):0===a.length?(0,d.jsxs)("div",{className:"text-center py-6 text-text-muted text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40","aria-hidden":"true",children:"folder_off"}),J("noBackupsYet")]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted",children:J("backupsAvailable",{count:a.length})}),(0,d.jsxs)("button",{onClick:N,className:"text-xs text-primary hover:underline flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"refresh"}),J("refresh")]})]}),a.map(a=>{var b;return(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg bg-black/[0.02] dark:bg-white/[0.02] border border-border/50 hover:border-border transition-colors",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-amber-500","aria-hidden":"true",children:"description"}),(0,d.jsx)("span",{className:"text-sm font-medium truncate",children:new Date(a.createdAt).toLocaleString(I)}),(0,d.jsx)(i.Badge,{variant:"pre-restore"===a.reason?"warning":"manual"===a.reason?"success":"default",size:"sm",children:(b=a.reason,"manual"===b?J("backupReasonManual"):"pre-restore"===b?J("backupReasonPreRestore"):b)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted ml-6",children:[(0,d.jsx)("span",{children:J("connectionsCount",{count:a.connectionCount})}),(0,d.jsx)("span",{children:"•"}),(0,d.jsx)("span",{children:T(a.size)})]})]}),(0,d.jsx)("div",{className:"flex items-center gap-2 ml-3",children:r===a.id?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-xs text-amber-500 font-medium",children:J("confirm")}),(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:()=>Q(a.id),loading:p===a.id,className:"!bg-amber-500 hover:!bg-amber-600",children:J("yes")}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:()=>s(null),children:J("no")})]}):(0,d.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:()=>s(a.id),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1","aria-hidden":"true",children:"restore"}),J("restore")]})})]},a.id)})]})})]})]})}[f]=l.then?(await l)():l,a.s(["default",()=>m]),c()}catch(a){c(a)}},!1),130361,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(489108),j=a.i(415925),k=b([f]);[f]=k.then?(await k)():k;let m=[{value:"disabled",labelKey:"ipModeDisabled",icon:"block"},{value:"blacklist",labelKey:"ipModeBlacklist",icon:"do_not_disturb"},{value:"whitelist",labelKey:"ipModeWhitelist",icon:"verified_user"},{value:"whitelist-priority",labelKey:"ipModeWhitelistPriority",icon:"priority_high"}];function l(){let[a,b]=(0,e.useState)({enabled:!1,mode:"blacklist",blacklist:[],whitelist:[],tempBans:[]}),[c,f]=(0,e.useState)(!0),[k,l]=(0,e.useState)(""),[n,o]=(0,e.useState)("blacklist"),p=(0,j.useTranslations)("settings");(0,e.useEffect)(()=>{q()},[]);let q=async()=>{try{let a=await fetch("/api/settings/ip-filter");a.ok&&b(await a.json())}catch{}finally{f(!1)}},r=async a=>{try{let c=await fetch("/api/settings/ip-filter",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});c.ok&&b(await c.json())}catch{}},s=()=>{k.trim()&&(r({["blacklist"===n?"addBlacklist":"addWhitelist"]:k.trim()}),l(""))},t=(a,b)=>{r({["blacklist"===b?"removeBlacklist":"removeWhitelist"]:a})},u=a.enabled?a.mode:"disabled";return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-red-500/10 text-red-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"security"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:p("ipAccessControl")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:p("ipAccessControlDesc")})]})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2 mb-5",children:m.map(a=>(0,d.jsxs)("button",{onClick:()=>{var b;return b=a.value,void("disabled"===b?r({enabled:!1}):r({enabled:!0,mode:b}))},disabled:c,className:`flex flex-col items-center gap-1.5 p-3 rounded-lg border text-center transition-all ${u===a.value?"border-red-500/50 bg-red-500/5 ring-1 ring-red-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[20px] ${u===a.value?"text-red-400":"text-text-muted"}`,children:a.icon}),(0,d.jsx)("span",{className:`text-xs font-medium ${u===a.value?"text-red-400":"text-text-muted"}`,children:p(a.labelKey)})]},a.value))}),a.enabled&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-end",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(i.Input,{label:p("addIpAddress"),placeholder:p("ipAddressPlaceholder"),value:k,onChange:a=>l(a.target.value),onKeyDown:a=>"Enter"===a.key&&s()})}),(0,d.jsxs)("div",{className:"flex gap-1 pb-[2px]",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"blacklist"===n?"danger":"secondary",onClick:()=>{o("blacklist"),k.trim()&&s()},children:p("block")}),(0,d.jsx)(h.Button,{size:"sm",variant:"whitelist"===n?"primary":"secondary",onClick:()=>{o("whitelist"),k.trim()&&s()},children:p("allow")})]})]}),a.blacklist.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:p("blocked",{count:a.blacklist.length})}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.blacklist.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-red-500/10 text-red-400 border border-red-500/20",children:[a,(0,d.jsx)("button",{onClick:()=>t(a,"blacklist"),className:"hover:text-red-300",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a))})]}),a.whitelist.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:p("allowed",{count:a.whitelist.length})}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.whitelist.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-mono bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[a,(0,d.jsx)("button",{onClick:()=>t(a,"whitelist"),className:"hover:text-emerald-300",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},a))})]}),a.tempBans.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-2",children:p("temporaryBans",{count:a.tempBans.length})}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5",children:a.tempBans.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-orange-500/5 border border-orange-500/20 text-sm",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)("span",{className:"font-mono text-xs text-orange-400 shrink-0",children:a.ip}),(0,d.jsxs)("span",{className:"text-xs text-text-muted truncate",children:["— ",a.reason]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted tabular-nums",children:p("minLeft",{min:Math.ceil(a.remainingMs/6e4)})}),(0,d.jsx)("button",{onClick:()=>{let b;return b=a.ip,r({removeBan:b})},className:"text-text-muted hover:text-orange-400",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]},a.ip))})]})]})]})}a.s(["default",()=>l]),c()}catch(a){c(a)}},!1),860500,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(415925),j=b([f]);function k(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!0),j=(0,i.useTranslations)("settings");(0,e.useEffect)(()=>{let a=!1;return async function(){let c=sessionStorage.getItem("omniroute_login_time"),d=Date.now(),e=j("unknown");if(c){let a=d-parseInt(c,10),b=Math.floor(a/36e5),f=Math.floor(a%36e5/6e4);e=b>0?`${b}h ${f}m`:`${f}m`}let g=!1;try{let a=await fetch("/api/auth/status",{method:"GET",cache:"no-store"});if(a.ok){let b=await a.json();g=!0===b.authenticated}}catch{}a||(b({authenticated:g,loginTime:c?new Date(parseInt(c,10)).toLocaleString():null,sessionAge:e,ipAddress:"—",userAgent:navigator.userAgent.split(" ").slice(-2).join(" ")||j("unknown")}),f(!1))}(),()=>{a=!0}},[]);let k=async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),sessionStorage.removeItem("omniroute_login_time"),window.location.href="/"}catch{window.location.href="/"}};return c?(0,d.jsx)(g.Card,{children:(0,d.jsx)("div",{className:"animate-pulse h-32 bg-black/5 dark:bg-white/5 rounded-lg"})}):(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"person"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:j("session")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-3",role:"list","aria-label":j("sessionDetailsAria"),children:[(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("status")}),(0,d.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full ${a?.authenticated?"bg-green-500":"bg-yellow-500"}`,"aria-hidden":"true"}),a?.authenticated?j("authenticated"):j("guest")]})]}),a?.loginTime&&(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("loginTime")}),(0,d.jsx)("span",{className:"font-mono text-xs",children:a.loginTime})]}),(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("sessionAge")}),(0,d.jsx)("span",{className:"font-mono text-xs",children:a?.sessionAge})]}),(0,d.jsxs)("div",{className:"flex justify-between items-center text-sm",role:"listitem",children:[(0,d.jsx)("span",{className:"text-text-muted",children:j("browser")}),(0,d.jsx)("span",{className:"font-mono text-xs truncate max-w-[200px]",children:a?.userAgent})]})]}),(0,d.jsxs)("div",{className:"flex gap-3 mt-4 pt-4 border-t border-border/50",children:[(0,d.jsx)(h.Button,{variant:"secondary",onClick:()=>{confirm(j("clearLocalDataConfirm"))&&(localStorage.clear(),sessionStorage.clear(),window.location.reload())},children:j("clearLocalData")}),a?.authenticated&&(0,d.jsx)(h.Button,{variant:"danger",onClick:k,children:j("logout")})]})]})}[f]=j.then?(await j)():j,a.s(["default",()=>k]),c()}catch(a){c(a)}},!1),547655,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(489108),j=a.i(709918),k=a.i(662073),l=a.i(130361),m=a.i(860500),n=a.i(415925),o=b([f,k,l,m]);function p(){let[a,b]=(0,e.useState)({requireLogin:!1,hasPassword:!1}),[c,f]=(0,e.useState)(!0),[o,p]=(0,e.useState)({current:"",new:"",confirm:""}),[q,r]=(0,e.useState)({type:"",message:""}),[s,t]=(0,e.useState)(!1),u=(0,n.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let v=async a=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:a})})).ok&&b(b=>({...b,requireLogin:a}))}catch(a){console.error("Failed to update require login:",a)}},w=async(a,c)=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:c})})).ok&&b(b=>({...b,[a]:c}))}catch(b){console.error(`Failed to update ${a}:`,b)}},x=async a=>{if(a.preventDefault(),o.new!==o.confirm)return void r({type:"error",message:u("passwordsNoMatch")});t(!0),r({type:"",message:""});try{let a=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:o.current,newPassword:o.new})}),b=await a.json();a.ok?(r({type:"success",message:u("passwordUpdated")}),p({current:"",new:"",confirm:""})):r({type:"error",message:b.error||u("failedUpdatePassword")})}catch{r({type:"error",message:u("errorOccurred")})}finally{t(!1)}},y=a.blockedProviders||[];return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"shield"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:u("security")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:u("requireLogin")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:u("requireLoginDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!0===a.requireLogin,onChange:()=>v(!a.requireLogin),disabled:c})]}),!0===a.requireLogin&&(0,d.jsxs)("form",{onSubmit:x,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[a.hasPassword&&(0,d.jsx)(i.Input,{label:u("currentPassword"),type:"password",placeholder:u("enterCurrentPassword"),value:o.current,onChange:a=>p({...o,current:a.target.value}),required:!0}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsx)(i.Input,{label:u("newPassword"),type:"password",placeholder:u("enterNewPassword"),value:o.new,onChange:a=>p({...o,new:a.target.value}),required:!0}),(0,d.jsx)(i.Input,{label:u("confirmPassword"),type:"password",placeholder:u("confirmPasswordPlaceholder"),value:o.confirm,onChange:a=>p({...o,confirm:a.target.value}),required:!0})]}),q.message&&(0,d.jsx)("p",{className:`text-sm ${"error"===q.type?"text-red-500":"text-green-500"}`,children:q.message}),(0,d.jsx)("div",{className:"pt-2",children:(0,d.jsx)(h.Button,{type:"submit",variant:"primary",loading:s,children:a.hasPassword?u("updatePassword"):u("setPassword")})})]})]})]}),(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-600 dark:text-amber-400",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"api"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:u("apiEndpointProtection")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:u("requireAuthModels")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:u("requireAuthModelsDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!0===a.requireAuthForModels,onChange:()=>w("requireAuthForModels",!a.requireAuthForModels),disabled:c})]}),(0,d.jsxs)("div",{className:"pt-4 border-t border-border/50",children:[(0,d.jsxs)("div",{className:"mb-3",children:[(0,d.jsx)("p",{className:"font-medium",children:u("blockedProviders")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:u("blockedProvidersDesc")})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:Object.values(k.AI_PROVIDERS).map(b=>{let e=y.includes(b.id);return(0,d.jsxs)("button",{onClick:()=>{var c;let d,e;return c=b.id,e=(d=a.blockedProviders||[]).includes(c)?d.filter(a=>a!==c):[...d,c],void w("blockedProviders",e)},disabled:c,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all border ${e?"bg-red-500/10 border-red-500/30 text-red-600 dark:text-red-400":"bg-black/[0.02] dark:bg-white/[0.02] border-transparent text-text-muted hover:bg-black/[0.05] dark:hover:bg-white/[0.05]"}`,title:e?u("unblockProviderTitle",{provider:b.name}):u("blockProviderTitle",{provider:b.name}),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:{color:e?void 0:b.color},children:e?"block":b.icon}),b.name,e&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-red-500",children:"close"})]},b.id)})}),y.length>0&&(0,d.jsxs)("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),u("providersBlocked",{count:y.length})]})]})]})]}),(0,d.jsx)(m.default,{}),(0,d.jsx)(l.default,{})]})}[f,k,l,m]=o.then?(await o)():o,a.s(["default",()=>p]),c()}catch(a){c(a)}},!1),754828,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(489108),j=a.i(609754),k=a.i(240246),l=a.i(415925),m=b([f]);[f]=m.then?(await m)():m;let o=["#6366f1","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6"];function n(){let[a,b]=(0,e.useState)({}),[c,f]=(0,e.useState)(!0),[m,n]=(0,e.useState)(!1),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),v=(0,k.useNotificationStore)(),w=(0,l.useTranslations)("settings"),x=(0,l.useTranslations)("common"),y=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/fallback/chains");if(a.ok){let c=await a.json();b(c.chains||c||{})}}catch{}finally{f(!1)}},[]);(0,e.useEffect)(()=>{y()},[y]);let z=async()=>{if(!p.trim()||!r.trim())return void v.warning(w("fillModelAndProviders"));let a=r.split(",").map(a=>a.trim()).filter(Boolean).map((a,b)=>({provider:a,priority:b+1,enabled:!0}));if(0===a.length)return void v.warning(w("addAtLeastOneProvider"));u(!0);try{(await fetch("/api/fallback/chains",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:p.trim(),chain:a})})).ok?(v.success(w("chainCreated",{model:p.trim()})),q(""),s(""),n(!1),await y()):v.error(w("failedCreateChain"))}catch{v.error(w("failedCreateChain"))}finally{u(!1)}},A=async a=>{if(confirm(w("deleteChainConfirm",{model:a})))try{(await fetch("/api/fallback/chains",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a})})).ok?(v.success(w("chainDeleted",{model:a})),await y()):v.error(w("failedDeleteChain"))}catch{v.error(w("failedDeleteChain"))}};if(c)return(0,d.jsx)(g.Card,{className:"p-6 mt-6",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted animate-pulse",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"timeline"}),w("loadingFallbackChains")]})});let B=Object.entries(a);return(0,d.jsxs)(g.Card,{className:"mt-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4 p-6 pb-0",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-cyan-500/10 text-cyan-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"timeline"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:w("fallbackChainsTitle")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:w("fallbackChainsDesc")})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"primary",onClick:()=>n(!m),children:m?x("cancel"):w("addChain")})]}),m&&(0,d.jsxs)("div",{className:"mx-6 p-4 rounded-lg border border-border/30 bg-surface/20 mb-4",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-3",children:[(0,d.jsx)(i.Input,{label:w("modelName"),placeholder:w("modelNamePlaceholder"),value:p,onChange:a=>q(a.target.value)}),(0,d.jsx)(i.Input,{label:w("providersCommaSeparated"),placeholder:w("providersCommaSeparatedPlaceholder"),value:r,onChange:a=>s(a.target.value)})]}),(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:z,loading:t,children:w("createChain")})]}),(0,d.jsx)("div",{className:"px-6 pb-6",children:0===B.length?(0,d.jsx)(j.EmptyState,{icon:"timeline",title:w("noFallbackChains"),description:w("noFallbackChainsDesc")}):(0,d.jsx)("div",{className:"flex flex-col gap-2",children:B.map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 rounded-lg border border-border/20 bg-surface/20 hover:bg-surface/40 transition-colors",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,d.jsx)("span",{className:"font-mono text-sm text-text-main truncate max-w-[200px]",children:a}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:(Array.isArray(b)?b:[]).map((a,b)=>(0,d.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:`${o[b%o.length]}20`,color:o[b%o.length],border:`1px solid ${o[b%o.length]}40`},children:[b+1,". ",a.provider]},`${a.provider}-${b}`))})]}),(0,d.jsx)("button",{onClick:()=>A(a),className:"text-text-muted hover:text-red-400 transition-colors ml-2",title:w("deleteChain"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},a))})})]})}a.s(["default",()=>n]),c()}catch(a){c(a)}},!1),72926,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(489108),i=a.i(294023),j=a.i(754828),k=a.i(669805),l=a.i(415925),m=b([f,j]);[f,j]=m.then?(await m)():m;let o=k.ROUTING_STRATEGIES.filter(a=>k.SETTINGS_FALLBACK_STRATEGY_VALUES.includes(a.value)).map(a=>({value:a.value,labelKey:a.labelKey,descKey:a.settingsDescKey,icon:a.icon}));function n(){let[a,b]=(0,e.useState)({fallbackStrategy:"fill-first"}),[c,f]=(0,e.useState)(!0),[k,m]=(0,e.useState)([]),[n,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),s=(0,l.useTranslations)("settings"),t=o.reduce((a,b)=>(a[b.value]=b.descKey,a),{});(0,e.useEffect)(()=>{fetch("/api/settings").then(a=>a.json()).then(a=>{b(a),m(a.wildcardAliases||[]),f(!1)}).catch(()=>f(!1))},[]);let u=async a=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok&&b(b=>({...b,...a}))}catch(a){console.error("Failed to update settings:",a)}},v=async()=>{if(!n.trim()||!q.trim())return;let a=[...k,{pattern:n.trim(),target:q.trim()}];await u({wildcardAliases:a}),m(a),p(""),r("")},w=async a=>{let b=k.filter((b,c)=>c!==a);await u({wildcardAliases:b}),m(b)};return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"route"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("routingStrategy")})]}),(0,d.jsxs)("div",{className:"mb-4 rounded-lg border border-blue-500/20 bg-blue-500/5 p-3",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-blue-700 dark:text-blue-300",children:s("routingAdvancedGuideTitle")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-1",children:s("routingAdvancedGuideHint1")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:s("routingAdvancedGuideHint2")})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-2 mb-4",style:{gridAutoRows:"1fr"},children:o.map(b=>(0,d.jsxs)("button",{onClick:()=>u({fallbackStrategy:b.value}),disabled:c,className:`flex flex-col items-center gap-2 p-4 rounded-lg border text-center transition-all ${a.fallbackStrategy===b.value?"border-blue-500/50 bg-blue-500/5 ring-1 ring-blue-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[24px] ${a.fallbackStrategy===b.value?"text-blue-400":"text-text-muted"}`,children:b.icon}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:`text-sm font-medium ${a.fallbackStrategy===b.value?"text-blue-400":""}`,children:s(b.labelKey)}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:s(b.descKey)})]})]},b.value))}),"round-robin"===a.fallbackStrategy&&(0,d.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-border/30",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:s("stickyLimit")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:s("stickyLimitDesc")})]}),(0,d.jsx)(h.Input,{type:"number",min:"1",max:"10",value:a.stickyRoundRobinLimit||3,onChange:a=>u({stickyRoundRobinLimit:parseInt(a.target.value)}),disabled:c,className:"w-20 text-center"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted italic pt-3 border-t border-border/30 mt-3",children:s(t[a.fallbackStrategy]||"fillFirstDesc")})]}),(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"alt_route"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("modelAliases")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:s("modelAliasesDesc")})]})]}),k.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-1.5 mb-4",children:k.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,d.jsx)("span",{className:"font-mono text-purple-400 break-all",children:a.pattern}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("span",{className:"font-mono text-text-main break-all",children:a.target})]}),(0,d.jsx)("button",{onClick:()=>w(b),className:"shrink-0 text-text-muted hover:text-red-400 transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},b))}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-end",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(h.Input,{label:s("pattern"),placeholder:s("aliasPatternPlaceholder"),value:n,onChange:a=>p(a.target.value)})}),(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(h.Input,{label:s("targetModel"),placeholder:s("aliasTargetPlaceholder"),value:q,onChange:a=>r(a.target.value)})}),(0,d.jsx)(i.Button,{size:"sm",variant:"primary",onClick:v,className:"mb-[2px] sm:w-auto w-full",children:s("add")})]})]}),(0,d.jsx)(j.default,{})]})}a.s(["default",()=>n]),c()}catch(a){c(a)}},!1),589980,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(489108),j=a.i(709918),k=a.i(171302),l=a.i(669805),m=a.i(415925),n=b([f]);function o(){let[a,b]=(0,e.useState)({strategy:"priority",maxRetries:1,retryDelayMs:2e3,timeoutMs:12e4,healthCheckEnabled:!0,healthCheckTimeoutMs:3e3,maxComboDepth:3,trackMetrics:!0}),[c,f]=(0,e.useState)({}),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(!1),r=(0,m.useTranslations)("settings"),s=(0,m.useTranslations)("common"),t=l.ROUTING_STRATEGIES.map(a=>({value:a.value,label:r(a.labelKey),icon:a.icon})),u=[{key:"maxRetries",label:r("maxRetriesLabel"),min:0,max:5},{key:"retryDelayMs",label:r("retryDelayLabel"),min:500,max:1e4,step:500},{key:"timeoutMs",label:r("timeoutLabel"),min:5e3,max:3e5,step:5e3},{key:"maxComboDepth",label:r("maxNestingDepth"),min:1,max:10}];(0,e.useEffect)(()=>{fetch("/api/settings/combo-defaults").then(a=>a.json()).then(a=>{a.comboDefaults&&b(a.comboDefaults),a.providerOverrides&&f(a.providerOverrides)}).catch(a=>console.error("Failed to fetch combo defaults:",a))},[]);let v=async()=>{q(!0);try{await fetch("/api/settings/combo-defaults",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboDefaults:a,providerOverrides:c})})}catch(a){console.error("Failed to save combo defaults:",a)}finally{q(!1)}},w=()=>{let a=n.trim().toLowerCase();a&&!c[a]&&(f(b=>({...b,[a]:{maxRetries:1,timeoutMs:12e4}})),o(""))};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"tune"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:r("comboDefaultsTitle")}),(0,d.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:r("globalComboConfig")})]}),(0,d.jsxs)("div",{className:"mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 p-3",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:r("comboDefaultsGuideTitle")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-1",children:r("comboDefaultsGuideHint1")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("comboDefaultsGuideHint2")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium text-sm",children:r("defaultStrategy")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("defaultStrategyDesc")})]}),(0,d.jsx)("div",{role:"tablist","aria-label":r("comboStrategyAria"),className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-1 p-0.5 rounded-md bg-black/5 dark:bg-white/5",children:t.map(c=>(0,d.jsxs)("button",{role:"tab","aria-selected":a.strategy===c.value,onClick:()=>b(a=>({...a,strategy:c.value})),className:(0,k.cn)("px-2 py-1 rounded text-xs font-medium transition-all flex items-center justify-center gap-0.5",a.strategy===c.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:c.icon}),c.label]},c.value))})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:u.map(({key:c,label:e,min:f,max:g,step:h})=>(0,d.jsx)(i.Input,{label:e,type:"number",min:f,max:g,step:h||1,value:a[c]??"",onChange:a=>b(b=>({...b,[c]:parseInt(a.target.value)||0})),className:"text-sm"},c))}),"round-robin"===a.strategy&&(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3 pt-3 border-t border-border/50",children:[(0,d.jsx)(i.Input,{label:r("concurrencyPerModel"),type:"number",min:1,max:20,value:a.concurrencyPerModel??"",placeholder:"3",onChange:a=>b(b=>({...b,concurrencyPerModel:parseInt(a.target.value)||0})),className:"text-sm"}),(0,d.jsx)(i.Input,{label:r("queueTimeout"),type:"number",min:1e3,max:12e4,step:1e3,value:a.queueTimeoutMs??"",placeholder:"30000",onChange:a=>b(b=>({...b,queueTimeoutMs:parseInt(a.target.value)||0})),className:"text-sm"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-3 pt-3 border-t border-border/50",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium text-sm",children:r("healthCheck")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("healthCheckDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!1!==a.healthCheckEnabled,onChange:()=>b(a=>({...a,healthCheckEnabled:!a.healthCheckEnabled}))})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium text-sm",children:r("trackMetrics")}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:r("trackMetricsDesc")})]}),(0,d.jsx)(j.Toggle,{checked:!1!==a.trackMetrics,onChange:()=>b(a=>({...a,trackMetrics:!a.trackMetrics}))})]})]}),(0,d.jsxs)("div",{className:"pt-3 border-t border-border/50",children:[(0,d.jsx)("p",{className:"font-medium text-sm mb-2",children:r("providerOverrides")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-3",children:r("providerOverridesDesc")}),Object.entries(c).map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-2 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[(0,d.jsx)("span",{className:"text-xs font-mono font-medium min-w-[80px]",children:a}),(0,d.jsx)(i.Input,{type:"number",min:"0",max:"5",value:b.maxRetries??1,onChange:b=>f(c=>({...c,[a]:{...c[a],maxRetries:parseInt(b.target.value)||0}})),className:"text-xs w-16","aria-label":r("providerMaxRetriesAria",{provider:a})}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:r("retries")}),(0,d.jsx)(i.Input,{type:"number",min:"5000",max:"300000",step:"5000",value:b.timeoutMs??12e4,onChange:b=>f(c=>({...c,[a]:{...c[a],timeoutMs:parseInt(b.target.value)||12e4}})),className:"text-xs w-24","aria-label":r("providerTimeoutAria",{provider:a})}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:r("ms")}),(0,d.jsx)("button",{onClick:()=>{f(b=>{let c={...b};return delete c[a],c})},className:"ml-auto text-red-400 hover:text-red-500 transition-colors","aria-label":r("removeProviderOverrideAria",{provider:a}),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})})]},a)),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,d.jsx)(i.Input,{type:"text",placeholder:r("newProviderNamePlaceholder"),value:n,onChange:a=>o(a.target.value),onKeyDown:a=>"Enter"===a.key&&w(),className:"text-xs flex-1","aria-label":r("newProviderNameAria")}),(0,d.jsx)(h.Button,{variant:"outline",size:"sm",onClick:w,disabled:!n.trim(),children:s("add")})]})]}),(0,d.jsx)("div",{className:"pt-3 border-t border-border/50",children:(0,d.jsx)(h.Button,{variant:"primary",size:"sm",onClick:v,loading:p,children:r("saveComboDefaults")})})]})]})}[f]=n.then?(await n)():n,a.s(["default",()=>o]),c()}catch(a){c(a)}},!1),928050,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(294023),h=a.i(292216),i=a.i(563203),j=b([f]);[f]=j.then?(await j)():j;let l={id:"",name:"",type:"http",host:"",port:"8080",username:"",password:"",region:"",notes:"",status:"active"};function k(){let[a,b]=(0,e.useState)([]),[c,f]=(0,e.useState)(!1),[j,k]=(0,e.useState)(null),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(l),[s,t]=(0,e.useState)({}),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)("provider"),[I,J]=(0,e.useState)(""),[K,L]=(0,e.useState)(""),M=(0,e.useMemo)(()=>q.id||"",[q.id]),N=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/settings/proxies/health?hours=24"),b=await a.json().catch(()=>({}));if(!a.ok)return;let c=Array.isArray(b?.items)?b.items:[],d=Object.fromEntries(c.map(a=>[a.proxyId,a]));v(d)}catch{}},[]),O=(0,e.useCallback)(async a=>{if(a.length)try{let b=await Promise.all(a.map(a=>fetch(`/api/settings/proxies/assignments?proxyId=${encodeURIComponent(a)}`).then(a=>a.ok?a.json():null).then(b=>{let c=Array.isArray(b?.items)?b.items:[],d=new Set,e=c.filter(a=>{let b=`${a.scope}:${a.scopeId??""}`;return!d.has(b)&&(d.add(b),!0)});return[a,{count:e.length,assignments:e}]}).catch(()=>[a,{count:0,assignments:[]}])));t(Object.fromEntries(b))}catch{}},[]),P=(0,e.useCallback)(async()=>{f(!0),k(null);try{let a=await fetch("/api/settings/proxies"),c=await a.json().catch(()=>({}));if(!a.ok){k(c?.error?.message||"Failed to load proxy registry"),b([]);return}let d=Array.isArray(c?.items)?c.items:[];b(d);let e=d.map(a=>a.id).filter(Boolean);N(),O(e)}catch(a){k(a?.message||"Failed to load proxy registry"),b([])}finally{f(!1)}},[N,O]);(0,e.useEffect)(()=>{P()},[P]),(0,e.useEffect)(()=>{a.length>0&&!K&&L(a[0].id)},[a,K]);let Q=async a=>{if(!y){z(a.id),x(b=>({...b,[a.id]:null}));try{let b=await fetch("/api/settings/proxy/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyId:a.id,proxy:{type:a.type||"http",host:a.host,port:String(a.port||8080)}})}),c=await b.json().catch(()=>({}));if(!b.ok)return void x(b=>({...b,[a.id]:{success:!1,error:c?.error?.message||"Test failed"}}));x(b=>({...b,[a.id]:{success:!0,...c}}))}catch(b){x(c=>({...c,[a.id]:{success:!1,error:b?.message}}))}finally{z(null)}}},R=async()=>{if(!q.name.trim()||!q.host.trim())return void k("Name and host are required");p(!0),k(null);let a=q.username.trim(),b=q.password.trim(),c={...M?{id:M}:{},name:q.name.trim(),type:q.type,host:q.host.trim(),port:Number(q.port||8080),region:q.region.trim()||null,notes:q.notes.trim()||null,status:q.status};(!M||a.length>0)&&(c.username=a),(!M||b.length>0)&&(c.password=b);try{let a=await fetch("/api/settings/proxies",{method:M?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),b=await a.json().catch(()=>({}));if(!a.ok)return void k(b?.error?.message||"Failed to save proxy");n(!1),r(l),await P()}catch(a){k(a?.message||"Failed to save proxy")}finally{p(!1)}},S=async a=>{try{let b=await fetch(`/api/settings/proxies?id=${encodeURIComponent(a)}`,{method:"DELETE"});if(b.ok)return void await P();let c=await b.json().catch(()=>({}));if(409===b.status){if(!window.confirm("This proxy is still assigned. Force delete and remove all assignments?"))return;let b=await fetch(`/api/settings/proxies?id=${encodeURIComponent(a)}&force=1`,{method:"DELETE"});if(!b.ok){let a=await b.json().catch(()=>({}));k(a?.error?.message||"Failed to force delete proxy");return}await P();return}k(c?.error?.message||"Failed to delete proxy")}catch(a){k(a?.message||"Failed to delete proxy")}},T=async()=>{B(!0),k(null);try{let a=await fetch("/api/settings/proxies/migrate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:!1})}),b=await a.json().catch(()=>({}));if(!a.ok)return void k(b?.error?.message||"Failed to migrate legacy proxy config");await P()}catch(a){k(a?.message||"Failed to migrate legacy proxy config")}finally{B(!1)}},U=async()=>{F(!0),k(null);try{let a="global"===G?[]:I.split(/[\n,]/g).map(a=>a.trim()).filter(Boolean),b=await fetch("/api/settings/proxies/bulk-assign",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:G,scopeIds:a,proxyId:K||null})}),c=await b.json().catch(()=>({}));if(!b.ok)return void k(c?.error?.message||"Failed to run bulk assignment");D(!1),J(""),await P()}catch(a){k(a?.message||"Failed to run bulk assignment")}finally{F(!1)}};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(h.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:"Proxy Registry"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Store reusable proxies and track assignments."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",icon:"upgrade",onClick:T,loading:A,"data-testid":"proxy-registry-import-legacy",children:"Import Legacy"}),(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",icon:"account_tree",onClick:()=>D(!0),"data-testid":"proxy-registry-open-bulk",children:"Bulk Assign"}),(0,d.jsx)(g.Button,{size:"sm",icon:"add",onClick:()=>{r(l),n(!0)},"data-testid":"proxy-registry-open-create",children:"Add Proxy"})]})]}),j&&(0,d.jsx)("div",{className:"mb-3 px-3 py-2 rounded border border-red-500/30 bg-red-500/10 text-sm text-red-400",children:j}),c?(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"Loading proxies..."}):0===a.length?(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"No saved proxies yet."}):(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"text-left text-text-muted border-b border-border",children:[(0,d.jsx)("th",{className:"py-2 pr-3",children:"Name"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Endpoint"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Status"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Health (24h)"}),(0,d.jsx)("th",{className:"py-2 pr-3",children:"Usage"}),(0,d.jsx)("th",{className:"py-2",children:"Actions"})]})}),(0,d.jsx)("tbody",{children:a.map(a=>{s[a.id];let b=u[a.id];return(0,d.jsxs)("tr",{className:"border-b border-border/60",children:[(0,d.jsxs)("td",{className:"py-2 pr-3",children:[(0,d.jsx)("div",{className:"font-medium text-text-main",children:a.name}),a.region&&(0,d.jsx)("div",{className:"text-xs text-text-muted",children:a.region})]}),(0,d.jsxs)("td",{className:"py-2 pr-3 font-mono text-xs text-text-muted",children:[a.type,"://",a.host,":",a.port]}),(0,d.jsx)("td",{className:"py-2 pr-3",children:(0,d.jsx)("span",{className:"text-xs px-2 py-1 rounded border border-border bg-bg-subtle",children:a.status||"active"})}),(0,d.jsx)("td",{className:"py-2 pr-3 text-xs text-text-muted",children:(0,d.jsx)("div",{className:"flex flex-col gap-0.5",children:w[a.id]?w[a.id].success?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"text-emerald-400",children:["✓ ",w[a.id].publicIp]}),w[a.id].latencyMs&&(0,d.jsxs)("span",{children:[w[a.id].latencyMs,"ms"]})]}):(0,d.jsxs)("span",{className:"text-red-400",children:["✗ ",w[a.id].error||"failed"]}):b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:[b.successRate??0,"% success"]}),(0,d.jsxs)("span",{children:[b.avgLatencyMs??"-"," ms avg"]})]}):(0,d.jsx)("span",{children:"—"})})}),(0,d.jsx)("td",{className:"py-2 pr-3 text-xs text-text-muted",children:null!=s[a.id]?`${s[a.id].count} assignment(s)`:"—"}),(0,d.jsx)("td",{className:"py-2",children:(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"ghost",icon:"speed",onClick:()=>void Q(a),loading:y===a.id,children:"Test"}),(0,d.jsx)(g.Button,{size:"sm",variant:"ghost",icon:"edit",onClick:()=>{r({id:a.id,name:a.name||"",type:a.type||"http",host:a.host||"",port:String(a.port||8080),username:"",password:"",region:a.region||"",notes:a.notes||"",status:a.status||"active"}),n(!0)},children:"Edit"}),(0,d.jsx)(g.Button,{size:"sm",variant:"ghost",icon:"delete",onClick:()=>void S(a.id),className:"!text-red-400",children:"Delete"})]})})]},a.id)})})]})})]}),(0,d.jsx)(i.Modal,{isOpen:m,onClose:()=>{o||n(!1)},title:M?"Edit Proxy":"Create Proxy",maxWidth:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Name"}),(0,d.jsx)("input",{"data-testid":"proxy-registry-name-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.name,onChange:a=>r(b=>({...b,name:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Type"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.type,onChange:a=>r(b=>({...b,type:a.target.value})),children:[(0,d.jsx)("option",{value:"http",children:"HTTP"}),(0,d.jsx)("option",{value:"https",children:"HTTPS"}),(0,d.jsx)("option",{value:"socks5",children:"SOCKS5"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Host"}),(0,d.jsx)("input",{"data-testid":"proxy-registry-host-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.host,onChange:a=>r(b=>({...b,host:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Port"}),(0,d.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.port,onChange:a=>r(b=>({...b,port:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Username"}),(0,d.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.username,placeholder:M?"Leave blank to keep current username":"",onChange:a=>r(b=>({...b,username:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Password"}),(0,d.jsx)("input",{type:"password",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.password,placeholder:M?"Leave blank to keep current password":"",onChange:a=>r(b=>({...b,password:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Region"}),(0,d.jsx)("input",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.region,onChange:a=>r(b=>({...b,region:a.target.value}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Status"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.status,onChange:a=>r(b=>({...b,status:a.target.value})),children:[(0,d.jsx)("option",{value:"active",children:"active"}),(0,d.jsx)("option",{value:"inactive",children:"inactive"})]})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Notes"}),(0,d.jsx)("textarea",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:q.notes,onChange:a=>r(b=>({...b,notes:a.target.value})),rows:3})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",onClick:()=>n(!1),children:"Cancel"}),(0,d.jsx)(g.Button,{size:"sm",icon:"save",onClick:R,loading:o,children:"Save"})]})]})}),(0,d.jsx)(i.Modal,{isOpen:C,onClose:()=>{E||D(!1)},title:"Bulk Proxy Assignment",maxWidth:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Scope"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:G,onChange:a=>H(a.target.value),children:[(0,d.jsx)("option",{value:"global",children:"global"}),(0,d.jsx)("option",{value:"provider",children:"provider"}),(0,d.jsx)("option",{value:"account",children:"account"}),(0,d.jsx)("option",{value:"combo",children:"combo"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Proxy"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",value:K,onChange:a=>L(a.target.value),children:[(0,d.jsx)("option",{value:"",children:"(clear assignment)"}),a.map(a=>(0,d.jsxs)("option",{value:a.id,children:[a.name," (",a.type,"://",a.host,":",a.port,")"]},a.id))]})]})]}),"global"!==G&&(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Scope IDs (comma or newline)"}),(0,d.jsx)("textarea",{"data-testid":"proxy-registry-bulk-scopeids-input",className:"w-full px-3 py-2 rounded bg-bg-subtle border border-border",rows:5,value:I,onChange:a=>J(a.target.value),placeholder:"provider-openai,provider-anthropic"})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[(0,d.jsx)(g.Button,{size:"sm",variant:"secondary",onClick:()=>D(!1),children:"Cancel"}),(0,d.jsx)(g.Button,{size:"sm",icon:"done_all",onClick:U,loading:E,"data-testid":"proxy-registry-bulk-apply",children:"Apply"})]})]})})]})}a.s(["default",()=>k]),c()}catch(a){c(a)}},!1),232327,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(248172),j=a.i(415925),k=a.i(928050),l=b([f,k]);function m(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(null),l=(0,e.useRef)(!0),m=(0,j.useTranslations)("settings"),n=(0,j.useTranslations)("common"),o=async()=>{try{let a=await fetch("/api/settings/proxy?level=global");if(a.ok){let b=await a.json();f(b.proxy||null)}}catch{}};return(0,e.useEffect)(()=>(l.current=!0,async function(){try{let a=await fetch("/api/settings/proxy?level=global");if(!l.current)return;if(a.ok){let b=await a.json();l.current&&f(b.proxy||null)}}catch{}}(),()=>{l.current=!1}),[]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"vpn_lock"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:m("globalProxy")})]}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:m("globalProxyDesc")}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[c?(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsxs)("span",{className:"px-2.5 py-1 rounded text-xs font-bold uppercase bg-emerald-500/15 text-emerald-400 border border-emerald-500/30",children:[c.type,"://",c.host,":",c.port]})}):(0,d.jsx)("span",{className:"text-sm text-text-muted",children:m("noGlobalProxy")}),(0,d.jsx)(h.Button,{size:"sm",variant:c?"secondary":"primary",icon:"settings",onClick:()=>{o(),b(!0)},children:c?n("edit"):m("configure")})]})]})}),(0,d.jsx)(k.default,{})]}),(0,d.jsx)(i.ProxyConfigModal,{isOpen:a,onClose:()=>b(!1),level:"global",levelLabel:m("globalLabel"),onSaved:o})]})}[f,k]=l.then?(await l)():l,a.s(["default",()=>m]),c()}catch(a){c(a)}},!1),220584,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(442308),g=a.i(294023),h=a.i(292216),i=a.i(709918),j=a.i(893711),k=a.i(788164),l=a.i(171302),m=a.i(415925),n=b([f,j,k]);function o(){let{theme:a,setTheme:b,isDark:c}=(0,j.useTheme)(),{colorTheme:f,customColor:n,setColorTheme:o,setCustomColorTheme:p}=(0,k.default)(),q=(0,m.useTranslations)("settings"),[r,s]=(0,e.useState)({}),[t,u]=(0,e.useState)(!0),[v,w]=(0,e.useState)(n||"#3b82f6"),x=/^#([0-9a-fA-F]{6})$/.test(v.startsWith("#")?v:`#${v}`);(0,e.useEffect)(()=>k.default.subscribe(a=>{a.customColor&&a.customColor!==v&&w(a.customColor)}),[]);let y={light:q("themeLight"),dark:q("themeDark"),system:q("themeSystem")};(0,e.useEffect)(()=>{fetch("/api/settings").then(a=>{if(!a.ok)throw Error(`HTTP error ${a.status}`);return a.json()}).then(a=>{s(a),u(!1)}).catch(()=>u(!1))},[]);let z=async(a,b)=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})})).ok&&s(c=>({...c,[a]:b}))}catch(b){console.error(`Failed to update ${a}:`,b)}},A=[{id:"coral",color:k.COLOR_THEMES.coral,label:q("themeCoral")},{id:"blue",color:k.COLOR_THEMES.blue,label:q("themeBlue")},{id:"red",color:k.COLOR_THEMES.red,label:q("themeRed")},{id:"green",color:k.COLOR_THEMES.green,label:q("themeGreen")},{id:"violet",color:k.COLOR_THEMES.violet,label:q("themeViolet")},{id:"orange",color:k.COLOR_THEMES.orange,label:q("themeOrange")},{id:"cyan",color:k.COLOR_THEMES.cyan,label:q("themeCyan")}];return(0,d.jsxs)(h.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"palette"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold",children:q("appearance")})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:q("darkMode")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:q("switchThemes")})]}),(0,d.jsx)(i.Toggle,{checked:c,onChange:()=>b(c?"light":"dark")})]}),(0,d.jsx)("div",{className:"pt-4 border-t border-border",children:(0,d.jsx)("div",{role:"tablist","aria-label":q("themeSelectionAria"),className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5",children:["light","dark","system"].map(c=>(0,d.jsxs)("button",{role:"tab","aria-selected":a===c,onClick:()=>b(c),className:(0,l.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all",a===c?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"light"===c?"light_mode":"dark"===c?"dark_mode":"contrast"}),(0,d.jsx)("span",{children:y[c]||c})]},c))})}),(0,d.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,d.jsx)("p",{className:"font-medium mb-1",children:q("themeAccent")}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-3",children:q("themeAccentDesc")}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mb-3",children:A.map(a=>{let b=f===a.id;return(0,d.jsx)("button",{onClick:()=>o(a.id),className:(0,l.cn)("flex items-center justify-between gap-2 p-2 rounded-lg border transition-colors",b?"border-primary bg-primary/10 text-primary":"border-border hover:bg-surface/50 text-text-main"),children:(0,d.jsxs)("span",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"size-4 rounded-full border border-black/10 dark:border-white/20",style:{backgroundColor:a.color}}),(0,d.jsx)("span",{className:"text-sm font-medium",children:a.label})]})},a.id)})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"color",value:v,onChange:a=>w(a.target.value),className:"h-10 w-12 rounded border border-border bg-surface cursor-pointer","aria-label":q("themeCustom")}),(0,d.jsx)("input",{type:"text",value:v,onChange:a=>w(a.target.value),placeholder:"#3b82f6",maxLength:7,className:`flex-1 h-10 px-3 rounded-lg bg-surface border text-sm text-text-main focus:outline-none ${x?"border-border focus:border-primary":"border-red-400 focus:border-red-500"}`}),(0,d.jsx)(g.Button,{onClick:()=>p(v),disabled:!x,children:q("themeCreate")})]})]}),(0,d.jsx)("div",{className:"pt-4 border-t border-border",children:(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-medium",children:q("hideHealthLogs")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:q("hideHealthLogsDesc")})]}),(0,d.jsx)(i.Toggle,{checked:!0===r.hideHealthCheckLogs,onChange:()=>z("hideHealthCheckLogs",!r.hideHealthCheckLogs),disabled:t})]})})]})]})}[f,j,k]=n.then?(await n)():n,a.s(["default",()=>o]),c()}catch(a){c(a)}},!1),413316,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 k=[{value:"passthrough",labelKey:"passthrough",descKey:"passthroughDesc",icon:"arrow_forward"},{value:"auto",labelKey:"auto",descKey:"autoDesc",icon:"auto_awesome"},{value:"custom",labelKey:"custom",descKey:"customDesc",icon:"tune"},{value:"adaptive",labelKey:"adaptive",descKey:"adaptiveDesc",icon:"trending_up"}],l=[{value:"none",labelKey:"effortNone"},{value:"low",labelKey:"effortLow"},{value:"medium",labelKey:"effortMedium"},{value:"high",labelKey:"effortHigh"}];function j(){let[a,b]=(0,e.useState)({mode:"passthrough",customBudget:10240,effortLevel:"medium"}),[c,f]=(0,e.useState)(!0),[i,j]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/thinking-budget").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let p=async c=>{let d={...a,...c};b(d),j(!0),n("");try{(await fetch("/api/settings/thinking-budget",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).ok?(n("saved"),setTimeout(()=>n(""),2e3)):n("error")}catch{n("error")}finally{j(!1)}};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-violet-500/10 text-violet-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"psychology"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:o("thinkingBudgetTitle")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:o("thinkingBudgetDesc")})]}),"saved"===m&&(0,d.jsxs)("span",{className:"ml-auto text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",o("saved")]})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-2 mb-5",children:k.map(b=>(0,d.jsxs)("button",{onClick:()=>p({mode:b.value}),disabled:c||i,className:`flex items-start gap-3 p-3 rounded-lg border text-left transition-all ${a.mode===b.value?"border-violet-500/50 bg-violet-500/5 ring-1 ring-violet-500/20":"border-border/50 hover:border-border hover:bg-surface/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[20px] mt-0.5 ${a.mode===b.value?"text-violet-500":"text-text-muted"}`,children:b.icon}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:`text-sm font-medium ${a.mode===b.value?"text-violet-400":""}`,children:o(b.labelKey)}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5 leading-relaxed",children:o(b.descKey)})]})]},b.value))}),"custom"===a.mode&&(0,d.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:o("tokenBudget")}),(0,d.jsxs)("span",{className:"text-sm font-mono tabular-nums text-violet-400",children:[a.customBudget.toLocaleString()," ",o("tokens")]})]}),(0,d.jsx)("input",{type:"range",min:"0",max:"131072",step:"1024",value:a.customBudget,onChange:a=>p({customBudget:parseInt(a.target.value)}),className:"w-full accent-violet-500"}),(0,d.jsxs)("div",{className:"flex justify-between text-xs text-text-muted mt-1",children:[(0,d.jsx)("span",{children:o("off")}),(0,d.jsx)("span",{children:"1K"}),(0,d.jsx)("span",{children:"10K"}),(0,d.jsx)("span",{children:"64K"}),(0,d.jsx)("span",{children:"128K"})]})]}),"adaptive"===a.mode&&(0,d.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-3",children:o("baseEffortLevel")}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-3",children:o("adaptiveHint")}),(0,d.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:l.map(b=>(0,d.jsx)("button",{onClick:()=>p({effortLevel:b.value}),disabled:c||i,className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${a.effortLevel===b.value?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border/50 text-text-muted hover:border-border"}`,children:o(b.labelKey)},b.value))})]})]})}a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),769979,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=b([f]);function i(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(!0),[h,i]=(0,e.useState)(!1),[j,k]=(0,e.useState)("");(0,e.useEffect)(()=>{fetch("/api/settings/codex-service-tier").then(a=>a.json()).then(a=>{b(!!a.enabled),f(!1)}).catch(()=>f(!1))},[]);let l=async a=>{b(a),i(!0),k("");try{(await fetch("/api/settings/codex-service-tier",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:a})})).ok?(k("saved"),setTimeout(()=>k(""),2e3)):(k("error"),b(!a))}catch{k("error"),b(!a)}finally{i(!1)}};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-sky-500/10 text-sky-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"bolt"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:"Codex Fast Service Tier"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Inject `service_tier=fast` into Codex requests when the client leaves it unset."})]}),"saved"===j&&(0,d.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),"Saved"]}),"error"===j&&(0,d.jsxs)("span",{className:"text-xs font-medium text-rose-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),"Failed to save"]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg bg-surface/30 border border-border/30",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"Force fast tier for Codex"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Off by default. Applies only to Codex requests and does not override an explicit tier."})]}),(0,d.jsx)("button",{onClick:()=>l(!a),disabled:c||h,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-sky-500":"bg-white/10"}`,children:(0,d.jsx)("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]})]})}[f]=h.then?(await h)():h,a.s(["default",()=>i]),c()}catch(a){c(a)}},!1),847910,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(709918),i=a.i(415925),j=b([f]);function k(){let[a,b]=(0,e.useState)({enabled:!1,prompt:""}),[c,f]=(0,e.useState)(!0),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)(null),n=(0,i.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/system-prompt").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let o=async c=>{let d={...a,...c};b(d),k("");try{(await fetch("/api/settings/system-prompt",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).ok&&(k("saved"),setTimeout(()=>k(""),2e3))}catch{k("error")}};return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"edit_note"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:n("globalSystemPrompt")}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:n("systemPromptDesc")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:["saved"===j&&(0,d.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",n("saved")]}),(0,d.jsx)(h.Toggle,{checked:a.enabled,onChange:()=>o({enabled:!a.enabled}),disabled:c})]})]}),a.enabled&&(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("textarea",{value:a.prompt,onChange:a=>{var c;return c=a.target.value,void(b(a=>({...a,prompt:c})),l&&clearTimeout(l),m(setTimeout(()=>{o({prompt:c})},800)))},placeholder:n("systemPromptPlaceholder"),rows:5,className:"w-full px-4 py-3 rounded-lg border border-border/50 bg-surface/30 text-sm placeholder:text-text-muted/50 resize-y min-h-[120px] focus:outline-none focus:ring-1 focus:ring-amber-500/30 focus:border-amber-500/50 transition-colors",disabled:c}),(0,d.jsx)("div",{className:"absolute bottom-2 right-3 text-xs text-text-muted/60 tabular-nums",children:n("chars",{count:a.prompt.length})})]}),(0,d.jsxs)("p",{className:"text-xs text-text-muted/70 flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"info"}),n("systemPromptHint")]})]})]})}[f]=j.then?(await j)():j,a.s(["default",()=>k]),c()}catch(a){c(a)}},!1),876881,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]);function j(){let[a,b]=(0,e.useState)({}),[c,f]=(0,e.useState)({}),[i,j]=(0,e.useState)(!0),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),s=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/model-aliases").then(a=>a.json()).then(a=>{b(a.builtIn||{}),f(a.custom||{}),j(!1)}).catch(()=>j(!1))},[]);let t=async()=>{if(o.trim()&&q.trim()){l(!0);try{let a=await fetch("/api/settings/model-aliases",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:o.trim(),to:q.trim()})});if(a.ok){let b=await a.json();f(b.custom),p(""),r(""),n("saved"),setTimeout(()=>n(""),2e3)}}catch{n("error")}finally{l(!1)}}},u=async a=>{l(!0);try{let b=await fetch("/api/settings/model-aliases",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a})});if(b.ok){let a=await b.json();f(a.custom),n("saved"),setTimeout(()=>n(""),2e3)}}catch{n("error")}finally{l(!1)}},v=Object.entries(a),w=Object.entries(c);return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-amber-500/10 text-amber-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"swap_horiz"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("modelAliasesTitle")||"Model Aliases"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:s("modelAliasesDesc")||"Auto-forward deprecated model IDs to their replacements"})]}),"saved"===m&&(0,d.jsxs)("span",{className:"ml-auto text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",s("saved")||"Saved"]})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-3",children:s("addCustomAlias")||"Add Custom Alias"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",placeholder:s("deprecatedModelId")||"Deprecated model ID",value:o,onChange:a=>p(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-amber-500/50 focus:outline-none"}),(0,d.jsx)("span",{className:"text-text-muted text-lg",children:"→"}),(0,d.jsx)("input",{type:"text",placeholder:s("newModelId")||"New model ID",value:q,onChange:a=>r(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-amber-500/50 focus:outline-none"}),(0,d.jsx)("button",{onClick:t,disabled:k||!o.trim()||!q.trim(),className:"px-4 py-2 rounded-lg text-sm font-medium bg-amber-500/10 text-amber-500 hover:bg-amber-500/20 disabled:opacity-50 transition-all",children:s("add")||"Add"})]})]}),w.length>0&&(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-muted uppercase tracking-wider mb-2",children:s("customAliases")||"Custom Aliases"}),(0,d.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20",children:w.map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,d.jsx)("code",{className:"text-xs text-red-400/80 flex-1 truncate",children:a}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("code",{className:"text-xs text-emerald-400/80 flex-1 truncate",children:b}),(0,d.jsx)("button",{onClick:()=>u(a),disabled:k,className:"p-1 rounded hover:bg-red-500/10 text-text-muted hover:text-red-400 transition-all",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},a))})]}),(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"text-xs font-medium text-text-muted uppercase tracking-wider cursor-pointer flex items-center gap-1 mb-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] group-open:rotate-90 transition-transform",children:"chevron_right"}),s("builtInAliases")||"Built-in Aliases"," (",v.length,")"]}),(0,d.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20 max-h-60 overflow-y-auto",children:v.map(([a,b])=>(0,d.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 opacity-60",children:[(0,d.jsx)("code",{className:"text-xs text-red-400/60 flex-1 truncate",children:a}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("code",{className:"text-xs text-emerald-400/60 flex-1 truncate",children:b}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"lock"})]},a))})]})]})}[f]=i.then?(await i)():i,a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),356962,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]);function j(){let[a,b]=(0,e.useState)({enabled:!1,degradationMap:{},detectionPatterns:[],stats:{detected:0,tokensSaved:0}}),[c,f]=(0,e.useState)(!0),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),s=(0,h.useTranslations)("settings");(0,e.useEffect)(()=>{fetch("/api/settings/background-degradation").then(a=>a.json()).then(a=>{b(a),f(!1)}).catch(()=>f(!1))},[]);let t=async c=>{let d={...a,...c};b(d),j(!0),l("");try{let{stats:a,...c}=d,e=await fetch("/api/settings/background-degradation",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(e.ok){let a=await e.json();b(a),l("saved"),setTimeout(()=>l(""),2e3)}else l("error")}catch{l("error")}finally{j(!1)}},u=Object.entries(a.degradationMap||{});return(0,d.jsxs)(g.Card,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,d.jsx)("div",{className:"p-2 rounded-lg bg-sky-500/10 text-sky-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"speed"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("h3",{className:"text-lg font-semibold",children:s("backgroundDegradationTitle")||"Background Task Degradation"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:s("backgroundDegradationDesc")||"Auto-redirect background requests (titles, summaries) to cheaper models"})]}),"saved"===k&&(0,d.jsxs)("span",{className:"text-xs font-medium text-emerald-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"})," ",s("saved")||"Saved"]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg bg-surface/30 border border-border/30 mb-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:s("enableDegradation")||"Enable Background Degradation"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:s("enableDegradationHint")||"Automatically use cheaper models for background utility tasks"})]}),(0,d.jsx)("button",{onClick:()=>t({enabled:!a.enabled}),disabled:c||i,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a.enabled?"bg-sky-500":"bg-white/10"}`,children:(0,d.jsx)("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${a.enabled?"translate-x-6":"translate-x-1"}`})})]}),a.stats&&a.stats.detected>0&&(0,d.jsx)("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-sky-500/5 border border-sky-500/20 mb-4",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-sky-400",children:"analytics"}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:[s("tasksDetected")||"Tasks detected",":"]}),(0,d.jsx)("span",{className:"text-sm font-mono font-semibold text-sky-400",children:a.stats.detected})]})}),a.enabled&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-muted uppercase tracking-wider mb-2",children:s("degradationMap")||"Model Degradation Map"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,d.jsx)("input",{type:"text",placeholder:s("premiumModel")||"Premium model",value:m,onChange:a=>n(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,d.jsx)("span",{className:"text-text-muted text-lg",children:"→"}),(0,d.jsx)("input",{type:"text",placeholder:s("cheapModel")||"Cheap model",value:o,onChange:a=>p(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,d.jsx)("button",{onClick:()=>{if(!m.trim()||!o.trim())return;let b={...a.degradationMap,[m.trim()]:o.trim()};t({degradationMap:b}),n(""),p("")},disabled:i||!m.trim()||!o.trim(),className:"px-3 py-2 rounded-lg text-sm font-medium bg-sky-500/10 text-sky-500 hover:bg-sky-500/20 disabled:opacity-50 transition-all",children:s("add")||"Add"})]}),u.length>0&&(0,d.jsx)("div",{className:"rounded-lg border border-border/30 divide-y divide-border/20 max-h-48 overflow-y-auto",children:u.map(([b,c])=>(0,d.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2",children:[(0,d.jsx)("code",{className:"text-xs text-orange-400/80 flex-1 truncate",children:b}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"arrow_forward"}),(0,d.jsx)("code",{className:"text-xs text-sky-400/80 flex-1 truncate",children:c}),(0,d.jsx)("button",{onClick:()=>{let c;return c={...a.degradationMap},void(delete c[b],t({degradationMap:c}))},disabled:i,className:"p-1 rounded hover:bg-red-500/10 text-text-muted hover:text-red-400 transition-all",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},b))})]}),(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"text-xs font-medium text-text-muted uppercase tracking-wider cursor-pointer flex items-center gap-1 mb-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] group-open:rotate-90 transition-transform",children:"chevron_right"}),s("detectionPatterns")||"Detection Patterns"," (",a.detectionPatterns?.length||0,")"]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,d.jsx)("input",{type:"text",placeholder:s("newPattern")||'e.g. "generate a title"',value:q,onChange:a=>r(a.target.value),className:"flex-1 px-3 py-2 rounded-lg text-sm bg-surface border border-border/50 focus:border-sky-500/50 focus:outline-none"}),(0,d.jsx)("button",{onClick:()=>{if(!q.trim())return;let b=[...a.detectionPatterns,q.trim()];t({detectionPatterns:b}),r("")},disabled:i||!q.trim(),className:"px-3 py-2 rounded-lg text-sm font-medium bg-sky-500/10 text-sky-500 hover:bg-sky-500/20 disabled:opacity-50 transition-all",children:s("add")||"Add"})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:(a.detectionPatterns||[]).map((b,c)=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs bg-sky-500/10 text-sky-400 border border-sky-500/20",children:[b,(0,d.jsx)("button",{onClick:()=>{let b;return b=a.detectionPatterns.filter((a,b)=>b!==c),void t({detectionPatterns:b})},className:"hover:text-red-400 transition-colors",disabled:i,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},c))})]})]})]})}[f]=i.then?(await i)():i,a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),976066,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]);function j(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!1),i=(0,h.useTranslations)("settings"),j=()=>{fetch("/api/cache/stats").then(a=>a.json()).then(b).catch(()=>{})};(0,e.useEffect)(j,[]);let k=async()=>{f(!0);try{await fetch("/api/cache/stats",{method:"DELETE"}),j()}finally{f(!1)}};return(0,d.jsxs)(g.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("h3",{className:"text-lg font-semibold text-text-main flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"cached"}),i("promptCache")]}),(0,d.jsx)("button",{onClick:k,disabled:c,className:"px-3 py-1.5 text-xs rounded-lg bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:i(c?"flushing":"flushCache")})]}),a?(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("size")}),(0,d.jsxs)("p",{className:"font-mono text-lg text-text-main",children:[a.size,"/",a.maxSize]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("hitRate")}),(0,d.jsxs)("p",{className:"font-mono text-lg text-text-main",children:[a.hitRate?.toFixed(1)??0,"%"]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("hits")}),(0,d.jsx)("p",{className:"font-mono text-text-main",children:a.hits??0})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted",children:i("evictions")}),(0,d.jsx)("p",{className:"font-mono text-text-main",children:a.evictions??0})]})]}):(0,d.jsx)("p",{className:"text-sm text-text-muted",children:i("loadingCacheStats")})]})}[f]=i.then?(await i)():i,a.s(["default",()=>j]),c()}catch(a){c(a)}},!1),986820,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(240246),j=a.i(32886),k=a.i(415925),l=b([f]);[f]=l.then?(await l)():l;let u={CLOSED:{bg:"bg-emerald-500/15",text:"text-emerald-400",border:"border-emerald-500/30",icon:"check_circle"},OPEN:{bg:"bg-red-500/15",text:"text-red-400",border:"border-red-500/30",icon:"error"},HALF_OPEN:{bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/30",icon:"warning"}},v={closed:{icon:"check_circle",color:"#22c55e"},"half-open":{icon:"pending",color:"#f59e0b"},open:{icon:"error",color:"#ef4444"}};function m(a,b){let c=String(a||"closed").toLowerCase().replaceAll("_","-");return b("open"===c?"breakerStateOpen":"half-open"===c?"breakerStateHalfOpen":"breakerStateClosed")}function n(a){return!a||a<=0?"—":a<1e3?`${a}ms`:a<6e4?`${(a/1e3).toFixed(1)}s`:`${(a/6e4).toFixed(1)}m`}function o(a,b){return a instanceof Error&&a.message?a.message:b}function p({profiles:a,onSave:b,saving:c}){let[f,i]=(0,e.useState)(!1),[j,l]=(0,e.useState)(a),m=(0,k.useTranslations)("settings"),n=(0,k.useTranslations)("common");(0,e.useEffect)(()=>{l(a)},[a]);let o=a=>null==a?"—":`${a}${m("ms")}`,p=[{key:"transientCooldown",label:m("transientCooldown"),format:o},{key:"rateLimitCooldown",label:m("rateLimitCooldown"),format:o},{key:"maxBackoffLevel",label:m("maxBackoffLevel")},{key:"circuitBreakerThreshold",label:m("cbThreshold"),format:a=>null==a?"—":m("failures",{count:a})},{key:"circuitBreakerReset",label:m("cbResetTime"),format:o}];return(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"tune"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:m("providerProfiles")})]}),f?(0,d.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",onClick:()=>i(!1),children:n("cancel")}),(0,d.jsx)(h.Button,{size:"sm",variant:"primary",icon:"save",onClick:()=>{b(j),i(!1)},disabled:c,children:n("save")})]}):(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>i(!0),children:n("edit")})]}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:m("providerProfilesDesc")}),(0,d.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:["oauth","apikey"].map(b=>(0,d.jsxs)("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 p-4",children:[(0,d.jsxs)("h3",{className:"text-sm font-bold uppercase tracking-wider mb-3 flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-base","aria-hidden":"true",children:"oauth"===b?"lock":"key"}),"oauth"===b?m("oauthProviders"):m("apiKeyProviders")]}),(0,d.jsx)("div",{className:"space-y-2",children:p.map(({key:c,label:e,format:g})=>(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted",children:e}),f?(0,d.jsx)("input",{type:"number",min:"0",value:j?.[b]?.[c]??0,onChange:a=>l({...j,[b]:{...j[b],[c]:Number(a.target.value)}}),className:"w-24 px-2 py-1 text-xs rounded bg-white/10 border border-white/20 text-right"}):(0,d.jsx)("span",{className:"text-sm font-mono",children:g?g(a?.[b]?.[c]):a?.[b]?.[c]??"—"})]},c))})]},b))})]})})}function q({rateLimitStatus:a,defaults:b,onSaveDefaults:c,saving:f}){let[i,j]=(0,e.useState)(!1),[l,m]=(0,e.useState)(b||{}),o=(0,k.useTranslations)("settings"),p=(0,k.useTranslations)("common");return(0,e.useEffect)(()=>{b&&m(b)},[b]),(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"speed"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:o("rateLimiting")})]}),i?(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",onClick:()=>j(!1),children:p("cancel")}),(0,d.jsx)(h.Button,{size:"sm",variant:"primary",icon:"save",onClick:()=>{c(l),j(!1)},disabled:f,children:p("save")})]}):(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>j(!0),children:p("edit")})]}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:o("rateLimitingDesc")}),(0,d.jsxs)("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 p-4 mb-4",children:[(0,d.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3 text-text-muted",children:o("defaultSafetyNet")}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[{key:"requestsPerMinute",label:o("rpm")},{key:"minTimeBetweenRequests",label:o("minGap"),format:n},{key:"concurrentRequests",label:o("maxConcurrent")}].map(({key:a,label:c,format:e})=>(0,d.jsxs)("div",{children:[i?(0,d.jsx)("input",{type:"number",min:"1",value:l[a]??0,onChange:b=>m(c=>({...c,[a]:parseInt(b.target.value)||0})),className:"w-full px-2 py-1 text-lg font-bold rounded bg-white/10 border border-white/20"}):(0,d.jsx)("div",{className:"text-lg font-bold",children:e?e(b?.[a]):b?.[a]??"—"}),(0,d.jsx)("div",{className:"text-xs text-text-muted",children:c})]},a))})]}),a&&a.length>0?(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider text-text-muted",children:o("activeLimiters")}),a.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-black/5 dark:bg-white/5",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:a.provider||a.key}),(0,d.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted",children:[null!=a.reservoir&&(0,d.jsxs)("span",{children:[o("reservoir"),": ",a.reservoir]}),null!=a.running&&(0,d.jsxs)("span",{children:[o("running"),": ",a.running]}),null!=a.queued&&(0,d.jsxs)("span",{children:[o("queued"),": ",a.queued]})]})]},b))]}):(0,d.jsx)("p",{className:"text-xs text-text-muted",children:o("noActiveLimiters")})]})})}function r({breakers:a,onReset:b,loading:c}){let e=a.filter(a=>"CLOSED"!==a.state),f=a.length,i=(0,k.useTranslations)("settings");return(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"electrical_services"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:i("circuitBreakers")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted",children:e.length>0?i("tripped",{count:e.length}):i("healthy",{count:f})}),e.length>0&&(0,d.jsx)(h.Button,{size:"sm",variant:"danger",icon:"restart_alt",onClick:b,disabled:c,children:i("resetAll")})]})]}),0===a.length?(0,d.jsx)("p",{className:"text-sm text-text-muted",children:i("noCircuitBreakers")}):(0,d.jsx)("div",{className:"space-y-2",children:a.map(a=>{let b=u[a.state]||u.CLOSED;return(0,d.jsxs)("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-black/5 dark:bg-white/5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-base ${b.text}`,"aria-hidden":"true",children:b.icon}),(0,d.jsx)("span",{className:"text-sm font-medium",children:a.name.replace("combo:","")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[a.failureCount>0&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:i("failures",{count:a.failureCount})}),(0,d.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-bold uppercase ${b.bg} ${b.text} border ${b.border}`,children:m(a.state,i)})]})]},a.name)})})]})})}function s(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!0),[l,n]=(0,e.useState)(null),o=(0,i.useNotificationStore)(),p=(0,j.useLocale)(),q=(0,k.useTranslations)("settings"),r=(0,e.useCallback)(async()=>{try{let a=await fetch("/api/policies");if(a.ok){let c=await a.json();b(c)}}catch{}finally{f(!1)}},[]);(0,e.useEffect)(()=>{r();let a=setInterval(r,15e3);return()=>clearInterval(a)},[r]);let s=async a=>{n(a);try{(await fetch("/api/policies",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"unlock",identifier:a})})).ok?(o.success(q("unlockedIdentifier",{identifier:a})),await r()):o.error(q("failedUnlock"))}catch{o.error(q("failedUnlock"))}finally{n(null)}},t=a?.circuitBreakers||[],u=a?.lockedIdentifiers||[],w=t.some(a=>"closed"!==a.state)||u.length>0;return c?(0,d.jsx)(g.Card,{className:"p-6",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted animate-pulse",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"policy"}),q("loadingPolicies")]})}):(0,d.jsx)(g.Card,{className:"p-0 overflow-hidden",children:(0,d.jsxs)("div",{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-xl text-primary","aria-hidden":"true",children:"policy"}),(0,d.jsx)("h2",{className:"text-lg font-bold",children:q("policiesLocked")})]}),w&&(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:r,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"})})]}),w?(0,d.jsxs)(d.Fragment,{children:[t.filter(a=>"closed"!==a.state).length>0&&(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text-muted mb-2",children:q("circuitBreakers")}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5",children:t.filter(a=>"closed"!==a.state).map((a,b)=>{let c=v[a.state]||v.open;return(0,d.jsx)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:c.color},children:c.icon}),(0,d.jsx)("span",{className:"text-sm text-text-main font-medium",children:a.name||a.provider||q("unknown")}),(0,d.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full",style:{backgroundColor:`${c.color}15`,color:c.color},children:m(a.state,q)}),a.failures>0&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:q("failures",{count:a.failures})})]})},a.name||b)})})]}),u.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text-muted mb-2",children:q("lockedIdentifiers")}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5",children:u.map((a,b)=>{let c="string"==typeof a?a:a.identifier||a.id;return(0,d.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface/30 border border-border/20",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-red-400",children:"lock"}),(0,d.jsx)("span",{className:"font-mono text-sm text-text-main",children:c}),"object"==typeof a&&a.lockedAt&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:q("sinceDate",{date:new Date(a.lockedAt).toLocaleString(p)})})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"ghost",onClick:()=>s(c),disabled:l===c,className:"text-xs",children:l===c?q("unlocking"):q("forceUnlock")})]},c||b)})})]})]}):(0,d.jsxs)("div",{className:"flex items-center gap-3",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]",children:"verified_user"})}),(0,d.jsx)("div",{children:(0,d.jsx)("p",{className:"text-sm text-text-muted",children:q("allOperational")})})]})]})})}function t(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(!0),[i,j]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),n=(0,k.useTranslations)("settings"),t=(0,e.useCallback)(async()=>{try{f(!0);let a=await fetch("/api/resilience");if(!a.ok)throw Error(n("failedLoadWithStatus",{status:a.status}));let c=await a.json();b(c),m(null)}catch(a){m(o(a,n("failedLoadResilience")))}finally{f(!1)}},[n]);(0,e.useEffect)(()=>{t();let a=setInterval(t,1e4);return()=>clearInterval(a)},[t]);let u=async()=>{try{if(f(!0),!(await fetch("/api/resilience/reset",{method:"POST"})).ok)throw Error(n("resetFailed"));await t()}catch(a){m(o(a,n("resetFailed")))}finally{f(!1)}},v=async a=>{try{if(j(!0),!(await fetch("/api/resilience",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({profiles:a})})).ok)throw Error(n("saveFailed"));await t()}catch(a){m(o(a,n("saveFailed")))}finally{j(!1)}},w=async a=>{try{if(j(!0),!(await fetch("/api/resilience",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaults:a})})).ok)throw Error(n("saveFailed"));await t()}catch(a){m(o(a,n("saveFailed")))}finally{j(!1)}};return c&&!a?(0,d.jsxs)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin mr-2",children:"hourglass_empty"}),n("loadingResilience")]}):l&&!a?(0,d.jsxs)(g.Card,{className:"p-6",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-red-400",children:[(0,d.jsx)("span",{className:"material-symbols-outlined",children:"error"}),(0,d.jsx)("span",{className:"text-sm",children:l})]}),(0,d.jsx)(h.Button,{size:"sm",variant:"secondary",icon:"refresh",onClick:t,className:"mt-3",children:n("retry")})]}):(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(p,{profiles:a?.profiles||{},onSave:v,saving:i}),(0,d.jsx)(q,{rateLimitStatus:a?.rateLimitStatus||[],defaults:a?.defaults||{},onSaveDefaults:w,saving:i}),(0,d.jsx)(r,{breakers:a?.circuitBreakers||[],onReset:u,loading:c}),(0,d.jsx)(s,{})]})}a.s(["default",()=>t]),c()}catch(a){c(a)}},!1),415242,a=>a.a(async(b,c)=>{try{var d=a.i(187924),e=a.i(572131),f=a.i(50944),g=a.i(171302),h=a.i(817648),i=a.i(415925),j=a.i(296248),k=a.i(547655),l=a.i(72926),m=a.i(589980),n=a.i(232327),o=a.i(220584),p=a.i(413316),q=a.i(769979),r=a.i(847910),s=a.i(876881),t=a.i(356962),u=a.i(976066),v=a.i(986820),w=b([h,j,k,l,m,n,o,p,q,r,s,t,u,v]);[h,j,k,l,m,n,o,p,q,r,s,t,u,v]=w.then?(await w)():w;let y=[{id:"general",labelKey:"general",icon:"settings"},{id:"ai",labelKey:"ai",icon:"smart_toy"},{id:"security",labelKey:"security",icon:"shield"},{id:"routing",labelKey:"routing",icon:"route"},{id:"resilience",labelKey:"resilience",icon:"electrical_services"},{id:"advanced",labelKey:"advanced",icon:"tune"}];function x(){let a=(0,i.useTranslations)("settings"),b=(0,f.useSearchParams)().get("tab"),[c,w]=(0,e.useState)(null),x=c||y.find(a=>a.id===b)?.id||"general";return(0,d.jsx)("div",{className:"max-w-6xl mx-auto min-w-0",children:(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)("div",{className:"w-full overflow-x-auto pb-1",children:(0,d.jsx)("div",{role:"tablist","aria-label":a("settingsSectionsAria"),className:"inline-flex items-center p-1 rounded-lg bg-black/5 dark:bg-white/5 min-w-max",children:y.map(b=>(0,d.jsxs)("button",{role:"tab","aria-selected":x===b.id,tabIndex:x===b.id?0:-1,onClick:()=>w(b.id),className:(0,g.cn)("flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all text-sm",x===b.id?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:b.icon}),(0,d.jsx)("span",{className:"hidden sm:inline whitespace-nowrap",children:a(b.labelKey)})]},b.id))})}),(0,d.jsxs)("div",{role:"tabpanel","aria-label":a(y.find(a=>a.id===x)?.labelKey||"general"),children:["general"===x&&(0,d.jsx)(d.Fragment,{children:(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(j.default,{}),(0,d.jsx)(o.default,{})]})}),"ai"===x&&(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(p.default,{}),(0,d.jsx)(q.default,{}),(0,d.jsx)(r.default,{}),(0,d.jsx)(u.default,{})]}),"security"===x&&(0,d.jsx)(k.default,{}),"routing"===x&&(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsx)(l.default,{}),(0,d.jsx)(m.default,{}),(0,d.jsx)(s.default,{}),(0,d.jsx)(t.default,{})]}),"resilience"===x&&(0,d.jsx)(v.default,{}),"advanced"===x&&(0,d.jsx)(n.default,{})]}),(0,d.jsxs)("div",{className:"text-center text-sm text-text-muted py-4",children:[(0,d.jsxs)("p",{children:[h.APP_CONFIG.name," v",h.APP_CONFIG.version]}),(0,d.jsx)("p",{className:"mt-1",children:a("localMode")})]})]})})}a.s(["default",()=>x]),c()}catch(a){c(a)}},!1)];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=src_app_%28dashboard%29_dashboard_settings_9e20fb8d._.js.map
|