@yina-npm/openrouterx 0.4.52 → 0.4.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -1245
- package/app/.next/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +2 -2
- package/app/.next/build-manifest.json +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/admin/keys/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/admin/users/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/focus-ui/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/network-analysis/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/user/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +1 -1
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error.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_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_not-found.html +1 -1
- package/app/.next/server/app/_not-found.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/api/keys/[id]/route.js +1 -1
- package/app/.next/server/app/api/models/route.js +1 -1
- package/app/.next/server/app/api/models/test/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
- package/app/.next/server/app/api/providers/route.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/app/.next/server/app/api/users/[id]/route.js +1 -1
- package/app/.next/server/app/api/users/route.js +1 -1
- package/app/.next/server/app/api/version/route.js +1 -1
- package/app/.next/server/app/api/version/shutdown/route.js +1 -1
- package/app/.next/server/app/api/version/update/route.js +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback.html +1 -1
- package/app/.next/server/app/callback.rsc +4 -4
- package/app/.next/server/app/callback.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/index.html +1 -1
- package/app/.next/server/app/index.rsc +4 -4
- package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing.html +1 -1
- package/app/.next/server/app/landing.rsc +4 -4
- package/app/.next/server/app/landing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login.html +1 -1
- package/app/.next/server/app/login.rsc +5 -5
- package/app/.next/server/app/login.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +2 -2
- package/app/.next/server/chunks/1350.js +1 -1
- package/app/.next/server/chunks/3110.js +1 -1
- package/app/.next/server/chunks/3493.js +1 -1
- package/app/.next/server/chunks/412.js +1 -1
- package/app/.next/server/chunks/7177.js +1 -1
- package/app/.next/server/chunks/7595.js +1 -1
- package/app/.next/server/chunks/7930.js +5 -2
- package/app/.next/server/chunks/8760.js +1 -1
- package/app/.next/server/chunks/9489.js +1 -1
- package/app/.next/server/chunks/9718.js +1 -1
- package/app/.next/server/middleware-build-manifest.js +1 -1
- package/app/.next/server/middleware.js +1 -1
- package/app/.next/server/pages/404.html +1 -1
- package/app/.next/server/pages/500.html +1 -1
- package/app/.next/static/chunks/1321-682ad944ed69404c.js +1 -0
- package/app/.next/static/chunks/4072-fdb34c3bf82582e6.js +6 -0
- package/app/.next/static/chunks/{5095-c2bb7e2fc99ab8c3.js → 5095-47fe70cd930f3c59.js} +2 -2
- package/app/.next/static/chunks/{5497-bebd4378b1048022.js → 5497-b59396fb56e7b9b1.js} +1 -1
- package/app/.next/static/css/{402ee8646e1afa89.css → 9b92fc8235e99d1e.css} +1 -1
- package/app/package.json +2 -2
- package/app/public/i18n/literals/ar.json +25 -1
- package/app/public/i18n/literals/bn.json +25 -1
- package/app/public/i18n/literals/cs.json +25 -1
- package/app/public/i18n/literals/da.json +25 -1
- package/app/public/i18n/literals/de.json +25 -1
- package/app/public/i18n/literals/el.json +25 -1
- package/app/public/i18n/literals/es.json +25 -1
- package/app/public/i18n/literals/fi.json +25 -1
- package/app/public/i18n/literals/fr.json +25 -1
- package/app/public/i18n/literals/he.json +25 -1
- package/app/public/i18n/literals/hi.json +25 -1
- package/app/public/i18n/literals/hu.json +25 -1
- package/app/public/i18n/literals/id.json +25 -1
- package/app/public/i18n/literals/it.json +25 -1
- package/app/public/i18n/literals/ja.json +25 -1
- package/app/public/i18n/literals/ko.json +25 -1
- package/app/public/i18n/literals/nl.json +25 -1
- package/app/public/i18n/literals/no.json +25 -1
- package/app/public/i18n/literals/pl.json +25 -1
- package/app/public/i18n/literals/pt-BR.json +25 -1
- package/app/public/i18n/literals/pt-PT.json +25 -1
- package/app/public/i18n/literals/ro.json +25 -1
- package/app/public/i18n/literals/ru.json +25 -1
- package/app/public/i18n/literals/sv.json +25 -1
- package/app/public/i18n/literals/th.json +25 -1
- package/app/public/i18n/literals/tl.json +25 -1
- package/app/public/i18n/literals/tr.json +25 -1
- package/app/public/i18n/literals/uk.json +25 -1
- package/app/public/i18n/literals/ur.json +25 -1
- package/app/public/i18n/literals/vi.json +25 -1
- package/app/public/i18n/literals/zh-CN.json +26 -1
- package/app/public/i18n/literals/zh-TW.json +25 -1
- package/package.json +2 -2
- package/app/.next/static/chunks/1321-621ed3470478397e.js +0 -1
- package/app/.next/static/chunks/4072-cc92fb1222a2752b.js +0 -3
- /package/app/.next/static/{Q5oB2dEL7XeWBhjwqT_vo → 4G6rOhJtfkDwKINMqIIf1}/_buildManifest.js +0 -0
- /package/app/.next/static/{Q5oB2dEL7XeWBhjwqT_vo → 4G6rOhJtfkDwKINMqIIf1}/_ssgManifest.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5095],{75095:(e,t,r)=>{r.d(t,{A:()=>y});var a=r(95155),s=r(12115),l=r(57250),i=r(45564);function n(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o({quotas:e=[],compact:t=!1}){if(!e||0===e.length)return null;let r=t?"py-1 px-1.5":"py-2 px-3",s=t?"text-[11px]":"text-sm",l=t?"text-[11px]":"text-sm",i=t?"text-[10px] leading-tight":"text-xs";return(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("table",{className:"w-full table-fixed text-left",children:(0,a.jsx)("tbody",{children:e.map((e,o)=>{let c=void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):n(e.used,e.total),d=c>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:c>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},u=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let s=Math.ceil(a/6e4);if(s<60)return`${s}m`;let l=Math.floor(s/60),i=s%60;if(l<24)return`${l}h ${i}m`;let n=Math.floor(l/24);return`${n}d ${l%24}h ${i}m`}catch(e){return"-"}}(e.resetAt),m=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(a);s.setDate(s.getDate()+1);let l="";l=t>=a&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let i=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${l}, ${i}`}catch{return null}}(e.resetAt);return(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:`${r} w-[30%]`,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:d.emoji}),(0,a.jsx)("span",{className:`${s} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${r} w-[45%]`,children:(0,a.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${d.bgLight} ${0===c?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${d.bg}`,style:{width:`${Math.min(c,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsxs)("span",{className:"text-text-muted",children:[e.used.toLocaleString()," / ",e.total>0?e.total.toLocaleString():"∞"]}),(0,a.jsxs)("span",{className:`font-medium ${d.text}`,children:[c,"%"]})]})]})}),(0,a.jsx)("td",{className:`${r} w-[25%]`,children:"-"!==u||m?t?(0,a.jsx)("div",{className:`${l} text-text-primary font-medium truncate`,title:m||"",children:"-"!==u?`in ${u}`:m}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==u&&(0,a.jsxs)("div",{className:`${l} text-text-primary font-medium`,children:["in ",u]}),m&&(0,a.jsx)("div",{className:`${i} text-text-muted`,children:m})]}):(0,a.jsx)("div",{className:`${l} text-text-muted italic`,children:"N/A"})})]},o)})})})})}var c=r(98542),d=r(84588),u=r(35497),m=r(52679),x=r(65921);let h=e=>m.wb.includes(e.provider)&&("oauth"===e.authType||m.jO.includes(e.provider)),p=Math.ceil(
|
|
2
|
-
Install: ${e.join(" or ")}`:"";throw Error(`${r.error||"Failed to activate Codex account"}${t}`)}let a=r.restart?.success?"Codex was restarted automatically.":r.restart?.reason?`Restart Codex manually: ${r.restart.reason}`:"Restart Codex to use it.",s=r.keychain?.success?"Keychain auth was updated.":r.keychain?.reason?`Keychain auth failed: ${r.keychain.reason}`:"",l=r.tokenWarning?` ${r.tokenWarning}`:"",i=`${r.account||e.email||e.name||"Account"} is now written to local Codex auth. ${s} ${a}${l}`.trim();r.keychain?.success&&r.restart?.success?eo.success(i,"Codex account activated"):eo.error(i,"Codex activation incomplete")}catch(e){eo.error(e.message||"Failed to activate Codex account","Codex activation failed")}finally{en(null)}}},[ei,eo]);(0,s.useEffect)(()=>{if(e)return;let t=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(e=>{!t&&e?.proxyPools&&V(e.proxyPools)}).catch(()=>{}),()=>{t=!0}},[e]);let ef=(0,s.useCallback)(async()=>{if(!I){M(!0),F(p);try{let e=(await em()).filter(h);await g(e,ex),O(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{M(!1)}}},[I,em,ex]);(0,s.useEffect)(()=>{(async()=>{U(!0);let e=await em();U(!1);let t=e.filter(h),r={};t.forEach(e=>{r[e.id]=!0}),E(r),await g(t,ex),O(new Date)})()},[]),(0,s.useEffect)(()=>{window.localStorage.setItem(b,String(P))},[P]),(0,s.useEffect)(()=>{if(!P){ed.current&&(clearInterval(ed.current),ed.current=null),eu.current&&(clearInterval(eu.current),eu.current=null);return}return ed.current=setInterval(()=>{ef()},1e3),eu.current=setInterval(()=>{F(e=>e<=1?p:e-1)},1e3),()=>{ed.current&&clearInterval(ed.current),eu.current&&clearInterval(eu.current)}},[P,ef]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(ed.current&&(clearInterval(ed.current),ed.current=null),eu.current&&(clearInterval(eu.current),eu.current=null)):P&&(ed.current=setInterval(ef,1e3),eu.current=setInterval(()=>{F(e=>e<=1?p:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[P,ef]);let eg=N.filter(h),ey=eg.filter(e=>"all"===X||e.provider===X),ev=e=>{let t=(C[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return t.length>0?Math.min(...t):1/0},ej=[...ey].sort((e,t)=>{if(j){let r=+(!1===e.isActive),a=+(!1===t.isActive);if(r!==a)return r-a}if(ee){let r=ev(e)-ev(t);if(0!==r)return r}let r=m.wb.indexOf(e.provider),a=m.wb.indexOf(t.provider);return r!==a?r-a:e.provider.localeCompare(t.provider)}),ew=Number.isFinite(w)&&w>0?Math.floor(w)*Math.max(1,Math.floor(k||1)):null,ek=ew?ej.slice(0,ew):ej,eN=e=>{let t=C[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=n(e.used,e.total))},e$=(0,s.useCallback)(async(e,t)=>{if(e.length&&!es){el(!0);try{await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}))),$(r=>r.map(r=>e.includes(r.id)?{...r,isActive:t}:r))}catch(e){console.error("Error bulk toggling connections:",e)}finally{el(!1)}}},[es]),eC=Array.from(new Set(eg.map(e=>e.provider))).sort(),eA="all"===X?"All providers":X;return(ej.length,Object.values(C).filter(e=>e?.quotas?.length>0).length,Object.values(C).reduce((e,t)=>t?.quotas?e+ +!!t.quotas.some(e=>30>n(e.used,e.total)&&e.total>0):e,0),_||0!==ej.length)?(0,a.jsxs)("div",{className:r?"space-y-4":"space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-3",children:(0,a.jsx)("h2",{className:"text-xl font-semibold text-text-primary",children:v})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>ea(e=>!e),className:"flex h-8 items-center justify-between gap-1 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-haspopup":"menu","aria-expanded":er,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===X?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(l.A,{src:`/providers/${X}.png`,alt:X,size:18,className:"size-[18px] rounded object-contain",fallbackText:X.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:eA})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),er&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>ea(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{Z("all"),ea(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===X?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===X&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:eC.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{Z(e),ea(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${X===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(l.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),X===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>et(e=>!e),className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${ee?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),!e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{e$(ej.filter(e=>(e.isActive??!0)&&eN(e)).map(e=>e.id),!1)},disabled:es,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota (within current filter)",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e$(ej.filter(e=>!(e.isActive??!0)&&!eN(e)).map(e=>e.id),!0)},disabled:es,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota (within current filter)",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn on Available"})]})]}),(0,a.jsxs)("button",{onClick:()=>D(e=>!e),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:P?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${P?"text-primary":"text-text-muted"}`,children:P?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),P&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",z,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:ef,disabled:I,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${I?"animate-spin":""}`,children:"refresh"})})]})]}),(0,a.jsx)("div",{className:f,children:ek.map(t=>{let r,s,i=C[t.id],n=S[t.id],u=q[t.id],m=!1===t.isActive,x=R===t.id||H===t.id,h=ei===t.id;return(0,a.jsxs)(d.default,{padding:"none",className:`min-w-0 ${m?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(l.A,{src:`/providers/${t.provider}.png`,alt:t.provider,size:32,className:"object-contain",fallbackText:t.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:t.provider}),(s=(r=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(t.email)?t.email:(r(t.name),t.name))?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:s}):null]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[ec&&"codex"===t.provider&&(0,a.jsxs)("button",{type:"button",onClick:()=>eb(t),disabled:x||h,className:"h-8 inline-flex items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs font-medium text-emerald-600 hover:bg-emerald-500/10 transition-colors disabled:opacity-50 dark:text-emerald-400",title:"Activate this account in local Codex",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${h?"animate-pulse":""}`,children:"key"}),(0,a.jsx)("span",{children:"Activate"})]}),!e&&(0,a.jsx)("div",{className:"inline-flex items-center",title:t.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(c.default,{size:"sm",checked:t.isActive??!0,disabled:x,onChange:e=>eh(t.id,e)})})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:n?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):u?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:u})]}):i?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:i.message})}):(0,a.jsx)(o,{quotas:i?.quotas,compact:!0})})]},t.id)})}),!e&&(0,a.jsx)(u.wI,{isOpen:W,connection:Y,proxyPools:Q,onSave:ep,onClose:()=>{G(!1),B(null)}})]}):(0,a.jsx)(d.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5095],{75095:(e,t,r)=>{r.d(t,{A:()=>y});var a=r(95155),s=r(12115),l=r(57250),i=r(45564);function n(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o({quotas:e=[],compact:t=!1}){if(!e||0===e.length)return null;let r=t?"py-1 px-1.5":"py-2 px-3",s=t?"text-[11px]":"text-sm",l=t?"text-[11px]":"text-sm",i=t?"text-[10px] leading-tight":"text-xs";return(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("table",{className:"w-full table-fixed text-left",children:(0,a.jsx)("tbody",{children:e.map((e,o)=>{let c=void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):n(e.used,e.total),d=c>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:c>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},u=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let s=Math.ceil(a/6e4);if(s<60)return`${s}m`;let l=Math.floor(s/60),i=s%60;if(l<24)return`${l}h ${i}m`;let n=Math.floor(l/24);return`${n}d ${l%24}h ${i}m`}catch(e){return"-"}}(e.resetAt),m=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(a);s.setDate(s.getDate()+1);let l="";l=t>=a&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let i=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${l}, ${i}`}catch{return null}}(e.resetAt);return(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:`${r} w-[30%]`,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:d.emoji}),(0,a.jsx)("span",{className:`${s} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${r} w-[45%]`,children:(0,a.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${d.bgLight} ${0===c?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${d.bg}`,style:{width:`${Math.min(c,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsxs)("span",{className:"text-text-muted",children:[e.used.toLocaleString()," / ",e.total>0?e.total.toLocaleString():"∞"]}),(0,a.jsxs)("span",{className:`font-medium ${d.text}`,children:[c,"%"]})]})]})}),(0,a.jsx)("td",{className:`${r} w-[25%]`,children:"-"!==u||m?t?(0,a.jsx)("div",{className:`${l} text-text-primary font-medium truncate`,title:m||"",children:"-"!==u?`in ${u}`:m}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==u&&(0,a.jsxs)("div",{className:`${l} text-text-primary font-medium`,children:["in ",u]}),m&&(0,a.jsx)("div",{className:`${i} text-text-muted`,children:m})]}):(0,a.jsx)("div",{className:`${l} text-text-muted italic`,children:"N/A"})})]},o)})})})})}var c=r(98542),d=r(84588),u=r(35497),m=r(52679),x=r(65921);let h=e=>m.wb.includes(e.provider)&&("oauth"===e.authType||m.jO.includes(e.provider)),p=Math.ceil(300),b="quotaAutoRefresh",f=e=>new Promise(t=>setTimeout(t,e));async function g(e,t){for(let r=0;r<e.length;r+=1){r>0&&await f(1e3);let a=e[r];await t(a.id,a.provider)}}function y({readOnly:e=!1,allowCodexActivation:t=!1,embedded:r=!1,gridClassName:f="grid grid-cols-1 md:grid-cols-2 gap-3",title:v="Provider Limits",activeFirst:j=!1,maxRows:w=null,maxColumns:k=4}){let[N,$]=(0,s.useState)([]),[C,A]=(0,s.useState)({}),[S,E]=(0,s.useState)({}),[q,T]=(0,s.useState)({}),[P,D]=(0,s.useState)(()=>{let e=window.localStorage.getItem(b);return null===e||"true"===e}),[L,O]=(0,s.useState)(null),[I,M]=(0,s.useState)(!1),[z,F]=(0,s.useState)(p),[_,U]=(0,s.useState)(!0),[R,K]=(0,s.useState)(null),[H,J]=(0,s.useState)(null),[W,G]=(0,s.useState)(!1),[Y,B]=(0,s.useState)(null),[Q,V]=(0,s.useState)([]),[X,Z]=(0,s.useState)("all"),[ee,et]=(0,s.useState)(!1),[er,ea]=(0,s.useState)(!1),[es,el]=(0,s.useState)(!1),[ei,en]=(0,s.useState)(null),eo=(0,x.i)(),ec=!e||t,ed=(0,s.useRef)(null),eu=(0,s.useRef)(null),em=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/providers/client");if(!e.ok)throw Error("Failed to fetch connections");let t=(await e.json()).connections||[];return $(t),t}catch(e){return console.error("Error fetching connections:",e),$([]),[]}},[]),ex=(0,s.useCallback)(async(e,t)=>{E(t=>({...t,[e]:!0})),T(t=>({...t,[e]:null}));try{console.log(`[ProviderLimits] Fetching quota for ${t} (${e})`);let r=await fetch(`/api/usage/${e}`);if(!r.ok){let a=(await r.json().catch(()=>({}))).error||r.statusText;if(404===r.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===r.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,a),A(t=>({...t,[e]:{quotas:[],message:a}}));return}throw Error(`HTTP ${r.status}: ${a}`)}let a=await r.json();console.log(`[ProviderLimits] Got quota for ${t}:`,a);let s=function(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"claude":t.message?r.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,i.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let a=t.modelKey||t.name,s=r.modelKey||r.name;return(e.get(a)??999)-(e.get(s)??999)})}return r}(t,a);A(t=>({...t,[e]:{quotas:s,plan:a.plan||null,message:a.message||null,raw:a}}))}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),T(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{E(t=>({...t,[e]:!1}))}},[]);(0,s.useCallback)(async(e,t)=>{await ex(e,t),O(new Date)},[ex]),(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){K(e);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&($(t=>t.filter(t=>t.id!==e)),A(t=>{let r={...t};return delete r[e],r}),E(t=>{let r={...t};return delete r[e],r}),T(t=>{let r={...t};return delete r[e],r}))}catch(e){console.error("Error deleting connection:",e)}finally{K(null)}}},[]);let eh=(0,s.useCallback)(async(e,t)=>{J(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&$(r=>r.map(r=>r.id===e?{...r,isActive:t}:r))}catch(e){console.error("Error updating connection status:",e)}finally{J(null)}},[]),ep=(0,s.useCallback)(async e=>{if(!Y?.id)return;let t=Y.id,r=Y.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await em(),G(!1),B(null),m.wb.includes(r)&&await ex(t,r))}catch(e){console.error("Error saving connection:",e)}},[Y,em,ex]),eb=(0,s.useCallback)(async e=>{if(e?.id&&!ei){en(e.id);try{let t=await fetch("/api/cli-tools/codex-settings/activate-account",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e.id,restartCodex:!0})}),r=await t.json().catch(()=>({}));if(!t.ok){let e=Array.isArray(r.installHints)&&r.installHints.length>0?r.installHints:r.installCommand?[r.installCommand]:[],t=e.length?`
|
|
2
|
+
Install: ${e.join(" or ")}`:"";throw Error(`${r.error||"Failed to activate Codex account"}${t}`)}let a=r.restart?.success?"Codex was restarted automatically.":r.restart?.reason?`Restart Codex manually: ${r.restart.reason}`:"Restart Codex to use it.",s=r.keychain?.success?"Keychain auth was updated.":r.keychain?.reason?`Keychain auth failed: ${r.keychain.reason}`:"",l=r.tokenWarning?` ${r.tokenWarning}`:"",i=`${r.account||e.email||e.name||"Account"} is now written to local Codex auth. ${s} ${a}${l}`.trim();r.keychain?.success&&r.restart?.success?eo.success(i,"Codex account activated"):eo.error(i,"Codex activation incomplete")}catch(e){eo.error(e.message||"Failed to activate Codex account","Codex activation failed")}finally{en(null)}}},[ei,eo]);(0,s.useEffect)(()=>{if(e)return;let t=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(e=>{!t&&e?.proxyPools&&V(e.proxyPools)}).catch(()=>{}),()=>{t=!0}},[e]);let ef=(0,s.useCallback)(async()=>{if(!I){M(!0),F(p);try{let e=(await em()).filter(h);await g(e,ex),O(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{M(!1)}}},[I,em,ex]);(0,s.useEffect)(()=>{(async()=>{U(!0);let e=await em();U(!1);let t=e.filter(h),r={};t.forEach(e=>{r[e.id]=!0}),E(r),await g(t,ex),O(new Date)})()},[]),(0,s.useEffect)(()=>{window.localStorage.setItem(b,String(P))},[P]),(0,s.useEffect)(()=>{if(!P){ed.current&&(clearInterval(ed.current),ed.current=null),eu.current&&(clearInterval(eu.current),eu.current=null);return}return ed.current=setInterval(()=>{ef()},3e5),eu.current=setInterval(()=>{F(e=>e<=1?p:e-1)},1e3),()=>{ed.current&&clearInterval(ed.current),eu.current&&clearInterval(eu.current)}},[P,ef]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(ed.current&&(clearInterval(ed.current),ed.current=null),eu.current&&(clearInterval(eu.current),eu.current=null)):P&&(ed.current=setInterval(ef,3e5),eu.current=setInterval(()=>{F(e=>e<=1?p:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[P,ef]);let eg=N.filter(h),ey=eg.filter(e=>"all"===X||e.provider===X),ev=e=>{let t=(C[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return t.length>0?Math.min(...t):1/0},ej=[...ey].sort((e,t)=>{if(j){let r=+(!1===e.isActive),a=+(!1===t.isActive);if(r!==a)return r-a}if(ee){let r=ev(e)-ev(t);if(0!==r)return r}let r=m.wb.indexOf(e.provider),a=m.wb.indexOf(t.provider);return r!==a?r-a:e.provider.localeCompare(t.provider)}),ew=Number.isFinite(w)&&w>0?Math.floor(w)*Math.max(1,Math.floor(k||1)):null,ek=ew?ej.slice(0,ew):ej,eN=e=>{let t=C[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=n(e.used,e.total))},e$=(0,s.useCallback)(async(e,t)=>{if(e.length&&!es){el(!0);try{await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}))),$(r=>r.map(r=>e.includes(r.id)?{...r,isActive:t}:r))}catch(e){console.error("Error bulk toggling connections:",e)}finally{el(!1)}}},[es]),eC=Array.from(new Set(eg.map(e=>e.provider))).sort(),eA="all"===X?"All providers":X;return(ej.length,Object.values(C).filter(e=>e?.quotas?.length>0).length,Object.values(C).reduce((e,t)=>t?.quotas?e+ +!!t.quotas.some(e=>30>n(e.used,e.total)&&e.total>0):e,0),_||0!==ej.length)?(0,a.jsxs)("div",{className:r?"space-y-4":"space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-3",children:(0,a.jsx)("h2",{className:"text-xl font-semibold text-text-primary",children:v})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>ea(e=>!e),className:"flex h-8 items-center justify-between gap-1 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-haspopup":"menu","aria-expanded":er,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===X?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(l.A,{src:`/providers/${X}.png`,alt:X,size:18,className:"size-[18px] rounded object-contain",fallbackText:X.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:eA})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),er&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>ea(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{Z("all"),ea(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===X?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===X&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:eC.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{Z(e),ea(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${X===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(l.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),X===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>et(e=>!e),className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${ee?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),!e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{e$(ej.filter(e=>(e.isActive??!0)&&eN(e)).map(e=>e.id),!1)},disabled:es,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota (within current filter)",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e$(ej.filter(e=>!(e.isActive??!0)&&!eN(e)).map(e=>e.id),!0)},disabled:es,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota (within current filter)",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn on Available"})]})]}),(0,a.jsxs)("button",{onClick:()=>D(e=>!e),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:P?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${P?"text-primary":"text-text-muted"}`,children:P?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),P&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",z,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:ef,disabled:I,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${I?"animate-spin":""}`,children:"refresh"})})]})]}),(0,a.jsx)("div",{className:f,children:ek.map(t=>{let r,s,i=C[t.id],n=S[t.id],u=q[t.id],m=!1===t.isActive,x=R===t.id||H===t.id,h=ei===t.id;return(0,a.jsxs)(d.default,{padding:"none",className:`min-w-0 ${m?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(l.A,{src:`/providers/${t.provider}.png`,alt:t.provider,size:32,className:"object-contain",fallbackText:t.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:t.provider}),(s=(r=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(t.email)?t.email:(r(t.name),t.name))?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:s}):null]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[ec&&"codex"===t.provider&&(0,a.jsxs)("button",{type:"button",onClick:()=>eb(t),disabled:x||h,className:"h-8 inline-flex items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs font-medium text-emerald-600 hover:bg-emerald-500/10 transition-colors disabled:opacity-50 dark:text-emerald-400",title:"Activate this account in local Codex",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${h?"animate-pulse":""}`,children:"key"}),(0,a.jsx)("span",{children:"Activate"})]}),!e&&(0,a.jsx)("div",{className:"inline-flex items-center",title:t.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(c.default,{size:"sm",checked:t.isActive??!0,disabled:x,onChange:e=>eh(t.id,e)})})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:n?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):u?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:u})]}):i?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:i.message})}):(0,a.jsx)(o,{quotas:i?.quotas,compact:!0})})]},t.id)})}),!e&&(0,a.jsx)(u.wI,{isOpen:W,connection:Y,proxyPools:Q,onSave:ep,onClose:()=>{G(!1),B(null)}})]}):(0,a.jsx)(d.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}}]);
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
`,children:[g.includes(e.name)&&(0,r.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),e.name]},e.id)})})]}),Object.entries(L).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,r.jsx)(o.A,{src:`/providers/${e}.png`,alt:t.name,size:14,fallbackText:(t.name||e).slice(0,2).toUpperCase(),fallbackColor:t.color}),(0,r.jsx)("span",{className:"text-xs font-medium text-primary",children:t.name}),(0,r.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",t.models.length,")"]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(e=>{let t=n===e.value,s=e.isPlaceholder;return(0,r.jsx)("button",{onClick:()=>_(e),title:s?"Select to pre-fill, then edit model ID in the input":void 0,className:`
|
|
5
5
|
px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
|
|
6
6
|
${s?"border-dashed border-border text-text-muted hover:border-primary/50 hover:text-primary bg-surface italic":t?"bg-primary text-white border-primary":g.includes(e.value)?"bg-primary border-primary text-white hover:bg-primary-hover":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
|
|
7
|
-
`,children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[g.includes(e.value)&&!s&&(0,r.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,r.jsxs)(r.Fragment,{children:[e.name,(0,r.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name]})},e.value)})})]},e)),0===Object.keys(L).length&&0===U.length&&(0,r.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,r.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}u.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,onDeselect:n().func,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object,kindFilter:n().string,addedModelValues:n().arrayOf(n().string),closeOnSelect:n().bool}},73579:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(81127),o=s(11910),d=s(92542),c=s(56061),m=s(52679);function x({isOpen:e,connection:t,proxyPools:s,onSave:l,onClose:n}){let[u,p]=(0,a.useState)({name:"",priority:1,apiKey:""}),[h,f]=(0,a.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[b,g]=(0,a.useState)({accountId:""}),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)(null),[w,k]=(0,a.useState)(!1),[C,S]=(0,a.useState)(null),[T,O]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData&&f({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}),"cloudflare-ai"===t.provider&&t.providerSpecificData&&g({accountId:t.providerSpecificData.accountId||""}),N(null),S(null))},[t]);let P=t?.authType==="oauth",$=t?.provider==="azure",E=t?.provider==="cloudflare-ai",I=!!t&&((0,m.mq)(t.provider)||(0,m.gb)(t.provider)),R=async()=>{if(t?.provider){y(!0),N(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),s=await e.json();N(s.valid?"success":"failed")}catch{N("failed")}finally{y(!1)}}},A=async()=>{if(t?.provider&&u.apiKey){k(!0),S(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:u.apiKey,...$?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})}),s=await e.json();S(s.valid?"success":"failed")}catch{S("failed")}finally{k(!1)}}},z=async()=>{if(t){O(!0);try{let e={name:u.name,priority:u.priority};if(!P&&u.apiKey){e.apiKey=u.apiKey;let s="success"===C;if(!s)try{k(!0),S(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:u.apiKey,...$?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})});s=!!(await e.json()).valid,S(s?"success":"failed")}catch{S("failed")}finally{k(!1)}s&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}$&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),E&&(e.providerSpecificData={accountId:b.accountId}),await l(e)}finally{O(!1)}}};return t?(0,r.jsx)(i.default,{isOpen:e,title:"Edit Connection",onClose:n,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(o.default,{label:"Name",value:u.name,onChange:e=>p({...u,name:e.target.value}),placeholder:P?"Account name":"Production Key"}),P&&t.email&&(0,r.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,r.jsx)("p",{className:"font-medium",children:t.email})]}),(0,r.jsx)(o.default,{label:"Priority",type:"number",value:u.priority,onChange:e=>p({...u,priority:Number.parseInt(e.target.value,10)||1})}),!P&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{label:"API Key",type:"password",value:u.apiKey,onChange:e=>p({...u,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,r.jsx)("div",{className:"pt-6",children:(0,r.jsx)(d.default,{onClick:A,disabled:!u.apiKey||w||T,variant:"secondary",children:w?"Checking...":"Check"})})]}),C&&(0,r.jsx)(c.default,{variant:"success"===C?"success":"error",children:"success"===C?"Valid":"Invalid"})]}),$&&(0,r.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,r.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>f({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,r.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>f({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,r.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>f({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,r.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>f({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),!I&&!$&&!E&&(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(d.default,{onClick:R,variant:"secondary",disabled:j,children:j?"Testing...":"Test Connection"}),v&&(0,r.jsx)(c.default,{variant:"success"===v?"success":"error",children:"success"===v?"Valid":"Failed"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(d.default,{onClick:z,fullWidth:!0,disabled:T,children:T?"Saving...":"Save"}),(0,r.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}x.propTypes={isOpen:n().bool.isRequired,connection:n().shape({id:n().string,name:n().string,email:n().string,priority:n().number,authType:n().string,provider:n().string,providerSpecificData:n().object}),proxyPools:n().arrayOf(n().shape({id:n().string,name:n().string})),onSave:n().func.isRequired,onClose:n().func.isRequired}},74891:(e,t,s)=>{s.d(t,{default:()=>b});var r=s(95155),a=s(12115),l=s(73321),n=s(98500),i=s.n(n),o=s(14051),d=s.n(o),c=s(57250),m=s(80752),x=s(38587),u=s(38003),p=s(90620),h=s(52679),f=s(73006);function b({onMenuClick:e,showMenuButton:t=!0}){let s=(0,l.usePathname)(),n=(0,l.useRouter)(),[o,d]=(0,a.useState)(""),[u,j]=(0,a.useState)(""),{title:y,description:v,icon:N,breadcrumbs:w}=(0,a.useMemo)(()=>(e=>{if(!e)return{title:"",description:"",breadcrumbs:[]};let t=e.match(/\/media-providers\/([^/]+)\/([^/]+)$/);if(t){let e=t[1],s=t[2],r=h.rj.find(t=>t.id===e),a=h.Q2[s];return{title:a?.name||s,description:"",breadcrumbs:[{label:"Media Providers",href:`/dashboard/media-providers/${e}`},{label:r?.label||e,href:`/dashboard/media-providers/${e}`},{label:a?.name||s,image:`/providers/${s}.png`}]}}let s=e.match(/\/media-providers\/([^/]+)$/);if(s){let e=s[1],t=h.rj.find(t=>t.id===e);return{title:t?.label||e,description:`Manage your ${t?.label||e} providers`,icon:t?.icon||"perm_media",breadcrumbs:[]}}let r=e.match(/\/providers\/([^/]+)$/);if(r){let e=r[1],t=p.zN[e]||p.fg[e];if(t)return{title:t.name,description:"",breadcrumbs:[{label:"Providers",href:"/dashboard/providers"},{label:t.name,image:`/providers/${t.id}.png`}]}}return e.includes("/providers")&&!e.includes("/media-providers")?{title:"Providers",description:"Manage your AI provider connections",icon:"dns",breadcrumbs:[]}:e.includes("/combos")?{title:"Combos",description:"Model combos with fallback",icon:"layers",breadcrumbs:[]}:e.includes("/usage")?{title:"Usage & Analytics",description:"Monitor your API usage, token consumption, and request logs",icon:"bar_chart",breadcrumbs:[]}:e.includes("/auth-files")?{title:"Auth Files",description:"Map provider credentials stored in the local database",icon:"vpn_key",breadcrumbs:[]}:e.includes("/quota")?{title:"Quota Tracker",description:"Track and manage your API quota limits",icon:"data_usage",breadcrumbs:[]}:e.includes("/mitm")?{title:"MITM Proxy",description:"Intercept CLI tool traffic and route through OpenrouterX",icon:"security",breadcrumbs:[]}:e.includes("/focus-ui")?{title:"Focus UI",description:"Monitor MITM status, quota, and realtime logs in one place",icon:"visibility",breadcrumbs:[]}:e.includes("/cli-tools")?{title:"CLI Tools",description:"Configure CLI tools",icon:"terminal",breadcrumbs:[]}:e.includes("/proxy-pools")?{title:"Proxy Pools",description:"Manage your proxy pool configurations",icon:"lan",breadcrumbs:[]}:e.includes("/network-analysis")?{title:"Network Analysis",description:"Diagnose local connectivity, proxy, DNS, and MITM network impact",icon:"network_check",breadcrumbs:[]}:e.includes("/skills")?{title:"Agent Skills",description:"Copy a link and paste to your AI to use OpenrouterX — no install needed",icon:"extension",breadcrumbs:[]}:e.includes("/endpoint")?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:e.includes("/profile")?{title:"Settings",description:"Manage your preferences",icon:"settings",breadcrumbs:[]}:e.includes("/console-log")?{title:"Console Log",description:"Live server console output",icon:"monitor",breadcrumbs:[]}:"/dashboard"===e?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}})(s),[s]);(0,a.useEffect)(()=>{let e=!1;return async function(){try{let t=await fetch("/api/auth/status",{cache:"no-store"});if(!t.ok)return;let s=await t.json();e||(d(s?.displayName||s?.oidcName||s?.oidcEmail||""),j(s?.loginMethod||""))}catch{e||(d(""),j(""))}}(),()=>{e=!0}},[]);let k=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(n.push("/login"),n.refresh())}catch(e){console.error("Failed to logout:",e)}};return(0,r.jsxs)("header",{className:"shrink-0 flex items-center justify-between gap-3 px-4 lg:px-8 pt-3 pb-2 border-b border-border-subtle bg-surface/60 backdrop-blur-xl lg:bg-transparent lg:backdrop-blur-none z-20",children:[(0,r.jsx)("div",{className:"flex items-center gap-3 lg:hidden shrink-0",children:t&&(0,r.jsx)("button",{onClick:e,className:"text-text-main hover:text-primary transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"menu"})})}),(0,r.jsx)("div",{className:"flex flex-col min-w-0 flex-1",children:w.length>0?(0,r.jsx)("div",{className:"flex items-center gap-2",children:w.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[t>0&&(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-base",children:"chevron_right"}),e.href?(0,r.jsx)(i(),{href:e.href,className:"text-text-muted hover:text-primary transition-colors",children:e.label}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.image&&(0,r.jsx)(c.A,{src:e.image,alt:e.label,size:28,className:"object-contain rounded max-w-[28px] max-h-[28px]",fallbackText:e.label.slice(0,2).toUpperCase()}),(0,r.jsx)("h1",{className:"text-base lg:text-2xl font-semibold text-text-main tracking-tight truncate",children:(0,f.Tl)(e.label)})]})]},`${e.label}-${e.href||"current"}`))}):y?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[N&&(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-xl lg:text-2xl",children:N}),(0,r.jsx)("h1",{className:"text-base lg:text-2xl font-semibold tracking-tight truncate",children:(0,f.Tl)(y)})]}),v&&(0,r.jsx)("p",{className:"hidden lg:block text-sm text-text-muted truncate",children:(0,f.Tl)(v)})]}):null}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[o&&"OIDC"===u&&(0,r.jsxs)("div",{className:"hidden sm:flex items-center max-w-[220px] px-3 py-1.5 rounded-full border border-border bg-surface/70 text-xs text-text-muted truncate",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1.5 text-primary",children:"person"}),(0,r.jsx)("span",{className:"truncate",children:o}),(0,r.jsx)("span",{className:"ml-2 shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary",children:"OIDC"})]}),(0,r.jsx)(g,{}),(0,r.jsx)(x.default,{}),(0,r.jsx)(m.default,{onLogout:k})]})]})}function g(){let e=(0,u.C)(e=>e.visible),t=(0,u.C)(e=>e.query),s=(0,u.C)(e=>e.placeholder),a=(0,u.C)(e=>e.setQuery);return e?(0,r.jsxs)("div",{className:"relative w-[160px] sm:w-[220px]",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-2 top-1/2 -translate-y-1/2 text-text-muted text-[16px] pointer-events-none",children:"search"}),(0,r.jsx)("input",{type:"text",value:t,onChange:e=>a(e.target.value),placeholder:s,className:"w-full h-8 pl-7 pr-7 rounded-lg border border-border bg-surface/60 text-sm focus:outline-none focus:border-primary/50 transition-colors"}),t&&(0,r.jsx)("button",{type:"button",onClick:()=>a(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-main p-0.5 rounded","aria-label":"Clear search",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}b.propTypes={onMenuClick:d().func,showMenuButton:d().bool}},80752:(e,t,s)=>{s.d(t,{default:()=>f});var r=s(95155),a=s(12115),l=s(73321),n=s(14051),i=s.n(n),o=s(93308),d=s(1620),c=s(95892),m=s(40197),x=s(14932),u=s(21931);let p={en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (BR)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (PT)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}};function h({icon:e,label:t,onClick:s,trailing:a,danger:l}){return(0,r.jsxs)("button",{onClick:s,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${l?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[20px] ${l?"":"text-text-muted"}`,children:e}),(0,r.jsx)("span",{className:"flex-1 text-left",children:t}),a&&(0,r.jsx)("span",{className:"text-base",children:a})]})}function f({onLogout:e}){let[t,s]=(0,a.useState)(!1),[n,i]=(0,a.useState)(!1),[b,g]=(0,a.useState)(!1),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)("en"),w=(0,l.useRouter)(),{toggleTheme:k,isDark:C}=(0,d.D)(),{role:S}=(0,c.hd)(),[T,O]=(0,a.useState)(null),P=(0,a.useRef)(null),$="sub_user"===(T||S||null);return(0,a.useEffect)(()=>{N(function(){if("u"<typeof document)return"en";let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${o.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):"en";return(0,o.QC)(t)}())},[j]),(0,a.useEffect)(()=>{S&&O(S)},[S]),(0,a.useEffect)(()=>{fetch("/api/auth/me").then(e=>e.json()).then(e=>{e?.role&&O(e.role)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&s(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",ref:P,children:[(0,r.jsx)("button",{onClick:()=>s(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[$&&(0,r.jsx)(h,{icon:"dashboard",label:"Dashboard",onClick:()=>{s(!1),w.push("/dashboard")}}),$&&(0,r.jsx)(h,{icon:"terminal",label:"CLI Tools",onClick:()=>{s(!1),w.push("/dashboard/cli-tools")}}),!$&&(0,r.jsx)(h,{icon:"history",label:"Change Log",onClick:()=>{s(!1),i(!0)}}),(0,r.jsx)(h,{icon:"language",label:p[v]?.name||v,trailing:p[v]?.flag||"\uD83C\uDF10",onClick:()=>{s(!1),y(!0)}}),!$&&(0,r.jsx)(h,{icon:C?"light_mode":"dark_mode",label:"Theme",onClick:()=>{k(),s(!1)}}),!$&&(0,r.jsx)(h,{icon:"computer",label:"Remote",onClick:()=>{s(!1),g(!0)}}),(0,r.jsx)(h,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{s(!1),e()}})]})]}),(0,r.jsx)(m.default,{isOpen:n,onClose:()=>i(!1)}),(0,r.jsx)(x.A,{isOpen:b,onClose:()=>g(!1)}),(0,r.jsx)(u.default,{hideTrigger:!0,isOpen:j,onClose:()=>y(!1)})]})}h.propTypes={icon:i().string.isRequired,label:i().string.isRequired,onClick:i().func.isRequired,trailing:i().node,danger:i().bool},f.propTypes={onLogout:i().func.isRequired}},81127:(e,t,s)=>{s.d(t,{ConfirmModal:()=>d,default:()=>o});var r=s(95155),a=s(12115),l=s(31474),n=s(92542),i=s(97677);function o({isOpen:e,onClose:t,title:s,children:n,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:x=!0,className:u}){return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,r.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],u),children:[(s||x)&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[x&&(0,r.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,r.jsx)(i.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,r.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,r.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,r.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,r.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),s&&(0,r.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})]}),(0,r.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,r.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:n}),d&&(0,r.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:s,title:a="Confirm",message:l,confirmText:i="Confirm",cancelText:c="Cancel",variant:m="danger",loading:x=!1}){return(0,r.jsx)(o,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.default,{variant:"ghost",onClick:t,disabled:x,children:c}),(0,r.jsx)(n.default,{variant:m,onClick:s,loading:x,children:i})]}),children:(0,r.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({children:e,title:t,subtitle:s,icon:n,action:i,padding:o="md",hover:d=!1,elev:c=!1,className:m,...x}){return(0,r.jsxs)("div",{className:(0,a.cn)("bg-surface border border-border-subtle",c?"rounded-[14px] shadow-[var(--shadow-elev)]":"rounded-[14px] shadow-[var(--shadow-soft)]",d&&"hover:shadow-[var(--shadow-warm)] hover:border-brand-500/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[o],m),...x,children:[(t||i)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,r.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,r.jsxs)("div",{children:[t&&(0,r.jsx)("h3",{className:"text-text-main font-semibold",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:s})]})]}),i]}),e]})}l.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",t),...s,children:e})},l.Row=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",t),...s,children:e})},l.ListItem=function({children:e,actions:t,className:s,...l}){return(0,r.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",s),...l,children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},90882:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,providerInfo:s,onSuccess:l,onClose:n,oauthMeta:c,idcConfig:m}){let[x,u]=(0,a.useState)("waiting"),[p,h]=(0,a.useState)(null),[f,b]=(0,a.useState)(""),[g,j]=(0,a.useState)(""),[y,v]=(0,a.useState)(null),[N,w]=(0,a.useState)(!1),[k,C]=(0,a.useState)(null),[S,T]=(0,a.useState)(!1),O=(0,a.useRef)(null),P=(0,a.useRef)(!1),{copied:$,copy:E}=(0,o.C)(),[I,R]=(0,a.useState)(!1),[A,z]=(0,a.useState)("/callback?code=..."),M=(0,a.useRef)(!1);(0,a.useEffect)(()=>{R("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),z(`${window.location.origin}/callback?code=...`)},[]);let U=(0,a.useCallback)(async(e,s)=>{if(p)try{let r=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:p.redirectUri,codeVerifier:p.codeVerifier,state:s,...c?{meta:c}:{}})}),a=await r.json();if(!r.ok)throw Error(a.error);u("success"),l?.()}catch(e){v(e.message),u("error")}},[p,t,l]),L=(0,a.useCallback)(async(e,s,r,a)=>{P.current=!1,T(!0);for(let n=0;n<60;n++){if(P.current){console.log("[OAuthModal] Polling aborted"),T(!1);return}if(await new Promise(e=>setTimeout(e,1e3*r)),P.current){console.log("[OAuthModal] Polling aborted after sleep"),T(!1);return}try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:a})}),i=await n.json();if(i.success){P.current=!0,u("success"),T(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(r=Math.min(r+5,30))}catch(e){v(e.message),u("error"),T(!1);return}}v("Authorization timeout"),u("error"),T(!1)},[t,l]),_=(0,a.useCallback)(async()=>{if(t)try{let e;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy"].includes(t)){w(!0),u("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&m?.startUrl&&(e.searchParams.set("start_url",m.startUrl),m.region&&e.searchParams.set("region",m.region),e.searchParams.set("auth_method","idc"));let s=await fetch(e.toString()),r=await s.json();if(!s.ok)throw Error(r.error);C(r);let a=r.verification_uri_complete||r.verification_uri;a&&window.open(a,"_blank","noopener,noreferrer");let l="kiro"===t?{_clientId:r._clientId,_clientSecret:r._clientSecret,_region:r._region,_authMethod:r._authMethod,_startUrl:r._startUrl}:null;L(r.device_code,r.codeVerifier,r.interval||5,l);return}let s=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":`http://localhost:${s}/callback`;let r=new URL(`/api/oauth/${t}/authorize`,window.location.origin);r.searchParams.set("redirect_uri",e),c&&Object.entries(c).forEach(([e,t])=>{t&&r.searchParams.set(e,t)});let a=await fetch(r.toString()),l=await a.json();if(!a.ok)throw Error(l.error);let n=!1,i=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",s),t.searchParams.set("state",l.state),t.searchParams.set("code_verifier",l.codeVerifier),t.searchParams.set("redirect_uri",e);let r=await fetch(t.toString()),a=await r.json();n=a.success,i=!!a.serverSide}catch{n=!1}h({...l,redirectUri:e,codexServerSide:i}),"codex"===t&&n||I&&"codex"!==t?(u("waiting"),O.current=window.open(l.authUrl,"oauth_popup","width=600,height=700"),O.current||u("input")):(u("input"),window.open(l.authUrl,"_blank"))}catch(e){v(e.message),u("error")}},[t,I,L,c,m]);(0,a.useEffect)(()=>{e&&t?(h(null),b(""),v(null),w(!1),C(null),T(!1),j(""),P.current=!1,_()):e||(P.current=!0,"codex"===t&&fetch("/api/oauth/codex/stop-proxy").catch(()=>{}))},[e,t,_]),(0,a.useEffect)(()=>{if(!p?.codexServerSide||!p?.state||M.current)return;let e=!1,t=0,s=async()=>{if(!e&&!M.current){t+=1;try{let t=await fetch(`/api/oauth/codex/poll-status?state=${encodeURIComponent(p.state)}`),s=await t.json();if(e||M.current)return;if("done"===s.status){M.current=!0,u("success"),l?.();return}if("error"===s.status){M.current=!0,v(s.error||"Authentication failed"),u("error");return}}catch{}if(t>=200){M.current=!0,v("Authentication timeout"),u("error");return}setTimeout(s,1500)}};return setTimeout(s,1500),()=>{e=!0}},[p,l]),(0,a.useEffect)(()=>{let e;if(!p)return;M.current=!1;let t=async e=>{if(M.current)return;let{code:t,state:s,error:r,errorDescription:a}=e;if(r){M.current=!0,v(a||r),u("error");return}t&&(M.current=!0,await U(t,s))},s=e=>{let s=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),r=e.origin===window.location.origin;(s||r)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let r=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",r);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&t(s),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",r),e&&e.close()}},[p,U]);let q=async()=>{try{v(null);let e=f.trim(),t=new URL(e),s=t.searchParams.get("code"),r=t.searchParams.get("state"),a=t.searchParams.get("error");if(a)throw Error(t.searchParams.get("error_description")||a);if(!s)throw Error("No authorization code found in URL");await U(s,r)}catch(e){v(e.message),u("error")}},F=async()=>{try{let e;v(null);let s=g.trim();if(!s)throw Error("Please paste the session JSON first");try{e=JSON.parse(s)}catch(e){throw Error("Invalid JSON format")}if(!e.accessToken||!e.sessionToken)throw Error("JSON must contain accessToken and sessionToken");let r=await fetch(`/api/oauth/${t}/import-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await r.json();if(!r.ok)throw Error(a.error);u("success"),l?.()}catch(e){v(e.message),u("error")}},D=(0,a.useCallback)(()=>{"codex"===t&&fetch("/api/oauth/codex/stop-proxy").catch(()=>{}),n()},[n,t]);if(!t||!s)return null;let W=k?.verification_uri_complete||k?.verification_uri||"";return(0,r.jsx)(i.aF,{isOpen:e,title:`Connect ${s.name}`,onClose:D,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===x&&!N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,r.jsx)("span",{className:"text-sm",children:"Waiting for popup authorization…"})]}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,r.jsx)(i.$n,{variant:"ghost",onClick:()=>u("input"),children:"codex"===t?"Popup blocked or use Session JSON?":"Popup blocked? Enter URL manually"})]}),"waiting"===x&&N&&k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"text-center py-4",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,r.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 text-sm break-all",children:W}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===$?"check":"content_copy",onClick:()=>E(W,"login_url"),disabled:!W}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(W,"_blank","noopener,noreferrer"),disabled:!W,children:"Open"})]})]}),(0,r.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:k.user_code}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===$?"check":"content_copy",onClick:()=>E(k.user_code,"user_code")})]})]})]}),S&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===x&&!N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:p?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===$?"check":"content_copy",onClick:()=>E(p?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,r.jsx)(i.pd,{value:f,onChange:e=>b(e.target.value),placeholder:A,className:"font-mono text-xs"}),(0,r.jsx)(i.$n,{onClick:q,fullWidth:!0,disabled:!f,className:"mt-3",children:"Connect"})]}),"codex"===t&&(0,r.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Alternative: Session JSON"}),(0,r.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Visit ",(0,r.jsx)("a",{href:"https://chatgpt.com/api/auth/session",target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:"https://chatgpt.com/api/auth/session"})," and paste the JSON response below."]}),(0,r.jsx)("textarea",{value:g,onChange:e=>j(e.target.value),placeholder:'{ "accessToken": "...", "user": {...} }',className:"w-full h-24 py-2 px-3 text-xs font-mono text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md placeholder-text-muted/60 focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all shadow-inner resize-none"}),(0,r.jsx)(i.$n,{onClick:F,fullWidth:!0,disabled:!g,className:"mt-2",variant:"secondary",children:"Parse and Connect"})]})]}),(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})})]}),"success"===x&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,r.jsx)(i.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===x&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:y}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:_,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired,oauthMeta:n().object,idcConfig:n().shape({startUrl:n().string,region:n().string})}},91450:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(14051),l=s.n(a),n=s(38587);function i({children:e}){return(0,r.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,r.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,r.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,r.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,r.jsx)(n.default,{variant:"card"})}),(0,r.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,s)=>{s.d(t,{default:()=>c});var r=s(95155),a=s(98500),l=s.n(a),n=s(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,r.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,r.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,r.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,r.jsx)("div",{className:"size-6 text-primary",children:(0,r.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,r.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,r.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,r.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,r.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,r.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(31474);let l={primary:"bg-brand-500 hover:bg-brand-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},n={sm:"h-7 px-3 text-xs rounded-[8px]",md:"h-9 px-4 text-sm rounded-[10px]",lg:"h-11 px-6 text-sm rounded-[10px]"};function i({children:e,variant:t="primary",size:s="md",type:o="button",icon:d,iconRight:c,disabled:m=!1,loading:x=!1,fullWidth:u=!1,className:p,...h}){return(0,r.jsxs)("button",{type:o,className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.97] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[s],u&&"w-full",p),disabled:m||x,...h,children:[x?(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):d?(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:d}):null,e,c&&!x&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:c})]})}},92622:(e,t,s)=>{s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(98500),o=s.n(i),d=s(73321),c=s(31474),m=s(90620),x=s(52679),u=s(11059),p=s(95892),h=s(92542),f=s(81127);let b=["embedding","image","tts","stt"],g="/dashboard/media-providers/web",j=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/focus-ui",label:"Focus UI",icon:"visibility"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal"}],y=[{href:"/dashboard/network-analysis",label:"Network Analysis",icon:"network_check"},{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"},{href:"/dashboard/translator",label:"Translator",icon:"translate"}],v=[{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/skills",label:"Skills",icon:"extension"}];function N({onClose:e,collapsed:t=!1,onCollapsedChange:s}){let l=(0,d.usePathname)(),n=(0,p.Od)(),{permissions:i=[]}=(0,p.hd)(),k=n||i.includes("view_usage"),C=n?j:j.filter(e=>"/dashboard/usage"===e.href?k:!["/dashboard/providers","/dashboard/combos","/dashboard/mitm","/dashboard/focus-ui","/dashboard/cli-tools","/dashboard/proxy-pools","/dashboard/quota","/dashboard/network-analysis"].includes(e.href)),[S,T]=(0,a.useState)(!1),[O,P]=(0,a.useState)(!1),[$,E]=(0,a.useState)(!1),[I,R]=(0,a.useState)(!1),[A,z]=(0,a.useState)(null),[M,U]=(0,a.useState)(!1),[L,_]=(0,a.useState)(!1),[q,F]=(0,a.useState)(0),[D,W]=(0,a.useState)(!1),{copied:K,copy:B}=(0,u.C)(2e3),V=m.h0.installCmdLatest||m.h0.installCmd;(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{e.enableTranslator&&W(!0)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>{e.hasUpdate&&z(e)}).catch(()=>{})},[]);let J=e=>"/dashboard/endpoint"===e?"/dashboard"===l||l.startsWith("/dashboard/endpoint"):l.startsWith(e),G=async()=>{try{await navigator.clipboard.writeText(V)}catch{}B(V);let e=m.h0.shutdownCountdownSec;F(e);let t=setInterval(()=>{F(e-=1),e<=0&&(clearInterval(t),fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),R(!0))},1e3)},Q=async()=>{E(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}E(!1),P(!1),R(!0)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:(0,c.cn)("flex flex-col border-r border-border-subtle bg-vibrancy backdrop-blur-xl transition-all duration-300 min-h-full",t?"w-20":"w-72"),children:[(0,r.jsxs)("div",{className:(0,c.cn)("flex items-center px-6 pt-5 pb-2",t?"justify-center":"justify-between"),children:[!t&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),"function"==typeof s&&(0,r.jsx)("button",{type:"button",onClick:()=>s(!t),className:"flex size-8 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-surface-2 hover:text-text-main","aria-label":t?"Expand sidebar":"Collapse sidebar",title:t?"Expand sidebar":"Collapse sidebar",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:t?"left_panel_open":"left_panel_close"})})]}),(0,r.jsxs)("div",{className:(0,c.cn)("py-4 flex flex-col gap-2",t?"px-0 items-center":"px-6"),children:[(0,r.jsxs)(o(),{href:"/dashboard",className:(0,c.cn)("flex items-center",t?"justify-center":"gap-3"),children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-9 rounded-[10px] bg-gradient-to-br from-brand-500 to-brand-700 shadow-[var(--shadow-warm)]",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-white text-[20px]",children:"hub"})}),(0,r.jsxs)("div",{className:(0,c.cn)("flex flex-col",t&&"hidden"),children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:m.vQ.name}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["v",m.vQ.version]})]})]}),A&&!t&&(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 rounded p-1 -m-1",children:[(0,r.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",A.latestVersion]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:()=>U(!0),className:"px-2 py-1 rounded bg-green-600 hover:bg-green-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white text-[11px] font-semibold transition-colors cursor-pointer",children:"Update now"}),(0,r.jsx)("button",{onClick:()=>B(V),title:"Copy install command",className:"flex-1 text-left hover:opacity-80 transition-opacity cursor-pointer min-w-0",children:(0,r.jsx)("code",{className:"block text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono truncate",children:K?"✓ copied!":V})})]})]})]}),(0,r.jsxs)("nav",{className:(0,c.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",t?"px-3":"px-4"),children:[C.map(s=>(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J(s.href)?"fill-1":"group-hover:text-primary transition-colors"),children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium",t&&"hidden"),children:s.label})]},s.href)),n&&(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[(0,r.jsx)("p",{className:(0,c.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",t&&"hidden"),children:"Admin"}),[{href:"/dashboard/admin/users",label:"User Management",icon:"manage_accounts"},{href:"/dashboard/admin/keys",label:"Key Management",icon:"key"}].map(s=>(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-4 py-2",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] group-hover:text-primary transition-colors",children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-sm font-medium",t&&"hidden"),children:s.label})]},s.href))]}),(0,r.jsxs)("div",{className:"pt-3 mt-2 space-y-0.5",children:[(0,r.jsx)("p",{className:(0,c.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",t&&"hidden"),children:"System"}),(0,r.jsxs)("button",{onClick:()=>T(e=>!e),title:t?"Media Providers":void 0,className:(0,c.cn)("w-full flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",l.startsWith("/dashboard/media-providers")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"perm_media"}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium flex-1 text-left",t&&"hidden"),children:"Media Providers"}),(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[14px] transition-transform",t&&"hidden"),style:{transform:S?"rotate(180deg)":"rotate(0deg)"},children:"expand_more"})]}),S&&!t&&(0,r.jsxs)("div",{className:"pl-4",children:[x.rj.filter(e=>b.includes(e.id)).map(t=>(0,r.jsxs)(o(),{href:`/dashboard/media-providers/${t.id}`,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",l.startsWith(`/dashboard/media-providers/${t.id}`)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:t.icon}),(0,r.jsx)("span",{className:"text-sm",children:t.label})]},t.id)),(0,r.jsxs)(o(),{href:g,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",l.startsWith(g)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"travel_explore"}),(0,r.jsx)("span",{className:"text-sm",children:"Web Fetch & Search"})]},"web")]}),v.map(s=>(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J(s.href)?"fill-1":"group-hover:text-primary transition-colors"),children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium",t&&"hidden"),children:s.label})]},s.href)),y.map(s=>"/dashboard/translator"!==s.href||D?(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-4 py-2",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J(s.href)?"fill-1":"group-hover:text-primary transition-colors"),children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-sm font-medium",t&&"hidden"),children:s.label})]},s.href):null),(0,r.jsxs)(o(),{href:"/dashboard/profile",onClick:e,title:t?"Settings":void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",J("/dashboard/profile")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J("/dashboard/profile")?"fill-1":"group-hover:text-primary transition-colors"),children:"settings"}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium",t&&"hidden"),children:"Settings"})]})]})]}),(0,r.jsx)("div",{className:"p-3 border-t border-border-subtle",children:t?(0,r.jsx)("button",{type:"button",onClick:()=>P(!0),className:"flex size-10 w-full items-center justify-center rounded-lg border border-red-200 text-red-500 transition-colors hover:bg-red-50 hover:border-red-300","aria-label":"Shutdown",title:"Shutdown",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"power_settings_new"})}):(0,r.jsx)(h.default,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>P(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"})})]}),(0,r.jsx)(f.ConfirmModal,{isOpen:O,onClose:()=>P(!1),onConfirm:Q,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:$}),(0,r.jsx)(f.ConfirmModal,{isOpen:M,onClose:()=>U(!1),onConfirm:()=>{U(!1),_(!0)},title:"Update OpenrouterX",message:`Show install command for v${A?.latestVersion||""}? You can copy it and shutdown to install manually.`,confirmText:"Show Command",cancelText:"Cancel",variant:"primary"}),(I||L)&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-6",children:L?(0,r.jsx)(w,{latestVersion:A?.latestVersion,installCmd:V,copied:K,onCopyAndShutdown:G,onCancel:()=>{_(!1),F(0)},countdown:q,isDisconnected:I}):(0,r.jsxs)("div",{className:"text-center p-8",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,r.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,r.jsx)(h.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}function w({latestVersion:e,installCmd:t,copied:s,onCopyAndShutdown:a,onCancel:l,countdown:n,isDisconnected:i}){let o=n>0;return(0,r.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-neutral-900/95 border border-white/10 p-6 text-white",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-500/20 text-amber-400",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"content_copy"})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h2",{className:"text-lg font-semibold",children:["Update OpenrouterX",e?` to v${e}`:""]}),(0,r.jsx)("p",{className:"text-xs text-white/60",children:i?"Server stopped. Paste the command into a terminal to install.":o?`Command copied. Server will stop in ${n}s...`:"Click the button below to copy the install command and shutdown."})]})]}),(0,r.jsx)("p",{className:"text-sm text-white/80 mb-2",children:"Install command:"}),(0,r.jsx)("div",{className:"w-full px-3 py-2 rounded bg-white/5 mb-4",children:(0,r.jsx)("code",{className:"text-xs font-mono text-amber-400 break-all",children:t})}),(0,r.jsxs)("ol",{className:"text-xs text-white/70 space-y-1 list-decimal list-inside mb-4",children:[(0,r.jsxs)("li",{children:["Click ",(0,r.jsx)("strong",{children:"Copy & Shutdown"})," below."]}),(0,r.jsx)("li",{children:"Paste the command into your terminal and press Enter."}),(0,r.jsxs)("li",{children:["Run ",(0,r.jsx)("code",{className:"px-1 rounded bg-white/10 text-green-400",children:"openrouterX"})," again after install."]})]}),i?(0,r.jsx)(h.default,{variant:"secondary",fullWidth:!0,onClick:()=>globalThis.location.reload(),children:"Reload Page"}):(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(h.default,{variant:"secondary",onClick:l,disabled:o,children:"Cancel"}),(0,r.jsx)(h.default,{variant:"primary",fullWidth:!0,onClick:a,disabled:o,children:s?"✓ Copied — shutting down...":o?`Shutting down in ${n}s`:"Copy & Shutdown"})]})]})}N.propTypes={onClose:n().func,collapsed:n().bool,onCollapsedChange:n().func},w.propTypes={latestVersion:n().string,installCmd:n().string.isRequired,copied:n().bool,onCopyAndShutdown:n().func.isRequired,onCancel:n().func.isRequired,countdown:n().number,isDisconnected:n().bool}},94230:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,onSuccess:s,onClose:l}){let[n,c]=(0,a.useState)("loading"),[m,x]=(0,a.useState)(""),[u,p]=(0,a.useState)(null),[h,f]=(0,a.useState)(""),[b,g]=(0,a.useState)(null),{copied:j,copy:y}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);p(s),x(s.authUrl),c("input"),window.open(s.authUrl,"_blank")}catch(e){g(e.message),c("error")}})()},[e,t]);let v=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!r)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:u.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);c("success"),s?.()}catch(e){g(e.message),c("error")}},N="google"===t?"Google":"GitHub";return(0,r.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${N}`,onClose:l,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",N," authentication"]})]}),"input"===n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===j?"check":"content_copy",onClick:()=>y(m,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,r.jsx)(i.pd,{value:h,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:v,fullWidth:!0,disabled:!h,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",N," has been connected."]}),(0,r.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:b}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},95088:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:s,onClose:l}){let n,[c,m]=(0,a.useState)(null),[x,u]=(0,a.useState)(o),[p,h]=(0,a.useState)(""),[f,b]=(0,a.useState)(""),[g,j]=(0,a.useState)(""),[y,v]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,T]=(0,a.useState)(null),O=()=>{m(null),u(o),h(""),b(""),j(""),w(null),v(!1),C(!1),T(null),l()},P=async()=>{if(!g.trim())return void w("Personal Access Token is required");v(!0),w(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:x.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");s?.(),O()}catch(e){w(e.message)}finally{v(!1)}};return e?k&&S?(0,r.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{s?.(),O()},onClose:()=>{C(!1),T(null)}}):(0,r.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:O,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,r.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,r.jsx)("a",{href:`${x.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(n=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${n}/callback`)})]}),(0,r.jsx)(i.pd,{label:"GitLab Base URL",value:x,onChange:e=>u(e.target.value),placeholder:o}),(0,r.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,r.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:f,onChange:e=>b(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:()=>{p.trim()?(w(null),T({baseUrl:x.trim()||o,clientId:p.trim(),clientSecret:f.trim()}),C(!0)):w("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,r.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,r.jsx)("a",{href:`${x.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,r.jsx)(i.pd,{label:"GitLab Base URL",value:x,onChange:e=>u(e.target.value),placeholder:o}),(0,r.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>j(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:P,fullWidth:!0,disabled:!g.trim()||y,loading:y,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},95892:(e,t,s)=>{s.d(t,{Od:()=>o,UserRoleProvider:()=>n,hd:()=>i});var r=s(95155),a=s(12115);let l=(0,a.createContext)({role:null,userId:null,displayName:null});function n({role:e,userId:t,displayName:s,children:i}){let[o,d]=(0,a.useState)({role:e,userId:t,displayName:s});return(0,a.useEffect)(()=>{},[]),(0,r.jsx)(l.Provider,{value:o,children:i})}function i(){return(0,a.useContext)(l)}function o(){let{role:e}=(0,a.useContext)(l);return"super_admin"===e}},96748:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:s,onSaved:l,node:n}){let c=!!n,[m,x]=(0,a.useState)({name:"",prefix:"",baseUrl:o}),[u,p]=(0,a.useState)(!1),[h,f]=(0,a.useState)(""),[b,g]=(0,a.useState)(""),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(N(null),f(""),g(""),c?x({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||o}):x({name:"",prefix:"",baseUrl:o}))},[e,c,n]);let w=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=c?"PUT":"POST",r={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl};c||(r.type="custom-embedding");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),i=await a.json();a.ok&&(c?l?.(i.node):s?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},k=async()=>{y(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:h,type:"custom-embedding",modelId:b.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{y(!1)}};return(0,r.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(i.pd,{label:"Name",value:m.name,onChange:e=>x({...m,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,r.jsx)(i.pd,{label:"Prefix",value:m.prefix,onChange:e=>x({...m,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,r.jsx)(i.pd,{label:"Base URL",value:m.baseUrl,onChange:e=>x({...m,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,r.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>f(e.target.value)}),(0,r.jsx)(i.pd,{label:"Model ID (for Check)",value:b,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(i.$n,{onClick:k,disabled:!h||!b.trim()||j||!m.baseUrl.trim(),variant:"secondary",children:j?"Checking...":"Check"}),(()=>{if(!v)return null;let{valid:e,error:t,dimensions:s}=v;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Ex,{variant:"success",children:"Valid"}),s&&(0,r.jsxs)("span",{className:"text-sm text-text-muted",children:[s," dims"]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:w,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||u,children:u?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,r.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string})}},97677:(e,t,s)=>{s.d(t,{default:()=>a});var r=s(95155);function a({text:e,children:t,position:s="top",color:l}){let n=l?"":"bg-gray-900";return(0,r.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,r.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[s]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${n} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:l?{backgroundColor:l}:{},children:e})]})}},98542:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({checked:e=!1,onChange:t,label:s,description:n,disabled:i=!1,size:o="md",className:d}){let c={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",i&&"opacity-50 cursor-not-allowed",d),children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:i,onClick:()=>{!i&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-brand-500/30",e?"bg-brand-500":"bg-surface-3",c[o].track,i&&"cursor-not-allowed"),children:(0,r.jsx)("span",{className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?c[o].translate:"translate-x-0.5",c[o].thumb,"mt-0.5")})}),(s||n)&&(0,r.jsxs)("div",{className:"flex flex-col",children:[s&&(0,r.jsx)("span",{className:"text-sm font-medium text-text-main",children:s}),n&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:n})]})]})}},98572:(e,t,s)=>{s.d(t,{default:()=>m});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(32598),d=s(68828);let c="https://api.openai.com/v1";function m({isOpen:e,onClose:t,onCreated:s,onSaved:l,node:n}){let x=!!n,[u,p]=(0,a.useState)({name:"",prefix:"",baseUrl:c,defaultSize:""}),[h,f]=(0,a.useState)(""),[b,g]=(0,a.useState)(""),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(""),[C,S]=(0,a.useState)(!1),[T,O]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(O(null),N(""),k(""),f(""),g(""),x?p({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||c,defaultSize:n.defaultSize||""}):p({name:"",prefix:"",baseUrl:c,defaultSize:""}))},[e,x,n]);let P=async()=>{if(u.name.trim()&&u.prefix.trim()&&u.baseUrl.trim()){y(!0);try{let e=x?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=x?"PUT":"POST",r={name:u.name,prefix:u.prefix,baseUrl:u.baseUrl,defaultSize:u.defaultSize.trim()};x||(r.type="custom-image");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),i=await a.json();a.ok&&(x?l?.(i.node):s?.(i.node))}catch(e){console.log("Error saving custom image node:",e)}finally{y(!1)}}},$=async()=>{S(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:u.baseUrl,apiKey:v,type:"custom-image",modelId:w.trim()||void 0,imageSize:u.defaultSize.trim()||void 0})}),t=await e.json();t.normalizedBaseUrl&&p(e=>({...e,baseUrl:t.normalizedBaseUrl})),O(t)}catch{O({valid:!1,error:"Network error"})}finally{S(!1)}};return(0,r.jsx)(i.aF,{isOpen:e,title:x?"Edit Custom Image":"Add Custom Image",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[!x&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Import From cURL"}),(0,r.jsx)("textarea",{value:h,onChange:e=>f(e.target.value),placeholder:'curl https://api.example.com/v1/images/generations -H "Authorization: Bearer sk-xxx" -H "Content-Type: application/json" -d \'{"model":"gpt-image-1","prompt":"A cute cat","size":"1024x1024","n":1}\'',className:"min-h-32 w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Paste a working OpenAI-compatible image curl command to auto-fill fields."}),(0,r.jsx)(i.$n,{onClick:()=>{try{let e=(0,d.rk)(h);p({name:e.defaultName,prefix:e.defaultPrefix,baseUrl:e.baseUrl,defaultSize:e.imageSize||""}),N(e.apiKey||""),k(e.modelId||""),g("")}catch(e){g(e.message||"Failed to parse curl")}},variant:"secondary",children:"Parse cURL"})]}),b&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:b})]}),(0,r.jsx)(i.pd,{label:"Name",value:u.name,onChange:e=>p({...u,name:e.target.value}),placeholder:"SenseNova Image",hint:"Required. A friendly label for this image provider."}),(0,r.jsx)(i.pd,{label:"Prefix",value:u.prefix,onChange:e=>p({...u,prefix:e.target.value}),placeholder:"sensenova",hint:"Required. Used as the provider prefix for model IDs (e.g. sensenova/sensenova-u1-fast)."}),(0,r.jsx)(i.pd,{label:"Base URL",value:u.baseUrl,onChange:e=>p({...u,baseUrl:e.target.value}),placeholder:"https://token.sensenova.cn/v1",hint:"The app will append /images/generations automatically."}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Default Size"}),(0,r.jsxs)("select",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:u.defaultSize,onChange:e=>p({...u,defaultSize:e.target.value}),children:[(0,r.jsx)("option",{value:"",children:"Use fallback"}),o.z.filter(e=>"auto"!==e).map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Used by model test and request example for vendors with restricted sizes."})]}),(0,r.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:v,onChange:e=>N(e.target.value)}),(0,r.jsx)(i.pd,{label:"Model ID (for Check)",value:w,onChange:e=>k(e.target.value),placeholder:"e.g. sensenova-u1-fast",hint:"Required for validation. Will send a test image generation request."}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(i.$n,{onClick:$,disabled:!v||!w.trim()||C||!u.baseUrl.trim(),variant:"secondary",children:C?"Checking...":"Check"}),(()=>{if(!T)return null;let{valid:e,error:t}=T;return e?(0,r.jsx)(i.Ex,{variant:"success",children:"Valid"}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:P,fullWidth:!0,disabled:!u.name.trim()||!u.prefix.trim()||!u.baseUrl.trim()||j,children:j?x?"Saving...":"Creating...":x?"Save":"Create"}),(0,r.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}m.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string,defaultSize:n().string})}}}]);
|
|
7
|
+
`,children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[g.includes(e.value)&&!s&&(0,r.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,r.jsxs)(r.Fragment,{children:[e.name,(0,r.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name]})},e.value)})})]},e)),0===Object.keys(L).length&&0===U.length&&(0,r.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,r.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}u.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,onDeselect:n().func,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object,kindFilter:n().string,addedModelValues:n().arrayOf(n().string),closeOnSelect:n().bool}},73579:(e,t,s)=>{s.d(t,{default:()=>x});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(81127),o=s(11910),d=s(92542),c=s(56061),m=s(52679);function x({isOpen:e,connection:t,proxyPools:s,onSave:l,onClose:n}){let[u,p]=(0,a.useState)({name:"",priority:1,apiKey:""}),[h,f]=(0,a.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[b,g]=(0,a.useState)({accountId:""}),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)(null),[w,k]=(0,a.useState)(!1),[C,S]=(0,a.useState)(null),[T,O]=(0,a.useState)(!1);(0,a.useEffect)(()=>{t&&(p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData&&f({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}),"cloudflare-ai"===t.provider&&t.providerSpecificData&&g({accountId:t.providerSpecificData.accountId||""}),N(null),S(null))},[t]);let P=t?.authType==="oauth",$=t?.provider==="azure",E=t?.provider==="cloudflare-ai",I=!!t&&((0,m.mq)(t.provider)||(0,m.gb)(t.provider)),R=async()=>{if(t?.provider){y(!0),N(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),s=await e.json();N(s.valid?"success":"failed")}catch{N("failed")}finally{y(!1)}}},A=async()=>{if(t?.provider&&u.apiKey){k(!0),S(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:u.apiKey,...$?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})}),s=await e.json();S(s.valid?"success":"failed")}catch{S("failed")}finally{k(!1)}}},z=async()=>{if(t){O(!0);try{let e={name:u.name,priority:u.priority};if(!P&&u.apiKey){e.apiKey=u.apiKey;let s="success"===C;if(!s)try{k(!0),S(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:u.apiKey,...$?{providerSpecificData:h}:{},...E?{providerSpecificData:b}:{}})});s=!!(await e.json()).valid,S(s?"success":"failed")}catch{S("failed")}finally{k(!1)}s&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}$&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),E&&(e.providerSpecificData={accountId:b.accountId}),await l(e)}finally{O(!1)}}};return t?(0,r.jsx)(i.default,{isOpen:e,title:"Edit Connection",onClose:n,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(o.default,{label:"Name",value:u.name,onChange:e=>p({...u,name:e.target.value}),placeholder:P?"Account name":"Production Key"}),P&&t.email&&(0,r.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,r.jsx)("p",{className:"font-medium",children:t.email})]}),(0,r.jsx)(o.default,{label:"Priority",type:"number",value:u.priority,onChange:e=>p({...u,priority:Number.parseInt(e.target.value,10)||1})}),!P&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(o.default,{label:"API Key",type:"password",value:u.apiKey,onChange:e=>p({...u,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,r.jsx)("div",{className:"pt-6",children:(0,r.jsx)(d.default,{onClick:A,disabled:!u.apiKey||w||T,variant:"secondary",children:w?"Checking...":"Check"})})]}),C&&(0,r.jsx)(c.default,{variant:"success"===C?"success":"error",children:"success"===C?"Valid":"Invalid"})]}),$&&(0,r.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,r.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>f({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,r.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>f({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,r.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>f({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,r.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>f({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),!I&&!$&&!E&&(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(d.default,{onClick:R,variant:"secondary",disabled:j,children:j?"Testing...":"Test Connection"}),v&&(0,r.jsx)(c.default,{variant:"success"===v?"success":"error",children:"success"===v?"Valid":"Failed"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(d.default,{onClick:z,fullWidth:!0,disabled:T,children:T?"Saving...":"Save"}),(0,r.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}x.propTypes={isOpen:n().bool.isRequired,connection:n().shape({id:n().string,name:n().string,email:n().string,priority:n().number,authType:n().string,provider:n().string,providerSpecificData:n().object}),proxyPools:n().arrayOf(n().shape({id:n().string,name:n().string})),onSave:n().func.isRequired,onClose:n().func.isRequired}},74891:(e,t,s)=>{s.d(t,{default:()=>b});var r=s(95155),a=s(12115),l=s(73321),n=s(98500),i=s.n(n),o=s(14051),d=s.n(o),c=s(57250),m=s(80752),x=s(38587),u=s(38003),p=s(90620),h=s(52679),f=s(73006);function b({onMenuClick:e,showMenuButton:t=!0}){let s=(0,l.usePathname)(),n=(0,l.useRouter)(),[o,d]=(0,a.useState)(""),[u,j]=(0,a.useState)(""),{title:y,description:v,icon:N,breadcrumbs:w}=(0,a.useMemo)(()=>(e=>{if(!e)return{title:"",description:"",breadcrumbs:[]};let t=e.match(/\/media-providers\/([^/]+)\/([^/]+)$/);if(t){let e=t[1],s=t[2],r=h.rj.find(t=>t.id===e),a=h.Q2[s];return{title:a?.name||s,description:"",breadcrumbs:[{label:"Media Providers",href:`/dashboard/media-providers/${e}`},{label:r?.label||e,href:`/dashboard/media-providers/${e}`},{label:a?.name||s,image:`/providers/${s}.png`}]}}let s=e.match(/\/media-providers\/([^/]+)$/);if(s){let e=s[1],t=h.rj.find(t=>t.id===e);return{title:t?.label||e,description:`Manage your ${t?.label||e} providers`,icon:t?.icon||"perm_media",breadcrumbs:[]}}let r=e.match(/\/providers\/([^/]+)$/);if(r){let e=r[1],t=p.zN[e]||p.fg[e];if(t)return{title:t.name,description:"",breadcrumbs:[{label:"Providers",href:"/dashboard/providers"},{label:t.name,image:`/providers/${t.id}.png`}]}}return e.includes("/providers")&&!e.includes("/media-providers")?{title:"Providers",description:"Manage your AI provider connections",icon:"dns",breadcrumbs:[]}:e.includes("/combos")?{title:"Combos",description:"Model combos with fallback",icon:"layers",breadcrumbs:[]}:e.includes("/usage")?{title:"Usage & Analytics",description:"Monitor your API usage, token consumption, and request logs",icon:"bar_chart",breadcrumbs:[]}:e.includes("/auth-files")?{title:"Auth Files",description:"Map provider credentials stored in the local database",icon:"vpn_key",breadcrumbs:[]}:e.includes("/quota")?{title:"Quota Tracker",description:"Track and manage your API quota limits",icon:"data_usage",breadcrumbs:[]}:e.includes("/mitm")?{title:"MITM Proxy",description:"Intercept CLI tool traffic and route through OpenrouterX",icon:"security",breadcrumbs:[]}:e.includes("/focus-ui")?{title:"Focus UI",description:"Monitor MITM status, quota, and realtime logs in one place",icon:"visibility",breadcrumbs:[]}:e.includes("/cli-tools")?{title:"CLI Tools",description:"Configure CLI tools",icon:"terminal",breadcrumbs:[]}:e.includes("/proxy-pools")?{title:"Proxy Pools",description:"Manage your proxy pool configurations",icon:"lan",breadcrumbs:[]}:e.includes("/network-analysis")?{title:"Network Analysis",description:"Diagnose local connectivity, proxy, DNS, and MITM network impact",icon:"network_check",breadcrumbs:[]}:e.includes("/skills")?{title:"Agent Skills",description:"Copy a link and paste to your AI to use OpenrouterX — no install needed",icon:"extension",breadcrumbs:[]}:e.includes("/endpoint")?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:e.includes("/profile")?{title:"Settings",description:"Manage your preferences",icon:"settings",breadcrumbs:[]}:e.includes("/console-log")?{title:"Console Log",description:"Live server console output",icon:"monitor",breadcrumbs:[]}:"/dashboard"===e?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}})(s),[s]);(0,a.useEffect)(()=>{let e=!1;return async function(){try{let t=await fetch("/api/auth/status",{cache:"no-store"});if(!t.ok)return;let s=await t.json();e||(d(s?.displayName||s?.oidcName||s?.oidcEmail||""),j(s?.loginMethod||""))}catch{e||(d(""),j(""))}}(),()=>{e=!0}},[]);let k=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(n.push("/login"),n.refresh())}catch(e){console.error("Failed to logout:",e)}};return(0,r.jsxs)("header",{className:"shrink-0 flex items-center justify-between gap-3 px-4 lg:px-8 pt-3 pb-2 border-b border-border-subtle bg-surface/60 backdrop-blur-xl lg:bg-transparent lg:backdrop-blur-none z-20",children:[(0,r.jsx)("div",{className:"flex items-center gap-3 lg:hidden shrink-0",children:t&&(0,r.jsx)("button",{onClick:e,className:"text-text-main hover:text-primary transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"menu"})})}),(0,r.jsx)("div",{className:"flex flex-col min-w-0 flex-1",children:w.length>0?(0,r.jsx)("div",{className:"flex items-center gap-2",children:w.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[t>0&&(0,r.jsx)("span",{className:"material-symbols-outlined text-text-muted text-base",children:"chevron_right"}),e.href?(0,r.jsx)(i(),{href:e.href,className:"text-text-muted hover:text-primary transition-colors",children:e.label}):(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.image&&(0,r.jsx)(c.A,{src:e.image,alt:e.label,size:28,className:"object-contain rounded max-w-[28px] max-h-[28px]",fallbackText:e.label.slice(0,2).toUpperCase()}),(0,r.jsx)("h1",{className:"text-base lg:text-2xl font-semibold text-text-main tracking-tight truncate",children:(0,f.Tl)(e.label)})]})]},`${e.label}-${e.href||"current"}`))}):y?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[N&&(0,r.jsx)("span",{className:"material-symbols-outlined text-primary text-xl lg:text-2xl",children:N}),(0,r.jsx)("h1",{className:"text-base lg:text-2xl font-semibold tracking-tight truncate",children:(0,f.Tl)(y)})]}),v&&(0,r.jsx)("p",{className:"hidden lg:block text-sm text-text-muted truncate",children:(0,f.Tl)(v)})]}):null}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[o&&"OIDC"===u&&(0,r.jsxs)("div",{className:"hidden sm:flex items-center max-w-[220px] px-3 py-1.5 rounded-full border border-border bg-surface/70 text-xs text-text-muted truncate",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1.5 text-primary",children:"person"}),(0,r.jsx)("span",{className:"truncate",children:o}),(0,r.jsx)("span",{className:"ml-2 shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary",children:"OIDC"})]}),(0,r.jsx)(g,{}),(0,r.jsx)(x.default,{}),(0,r.jsx)(m.default,{onLogout:k})]})]})}function g(){let e=(0,u.C)(e=>e.visible),t=(0,u.C)(e=>e.query),s=(0,u.C)(e=>e.placeholder),a=(0,u.C)(e=>e.setQuery);return e?(0,r.jsxs)("div",{className:"relative w-[160px] sm:w-[220px]",children:[(0,r.jsx)("span",{className:"material-symbols-outlined absolute left-2 top-1/2 -translate-y-1/2 text-text-muted text-[16px] pointer-events-none",children:"search"}),(0,r.jsx)("input",{type:"text",value:t,onChange:e=>a(e.target.value),placeholder:s,className:"w-full h-8 pl-7 pr-7 rounded-lg border border-border bg-surface/60 text-sm focus:outline-none focus:border-primary/50 transition-colors"}),t&&(0,r.jsx)("button",{type:"button",onClick:()=>a(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-main p-0.5 rounded","aria-label":"Clear search",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}b.propTypes={onMenuClick:d().func,showMenuButton:d().bool}},80752:(e,t,s)=>{s.d(t,{default:()=>f});var r=s(95155),a=s(12115),l=s(73321),n=s(14051),i=s.n(n),o=s(93308),d=s(1620),c=s(95892),m=s(40197),x=s(14932),u=s(21931);let p={en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (BR)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (PT)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}};function h({icon:e,label:t,onClick:s,trailing:a,danger:l}){return(0,r.jsxs)("button",{onClick:s,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${l?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[20px] ${l?"":"text-text-muted"}`,children:e}),(0,r.jsx)("span",{className:"flex-1 text-left",children:t}),a&&(0,r.jsx)("span",{className:"text-base",children:a})]})}function f({onLogout:e}){let[t,s]=(0,a.useState)(!1),[n,i]=(0,a.useState)(!1),[b,g]=(0,a.useState)(!1),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)("en"),w=(0,l.useRouter)(),{toggleTheme:k,isDark:C}=(0,d.D)(),{role:S}=(0,c.hd)(),[T,O]=(0,a.useState)(null),P=(0,a.useRef)(null),$="sub_user"===(T||S||null);return(0,a.useEffect)(()=>{N(function(){if("u"<typeof document)return"en";let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${o.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):"en";return(0,o.QC)(t)}())},[j]),(0,a.useEffect)(()=>{S&&O(S)},[S]),(0,a.useEffect)(()=>{fetch("/api/auth/me").then(e=>e.json()).then(e=>{e?.role&&O(e.role)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&s(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",ref:P,children:[(0,r.jsx)("button",{onClick:()=>s(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,r.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[$&&(0,r.jsx)(h,{icon:"dashboard",label:"Dashboard",onClick:()=>{s(!1),w.push("/dashboard")}}),$&&(0,r.jsx)(h,{icon:"terminal",label:"CLI Tools",onClick:()=>{s(!1),w.push("/dashboard/cli-tools")}}),!$&&(0,r.jsx)(h,{icon:"history",label:"Change Log",onClick:()=>{s(!1),i(!0)}}),(0,r.jsx)(h,{icon:"language",label:p[v]?.name||v,trailing:p[v]?.flag||"\uD83C\uDF10",onClick:()=>{s(!1),y(!0)}}),!$&&(0,r.jsx)(h,{icon:C?"light_mode":"dark_mode",label:"Theme",onClick:()=>{k(),s(!1)}}),!$&&(0,r.jsx)(h,{icon:"computer",label:"Remote",onClick:()=>{s(!1),g(!0)}}),(0,r.jsx)(h,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{s(!1),e()}})]})]}),(0,r.jsx)(m.default,{isOpen:n,onClose:()=>i(!1)}),(0,r.jsx)(x.A,{isOpen:b,onClose:()=>g(!1)}),(0,r.jsx)(u.default,{hideTrigger:!0,isOpen:j,onClose:()=>y(!1)})]})}h.propTypes={icon:i().string.isRequired,label:i().string.isRequired,onClick:i().func.isRequired,trailing:i().node,danger:i().bool},f.propTypes={onLogout:i().func.isRequired}},81127:(e,t,s)=>{s.d(t,{ConfirmModal:()=>d,default:()=>o});var r=s(95155),a=s(12115),l=s(31474),n=s(92542),i=s(97677);function o({isOpen:e,onClose:t,title:s,children:n,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:x=!0,className:u}){return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let s=s=>{"Escape"===s.key&&e&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e,t]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,r.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],u),children:[(s||x)&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[x&&(0,r.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,r.jsx)(i.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,r.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,r.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,r.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,r.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),s&&(0,r.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:s})]}),(0,r.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,r.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:n}),d&&(0,r.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:s,title:a="Confirm",message:l,confirmText:i="Confirm",cancelText:c="Cancel",variant:m="danger",loading:x=!1}){return(0,r.jsx)(o,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.default,{variant:"ghost",onClick:t,disabled:x,children:c}),(0,r.jsx)(n.default,{variant:m,onClick:s,loading:x,children:i})]}),children:(0,r.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({children:e,title:t,subtitle:s,icon:n,action:i,padding:o="md",hover:d=!1,elev:c=!1,className:m,...x}){return(0,r.jsxs)("div",{className:(0,a.cn)("bg-surface border border-border-subtle",c?"rounded-[14px] shadow-[var(--shadow-elev)]":"rounded-[14px] shadow-[var(--shadow-soft)]",d&&"hover:shadow-[var(--shadow-warm)] hover:border-brand-500/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[o],m),...x,children:[(t||i)&&(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,r.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,r.jsxs)("div",{children:[t&&(0,r.jsx)("h3",{className:"text-text-main font-semibold",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-text-muted",children:s})]})]}),i]}),e]})}l.Section=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",t),...s,children:e})},l.Row=function({children:e,className:t,...s}){return(0,r.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",t),...s,children:e})},l.ListItem=function({children:e,actions:t,className:s,...l}){return(0,r.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",s),...l,children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},90882:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,providerInfo:s,onSuccess:l,onClose:n,oauthMeta:c,idcConfig:m}){let[x,u]=(0,a.useState)("waiting"),[p,h]=(0,a.useState)(null),[f,b]=(0,a.useState)(""),[g,j]=(0,a.useState)(""),[y,v]=(0,a.useState)(null),[N,w]=(0,a.useState)(!1),[k,C]=(0,a.useState)(null),[S,T]=(0,a.useState)(!1),O=(0,a.useRef)(null),P=(0,a.useRef)(!1),{copied:$,copy:E}=(0,o.C)(),[I,R]=(0,a.useState)(!1),[A,z]=(0,a.useState)("/callback?code=..."),M=(0,a.useRef)(!1);(0,a.useEffect)(()=>{R("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),z(`${window.location.origin}/callback?code=...`)},[]);let U=(0,a.useCallback)(async(e,s)=>{if(p)try{let r=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:p.redirectUri,codeVerifier:p.codeVerifier,state:s,...c?{meta:c}:{}})}),a=await r.json();if(!r.ok)throw Error(a.error);u("success"),l?.()}catch(e){v(e.message),u("error")}},[p,t,l]),L=(0,a.useCallback)(async(e,s,r,a)=>{P.current=!1,T(!0);for(let n=0;n<60;n++){if(P.current){console.log("[OAuthModal] Polling aborted"),T(!1);return}if(await new Promise(e=>setTimeout(e,1e3*r)),P.current){console.log("[OAuthModal] Polling aborted after sleep"),T(!1);return}try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:s,extraData:a})}),i=await n.json();if(i.success){P.current=!0,u("success"),T(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(r=Math.min(r+5,30))}catch(e){v(e.message),u("error"),T(!1);return}}v("Authorization timeout"),u("error"),T(!1)},[t,l]),_=(0,a.useCallback)(async()=>{if(t)try{let e;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy"].includes(t)){w(!0),u("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&m?.startUrl&&(e.searchParams.set("start_url",m.startUrl),m.region&&e.searchParams.set("region",m.region),e.searchParams.set("auth_method","idc"));let s=await fetch(e.toString()),r=await s.json();if(!s.ok)throw Error(r.error);C(r);let a=r.verification_uri_complete||r.verification_uri;a&&window.open(a,"_blank","noopener,noreferrer");let l="kiro"===t?{_clientId:r._clientId,_clientSecret:r._clientSecret,_region:r._region,_authMethod:r._authMethod,_startUrl:r._startUrl}:null;L(r.device_code,r.codeVerifier,r.interval||5,l);return}let s=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":`http://localhost:${s}/callback`;let r=new URL(`/api/oauth/${t}/authorize`,window.location.origin);r.searchParams.set("redirect_uri",e),c&&Object.entries(c).forEach(([e,t])=>{t&&r.searchParams.set(e,t)});let a=await fetch(r.toString()),l=await a.json();if(!a.ok)throw Error(l.error);let n=!1,i=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",s),t.searchParams.set("state",l.state),t.searchParams.set("code_verifier",l.codeVerifier),t.searchParams.set("redirect_uri",e);let r=await fetch(t.toString()),a=await r.json();n=a.success,i=!!a.serverSide}catch{n=!1}h({...l,redirectUri:e,codexServerSide:i}),"codex"===t&&n||I&&"codex"!==t?(u("waiting"),O.current=window.open(l.authUrl,"oauth_popup","width=600,height=700"),O.current||u("input")):(u("input"),window.open(l.authUrl,"_blank"))}catch(e){v(e.message),u("error")}},[t,I,L,c,m]);(0,a.useEffect)(()=>{e&&t?(h(null),b(""),v(null),w(!1),C(null),T(!1),j(""),P.current=!1,_()):e||(P.current=!0,"codex"===t&&fetch("/api/oauth/codex/stop-proxy").catch(()=>{}))},[e,t,_]),(0,a.useEffect)(()=>{if(!p?.codexServerSide||!p?.state||M.current)return;let e=!1,t=0,s=async()=>{if(!e&&!M.current){t+=1;try{let t=await fetch(`/api/oauth/codex/poll-status?state=${encodeURIComponent(p.state)}`),s=await t.json();if(e||M.current)return;if("done"===s.status){M.current=!0,u("success"),l?.();return}if("error"===s.status){M.current=!0,v(s.error||"Authentication failed"),u("error");return}}catch{}if(t>=200){M.current=!0,v("Authentication timeout"),u("error");return}setTimeout(s,1500)}};return setTimeout(s,1500),()=>{e=!0}},[p,l]),(0,a.useEffect)(()=>{let e;if(!p)return;M.current=!1;let t=async e=>{if(M.current)return;let{code:t,state:s,error:r,errorDescription:a}=e;if(r){M.current=!0,v(a||r),u("error");return}t&&(M.current=!0,await U(t,s))},s=e=>{let s=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),r=e.origin===window.location.origin;(s||r)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let r=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",r);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&t(s),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",r),e&&e.close()}},[p,U]);let q=async()=>{try{v(null);let e=f.trim(),t=new URL(e),s=t.searchParams.get("code"),r=t.searchParams.get("state"),a=t.searchParams.get("error");if(a)throw Error(t.searchParams.get("error_description")||a);if(!s)throw Error("No authorization code found in URL");await U(s,r)}catch(e){v(e.message),u("error")}},F=async()=>{try{let e;v(null);let s=g.trim();if(!s)throw Error("Please paste the session JSON first");try{e=JSON.parse(s)}catch(e){throw Error("Invalid JSON format")}if(!e.accessToken||!e.sessionToken)throw Error("JSON must contain accessToken and sessionToken");let r=await fetch(`/api/oauth/${t}/import-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await r.json();if(!r.ok)throw Error(a.error);u("success"),l?.()}catch(e){v(e.message),u("error")}},D=(0,a.useCallback)(()=>{"codex"===t&&fetch("/api/oauth/codex/stop-proxy").catch(()=>{}),n()},[n,t]);if(!t||!s)return null;let W=k?.verification_uri_complete||k?.verification_uri||"";return(0,r.jsx)(i.aF,{isOpen:e,title:`Connect ${s.name}`,onClose:D,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===x&&!N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,r.jsx)("span",{className:"text-sm",children:"Waiting for popup authorization…"})]}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,r.jsx)(i.$n,{variant:"ghost",onClick:()=>u("input"),children:"codex"===t?"Popup blocked or use Session JSON?":"Popup blocked? Enter URL manually"})]}),"waiting"===x&&N&&k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"text-center py-4",children:[(0,r.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,r.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 text-sm break-all",children:W}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===$?"check":"content_copy",onClick:()=>E(W,"login_url"),disabled:!W}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(W,"_blank","noopener,noreferrer"),disabled:!W,children:"Open"})]})]}),(0,r.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:k.user_code}),(0,r.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===$?"check":"content_copy",onClick:()=>E(k.user_code,"user_code")})]})]})]}),S&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===x&&!N&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:p?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===$?"check":"content_copy",onClick:()=>E(p?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,r.jsx)(i.pd,{value:f,onChange:e=>b(e.target.value),placeholder:A,className:"font-mono text-xs"}),(0,r.jsx)(i.$n,{onClick:q,fullWidth:!0,disabled:!f,className:"mt-3",children:"Connect"})]}),"codex"===t&&(0,r.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Alternative: Session JSON"}),(0,r.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Visit ",(0,r.jsx)("a",{href:"https://chatgpt.com/api/auth/session",target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:"https://chatgpt.com/api/auth/session"})," and paste the JSON response below."]}),(0,r.jsx)("textarea",{value:g,onChange:e=>j(e.target.value),placeholder:'{ "accessToken": "...", "user": {...} }',className:"w-full h-24 py-2 px-3 text-xs font-mono text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md placeholder-text-muted/60 focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all shadow-inner resize-none"}),(0,r.jsx)(i.$n,{onClick:F,fullWidth:!0,disabled:!g,className:"mt-2",variant:"secondary",children:"Parse and Connect"})]})]}),(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})})]}),"success"===x&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",s.name," account has been connected."]}),(0,r.jsx)(i.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===x&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:y}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:_,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired,oauthMeta:n().object,idcConfig:n().shape({startUrl:n().string,region:n().string})}},91450:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(14051),l=s.n(a),n=s(38587);function i({children:e}){return(0,r.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,r.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,r.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,r.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,r.jsx)(n.default,{variant:"card"})}),(0,r.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,s)=>{s.d(t,{default:()=>c});var r=s(95155),a=s(98500),l=s.n(a),n=s(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,r.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,r.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,r.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,r.jsx)("div",{className:"size-6 text-primary",children:(0,r.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,r.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,r.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,r.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,r.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,r.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,r.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,r.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,r.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,s)=>{s.d(t,{default:()=>i});var r=s(95155),a=s(31474);let l={primary:"bg-brand-500 hover:bg-brand-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},n={sm:"h-7 px-3 text-xs rounded-[8px]",md:"h-9 px-4 text-sm rounded-[10px]",lg:"h-11 px-6 text-sm rounded-[10px]"};function i({children:e,variant:t="primary",size:s="md",type:o="button",icon:d,iconRight:c,disabled:m=!1,loading:x=!1,fullWidth:u=!1,className:p,...h}){return(0,r.jsxs)("button",{type:o,className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.97] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[s],u&&"w-full",p),disabled:m||x,...h,children:[x?(0,r.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):d?(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:d}):null,e,c&&!x&&(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:c})]})}},92622:(e,t,s)=>{s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(98500),o=s.n(i),d=s(73321),c=s(31474),m=s(90620),x=s(52679),u=s(11059),p=s(95892),h=s(92542),f=s(81127);let b=["embedding","image","tts","stt"],g="/dashboard/media-providers/web",j=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/endpoint#auto-routes",label:"Auto Routes",icon:"route"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/focus-ui",label:"Focus UI",icon:"visibility"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal"}],y=[{href:"/dashboard/network-analysis",label:"Network Analysis",icon:"network_check"},{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"},{href:"/dashboard/translator",label:"Translator",icon:"translate"}],v=[{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/skills",label:"Skills",icon:"extension"}];function N({onClose:e,collapsed:t=!1,onCollapsedChange:s}){let l=(0,d.usePathname)(),n=(0,p.Od)(),{permissions:i=[]}=(0,p.hd)(),k=n||i.includes("view_usage"),C=n?j:j.filter(e=>"/dashboard/usage"===e.href?k:!["/dashboard/providers","/dashboard/combos","/dashboard/mitm","/dashboard/focus-ui","/dashboard/cli-tools","/dashboard/proxy-pools","/dashboard/quota","/dashboard/network-analysis"].includes(e.href)),[S,T]=(0,a.useState)(!1),[O,P]=(0,a.useState)(!1),[$,E]=(0,a.useState)(!1),[I,R]=(0,a.useState)(!1),[A,z]=(0,a.useState)(null),[M,U]=(0,a.useState)(!1),[L,_]=(0,a.useState)(!1),[q,F]=(0,a.useState)(0),[D,W]=(0,a.useState)(!1),{copied:K,copy:B}=(0,u.C)(2e3),V=m.h0.installCmdLatest||m.h0.installCmd;(0,a.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{e.enableTranslator&&W(!0)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>{e.hasUpdate&&z(e)}).catch(()=>{})},[]);let J=e=>"/dashboard/endpoint"===e?"/dashboard"===l||l.startsWith("/dashboard/endpoint"):l.startsWith(e),G=async()=>{try{await navigator.clipboard.writeText(V)}catch{}B(V);let e=m.h0.shutdownCountdownSec;F(e);let t=setInterval(()=>{F(e-=1),e<=0&&(clearInterval(t),fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),R(!0))},1e3)},Q=async()=>{E(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}E(!1),P(!1),R(!0)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:(0,c.cn)("flex flex-col border-r border-border-subtle bg-vibrancy backdrop-blur-xl transition-all duration-300 min-h-full",t?"w-20":"w-72"),children:[(0,r.jsxs)("div",{className:(0,c.cn)("flex items-center px-6 pt-5 pb-2",t?"justify-center":"justify-between"),children:[!t&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,r.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),"function"==typeof s&&(0,r.jsx)("button",{type:"button",onClick:()=>s(!t),className:"flex size-8 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-surface-2 hover:text-text-main","aria-label":t?"Expand sidebar":"Collapse sidebar",title:t?"Expand sidebar":"Collapse sidebar",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:t?"left_panel_open":"left_panel_close"})})]}),(0,r.jsxs)("div",{className:(0,c.cn)("py-4 flex flex-col gap-2",t?"px-0 items-center":"px-6"),children:[(0,r.jsxs)(o(),{href:"/dashboard",className:(0,c.cn)("flex items-center",t?"justify-center":"gap-3"),children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-9 rounded-[10px] bg-gradient-to-br from-brand-500 to-brand-700 shadow-[var(--shadow-warm)]",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-white text-[20px]",children:"hub"})}),(0,r.jsxs)("div",{className:(0,c.cn)("flex flex-col",t&&"hidden"),children:[(0,r.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:m.vQ.name}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:["v",m.vQ.version]})]})]}),A&&!t&&(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 rounded p-1 -m-1",children:[(0,r.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",A.latestVersion]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:()=>U(!0),className:"px-2 py-1 rounded bg-green-600 hover:bg-green-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white text-[11px] font-semibold transition-colors cursor-pointer",children:"Update now"}),(0,r.jsx)("button",{onClick:()=>B(V),title:"Copy install command",className:"flex-1 text-left hover:opacity-80 transition-opacity cursor-pointer min-w-0",children:(0,r.jsx)("code",{className:"block text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono truncate",children:K?"✓ copied!":V})})]})]})]}),(0,r.jsxs)("nav",{className:(0,c.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",t?"px-3":"px-4"),children:[C.map(s=>(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J(s.href)?"fill-1":"group-hover:text-primary transition-colors"),children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium",t&&"hidden"),children:s.label})]},s.href)),n&&(0,r.jsxs)("div",{className:"pt-4 mt-2",children:[(0,r.jsx)("p",{className:(0,c.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",t&&"hidden"),children:"Admin"}),[{href:"/dashboard/admin/users",label:"User Management",icon:"manage_accounts"},{href:"/dashboard/admin/keys",label:"Key Management",icon:"key"}].map(s=>(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-4 py-2",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] group-hover:text-primary transition-colors",children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-sm font-medium",t&&"hidden"),children:s.label})]},s.href))]}),(0,r.jsxs)("div",{className:"pt-3 mt-2 space-y-0.5",children:[(0,r.jsx)("p",{className:(0,c.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",t&&"hidden"),children:"System"}),(0,r.jsxs)("button",{onClick:()=>T(e=>!e),title:t?"Media Providers":void 0,className:(0,c.cn)("w-full flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",l.startsWith("/dashboard/media-providers")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"perm_media"}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium flex-1 text-left",t&&"hidden"),children:"Media Providers"}),(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[14px] transition-transform",t&&"hidden"),style:{transform:S?"rotate(180deg)":"rotate(0deg)"},children:"expand_more"})]}),S&&!t&&(0,r.jsxs)("div",{className:"pl-4",children:[x.rj.filter(e=>b.includes(e.id)).map(t=>(0,r.jsxs)(o(),{href:`/dashboard/media-providers/${t.id}`,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",l.startsWith(`/dashboard/media-providers/${t.id}`)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:t.icon}),(0,r.jsx)("span",{className:"text-sm",children:t.label})]},t.id)),(0,r.jsxs)(o(),{href:g,onClick:e,className:(0,c.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",l.startsWith(g)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"travel_explore"}),(0,r.jsx)("span",{className:"text-sm",children:"Web Fetch & Search"})]},"web")]}),v.map(s=>(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J(s.href)?"fill-1":"group-hover:text-primary transition-colors"),children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium",t&&"hidden"),children:s.label})]},s.href)),y.map(s=>"/dashboard/translator"!==s.href||D?(0,r.jsxs)(o(),{href:s.href,onClick:e,title:t?s.label:void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-4 py-2",J(s.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J(s.href)?"fill-1":"group-hover:text-primary transition-colors"),children:s.icon}),(0,r.jsx)("span",{className:(0,c.cn)("text-sm font-medium",t&&"hidden"),children:s.label})]},s.href):null),(0,r.jsxs)(o(),{href:"/dashboard/profile",onClick:e,title:t?"Settings":void 0,className:(0,c.cn)("flex items-center rounded-lg transition-all group",t?"justify-center px-0 py-2":"gap-3 px-3 py-1",J("/dashboard/profile")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,r.jsx)("span",{className:(0,c.cn)("material-symbols-outlined text-[18px]",J("/dashboard/profile")?"fill-1":"group-hover:text-primary transition-colors"),children:"settings"}),(0,r.jsx)("span",{className:(0,c.cn)("text-[13px] font-medium",t&&"hidden"),children:"Settings"})]})]})]}),(0,r.jsx)("div",{className:"p-3 border-t border-border-subtle",children:t?(0,r.jsx)("button",{type:"button",onClick:()=>P(!0),className:"flex size-10 w-full items-center justify-center rounded-lg border border-red-200 text-red-500 transition-colors hover:bg-red-50 hover:border-red-300","aria-label":"Shutdown",title:"Shutdown",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"power_settings_new"})}):(0,r.jsx)(h.default,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>P(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"})})]}),(0,r.jsx)(f.ConfirmModal,{isOpen:O,onClose:()=>P(!1),onConfirm:Q,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:$}),(0,r.jsx)(f.ConfirmModal,{isOpen:M,onClose:()=>U(!1),onConfirm:()=>{U(!1),_(!0)},title:"Update OpenrouterX",message:`Show install command for v${A?.latestVersion||""}? You can copy it and shutdown to install manually.`,confirmText:"Show Command",cancelText:"Cancel",variant:"primary"}),(I||L)&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-6",children:L?(0,r.jsx)(w,{latestVersion:A?.latestVersion,installCmd:V,copied:K,onCopyAndShutdown:G,onCancel:()=>{_(!1),F(0)},countdown:q,isDisconnected:I}):(0,r.jsxs)("div",{className:"text-center p-8",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,r.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,r.jsx)(h.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}function w({latestVersion:e,installCmd:t,copied:s,onCopyAndShutdown:a,onCancel:l,countdown:n,isDisconnected:i}){let o=n>0;return(0,r.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-neutral-900/95 border border-white/10 p-6 text-white",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,r.jsx)("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-500/20 text-amber-400",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"content_copy"})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h2",{className:"text-lg font-semibold",children:["Update OpenrouterX",e?` to v${e}`:""]}),(0,r.jsx)("p",{className:"text-xs text-white/60",children:i?"Server stopped. Paste the command into a terminal to install.":o?`Command copied. Server will stop in ${n}s...`:"Click the button below to copy the install command and shutdown."})]})]}),(0,r.jsx)("p",{className:"text-sm text-white/80 mb-2",children:"Install command:"}),(0,r.jsx)("div",{className:"w-full px-3 py-2 rounded bg-white/5 mb-4",children:(0,r.jsx)("code",{className:"text-xs font-mono text-amber-400 break-all",children:t})}),(0,r.jsxs)("ol",{className:"text-xs text-white/70 space-y-1 list-decimal list-inside mb-4",children:[(0,r.jsxs)("li",{children:["Click ",(0,r.jsx)("strong",{children:"Copy & Shutdown"})," below."]}),(0,r.jsx)("li",{children:"Paste the command into your terminal and press Enter."}),(0,r.jsxs)("li",{children:["Run ",(0,r.jsx)("code",{className:"px-1 rounded bg-white/10 text-green-400",children:"openrouterX"})," again after install."]})]}),i?(0,r.jsx)(h.default,{variant:"secondary",fullWidth:!0,onClick:()=>globalThis.location.reload(),children:"Reload Page"}):(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(h.default,{variant:"secondary",onClick:l,disabled:o,children:"Cancel"}),(0,r.jsx)(h.default,{variant:"primary",fullWidth:!0,onClick:a,disabled:o,children:s?"✓ Copied — shutting down...":o?`Shutting down in ${n}s`:"Copy & Shutdown"})]})]})}N.propTypes={onClose:n().func,collapsed:n().bool,onCollapsedChange:n().func},w.propTypes={latestVersion:n().string,installCmd:n().string.isRequired,copied:n().bool,onCopyAndShutdown:n().func.isRequired,onCancel:n().func.isRequired,countdown:n().number,isDisconnected:n().bool}},94230:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(11059);function d({isOpen:e,provider:t,onSuccess:s,onClose:l}){let[n,c]=(0,a.useState)("loading"),[m,x]=(0,a.useState)(""),[u,p]=(0,a.useState)(null),[h,f]=(0,a.useState)(""),[b,g]=(0,a.useState)(null),{copied:j,copy:y}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),s=await e.json();if(!e.ok)throw Error(s.error);p(s),x(s.authUrl),c("input"),window.open(s.authUrl,"_blank")}catch(e){g(e.message),c("error")}})()},[e,t]);let v=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let r=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!r)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r,codeVerifier:u.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);c("success"),s?.()}catch(e){g(e.message),c("error")}},N="google"===t?"Google":"GitHub";return(0,r.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${N}`,onClose:l,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,r.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",N," authentication"]})]}),"input"===n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,r.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===j?"check":"content_copy",onClick:()=>y(m,"auth_url"),children:"Copy"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,r.jsx)(i.pd,{value:h,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:v,fullWidth:!0,disabled:!h,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,r.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",N," has been connected."]}),(0,r.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,r.jsx)("p",{className:"text-sm text-red-600 mb-4",children:b}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,r.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},95088:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:s,onClose:l}){let n,[c,m]=(0,a.useState)(null),[x,u]=(0,a.useState)(o),[p,h]=(0,a.useState)(""),[f,b]=(0,a.useState)(""),[g,j]=(0,a.useState)(""),[y,v]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,T]=(0,a.useState)(null),O=()=>{m(null),u(o),h(""),b(""),j(""),w(null),v(!1),C(!1),T(null),l()},P=async()=>{if(!g.trim())return void w("Personal Access Token is required");v(!0),w(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:x.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");s?.(),O()}catch(e){w(e.message)}finally{v(!1)}};return e?k&&S?(0,r.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{s?.(),O()},onClose:()=>{C(!1),T(null)}}):(0,r.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:O,size:"lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,r.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,r.jsx)("a",{href:`${x.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(n=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${n}/callback`)})]}),(0,r.jsx)(i.pd,{label:"GitLab Base URL",value:x,onChange:e=>u(e.target.value),placeholder:o}),(0,r.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,r.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:f,onChange:e=>b(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:()=>{p.trim()?(w(null),T({baseUrl:x.trim()||o,clientId:p.trim(),clientSecret:f.trim()}),C(!0)):w("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,r.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,r.jsx)("a",{href:`${x.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,r.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,r.jsx)(i.pd,{label:"GitLab Base URL",value:x,onChange:e=>u(e.target.value),placeholder:o}),(0,r.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>j(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:P,fullWidth:!0,disabled:!g.trim()||y,loading:y,children:"Connect"}),(0,r.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},95892:(e,t,s)=>{s.d(t,{Od:()=>o,UserRoleProvider:()=>n,hd:()=>i});var r=s(95155),a=s(12115);let l=(0,a.createContext)({role:null,userId:null,displayName:null});function n({role:e,userId:t,displayName:s,children:i}){let[o,d]=(0,a.useState)({role:e,userId:t,displayName:s});return(0,a.useEffect)(()=>{},[]),(0,r.jsx)(l.Provider,{value:o,children:i})}function i(){return(0,a.useContext)(l)}function o(){let{role:e}=(0,a.useContext)(l);return"super_admin"===e}},96748:(e,t,s)=>{s.d(t,{default:()=>d});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:s,onSaved:l,node:n}){let c=!!n,[m,x]=(0,a.useState)({name:"",prefix:"",baseUrl:o}),[u,p]=(0,a.useState)(!1),[h,f]=(0,a.useState)(""),[b,g]=(0,a.useState)(""),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(N(null),f(""),g(""),c?x({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||o}):x({name:"",prefix:"",baseUrl:o}))},[e,c,n]);let w=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=c?"PUT":"POST",r={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl};c||(r.type="custom-embedding");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),i=await a.json();a.ok&&(c?l?.(i.node):s?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},k=async()=>{y(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:h,type:"custom-embedding",modelId:b.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{y(!1)}};return(0,r.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(i.pd,{label:"Name",value:m.name,onChange:e=>x({...m,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,r.jsx)(i.pd,{label:"Prefix",value:m.prefix,onChange:e=>x({...m,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,r.jsx)(i.pd,{label:"Base URL",value:m.baseUrl,onChange:e=>x({...m,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,r.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>f(e.target.value)}),(0,r.jsx)(i.pd,{label:"Model ID (for Check)",value:b,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(i.$n,{onClick:k,disabled:!h||!b.trim()||j||!m.baseUrl.trim(),variant:"secondary",children:j?"Checking...":"Check"}),(()=>{if(!v)return null;let{valid:e,error:t,dimensions:s}=v;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Ex,{variant:"success",children:"Valid"}),s&&(0,r.jsxs)("span",{className:"text-sm text-text-muted",children:[s," dims"]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:w,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||u,children:u?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,r.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string})}},97677:(e,t,s)=>{s.d(t,{default:()=>a});var r=s(95155);function a({text:e,children:t,position:s="top",color:l}){let n=l?"":"bg-gray-900";return(0,r.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,r.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[s]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${n} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:l?{backgroundColor:l}:{},children:e})]})}},98542:(e,t,s)=>{s.d(t,{default:()=>l});var r=s(95155),a=s(31474);function l({checked:e=!1,onChange:t,label:s,description:n,disabled:i=!1,size:o="md",className:d}){let c={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",i&&"opacity-50 cursor-not-allowed",d),children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:i,onClick:()=>{!i&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-brand-500/30",e?"bg-brand-500":"bg-surface-3",c[o].track,i&&"cursor-not-allowed"),children:(0,r.jsx)("span",{className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?c[o].translate:"translate-x-0.5",c[o].thumb,"mt-0.5")})}),(s||n)&&(0,r.jsxs)("div",{className:"flex flex-col",children:[s&&(0,r.jsx)("span",{className:"text-sm font-medium text-text-main",children:s}),n&&(0,r.jsx)("span",{className:"text-xs text-text-muted",children:n})]})]})}},98572:(e,t,s)=>{s.d(t,{default:()=>m});var r=s(95155),a=s(12115),l=s(14051),n=s.n(l),i=s(35497),o=s(32598),d=s(68828);let c="https://api.openai.com/v1";function m({isOpen:e,onClose:t,onCreated:s,onSaved:l,node:n}){let x=!!n,[u,p]=(0,a.useState)({name:"",prefix:"",baseUrl:c,defaultSize:""}),[h,f]=(0,a.useState)(""),[b,g]=(0,a.useState)(""),[j,y]=(0,a.useState)(!1),[v,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(""),[C,S]=(0,a.useState)(!1),[T,O]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(O(null),N(""),k(""),f(""),g(""),x?p({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||c,defaultSize:n.defaultSize||""}):p({name:"",prefix:"",baseUrl:c,defaultSize:""}))},[e,x,n]);let P=async()=>{if(u.name.trim()&&u.prefix.trim()&&u.baseUrl.trim()){y(!0);try{let e=x?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=x?"PUT":"POST",r={name:u.name,prefix:u.prefix,baseUrl:u.baseUrl,defaultSize:u.defaultSize.trim()};x||(r.type="custom-image");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),i=await a.json();a.ok&&(x?l?.(i.node):s?.(i.node))}catch(e){console.log("Error saving custom image node:",e)}finally{y(!1)}}},$=async()=>{S(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:u.baseUrl,apiKey:v,type:"custom-image",modelId:w.trim()||void 0,imageSize:u.defaultSize.trim()||void 0})}),t=await e.json();t.normalizedBaseUrl&&p(e=>({...e,baseUrl:t.normalizedBaseUrl})),O(t)}catch{O({valid:!1,error:"Network error"})}finally{S(!1)}};return(0,r.jsx)(i.aF,{isOpen:e,title:x?"Edit Custom Image":"Add Custom Image",onClose:t,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[!x&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Import From cURL"}),(0,r.jsx)("textarea",{value:h,onChange:e=>f(e.target.value),placeholder:'curl https://api.example.com/v1/images/generations -H "Authorization: Bearer sk-xxx" -H "Content-Type: application/json" -d \'{"model":"gpt-image-1","prompt":"A cute cat","size":"1024x1024","n":1}\'',className:"min-h-32 w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-text-muted",children:"Paste a working OpenAI-compatible image curl command to auto-fill fields."}),(0,r.jsx)(i.$n,{onClick:()=>{try{let e=(0,d.rk)(h);p({name:e.defaultName,prefix:e.defaultPrefix,baseUrl:e.baseUrl,defaultSize:e.imageSize||""}),N(e.apiKey||""),k(e.modelId||""),g("")}catch(e){g(e.message||"Failed to parse curl")}},variant:"secondary",children:"Parse cURL"})]}),b&&(0,r.jsx)("p",{className:"text-sm text-red-500",children:b})]}),(0,r.jsx)(i.pd,{label:"Name",value:u.name,onChange:e=>p({...u,name:e.target.value}),placeholder:"SenseNova Image",hint:"Required. A friendly label for this image provider."}),(0,r.jsx)(i.pd,{label:"Prefix",value:u.prefix,onChange:e=>p({...u,prefix:e.target.value}),placeholder:"sensenova",hint:"Required. Used as the provider prefix for model IDs (e.g. sensenova/sensenova-u1-fast)."}),(0,r.jsx)(i.pd,{label:"Base URL",value:u.baseUrl,onChange:e=>p({...u,baseUrl:e.target.value}),placeholder:"https://token.sensenova.cn/v1",hint:"The app will append /images/generations automatically."}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Default Size"}),(0,r.jsxs)("select",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:u.defaultSize,onChange:e=>p({...u,defaultSize:e.target.value}),children:[(0,r.jsx)("option",{value:"",children:"Use fallback"}),o.z.filter(e=>"auto"!==e).map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}),(0,r.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Used by model test and request example for vendors with restricted sizes."})]}),(0,r.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:v,onChange:e=>N(e.target.value)}),(0,r.jsx)(i.pd,{label:"Model ID (for Check)",value:w,onChange:e=>k(e.target.value),placeholder:"e.g. sensenova-u1-fast",hint:"Required for validation. Will send a test image generation request."}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(i.$n,{onClick:$,disabled:!v||!w.trim()||C||!u.baseUrl.trim(),variant:"secondary",children:C?"Checking...":"Check"}),(()=>{if(!T)return null;let{valid:e,error:t}=T;return e?(0,r.jsx)(i.Ex,{variant:"success",children:"Valid"}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(i.$n,{onClick:P,fullWidth:!0,disabled:!u.name.trim()||!u.prefix.trim()||!u.baseUrl.trim()||j,children:j?x?"Saving...":"Creating...":x?"Save":"Create"}),(0,r.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}m.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string,defaultSize:n().string})}}}]);
|