umans-gate 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/README.md +165 -45
  3. package/npm-shim.cjs +71 -0
  4. package/package.json +16 -80
  5. package/dashboard/dist/assets/alert-dialog-DlhAyxD3.js +0 -2
  6. package/dashboard/dist/assets/alert-dialog-DlhAyxD3.js.map +0 -1
  7. package/dashboard/dist/assets/clear-confirm-dialog-BOcl93wD.js +0 -2
  8. package/dashboard/dist/assets/clear-confirm-dialog-BOcl93wD.js.map +0 -1
  9. package/dashboard/dist/assets/config-tab-pnBjiSyC.js +0 -4
  10. package/dashboard/dist/assets/config-tab-pnBjiSyC.js.map +0 -1
  11. package/dashboard/dist/assets/economics-tab-BJXa5ydD.js +0 -2
  12. package/dashboard/dist/assets/economics-tab-BJXa5ydD.js.map +0 -1
  13. package/dashboard/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  14. package/dashboard/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  15. package/dashboard/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  16. package/dashboard/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  17. package/dashboard/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  18. package/dashboard/dist/assets/headers-viewer-C9FKdG-_.js +0 -2
  19. package/dashboard/dist/assets/headers-viewer-C9FKdG-_.js.map +0 -1
  20. package/dashboard/dist/assets/index-72wCsW4_.js +0 -3
  21. package/dashboard/dist/assets/index-72wCsW4_.js.map +0 -1
  22. package/dashboard/dist/assets/index-DFhG4t-C.css +0 -1
  23. package/dashboard/dist/assets/json-viewer-CXkZMoVn.js +0 -2
  24. package/dashboard/dist/assets/json-viewer-CXkZMoVn.js.map +0 -1
  25. package/dashboard/dist/assets/mode-toggle-BxkGFiYG.js +0 -2
  26. package/dashboard/dist/assets/mode-toggle-BxkGFiYG.js.map +0 -1
  27. package/dashboard/dist/assets/models-tab-Deqk3WT3.js +0 -2
  28. package/dashboard/dist/assets/models-tab-Deqk3WT3.js.map +0 -1
  29. package/dashboard/dist/assets/performance-meter-Bd152C4C.js +0 -2
  30. package/dashboard/dist/assets/performance-meter-Bd152C4C.js.map +0 -1
  31. package/dashboard/dist/assets/select-mZPf2BR3.js +0 -2
  32. package/dashboard/dist/assets/select-mZPf2BR3.js.map +0 -1
  33. package/dashboard/dist/assets/sheet-BgQXtbdw.js +0 -2
  34. package/dashboard/dist/assets/sheet-BgQXtbdw.js.map +0 -1
  35. package/dashboard/dist/assets/sonner-DGu1DGeO.js +0 -2
  36. package/dashboard/dist/assets/sonner-DGu1DGeO.js.map +0 -1
  37. package/dashboard/dist/assets/sse-viewer-BHnn3FcY.js +0 -3
  38. package/dashboard/dist/assets/sse-viewer-BHnn3FcY.js.map +0 -1
  39. package/dashboard/dist/assets/use-capture-done-listener-u5RxfYQP.js +0 -2
  40. package/dashboard/dist/assets/use-capture-done-listener-u5RxfYQP.js.map +0 -1
  41. package/dashboard/dist/assets/use-models-B4MLkfpt.js +0 -2
  42. package/dashboard/dist/assets/use-models-B4MLkfpt.js.map +0 -1
  43. package/dashboard/dist/assets/use-polling-resource-D_vWHFwW.js +0 -2
  44. package/dashboard/dist/assets/use-polling-resource-D_vWHFwW.js.map +0 -1
  45. package/dashboard/dist/assets/vendor-CVKsgXJU.js +0 -312
  46. package/dashboard/dist/assets/vendor-CVKsgXJU.js.map +0 -1
  47. package/dashboard/dist/assets/vendor-DtX4s2-2.css +0 -1
  48. package/dashboard/dist/assets/vendor-react-Dtud3GyP.js +0 -41
  49. package/dashboard/dist/assets/vendor-react-Dtud3GyP.js.map +0 -1
  50. package/dashboard/dist/assets/vision-calls-BquNiDzm.js +0 -3
  51. package/dashboard/dist/assets/vision-calls-BquNiDzm.js.map +0 -1
  52. package/dashboard/dist/index.html +0 -34
  53. package/dist/cli.d.ts +0 -1
  54. package/dist/cli.js +0 -6788
  55. package/dist/cli.js.map +0 -1
  56. package/dist/index.d.ts +0 -1094
  57. package/dist/index.js +0 -6443
  58. package/dist/index.js.map +0 -1
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/json-viewer-CXkZMoVn.js","assets/vendor-react-Dtud3GyP.js","assets/vendor-CVKsgXJU.js","assets/vendor-DtX4s2-2.css","assets/sse-viewer-BHnn3FcY.js","assets/headers-viewer-C9FKdG-_.js","assets/sheet-BgQXtbdw.js","assets/clear-confirm-dialog-BOcl93wD.js","assets/alert-dialog-DlhAyxD3.js","assets/config-tab-pnBjiSyC.js","assets/select-mZPf2BR3.js","assets/use-models-B4MLkfpt.js","assets/use-polling-resource-D_vWHFwW.js","assets/use-capture-done-listener-u5RxfYQP.js","assets/models-tab-Deqk3WT3.js","assets/performance-meter-Bd152C4C.js","assets/economics-tab-BJXa5ydD.js","assets/vision-calls-BquNiDzm.js","assets/mode-toggle-BxkGFiYG.js","assets/sonner-DGu1DGeO.js"])))=>i.map(i=>d[i]);
2
- var Se=Object.defineProperty;var Te=(t,s,r)=>s in t?Se(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var se=(t,s,r)=>Te(t,typeof s!="symbol"?s+"":s,r);import{r as n,j as e,R as Ee,d as ze}from"./vendor-react-Dtud3GyP.js";import{t as Le,c as Pe,B as Re,a as X,I as Ie,T as De,b as re,d as $e,e as Ae,f as Fe,g as Oe,h as qe,E as Me,i as de,F as Ve,C as Be,S as He,u as Ue,j as Ge,o as Ke,s as We,k as Je,l as Qe,m as V,K as Ye,n as Xe,p as Ze,q as et,L as tt,r as st,v as rt,w as nt,x as at,y as it,z as ot,A as lt,D as dt,G as ct,H as ce,R as ue,J as ut,M as mt,N as ft,O as xt,P as me,Q as ht,U as pt,V as gt,W as bt,X as jt}from"./vendor-CVKsgXJU.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const o of l.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function r(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function i(a){if(a.ep)return;a.ep=!0;const l=r(a);fetch(a.href,l)}})();const vt="modulepreload",yt=function(t){return"/dashboard/"+t},ne={},S=function(s,r,i){let a=Promise.resolve();if(r&&r.length>0){let o=function(x){return Promise.all(x.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),f=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=o(r.map(x=>{if(x=yt(x),x in ne)return;ne[x]=!0;const m=x.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${p}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":vt,m||(g.as="script"),g.crossOrigin="",g.href=x,f&&g.setAttribute("nonce",f),document.head.appendChild(g),m)return new Promise((u,d)=>{g.addEventListener("load",u),g.addEventListener("error",()=>d(new Error(`Unable to preload CSS for ${x}`)))})}))}function l(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return a.then(o=>{for(const c of o||[])c.status==="rejected"&&l(c.reason);return s().catch(l)})};function b(...t){return Le(Pe(t))}const wt=X("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}}),L=n.forwardRef(({className:t,variant:s="default",size:r="default",...i},a)=>e.jsx(Re,{ref:a,"data-slot":"button",className:b(wt({variant:s,size:r,className:t})),...i}));L.displayName="Button";function kt({className:t,type:s,...r}){return e.jsx(Ie,{type:s,"data-slot":"input",className:b("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),...r})}function Nt({delay:t=0,...s}){return e.jsx(qe,{"data-slot":"tooltip-provider",delay:t,...s})}function j({...t}){return e.jsx(De,{"data-slot":"tooltip",...t})}function v({children:t,asChild:s,...r}){return s&&n.isValidElement(t)?e.jsx(re,{"data-slot":"tooltip-trigger",render:t,...r}):e.jsx(re,{"data-slot":"tooltip-trigger",...r,children:t})}function y({className:t,side:s="top",sideOffset:r=4,align:i="center",alignOffset:a=0,children:l,...o}){return e.jsx($e,{children:e.jsx(Ae,{align:i,alignOffset:a,side:s,sideOffset:r,className:"isolate z-50",children:e.jsxs(Fe,{"data-slot":"tooltip-content",className:b("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...o,children:[l,e.jsx(Oe,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}function Ct({className:t,...s}){const[r,i]=n.useState(!1);return e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(kt,{type:r?"text":"password",className:b("pr-9",t),...s}),e.jsxs(j,{children:[e.jsx(v,{render:e.jsx(L,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0.5 h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>i(a=>!a),"aria-label":r?"Hide password":"Show password",tabIndex:-1}),children:r?e.jsx(Me,{className:"h-3.5 w-3.5"}):e.jsx(de,{className:"h-3.5 w-3.5"})}),e.jsx(y,{side:"top",children:r?"Hide password":"Show password"})]})]})}const A="/dashboard/api",H=`${A}/config`,_t="umans-gate:capture-done";function St(){const[t,s]=n.useState(null),[r,i]=n.useState(!0),[a,l]=n.useState(null),o=n.useCallback(async()=>{i(!0),l(null);try{const u=await fetch(H);if(!u.ok)return l(`HTTP ${u.status}`),null;if(!(u.headers.get("content-type")??"").includes("application/json"))return l("Backend not reachable"),null;const h=await u.json();return s(h),h}catch(u){return l(u instanceof Error?u.message:String(u)),null}finally{i(!1)}},[]);n.useEffect(()=>{o()},[o]);const c=n.useCallback(async u=>{try{const h=await(await fetch(H,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)})).json();return h.ok&&await o(),h}catch(d){return{ok:!1,errors:[d instanceof Error?d.message:String(d)],warnings:[],written:u}}},[o]),f=n.useCallback(async u=>{try{const d=await fetch(`${H}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return d.ok?await d.json():null}catch{return null}},[]),x=n.useCallback(async()=>{try{const u=await fetch(`${H}/reload`,{method:"POST"});if(!u.ok)return null;const d=await u.json();return await o(),d}catch{return null}},[o]),m=n.useCallback(async()=>{try{const u=await fetch(`${A}/usage/refresh-source`,{method:"POST"});if(!u.ok)return null;const d=await u.json();return d.ok&&await o(),d}catch{return null}},[o]),p=n.useCallback(async()=>{try{const u=await fetch(`${A}/restart`,{method:"POST"});return u.ok?await u.json():null}catch(u){return{ok:!1,error:u instanceof Error?u.message:String(u)}}},[]),g=n.useCallback(async()=>{try{const d=await(await fetch(`${H}/reset`,{method:"POST"})).json();return d.ok&&await o(),d}catch(u){return{ok:!1,errors:[u instanceof Error?u.message:String(u)],warnings:[],written:null}}},[o]);return{config:t,loading:r,error:a,reload:o,save:c,validate:f,reloadFromDisk:x,refreshFromSource:m,restart:p,resetToDefault:g}}const fe=n.createContext(null);function Tt({children:t}){const s=St();return e.jsx(fe.Provider,{value:s,children:t})}function Et(){const t=n.useContext(fe);if(!t)throw new Error("useConfigContext must be used within a ConfigProvider");return t}function zt({className:t,size:s="default",...r}){return e.jsx("div",{"data-slot":"card","data-size":s,className:b("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),...r})}function Lt({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:b("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",t),...s})}function Pt({className:t,...s}){return e.jsx("div",{"data-slot":"card-title",className:b("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),...s})}function Rt({className:t,...s}){return e.jsx("div",{"data-slot":"card-description",className:b("text-sm text-muted-foreground",t),...s})}function It({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:b("px-(--card-spacing)",t),...s})}function Dt({className:t,...s}){return e.jsx("label",{"data-slot":"label",className:b("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...s})}const $t=Ve,xe=n.createContext({}),At=({...t})=>e.jsx(xe.Provider,{value:{name:t.name},children:e.jsx(Be,{...t})}),Z=()=>{const t=n.useContext(xe),s=n.useContext(he),{getFieldState:r}=Ue(),i=Ge({name:t.name}),a=r(t.name,i);if(!t)throw new Error("useFormField should be used within <FormField>");const{id:l}=s;return{id:l,name:t.name,formItemId:`${l}-form-item`,formDescriptionId:`${l}-form-item-description`,formMessageId:`${l}-form-item-message`,...a}},he=n.createContext({});function Ft({className:t,...s}){const r=n.useId();return e.jsx(he.Provider,{value:{id:r},children:e.jsx("div",{"data-slot":"form-item",className:b("grid gap-2",t),...s})})}function Ot({className:t,...s}){const{error:r,formItemId:i}=Z();return e.jsx(Dt,{"data-slot":"form-label","data-error":!!r,className:b("data-[error=true]:text-destructive",t),htmlFor:i,...s})}function qt({...t}){const{error:s,formItemId:r,formDescriptionId:i,formMessageId:a}=Z();return e.jsx(He,{"data-slot":"form-control",id:r,"aria-describedby":s?`${i} ${a}`:`${i}`,"aria-invalid":!!s,...t})}function Mt({className:t,...s}){const{error:r,formMessageId:i}=Z(),a=r?String((r==null?void 0:r.message)??""):s.children;return a?e.jsx("p",{"data-slot":"form-message",id:i,className:b("text-destructive text-sm",t),...s,children:a}):null}const Vt=Ke({umans_api_key:We().trim().min(1,"API key is required")});function Bt(){const{config:t,loading:s,error:r,save:i}=Et(),a=Je({resolver:Qe(Vt),defaultValues:{umans_api_key:""}}),{handleSubmit:l,formState:{isSubmitting:o}}=a,c=n.useRef(null),f=t!==null&&!s&&!r&&!t.has_api_key;if(n.useEffect(()=>{r&&V.error("Failed to load configuration",{description:String(r)})},[r]),n.useEffect(()=>{const m=c.current;f&&m&&!m.open&&m.showModal()},[f]),!f)return null;const x=async m=>{try{const p=await i({umans_api_key:m.umans_api_key});if(!p||!p.ok){V.error("Failed to save API key",{description:(p==null?void 0:p.errors.join("; "))||"Unknown error"});return}V.success("API key saved. Reloading configuration…")}catch(p){V.error("Failed to save API key",{description:p instanceof Error?p.message:"Unknown error"})}};return e.jsx("dialog",{ref:c,className:"fixed inset-0 z-[100] m-0 h-screen w-screen bg-background/80 backdrop-blur-sm p-0 border-0","aria-label":"Umans API key required",children:e.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",children:e.jsxs(zt,{className:"w-full max-w-md",children:[e.jsxs(Lt,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ye,{className:"size-5 text-muted-foreground"}),e.jsx(Pt,{children:"Umans API Key Required"})]}),e.jsx(Rt,{children:"Enter your Umans API key to start capturing traffic. The key is stored in your local config file and can be changed later from the Config tab."})]}),e.jsxs(It,{children:[e.jsx($t,{...a,children:e.jsxs("form",{onSubmit:l(x),className:"grid gap-4",children:[e.jsx(At,{control:a.control,name:"umans_api_key",render:({field:m})=>e.jsxs(Ft,{children:[e.jsx(Ot,{children:"API Key"}),e.jsx(qt,{children:e.jsx(Ct,{placeholder:"sk-...",autoComplete:"off",autoFocus:!0,disabled:o,...m})}),e.jsx(Mt,{})]})}),e.jsx(L,{type:"submit",disabled:o,children:o?"Saving…":"Save & Continue"})]})}),e.jsxs("p",{className:"mt-3 text-center text-xs text-muted-foreground",children:["Don't have a key?"," ",e.jsx("a",{href:"https://app.umans.ai",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:"Get one here"})]})]})]})})})}const Ht=n.lazy(()=>S(()=>import("./json-viewer-CXkZMoVn.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.JsonViewer}))),Ut=n.lazy(()=>S(()=>import("./sse-viewer-BHnn3FcY.js"),__vite__mapDeps([4,1,2,3])).then(t=>({default:t.SseViewer})));function ae({body:t,isSse:s}){if(!t)return e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground italic",children:[e.jsx(Xe,{className:"h-3.5 w-3.5"}),"empty body"]});if(t.startsWith("__B64__"))return e.jsxs("div",{className:"text-muted-foreground italic",children:["binary data (base64, ",t.length-6," chars)"]});if(s)return e.jsx(Ut,{body:t});try{return JSON.parse(t),e.jsx(Ht,{body:t})}catch{return e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs leading-relaxed",children:t})}}const G="border-transparent bg-green-50 dark:bg-green-800 text-green-900 dark:text-green-100",K="border-transparent bg-amber-50 dark:bg-amber-800 text-amber-900 dark:text-amber-100",Gt="border-transparent bg-yellow-100 dark:bg-yellow-700 text-yellow-900 dark:text-yellow-50",ee="border-transparent bg-blue-50 dark:bg-blue-800 text-blue-900 dark:text-blue-100",Kt="bg-green-500 dark:bg-green-400",Wt="bg-amber-500 dark:bg-amber-400";function R(t){const s=t??0;return s===0?"0 B":s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(2)} MB`}function ie(t){const s=t??0;return s===0?"0":s<1e3?String(s):s<1e6?`${(s/1e3).toFixed(1)}K`:s<1e9?`${(s/1e6).toFixed(2)}M`:`${(s/1e9).toFixed(2)}B`}function Y(t){return t==null?"":t<1e3?`${t} ms`:`${(t/1e3).toFixed(2)} s`}function Jt(t){return t==null?"—":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(2)}s`}function Qt(t){return t==null?"—":`${t.toFixed(1)}`}function Yt(t,s){const r=t??0,i=s??0;return i<=0?"—":`${(r/i*100).toFixed(0)}%`}function pe(t){return t?new Date(t).toLocaleTimeString([],{hour12:!1}):""}function oe(t){return t?new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}):""}function Xt(t){return(t??"").replace(/[&<>]/g,s=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[s]??s)}function Zt(t){return t?t<300?"ok":t<400?"info":t<500?"warn":"err":""}function Ys(t){try{const s=JSON.parse(t??"{}");return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function Xs(t){return Xt(t)}function es(t){if(!t)return null;let s;try{s=JSON.parse(t)}catch{return null}if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;let i=0,a=null;const l=o=>{if(Array.isArray(o))for(const c of o){const f=c==null?void 0:c.cache_control;(f==null?void 0:f.type)==="ephemeral"&&(i++,f.ttl&&!a&&(a=f.ttl))}};l(r.system);for(const o of r.messages??[])l(o==null?void 0:o.content);return i>0?{count:i,ttl:a}:null}const ts=X("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"",sm:"h-4 gap-0.5 px-1.5 text-[0.625rem] [&>svg]:size-2.5!"}},defaultVariants:{variant:"default",size:"default"}});function C({className:t,variant:s="default",size:r="default",render:i,...a}){return Ze({defaultTagName:"span",props:et({className:b(ts({variant:s,size:r}),t)},a),render:i,state:{slot:"badge",variant:s,size:r}})}const ss={ok:{variant:"secondary",className:G},info:{variant:"secondary",className:ee},warn:{variant:"secondary",className:K},err:{variant:"destructive"},"":{variant:"secondary"}},rs={ok:"2xx/3xx success",info:"3xx redirection",warn:"4xx client error",err:"5xx server error","":"No response yet"};function ge({status:t,statusSource:s=null,gateReason:r=null,size:i="default"}){const a=Zt(t),l=ss[a],o=rs[a],c=s==="gate",f=t==null?"—":`${t}${c?"-gate":""}`,x=c&&r?`HTTP ${t} — generated by gate (not upstream): ${r}`:`HTTP ${f} — ${o}`;return e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsx(C,{variant:l.variant,size:i,className:l.className,children:f})}),e.jsx(y,{side:"top",children:x})]})}function ns({className:t,...s}){return e.jsx(tt,{role:"img","aria-label":"Loading",className:b("animate-spin size-4",t),...s})}function W({className:t}){return e.jsx("div",{"data-slot":"loader",className:b("flex h-full items-center justify-center",t),children:e.jsx(ns,{className:"size-8 text-muted-foreground"})})}function be({className:t,children:s,viewportRef:r,...i}){return e.jsxs(st,{"data-slot":"scroll-area",className:b("relative",t),...i,children:[e.jsx(rt,{"data-slot":"scroll-area-viewport",ref:r,className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:s}),e.jsx(as,{}),e.jsx(nt,{})]})}function as({className:t,orientation:s="vertical",...r}){return e.jsx(at,{"data-slot":"scroll-area-scrollbar","data-orientation":s,orientation:s,className:b("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",t),...r,children:e.jsx(it,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-muted-foreground/40 hover:bg-muted-foreground/60"})})}function je({className:t,orientation:s="horizontal",...r}){return e.jsx(ot,{"data-slot":"tabs","data-orientation":s,className:b("group/tabs flex data-[orientation=horizontal]:flex-col",t),...r})}const is=X("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function ve({className:t,variant:s="default",activateOnFocus:r=!0,...i}){return e.jsx(lt,{"data-slot":"tabs-list","data-variant":s,activateOnFocus:r,className:b(is({variant:s}),t),...i})}function ye({className:t,...s}){return e.jsx(ct,{"data-slot":"tabs-trigger",className:b("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",t),...s})}function z({className:t,...s}){return e.jsx(dt,{"data-slot":"tabs-content",className:b("flex-1 text-sm outline-none",t),...s})}const le=n.lazy(()=>S(()=>import("./headers-viewer-C9FKdG-_.js"),__vite__mapDeps([5,1,2,3])).then(t=>({default:t.HeadersViewer}))),Q={response:"Response Body",request:"Request Body","res-headers":"Response Headers","req-headers":"Request Headers"},os={response:"Body returned by the upstream LLM",request:"Body sent to the upstream — full prompt","res-headers":"HTTP response headers from upstream","req-headers":"HTTP request headers sent to upstream"};function ls({capture:t,isLoading:s,detailError:r,onCopy:i,onCopyStatus:a,onRetry:l}){const[o,c]=n.useState("response"),[f,x]=n.useState("idle"),m=n.useRef(!1),p=n.useMemo(()=>f==="copied"?"Copied!":f==="failed"?"Failed":"Copy",[f]);a&&!m.current&&(m.current=!0,a(p));const g=n.useMemo(()=>t?{response:t.response_body,request:t.request_body,"res-headers":t.response_headers,"req-headers":t.request_headers}:{},[t]),u=n.useMemo(()=>t?es(t.request_body):null,[t]);async function d(){if(!t)return;const h=await i(g[o]??""),N=h?"copied":"failed",T=h?"Copied!":"Failed";x(N),a==null||a(T),setTimeout(()=>{x("idle"),a==null||a("Copy")},1200);const w=Q[o];h?V.success("Copied to clipboard",{description:w}):V.error("Copy failed",{description:`Could not copy ${w.toLowerCase()}.`})}return s?e.jsx("main",{"aria-label":"Capture detail",className:"flex flex-1 flex-col overflow-hidden",children:e.jsx(W,{})}):!t&&r?e.jsxs("main",{className:"flex flex-1 flex-col items-center justify-center gap-3 overflow-y-auto p-8 text-center text-muted-foreground",children:[e.jsx(ce,{className:"h-12 w-12 text-destructive"}),e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Something went wrong"}),e.jsx("p",{className:"text-xs",children:r}),e.jsxs(j,{children:[e.jsx(v,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",onClick:l,children:[e.jsx(ue,{className:"mr-1.5 h-3.5 w-3.5"}),"Retry"]})}),e.jsx(y,{side:"top",children:"Retry loading capture detail"})]})]}):t?e.jsxs("main",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("header",{className:"border-b border-border px-4 py-3",children:[e.jsxs("div",{className:"flex w-full items-start justify-between gap-3",children:[e.jsxs("h2",{className:"break-all font-mono text-[15px] font-semibold leading-tight",children:[t.method," ",t.path]}),e.jsxs(j,{children:[e.jsx(v,{asChild:!0,children:e.jsxs(L,{size:"sm",variant:"outline",className:"shrink-0",onClick:d,children:[e.jsx(mt,{className:"mr-1.5 h-3.5 w-3.5"}),p]})}),e.jsx(y,{side:"left",children:"Copy active tab content to clipboard"})]})]}),e.jsxs("div",{className:"mt-2 flex w-full flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ge,{status:t.response_status,statusSource:t.status_source,gateReason:t.gate_reason,size:"sm"}),u&&e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsxs(C,{variant:"outline",size:"sm",children:[e.jsx(ft,{className:"mr-1 h-2.5 w-2.5","aria-hidden":!0}),"TTL ",u.ttl??"—"]})}),e.jsxs(y,{side:"top",className:"max-w-[240px]",children:[u.count," block",u.count>1?"s":""," stamped with ephemeral TTL"]})]}),t.is_sse&&e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsx(C,{variant:"secondary",size:"sm",children:"SSE"})}),e.jsx(y,{side:"top",children:"Upstream response is an SSE stream"})]}),e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex tabular-nums"}),children:e.jsxs("span",{children:["↑",R(t.request_size)," ↓",R(t.response_size)]})}),e.jsxs(y,{side:"top",children:["↑ ",R(t.request_size)," request · ↓ ",R(t.response_size)," ","response"]})]}),e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex tabular-nums"}),children:e.jsx("span",{children:Y(t.duration_ms)})}),e.jsx(y,{side:"top",children:"Wall-clock duration from start to completion"})]}),t.incoming_protocol&&e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsxs(C,{variant:"outline",size:"sm",children:["in ",t.incoming_protocol]})}),e.jsx(y,{side:"top",children:"HTTP version used by the client"})]}),t.upstream_protocol&&e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsxs(C,{variant:"outline",size:"sm",children:["out ",t.upstream_protocol]})}),e.jsx(y,{side:"top",children:"HTTP version used to reach upstream"})]}),e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex font-mono tabular-nums"}),children:e.jsx("span",{children:pe(t.started_at)})}),e.jsx(y,{side:"top",children:t.started_at?new Date(t.started_at).toLocaleString():"Not yet recorded"})]}),t.state==="streaming"&&e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsx(C,{variant:"secondary",size:"sm",className:G,children:"live"})}),e.jsx(y,{side:"top",children:"Response is still streaming"})]})]}),e.jsx("div",{className:"mt-0.5 w-full break-all font-mono text-[11px] text-muted-foreground",children:t.url})]}),e.jsxs(je,{value:o,onValueChange:h=>c(h),className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(ve,{className:"mx-auto mt-2 w-fit",children:Object.keys(Q).map(h=>e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{}),children:e.jsx(ye,{value:h,children:Q[h]})}),e.jsx(y,{side:"bottom",className:"max-w-[240px]",children:os[h]})]},h))}),e.jsx(n.Suspense,{fallback:e.jsx(W,{}),children:e.jsx(be,{className:"flex-1 min-h-0 px-4 py-3",children:e.jsxs("div",{className:"w-full",children:[e.jsx(z,{value:"response",className:"m-0",children:e.jsx(ae,{body:t.response_body,isSse:t.is_sse})}),e.jsx(z,{value:"request",className:"m-0",children:e.jsx(ae,{body:t.request_body,isSse:!1})}),e.jsx(z,{value:"res-headers",className:"m-0",children:e.jsx(le,{headers:t.response_headers})}),e.jsx(z,{value:"req-headers",className:"m-0",children:e.jsx(le,{headers:t.request_headers})})]})})})]})]}):e.jsxs("main",{className:"flex flex-1 flex-col items-center justify-center gap-3 overflow-y-auto p-8 text-center text-muted-foreground",children:[e.jsx(ut,{className:"h-12 w-12 text-muted-foreground/40"}),e.jsx("p",{className:"text-sm font-medium",children:"Select a capture to inspect"}),e.jsx("p",{className:"text-xs",children:"Requests appear here automatically as they flow through the proxy."})]})}function ds(t,s){const[r,i]=n.useState(()=>Date.now());return n.useEffect(()=>{if(!s||t==null)return;const a=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(a)},[s,t]),!s||t==null?null:Math.max(0,r-t)}function cs(t){const s=Math.floor(t/1e3);if(s<60)return`${s}s`;const r=Math.floor(s/60),i=s%60;return`${r}m${i}s`}function k({tip:t,children:s}){return e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:s}),e.jsx(y,{side:"top",className:"max-w-[220px]",children:t})]})}function us({capture:t,selected:s,isActive:r,optionId:i,onActivate:a}){const l=t.state==="enqueued"||t.state==="streaming",o=ds(t.started_at,l);return e.jsxs("div",{role:"option",id:i,"aria-selected":s,tabIndex:-1,onClick:a,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),a())},className:b("cursor-pointer border-b border-border px-4 py-3 w-full transition-colors hover:bg-accent overflow-hidden",s&&"bg-accent",r&&!s&&"bg-accent/50"),children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx(k,{tip:e.jsxs(e.Fragment,{children:["Method ",e.jsx("span",{className:"font-mono",children:t.method})]}),children:e.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-primary",children:t.method})}),e.jsx(ge,{status:t.response_status,statusSource:t.status_source,gateReason:t.gate_reason,size:"sm"}),t.is_vision&&e.jsx(k,{tip:"Vision call — request included image input",children:e.jsx("span",{className:"inline-flex shrink-0 items-center text-muted-foreground",children:e.jsx(de,{className:"h-3.5 w-3.5"})})}),t.state==="enqueued"&&e.jsx(k,{tip:"Queued — waiting for a concurrency slot",children:e.jsx(C,{variant:"secondary",size:"sm",className:ee,children:"queued"})}),t.state==="streaming"&&e.jsx(k,{tip:"Running — upstream is streaming the response",children:e.jsx(C,{variant:"secondary",size:"sm",className:G,children:"running"})}),t.is_sse&&e.jsx(k,{tip:"SSE — upstream response is a stream",children:e.jsx(C,{variant:"secondary",size:"sm",children:"SSE"})}),t.upstream_protocol&&e.jsx(k,{tip:e.jsxs(e.Fragment,{children:["Upstream HTTP ",e.jsx("span",{className:"font-mono",children:t.upstream_protocol})]}),children:e.jsx(C,{variant:"outline",size:"sm",children:t.upstream_protocol})}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[11px] tabular-nums text-muted-foreground",children:[e.jsx(k,{tip:e.jsxs(e.Fragment,{children:["Request size — ",R(t.request_size)]}),children:e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground/70",children:"↑"}),R(t.request_size)]})}),e.jsx(k,{tip:e.jsxs(e.Fragment,{children:["Response size — ",R(t.response_size)]}),children:e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground/70",children:"↓"}),R(t.response_size)]})}),e.jsx(k,{tip:t.started_at?`Started ${new Date(t.started_at).toLocaleString()}${t.finished_at?` · finished ${new Date(t.finished_at).toLocaleString()}`:""}`:"Start time not recorded",children:e.jsx("span",{className:"text-muted-foreground/60",children:pe(t.started_at)})})]})]}),e.jsx(k,{tip:e.jsxs("span",{className:"font-mono break-all",children:[t.path,t.model?` · ${t.model}`:""]}),children:e.jsxs("div",{className:"mt-1 truncate font-mono text-xs text-foreground/80",children:[t.path,t.model&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.model]})]})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-3 text-[11px] tabular-nums text-muted-foreground",children:[l&&o!=null?e.jsx(k,{tip:"Age — time since request started (still running)",children:e.jsxs("span",{className:"flex items-center gap-1 font-medium text-primary",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-primary animate-pulse","aria-hidden":!0}),cs(o)]})}):e.jsx(k,{tip:e.jsxs(e.Fragment,{children:["Total time — ",Y(t.duration_ms)||"—"]}),children:e.jsx("span",{children:Y(t.duration_ms)||"—"})}),(!l||t.ttft_ms!=null)&&e.jsx(k,{tip:"Time to first token — delay before first response token",children:e.jsxs("span",{children:["ttft ",Jt(t.ttft_ms)]})}),e.jsx(k,{tip:t.tps==null?t.usage_missing?"Tokens per second — usage data unavailable":t.output_tokens==null||t.output_tokens<=0?"Tokens per second — no output tokens":"Tokens per second — generation time too short to measure (< 1 s)":"Tokens per second — output generation rate",children:e.jsxs("span",{children:[Qt(t.tps)," t/s"]})}),e.jsx(k,{tip:"Total input tokens — prompt tokens sent (incl. cache writes)",children:e.jsxs("span",{children:["in ",ie(t.total_input_tokens)]})}),e.jsx(k,{tip:"Total output tokens — completion tokens received",children:e.jsxs("span",{children:["out ",ie(t.total_output_tokens)]})}),e.jsx(k,{tip:"Cache read % — share of input from prompt cache",children:e.jsxs("span",{children:["cache ",Yt(t.cache_read_tokens,t.total_input_tokens)]})})]})]})}const ms={"Code Max":Gt,"Code Pro":ee,unknown:void 0},fs={closed:"Upstream healthy — requests flow normally",open:"Too many 429s — requests fail fast until cooldown",half_open:"Probe request sent to test upstream recovery"},xs={open:"text-destructive",half_open:"text-muted-foreground",closed:"text-primary"},hs={open:ht,half_open:me,closed:xt};function ps({stats:t}){if(!t)return null;const s=t.hardCap>0?t.active/t.hardCap*100:0,r=t.tier==="unknown"?"no key":t.tier;return e.jsxs("div",{className:"border-b border-border px-4 py-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1",children:[e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsx(C,{variant:"secondary",className:ms[t.tier],children:r})}),e.jsx(y,{side:"bottom",className:"max-w-[240px]",children:t.tier==="Code Max"?"Highest concurrency — no rate limit gating":t.tier==="Code Pro"?"Standard concurrency with rate-limit gating":"No API key configured — upstream defaults apply"})]}),e.jsxs(j,{children:[e.jsxs(v,{render:e.jsx("span",{className:"cursor-help"}),children:[e.jsxs("span",{className:b("font-mono",t.breaker==="open"&&"text-destructive"),children:[t.active,"/",t.hardCap]}),e.jsx("span",{className:"text-muted-foreground ml-1",children:"hard cap"})]}),e.jsxs(y,{side:"bottom",children:[t.active," active · ",t.hardCap," hard cap · ",t.softLimit," soft limit"]})]}),t.queued>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-muted-foreground",children:t.queued}),e.jsx("span",{className:"text-muted-foreground",children:"queued"})]}),e.jsx("span",{className:"text-muted-foreground",children:"·"}),e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex items-center gap-1 cursor-help"}),children:(()=>{const i=hs[t.breaker]??me;return e.jsx(i,{"aria-hidden":!0,className:b("h-3.5 w-3.5",xs[t.breaker]??"text-muted-foreground")})})()}),e.jsx(y,{side:"bottom",className:"max-w-[260px]",children:fs[t.breaker]??t.breaker})]}),t.boxed&&e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsxs(C,{variant:"destructive",children:["boxed",t.boxedReason?`: ${t.boxedReason}`:""]})}),e.jsxs(y,{side:"bottom",className:"max-w-[260px]",children:["Requests rejected by box guard",t.boxedReason?` — ${t.boxedReason}`:""]})]}),!t.usageOk&&e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsx(C,{variant:"secondary",className:K,children:"usage: stale"})}),e.jsx(y,{side:"bottom",className:"max-w-[240px]",children:"Last usage fetch failed — rate limit counters may be inaccurate"})]})]}),e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex"}),children:e.jsx(C,{variant:t.unitsDemoted?"destructive":"secondary",className:t.unitsDemoted?void 0:t.priorityLow?K:G,children:t.unitsDemoted?"demoted":t.priorityLow?"low":"high"})}),e.jsx(y,{side:"bottom",className:"max-w-[260px]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Priority: ",t.unitsDemoted?"demoted":t.priorityLow?"low":"high"]}),t.boxed&&t.boxedUntil!==null&&e.jsxs("p",{className:"text-muted-foreground",children:["boxed until ",oe(t.boxedUntil)]}),t.demotedUntil!==null&&e.jsxs("p",{className:"text-muted-foreground",children:["demoted until ",oe(t.demotedUntil)]})]})})]})]}),e.jsx("div",{className:"mt-1.5 h-1 w-full overflow-hidden rounded bg-secondary",children:e.jsx("div",{className:b("h-full transition-all",s>=100?"bg-destructive":"bg-primary"),style:{width:`${Math.min(100,s)}%`}})}),t.requestsLimit!==null&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{children:["requests: ",t.requestsInWindow,t.requestsLimit?` / ${t.requestsLimit}`:""]}),t.requestsRemaining!==null&&e.jsxs("span",{children:["(",t.requestsRemaining," remaining)"]}),t.windowSeconds&&e.jsxs("span",{children:["· ",Math.round(t.windowSeconds/3600),"h window"]})]})]})}const gs=n.lazy(()=>S(()=>import("./sheet-BgQXtbdw.js"),__vite__mapDeps([6,1,2,3])).then(t=>({default:t.Sheet}))),bs=n.lazy(()=>S(()=>import("./sheet-BgQXtbdw.js"),__vite__mapDeps([6,1,2,3])).then(t=>({default:t.SheetContent}))),we=n.createContext(null),js={openDrawer:()=>{},closeDrawer:()=>{},isOpen:!1};function te(){return n.useContext(we)??js}function vs({children:t}){const[s,r]=n.useState(!1),i={openDrawer:()=>r(!0),closeDrawer:()=>r(!1),isOpen:s};return e.jsx(we.Provider,{value:i,children:t})}function ys({master:t,detail:s,masterAriaLabel:r,detailAriaLabel:i}){const{isOpen:a,closeDrawer:l}=te();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full",children:[e.jsx("aside",{"aria-label":r,className:"hidden w-[380px] shrink-0 md:flex",children:t}),e.jsx("div",{className:"flex flex-1 min-w-0","aria-label":i,children:s})]}),a&&e.jsx(n.Suspense,{fallback:null,children:e.jsx(gs,{open:a,onOpenChange:o=>{o||l()},children:e.jsx(bs,{side:"left","aria-label":r,className:"p-0 data-[side=left]:w-[85vw] data-[side=left]:sm:w-[380px] data-[side=left]:sm:max-w-[380px]",children:t})})})]})}const ws=500;function ks({captures:t,selectedId:s,onSelectId:r,scrollToIndex:i}){const a=t.length,[l,o]=n.useState(0),c=n.useRef({chars:"",timer:void 0});n.useEffect(()=>{if(s===null||a===0)return;const d=t.findIndex(h=>h.id===s);d>=0&&o(d)},[s,a,t]),n.useEffect(()=>()=>{c.current.timer&&clearTimeout(c.current.timer)},[]);const f=n.useCallback(d=>a===0?-1:Math.max(0,Math.min(d,a-1)),[a]),x=n.useCallback(d=>{const h=f(d);h<0||(o(h),i(h,{align:"auto"}))},[f,i]),m=n.useCallback(d=>{if(a!==0)switch(d.key){case"ArrowDown":d.preventDefault(),x(l+1);break;case"ArrowUp":d.preventDefault(),x(l-1);break;case"Home":d.preventDefault(),x(0);break;case"End":d.preventDefault(),x(a-1);break;case"Enter":case" ":d.preventDefault(),l>=0&&l<a&&r(t[l].id);break;default:{if(d.key.length===1&&/[a-zA-Z0-9/]/.test(d.key)){const h=d.key.toLowerCase(),N=c.current;N.chars+=h,N.timer&&clearTimeout(N.timer),N.timer=setTimeout(()=>{c.current.chars=""},ws);const T=N.chars;for(let w=0;w<a;w++)if(t[w].path.toLowerCase().startsWith(T)){x(w);break}}break}}},[a,l,x,r,t]),p=n.useCallback(d=>{d<0||d>=a||(o(d),r(t[d].id))},[r,t,a]),g=a===0?-1:Math.min(l,a-1),u=g>=0?`capture-opt-${t[g].id}`:void 0;return{activeIndex:g,activeOptionId:u,handleKeyDown:m,handleRowClick:p}}const Ns=n.lazy(()=>S(()=>import("./clear-confirm-dialog-BOcl93wD.js"),__vite__mapDeps([7,1,8,2,3])).then(t=>({default:t.ClearConfirmDialog}))),Cs=92;function _s({captures:t,selectedId:s,wsState:r,gateStats:i,listError:a,isLoading:l,onSelect:o,onClear:c,onRetry:f}){const x=n.useRef(null),{closeDrawer:m,isOpen:p}=te(),[g,u]=n.useState(!1),d=pt({count:t.length,getScrollElement:()=>x.current,estimateSize:()=>Cs,overscan:8}),h=d.getTotalSize(),N=d.getVirtualItems(),T=E=>{o(E),m()},{activeIndex:w,activeOptionId:P,handleKeyDown:I,handleRowClick:J}=ks({captures:t,selectedId:s,onSelectId:T,scrollToIndex:d.scrollToIndex});return e.jsxs("aside",{className:"flex h-full w-full min-w-0 flex-col border-r border-border bg-card",children:[e.jsxs("header",{className:b("flex items-center justify-between border-b border-border bg-card px-4 py-3",p&&"pr-12"),children:[e.jsxs("h2",{className:"text-sm font-semibold",children:["Captures ",e.jsxs("span",{className:"text-muted-foreground",children:["(",t.length,")"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(j,{children:[e.jsx(v,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>u(!0),children:[e.jsx(gt,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear"]})}),e.jsx(y,{side:"bottom",children:"Remove all recorded captures"})]})})]}),e.jsx(ps,{stats:i}),r!=="live"&&t.length>0&&e.jsxs("output",{"aria-live":"polite",className:"flex items-center gap-1.5 border-b px-4 py-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-muted-foreground","aria-hidden":!0}),"List may be stale — ",r==="down"?"reconnecting":"disconnected"]}),t.length===0?a?e.jsxs("section",{"aria-label":"Captures",className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center text-muted-foreground",children:[e.jsx(ce,{className:"h-12 w-12 text-destructive"}),e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Something went wrong"}),e.jsx("p",{className:"text-xs",children:a}),e.jsxs(j,{children:[e.jsx(v,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",onClick:f,children:[e.jsx(ue,{className:"mr-1.5 h-3.5 w-3.5"}),"Retry"]})}),e.jsx(y,{side:"top",children:"Retry loading captures"})]})]}):l?e.jsx("section",{"aria-label":"Captures",className:"flex flex-1 flex-col items-center justify-center overflow-hidden",children:e.jsx(W,{className:"h-auto"})}):e.jsxs("section",{"aria-label":"Captures",className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center text-muted-foreground",children:[e.jsx(bt,{className:"h-12 w-12 text-muted-foreground/40"}),e.jsx("p",{className:"text-sm font-medium",children:"No captures yet"}),e.jsx("p",{className:"text-xs",children:"Send a request through the proxy to see it here."})]}):e.jsx(be,{className:"min-h-0 flex-1 overflow-hidden outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",viewportRef:x,role:"listbox","aria-label":"Captures","aria-activedescendant":P,tabIndex:0,onKeyDown:I,children:e.jsx("div",{className:b("relative",r!=="live"&&t.length>0&&"opacity-60"),style:{height:h},children:N.map(E=>{const D=t[E.index];return D?e.jsx("div",{"data-index":E.index,style:{position:"absolute",top:0,left:0,width:"100%",height:E.size,transform:`translateY(${E.start}px)`},children:e.jsx(us,{capture:D,selected:D.id===s,isActive:E.index===w,optionId:`capture-opt-${D.id}`,onActivate:()=>J(E.index)})},D.id):null})})}),g&&e.jsx(n.Suspense,{fallback:null,children:e.jsx(Ns,{open:g,count:t.length,onConfirm:()=>{u(!1),c()},onClose:()=>u(!1)})})]})}const Ss={live:{label:"Live",variant:"secondary",className:G,dotClass:Kt,pulse:!1,tip:"Real-time updates active"},down:{label:"Reconnecting",variant:"secondary",className:K,dotClass:Wt,pulse:!0,tip:"Connection lost — auto-retrying"},unavailable:{label:"Disconnected",variant:"destructive",className:void 0,dotClass:"bg-destructive",pulse:!1,tip:"WebSocket unavailable — refresh page"}};function Ts({wsState:t}){const s=Ss[t];return e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{className:"inline-flex items-center outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":`WebSocket: ${s.label}`}),children:e.jsxs(C,{variant:s.variant,size:"sm",className:b("gap-1",s.className),children:[e.jsx("span",{"aria-hidden":!0,className:b("inline-block h-1.5 w-1.5 rounded-full",s.dotClass,s.pulse&&"animate-pulse")}),s.label]})}),e.jsx(y,{side:"bottom",children:s.tip})]})}function Es(){const[t,s]=n.useState(null),[r,i]=n.useState(null),[a,l]=n.useState(!1),[o,c]=n.useState(null),f=n.useRef(r);f.current=r;const x=n.useRef(t);x.current=t;const m=n.useCallback(async d=>{l(!0);try{const h=await fetch(`${A}/captures/${d}`);if(!h.ok){c(`HTTP ${h.status} ${h.statusText}`);return}if(!(h.headers.get("content-type")??"").includes("application/json")){c("Backend not reachable");return}const T=await h.json();i(T),c(null)}catch(h){c(String(h))}finally{l(!1)}},[]),p=n.useCallback(d=>{s(d),i(null),c(null),m(d)},[m]),g=n.useCallback(()=>{const d=x.current;d!==null&&m(d)},[m]),u=n.useCallback(()=>{s(null),i(null)},[]);return{selectedCapture:r,setSelectedCapture:i,selectedId:t,selectedIdRef:x,selectedCaptureRef:f,isLoadingDetail:a,detailError:o,selectCapture:p,fetchCapture:m,retryDetail:g,resetSelection:u}}function zs(){const[t,s]=n.useState([]),[r,i]=n.useState(!0),[a,l]=n.useState(null),[o,c]=n.useState(!1),f=n.useCallback(async()=>{try{const m=await fetch(`${A}/captures?limit=200`);if(!m.ok){l(`HTTP ${m.status} ${m.statusText}`),c(!1);return}if(!(m.headers.get("content-type")??"").includes("application/json")){c(!1);return}const g=await m.json();g.sort((u,d)=>d.id-u.id),s(g),l(null),c(!0)}catch(m){l(String(m)),c(!1)}finally{i(!1)}},[]),x=n.useCallback(()=>{f()},[f]);return{captures:t,setCaptures:s,isLoadingList:r,listError:a,backendReachable:o,loadList:f,retryList:x}}const Ls=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/dashboard/ws`;function Ps({backendReachable:t,setWsState:s,onConnected:r,onCaptureClear:i,onVisionClear:a,onCaptureState:l,onGateStats:o,onCaptureUpsert:c}){const f=n.useRef(r);f.current=r;const x=n.useRef(i);x.current=i;const m=n.useRef(a);m.current=a;const p=n.useRef(l);p.current=l;const g=n.useRef(o);g.current=o;const u=n.useRef(c);u.current=c,n.useEffect(()=>{if(!t){s("unavailable");return}let d=null,h=!1;const N={clear:()=>x.current(),"vision-clear":()=>m.current(),state:w=>p.current(w.captureId,w.state),gate:w=>g.current(w.stats),new:w=>u.current(w.capture,!0),update:w=>u.current(w.capture,!1)};function T(){try{d=new WebSocket(Ls)}catch{s("unavailable");return}d.onopen=()=>{s("live"),f.current()},d.onmessage=w=>{try{const P=JSON.parse(w.data),I=N[P.type];I(P)}catch(P){console.error(P)}},d.onclose=()=>{s("down"),h||setTimeout(T,1e3)},d.onerror=()=>{d==null||d.close()}}return T(),()=>{h=!0,d==null||d.close()}},[t,s])}function Rs(){const[t,s]=n.useState(null),[r,i]=n.useState(null),a=n.useCallback(async()=>{try{const o=await fetch(`${A}/gate`);if(!o.ok){i(`HTTP ${o.status} ${o.statusText}`);return}if(!(o.headers.get("content-type")??"").includes("application/json"))return;s(await o.json()),i(null)}catch(o){i(String(o))}},[]),l=n.useCallback(()=>{a()},[a]);return{gateStats:t,setGateStats:s,gateError:r,loadGate:a,retryGate:l}}function Is(){const{captures:t,setCaptures:s,isLoadingList:r,listError:i,backendReachable:a,loadList:l,retryList:o}=zs(),{selectedCapture:c,selectedId:f,selectedIdRef:x,selectedCaptureRef:m,isLoadingDetail:p,detailError:g,selectCapture:u,fetchCapture:d,retryDetail:h,resetSelection:N}=Es(),{gateStats:T,setGateStats:w,gateError:P,loadGate:I,retryGate:J}=Rs(),[E,D]=n.useState("down");n.useEffect(()=>{l(),I()},[l,I]),Ps({backendReachable:a,setWsState:D,onConnected:()=>{l(),I()},onCaptureClear:()=>{s([])},onVisionClear:()=>{s(_=>_.filter(B=>!B.is_vision))},onCaptureState:(_,B)=>{s(F=>{const $=F.findIndex(q=>q.id===_);if($<0)return F;const O=F.slice();return O[$]={...O[$],state:B},O})},onGateStats:_=>{w(_)},onCaptureUpsert:(_,B)=>{var F;s($=>{const O=$.findIndex(q=>q.id===_.id);if(O>=0){const q=$.slice();return q[O]=_,q}return[_,...$]}),!B&&_.state==="done"&&(window.dispatchEvent(new CustomEvent(_t)),_.id===x.current&&((F=m.current)==null?void 0:F.state)==="streaming"&&d(_.id))}});const _e=n.useCallback(async()=>{try{await fetch(`${A}/clear`,{method:"POST"}),s([]),N()}catch(_){console.error(_)}},[s,N]);return{captures:t,selectedCapture:c,isLoadingDetail:p,isLoadingList:r,wsState:E,selectedId:f,gateStats:T,listError:i,gateError:P,detailError:g,selectCapture:u,clearCaptures:_e,retryList:o,retryGate:J,retryDetail:h}}function Ds(){return{copyText:n.useCallback(async s=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(s),!0}catch{}const r=document.createElement("textarea");r.value=s,r.style.position="fixed",r.style.top="-9999px",document.body.appendChild(r),r.focus(),r.select();let i=!1;try{i=document.execCommand("copy")}catch{}return document.body.removeChild(r),i},[])}}const $s=n.lazy(()=>S(()=>import("./config-tab-pnBjiSyC.js"),__vite__mapDeps([9,1,2,3,10,8,11,12,13])).then(t=>({default:t.ConfigTab}))),As=n.lazy(()=>S(()=>import("./models-tab-Deqk3WT3.js"),__vite__mapDeps([14,1,11,12,13,2,3])).then(t=>({default:t.ModelsTab}))),Fs=n.lazy(()=>S(()=>import("./performance-meter-Bd152C4C.js"),__vite__mapDeps([15,1,12,13,2,3])).then(t=>({default:t.PerformanceMeter}))),Os=n.lazy(()=>S(()=>import("./economics-tab-BJXa5ydD.js"),__vite__mapDeps([16,1,10,2,3,13])).then(t=>({default:t.EconomicsTab}))),qs=n.lazy(()=>S(()=>import("./vision-calls-BquNiDzm.js"),__vite__mapDeps([17,1,12,13,2,3])).then(t=>({default:t.VisionCalls}))),Ms=n.lazy(()=>S(()=>import("./mode-toggle-BxkGFiYG.js"),__vite__mapDeps([18,1,2,3])).then(t=>({default:t.ModeToggle}))),Vs=n.lazy(()=>S(()=>import("./sonner-DGu1DGeO.js"),__vite__mapDeps([19,1,2,3])).then(t=>({default:t.Toaster})));function U(){return e.jsx(W,{})}function M({value:t,label:s,tip:r}){return e.jsxs(j,{children:[e.jsx(v,{render:e.jsx("span",{}),children:e.jsx(ye,{value:t,children:s})}),e.jsx(y,{side:"bottom",children:r})]})}function Bs(){const{captures:t,selectedCapture:s,isLoadingDetail:r,isLoadingList:i,wsState:a,selectedId:l,gateStats:o,listError:c,detailError:f,selectCapture:x,clearCaptures:m,retryList:p,retryDetail:g}=Is(),{copyText:u}=Ds(),[d,h]=n.useState("Copy");return e.jsx(Tt,{children:e.jsx(Nt,{delay:300,children:e.jsxs(vs,{children:[e.jsx(Bt,{}),e.jsxs("div",{className:"h-screen flex flex-col overflow-hidden bg-background text-foreground",children:[e.jsx("a",{href:"#main",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:top-2 focus:left-2 focus:rounded-md focus:bg-background focus:px-4 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:border focus:border-border",children:"Skip to content"}),e.jsx("h1",{className:"sr-only",children:"umans-gate"}),e.jsxs(je,{defaultValue:"captures",className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("header",{className:"flex items-center gap-2 px-4 py-2 border-b bg-background",children:[e.jsx(Hs,{}),e.jsx(Ts,{wsState:a}),e.jsx("div",{className:"tab-scroll flex-1 min-w-0 overflow-x-auto overflow-y-hidden scrollbar-none",children:e.jsxs(ve,{className:"flex w-max md:mx-auto md:w-fit",children:[e.jsx(M,{value:"captures",label:"Captures",tip:"Live log of every intercepted API call"}),e.jsx(M,{value:"vision",label:"Vision Calls",tip:"Image-bearing requests with model responses"}),e.jsx(M,{value:"performance",label:"Performance",tip:"Per-model TTFT, TPS, and token throughput"}),e.jsx(M,{value:"economics",label:"Economics",tip:"Daily usage accumulation and cost tracking"}),e.jsx(M,{value:"models",label:"Models",tip:"Upstream model catalog with pricing"}),e.jsx(M,{value:"config",label:"Config",tip:"Edit proxy settings and reload live"})]})}),e.jsx(n.Suspense,{fallback:null,children:e.jsx(Ms,{})})]}),e.jsxs("main",{id:"main","aria-label":"Inspector",className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(z,{value:"captures",className:"flex-1 overflow-hidden",keepMounted:!0,children:e.jsx(ys,{master:e.jsx(_s,{captures:t,selectedId:l,wsState:a,gateStats:o,listError:c,isLoading:i,onSelect:x,onClear:m,onRetry:p}),detail:e.jsx(ls,{capture:s,isLoading:r,detailError:f,onCopy:u,onCopyStatus:h,onRetry:g}),masterAriaLabel:"Captures list",detailAriaLabel:"Capture detail"})}),e.jsx(z,{value:"vision",className:"min-h-0 flex-1 overflow-hidden",keepMounted:!0,children:e.jsx(n.Suspense,{fallback:e.jsx(U,{}),children:e.jsx(qs,{})})}),e.jsx(z,{value:"performance",className:"min-h-0 flex-1 overflow-hidden",keepMounted:!0,children:e.jsx(n.Suspense,{fallback:e.jsx(U,{}),children:e.jsx(Fs,{})})}),e.jsx(z,{value:"models",className:"min-h-0 flex-1 overflow-hidden",keepMounted:!0,children:e.jsx(n.Suspense,{fallback:e.jsx(U,{}),children:e.jsx(As,{})})}),e.jsx(z,{value:"economics",className:"min-h-0 flex-1 overflow-hidden",keepMounted:!0,children:e.jsx(n.Suspense,{fallback:e.jsx(U,{}),children:e.jsx(Os,{})})}),e.jsx(z,{value:"config",className:"min-h-0 flex-1 overflow-hidden",keepMounted:!0,children:e.jsx(n.Suspense,{fallback:e.jsx(U,{}),children:e.jsx($s,{})})})]})]}),e.jsx(n.Suspense,{fallback:null,children:e.jsx(Vs,{})}),e.jsx("output",{"aria-live":"polite",className:"sr-only",children:d})]})]})})})}function Hs(){const{openDrawer:t}=te();return e.jsxs(j,{children:[e.jsx(v,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":"Open captures",onClick:t,children:e.jsx(jt,{className:"h-5 w-5"})})}),e.jsx(y,{side:"bottom",children:"Open captures list"})]})}class Us extends Ee.Component{constructor(){super(...arguments);se(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}render(){const{error:r}=this.state;return r?this.props.fallback??e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 p-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Something went wrong"}),e.jsx("p",{className:"text-xs",children:r.message}),e.jsxs(j,{children:[e.jsx(v,{render:e.jsx(L,{variant:"outline",size:"sm",onClick:()=>window.location.reload()}),children:"Reload"}),e.jsx(y,{side:"top",children:"Reload the page"})]})]}):this.props.children}}const ke=n.createContext(void 0);function Ne(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Gs(t){const s=window.document.documentElement;s.classList.remove("light","dark");const r=t==="system"?Ne():t;return s.classList.add(r),r}function Ks({children:t,defaultTheme:s="system",storageKey:r="umans-gate-theme"}){const[i,a]=n.useState(()=>typeof window>"u"?s:window.localStorage.getItem(r)??s),[l,o]=n.useState(()=>i==="system"?Ne():i);n.useEffect(()=>{const f=Gs(i);if(o(f),i!=="system")return;const x=window.matchMedia("(prefers-color-scheme: dark)"),m=p=>{const g=p.matches?"dark":"light";window.document.documentElement.classList.remove("light","dark"),window.document.documentElement.classList.add(g),o(g)};return x.addEventListener("change",m),()=>x.removeEventListener("change",m)},[i]);const c=n.useMemo(()=>({theme:i,resolvedTheme:l,setTheme:f=>{window.localStorage.setItem(r,f),a(f)}}),[i,l,r]);return e.jsx(ke.Provider,{value:c,children:t})}function Zs(){const t=n.useContext(ke);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t}const Ce=document.getElementById("root");if(!Ce)throw new Error("Missing root element");ze.createRoot(Ce).render(e.jsx(n.StrictMode,{children:e.jsx(Us,{children:e.jsx(Ks,{defaultTheme:"system",storageKey:"umans-gate-theme",children:e.jsx(Bs,{})})})}));export{A,L as B,zt as C,kt as I,Dt as L,Ct as P,be as S,j as T,S as _,v as a,y as b,b as c,C as d,K as e,ee as f,W as g,ns as h,It as i,ie as j,G as k,pe as l,R as m,Y as n,_t as o,Zs as p,Xs as q,Ys as s,Et as u};
3
- //# sourceMappingURL=index-72wCsW4_.js.map