1import{a as Re,b as I,h as te,r as f,z as he,t as O,aa as J,A as se,ck as Ee,j as e,c as y,B as $,S as ae,g as Ie,aB as $e,F as R,cl as Pe,cm as Ae,b$ as Oe,ab as ze,bS as Le,Y as Fe,Z as Be,aw as H,b3 as He,cn as Ue,co as Qe,u as fe,cp as Ve,ap as ge,at as be,au as ye,av as je,aq as ve,cq as We,cr as Ke,cs as Ge,a1 as Ye,a0 as Ze,i as Xe,ct as Je,V as U}from"./index-QV4IKLWy.js";import{u as et}from"./use-mobile-Dzpyj444.js";import{S as tt,a as st,b as at,c as rt,d as nt}from"./sheet-D40BzFJf.js";import{T as it,a as ot,b as lt,c as dt}from"./tooltip-C4BJJbpi.js";import{P as ct}from"./panel-left-B6oE2qNU.js";import{L as we}from"./language-switch-KDyNRh87.js";import{D as K,a as G,b as Y,c as E,d as F,h as ut,i as mt,j as pt,f as re,k as xt,l as ht}from"./dropdown-menu-ArVj_r7h.js";import{I as Q}from"./IconCheck-DBu1IPVb.js";import{B as A}from"./badge-DgrPbXxO.js";import{P as ft,a as gt,b as bt}from"./popover-DxItDGMy.js";import{L as yt}from"./loader-circle-F9FvqoUP.js";import{R as jt}from"./refresh-cw-Bgw5o8j2.js";import{f as oe}from"./format-Cr--RMFj.js";import{P as vt}from"./permission-guard-CsgEtGWV.js";import{u as wt}from"./projects-Cd6niGjM.js";import{C as _e}from"./chevrons-up-down-D7xEDVx0.js";import{C as _t,a as Nt,b as kt}from"./collapsible-BOqguLek.js";import{C as Ne}from"./chevron-right-XZPDl4jy.js";import{A as le,a as de,b as ce}from"./avatar-BqGJNA4J.js";import{A as ke}from"./driver-B4w0q6_T.js";import"./index-D0E_EWLn.js";import"./index-BjjTdI9A.js";import"./index-B7KSpmBd.js";import"./index-DjW7Siof.js";import"./index-GUvDrQ0l.js";import"./check-CHQSjL-x.js";import"./usePermissions-B28mW86T.js";import"./pagination-CuFexddI.js";import"./schemas-F-8yFocu.js";import"./coerce-BwMxsVlN.js";import"./index-Cli-coQw.js";const qt=[["path",{d:"M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25",key:"svg-0"}],["path",{d:"M7.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M11.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}],["path",{d:"M15.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-3"}]],St=Re("outline","palette","Palette",qt);const Ct=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Mt=I("badge-check",Ct);const Dt=[["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 14v-4",key:"14a6bd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],Tt=I("battery-low",Dt);const Rt=[["path",{d:"M10 10v4",key:"1mb2ec"}],["path",{d:"M14 10v4",key:"1nt88p"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 10v4",key:"1n77qd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],Et=I("battery-full",Rt);const It=[["path",{d:"M10 14v-4",key:"suye4c"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 14v-4",key:"14a6bd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],$t=I("battery-medium",It);const Pt=[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 6h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2",key:"1m83kb"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"h8lgfh"}]],At=I("battery-warning",Pt);const Ot=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],zt=I("battery",Ot);const Lt=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],Ft=I("folder-kanban",Lt);const Bt=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ht=I("log-out",Bt);function V(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var n in a)n!=="__proto__"&&(t[n]=a[n])}return t}var Ut={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decode
1URIComponent)}};function ee(t,s){function a(i,l,o){if(!(typeof document>"u")){o=V({},s,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var d="";for(var u in o)o[u]&&(d+="; "+u,o[u]!==!0&&(d+="="+o[u].split(";")[0]));return document.cookie=i+"="+t.write(l,i)+d}}function n(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var l=document.cookie?document.cookie.split("; "):[],o={},d=0;d<l.length;d++){var u=l[d].split("="),x=u.slice(1).join("=");try{var g=decodeURIComponent(u[0]);if(g in o||(o[g]=t.read(x,g)),i===g)break}catch{}}return i?o[i]:o}}return Object.create({set:a,get:n,remove:function(i,l){a(i,"",V({},l,{expires:-1}))},withAttributes:function(i){return ee(this.converter,V({},this.attributes,i))},withConverter:function(i){return ee(V({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(s)},converter:{value:Object.freeze(t)}})}var Qt=ee(Ut,{path:"/"});const ue="axonhub_dismissed_version",me="axonhub_version_check_timestamp",Vt=600*1e3;function Wt(){const s=te(l=>l.auth.user)?.isOwner??!1,a=f.useCallback(()=>{if(!s)return!1;const l=localStorage.getItem(me);return l?Date.now()-parseInt(l,10)>=Vt:!0},[s]),{data:n}=he({queryKey:["versionCheck"],queryFn:async()=>(await se(Ee)).checkForUpdate,onSuccess:()=>{localStorage.setItem(me,Date.now().toString())},enabled:a(),retry:!1,staleTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1}),i=f.useCallback((l,o)=>{O.info(J.t("system.about.updateCheck.newVersionAvailable"),{description:`${J.t("system.about.updateCheck.latestVersion")}: ${l}`,duration:1e4,action:{label:J.t("system.about.updateCheck.viewRelease"),onClick:()=>{window.open(o,"_blank","noopener,noreferrer")}}})},[]);f.useEffect(()=>{!s||!n||!n.hasUpdate||localStorage.getItem(ue)===n.latestVersion||(i(n.latestVersion,n.releaseUrl),localStorage.setItem(ue,n.latestVersion))},[s,n,i])}const Kt="sidebar_state",Gt=3600*24*7,Yt="14rem",Zt="16rem",Xt="3rem",Jt="b",qe=f.createContext(null);function D(){const t=f.useContext(qe);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function es({defaultOpen:t=!0,open:s,onOpenChange:a,className:n,style:i,children:l,...o}){const d=et(),[u,x]=f.useState(!1),[g,C]=f.useState(t),S=s??g,N=f.useCallback(c=>{const p=typeof c=="function"?c(S):c;a?a(p):C(p),document.cookie=`${Kt}=${p}; path=/; max-age=${Gt}`},[a,S]),T=f.useCallback(()=>d?x(c=>!c):N(c=>!c),[d,N,x]);f.useEffect(()=>{const c=p=>{p.key===Jt&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),T())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[T]);const z=S?"expanded":"collapsed",r=f.useMemo(()=>({state:z,open:S,setOpen:N,isMobile:d,openMobile:u,setOpenMobile:x,toggleSidebar:T}),[z,S,N,d,u,x,T]);return e.jsx(qe.Provider,{value:r,children:e.jsx(it,{delayDuration:0,children:e.jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Yt,"--sidebar-width-icon":Xt,...i},className:y("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",n),...o,children:l})})})}function ts({side:t="left",variant:s="sidebar",collapsible:a="offcanvas",className:n,children:i,...l}){const{isMobile:o,state:d,openMobile:u,setOpenMobile:x}=D();return a==="none"?e.jsx("div",{"data-slot":"sidebar",className:y("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",n),...l,children:i}):o?e.jsx(tt,{open:u,onOpenChange:x,...l,children:e.jsxs(st,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":Zt},side:t,children:[e.jsxs(at,{className:"sr-only",children:[e.jsx(rt,{children:"Sidebar"}),e.jsx(nt,{children:"Displays the mobile sidebar."})]}),e.jsx("div",{className:"flex h-full w-full flex-col",children:i})]})}):e.jsxs("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":d,"data-collapsible":d==="collapsed"?a:"","data-variant":s,"data-side":t,"data-slot":"sidebar",children:[e.jsx("div",{"data-slot":"sidebar-gap",className:y("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",s==="floating"||s==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),e.jsx("div",{"data-slot":"sidebar-container",className:y("fixed top-14 bottom-0 z-10 hidden h-[calc(100vh-3.5rem)] w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",t==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",s==="floating"||s==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)",n),...l,children:e.jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm",children:i})})]})}function ss({className:t,onClick:s,...a}){const{toggleSidebar:n}=D();return e.jsxs($,{"data-sidebar":"trigger","data-slot":"sidebar-tr
1igger",variant:"ghost",size:"icon",className:y("size-7",t),onClick:i=>{s?.(i),n()},...a,children:[e.jsx(ct,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function as({className:t,...s}){const{toggleSidebar:a}=D();return e.jsx("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:a,title:"Toggle Sidebar",className:y("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...s})}function rs({className:t,...s}){return e.jsx("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:y("flex flex-col gap-2 p-2",t),...s})}function ns({className:t,...s}){const a=f.useRef(null),[n,i]=f.useState(!1),l=f.useCallback(()=>{const o=a.current;if(!o)return;const d=o.scrollHeight>o.clientHeight,u=o.scrollTop+o.clientHeight>=o.scrollHeight-10;i(d&&!u)},[]);return f.useEffect(()=>{const o=a.current;if(!o)return;l();const d=new ResizeObserver(l);return d.observe(o),o.addEventListener("scroll",l),()=>{d.disconnect(),o.removeEventListener("scroll",l)}},[l]),e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{ref:a,"data-slot":"sidebar-content","data-sidebar":"content",className:y("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...s}),e.jsx("div",{className:y("absolute bottom-0 left-0 right-0 h-8 pointer-events-none transition-opacity duration-300 bg-gradient-to-t from-sidebar to-transparent",n?"opacity-100":"opacity-0")})]})}function is({className:t,...s}){return e.jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:y("relative flex w-full min-w-0 flex-col p-2",t),...s})}function os({className:t,asChild:s=!1,...a}){const n=s?ae:"div";return e.jsx(n,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:y("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...a})}function Se({className:t,...s}){return e.jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:y("flex w-full min-w-0 flex-col gap-1",t),...s})}function Z({className:t,...s}){return e.jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:y("group/menu-item relative",t),...s})}const ls=Ie("flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-primary data-[active=true]:font-medium data-[active=true]:text-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function X({asChild:t=!1,isActive:s=!1,variant:a="default",size:n="default",tooltip:i,className:l,...o}){const d=t?ae:"button",{isMobile:u,state:x}=D(),g=e.jsx(d,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":n,"data-active":s,className:y(ls({variant:a,size:n}),l),...o});return i?(typeof i=="string"&&(i={children:i}),e.jsxs(ot,{children:[e.jsx(lt,{asChild:!0,children:g}),e.jsx(dt,{side:"right",align:"center",hidden:x!=="collapsed"||u,...i})]})):g}function ds({className:t,...s}){return e.jsx("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:y("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...s})}function cs({className:t,...s}){return e.jsx("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:y("group/menu-sub-item relative",t),...s})}function us({asChild:t=!1,size:s="md",isActive:a=!1,className:n,...i}){const l=t?ae:"a";return e.jsx(l,{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":s,"data-active":a,className:y("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focu
1s-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0","data-[active=true]:bg-primary data-[active=true]:text-primary-foreground",s==="sm"&&"text-xs",s==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",n),...i})}function Ce(){const{theme:t,setTheme:s,colorScheme:a,setColorScheme:n}=$e(),{t:i}=R(),l=[{name:"blue",label:i("theme.colors.blue"),color:"bg-blue-500"},{name:"green",label:i("theme.colors.green"),color:"bg-green-500"},{name:"purple",label:i("theme.colors.purple"),color:"bg-purple-500"},{name:"orange",label:i("theme.colors.orange"),color:"bg-orange-500"},{name:"red",label:i("theme.colors.red"),color:"bg-red-500"},{name:"black",label:i("theme.colors.black"),color:"bg-black"},{name:"cream",label:i("theme.colors.cream"),color:"bg-amber-100"},{name:"claude",label:i("theme.colors.claude"),color:"bg-amber-600"},{name:"starry",label:i("theme.colors.starry"),color:"bg-blue-600"}];return f.useEffect(()=>{const o=t==="dark"?"#020817":"#fff",d=document.querySelector("meta[name='theme-color']");d&&d.setAttribute("content",o)},[t]),e.jsxs(K,{modal:!1,children:[e.jsx(G,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"icon",className:"scale-95 rounded-full",children:[e.jsx(Pe,{className:"size-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90"}),e.jsx(Ae,{className:"absolute size-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0"}),e.jsx("span",{className:"sr-only",children:i("theme.toggle")})]})}),e.jsxs(Y,{align:"end",children:[e.jsxs(E,{onClick:()=>s("light"),children:[i("theme.light")," ",e.jsx(Q,{size:14,className:y("ml-auto",t!=="light"&&"hidden")})]}),e.jsxs(E,{onClick:()=>s("dark"),children:[i("theme.dark"),e.jsx(Q,{size:14,className:y("ml-auto",t!=="dark"&&"hidden")})]}),e.jsxs(E,{onClick:()=>s("system"),children:[i("theme.system"),e.jsx(Q,{size:14,className:y("ml-auto",t!=="system"&&"hidden")})]}),e.jsx(F,{}),e.jsxs(ut,{children:[e.jsxs(mt,{children:[e.jsx(St,{size:14,className:"mr-2"}),i("theme.colorScheme"),e.jsx("div",{className:y("ml-auto h-3 w-3 rounded-full",l.find(o=>o.name===a)?.color||"bg-blue-500")})]}),e.jsx(pt,{children:l.map(o=>e.jsxs(E,{onClick:()=>n(o.name),className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:y("mr-2 h-3 w-3 rounded-full",o.color)}),o.label]}),e.jsx(Q,{size:14,className:y("ml-auto",a!==o.name&&"hidden")})]},o.name))})]})]})]})}const ms=` 2 mutation CheckProviderQuotas { 3 checkProviderQuotas 4 } 5`,ps=` 6 query ProviderQuotaStatuses($input: QueryChannelInput!) { 7 queryChannels(input: $input) { 8 edges { 9 node { 10 id 11 name 12 type 13 providerQuotaStatus { 14 status 15 nextResetAt 16 ready 17 quotaData 18 providerType 19 } 20 } 21 } 22 } 23 } 24`;async function xs(){return se(ms)}function hs(t){const s=t.providerQuotaStatus,a=s?.providerType,n={id:t.id,name:t.name,quotaStatus:{status:s.status,nextResetAt:s.nextResetAt,ready:s.ready}};if(t.type==="claudecode")return{...n,type:"claudecode",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}};if(t.type==="codex")return{...n,type:"codex",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}};if(t.type==="github_copilot")return{...n,type:"github_copilot",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}};if(t.type==="nanogpt")return{...n,type:"nanogpt",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}};if(t.type==="nanogpt_responses")return{...n,type:"nanogpt_responses",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}};if(t.type==="openai"||t.type==="openai_responses"){const i=t.type;return a==="wafer"?{...n,type:i,providerType:"wafer",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}}:a==="synthetic"?{...n,type:i,providerType:"synthetic",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}}:a==="neuralwatt"?{...n,type:i,providerType:"neuralwatt",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}}:a==="apertis"?{...n,type:i,providerType:"apertis",quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}}:{...n,type:i,providerType:void 0,quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}}}return{...n,type:t.type,quotaStatus:{...n.quotaStatus,quotaData:t.providerQuotaStatus.quotaData}}}function fs(){const{data:t}=he({queryKey:["provider-quotas"],queryFn:async()=>se(ps,{input:{where:{statusIn:["enabled"]}}}
24),refetchInterval:6e4,refetchIntervalInBackground:!0});return(t?.queryChannels?.edges?.map(n=>n.node)||[]).filter(n=>n.providerQuotaStatus!=null).map(hs)}const gs=.02,pe={green:"bg-green-500/10 text-green-500 border-green-500/20 hover:bg-green-500/20",red:"bg-red-500/10 text-red-500 border-red-500/20 hover:bg-red-500/20",amber:"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20"},bs={available:"quota.status.available",warning:"quota.status.warning",exhausted:"quota.status.exhausted",unknown:"quota.status.unknown"};function Me(t){switch(t){case"full":return Et;case"medium":return $t;case"low":return Tt;case"warning":return At;default:return zt}}function De(t,s){if(s==="exhausted")return"warning";const a=100-t;return a<5?"empty":a<20?"low":a<80?"medium":"full"}function M(t){return t==="openai"||t==="openai_responses"}function Te(t){let s=0;if(!t.quotaStatus)return 0;if(t.type==="claudecode"){const a=t.quotaStatus.quotaData,n=a.windows?.["5h"]?.utilization||0,i=a.windows?.["7d"]?.utilization||0;s=Math.max(n,i)*100}else if(t.type==="codex")s=t.quotaStatus.quotaData.rate_limit?.primary_window?.used_percent||0;else if(t.type==="github_copilot"){const a=t.quotaStatus.quotaData;let n=100;const i=a.limited_user_quotas,l=a.total_quotas;i&&Object.entries(i).forEach(([o,d])=>{if(typeof d=="number"){const u=l?.[o]??d;u>0&&(n=Math.min(n,d/u*100))}}),a.quota_snapshots&&Object.values(a.quota_snapshots).forEach(o=>{o&&!o.unlimited&&typeof o.percent_remaining=="number"&&(n=Math.min(n,o.percent_remaining))}),s=100-n}else if(t.type==="nanogpt"||t.type==="nanogpt_responses"){const a=t.quotaStatus?.quotaData;if(!a)return 0;let n=0;a.windows?.weeklyInputTokens&&(n=Math.max(n,(a.windows.weeklyInputTokens.percentUsed??0)*100)),a.windows?.dailyInputTokens&&(n=Math.max(n,(a.windows.dailyInputTokens.percentUsed??0)*100)),a.windows?.dailyImages&&(n=Math.max(n,(a.windows.dailyImages.percentUsed??0)*100)),s=n}else if(M(t.type)&&t.providerType==="wafer")s=t.quotaStatus?.quotaData?.current_period_used_percent??0;else if(M(t.type)&&t.providerType==="synthetic")s=100-(t.quotaStatus?.quotaData?.weeklyTokenLimit?.percentRemaining??100);else if(M(t.type)&&t.providerType==="neuralwatt"){const a=t.quotaStatus?.quotaData,n=a?.subscription?.kwh_included??0,i=a?.subscription?.kwh_used??0;n>0&&(s=i/n*100)}else M(t.type)&&t.providerType==="apertis"&&(s=ys(t.quotaStatus?.quotaData));return s}function ys(t){return t?t.is_subscriber&&t.subscription?.cycle_quota_limit?t.subscription.cycle_quota_used/t.subscription.cycle_quota_limit*100:t.payg&&!t.payg.token_is_unlimited&&typeof t.payg.token_total=="number"&&typeof t.payg.token_used=="number"?t.payg.token_used/t.payg.token_total*100:0:0}function w({percentage:t,type:s="usage",durationPercentage:a}){const n=Math.min(Math.max(t||0,0),100);let i={};if(s==="duration")i={backgroundColor:"#71717a"};else{const l=n/100;let o=l;if(a!==void 0&&a>0){const g=Math.max(a/100,.01);o=l*(l/g)}o=Math.min(1,Math.max(0,o));let d,u,x;if(o<.5){const g=o*2;d=142-g*97,u=71+g*22,x=45+g*2}else{const g=(o-.5)*2;d=45-g*45,u=93-g*9,x=47+g*13}i={backgroundColor:`hsl(${Math.round(d)}, ${Math.round(u)}%, ${Math.round(x)}%)`}}return e.jsx("div",{className:"bg-muted/60 h-1.5 w-full overflow-hidden rounded-full",children:e.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${n}%`,...i}})})}function xe(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:`${t}`}function js({channel:t,enforcementMode:s}){const{t:a}=R(),n=t.quotaStatus;if(!n)return null;const i=n.status,l=a(bs[i]),o=s&&(i==="exhausted"||i==="warning"&&s==="DE_PRIORITIZE")?s==="EXHAUSTED_ONLY"?"blocked":"deprioritized":null,d=Te(t),u=De(d,i),x=Me(u),g=r=>{if(!r)return"";const c=Math.floor(r/3600),p=c>=24?Math.floor(c/24):0;return p>0?`${p}${a(p>1?"quota.label.days":"quota.label.day")}`:c>0?`${c}${a(c>1?"quota.label.hours":"quota.label.hour")}`:`${Math.floor(r/60)}${a("quota.label.mins")}`},C=(r,c)=>{if(!r||c===void 0)return 0;const p=r-c;return Math.max(0,Math.min(100,p/r*100))},S=(r,c)=>{if(!c)return;let p=0;if(r==="5h")p=5*3600;else if(r==="7d")p=168*3600;else return;const b=Date.now()/1e3,m=c-b;return C(p,m)},N=(r,c,p)=>{if(!r)return"";let b;if(typeof r=="number"?b=Date.now()+r*1e3:b=new Date(r).getTime(),c===0)return a("quota.label.no_usage_yet");const m=Date.now(),h=b-m,j=p!=null&&p!==!1,k=typeof p=="number"?Math.round(p*100):null;if(h<0)return a(j?"quota.label.regenerating_now":"quota.label.reset_now");
24const _=Math.floor(h/6e4),v=Math.floor(_/60),q=Math.floor(v/24),L=a("quota.label.d"),ne=a("quota.label.h"),ie=a("quota.label.m");let P;return q>0?P=`${q}${L} ${v%24}${ne}`:v>0?P=`${v}${ne} ${_%60}${ie}`:P=`${_}${ie}`,j&&k!=null?a("quota.label.regenerates_pct_in_time",{percent:k,time:P}):j?a("quota.label.regenerates_in_time",{time:P}):a("quota.label.resets_in_time",{time:P})},T=r=>{if(!r)return"";const c=new Date(r*1e3),p=new Date;return c.toDateString()===p.toDateString()?`${a("quota.label.today")}, ${c.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}`:c.getFullYear()===p.getFullYear()?oe(c,"MM-dd HH:mm"):oe(c,"yyyy-MM-dd HH:mm")},z=n.quotaData;return e.jsxs("div",{className:"space-y-3 border-b py-3 first:pt-1 last:border-0 last:pb-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:`h-4 w-4 ${i==="exhausted"?"text-red-500":i==="warning"?"text-yellow-500":"text-muted-foreground"}`}),e.jsx("span",{className:"text-foreground font-medium",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(A,{variant:i==="available"?"outline":i==="warning"?"secondary":i==="exhausted"?"destructive":"outline",className:i==="available"?pe.green:"",children:l}),o&&e.jsx(A,{variant:"outline",className:pe[o==="blocked"?"red":"amber"],children:a(`quota.status.${o}`)})]})]}),z.error&&e.jsxs("div",{className:"ml-6 rounded bg-red-500/10 p-2 text-xs break-words text-red-500",children:[e.jsxs("span",{className:"font-medium",children:[a("quota.label.error"),":"]})," ",z.error]}),t.type==="claudecode"&&e.jsx("div",{className:"mt-4 space-y-4",children:(()=>{const r=t.quotaStatus?.quotaData;return r?e.jsxs(e.Fragment,{children:[r.windows?.["5h"]&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.window.5h")}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round((r.windows["5h"].utilization||0)*100),"%"]})]}),e.jsx(w,{percentage:(r.windows["5h"].utilization||0)*100,durationPercentage:S("5h",r.windows["5h"].reset)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.label.5h_duration")}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round(S("5h",r.windows["5h"].reset)||0),"%"]})]}),e.jsx(w,{type:"duration",percentage:S("5h",r.windows["5h"].reset)||0})]})]}),r.windows?.["7d"]&&e.jsxs("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.window.7d")}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round((r.windows["7d"].utilization||0)*100),"%"]})]}),e.jsx(w,{percentage:(r.windows["7d"].utilization||0)*100,durationPercentage:S("7d",r.windows["7d"].reset)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.label.7d_duration")}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round(S("7d",r.windows["7d"].reset)||0),"%"]})]}),e.jsx(w,{type:"duration",percentage:S("7d",r.windows["7d"].reset)||0})]})]}),r.windows?.overage&&e.jsx("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.label.overage_window")}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round((r.windows.overage.utilization||0)*100),"%"]})]}),e.jsx(w,{percentage:(r.windows.overage.utilization||0)*100})]})}),(n.nextResetAt||r.representative_claim)&&e.jsxs("div",{className:"text-muted-foreground flex items-center justify-between pt-1 text-[11px]",children:[e.jsx("span",{children:r.representative_claim==="five_hour"?a("quota.label.5h_limiting"):r.representative_claim==="seven_day"?a("quota.label.7d_limiting"):""}),n.nextResetAt&&e.jsxs("span",{children:[N(n.nextResetAt)," (",T(new Date(n.nextResetAt).getTime()/1e3),")"]})]})]}):null})()}),t.type==="github_copilot"&&e.jsxs("div",{className:"mt-3 space-y-3",children:[(()=>{const r=t.quotaStatus?.quotaData;if(!r)return null;const c=[],p=r.limited_user_quotas,b=r.total_quotas;
24return p&&Object.entries(p).forEach(([m,h])=>{if(typeof h=="number"){const j=b?.[m]??h,k=h/10,_=j/10,v=j>0?(1-h/j)*100:0,q=m==="completions"?"quota.label.inline_suggestions":m==="chat"?"quota.label.chat_messages":"",L=q?a(q):m.replace(/_/g," ");c.push(e.jsx("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3 first:border-0 first:pt-0",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[L," ",e.jsxs("span",{className:"font-normal opacity-70",children:["(",Math.round(k),"/",Math.round(_),")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(v)})})]}),e.jsx(w,{percentage:v})]})},m))}}),r.quota_snapshots&&Object.entries(r.quota_snapshots).forEach(([m,h])=>{if(h){const j=h.unlimited?0:100-(h.percent_remaining||0),k=m==="premium_interactions"?"quota.label.premium_interactions":m==="premium_models"?"quota.label.premium_models":m==="completions"?"quota.label.inline_suggestions":m==="chat"?"quota.label.chat_messages":"",_=k?a(k):m.replace(/_/g," "),v=h.quota_remaining||h.remaining||0,q=h.entitlement||0;c.push(e.jsx("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3 first:border-0 first:pt-0",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[_," ",!h.unlimited&&e.jsxs("span",{className:"font-normal opacity-70",children:["(",Math.round(v),"/",Math.round(q),")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:h.unlimited?a("quota.label.unlimited"):a("quota.label.percent_used",{percent:Math.round(j)})})]}),!h.unlimited&&e.jsx(w,{percentage:j})]})},m))}}),c})(),n.nextResetAt&&e.jsxs("div",{className:"text-muted-foreground pt-1 text-right text-[11px]",children:[N(n.nextResetAt)," (",T(new Date(n.nextResetAt).getTime()/1e3),")"]})]}),t.type==="codex"&&e.jsx("div",{className:"mt-4 space-y-4",children:(()=>{const r=t.quotaStatus?.quotaData;return r?e.jsxs(e.Fragment,{children:[r.rate_limit?.primary_window&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.label.primary_window")}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round(r.rate_limit.primary_window.used_percent||0),"%"]})]}),e.jsx(w,{percentage:r.rate_limit.primary_window.used_percent||0,durationPercentage:r.rate_limit.primary_window.limit_window_seconds?C(r.rate_limit.primary_window.limit_window_seconds,r.rate_limit.primary_window.reset_after_seconds):void 0})]}),r.rate_limit.primary_window.limit_window_seconds?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.primary_duration")," (",g(r.rate_limit.primary_window.limit_window_seconds),")"]}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round(C(r.rate_limit.primary_window.limit_window_seconds,r.rate_limit.primary_window.reset_after_seconds)),"%"]})]}),e.jsx(w,{type:"duration",percentage:C(r.rate_limit.primary_window.limit_window_seconds,r.rate_limit.primary_window.reset_after_seconds)})]}):null,r.rate_limit.primary_window.reset_at&&e.jsxs("div",{className:"text-muted-foreground pt-0.5 text-right text-[11px]",children:[N(r.rate_limit.primary_window.reset_after_seconds)," (",T(r.rate_limit.primary_window.reset_at),")"]})]}),r.rate_limit?.secondary_window?.used_percent!==void 0&&e.jsxs("div",{className:"border-border/60 mt-3 space-y-2.5 border-t border-dashed pt-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.label.secondary_window")}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round(r.rate_limit.secondary_window.used_percent),"%"]})]}),e.jsx(w,{percentage:r.rate_limit.secondary_window.used_percent,durationPercentage:r.rate_limit.secondary_window.limit_window_seconds?C(r.rate_limit.secondary_window.limit_window_seconds,r.rate_limit.secondary_window.reset_after_seconds):void 0})]}),r.rate_limit.secondary_window.limit_window_seconds?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.secondary_duration")," (",g(r.rate_limit.secondary_window.limit_window_seconds),")"]}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round(C(r.rate_limit.secondary_window.limit_window_seconds,r.rate_limit.secondary_window.reset_after_seconds)),"%"]})]}),e.jsx(w,{type:"duration",percentage:C(r.rate_limit.secondary_window.limit_window_seconds,r.rate_limit.secondary_window.reset_after_seconds)})]}):null,r.rate_limit.secondary_window.reset_at&&e.jsxs("div",{className:"text-muted-foreground pt-0.5 text-right text-[11px]",children:[N(r.rate_limit.secondary_window.reset_after_seconds)," (",T(r.rate_limit.secondary_window.reset_at),")"]})]})]}):null})()}),(t.type==="nanogpt"||t.type==="nanogpt_responses")&&e.jsx("div",{className:"mt-3 space-y-3",children:(()=>{const r=t.quotaStatus?.quotaData;if(!r)return null;const c=[];if([["weekly_input_tokens",r.windows?.weeklyInputTokens,!0],["daily_images",r.windows?.dailyImages,!1],["daily_input_tokens",r.windows?.dailyInputTokens,!0]].forEac
24h(([b,m,h],j)=>{if(!m)return;const k=a(`quota.window.${b}`),_=(m.percentUsed??0)*100,v=h?xe(m.used??0):`${m.used??0}`,q=(m.used??0)+(m.remaining??0),L=h?xe(q):`${q}`;c.push(e.jsxs("div",{className:j>0?"border-border/60 space-y-2.5 border-t border-dashed pt-3":"space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[k," ",e.jsxs("span",{className:"font-normal opacity-70",children:["(",v,"/",L,")"]})]}),e.jsxs("span",{className:"text-foreground font-medium",children:[Math.round(_),"%"]})]}),e.jsx(w,{percentage:_})]}),m.resetAt?e.jsx("div",{className:"text-muted-foreground pt-0.5 text-right text-[11px]",children:N(new Date(m.resetAt).toISOString())}):null]},b))}),r.state&&r.state!=="active"){const b=`quota.label.state_${r.state}`;c.push(e.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:e.jsx(A,{variant:"outline",className:"h-4 border-yellow-500/30 px-1.5 py-0 text-[10px] font-semibold tracking-wider text-yellow-500 uppercase",children:a(b)})},"state"))}return c})()}),M(t.type)&&t.providerType==="wafer"&&e.jsx("div",{className:"mt-3 space-y-3",children:(()=>{const r=t.quotaStatus?.quotaData;if(!r)return null;const c=[],p=r.current_period_used_percent??0,b=(r.included_request_limit??0)-(r.remaining_included_requests??0),m=r.included_request_limit??0;return c.push(e.jsx("div",{className:"space-y-2.5",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.requests")," ",e.jsxs("span",{className:"font-normal opacity-70",children:["(",b,"/",m,")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(p)})})]}),e.jsx(w,{percentage:p})]})},"usage")),r.window_end&&c.push(e.jsx("div",{className:"text-muted-foreground pt-1 text-right text-[11px]",children:N(r.window_end,p)},"reset")),c})()}),M(t.type)&&t.providerType==="synthetic"&&e.jsx("div",{className:"mt-3 space-y-3",children:(()=>{const r=t.quotaStatus?.quotaData;if(!r)return null;const c=[];if(r.weeklyTokenLimit){const b=100-(r.weeklyTokenLimit.percentRemaining??100),m=r.weeklyTokenLimit.remainingCredits,h=r.weeklyTokenLimit.maxCredits,j=m!=null&&h!=null?`$${(parseFloat(h.replace("$",""))-parseFloat(m.replace("$",""))).toFixed(2)}`:null;c.push(e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.weekly_token_limit"),j!=null&&h!=null&&e.jsxs("span",{className:"font-normal opacity-70",children:[" ","(",j,"/",h,")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(b)})})]}),e.jsx(w,{percentage:b})]}),r.weeklyTokenLimit.nextRegenAt&&e.jsx("div",{className:"text-muted-foreground pt-0.5 text-right text-[11px]",children:N(r.weeklyTokenLimit.nextRegenAt,b,gs)})]},"weekly"))}if(r.rollingFiveHourLimit){const p=r.rollingFiveHourLimit.remaining??0,b=r.rollingFiveHourLimit.max??0,m=b-p,h=b>0?m/b*100:0;c.push(e.jsxs("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.rolling_5h_limit")," ",e.jsxs("span",{className:"font-normal opacity-70",children:["(",Math.round(m),"/",Math.round(b),")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(h)})})]}),e.jsx(w,{percentage:h})]}),r.rollingFiveHourLimit.limited&&e.jsx(A,{variant:"outline",className:"h-4 border-yellow-500/30 px-1.5 py-0 text-[10px] font-semibold tracking-wider text-yellow-500 uppercase",children:a("quota.status.limited")}),r.rollingFiveHourLimit.nextTickAt&&e.jsx("div",{className:"text-muted-foreground pt-0.5 text-right text-[11px]",children:N(r.rollingFiveHourLimit.nextTickAt,h,r.rollingFiveHourLimit.tickPercent??.05)})]},"5h"))}return c})()}),M(t.type)&&t.providerType==="neuralwatt"&&e.jsx("div",{className:"mt-3 space-y-3",children:(()=>{const r=t.quotaStatus?.quotaData;if(!r)return null;const c=[];if(r.subscription){const p=r.subscription.kwh_included??0,b=r.subscription.kwh_used??0,m=p>0?b/p*100:0;c.push(e.jsx("div",{className:"space-y-2.5",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.kwh_remaining"),e.jsxs("span",{className:"font-normal opacity-70",children:[" ","(",b,"/",p,")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(m)})})]}),e.jsx(w,{percentage:m})]})},"kwh")),r.subscription.in_overage&&c.push(e.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:e.jsx(A,{variant:"destructive",className:"h-4 px-1.5 py-0 text-[10px] font-semibold tracking-wider up
24percase",children:a("quota.label.in_overage")})},"overage"))}return r.balance&&c.push(e.jsx("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3",children:e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.label.credits_remaining")}),e.jsx("span",{className:"text-foreground font-medium",children:r.balance.credits_remaining_usd!=null?`$${r.balance.credits_remaining_usd.toFixed(2)}`:"$0.00"})]})},"credits")),n.nextResetAt&&c.push(e.jsx("div",{className:"text-muted-foreground pt-1 text-right text-[11px]",children:N(n.nextResetAt)},"reset")),c})()}),M(t.type)&&t.providerType==="apertis"&&e.jsx("div",{className:"mt-3 space-y-3",children:(()=>{const r=t.quotaStatus?.quotaData;if(!r)return null;const c=[];if(r.is_subscriber&&r.subscription&&r.subscription.cycle_quota_limit>0){const m=r.subscription.cycle_quota_used,h=r.subscription.cycle_quota_limit,j=m/h*100,k=r.subscription.plan_type?`${r.subscription.plan_type.charAt(0).toUpperCase()+r.subscription.plan_type.slice(1)}
24 Plan`:a("quota.label.subscription");if(c.push(e.jsx("div",{className:"space-y-2.5",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[k,e.jsxs("span",{className:"font-normal opacity-70",children:[" ","(",m,"/",h,")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(j)})})]}),e.jsx(w,{percentage:j})]})},"subscription")),r.subscription.payg_fallback_enabled){const _=r.subscription.payg_spent_usd,v=r.subscription.payg_limit_usd,q=_!=null&&v!=null&&v>0?_/v*100:0;c.push(e.jsx("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.payg_fallback"),_!=null&&v!=null&&e.jsxs("span",{className:"font-normal opacity-70",children:[" ","($",_.toFixed(2),"/$",v.toFixed(2),")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:_!=null&&v!=null?a("quota.label.percent_used",{percent:Math.round(q)}):""})]}),_!=null&&v!=null&&v>0&&e.jsx(w,{percentage:q})]})},"fallback"))}}const p=r.payg&&(r.payg.account_credits>0||typeof r.payg.token_used=="number"&&r.payg.token_used>0),b=!r.is_subscriber||r.subscription?.status!=="active"||r.subscription?.payg_fallback_enabled||p;if(b&&r.payg&&!r.payg.token_is_unlimited&&typeof r.payg.token_total=="number"&&typeof r.payg.token_used=="number"&&r.payg.token_total>0){const m=r.payg.token_used,h=r.payg.token_total,j=m/h*100,k=c.length>0;c.push(e.jsx("div",{className:k?"border-border/60 space-y-2.5 border-t border-dashed pt-3":"space-y-2.5",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.token_usage"),e.jsxs("span",{className:"font-normal opacity-70",children:[" ","($",m.toFixed(2),"/$",h.toFixed(2),")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(j)})})]}),e.jsx(w,{percentage:j})]})},"payg"))}if(b&&r.payg&&r.payg.account_credits!==void 0){const m=c.length>0;c.push(e.jsx("div",{className:m?"border-border/60 space-y-2.5 border-t border-dashed pt-3":"space-y-2.5",children:e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:a("quota.label.account_balance")}),e.jsx("span",{className:"text-foreground font-medium",children:r.payg.token_is_unlimited?`${a("quota.label.unlimited")} · $${r.payg.account_credits.toFixed(2)}`:`$${r.payg.account_credits.toFixed(2)}`})]})},"balance"))}if(b&&r.payg?.token_monthly_limit_usd!=null&&r.payg.token_monthly_used_usd!=null){const m=r.payg.token_monthly_limit_usd>0?r.payg.token_monthly_used_usd/r.payg.token_monthly_limit_usd*100:0;c.push(e.jsx("div",{className:"border-border/60 space-y-2.5 border-t border-dashed pt-3",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a("quota.label.monthly_limit"),e.jsxs("span",{className:"font-normal opacity-70",children:[" ","($",r.payg.token_monthly_used_usd.toFixed(2),"/$",r.payg.token_monthly_limit_usd.toFixed(2),")"]})]}),e.jsx("span",{className:"text-foreground font-medium",children:a("quota.label.percent_used",{percent:Math.round(m)})})]}),e.jsx(w,{percentage:m})]})},"monthly"))}return n.nextResetAt&&c.push(e.jsx("div",{className:"text-muted-foreground pt-1 text-right text-[11px]",children:N(n.nextResetAt)},"reset")),c})()})]})}function vs({channels:t}){const s=Math.max(...t.map(u=>u.quotaStatus?Te(u):0)),a=t.some(u=>u.quotaStatus?.status==="exhausted"),n=t.some(u=>u.quotaStatus?.status==="warning");let i="full";a?i="warning":n?i="low":i=De(s,"available");const l=Me(i),d=i==="warning"?"text-red-500":i==="low"?"text-yellow-500":"text-muted-foreground";return e.jsx(l,{className:`h-5 w-5 ${d} transition-colors`})}function ws({isRefreshing:t,onRefresh:s}){const{t:a}=R(),n=fs(),{data:i}=Oe(),l=i?.enabled?i.mode:null;if(n.length===0)return null;const o=n.reduce((d,u)=>(u.type==="nanogpt_responses"?d.find(g=>g.type==="nanogpt")||d.push(u):M(u.type)&&u.providerType&&d.find(g=>M(g.type)&&g.providerType===u.providerType)||d.push(u),d),[]);return e.jsxs(ft,{children:[e.jsx(gt,{asChild:!0,children:e.jsx("button",{type:"button",className:"hover:bg-muted relative rounded-md p-2 transition-colors",children:e.jsx(vs,{channels:o})})}),e.jsx(bt,{className:o.length>4?"w-full sm:w-[640px]":"w-full sm:w-80",align:"end",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:a("system.providerQuota.title")}),e.jsx("button",{onClick:s,disabled:t,className:"text-muted-foreground hover:text-foreground transition-colors","aria-label":a("system.providerQuota.refresh.label"),children:t?e.jsx(yt,{className:"h-4 w-4 animate-spin"}):e.jsx(jt,{className:"h-4 w-4"})})]}),e.jsx("div",{className:`max-h-[60vh] overflow-y-auto pr-1 pl-1 ${o.length>4?"grid grid-cols-1 gap-x-4 sm:grid-cols-2":""}`,children:o.map(d=>e.jsx(js,{channel:d,enforcementMode:l},d.id))})]})})]})}function _s(){const{data:t,isLoading:s}
24=wt(),{t:a}=R(),{selectedProjectId:n,setSelectedProjectId:i}=ze();f.useEffect(()=>{if(!t)return;if(t.length===0){n&&i(null);return}if(n&&t.some(C=>C.id===n))return;const x=t[0];i(x.id)},[t,n,i]);const l=x=>{i(x)},o=f.useMemo(()=>t?.find(x=>x.id===n),[t,n]);if(!(!s&&t&&t.length>0))return null;const u=o?.name||a("sidebar.projectSwitcher.selectProject");return e.jsxs(K,{children:[e.jsx(G,{asChild:!0,children:e.jsxs("button",{className:"hover:bg-accent/50 inline-flex items-center gap-1 rounded-md px-2 py-1 text-sm leading-none transition-colors",children:[e.jsx("span",{className:"text-sm leading-none font-medium",children:u}),e.jsx(_e,{className:"text-muted-foreground size-3"})]})}),e.jsxs(Y,{className:"min-w-56 rounded-lg",align:"start",sideOffset:4,children:[e.jsx(re,{className:"text-muted-foreground text-xs",children:a("sidebar.projectSwitcher.projects")}),t.map(x=>e.jsxs(E,{onClick:()=>l(x.id),className:"gap-2 p-2",children:[e.jsx("div",{className:"flex size-6 items-center justify-center rounded-sm border",children:e.jsx(Ft,{className:"size-4 shrink-0"})}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-sm font-medium",children:x.name})}),n===x.id&&e.jsx(xt,{children:"â"})]},x.id))]})]})}function Ns(){const{data:t}=Le(),{t:s}=R(),[a,n]=f.useState(!1),i=Fe(),{isMobile:l}=D(),o=t?.brandName||"AxonHub",d=Be({mutationFn:async()=>xs(),onSuccess:()=>{i.refetchQueries({queryKey:["provider-quotas"]}),O.success(s("system.providerQuota.refresh.success"))},onError:x=>{O.error(x.message||s("system.providerQuota.refresh.failure"))}}),u=f.useCallback(()=>{n(!0),d.mutate(void 0,{onSettled:()=>n(!1)})},[d]);return e.jsx("header",{className:"bg-background/95 supports-[backdrop-filter]:bg-background/60 fixed top-0 z-50 w-full backdrop-blur",children:e.jsxs("div",{className:"flex h-14 items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 pl-6",children:[e.jsx(ss,{className:"-ml-4 size-8"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded",children:t?.brandLogo?e.jsx("img",{src:t.brandLogo,alt:"Brand Logo",width:24,height:24,className:"size-8 object-cover",onError:x=>{x.currentTarget.src="/logo.jpg"}}):e.jsx("img",{src:"/logo.jpg",alt:"Default Logo",width:24,height:24,className:"size-8 object-cover"})}),e.jsx("span",{className:"text-sm leading-none font-semibold",children:o})]}),e.jsx("div",{className:"bg-border mx-0.5 h-3.5 w-px"}),e.jsx(_s,{})]}),e.jsxs("div",{className:"flex items-center gap-2 pr-6",children:[e.jsx(ws,{onRefresh:u,isRefreshing:a}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(vt,{requiredSystemScope:"read_system",children:e.jsx(H,{to:"/system",children:e.jsx($,{variant:"ghost",size:"icon",className:"size-8",children:e.jsx(He,{className:"h-4 w-4"})})})}),e.jsx(we,{}),e.jsx(Ce,{})]})]})]})})}function ks({title:t,items:s}){const{state:a,isMobile:n}=D(),i=Ue({select:o=>o.href}),l=s.filter(o=>o.items?o.items.some(u=>!u.isDisabled)&&!o.isDisabled:!(o.isDisabled||o.mobileOnly&&!n));return l.length===0?null:e.jsxs(is,{children:[e.jsx(os,{children:t}),e.jsx(Se,{children:l.map(o=>{const d=`${o.title}-${o.url}`;return o.items?a==="collapsed"&&!n?e.jsx(Cs,{item:o,href:i},d):e.jsx(Ss,{item:o,href:i},d):e.jsx(qs,{item:o,href:i},d)})})]})}const W=({children:t})=>e.jsx(A,{className:"rounded-full px-1 py-0 text-xs",children:t}),qs=({item:t,href:s})=>{const{setOpenMobile:a}=D();return e.jsx(Z,{children:e.jsx(X,{asChild:!0,isActive:B(s,t),tooltip:t.title,className:"h-12 rounded-2xl transition-all",children:e.jsxs(H,{to:t.url,onClick:()=>a(!1),children:[t.icon&&e.jsx(t.icon,{className:"text-xl"}),e.jsx("span",{children:t.title}),t.badge&&e.jsx(W,{children:t.badge})]})})})},Ss=({item:t,href:s})=>{const{setOpenMobile:a}=D(),n=t.items.filter(i=>!i.isDisabled);return e.jsx(_t,{asChild:!0,defaultOpen:B(s,t,!0),className:"group/collapsible",children:e.jsxs(Z,{children:[e.jsx(Nt,{asChild:!0,children:e.jsxs(X,{tooltip:t.title,className:"h-12 rounded-2xl transition-all",children:[t.icon&&e.jsx(t.icon,{className:"text-xl"}),e.jsx("span",{children:t.title}),t.badge&&e.jsx(W,{children:t.badge}),e.jsx(Ne,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),e.jsx(kt,{className:"CollapsibleContent",children:e.jsx(ds,{children:n.map(i=>e.jsx(cs,{children:e.jsx(us,{asChild:!0,isActive:B(s,i),children:e.jsxs(H,{to:i.url,onClick:()=>a(!1),children:[i.icon&&e.jsx(i.icon,{}),e.jsx("span",{children:i.title}),i.badge&&e.jsx(W,{children:i.badge})]})})},i.title))})})]})})},Cs=({item:t,href:s})=>{const a=t.items.filter(n=>!n.isDisabled);return e.jsx(Z,{children:e.jsxs(K,{children:[e.jsx(G,{asChild:!0,children:e.jsxs(X,{tooltip:t.t
24itle,isActive:B(s,t),className:"h-12 rounded-2xl transition-all",children:[t.icon&&e.jsx(t.icon,{className:"text-xl"}),e.jsx("span",{children:t.title}),t.badge&&e.jsx(W,{children:t.badge}),e.jsx(Ne,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),e.jsxs(Y,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(re,{children:[t.title," ",t.badge?`(${t.badge})`:""]}),e.jsx(F,{}),a.map(n=>e.jsx(E,{asChild:!0,children:e.jsxs(H,{to:n.url,className:`${B(s,n)?"bg-secondary":""}`,children:[n.icon&&e.jsx(n.icon,{}),e.jsx("span",{className:"max-w-52 text-wrap",children:n.title}),n.badge&&e.jsx("span",{className:"ml-auto text-xs",children:n.badge})]})},`${n.title}-${n.url}`))]})]})})};function B(t,s,a=!1){return t===s.url||t.split("?")[0]===s.url||!!s?.items?.filter(n=>n.url===t).length||a&&t.split("/")[1]!==""&&t.split("/")[1]===s?.url?.split("/")[1]}function Ms({user:t}){const{isMobile:s}=D(),a=Qe(),{t:n}=R(),i=t.avatar.startsWith("http")||t.avatar.startsWith("/")||t.avatar.startsWith("data:"),l=i?t.name.charAt(0).toUpperCase():t.avatar;return e.jsx(Se,{children:e.jsx(Z,{children:e.jsxs(K,{children:[e.jsx(G,{asChild:!0,children:e.jsxs(X,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[e.jsxs(le,{className:"h-8 w-8 rounded-lg",children:[i&&e.jsx(de,{src:t.avatar,alt:t.name}),e.jsx(ce,{className:"rounded-lg",children:l})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-semibold",children:t.name}),e.jsx("span",{className:"truncate text-xs",children:t.email})]}),e.jsx(_e,{className:"ml-auto size-4"})]})}),e.jsxs(Y,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",side:s?"bottom":"right",align:"end",sideOffset:4,children:[e.jsx(re,{className:"p-0 font-normal",children:e.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[e.jsxs(le,{className:"h-8 w-8 rounded-lg",children:[i&&e.jsx(de,{src:t.avatar,alt:t.name}),e.jsx(ce,{className:"rounded-lg",children:l})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-semibold",children:t.name}),e.jsx("span",{className:"truncate text-xs",children:t.email})]})]})}),e.jsx(F,{}),e.jsx(F,{}),e.jsx(ht,{children:e.jsx(E,{asChild:!0,children:e.jsxs(H,{to:"/settings/profile",children:[e.jsx(Mt,{}),n("sidebar.userMenu.account")]})})}),e.jsx(F,{}),e.jsxs(E,{onClick:a,children:[e.jsx(Ht,{}),n("sidebar.userMenu.logOut")]})]})]})})})}function Ds(){const{t}=R();return e.jsxs("div",{role:"toolbar","aria-label":t("sidebar.settingsControls"),className:"flex flex-row items-center justify-end gap-2","data-testid":"mobile-header-controls",children:[e.jsx("div",{"data-testid":"mobile-language-switch",children:e.jsx(we,{})}),e.jsx("div",{"data-testid":"mobile-theme-switch",children:e.jsx(Ce,{})})]})}function Ts({sidebarData:t,...s}){const{isMobile:a}=D();return e.jsxs(ts,{collapsible:"icon",variant:"floating",...s,children:[e.jsx(ns,{children:t.navGroups.map(n=>e.jsx(ks,{...n},n.title))}),e.jsxs(rs,{children:[a&&e.jsx(Ds,{}),e.jsx(Ms,{user:t.user})]}),e.jsx(as,{})]})}const Rs=()=>e.jsx("a",{className:"bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:ring-ring fixed left-44 z-999 -translate-y-52 px-4 py-2 text-sm font-medium whitespace-nowrap opacity-95 shadow-sm transition focus:translate-y-3 focus:transform focus-visible:ring-1",href:"#content",children:"Skip to Main"});function Es({onComplete:t}){const{t:s}=R(),a=fe(),n=Ve(),[i,l]=f.useState(!0),o=f.useRef(!1);f.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i]);const d=f.useCallback(()=>{o.current||n.isPending||(o.current=!0,n.mutate(void 0,{onSuccess:()=>{t?.()},onError:()=>{o.current=!1,O.error(s("common.errors.onboardingFailed"))}}))},[n,t,s]),u=f.useCallback(()=>{l(!1),a({to:"/system",search:{tab:"retry"}}).then(()=>{setTimeout(()=>{const g=ke({showProgress:!0,steps:[{popover:{title:s("system.onboarding.steps.autoDisableIntro.title"),description:s("system.onboarding.steps.autoDisableIntro.description")}},{element:"#auto-disable-channel",popover:{title:s("system.onboarding.steps.autoDisableToggle.title"),description:s("system.onboarding.steps.autoDisableToggle.description"),side:"right",align:"start"}},{popover:{title:s("system.onboarding.steps.autoDisableComplete.title"),description:s("system.onboarding.steps.autoDisableComplete.de
24scription")}}],onDestroyStarted:()=>{d(),g.destroy()},onDestroyed:()=>{d()}});g.drive()},500)})},[a,s,d]),x=f.useCallback(()=>{l(!1),d()},[d]);return i===!1?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-hidden bg-black/50",children:[e.jsx("div",{className:"absolute inset-0",onClick:()=>{}}),e.jsxs(ge,{className:"relative z-10 mx-4 w-full max-w-md",children:[e.jsxs(be,{className:"text-center",children:[e.jsx(ye,{className:"text-2xl",children:s("system.onboarding.autoDisableChannel.title")}),e.jsx(je,{className:"text-lg",children:s("system.onboarding.autoDisableChannel.description")})]}),e.jsx(ve,{className:"space-y-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx($,{onClick:u,className:"w-full",size:"lg","data-testid":"auto-disable-onboarding-start-tour",children:s("system.onboarding.autoDisableChannel.startTour")}),e.jsx($,{variant:"outline",onClick:x,className:"w-full",size:"lg","data-testid":"auto-disable-onboarding-skip-tour",children:s("system.onboarding.autoDisableChannel.skipTour")})]})})]})]})}function Is({onComplete:t}){const{t:s}=R(),a=fe(),n=We(),[i,l]=f.useState(!0);f.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i]);const o=f.useCallback(()=>{l(!1),a({to:"/system"}).then(()=>{setTimeout(()=>{const u=ke({showProgress:!0,steps:[{element:"#system-title",popover:{title:s("system.onboarding.steps.welcome.title"),description:s("system.onboarding.steps.welcome.description"),side:"bottom",align:"start"}},{element:"#brand-name",popover:{title:s("system.onboarding.steps.brandName.title"),description:s("system.onboarding.steps.brandName.description"),side:"bottom",align:"start"}},{element:"#brand-logo-upload",popover:{title:s("system.onboarding.steps.brandLogo.title"),description:s("system.onboarding.steps.brandLogo.description"),side:"bottom",align:"start"}},{element:'[data-value="retry"]',popover:{title:s("system.onboarding.steps.retryPolicy.title"),description:s("system.onboarding.steps.retryPolicy.description"),side:"bottom",align:"center"},onHighlighted:()=>{setTimeout(()=>{a({to:"/system",search:{tab:"retry"}})},300)}},{element:"#retry-enabled-switch",popover:{title:s("system.onboarding.steps.retryEnabled.title"),description:s("system.onboarding.steps.retryEnabled.description"),side:"right",align:"start"}},{element:"#retry-max-retries",popover:{title:s("system.onboarding.steps.retryMaxRetries.title"),description:s("system.onboarding.steps.retryMaxRetries.description"),side:"right",align:"start"}},{element:"#max-single-channel-retries",popover:{title:s("system.onboarding.steps.retrySingleChannel.title"),description:s("system.onboarding.steps.retrySingleChannel.description"),side:"right",align:"start"}},{element:"#retry-delay",popover:{title:s("system.onboarding.steps.retryDelay.title"),description:s("system.onboarding.steps.retryDelay.description"),side:"right",align:"start"}},{popover:{title:s("system.onboarding.steps.autoDisableIntro.title"),description:s("system.onboarding.steps.autoDisableIntro.description")}},{element:"#auto-disable-channel",popover:{title:s("system.onboarding.steps.autoDisableToggle.title"),description:s("system.onboarding.steps.autoDisableToggle.description"),side:"right",align:"start"}},{popover:{title:s("system.onboarding.steps.autoDisableComplete.title"),description:s("system.onboarding.steps.autoDisableComplete.description")}},{element:'[data-value="storage"]',popover:{title:s("system.onboarding.steps.dataStorage.title"),description:s("system.onboarding.steps.dataStorage.description"),side:"bottom",align:"center"},onHighlighted:()=>{setTimeout(()=>{a({to:"/system",search:{tab:"storage"}})},300)}},{element:"#default-data-storage",popover:{title:s("system.onboarding.steps.dataStorageSelection.title"),description:s("system.onboarding.steps.dataStorageSelection.description"),side:"right",align:"start"}},{element:"#storage-policy-store-chunks",popover:{title:s("system.onboarding.steps.storageChunks.title"),description:s("system.onboarding.steps.storageChunks.description"),side:"right",align:"start"}},{element:"#storage-policy-store-request-body",popover:{title:s("system.onboarding.steps.storageRequestBody.title"),description:s("system.onboarding.steps.storageRequestBody.description"),side:"right",align:"start"}},{element:"#storage-policy-store-response-body",popover:{title:s("system.onboarding.steps.storageResponseBody.title"),description:s("system.onboarding.steps.storageResponseBody.description"),side:"right",align:"start"}},{element:"#storage-cleanup-option-requests",popover:{title:s("system.onboarding.steps.storageCleanupRequests.title"),description:s("system.onboarding.steps.storageCleanupRequests.description"),side:"right",align:"start"}},{element:"#storage-cleanup-option-usage_logs",popover:{title:s("system.onboarding.steps.storageCleanupUsageLogs.title"),description:s("system.onboarding.steps.storageCleanupUsageLogs.description"),side:"right",align:"start"}},{element:"#data-storages-link",popover:{title:s("system.onboarding.steps.complete.title"),description:s("system.onboarding.steps.complete.de
24scription"),side:"bottom",align:"start"},onHighlighted:()=>{n.mutate(void 0,{onSuccess:()=>{O.success(s("system.onboarding.completeTour")),t?.(),a({to:"/data-storages"})}})}}],onDestroyStarted:()=>{n.mutate(void 0,{onSuccess:()=>{O.success(s("system.onboarding.completeTour")),t?.()}}),u.destroy()}});u.drive()},500)})},[n,a,s]),d=f.useCallback(()=>{l(!1),n.mutate(void 0,{onSuccess:()=>{t?.()}})},[n,t]);return i===!1?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-hidden bg-black/50",children:[e.jsx("div",{className:"absolute inset-0",onClick:()=>{}}),e.jsxs(ge,{className:"relative z-10 mx-4 w-full max-w-md",children:[e.jsxs(be,{className:"text-center",children:[e.jsx(ye,{className:"text-2xl",children:s("system.onboarding.title")}),e.jsx(je,{className:"text-lg",children:s("system.onboarding.description")})]}),e.jsx(ve,{className:"space-y-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx($,{onClick:o,className:"w-full",size:"lg","data-testid":"onboarding-start-tour",children:s("system.onboarding.startTour")}),e.jsx($,{variant:"outline",onClick:d,className:"w-full",size:"lg","data-testid":"onboarding-skip-tour",children:s("system.onboarding.skipTour")})]})})]})]})}function $s({children:t,showOnboarding:s=!0,onComplete:a}){const{data:n,isLoading:i}=Ke(),[l,o]=f.useState("none"),u=te(g=>g.auth.user)?.isOwner??!1;f.useEffect(()=>{!i&&s&&u&&(!n||!n.onboarded?o("main"):n.autoDisableChannel?.onboarded?o("none"):o("autoDisableChannel"))},[n,i,s,u]);const x=()=>{o("none"),a?.()};return e.jsxs(e.Fragment,{children:[t,l==="main"&&e.jsx(Is,{onComplete:x}),l==="autoDisableChannel"&&e.jsx(Es,{onComplete:x})]})}function Ps({children:t}){const s=Qt.get("sidebar_state")!=="false",a=Ge();return Wt(),e.jsxs(es,{defaultOpen:s,className:"h-screen flex-col overflow-hidden",children:[e.jsx(Ns,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx(Rs,{}),e.jsx(Ts,{sidebarData:a}),e.jsx("div",{id:"content",className:y("ml-auto w-full max-w-full","peer-data-[state=collapsed]:w-[calc(100%-var(--sidebar-width-icon)-1rem)]","peer-data-[state=expanded]:w-[calc(100%-var(--sidebar-width))]","sm:transition-[width] sm:duration-200 sm:ease-linear","flex min-h-0 min-w-0 flex-1 flex-col overflow-auto pt-14 has-[main.fixed-main]:overflow-hidden","group-data-[scroll-locked=1]/body:h-full","has-[main.fixed-main]:group-data-[scroll-locked=1]/body:h-svh"),children:e.jsx($s,{children:t||e.jsx(Ye,{})})})]})]})}function As({children:t}){const s=Ze(),{accessToken:a}=te(l=>l.auth),{isLoading:n,error:i}=Xe();if(f.useEffect(()=>{if(!a){const l=window.location.pathname;!l.startsWith("/sign-in")&&!l.startsWith("/sign-up")&&!l.startsWith("/initialization")&&!l.startsWith("/forgot-password")&&!l.startsWith("/otp")&&s.navigate({to:"/sign-in"})}},[a,s]),f.useEffect(()=>{i&&a&&Je(i)&&s.navigate({to:"/sign-in"})},[i,a,s]),!a){const l=window.location.pathname;return l.startsWith("/sign-in")||l.startsWith("/sign-up")||l.startsWith("/initialization")||l.startsWith("/forgot-password")||l.startsWith("/otp")?e.jsx(e.Fragment,{children:t}):e.jsx("div",{className:"flex h-screen items-center justify-center",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(U,{className:"h-8 w-48"}),e.jsx(U,{className:"h-4 w-32"})]})})}return a&&n?e.jsx("div",{className:"flex h-screen items-center justify-center",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(U,{className:"h-8 w-48"}),e.jsx(U,{className:"h-4 w-32"})]})}):e.jsx(e.Fragment,{children:t})}const ha=()=>e.jsx(As,{children:e.jsx(Ps,{})});export{ha as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.