@warlock.js/devtools 5.63.0 → 5.64.0

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.
@@ -47,7 +47,7 @@ Error generating stack: `+e.message+`
47
47
  .block-interactivity-${e} {pointer-events: none;}
48
48
  .allow-interactivity-${e} {pointer-events: all;}
49
49
  `},Mr=0,Nr=[];function Pr(e){var t=_.useRef([]),n=_.useRef([0,0]),r=_.useRef(),i=_.useState(Mr++)[0],a=_.useState(nr)[0],o=_.useRef(e);_.useEffect(function(){o.current=e},[e]),_.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Mn([e.lockRef.current],(e.shards||[]).map(kr),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=_.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Dr(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=br(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=br(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Er(h,t,e,h===`h`?s:c,!0)},[]),c=_.useCallback(function(e){var n=e;if(Nr.length&&Nr[Nr.length-1]===a){var r=`deltaY`in n?Or(n):Dr(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Ar(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(kr).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=_.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Fr(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=_.useCallback(function(e){n.current=Dr(e),r.current=void 0},[]),d=_.useCallback(function(t){l(t.type,Or(t),t.target,s(t,e.lockRef.current))},[]),f=_.useCallback(function(t){l(t.type,Dr(t),t.target,s(t,e.lockRef.current))},[]);_.useEffect(function(){return Nr.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,hr),document.addEventListener(`touchmove`,c,hr),document.addEventListener(`touchstart`,u,hr),function(){Nr=Nr.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,hr),document.removeEventListener(`touchmove`,c,hr),document.removeEventListener(`touchstart`,u,hr)}},[]);var p=e.removeScrollBar,m=e.inert;return _.createElement(_.Fragment,null,m?_.createElement(a,{styles:jr(i)}):null,p?_.createElement(fr,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Fr(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Ir=Kn(qn,Pr),Lr=_.forwardRef(function(e,t){return _.createElement(Yn,An({},e,{ref:t,sideCar:Ir}))});Lr.classNames=Yn.classNames;var Rr=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},zr=new WeakMap,Br=new WeakMap,Vr={},Hr=0,Ur=function(e){return e&&(e.host||Ur(e.parentNode))},Wr=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ur(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Gr=function(e,t,n,r){var i=Wr(t,Array.isArray(e)?e:[e]);Vr[n]||(Vr[n]=new WeakMap);var a=Vr[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(zr.get(e)||0)+1,l=(a.get(e)||0)+1;zr.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Br.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Hr++,function(){o.forEach(function(e){var t=zr.get(e)-1,i=a.get(e)-1;zr.set(e,t),a.set(e,i),t||(Br.has(e)||e.removeAttribute(r),Br.delete(e)),i||e.removeAttribute(n)}),Hr--,Hr||(zr=new WeakMap,zr=new WeakMap,Br=new WeakMap,Vr={})}},Kr=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Rr(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Gr(r,i,n,`aria-hidden`)):function(){return null}},qr=Object.defineProperty,Jr=(e,t)=>qr(e,`name`,{value:t,configurable:!0}),Yr=`Dialog`,[Xr,Zr]=Qe(Yr),[Qr,$r]=Xr(Yr),ei=Jr(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=_.useRef(null),c=_.useRef(null),{nodes:l,registry:u}=cn(),[d,f]=_t({prop:r,defaultProp:i??!1,onChange:a,caller:Yr}),[p,m]=_.useState(0),[h,g]=_.useState(0);return(0,A.jsx)(Qr,{scope:t,triggerRef:s,contentRef:c,contentId:Ft(),titleId:Ft(),descriptionId:Ft(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),ti=`DialogPortal`,[ni,ri]=Xr(ti,{forceMount:void 0}),ii=Jr(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=$r(ti,t);return(0,A.jsx)(ni,{scope:t,forceMount:n,children:_.Children.map(r,e=>(0,A.jsx)(Tt,{present:n||a.open,children:(0,A.jsx)(Sn,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),ai=`DialogOverlay`,oi=_.forwardRef(Jr(function(e,t){let n=ri(ai,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$r(ai,e.__scopeDialog);return a.modal?(0,A.jsx)(Tt,{present:r||a.open,children:(0,A.jsx)(ci,{...i,ref:t})}):null},`DialogOverlay`)),si=De(`DialogOverlay.RemoveScroll`),ci=_.forwardRef(Jr(function(e,t){let{__scopeDialog:n,...r}=e,i=$r(ai,n),a=we(t,qt());return(0,A.jsx)(Lr,{as:si,allowPinchZoom:!0,shards:_.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,A.jsx)(qe.div,{"data-state":yi(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),li=`DialogContent`,ui=_.forwardRef(Jr(function(e,t){let n=ri(li,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$r(li,e.__scopeDialog);return(0,A.jsx)(Tt,{present:r||a.open,children:a.modal?(0,A.jsx)(di,{...i,ref:t}):(0,A.jsx)(fi,{...i,ref:t})})},`DialogContent`)),di=_.forwardRef(Jr(function(e,t){let n=$r(li,e.__scopeDialog),r=_.useRef(null),i=we(t,n.contentRef,r);return _.useEffect(()=>{let e=r.current;if(e)return Kr(e)},[]),(0,A.jsx)(pi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:rt(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:rt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:rt(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),fi=_.forwardRef(Jr(function(e,t){let n=$r(li,e.__scopeDialog),r=_.useRef(!1),i=_.useRef(!1);return(0,A.jsx)(pi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),pi=_.forwardRef(Jr(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=$r(li,n);return On(),(0,A.jsx)(sn,{registry:l.branchRegistry,children:(0,A.jsx)(an,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,A.jsx)(Kt,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?vi(o,l.descriptionId):o,"data-state":yi(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`)),mi=_.forwardRef(Jr(function(e,t){let{__scopeDialog:n,...r}=e,i=$r(`DialogTitle`,n),{setTitleCount:a}=i;return ct(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,A.jsx)(qe.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),hi=_.forwardRef(Jr(function(e,t){let{__scopeDialog:n,...r}=e,i=$r(`DialogDescription`,n),{setDescriptionCount:a}=i;return ct(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,A.jsx)(qe.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),gi=`DialogClose`,_i=_.forwardRef(Jr(function(e,t){let{__scopeDialog:n,...r}=e,i=$r(gi,n);return(0,A.jsx)(qe.button,{type:`button`,...r,ref:t,onClick:rt(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function vi(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}Jr(vi,`concatAriaDescribedby`);function yi(e){return e?`open`:`closed`}Jr(yi,`getState`);var bi=Object.defineProperty,xi=_.forwardRef(((e,t)=>bi(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,A.jsx)(qe.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),Si=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Ci=(e,t)=>({classGroupId:e,validator:t}),wi=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Ti=`-`,Ei=[],Di=`arbitrary..`,Oi=e=>{let t=ji(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Ai(e);let n=e.split(Ti);return ki(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Si(i,t):t:i||Ei}return n[e]||Ei}}},ki=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=ki(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(Ti):e.slice(t).join(Ti),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Ai=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Di+r:void 0})(),ji=e=>{let{theme:t,classGroups:n}=e;return Mi(n,t)},Mi=(e,t)=>{let n=wi();for(let r in e){let i=e[r];Ni(i,n,r,t)}return n},Ni=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Pi(i,t,n,r)}},Pi=(e,t,n,r)=>{if(typeof e==`string`){Fi(e,t,n);return}if(typeof e==`function`){Ii(e,t,n,r);return}Li(e,t,n,r)},Fi=(e,t,n)=>{let r=e===``?t:Ri(t,e);r.classGroupId=n},Ii=(e,t,n,r)=>{if(zi(e)){Ni(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ci(n,e))},Li=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Ni(o,Ri(t,a),n,r)}},Ri=(e,t)=>{let n=e,r=t.split(Ti),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=wi(),n.nextPart.set(t,i)),n=i}return n},zi=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Bi=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Vi=`!`,Hi=`:`,j=[],Ui=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Wi=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Hi){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Vi)?(c=s.slice(0,-1),l=!0):s.startsWith(Vi)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Ui(t,l,c,u)};if(t){let e=t+Hi,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Ui(j,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Gi=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Ki=e=>({cache:Bi(e.cacheSize),parseClassName:Wi(e),sortModifiers:Gi(e),postfixLookupClassGroupIds:qi(e),...Oi(e)}),qi=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},Ji=/\s+/,Yi=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(Ji),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Vi:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},Xi=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Zi(n))&&(i&&(i+=` `),i+=r);return i},Zi=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Zi(e[r]))&&(n&&(n+=` `),n+=t);return n},Qi=(e,...t)=>{let n,r,i,a,o=o=>(n=Ki(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=Yi(e,n);return i(e,a),a};return a=o,(...e)=>a(Xi(...e))},$i=[],ea=e=>{let t=t=>t[e]||$i;return t.isThemeGetter=!0,t.themeKey=e,t},ta=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,na=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ra=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ia=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,aa=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,oa=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,sa=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ca=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,la=e=>ra.test(e),M=e=>!!e&&!Number.isNaN(Number(e)),ua=e=>!!e&&Number.isInteger(Number(e)),da=e=>e.endsWith(`%`)&&M(e.slice(0,-1)),fa=e=>ia.test(e),pa=()=>!0,ma=e=>aa.test(e)&&!oa.test(e),ha=()=>!1,ga=e=>sa.test(e),_a=e=>ca.test(e),va=e=>!N(e)&&!P(e),ya=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),ba=e=>Fa(e,za,ha),N=e=>ta.test(e),xa=e=>Fa(e,Ba,ma),Sa=e=>Fa(e,Va,M),Ca=e=>Fa(e,Ua,pa),wa=e=>Fa(e,Ha,ha),Ta=e=>Fa(e,La,ha),Ea=e=>Fa(e,Ra,_a),Da=e=>Fa(e,Wa,ga),P=e=>na.test(e),Oa=e=>Ia(e,Ba),ka=e=>Ia(e,Ha),Aa=e=>Ia(e,La),ja=e=>Ia(e,za),Ma=e=>Ia(e,Ra),Na=e=>Ia(e,Wa,!0),Pa=e=>Ia(e,Ua,!0),Fa=(e,t,n)=>{let r=ta.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ia=(e,t,n=!1)=>{let r=na.exec(e);return r?r[1]?t(r[1]):n:!1},La=e=>e===`position`||e===`percentage`,Ra=e=>e===`image`||e===`url`,za=e=>e===`length`||e===`size`||e===`bg-size`,Ba=e=>e===`length`,Va=e=>e===`number`,Ha=e=>e===`family-name`,Ua=e=>e===`number`||e===`weight`,Wa=e=>e===`shadow`,Ga=Qi(()=>{let e=ea(`color`),t=ea(`font`),n=ea(`text`),r=ea(`font-weight`),i=ea(`tracking`),a=ea(`leading`),o=ea(`breakpoint`),s=ea(`container`),c=ea(`spacing`),l=ea(`radius`),u=ea(`shadow`),d=ea(`inset-shadow`),f=ea(`text-shadow`),p=ea(`drop-shadow`),m=ea(`blur`),h=ea(`perspective`),g=ea(`aspect`),_=ea(`ease`),v=ea(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),P,N],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[P,N,c],T=()=>[la,`full`,`auto`,...w()],ee=()=>[ua,`none`,`subgrid`,P,N],te=()=>[`auto`,{span:[`full`,ua,P,N]},ua,P,N],ne=()=>[ua,`auto`,P,N],re=()=>[`auto`,`min`,`max`,`fr`,P,N],ie=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ae=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],oe=()=>[`auto`,...w()],se=()=>[la,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ce=()=>[s,la,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],le=()=>[la,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],E=()=>[e,P,N],D=()=>[...b(),Aa,Ta,{position:[P,N]}],ue=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],de=()=>[`auto`,`cover`,`contain`,ja,ba,{size:[P,N]}],fe=()=>[da,Oa,xa],pe=()=>[``,`none`,`full`,l,P,N],O=()=>[``,M,Oa,xa],me=()=>[`solid`,`dashed`,`dotted`,`double`],k=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],he=()=>[M,da,Aa,Ta],ge=()=>[``,`none`,m,P,N],_e=()=>[`none`,M,P,N],ve=()=>[`none`,M,P,N],ye=()=>[M,P,N],be=()=>[la,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[fa],breakpoint:[fa],color:[pa],container:[fa],"drop-shadow":[fa],ease:[`in`,`out`,`in-out`],font:[va],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[fa],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[fa],shadow:[fa],spacing:[`px`,M],text:[fa],"text-shadow":[fa],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,la,N,P,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,P,N]}],"container-named":[ya],columns:[{columns:[M,`auto`,N,P,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[ua,`auto`,P,N]}],basis:[{basis:[la,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[M,la,`auto`,`initial`,`none`,N]}],grow:[{grow:[``,M,P,N]}],shrink:[{shrink:[``,M,P,N]}],order:[{order:[ua,`first`,`last`,`none`,P,N]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":ne()}],"col-end":[{"col-end":ne()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":ne()}],"row-end":[{"row-end":ne()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...ie(),`normal`]}],"justify-items":[{"justify-items":[...ae(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ae()]}],"align-content":[{content:[`normal`,...ie()]}],"align-items":[{items:[...ae(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ae(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ie()}],"place-items":[{"place-items":[...ae(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ae()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:oe()}],mx:[{mx:oe()}],my:[{my:oe()}],ms:[{ms:oe()}],me:[{me:oe()}],mbs:[{mbs:oe()}],mbe:[{mbe:oe()}],mt:[{mt:oe()}],mr:[{mr:oe()}],mb:[{mb:oe()}],ml:[{ml:oe()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:se()}],"inline-size":[{inline:[`auto`,...ce()]}],"min-inline-size":[{"min-inline":[`auto`,...ce()]}],"max-inline-size":[{"max-inline":[`none`,...ce()]}],"block-size":[{block:[`auto`,...le()]}],"min-block-size":[{"min-block":[`auto`,...le()]}],"max-block-size":[{"max-block":[`none`,...le()]}],w:[{w:[s,`screen`,...se()]}],"min-w":[{"min-w":[s,`screen`,`none`,...se()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...se()]}],h:[{h:[`screen`,`lh`,...se()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...se()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...se()]}],"font-size":[{text:[`base`,n,Oa,xa]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Pa,Ca]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,da,N]}],"font-family":[{font:[ka,wa,t]}],"font-features":[{"font-features":[N]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,P,N]}],"line-clamp":[{"line-clamp":[M,`none`,P,Sa]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,P,N]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,P,N]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...me(),`wavy`]}],"text-decoration-thickness":[{decoration:[M,`from-font`,`auto`,P,xa]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[M,`auto`,P,N]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[ua,P,N]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,P,N]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,P,N]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:ue()}],"bg-size":[{bg:de()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},ua,P,N],radial:[``,P,N],conic:[``,ua,P,N]},Ma,Ea]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:fe()}],"gradient-via-pos":[{via:fe()}],"gradient-to-pos":[{to:fe()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:pe()}],"rounded-s":[{"rounded-s":pe()}],"rounded-e":[{"rounded-e":pe()}],"rounded-t":[{"rounded-t":pe()}],"rounded-r":[{"rounded-r":pe()}],"rounded-b":[{"rounded-b":pe()}],"rounded-l":[{"rounded-l":pe()}],"rounded-ss":[{"rounded-ss":pe()}],"rounded-se":[{"rounded-se":pe()}],"rounded-ee":[{"rounded-ee":pe()}],"rounded-es":[{"rounded-es":pe()}],"rounded-tl":[{"rounded-tl":pe()}],"rounded-tr":[{"rounded-tr":pe()}],"rounded-br":[{"rounded-br":pe()}],"rounded-bl":[{"rounded-bl":pe()}],"border-w":[{border:O()}],"border-w-x":[{"border-x":O()}],"border-w-y":[{"border-y":O()}],"border-w-s":[{"border-s":O()}],"border-w-e":[{"border-e":O()}],"border-w-bs":[{"border-bs":O()}],"border-w-be":[{"border-be":O()}],"border-w-t":[{"border-t":O()}],"border-w-r":[{"border-r":O()}],"border-w-b":[{"border-b":O()}],"border-w-l":[{"border-l":O()}],"divide-x":[{"divide-x":O()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":O()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...me(),`hidden`,`none`]}],"divide-style":[{divide:[...me(),`hidden`,`none`]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...me(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[M,P,N]}],"outline-w":[{outline:[``,M,Oa,xa]}],"outline-color":[{outline:E()}],shadow:[{shadow:[``,`inner`,`none`,u,Na,Da]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":[`none`,d,Na,Da]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:O()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[M,xa]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":O()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":[`none`,f,Na,Da]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[M,P,N]}],"mix-blend":[{"mix-blend":[...k(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":k()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[M]}],"mask-image-linear-from-pos":[{"mask-linear-from":he()}],"mask-image-linear-to-pos":[{"mask-linear-to":he()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":he()}],"mask-image-t-to-pos":[{"mask-t-to":he()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":he()}],"mask-image-r-to-pos":[{"mask-r-to":he()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":he()}],"mask-image-b-to-pos":[{"mask-b-to":he()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":he()}],"mask-image-l-to-pos":[{"mask-l-to":he()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":he()}],"mask-image-x-to-pos":[{"mask-x-to":he()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":he()}],"mask-image-y-to-pos":[{"mask-y-to":he()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[P,N]}],"mask-image-radial-from-pos":[{"mask-radial-from":he()}],"mask-image-radial-to-pos":[{"mask-radial-to":he()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[M]}],"mask-image-conic-from-pos":[{"mask-conic-from":he()}],"mask-image-conic-to-pos":[{"mask-conic-to":he()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:de()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,P,N]}],filter:[{filter:[``,`none`,P,N]}],blur:[{blur:ge()}],brightness:[{brightness:[M,P,N]}],contrast:[{contrast:[M,P,N]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Na,Da]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:[``,M,P,N]}],"hue-rotate":[{"hue-rotate":[M,P,N]}],invert:[{invert:[``,M,P,N]}],saturate:[{saturate:[M,P,N]}],sepia:[{sepia:[``,M,P,N]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,P,N]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[M,P,N]}],"backdrop-contrast":[{"backdrop-contrast":[M,P,N]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,M,P,N]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[M,P,N]}],"backdrop-invert":[{"backdrop-invert":[``,M,P,N]}],"backdrop-opacity":[{"backdrop-opacity":[M,P,N]}],"backdrop-saturate":[{"backdrop-saturate":[M,P,N]}],"backdrop-sepia":[{"backdrop-sepia":[``,M,P,N]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,P,N]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[M,`initial`,P,N]}],ease:[{ease:[`linear`,`initial`,_,P,N]}],delay:[{delay:[M,P,N]}],animate:[{animate:[`none`,v,P,N]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,P,N]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:_e()}],"rotate-x":[{"rotate-x":_e()}],"rotate-y":[{"rotate-y":_e()}],"rotate-z":[{"rotate-z":_e()}],scale:[{scale:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":[`scale-3d`],skew:[{skew:ye()}],"skew-x":[{"skew-x":ye()}],"skew-y":[{"skew-y":ye()}],transform:[{transform:[P,N,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":[`translate-none`],zoom:[{zoom:[ua,P,N]}],accent:[{accent:E()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,P,N]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":E()}],"scrollbar-track-color":[{"scrollbar-track":E()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,P,N]}],fill:[{fill:[`none`,...E()]}],"stroke-w":[{stroke:[M,Oa,xa,Sa]}],stroke:[{stroke:[`none`,...E()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function F(...e){return Ga(ge(e))}var Ka=ye(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 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:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`border-destructive/25 bg-destructive/10 text-destructive focus-visible:ring-destructive/20 [a&]:hover:bg-destructive/15`,success:`border-success/25 bg-success/10 text-success [a&]:hover:bg-success/15`,warning:`border-warning/30 bg-warning/10 text-warning [a&]:hover:bg-warning/15`,info:`border-info/25 bg-info/10 text-info [a&]:hover:bg-info/15`,brand:`border-brand/25 bg-brand/10 text-brand [a&]:hover:bg-brand/15`,neutral:`border-border bg-muted text-muted-foreground [a&]:hover:bg-accent`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function qa({className:e,variant:t,asChild:n=!1,...r}){let i=n?Oe:`span`;return(0,A.jsx)(i,{"data-slot":`badge`,className:F(Ka({variant:t}),e),...r})}var Ja=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function Ya(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:Ja(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var Xa=e=>{let t=``,n=!1;for(let r of e){if(r===`-`||r===`_`||r<=` `){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t},Za=e=>{let t=Xa(e);return t.charAt(0).toUpperCase()+t.slice(1)},Qa=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),$a={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function eo(e){return e!=null}function to(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??$a.width,a=e.size??e.height??$a.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?Qa(...c):Qa(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??$a[`stroke-width`])*Number(e.size??e.width??$a.width)/Number(t.size??t.width??$a.width):t.strokeWidth??$a[`stroke-width`];return[`svg`,{...Object.entries($a).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&eo(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&eo(t.width)&&{[r(`width`)]:t.width},...`height`in t&&eo(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function no(e,t={}){return to(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var ro=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},io=(0,_.createContext)({}),ao=()=>(0,_.useContext)(io),oo=(0,_.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:v=`currentColor`,className:y=``}=ao()??{},b=!!c||ro(d),[x,S,C=[]]=no(u,{color:e??v,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:Qa(y,s),hasA11yProp:b,attributes:d});return(0,_.createElement)(x,{ref:f,...S},[...C.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function I(e,t=[],n=[]){let r=typeof e==`string`?Ya(e,t,n):e,i=(0,_.forwardRef)(({className:e,...t},n)=>(0,_.createElement)(oo,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=Za(r.name)),i}var so={name:`arrow-left-right`,size:24,node:[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]};so.node;var co=I(so),lo={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};lo.node;var uo=I(lo),fo={name:`book-bookmark`,size:24,node:[[`path`,{d:`M10 2v7.751a.25.25 0 00.407.195l2.28-1.834a.5.5 0 01.627 0l2.28 1.834A.25.25 0 0016 9.751V2`,key:`x9x4jl`}],[`path`,{d:`M4 19.5v-15A2.5 2.5 0 016.5 2H19a1 1 0 011 1v18a1 1 0 01-1 1H6.5a1 1 0 010-5H20`,key:`1889un`}]],aliases:[`book-marked`]};fo.node;var po=I(fo),mo={name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]};mo.node;var ho=I(mo),go={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};go.node;var L=I(go),_o={name:`boxes`,size:24,node:[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]};_o.node;var vo=I(_o),yo={name:`bug`,size:24,node:[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]};yo.node;var bo=I(yo),xo={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};xo.node;var So=I(xo),Co={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Co.node;var wo=I(Co),To={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};To.node;var Eo=I(To),Do={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};Do.node;var Oo=I(Do),ko={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};ko.node;var Ao=I(ko),jo={name:`circle-minus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-circle`]};jo.node;var Mo=I(jo),No={name:`circle-user`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}],[`path`,{d:`M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662`,key:`154egf`}]],aliases:[`user-circle`]};No.node;var Po=I(No),Fo={name:`clipboard-check`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]};Fo.node;var Io=I(Fo),Lo={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Lo.node;var Ro=I(Lo),zo={name:`corner-down-left`,size:24,node:[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]};zo.node;var Bo=I(zo),Vo={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};Vo.node;var Ho=I(Vo),Uo={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Uo.node;var Wo=I(Uo),Go={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Go.node;var Ko=I(Go),qo={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};qo.node;var Jo=I(qo),Yo={name:`heart-pulse`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}],[`path`,{d:`M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`auskq0`}]]};Yo.node;var Xo=I(Yo),Zo={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};Zo.node;var Qo=I(Zo),$o={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};$o.node;var es=I($o),ts={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};ts.node;var ns=I(ts),rs={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};rs.node;var is=I(rs),as={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};as.node;var os=I(as),ss={name:`menu`,size:24,node:[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]};ss.node;var cs=I(ss),ls={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};ls.node;var us=I(ls),ds={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};ds.node;var fs=I(ds),ps={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};ps.node;var ms=I(ps),hs={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};hs.node;var gs=I(hs),_s={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};_s.node;var vs=I(_s),ys={name:`route`,size:24,node:[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]};ys.node;var bs=I(ys),xs={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};xs.node;var Ss=I(xs),Cs={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Cs.node;var ws=I(Cs),Ts={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};Ts.node;var Es=I(Ts),Ds={name:`shield-check`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};Ds.node;var Os=I(Ds),ks={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};ks.node;var As=I(ks),js={name:`sun-moon`,size:24,node:[[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715`,key:`xlf6rm`}],[`path`,{d:`M16 12a4 4 0 0 0-4-4`,key:`6vsxu`}],[`path`,{d:`m19 5-1.256 1.256`,key:`1yg6a6`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}]]};js.node;var Ms=I(js),Ns={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Ns.node;var Ps=I(Ns),Fs={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Fs.node;var Is=I(Fs),Ls={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Ls.node;var Rs=I(Ls),zs=ye(`inline-flex shrink-0 items-center justify-center gap-2 rounded-lg text-sm font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-150 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 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 shadow-xs hover:bg-primary/90`,brand:`bg-brand text-brand-foreground shadow-xs hover:bg-brand/90`,soft:`bg-brand/10 text-brand hover:bg-brand/15`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive dark:text-background dark:focus-visible:ring-destructive/40`,outline:`border border-input bg-card shadow-xs hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-brand underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3 max-md:h-10`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5 max-md:h-10`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9 max-md:size-10`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8 max-md:size-10`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function R({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?Oe:`button`;return(0,A.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:F(zs({variant:t,size:n,className:e})),...i})}var Bs=ye(`relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-xl border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`border-destructive/30 bg-destructive/5 text-destructive *:data-[slot=alert-description]:text-destructive [&>svg]:text-current`,success:`border-success/30 bg-success/5 text-success *:data-[slot=alert-description]:text-success`,warning:`border-warning/30 bg-warning/5 text-warning *:data-[slot=alert-description]:text-warning`,info:`border-info/30 bg-info/5 text-info *:data-[slot=alert-description]:text-info`}},defaultVariants:{variant:`default`}});function Vs({className:e,variant:t,...n}){return(0,A.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:F(Bs({variant:t}),e),...n})}function Hs({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`alert-title`,className:F(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),...t})}function Us({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`alert-description`,className:F(`col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed`,e),...t})}function Ws(e){return e instanceof Error&&e.message?e.message:typeof e==`string`&&e?e:`The action failed. Try again; if it keeps failing, check the server log.`}function z({error:e,message:t,reference:n,title:r,onRetry:i,className:a}){if(!e&&!t)return null;let o=t??Ws(e),s=n??(e instanceof E?e.ref:null);return(0,A.jsxs)(Vs,{variant:`destructive`,className:F(`text-left`,a),children:[(0,A.jsx)(Is,{"aria-hidden":`true`}),(0,A.jsxs)(Us,{className:`text-destructive`,children:[r?(0,A.jsx)(Hs,{children:r}):null,(0,A.jsx)(`p`,{children:o}),s?(0,A.jsxs)(`p`,{className:`font-mono text-xs opacity-90`,children:[`Reference: `,s]}):null,i?(0,A.jsx)(R,{variant:`outline`,size:`xs`,className:`mt-2`,onClick:i,children:`Try again`}):null]})]})}function Gs({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`skeleton`,className:F(`animate-pulse rounded-md bg-muted motion-reduce:animate-none`,e),...t})}function Ks({rows:e=5,className:t}){return(0,A.jsx)(`div`,{className:t,role:`status`,"aria-label":`Loading`,children:Array.from({length:e},(t,n)=>(0,A.jsx)(Gs,{className:`mb-2 h-9 w-full`,style:{opacity:1-.6/Math.max(e,1)*n}},n))})}var qs=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAkvklEQVR42nV7Z5hb1bX2u9Y+RRpNn7E9425s02wMxgZMNc1AqIkJLTcxgQChpBEC94bwpVwSCCQBEkghECD0DiZwIRBaAhhiMGCDccEejz3F0zQzGrVT9l7fj6MjaQzR8+iRdHTO3nutvcq7yiYikAgAAESASPQJRN8BgLnyO/6fCDCmfC+JoHQ3QEQQkfg+MqbqPwDE0f3xfACiGySayxiMe1XPt+ureoz4d7zW6DvFo4OZSAQipQdEAFW6o/xgPBlz5drnvZiJiBC/owkZYKKqiSMGACDmykKVGj+ySOlGqsy/K5HVa6v+nyNmUnnC0pd4/fG7mkkxc5hLDIh27PNviHe9tLFlYkq7DiKCEZLKRESAxJPSODoIUIpJpLwJ5XuoakwRUPyKmUiVbaLKWNF/1RJcuoMqdBGqSPsMU8dJQCzqpe9kTGXw6oeqGC3VkwMAKy7vSCwJVEVBdD99ZjyOLxHATON2Lh4nVquYuOjaeKkoTSVVdFH8VB2A2397sNO1Y8T09PsVEaVoYi49zK5LzDyO20wEVqpyPf6tFDGVOR7xrrR3pBSYuTxu6U2sFLPtEFeNTzGfEGsRR3NwNAcxl2WCiOLfFamsfts2sWWBmUEAURNAN14M1btl2aK+jmXznJKWlHYHpFRpsmjS8mRlokrEKBU/VFYFtm1iZiozT6mYARQTXx43XjzAlAB44QyXDpphUx0zlxbEllXZiOhZoojJEdHjbE+JwJjwte+c0vCHG/e3AZBlgwgWAaBVz852R3oPPcfrm39d0NfWXM0sK9bx2IpH4lsR/CpdjSQwFtvSp9YCkYhXIoLIugtVPSuxpBkDOCBceLKNr3/ZozUfS61SZI4/1Co89JiSm54MsDMbxvdLrN8VDyOxmJExgGvZKPqB/N+T89QRRzQu1UF/clMy/QIA1FsuTQ88eeajRQ3NU2ouTuT7zlLFnstpVjZd8jVlZSxb8SpdL1+LJ491D4AwExmBiKnoZLUbjI3keLdFOGl+Da69OsRgGk7L7NS+U3c3K0KvmO/aJPfZnto4sdGEN97Ecs9rATJeUG0jJOK8QASwLFAQMHa3DF7ffnBDU83I+chlDyzmM1c1zh3dngTTMTByz/bDpte24Gon038W+nb8eVgVrtl7QW3YJ9nyxpSte6xLSoFiMYzEOdY5lHXWsojG6X2VHsbiXq0qE5IO3/fjGt76d1ivP9Q8tfODxssL/amPZCgRmJ2On+tOvLvt/eRFqx5LtuU3pKxVdzSqRTOSHCEGVNudcbreuemoWr9vz2vDTc3bRlc7XxQRzEmAH/4+eLTv8EV+cfHzZmjPorxb84H5kOYCU6hkP7lqnIrLYQbZ9jijxdUTV2xEdJ0V8a5MYAYxVwzcisPqeOuz4H/8tb7249dbjx/ZVr9SD7g52WmFst3NyGY7LzssEw64meHO1COb36o9et3zdm3uE0vd/I0ktyYVgyIbsKuxW//OPMdsbjiosMo6e83DXDMZoE9fnefkRg47OfTnfyBjc3xZXZuVVfzNv2+fzRMTarzhjQ3I57m3issqIbaS0FSrQnwPc9l+gBnQmrD/5ATdcI2gpb2oPG6bOWOOWdHSnDvXYX8qDIoY5YLZKJY2AmsuhBoliQTZAdmdmRH33nQX399cm+7s/DihL7vGyNvbA4BMWXCZSWCEDGBEgLMaQH9au7Q21ZpdYbtD/0NB2IYNo0Am/6Jus1dM2LMuPYyB6rWDqAyExtsAZpBSJFVQt4QqPosFSj63gvKEaMWRLt19S5EGgoaGCdOaTp69R/Ha5sbc2RaFtfB5DNthsMXUSF7yYVrAQ0gwyEOKAuWa5mQ9Dk212IvyXkPOD6X7kq/mvAk6iQ82CXKBKc8nAPZpc3nweU03/OuY9lT9zqstp/cHZPxGbMkbDORHUcNXqf2++JFgDWtUQEgZY0R6TzCmgo9jMFEBLZX/qiFtlckUMQYL2m265X8EOdu22mc1zp8xy7+osaH4ZcsOGiGcxyA0usMECiZAgv8pTep2PaDrVEYupBCL0UCE3awA7WQhQQltEqP5TO1TQ13qdn9nx0db3qNgxa+UDOZCARin7Sv08/8VmnPYEXvZqvunSg2cAiXADoTYlnfB9Pvs9ORVe+zpB70coERkvKUQif3XLmIdu72SqJUJJwJpHcHYqkAHdcrGlWdbOOVkUBo1rbvNMadPmhhenEz6e4Pho6A89IY2MqEFizaiju6UKdZjD743s19Py+Jr3D+V+sxXkDPnAjQTrVaAGZZBi+2Ak64ftG4aHUjd2rN+x71fPqU7t1UzXXOmwXdu2Muqq69daqH7WqbhA6CgMaBCfFq0JZRNpoFPtw5ftAF4h5WK3bggDs5EAKsqepIq0SgDXGOkhPdFFFM5ghOAxDCO3NPFr3+g0OuTqybwkoXT/Mvq64MTlGUcaM5hQIC0l4RgGI38BCbwHcPJ2vVnTfbDd+lTygSMczF3x/begd9MGxj+B4bNRcgGp2KzbsQoeZhiBY7lTW+pLy6WGfa9tlZ08/kaF/xm36Rj/LOV2XoNSXYGLAoxZIX41FMoSmAS9MfvZ2ZsJLzHpCKLbcKwHNdU6KXyjpf1YtnBbVZ73US598W1emKNRf15DVAkLhUswPTdoxtxwpEhuXP19Nm704rWlvB81zFTweShQAHSoY2CaDh4E/XWH/Qk65WrDpyYe2eoj94dDeD5gQCAk3BIihYCHGeK21+qdYf9Y1EwlwFyMFK2hSR1wvW/RtNmrX7kwi102g3zWi0z+h02I5eR9hqgWKNghbLeB8a0bRx6OddgfbXhqNQgMFwd3BNzGU9IJQolqvaxePDWae1dmw64dKj7gL0fugzquCZwq21VwWCiFBL02O9qaz9+I/Gl0W3uK7rf9WTADWQgkZftTkE+UUVZzx/LFvsKM5CY8vQD+/AX2uu40XG4FPvRqpeXtL389JwImhIxQzFQT8AyCjvdybLR+oFsUh+ZbdYV993WyGdOZvZGF87VI+0PymDSl52Olp1OIDtqPP2CW9APsRc+wgP5Z60To50uuz3c+OP9nTOPb1IAyHHiOKGMAyLQExHn0BO/oaaRja3Phrnpa7Pp2Rf3bprTehVAJ80mpkqmgD5e3dpeHKr5q6SdggwnPcmmCpJ2Atlp9UuvfbsMOfv3ddfYNaihSTVOGdgAoFcePMTODi362UBHy3nRQohjXGHDZmASffivZivsc3fPdCQbAdBvLl+qwvy8oyXf+FcZrlkrA4m86U4U/JfcTPE+zngP8nDxSXXTmqecBJAgAHjx7mlWNr38iO51Sy+48yd2ElBlgFZmQJkJFhOg6MrzUvbgW/bvpK/ON8XmrJ+d/HR2aNbRPWtmJH64F/iomRbXOA6/+Ps2JSM1bdJvXyEDqU0STCiI3/Sa5FOn+2OpOkI7tUIxQEwcRYZx5D8ycNReOr/bhsLO5EufvGW3lhYcryO6GzZHO2mTssB7z0rxrZeCg8KsWsm23Wh6a4qZx52xnp9Stvvn/NHO29S3e5+xG2P/lBk8ZZrnHfuzcGhJ58Crk65bfhiUgr0roKpCReUQWND1mrpEr3fykq4pSCZldLap289Mu36sb/6cjieU+u054MPn1DLQTuv/3myZ0frFEu5zkQ4Xzrr2+HZuhE0cRQVEBLZtMCswwPzIz2aqYnbR1ZJvLep+dzTd6SwHWgEQx1Fg1S5xKe6jOGtg9N5Hm8yE7blnagqD1/JA/y/47p23qP2W/FeKRP6Fvm3LU35h2XIdLH5Dgn28cPWk0c576WypRDWVdwnaVuJjMIkAG/9hHxWsUWnZmhiToURB0q6W0VSgRyf+u5iec26md0HTS1eAv36gyxPRwMBMAppK8JIZ4FjUSnEFcSlMopG+L8wK8zPfk+FaX3a4pthjP77xLafehR2pAo/PFTBVntXmwKlmbNarhRcaiulfqbfTv+Wv7HzMSYkcibtuOZr97HELdGGf2403bVCCtlC2TMwVH7G3rbuDF8YMoP+kAkRxfD2NVj9t71b4UH3kv2pliq8m0mZHIiODri8DrjGDdWPB4OSHcjvnHdy3aU/33gvAh85wS+JN5Ti+ksSIRq+Fw3dfDi4OL77MDNcXpSfpyQY71NutgaGtzjHAVACqKr8QhSglpEIj+XkJPTz3V4VXm3syv7duGLlLzZIsQeQqeJlTJpjM/t81I5M/keHaUEZrfNNfnw2edLOZv/C/Xr5JTQBSpXiFmMr52fGYDoCg3RpFZ5/qL4xhjfQYx2wKXO8tY3Q3ZxFSkfxi0vIGz06Yroca6wv//aVfLJz2wP2GbvumYPcJdtnFiEjECQJBiDR8+eJVy9osM3gWFQouPAEK0JyX5qSSMz9+YyQ5vcaBkSp0FiXe6Pyvguqz5oRwc2ZWuCNz3uZUeE3Decd29I2c6prMS8ts74O/Un7TL8kb2B1hqKWPPHnTC2k0UEXBJ09/QCOAF5NazlaWc4JlJjAoZ0IaGEsGp+0RrK9huErRbCpKnenTJAX2KMUhKcOkvSYlhcMUewelJrZn9z1qUtcxs3f6g90K67uFojR0hDgSsHHjuZqWfKHpi1bQfQH5vhKfhHJRFoVtnmCl+PUf3eT2AIaITJkHIpBX/29BvZsrTg460/ekvnzEB7f9dZYcdURu9zra8t9U7PoJ+cMLgJAQWAE2kIc1PtOYTiBJ2wpJ+t0Z/2/yBmCESmn3cRlkqgL+MS6ABcA3vul4qjExhYrHKl8uR4AlosFIqoCnKUNtYsMyDpiUWO6oUfUrfWm8LbNt54dnnp7R/+wMwEwwhjATRj7sO6olRR33qkL3CTASep1KW6RF1RmFJCGfSNy0tcv9yX+dUQjX7ixEWSEmMlpwz02z2M31ydnXvKz9/I8aHd19OrzBb8PPzoPRBLDGoAqxwRgMhY44yKMOT5lG+u2b6eRHp5xflIwXiFIRQ8vR7S7REVWiP0DAEFMrIhnxX7LbbF+fSz4uFB/ToSlEs+XTLMVoMg5YFJQyIo1rkJi64sJp//70L2kiIkHKSeBrS4py85MHnOr4m/5KXrZWAksX3hVx641RU4RhgcOaxKZRU3/muQf0fvLcMBOzABAotlAfhvLxp4dZkyYXD4TX+z34I1+A9pMAaRSUxmYJsDUgiFhSS2tNA91UmGQ9W3fw8lwCj7LHIShKkQsglUJMRferiEfkGhybAYwRkcXucVP7VqVafi1N6hyqo0cpKR6NBglZ67PZTJ4EVhGeMVQYXUimuOx/HgPvPyUJEcLiCUX88vFldRZGzyZTqIdikRESCoymUARCAgWjJJydtHHS9Y+1qIXtKRgjMAZIhaH0ZJbXTWrPfB/5LQ+hOHA6JHBBKkS35eMN4+HTgMTBsG7hm712dZa17phH6w7mvMuPsK8MmEqUoxIGo+T6dglvSzZMBJ4nImIMEIpCNx1/dE74qCdWe5PsS00jf0dqsRZGW8Emzy2uFQMtDA4cyNjJsw8/prGlkAegsHAqJOkWD2CkjwaJASmDtFE6IS9KCmvhkYJFRBJaDrzTJ89umXrgtDEACgQHEwA47vCRCHquhMlPBFMgGSuUt6mIt/xQsoEJ6/G6N4HP75mb/GnyuImdjde+TECefGhIOTkplUJGNQPGJx8BpUBGi9xydcru23bAPjp/SH07fJnS4sGhMzmx2B374Y4F94f16pzA5j/4AQq6L2QJLR8WDCR7AJHefyANOXpiiP/927Kk4tEzCflWWGyQZ0FosmED3YUmegLGGAgJBKJMcX7SCo776lWgGjDq4ePjwopa6P6zEGabwIxgh53PPxt4er1HhqTHb+DrMm3qG8nTzv7H4kUSAl0y4oeSTKgSEKn29uNLZWXAUZ3VjeJlhZZGz07ItitYd9y2I7/7wtdens4Hu0W4NEZ3XbSOnCMu3/JKr/Vjz8aLNowjIxxAKQ0pNsFkTv336FL3xlOBRMqeT5I+HqIFpAyGNGtb3g3brFW6Xv1dHHTBA4NIKPQTjuTP2PPA+S2L7QBNgNj20P4wQ0eCxUCrwFsb+v6oNjmi5zMpnLd+buKWluMa+oH7qB+HyejOpTNfe2pOe6Goy5bdmGj3JVaBCKeAgfL1smeIJMZCMdAGuYyLfOYryO98uG1meOkr6QUt1x5psNc0AXATn3CZl/Xr+DFVIwUa1ASyfEAL9PCxdm3tbvN/Nc1i6V9OenQKCAY5EhkLA+PSU86s9uGgLrlZXHoJvlAkBWJUkD0gSbnDb7gGsjl7VgKm7wyY7EQoZfSQKnAmTAR1tHa1T1c0nR++c+bSnAEGJD9yYp14XSuc7JZ7Ev09i0UmiTEEAQkRhJlQglUkRsQYQRkIVZXAS8zQGCuwJoiPotbQ3iyY4euZ0ndd+dJ+h95xazNPawCIEjSg1BthDdZRPnCRVT4IBnpkJsK+ZZzYaw8yA6dCBwQog34DAT419fyPpy81Utt2hmcS/KRARuBFwkihV+vozFlzLmitt2pyeyPsOwFGA7ADs9UYZQnlXXpq2ZpZ3SCiJ19dqkxu8UFJ88HtyOy42Vs/OF/SBRvoi/a3ZAPiyk51LXGcDShfLDFj53bHiIOijBoyW5TGKNkIzYkoZH6xxwGYsk8+FEDoghfn9BdsekZIA/2hwJBB4Nnw06epcORc8tOzYcQgyxrDoRGLnvdnJjpf+GgIu+FxClPWu6LwNvKGATIQMUrnliZhHYpw52kIRqaByMiIKnCflwhd6ugjeh7PzBWRT2X+3qPzKNN5B4ojX/I7ffa7AttKfqa2H+FcU8ltjmMAK4qDl1LRSOijLleCHH2od+jXpav4ZrixsEa2ZjIYGliAwJzwy3cW8OQk4d0/HWXGiJ8PHXRhyLdRYB+hMfCGF3Fx+wp4HsOwQZ8IQtOHenrmiUcnByvXFdHPOdzw4N4j4vJTMMaDTwImwzpochF+B/ne5Qh8hnBoOsIQWts5S557ssfaCvyDgPNA4XATRkenYCikcLsGCyzLquzx+PL/uORvxQ3qUMREeWMigEAGg92ebHuf7xrWvHxkmru8MKv5QaSKtvhFV7Le6fPnBhN6CkUB7qIOP7XZZ3oFhdDGgNEwIvDzSRTSTdAiyLNGv09i4Q1p53X/+mMn8jpE1oT40w/6YWr4ZWHagKwwmASAWF52KfJDc6BFJKc82eE5oYO+IaGnb7wuHwIGQBtALBAIjGaCkKUAy6rUE3cVhBjwSAyESj/K2WAiQLHIvzfmcMA32Jt4apCxpy+eVlNvLiBLWbIeoXzgTUNnemI0Q0BLTxz2cgZPa5Gs6Q0ZIWuYEuhiNugTg4LJUZKe/mfv1Nwz6zxEMZkBuf30qWruFpueQ1EDHhkwCXTICDUDbGSHCbgYukVFr28I7I8spChiwDTAUoBNAotE2STKgihVFfdQdbxT8gaxG4ybIXbhUpl7C1N5Gtp+QkNNTd8Vigu7Y5PyeMCkKTQ/37F1dIOiJAOBEDXQANv/DpjWmNHQkTEKoUqlF18Z9IQKitaizXrrvWtHkNZGCBDFhF7Px95T27VJ8t+E0IuMMJgj+MYEBMo3nYEyhPwY6IkvXVTIhyiUYPwhkUJbJLAAUiBWANtU5dZFSjYwrjqXbQLHafAYADFHm6Y1MNmxcc/9u3FtY/9Zyhr8IrZKgB5/SBrpB6vm1j0841Qr0FIAALJUnuYvO2fYc/kZsBhJm2jnHRbpF2OyWiOFlUNzmwb/b20h5jLpUo5+utNBucbEJ+Lwq8gbRhARBJvEDLKHkTDhWXivD1hF1EZsESLujlUsOJOAIOX0ScW0UxznxLWMct1DpNJ9Vc6ZG5CCoj39QHY/as5+tjP8XeoOXHQF/dKEKx6a1fzEoYuLBsgCgFkwyUWoDYBtUkjxPySF7ZzTNgxrGKVNl2YodKCV//7QpY55rcMHYCFhCEoiU7Tdz6Ox7VsFU8NPCjCGjCFYLFC2r7dpETG6YNMTi9+ZkQb6icvFsV6UkT1VuqUiyGuV0W21plMpZ1VmQJQrj5MYkeWcCi1P9x7bbCd7fkCDmTnY5ndJvXzv8elTVv7X4jG0oICdm45L5vuPX7Dq3w2J5QsdAG/SelPTEdbSi2CtUBQjg6SR0UQpPOfNt7e982YaRzSEeOO+kHp2Hm337TzQuub0UA5q8DABdyJsdt+WGryHglEAG5NRvun1E6GijcMKL+G2IgAjUTOWRvSu1vCIhGgvw/hbWQXEVLV9xW5QjFQNQJhoGTy3cj+VbMqew5mhE9GR2yKJ8Nt3TZ723CX7D4JRkM7+ZfUts7zvuWHnHTXByKLzr6hDk0V0zNLhwEuplSaJEWRClu0BkYUBauaVqx+aFF507hi9lj6j7dCvHPv1xsbRX7fUFq+79v4DT3ujf1btN48Zote7905LHT0FSwLkRPSnoRHfcNHC31bWNXQl0EcAyERiK8DMij9jgjBFDqGaKabcUVbCORWRsKrEg0QgNlnUHwYy97jm/VWh81vUOdopHH73xuxer/7poG00JDnxcidMtNyhH9Lo6Plmc59rkvory04tvKdDLgINNAxrTU1Sv+NoOY7yIqil1zDbWbdw01ZKffekqdCdv4TuPAVeNom8BgLrG5Yjf/7xg8mfXz8pnT16m/USh8EWZMxc6dGuONSTU7TyypO+rYGfRlAWAKAICEuNdYjeJcWoJPsIIPlMQTdu1KsOhyUCQYFkR45psbzeq6hnoCChd+mX35r36h+Xb6FtuawYOXGmzf03c0f3N/F695jZkF0ZduL5bIfoDEIBxmi3RdeM+g4/KRY8sjFGdXjs6gf2ysvhU1kKO76G7MblKGZceFrDDw2yhTrZ5l0sn3rH/ASnSb/fuF1q+DkoQClRQQIvrrVSG1L4OYGIRAhJuABC6RrYZIHqpwCkSmGfAATiz8Q35fY9U9W7U0aCIkATQOtWL1EJGlmBgYF2PZa7pPGSfd54/cqNdNRRBTHFw/ZDf8etsqlzn3DjwK1+UDijOFed555xwjMLlhQDICi1UtxKY4Zf0YStSMqasI7fvP6qdyETd0tJNr0UmZyNsVCQ14APkSGE6JJaGZMjfvTY/Tx19y8FJsEr4WAANTRScPDYieeM+jlogjB2g+AXF3rQ4VlTplrPX4GhT3+CIEiJ4TAowAgDrCoSEON/lHuNSGLcY5U9iDg0DN/MmRMeIiMDS8LRzPcSS1pWJ7Gep0+38Ie7jp+nB7tON4M9fwvTmZc2tdH2/RaZcIKdIOAF7i5EoacFohBpuu1hu/uHZ/hP1tRTl32QlwaIfD+vagqei5wRCAEM0Wlo0ylsERntiFtTCAh4hHJir6u3/Df9Gjjb0vxeG9lkwcdcaHm/+OUaV/cvRf9blyHffxgQOMEIF0beC/1CjySsVimMJamAimCX+x6qmi2ljASNiVLWuYFDJprC6BH+2PANicX+6kZ7mAvw5bxL9uXhwVx2uKfvJne/0dtTR7d3HLYYhojZ03kCtLz9/nLO579e89wfE1gyycN119WbnVm6sxd4GmggwMLOvrGxMPDWIU/AmJigS8LiZoEuQjTBy4Pe/9GKQQ1kqXHG5flA8b3ZGrrroAuCbAuK9NyjbbQ+PHKOW/zoxxh8/08Y6z5WiiHnPubM0AvGz3cYJ+djy8atuGbVarxNVK4Dll1htduP0RABwBP3LVDHLWtcIrmuofrZWz+psWzOh0HcD0CIcCdFhkcLEVObZdCbhOjOo1p5rPsrSOj9UTPp4SA54Z9fn7Qy/+AgALhw3IB8jwG0yOCHmf3rC8FfKG329noEpAlWElKo5ec6hS/d9/RkH5AhwMXrjyvbLoZ49kee/9ONS+ps3X88csPfRjG3GIHmsJ/zubWm6PWKHQC5AQ8rNw7Tn8/+c/MnMCNCFFAs9kRCWsdqUGFGmQErHz/EnTtLavZetGoYsAkIhBkUAdYqJ0mVICLfdajjjg0fgvzA9+GMLYUVuuBkHxomPYqmGXd3bS9suHD+W+ZN7WAsDDCzycGV59bhlFMyi5JpfbGrZV8w/IKF13s0//mcFVO2bQ97KB+ESNkuJgRFeXvdIWrSHrk9Uei9CIXMmQjCFimy52+SvLfRiPGEsoL3O7P4w3Od9ovXP1AspGyHc0GIqHWbiJiEYKiqB6KMeeLeQOgynmBiNhCBWJaiIIh022UiT6KKu9YR3lj/wOTDJ9HIrQ6Kc7iGPXeSOCopLizWqG34GI1T7pTatid/u/zFwaf+Dazqs9BSb2Hn6AK5/cYP3X1mmAbPh3lunTXy6xvrwrrkEI0VgHnNGhedBHzrroMa2e87Ffn0pQgKCwAi0085/0Md6EFja4WBfp/uXzdIdy+/MdcF1BHgE4hEscTnFKhK56m8k3HzddUNVZ3XBDFES8jg7+ljptbWOnj+7vU9J13UqZkJRoD2iU24+guZuj3q9fHT63BpvUv7uQ1kUnMZTrtJkC02XCeP+saXUd/6x4Ca37p8338Wn+8hbB1TiPy3FYM0AKCkbWNf4+H5bYdbjW35fZDtvATFsS9CTAMCLpotUjCbtdKBIEv0r+0F3PLARvfN39wxM3CtjeyFulrEaVx5DeWgqBoXjz9oEKMkYyKVH+he0Fqns7dILtyWtVqvnzB3TY4YpZMdRFpbIhLIAxeqafu0yXmtSXwt6dIEZxKFidmwVJMkYIGRTPQiVf8w6qbcvf0T69PzDn7brA0sDHq6RDxjXovB984Dzr/xhBbOb1mOfN/FCPJ7gwgYtsbk41BL2iQ8JT0Dmu5cl1H3nXzVO/0tiQNoqKgRpf0qZr9S6IqCo/G7X73hUUX4M/nyx++ZrY45NHm26u/bZ2zbwB3Pb0h0XHBtYJhL+TUjpcoSCXCoHHHAe9bPjvQPntUs36536WjbheXMJG3vRg4lxQWRRqLmQ9RO+LMk259ZefW/0jf9FegYs7FkUoB7PjzeTjm5RRjruASFwRMBUw/NRXRIHlu1rQ0kw/RyZwE337mpdvXvf1urge5yC2dVpCelUyTlKDc+bxA1fI1r8owMpMTNcVU8uO9P+yX3n1uchf7NHfPOcQstiSIN+1EEZkzlUEJVWCEiRu79ltW0eLKcMbFGLk7amGs1cWDvzuAJSALGhlIZpBqeR23Lnzy/ZvXAprXBlIUntVF28xkY2/EN+LndwUqQUTls0hrDOlFg7OjX+OOHw/TQaVeeMTTReYL7/aC84Gq/Xo3+Sv+VVcKYCkNiV0jV2ZLy6Q8GkQFM2fVFL6WiQUriVOZ65B5AEMCYegGS9Mo1g3vObcUlzUk5w3WoltqVxzNgIykuGIyEsw3J+nthT1+HTM9Xke8/FghrYawCOpHH9tDRAj1K9EJHHrf8+g3n/YcfMIZQpDhvV93qVsWMqlMpMv5g1i6nW8bZgLhqGrfHVneJxoTKLpUlVqWCm0h8eCk6ScYKRmvzq4uSNSfP84+bUofvpBgHcJIMzVQak8mFbRxY7MO3xlAsNIPZIKvy2Kw1RoxbsLCt39Bt76fp0S99f8HIjPq13JkJdmndL6tu2QAQEZWMXXxQq0rcq4VDKgyI+/sBCJXUejwjPiNa5W5RywKF4fjMY2lJAJIAXpO/X3vI1HmT5PzWpHzdVdSGCcrDHMVoJAcFw8ibAN1cwPbQ0kbCUcJznUW65fq36tY9do82QJYAMw7AMJfSH5UjcGVRrz5HVKoClfIAlZR4rAJqvB5HJaNdRaZsTqtFqHJggEQozjdVjtAREAVHf6H7Xz1kNOsOvbVbe/ium0CrHZrZnBELtiqKp4r4ONTYqRNFRkef0HXvjlg3HXnZiZ19n6yngi5QHMft0qhd9nOxKigFAtGuW0ZM4+gZ5/nKOICo0jBdSpLGBZWyMfkcPaKqxUj8rDbxwCjV5AAFR0LxZeX1TsvCGfrsCQ3yrWQSu+lhCs0oimM2nukK+ea71zV99M7DRVnVW9712JlLHNCVelZLprtCr2UBYVg5kLnLcbqyERxHR8yA6hOj0a6WU0njpKD0MFUWMB5qlTrPQBSdJYrHicwRAZgqc9qz9Mh1o/vOmCLfs7OYN9hPf17nq0e++J19R3dvXsub0l611MVwFmJM7NJKhjjqfiYm0mGURI4XyRwldqOaYDkRGtMpsSf4XAb8J7Ev655AmIEwLCPH8oEpVLQDRDwuBUdMJESosy3JFHy5/+dOfVOdbrrrDbfrpceVyVOOdJyfo7LoSilvSRULHOcwY4ZL2chFAE2qD3jt8tDnBEOlBuJokMi4ltUhFuvYA1TXEavwAKotrAhIRKTUJgeRam8qYKVgDGA0CdAqQH+pyFEeu+zXxjX4YxxBZWmMpSLuAYlPocZt8buqa3lsqe4Si7MmVDkUvau+RMygXfSrrAUUtdBHx2NLalB1GiXagKg0DRAZiYjOEpXPdpYZHtshqtrJcUdkq84My7jCTqk/8/MkurTOcQxUFRqq3AZVFxYq/33OgKg2OJXui5igMvwc99o1KVEenysnmaJSbUQz7zJ3PHbMrCrdHpfzr143VSVGqpkzrk9w1wPUu4r8f8AFn8uQ6vHGZ+L/8xjxzsVCGif4d13L5611PHM+O+fnrRMA/j9u09405ZezXQAAAABJRU5ErkJggg==`;function Js({className:e}){return(0,A.jsx)(`img`,{src:qs,alt:``,"aria-hidden":`true`,width:32,height:32,className:F(`size-8 shrink-0 rounded-lg bg-black`,e)})}function Ys({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`card`,className:F(`flex flex-col gap-5 rounded-xl border bg-card py-5 text-card-foreground shadow-xs`,e),...t})}function Xs({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`card-header`,className:F(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-5 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-5`,e),...t})}function Zs({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`card-title`,className:F(`leading-tight font-semibold tracking-tight`,e),...t})}function Qs({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`card-description`,className:F(`text-sm text-muted-foreground`,e),...t})}function $s({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`card-content`,className:F(`px-5`,e),...t})}function ec({title:e,description:t,children:n,wide:r}){return(0,A.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-[radial-gradient(60rem_30rem_at_50%_-10%,color-mix(in_oklab,var(--brand)_14%,transparent),transparent)] p-4`,children:(0,A.jsxs)(`div`,{className:r?`w-full max-w-lg`:`w-full max-w-sm`,children:[(0,A.jsxs)(`div`,{className:`mb-5 flex flex-col items-center gap-2`,children:[(0,A.jsx)(Js,{className:`size-11 rounded-xl`}),(0,A.jsx)(`p`,{className:`text-sm font-semibold tracking-tight`,children:`Warlock Devtools`})]}),(0,A.jsxs)(Ys,{className:`shadow-lg`,children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{className:`text-lg`,children:e}),t?(0,A.jsx)(Qs,{children:t}):null]}),(0,A.jsx)($s,{className:`grid gap-4`,children:n})]})]})})}function tc({className:e,type:t,...n}){return(0,A.jsx)(`input`,{type:t,"data-slot":`input`,className:F(`h-9 w-full min-w-0 rounded-lg border border-input bg-card px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 max-md:h-10 md:text-sm`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}function nc({className:e,...t}){return(0,A.jsx)(xi,{"data-slot":`label`,className:F(`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`,e),...t})}function rc(e){let[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(null),a=(0,_.useRef)(e);return(0,_.useEffect)(()=>{a.current=e}),{run:(0,_.useCallback)(async(...e)=>{n(!0),i(null);try{return{ok:!0,value:await a.current(...e)}}catch(e){return i(e),{ok:!1}}finally{n(!1)}},[]),pending:t,error:r,clear:(0,_.useCallback)(()=>i(null),[])}}function ic({requireCurrent:e,submitLabel:t,onSubmit:n,onDone:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),f=rc(async()=>{await n({...e?{current:i}:{},password:o})});return(0,A.jsxs)(`form`,{className:`grid gap-4`,onSubmit:async e=>{if(e.preventDefault(),o!==c){d(!0);return}d(!1),(await f.run()).ok&&(a(``),s(``),l(``),r?.())},children:[e?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`pw-current`,children:`Current password`}),(0,A.jsx)(tc,{id:`pw-current`,type:`password`,autoComplete:`current-password`,required:!0,value:i,onChange:e=>a(e.target.value)})]}):null,(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`pw-new`,children:`New password`}),(0,A.jsx)(tc,{id:`pw-new`,type:`password`,autoComplete:`new-password`,required:!0,value:o,onChange:e=>s(e.target.value)})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`pw-repeat`,children:`Repeat the new password`}),(0,A.jsx)(tc,{id:`pw-repeat`,type:`password`,autoComplete:`new-password`,required:!0,value:c,onChange:e=>l(e.target.value)})]}),u?(0,A.jsx)(z,{message:`The two passwords are not the same. Type the same password in both fields.`}):null,(0,A.jsx)(z,{error:f.error}),(0,A.jsx)(R,{type:`submit`,disabled:f.pending,children:f.pending?`Saving…`:t})]})}function ac({token:e,onStep:t,onCancel:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let t=!1;return k(`api/auth/invite/inspect`,{method:`POST`,body:{token:e}}).then(e=>{t||i(e)},e=>{t||o(e)}),()=>{t=!0}},[e]),(0,A.jsxs)(ec,{title:`Accept your invite`,description:`Choose a password to finish creating your account.`,children:[a?(0,A.jsx)(z,{error:a}):null,!r&&!a?(0,A.jsx)(Ks,{rows:2}):null,r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`p`,{className:`text-sm`,children:[(0,A.jsx)(`span`,{className:`font-medium`,children:r.email}),` `,(0,A.jsx)(qa,{variant:`secondary`,children:r.role})]}),(0,A.jsx)(ic,{submitLabel:`Create my account`,onSubmit:async({password:n})=>{await t(await k(`api/auth/invite/accept`,{method:`POST`,body:{token:e,password:n}}))}})]}):null,(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:n,children:`Go to sign in`})]})}function oc({notice:e,onStep:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),o=rc(async()=>{await t(await k(`api/auth/login`,{method:`POST`,body:{email:n,password:i}}))});return(0,A.jsxs)(ec,{title:`Sign in`,description:`Use the account an admin created for you.`,children:[e?(0,A.jsx)(Vs,{children:(0,A.jsx)(Us,{children:e})}):null,(0,A.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),o.run()},children:[(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`login-email`,children:`Email`}),(0,A.jsx)(tc,{id:`login-email`,type:`email`,autoComplete:`username`,required:!0,value:n,onChange:e=>r(e.target.value)})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`login-password`,children:`Password`}),(0,A.jsx)(tc,{id:`login-password`,type:`password`,autoComplete:`current-password`,required:!0,value:i,onChange:e=>a(e.target.value)})]}),(0,A.jsx)(z,{error:o.error}),(0,A.jsx)(R,{type:`submit`,disabled:o.pending,children:o.pending?`Signing in…`:`Sign in`})]})]})}function sc(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function cc(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function lc(){return uc.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var uc={stubThis:e=>e};function dc(e){let{id:t}=e;return{...e,id:cc(t),transports:e.transports}}function fc(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var pc=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function mc({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new pc({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new pc({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new pc({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new pc({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new pc({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new pc({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new pc({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new pc({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!fc(t))return new pc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new pc({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new pc({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new pc({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var hc=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},gc=[`cross-platform`,`platform`];function _c(e){if(e&&!(gc.indexOf(e)<0))return e}async function vc(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!lc())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:cc(t.challenge),user:{...t.user,id:cc(t.user.id)},excludeCredentials:t.excludeCredentials?.map(dc)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=hc.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw mc({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){yc(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=sc(e))}catch(e){yc(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=sc(c.getAuthenticatorData())}catch(e){yc(`getAuthenticatorData()`,e)}return{id:o,rawId:sc(s),response:{attestationObject:sc(c.attestationObject),clientDataJSON:sc(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:_c(a.authenticatorAttachment)}}function yc(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function bc(){if(!lc())return xc.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?xc.stubThis(new Promise(e=>e(!1))):xc.stubThis(e.isConditionalMediationAvailable())}var xc={stubThis:e=>e};function Sc({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new pc({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new pc({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!fc(t))return new pc({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new pc({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new pc({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function Cc(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!lc())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(dc));let a={...t,challenge:cc(t.challenge),allowCredentials:i},o={};if(n){if(!await bc())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=hc.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Sc({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=sc(u.userHandle)),{id:c,rawId:sc(l),response:{authenticatorData:sc(u.authenticatorData),clientDataJSON:sc(u.clientDataJSON),signature:sc(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:_c(s.authenticatorAttachment)}}function wc(e){if(e instanceof E)return e;let t=e instanceof Error&&e.message?` (${e.message})`:``;return Error(`The passkey prompt did not finish${t}. Try again, or use another sign-in method.`)}async function Tc(e,t){let n=await k(`${e}/passkey/options`,{method:`POST`,body:{purpose:`register`}}),r;try{r=await vc({optionsJSON:n})}catch(e){throw wc(e)}return await k(`${e}/passkey/verify`,{method:`POST`,body:{purpose:`register`,response:r,...t?{current:t}:{}}})??{stage:`active`,csrf:null}}async function Ec(e=`api/auth`){let t=await k(`${e}/passkey/options`,{method:`POST`,body:{purpose:`login`}}),n;try{n=await Cc({optionsJSON:t})}catch(e){throw wc(e)}return k(`${e}/passkey/verify`,{method:`POST`,body:{purpose:`login`,response:n}})}function Dc({value:e,label:t=`Copy`,size:n=`sm`,variant:r=`outline`}){let[i,a]=(0,_.useState)(`idle`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(R,{type:`button`,size:n,variant:r,onClick:async()=>{try{await navigator.clipboard.writeText(e),a(`copied`),setTimeout(()=>a(`idle`),2e3)}catch{a(`failed`)}},children:[i===`copied`?(0,A.jsx)(wo,{}):(0,A.jsx)(Ro,{}),i===`copied`?`Copied`:t]}),i===`failed`?(0,A.jsx)(`span`,{role:`status`,className:`text-xs text-destructive`,children:`The browser blocked copying. Select the text and copy it by hand.`}):null]})}function Oc({codes:e,onDone:t,doneLabel:n=`Continue`}){let[r,i]=(0,_.useState)(!1),a=e.join(`
50
- `);return(0,A.jsxs)(`div`,{className:`grid gap-4`,children:[(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Each code works once if you lose your authenticator. They are shown only now: save them somewhere safe before you continue.`}),(0,A.jsx)(`ul`,{className:`grid grid-cols-2 gap-2 rounded-md border bg-muted p-3 font-mono text-sm`,"aria-label":`Recovery codes`,children:e.map(e=>(0,A.jsx)(`li`,{children:e},e))}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(Dc,{value:a,label:`Copy codes`}),(0,A.jsxs)(R,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{let e=URL.createObjectURL(new Blob([`${a}\n`],{type:`text/plain`})),t=document.createElement(`a`);t.href=e,t.download=`warlock-devtools-recovery-codes.txt`,t.click(),URL.revokeObjectURL(e)},children:[(0,A.jsx)(Ko,{}),`Download .txt`]})]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),`I saved them`]}),(0,A.jsx)(R,{type:`button`,disabled:!r,onClick:t,children:n})]})}var kc=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(kc||{}),Ac=Object.defineProperty,jc=(e,t,n)=>t in e?Ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mc=(e,t,n)=>(jc(e,typeof t==`symbol`?t:t+``,n),n),Nc=[0,1],Pc=[1,0],Fc=[2,3],Ic=[3,2],Lc={L:Nc,M:Pc,Q:Fc,H:Ic},Rc=/^[0-9]*$/,zc=/^[A-Z0-9 $%*+.\/:-]*$/,Bc=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,Vc=1,Hc=40,Uc=3,Wc=3,Gc=40,Kc=10,qc=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Jc=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Yc=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,Mc(this,`size`),Mc(this,`mask`),Mc(this,`modules`,[]),Mc(this,`types`,[]),e<Vc||e>Hc)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size},()=>!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,kc.Timing),this.setFunctionModule(e,6,e%2==0,kc.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,Zc(r,e));this.setFunctionModule(8,7,Zc(r,6)),this.setFunctionModule(8,8,Zc(r,7)),this.setFunctionModule(7,8,Zc(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Zc(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Zc(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Zc(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=Zc(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,kc.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,kc.Alignment)}setFunctionModule(e,t,n,r=kc.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==fl(t,n))throw RangeError(`Invalid argument`);let r=Jc[n[0]][t],i=qc[n[0]][t],a=Math.floor(dl(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=pl(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=ml(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(dl(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=Zc(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Uc:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Gc),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Gc}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Uc:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Gc),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Gc}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Wc)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*Kc,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Xc(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Zc(e,t){return!!(e>>>t&1)}var Qc=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},$c=[1,10,12,14],el=[2,9,11,13],tl=[4,8,16,16];function nl(e,t){return e[Math.floor((t+7)/17)+1]}function rl(e){let t=[];for(let n of e)Xc(n,8,t);return new Qc(tl,e.length,t)}function il(e){if(!sl(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Xc(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Qc($c,e.length,t)}function al(e){if(!cl(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Bc.indexOf(e.charAt(n))*45;r+=Bc.indexOf(e.charAt(n+1)),Xc(r,11,t)}return n<e.length&&Xc(Bc.indexOf(e.charAt(n)),6,t),new Qc(el,e.length,t)}function ol(e){return e===``?[]:sl(e)?[il(e)]:cl(e)?[al(e)]:[rl(ul(e))]}function sl(e){return Rc.test(e)}function cl(e){return zc.test(e)}function ll(e,t){let n=0;for(let r of e){let e=nl(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function ul(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function dl(e){if(e<Vc||e>Hc)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function fl(e,t){return Math.floor(dl(e)/8)-qc[t[0]][e]*Jc[t[0]][e]}function pl(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=hl(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=hl(n,2)}return t}function ml(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=hl(t,e))}return n}function hl(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function gl(e,t,n=1,r=40,i=-1,a=!0){if(!(Vc<=n&&n<=r&&r<=Hc)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=fl(o,t)*8,i=ll(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Pc,Fc,Ic])a&&s<=fl(o,e)*8&&(t=e);let c=[];for(let t of e){Xc(t.mode[0],4,c),Xc(t.numChars,nl(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=fl(o,t)*8;Xc(0,Math.min(4,l-c.length),c),Xc(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Xc(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Yc(o,t,u,i)}function _l(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?ol(e):Array.isArray(e)?[rl(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=gl(c,Lc[n],i,a,o,r),u=vl({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function vl(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=kc.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function yl(e,t={}){let n=_l(e,t),{pixelSize:r=10,whiteColor:i=`white`,blackColor:a=`black`}=t,o=n.size*r,s=n.size*r,c=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${s} ${o}">`,l=[];for(let e=0;e<n.size;e++)for(let t=0;t<n.size;t++){let i=t*r,a=e*r;n.data[e][t]&&l.push(`M${i},${a}h${r}v${r}h-${r}z`)}return c+=`<rect fill="${i}" width="${s}" height="${o}"/>`,c+=`<path fill="${a}" d="${l.join(``)}"/>`,c+=`</svg>`,c}function bl({base:e,onConfirmed:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),c=e===`api/account`,l=rc(async()=>{r(await k(`${e}/totp/start`,{method:`POST`}))}),u=rc(async()=>{t(await k(`${e}/totp/confirm`,{method:`POST`,body:{code:i.trim(),...c?{current:o}:{}}})??{stage:`active`,csrf:null})});return n?(0,A.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),u.run()},children:[(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Scan the code with your authenticator app, or type the secret in by hand. Then enter the 6-digit code the app shows.`}),(0,A.jsx)(`div`,{role:`img`,"aria-label":`QR code for ${n.account}`,className:`mx-auto w-48 rounded-md bg-white p-2 [&>svg]:h-auto [&>svg]:w-full`,dangerouslySetInnerHTML:{__html:yl(n.uri)}}),(0,A.jsxs)(`p`,{className:`text-center text-sm`,children:[`Secret: `,(0,A.jsx)(`code`,{className:`font-mono break-all`,children:n.secret})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`totp-code`,children:`Code from the app`}),(0,A.jsx)(tc,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,required:!0,value:i,onChange:e=>a(e.target.value)})]}),c?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`totp-current`,children:`Current password`}),(0,A.jsx)(tc,{id:`totp-current`,type:`password`,autoComplete:`current-password`,required:!0,value:o,onChange:e=>s(e.target.value)})]}):null,(0,A.jsx)(z,{error:u.error}),(0,A.jsx)(R,{type:`submit`,disabled:u.pending,children:u.pending?`Checking…`:`Confirm the code`})]}):(0,A.jsxs)(`div`,{className:`grid gap-3`,children:[(0,A.jsx)(z,{error:l.error}),(0,A.jsx)(R,{type:`button`,disabled:l.pending,onClick:()=>void l.run(),children:l.pending?`Starting…`:`Set up an authenticator app`})]})}function xl({session:e,onStep:t,onSignOut:n}){let[r,i]=(0,_.useState)(null),a=e=>{e.csrf&&de(e.csrf),i(e)},o=rc(async()=>{a(await Tc(`api/auth`))});if(r){let e=r.recoveryCodes??[];return(0,A.jsx)(ec,{title:`Save your recovery codes`,wide:!0,children:e.length>0?(0,A.jsx)(Oc,{codes:e,onDone:()=>void t(r)}):(0,A.jsx)(R,{onClick:()=>void t(r),children:`Continue`})})}return(0,A.jsxs)(ec,{title:`Add a second sign-in step`,description:`Your account needs a second factor. Add one now; you will use it at every sign-in.`,wide:!0,children:[(0,A.jsx)(bl,{base:`api/auth`,onConfirmed:a}),e.methods?.passkeys?(0,A.jsxs)(`div`,{className:`grid gap-3 border-t pt-4`,children:[(0,A.jsx)(z,{error:o.error}),(0,A.jsx)(R,{type:`button`,variant:`outline`,disabled:o.pending,onClick:()=>void o.run(),children:o.pending?`Waiting for the passkey…`:`Add a passkey instead`})]}):null,(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:()=>void n(),children:`Sign out`})]})}function Sl({session:e,onStep:t,onSignOut:n}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),s=rc(async()=>{await t(await k(`api/auth/mfa`,{method:`POST`,body:r?{recoveryCode:a.trim()}:{code:a.trim()}}))}),c=rc(async()=>{await t(await Ec())});return(0,A.jsxs)(ec,{title:`Second step`,description:r?`Enter one of your recovery codes. Each works once.`:`Enter the 6-digit code from your authenticator app.`,children:[(0,A.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),s.run()},children:[(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`mfa-value`,children:r?`Recovery code`:`Code`}),(0,A.jsx)(tc,{id:`mfa-value`,required:!0,autoComplete:`one-time-code`,inputMode:r?`text`:`numeric`,value:a,onChange:e=>o(e.target.value)})]}),(0,A.jsx)(z,{error:s.error}),(0,A.jsx)(R,{type:`submit`,disabled:s.pending,children:s.pending?`Checking…`:`Verify`})]}),(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm underline underline-offset-4`,onClick:()=>{i(e=>!e),o(``),s.clear()},children:r?`Use the authenticator app`:`Use a recovery code`}),e.methods?.passkeys?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(z,{error:c.error}),(0,A.jsx)(R,{type:`button`,variant:`outline`,disabled:c.pending,onClick:()=>void c.run(),children:c.pending?`Waiting for the passkey…`:`Use a passkey`})]}):null,(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:()=>void n(),children:`Sign out`})]})}function Cl({onStep:e,onSignOut:t}){return(0,A.jsxs)(ec,{title:`Choose a new password`,description:`The password you signed in with was set for you. Choose your own to continue.`,children:[(0,A.jsx)(ic,{submitLabel:`Save the new password`,onSubmit:async({password:t})=>{await e(await k(`api/auth/password`,{method:`POST`,body:{password:t}}))}}),(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:()=>void t(),children:`Sign out`})]})}function wl({token:e,onStep:t,onCancel:n}){return(0,A.jsxs)(ec,{title:`Set up the first admin`,description:`Choose a password for the admin account. The setup link works once.`,children:[(0,A.jsx)(ic,{submitLabel:`Create the admin account`,onSubmit:async({password:n})=>{await t(await k(`api/auth/setup`,{method:`POST`,body:{token:e,password:n}}))}}),(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:n,children:`Go to sign in`})]})}function Tl(e){let t=e.replace(/^#/,``);if(t.startsWith(`/`)){let[,e=``,n=``]=t.split(`/`);if(e===`setup`&&n)return{type:`setup`,token:decodeURIComponent(n)};if(e===`invite`&&n)return{type:`invite`,token:decodeURIComponent(n)};if(e===`share`)return{type:`share`,token:n?decodeURIComponent(n):null};if(e===`account`)return{type:`account`};if(e===`admin`){let e=n.split(`?`)[0];return{type:`admin`,page:e===`audit`||e===`settings`||e===`shares`?e:`users`}}return{type:`tab`,id:``,route:``}}let n=t.indexOf(`/`);return n===-1?{type:`tab`,id:t,route:``}:{type:`tab`,id:t.slice(0,n),route:t.slice(n+1)}}function El(){history.replaceState(null,``,location.pathname+location.search)}function Dl(e){return/^#?(\/share(\/|$)|share(\/|$))/.test(e)}function Ol(e){let t=e.replace(/^#/,``);return t===``||t.startsWith(`/`)||t===`share`?``:t.replace(/^share\//,``)}function kl(e){let t=e.split(`?`)[1];return t?new URLSearchParams(t).get(`panel`):null}var Al=`warlock-devtools-theme`,jl=`system`;function Ml(){try{let e=localStorage.getItem(Al);return e===`light`||e===`dark`?e:`system`}catch{return jl}}function Nl(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function Pl(e){let t=e===`dark`||e===`system`&&Nl();document.documentElement.classList.toggle(`dark`,t)}function Fl(){Pl(Ml())}var Il=new Set;function Ll(e){return Il.add(e),()=>Il.delete(e)}function Rl(){let e=(0,_.useSyncExternalStore)(Ll,Ml,()=>`system`);return(0,_.useEffect)(()=>{if(Pl(e),e!==`system`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>Pl(`system`);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),{choice:e,setChoice:(0,_.useCallback)(e=>{try{e===`system`?localStorage.removeItem(Al):localStorage.setItem(Al,e)}catch{jl=e}Pl(e),Il.forEach(e=>e())},[])}}var zl=`http://www.w3.org/2000/svg`;function Bl(e,t,n){for(let[n,r]of Object.entries(t))r!=null&&(n===`class`&&e instanceof HTMLElement?e.className=String(r):n===`text`?e.textContent=String(r):n.startsWith(`on`)&&typeof r==`function`?e.addEventListener(n.slice(2),r):e.setAttribute(n,String(r)));for(let t of Array.isArray(n)?n:[n])t!=null&&e.append(t)}function Vl(e,t={},n=[]){let r=document.createElement(e);return Bl(r,t,n),r}function Hl(e,t={},n=[]){let r=document.createElementNS(zl,e);return Bl(r,t,n),r}function Ul(e){return Vl(`p`,{class:`empty`,text:e})}function Wl(e,t=``){return`api/${e}${!t||t.startsWith(`/`)||t.startsWith(`?`)?t:`/${t}`}`}function Gl(e,t=``){return`#${e}${t?`/${t}`:``}`}async function Kl(e,t={}){let n=(t.method??`GET`).toUpperCase(),r=new Headers(t.headers),i=fe();n!==`GET`&&n!==`HEAD`&&i&&r.set(`X-Devtools-Csrf`,i);let a;try{a=await fetch(e,{...t,headers:r,credentials:`same-origin`})}catch{throw oe(),Object.assign(Error(`Could not reach the server. Check your connection and try again.`),{status:0})}if(te(a.status)?oe():se(),!a.ok&&a.status!==204){let t=a.statusText||`Request failed (${a.status})`,n=!1;try{let e=await a.json();t=e.error||t,n=e.code!==void 0}catch{}throw a.status===404&&!n&&window.dispatchEvent(new CustomEvent(D,{detail:{path:e}})),Object.assign(Error(t),{status:a.status})}return a.status===204?void 0:a.json()}function B(e){return e.split(`/`).filter(e=>e!==``).map(encodeURIComponent).join(`/`)}function V(e){return new URL(e,document.baseURI).href}function ql(e=``){return`api/share/panel${!e||e.startsWith(`?`)||e.startsWith(`/`)?e:`/${e}`}`}function Jl({id:e,root:t,route:n,refresh:r,shared:i=!1,share:a=null}){return{id:e,root:t,route:n,api:(t,n)=>Kl(i?ql(t):Wl(e,t),n),asset:t=>V(i?`api/share/assets/${encodeURIComponent(t)}`:`panels/${e}/${encodeURIComponent(t)}`),file:t=>V(i?`api/share/files/${B(t)}`:`panels/${e}/files/${B(t)}`),shared:i,share:i?null:a,href:t=>i?`#share${t?`/${t}`:``}`:Gl(e,t),navigate(t){let n=i?`#share${t?`/${t}`:``}`:Gl(e,t);location.hash===n?r():location.hash=n},refresh:r,el:Vl,svg:Hl,empty:Ul}}var Yl=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Xl=function(e,t){return new URL(e,t).href},Zl={},Ql=function(e){return e.pathname.endsWith(`.css`)},$l=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Xl(t,n);let r=s(t);if(r.href in Zl)return;Zl[r.href]=!0;let i=Ql(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:Yl,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},eu=(e,t=!1)=>$l(()=>import(new URL(t?`api/share/view.js`:`panels/${e}/view.js`,location.href).href),[],import.meta.url),tu=new Map;function nu(e,t=!1){let n=t?`share:${e}`:e,r=tu.get(n);return r||(r=t?eu(e,!0):eu(e),r.catch(()=>tu.delete(n)),tu.set(n,r)),r}function ru({id:e,title:t,route:n,shared:r=!1,share:i=null}){let a=(0,_.useRef)(null),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let o=!0,c=a.current;if(!c)return;l(null),d(!c.hasChildNodes());let u=()=>s(e=>e+1);return(async()=>{let a;try{a=await nu(e,r)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`The ${t} panel's view module did not load (${n}). Check the server log.`)}if(typeof a?.default!=`function`)throw Error(`The ${t} panel's view module has no default export function. Check the panel package.`);let s=document.createElement(`section`);s.className=`panel`,s.dataset.panel=e;let l=await a.default(Jl({id:e,root:s,route:n,refresh:u,shared:r,share:i}));o&&(c.replaceChildren(l instanceof Node?l:s),d(!1))})().catch(e=>{o&&(l(e instanceof Error?e.message:String(e)),d(!1))}),()=>{o=!1}},[e,t,n,o,r,i?.enabled,i?.manageHref]),(0,A.jsxs)(A.Fragment,{children:[c?(0,A.jsx)(z,{message:c,title:`The ${t} panel could not be shown`}):null,u&&!c?(0,A.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2.5 rounded-xl border bg-card px-4 py-6 text-sm text-muted-foreground`,children:[(0,A.jsx)(is,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}),`Loading `,t,`…`]}):null,(0,A.jsx)(`div`,{ref:a,"data-panel-host":e})]})}var iu=`This link has expired or was revoked. Ask the person who shared it for a new one.`;function au(){Rl();let[e]=(0,_.useState)(()=>Tl(location.hash)),[t,n]=(0,_.useState)({type:`loading`}),[r,i]=(0,_.useState)(()=>Ol(location.hash)),[a,o]=(0,_.useState)(0);(0,_.useEffect)(()=>{let t=!0,r=e.type===`share`?e.token:null;return(r!==null&&a===0?k(`api/share/open`,{method:`POST`,body:{token:r}}):k(`api/share/info`)).then(e=>{t&&(r!==null&&/^#\/share\/./.test(location.hash)&&history.replaceState(null,``,`${location.pathname}${location.search}#/share`),n({type:`ready`,info:e}))},e=>{t&&n(e instanceof E&&e.status===404?{type:`closed`}:{type:`failed`,error:e})}),()=>{t=!1}},[e,a]),(0,_.useEffect)(()=>{let e=()=>i(Ol(location.hash));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let s=(0,_.useCallback)(()=>{n({type:`loading`}),o(e=>e+1)},[]);if(t.type===`loading`)return(0,A.jsx)(`main`,{className:`mx-auto max-w-sm p-8`,children:(0,A.jsx)(Ks,{rows:3})});if(t.type===`closed`)return(0,A.jsx)(ec,{title:`This link is not available`,children:(0,A.jsx)(`p`,{className:`text-sm`,children:iu})});if(t.type===`failed`)return(0,A.jsxs)(ec,{title:`The page could not be opened`,children:[(0,A.jsx)(z,{error:t.error}),(0,A.jsx)(R,{onClick:s,children:`Try again`})]});let{info:c}=t;return(0,A.jsxs)(`div`,{className:`min-h-screen`,children:[(0,A.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-b bg-card px-4 py-3.5 sm:px-6`,children:[(0,A.jsx)(Js,{}),(0,A.jsx)(`h1`,{className:`text-base font-semibold`,children:c.title}),(0,A.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:c.label}),(0,A.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground`,"data-testid":`share-expiry`,children:[`Read-only link · expires `,new Date(c.expiresAt).toLocaleDateString()]})]}),(0,A.jsx)(`main`,{className:`mx-auto w-full max-w-[110rem] px-4 py-6 sm:px-8`,children:(0,A.jsx)(ru,{id:c.panel,title:c.title,route:r,shared:!0})})]})}function ou(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t} s`:`${Math.floor(t/60)} min ${t%60} s`}function su(){let e=le(),[t,n]=(0,_.useState)(()=>Date.now());if((0,_.useEffect)(()=>{if(e.phase!==`down`)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e.phase]),e.phase===`online`)return null;let r=e.phase===`down`;return(0,A.jsx)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`connection-banner`,className:`sticky top-0 z-50 flex flex-wrap items-center justify-center gap-x-3 px-4 py-1.5 text-center text-sm font-medium ${r?`bg-warning text-background`:`bg-success text-background`}`,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{children:`Reconnecting to the app…`}),(0,A.jsx)(`span`,{className:`tabular-nums opacity-90`,children:ou(Math.max(t,e.since)-e.since)})]}):(0,A.jsx)(`span`,{children:`Reconnected`})})}function H(e,t={}){let[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)({key:null,data:void 0,error:void 0}),o=(0,_.useCallback)(()=>r(e=>e+1),[]),{generation:s}=le(),c=e===null?null:`${e}#${n}#${s}`;return(0,_.useEffect)(()=>{if(c===null||e===null)return;let t=new AbortController;return k(e,{signal:t.signal}).then(e=>{t.signal.aborted||a({key:c,data:e,error:void 0})},e=>{if(t.signal.aborted)return;let n=e instanceof E?e:new E(String(e),0);te(n.status)&&re()||a(e=>({key:c,data:e.data,error:n}))}),()=>t.abort()},[c,e]),cu(o,e===null?null:t.refreshMs??null),{data:i.data,error:i.error,loading:c!==null&&i.key!==c,reload:o}}function cu(e,t){let n=(0,_.useRef)(e);(0,_.useEffect)(()=>{n.current=e},[e]),(0,_.useEffect)(()=>{if(t===null)return;let e=setInterval(()=>{(typeof document>`u`||document.visibilityState!==`hidden`)&&n.current()},t);return()=>clearInterval(e)},[t])}function lu(e,t){let n=(0,_.useRef)(t),r=e.join(`,`);(0,_.useEffect)(()=>{n.current=t},[t]),(0,_.useEffect)(()=>{if(typeof EventSource>`u`)return;let e=null,t=1e3,i,a=!1,o=()=>{let s=new EventSource(`api/stream`);e=s,s.addEventListener(`open`,()=>{t=1e3,se()}),s.addEventListener(`error`,()=>{s.close(),oe(),!a&&(i=setTimeout(o,t),t=Math.min(t*2,3e4))});for(let e of r.split(`,`))e&&s.addEventListener(e,t=>{try{n.current({type:e,data:JSON.parse(t.data)})}catch{}})};return o(),()=>{a=!0,i&&clearTimeout(i),e?.close()}},[r])}function U({title:e,hint:t,icon:n=Qo,className:r}){return(0,A.jsxs)(`div`,{className:F(`flex flex-col items-center rounded-xl border border-dashed bg-card/50 px-6 py-10 text-center`,r),children:[(0,A.jsx)(`span`,{className:`mb-3 grid size-10 place-items-center rounded-full bg-brand/10 text-brand`,children:(0,A.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),(0,A.jsx)(`p`,{className:`text-sm font-semibold`,children:e}),t?(0,A.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:t}):null]})}var uu=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}render(){if(this.state.error===null)return this.props.children;let e=this.state.error instanceof Error?` (${this.state.error.message})`:``;return(0,A.jsx)(z,{title:`The ${this.props.name} view could not be shown`,message:`It failed while drawing its data${e}. Open another tab, or reload the page; if it keeps failing, report it with the browser console output.`,onRetry:()=>this.setState({error:null})})}};function du({className:e,containerClassName:t,...n}){return(0,A.jsx)(`div`,{"data-slot":`table-container`,className:F(`relative max-h-[calc(100vh-14rem)] w-full overflow-auto rounded-lg border bg-card`,t),children:(0,A.jsx)(`table`,{"data-slot":`table`,className:F(`w-full caption-bottom text-sm tabular-nums`,e),...n})})}function fu({className:e,...t}){return(0,A.jsx)(`thead`,{"data-slot":`table-header`,className:F(`sticky top-0 z-10 bg-card shadow-[0_1px_0_var(--border)] [&_tr]:border-b`,e),...t})}function pu({className:e,...t}){return(0,A.jsx)(`tbody`,{"data-slot":`table-body`,className:F(`[&_tr:last-child]:border-0`,e),...t})}function W({className:e,...t}){return(0,A.jsx)(`tr`,{"data-slot":`table-row`,className:F(`border-b transition-colors hover:bg-muted/60 data-[state=selected]:bg-accent`,e),...t})}function G({className:e,...t}){return(0,A.jsx)(`th`,{"data-slot":`table-head`,className:F(`h-10 px-3 text-left align-middle text-xs font-semibold whitespace-nowrap text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function K({className:e,...t}){return(0,A.jsx)(`td`,{"data-slot":`table-cell`,className:F(`px-3 py-2.5 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function mu({...e}){return(0,A.jsx)(ei,{"data-slot":`dialog`,...e})}function hu({...e}){return(0,A.jsx)(ii,{"data-slot":`dialog-portal`,...e})}function gu({className:e,...t}){return(0,A.jsx)(oi,{"data-slot":`dialog-overlay`,className:F(`fixed inset-0 z-50 animate-dt-fade bg-black/50 backdrop-blur-[2px]`,e),...t})}function _u({className:e,children:t,showCloseButton:n=!0,...r}){return(0,A.jsxs)(hu,{"data-slot":`dialog-portal`,children:[(0,A.jsx)(gu,{}),(0,A.jsxs)(ui,{"data-slot":`dialog-content`,className:F(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-2xl outline-none sm:max-w-lg`,e),...r,children:[t,n&&(0,A.jsxs)(_i,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,A.jsx)(Rs,{}),(0,A.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function vu({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`dialog-header`,className:F(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function yu({className:e,showCloseButton:t=!1,children:n,...r}){return(0,A.jsxs)(`div`,{"data-slot":`dialog-footer`,className:F(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,A.jsx)(_i,{asChild:!0,children:(0,A.jsx)(R,{variant:`outline`,children:`Close`})})]})}function bu({className:e,...t}){return(0,A.jsx)(mi,{"data-slot":`dialog-title`,className:F(`text-lg leading-none font-semibold`,e),...t})}function xu({className:e,...t}){return(0,A.jsx)(hi,{"data-slot":`dialog-description`,className:F(`text-sm text-muted-foreground`,e),...t})}function Su({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=`Confirm`,destructive:a=!1,requireText:o,requirePassword:s=!1,onConfirm:c}){let[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(e);return e!==v&&(y(e),e&&(f(null),m(``),g(``))),(0,A.jsx)(mu,{open:e,onOpenChange:e=>l?void 0:t(e),children:(0,A.jsxs)(_u,{children:[(0,A.jsxs)(vu,{children:[(0,A.jsx)(bu,{children:n}),(0,A.jsx)(xu,{asChild:!0,children:(0,A.jsx)(`div`,{children:r})})]}),o?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsxs)(nc,{htmlFor:`confirm-text`,children:[`Type `,(0,A.jsx)(`code`,{className:`font-mono`,children:o}),` to continue`]}),(0,A.jsx)(tc,{id:`confirm-text`,value:p,autoComplete:`off`,onChange:e=>m(e.target.value)})]}):null,s?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`confirm-password`,children:`Current password`}),(0,A.jsx)(tc,{id:`confirm-password`,type:`password`,autoComplete:`current-password`,value:h,onChange:e=>g(e.target.value)})]}):null,(0,A.jsx)(z,{error:d}),(0,A.jsxs)(yu,{children:[(0,A.jsx)(R,{variant:`outline`,disabled:l,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsx)(R,{variant:a?`destructive`:`default`,disabled:l||o!==void 0&&p!==o||s&&h===``,onClick:async()=>{u(!0),f(null);try{await c({password:h}),t(!1)}catch(e){f(e)}finally{u(!1)}},children:l?`Working…`:i})]})]})})}function Cu(e,t=Date.now()){let n=t-e,r=Math.abs(n);return r<5e3?`just now`:(e=>n>=0?`${e} ago`:`in ${e}`)(r<6e4?`${Math.round(r/1e3)} s`:r<36e5?`${Math.round(r/6e4)} min`:r<864e5?`${Math.round(r/36e5)} h`:`${Math.round(r/864e5)} d`)}function wu({at:e,fallback:t=`never`,className:n}){let[r,i]=(0,_.useState)(()=>Date.now());return(0,_.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),3e4);return()=>clearInterval(e)},[]),e==null?(0,A.jsx)(`span`,{className:n,children:t}):(0,A.jsx)(`time`,{className:n,dateTime:new Date(e).toISOString(),title:new Date(e).toLocaleString(),children:Cu(e,r)})}function Tu(){let[e,t]=(0,_.useState)(!1);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Password`}),(0,A.jsx)(Qs,{children:`Changing it asks for the current one.`})]}),(0,A.jsxs)($s,{className:`grid max-w-sm gap-3`,children:[(0,A.jsx)(ic,{requireCurrent:!0,submitLabel:`Change password`,onSubmit:async({current:e,password:t})=>{let n=await k(`api/account/password`,{method:`POST`,body:{current:e,password:t}});n?.csrf&&de(n.csrf)},onDone:()=>t(!0)}),e?(0,A.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Password changed.`}):null]})]})}function Eu({account:e,reload:t}){let[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Authenticator app`}),(0,A.jsx)(Qs,{children:e.twoFactor.totp?`An authenticator app is set up.`:`No authenticator app yet.`})]}),(0,A.jsx)($s,{className:`grid max-w-md gap-3`,children:o?(0,A.jsx)(Oc,{codes:o,onDone:()=>{s(null),t()}}):e.twoFactor.totp?(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{variant:`outline`,onClick:()=>a(!0),children:`Remove the authenticator app`})}):n?(0,A.jsx)(bl,{base:`api/account`,onConfirmed:e=>{r(!1),e.recoveryCodes?.length?s(e.recoveryCodes):t()}}):(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{onClick:()=>r(!0),children:`Add an authenticator app`})})}),(0,A.jsx)(Su,{open:i,onOpenChange:a,title:`Remove the authenticator app?`,description:`You will no longer be asked for its code. If it is your only second factor, the server refuses and says what to add first.`,confirmLabel:`Remove`,destructive:!0,requirePassword:!0,onConfirm:async({password:e})=>{await k(`api/account/totp`,{method:`DELETE`,body:{current:e}}),t()}})]})}function Du({account:e,reload:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),o=e.twoFactor.passkeys;return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Passkeys`}),(0,A.jsx)(Qs,{children:`Sign in with a device key instead of a code.`})]}),(0,A.jsxs)($s,{className:`grid max-w-xl gap-3`,children:[o.length===0?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No passkeys yet.`}):(0,A.jsx)(`ul`,{className:`grid gap-2`,children:o.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,A.jsxs)(`span`,{children:[e.name,` `,(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· last used `,(0,A.jsx)(wu,{at:e.lastUsedAt})]})]}),(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>r(e.id),children:`Remove`})]},e.id))}),(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{onClick:()=>a(!0),children:`Add a passkey`})})]}),(0,A.jsx)(Su,{open:i,onOpenChange:a,title:`Add a passkey`,description:`Enter your current password, then follow your browser's passkey prompt.`,confirmLabel:`Continue`,requirePassword:!0,onConfirm:async({password:e})=>{await Tc(`api/account`,e),t()}}),(0,A.jsx)(Su,{open:n!==null,onOpenChange:e=>!e&&r(null),title:`Remove this passkey?`,description:`It will stop working for sign-in. If it is your only second factor, the server refuses and says what to add first.`,confirmLabel:`Remove`,destructive:!0,requirePassword:!0,onConfirm:async({password:e})=>{await k(`api/account/passkeys/${encodeURIComponent(n??``)}`,{method:`DELETE`,body:{current:e}}),t()}})]})}function Ou({account:e,reload:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(null),o=rc(async()=>{let e=await k(`api/account/recovery-codes`,{method:`POST`,body:{code:n.trim()}});r(``),a(e.codes)}),s=rc(async()=>{await Ec(`api/account`);let e=await k(`api/account/recovery-codes`,{method:`POST`,body:{}});a(e.codes)}),c=e.twoFactor.totp,l=e.twoFactor.passkeys.length>0;return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Recovery codes`}),(0,A.jsxs)(Qs,{children:[e.twoFactor.recoveryCodesLeft,` left. Making new ones replaces the old ones.`]})]}),(0,A.jsx)($s,{className:`grid max-w-md gap-3`,children:i?(0,A.jsx)(Oc,{codes:i,onDone:()=>{a(null),t()}}):(0,A.jsxs)(A.Fragment,{children:[c?(0,A.jsxs)(`form`,{className:`grid gap-3`,onSubmit:e=>{e.preventDefault(),o.run()},children:[(0,A.jsx)(nc,{htmlFor:`regen-code`,children:`Current code from your authenticator app`}),(0,A.jsx)(tc,{id:`regen-code`,inputMode:`numeric`,autoComplete:`one-time-code`,required:!0,value:n,onChange:e=>r(e.target.value)}),(0,A.jsx)(z,{error:o.error}),(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{type:`submit`,disabled:o.pending,children:o.pending?`Working…`:`Make new recovery codes`})})]}):null,l?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(z,{error:s.error}),(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{variant:c?`outline`:`default`,disabled:s.pending,onClick:()=>void s.run(),children:s.pending?`Waiting for the passkey…`:`Make new recovery codes with a passkey`})})]}):null,!c&&!l?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add an authenticator app or a passkey first; recovery codes come with it.`}):null]})})]})}function ku(){let e=H(`api/account/sessions`),[t,n]=(0,_.useState)(null);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Sessions`}),(0,A.jsx)(Qs,{children:`Where you are signed in. Revoke any you do not recognise.`})]}),(0,A.jsxs)($s,{children:[e.error&&!e.data?(0,A.jsx)(z,{error:e.error}):null,!e.data&&!e.error?(0,A.jsx)(Ks,{rows:2}):null,e.data?(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`Browser`}),(0,A.jsx)(G,{children:`IP`}),(0,A.jsx)(G,{children:`Last active`}),(0,A.jsx)(G,{})]})}),(0,A.jsx)(pu,{children:e.data.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{className:`max-w-64 truncate`,title:e.userAgent??void 0,children:[e.userAgent??`Unknown`,` `,e.current?(0,A.jsx)(qa,{children:`This session`}):null]}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.ip??`—`}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:e.lastSeenAt})}),(0,A.jsx)(K,{className:`text-right`,children:e.current?null:(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>n(e),children:`Revoke`})})]},e.id))})]}):null]}),(0,A.jsx)(Su,{open:t!==null,onOpenChange:e=>!e&&n(null),title:`Revoke this session?`,description:`That browser is signed out at once.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:async()=>{await k(`api/account/sessions/${t?.id??``}`,{method:`DELETE`}),e.reload()}})]})}function Au(){let e=H(`api/account`);return e.error&&!e.data?(0,A.jsx)(z,{error:e.error}):e.data?(0,A.jsxs)(`div`,{className:`mx-auto grid max-w-3xl gap-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Account`}),(0,A.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[e.data.email,` `,(0,A.jsx)(qa,{variant:`brand`,children:e.data.role})]})]}),(0,A.jsx)(Tu,{}),(0,A.jsx)(Eu,{account:e.data,reload:e.reload}),(0,A.jsx)(Du,{account:e.data,reload:e.reload}),(0,A.jsx)(Ou,{account:e.data,reload:e.reload}),(0,A.jsx)(ku,{})]}):(0,A.jsx)(Ks,{})}var ju=(0,_.createContext)(null);function Mu(){let e=(0,_.useContext)(ju);if(!e)throw Error(`useSession was called outside the dashboard shell.`);return e}var Nu=50,Pu=`admin.seeded,admin.reset,setup.completed,login.succeeded,login.failed,login.blocked,mfa.succeeded,mfa.failed,mfa.enrolled,mfa.removed,recovery-code.used,recovery-codes.regenerated,passkey.added,passkey.removed,password.changed,logout,session.revoked,invite.created,invite.revoked,invite.accepted,account.role-changed,account.removed,account.mfa-reset,account.signed-out,dashboard.disabled,dashboard.enabled,dashboard.locked,explain.run,requests.cleared,panel.action`.split(`,`),Fu=new Set([`login.failed`,`mfa.failed`,`login.blocked`,`dashboard.locked`]);function Iu(e,t,n){let r=new URLSearchParams({limit:String(Nu)});return e&&r.set(`type`,e),t&&r.set(`account`,t),n!==void 0&&r.set(`before`,String(n)),`api/admin/audit?${r.toString()}`}function Lu(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1),f=H(`api/admin/users`),p=(e,t)=>{e(t),a(null),l(null)};(0,_.useEffect)(()=>{let t=!0;return k(Iu(e,n)).then(e=>{t&&(a(e),s(e.length>=Nu))},e=>{t&&l(e)}),()=>{t=!1}},[e,n]);let m=(0,_.useCallback)(async()=>{let t=i?.at(-1);if(t){d(!0),l(null);try{let r=await k(Iu(e,n,t.at));a(e=>{let t=new Set((e??[]).map(e=>e.id));return[...e??[],...r.filter(e=>!t.has(e.id))]}),s(r.length>=Nu)}catch(e){l(e)}finally{d(!1)}}},[i,e,n]);return(0,A.jsxs)(`div`,{className:`grid gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,A.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Event type`,(0,A.jsxs)(`select`,{className:`h-9 rounded-lg border border-input bg-card px-2.5 shadow-xs focus-visible:ring-[3px] focus-visible:ring-ring/50 max-md:h-10`,value:e,onChange:e=>p(t,e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`All events`}),Pu.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]})]}),(0,A.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Account`,(0,A.jsxs)(`select`,{className:`h-9 rounded-lg border border-input bg-card px-2.5 shadow-xs focus-visible:ring-[3px] focus-visible:ring-ring/50 max-md:h-10`,value:n,onChange:e=>p(r,e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`All accounts`}),f.data?.accounts.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.email},e.id))]})]})]}),(0,A.jsx)(z,{error:c}),!i&&!c?(0,A.jsx)(Ks,{}):null,i&&i.length===0?(0,A.jsx)(U,{title:`No audit entries match.`,hint:`Clear a filter to see more.`}):null,i&&i.length>0?(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`When`}),(0,A.jsx)(G,{children:`Event`}),(0,A.jsx)(G,{children:`Account`}),(0,A.jsx)(G,{children:`IP`}),(0,A.jsx)(G,{children:`Detail`}),(0,A.jsx)(G,{children:`Ref`})]})}),(0,A.jsx)(pu,{children:i.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`whitespace-nowrap`,children:new Date(e.at).toLocaleString()}),(0,A.jsx)(K,{children:(0,A.jsx)(qa,{variant:Fu.has(e.type)?`destructive`:`secondary`,children:e.type})}),(0,A.jsx)(K,{children:e.email??`—`}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.ip??`—`}),(0,A.jsx)(K,{className:`max-w-64 truncate font-mono text-xs`,children:Object.entries(e.detail).map(([e,t])=>`${e}=${String(t)}`).join(` `)}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.ref})]},e.id))})]}):null,i&&o?(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{variant:`outline`,disabled:u,onClick:()=>void m(),children:u?`Loading…`:`Load older`})}):null]})}function Ru(){let{markDisabled:e}=Mu(),[t,n]=(0,_.useState)(!1);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Disable the dashboard`}),(0,A.jsx)(Qs,{children:`Closes the dashboard on every instance within seconds. It stays closed after a restart.`})]}),(0,A.jsx)($s,{children:(0,A.jsx)(R,{variant:`destructive`,onClick:()=>n(!0),children:`Disable the dashboard`})}),(0,A.jsx)(Su,{open:t,onOpenChange:n,title:`Disable the dashboard?`,description:(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`p`,{children:[`Every instance answers as if the page did not exist, and every session ends. Only someone with shell access can open it again: run `,(0,A.jsx)(`code`,{children:`warlock devtools:enable`}),`, or deploy with a new `,(0,A.jsx)(`code`,{children:`DEVTOOLS_PATH`}),`.`]})}),confirmLabel:`Disable the dashboard`,destructive:!0,requireText:`disable`,onConfirm:async()=>{await k(`api/admin/disable`,{method:`POST`,body:{confirm:`disable`}}),e()}})]})}var zu=80;function Bu({list:e,open:t,onOpenChange:n,onCreated:r}){let i=kl(location.hash),[a,o]=(0,_.useState)(e.panels.find(e=>e.id===i)?.id??e.panels[0]?.id??``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(String(Math.min(7,e.maxDays))),d=rc(async()=>{let e=await k(`api/admin/shares`,{method:`POST`,body:{panel:a,label:s.trim(),days:Number(l)}});c(``),r(e),n(!1)});return(0,A.jsx)(mu,{open:t,onOpenChange:n,children:(0,A.jsxs)(_u,{children:[(0,A.jsxs)(vu,{children:[(0,A.jsx)(bu,{children:`Create a share link`}),(0,A.jsx)(xu,{children:`Anyone with the link can read the shared view of the panel until the link expires or you revoke it. They need no account and cannot change anything.`})]}),(0,A.jsxs)(`form`,{className:`grid gap-3`,onSubmit:e=>{e.preventDefault(),d.run()},children:[(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`share-panel`,children:`Panel`}),(0,A.jsx)(`select`,{id:`share-panel`,className:`h-9 rounded-md border bg-background px-2 text-sm`,value:a,onChange:e=>o(e.target.value),children:e.panels.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`share-label`,children:`Label`}),(0,A.jsx)(tc,{id:`share-label`,required:!0,maxLength:zu,placeholder:`Who or what is this link for?`,value:s,onChange:e=>c(e.target.value)})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsxs)(nc,{htmlFor:`share-days`,children:[`Days until it expires (1 to `,e.maxDays,`)`]}),(0,A.jsx)(tc,{id:`share-days`,type:`number`,required:!0,min:1,max:e.maxDays,step:1,value:l,onChange:e=>u(e.target.value)})]}),(0,A.jsx)(z,{error:d.error}),(0,A.jsxs)(yu,{children:[(0,A.jsx)(R,{type:`button`,variant:`ghost`,onClick:()=>n(!1),children:`Cancel`}),(0,A.jsx)(R,{type:`submit`,disabled:d.pending||e.panels.length===0,children:d.pending?`Creating…`:`Create link`})]})]})]})})}function Vu(e){return(0,A.jsx)(qa,{variant:e.status===`active`?`default`:`outline`,children:e.status})}function Hu(){let e=H(`api/admin/shares`),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),l=e.data,u=e=>l?.panels.find(t=>t.id===e)?.title??e,d=l?.shares.filter(e=>e.status===`active`).length??0;return(0,A.jsxs)(`div`,{className:`grid gap-4`,children:[(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Share links`}),(0,A.jsx)(Qs,{children:`A read-only link opens one panel's shared view without an account. The link is shown once, expires on its own and can be revoked at any time.`})]}),(0,A.jsxs)($s,{className:`flex flex-wrap gap-2`,children:[(0,A.jsx)(R,{onClick:()=>n(!0),disabled:!l||l.panels.length===0,children:`Create a link`}),(0,A.jsx)(R,{variant:`outline`,disabled:d===0,onClick:()=>c(!0),children:`Revoke all links`})]})]}),r?(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsxs)(Zs,{children:[`Link for `,r.share.label]}),(0,A.jsx)(Qs,{children:`This link is shown only now. Copy it and hand it over; it cannot be shown again.`})]}),(0,A.jsxs)($s,{className:`grid gap-2`,children:[(0,A.jsx)(`code`,{className:`font-mono text-xs break-all`,"data-testid":`share-link`,children:r.url}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(Dc,{value:r.url,label:`Copy link`}),(0,A.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>i(null),children:`Hide`})]})]})]}):null,e.error&&!l?(0,A.jsx)(z,{error:e.error,onRetry:e.reload}):null,!l&&!e.error?(0,A.jsx)(Ks,{}):null,l&&l.panels.length===0?(0,A.jsx)(U,{title:`No panel can be shared.`,hint:`A panel needs a shared view (share) before it can have links. Add a panel that declares one, such as the Grimoire panel.`}):null,l&&l.shares.length===0&&l.panels.length>0?(0,A.jsx)(U,{title:`No links yet.`,hint:`Create a link to share a panel read-only.`}):null,l&&l.shares.length>0?(0,A.jsx)(Ys,{children:(0,A.jsx)($s,{children:(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`Label`}),(0,A.jsx)(G,{children:`Panel`}),(0,A.jsx)(G,{children:`Status`}),(0,A.jsx)(G,{children:`Expires`}),(0,A.jsx)(G,{children:`Last used`}),(0,A.jsx)(G,{children:`Uses`}),(0,A.jsx)(G,{})]})}),(0,A.jsx)(pu,{children:l.shares.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{children:[e.label,e.createdBy?(0,A.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`by `,e.createdBy]}):null]}),(0,A.jsx)(K,{children:u(e.panel)}),(0,A.jsx)(K,{children:Vu(e)}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:e.expiresAt})}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:e.lastUsedAt})}),(0,A.jsx)(K,{children:e.uses}),(0,A.jsx)(K,{className:`text-right`,children:e.status===`active`?(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>o(e),children:`Revoke`}):null})]},e.id))})]})})}):null,l&&t?(0,A.jsx)(Bu,{list:l,open:!0,onOpenChange:n,onCreated:t=>{i(t),e.reload()}}):null,a?(0,A.jsx)(Su,{open:!0,onOpenChange:e=>!e&&o(null),title:`Revoke the link "${a.label}"?`,description:`The link stops working within a few seconds, on every instance.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:async()=>{await k(`api/admin/shares/${a.id}`,{method:`DELETE`}),e.reload()}}):null,s?(0,A.jsx)(Su,{open:!0,onOpenChange:e=>!e&&c(!1),title:`Revoke every share link?`,description:`All ${d} active links stop working within a few seconds. This cannot be undone.`,confirmLabel:`Revoke all`,destructive:!0,requireText:`revoke all`,onConfirm:async()=>{await k(`api/admin/shares/revoke-all`,{method:`POST`}),e.reload()}}):null]})}function Uu(e){return`${location.origin}${location.pathname}#/invite/${e}`}function Wu({onCreated:e}){let[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(`viewer`),[a,o]=(0,_.useState)(null),s=rc(async()=>{let i=await k(`api/admin/invites`,{method:`POST`,body:{email:t.trim(),role:r}});o(i),n(``),e()});return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Invite someone`}),(0,A.jsx)(Qs,{children:`You get a link to hand over. It works once and expires in 24 hours. No email is sent.`})]}),(0,A.jsxs)($s,{className:`grid gap-3`,children:[(0,A.jsxs)(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:e=>{e.preventDefault(),s.run()},children:[(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`invite-email`,children:`Email`}),(0,A.jsx)(tc,{id:`invite-email`,type:`email`,required:!0,value:t,onChange:e=>n(e.target.value)})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`invite-role`,children:`Role`}),(0,A.jsxs)(`select`,{id:`invite-role`,className:`h-9 rounded-md border bg-background px-2 text-sm`,value:r,onChange:e=>i(e.target.value),children:[(0,A.jsx)(`option`,{value:`viewer`,children:`Viewer`}),(0,A.jsx)(`option`,{value:`admin`,children:`Admin`})]})]}),(0,A.jsx)(R,{type:`submit`,disabled:s.pending,children:s.pending?`Creating…`:`Create invite`})]}),(0,A.jsx)(z,{error:s.error}),a?(0,A.jsxs)(`div`,{className:`grid gap-2 rounded-md border bg-muted p-3 text-sm`,children:[(0,A.jsxs)(`p`,{children:[`Invite for `,(0,A.jsx)(`strong`,{children:a.invite.email}),` (expires`,` `,(0,A.jsx)(wu,{at:a.invite.expiresAt}),`). This link is shown only now:`]}),(0,A.jsx)(`code`,{className:`font-mono text-xs break-all`,"data-testid":`invite-link`,children:Uu(a.token)}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(Dc,{value:Uu(a.token),label:`Copy link`}),(0,A.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>o(null),children:`Hide`})]})]}):null]})]})}function Gu(e){switch(e.type){case`role`:return{title:`Make ${e.account.email} ${e.role===`admin`?`an admin`:`a viewer`}?`,description:e.role===`admin`?`Admins manage users and can turn the dashboard off. They are asked to add a second factor at the next sign-in.`:`They lose access to user management and settings.`,label:`Change role`};case`remove`:return{title:`Remove ${e.account.email}?`,description:`The account and its sessions are deleted. This cannot be undone.`,label:`Remove`};case`reset-mfa`:return{title:`Reset the second factor of ${e.account.email}?`,description:`Their authenticator app, passkeys and recovery codes are removed. They add new ones at the next sign-in.`,label:`Reset`};case`sign-out`:return{title:`Sign ${e.account.email} out everywhere?`,description:`Every browser session of this account ends at once.`,label:`Sign out`};case`revoke`:return{title:`Revoke the invite for ${e.invite.email}?`,description:`The link stops working.`,label:`Revoke`}}}function Ku(){let{session:e}=Mu(),t=H(`api/admin/users`),[n,r]=(0,_.useState)(null),i=async()=>{if(n){switch(n.type){case`role`:await k(`api/admin/users/${n.account.id}`,{method:`PATCH`,body:{role:n.role}});break;case`remove`:await k(`api/admin/users/${n.account.id}`,{method:`DELETE`});break;case`reset-mfa`:await k(`api/admin/users/${n.account.id}/reset-mfa`,{method:`POST`});break;case`sign-out`:await k(`api/admin/users/${n.account.id}/sign-out`,{method:`POST`});break;case`revoke`:await k(`api/admin/invites/${n.invite.id}`,{method:`DELETE`})}t.reload()}},a=n?Gu(n):null;return(0,A.jsxs)(`div`,{className:`grid gap-4`,children:[(0,A.jsx)(Wu,{onCreated:t.reload}),t.error&&!t.data?(0,A.jsx)(z,{error:t.error}):null,!t.data&&!t.error?(0,A.jsx)(Ks,{}):null,t.data?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsx)(Zs,{children:`Accounts`})}),(0,A.jsx)($s,{children:(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`Email`}),(0,A.jsx)(G,{children:`Role`}),(0,A.jsx)(G,{children:`Second factor`}),(0,A.jsx)(G,{children:`Last sign-in`}),(0,A.jsx)(G,{})]})}),(0,A.jsx)(pu,{children:t.data.accounts.map(t=>{let n=t.id===e.account?.id;return(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{children:[t.email,` `,n?(0,A.jsx)(qa,{variant:`outline`,children:`You`}):null]}),(0,A.jsx)(K,{children:t.role}),(0,A.jsx)(K,{children:t.twoFactor.totp||t.twoFactor.passkeys.length>0?`On`:`Off`}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:t.lastLoginAt})}),(0,A.jsx)(K,{className:`flex flex-wrap justify-end gap-1`,children:n?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`role`,account:t,role:t.role===`admin`?`viewer`:`admin`}),children:t.role===`admin`?`Make viewer`:`Make admin`}),(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`reset-mfa`,account:t}),children:`Reset second factor`}),(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`sign-out`,account:t}),children:`Sign out everywhere`}),(0,A.jsx)(R,{size:`xs`,variant:`destructive`,onClick:()=>r({type:`remove`,account:t}),children:`Remove`})]})})]},t.id)})})]})})]}),(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsx)(Zs,{children:`Pending invites`})}),(0,A.jsx)($s,{children:t.data.invites.filter(e=>e.usedAt===null).length===0?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No pending invites.`}):(0,A.jsx)(du,{children:(0,A.jsx)(pu,{children:t.data.invites.filter(e=>e.usedAt===null).map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{children:e.email}),(0,A.jsx)(K,{children:e.role}),(0,A.jsxs)(K,{children:[`expires `,(0,A.jsx)(wu,{at:e.expiresAt})]}),(0,A.jsx)(K,{className:`text-right`,children:(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`revoke`,invite:e}),children:`Revoke`})})]},e.id))})})})]})]}):null,a?(0,A.jsx)(Su,{open:!0,onOpenChange:e=>!e&&r(null),title:a.title,description:a.description,confirmLabel:a.label,destructive:n?.type===`remove`,onConfirm:i}):null]})}var qu=[{id:`users`,label:`Users and invites`},{id:`audit`,label:`Audit log`},{id:`settings`,label:`Settings`},{id:`shares`,label:`Share links`}];function Ju({page:e}){let{session:t}=Mu();return t.role!==`admin`||t.mode!==`production`?(0,A.jsx)(U,{title:`This page is for admins.`,hint:`Ask an admin of this dashboard to change your role, or sign in with an admin account.`}):(0,A.jsxs)(`div`,{className:`mx-auto grid max-w-6xl gap-5`,children:[(0,A.jsx)(`nav`,{"aria-label":`Admin pages`,className:`flex gap-1 overflow-x-auto rounded-lg border bg-card p-1 text-sm`,children:qu.filter(e=>e.id!==`shares`||t.share?.enabled).map(t=>(0,A.jsx)(`a`,{href:`#/admin/${t.id}`,"aria-current":t.id===e?`page`:void 0,className:F(`flex min-h-8 items-center rounded-md px-3 whitespace-nowrap transition-colors max-md:min-h-10`,t.id===e?`bg-brand/10 font-semibold text-brand`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`),children:t.label},t.id))}),e===`users`?(0,A.jsx)(Ku,{}):e===`audit`?(0,A.jsx)(Lu,{}):e===`shares`&&t.share?.enabled?(0,A.jsx)(Hu,{}):(0,A.jsx)(Ru,{})]})}function q(e){return e==null||Number.isNaN(e)?`—`:e.toLocaleString(`en-US`)}function J(e){return e==null||Number.isNaN(e)?`—`:e>=1e4?`${(e/1e3).toFixed(1)} s`:e>=1e3?`${(e/1e3).toFixed(2)} s`:e>=100?`${Math.round(e)} ms`:e>=10?`${e.toFixed(1)} ms`:`${e.toFixed(e<1?2:1)} ms`}function Yu(e){if(e==null||Number.isNaN(e))return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${r===0?n:n.toFixed(n>=100?0:1)} ${t[r]}`}function Xu(e,t=1){return e==null||Number.isNaN(e)?`—`:`${e.toFixed(t)} %`}function Zu(e){return e==null?`unpriced`:`$${e.toFixed(6)} USD`}function Qu(e){return e<60?`${Math.round(e)} s`:e<3600?`${Math.floor(e/60)} min`:e<86400?`${(e/3600).toFixed(1)} h`:`${(e/86400).toFixed(1)} d`}function $u(e,t=Date.now()){let n=Math.round((t-e)/1e3),r=Math.abs(n),i=r<5?`just now`:Qu(r);return r<5?i:n>=0?`${i} ago`:`in ${i}`}function ed({at:e,className:t}){return e==null?(0,A.jsx)(`span`,{className:t,children:`—`}):(0,A.jsx)(`time`,{dateTime:new Date(e).toISOString(),title:new Date(e).toLocaleString(),className:t,children:$u(e)})}function td(e){return e==null?`—`:new Date(e).toLocaleTimeString()}function nd({children:e}){return(0,A.jsx)(`h3`,{className:`mt-6 mb-2 text-sm font-semibold text-foreground`,children:e})}function rd({children:e,className:t}){return(0,A.jsx)(`pre`,{className:F(`max-h-80 overflow-auto rounded-lg border bg-muted p-3 font-mono text-xs leading-relaxed break-words whitespace-pre-wrap`,t),children:e})}function id({value:e}){return(0,A.jsx)(rd,{children:JSON.stringify(e,null,2)??`undefined`})}var ad=`h-8 rounded-lg border border-input bg-card px-2.5 text-sm shadow-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 max-md:h-10`;function od({className:e,...t}){return(0,A.jsx)(`input`,{className:F(ad,e),...t})}function sd({className:e,...t}){return(0,A.jsx)(`select`,{className:F(ad,e),...t})}function cd({active:e,children:t,...n}){return(0,A.jsx)(R,{type:`button`,size:`sm`,variant:e?`brand`:`outline`,"aria-pressed":e,...n,children:t})}function ld({selected:e,className:t,...n}){return(0,A.jsx)(`button`,{type:`button`,"aria-current":e?`true`:void 0,className:F(`block w-full rounded-lg border bg-card p-2.5 text-left text-sm transition-colors hover:bg-muted/60 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,e&&`border-brand bg-brand/10`,t),...n})}function ud(e,t){return e?t?.find(t=>t.id===e)?.label??e:`—`}function dd(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){if(r==null)continue;let e=String(r).trim();e&&t.set(n,e)}let n=t.toString();return n?`?${n}`:``}var fd={success:`border-success/25 bg-success/10 text-success`,warning:`border-warning/30 bg-warning/10 text-warning`,info:`border-info/25 bg-info/10 text-info`,destructive:`border-destructive/25 bg-destructive/10 text-destructive`,brand:`border-brand/25 bg-brand/10 text-brand`,neutral:`border-border bg-muted text-muted-foreground`},pd={success:`text-success`,warning:`text-warning`,info:`text-info`,destructive:`text-destructive`,brand:`text-brand`,neutral:`text-foreground`};function Y({tone:e=`neutral`,mono:t,className:n,children:r,...i}){return(0,A.jsx)(`span`,{className:F(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs leading-none font-medium whitespace-nowrap`,t&&`font-mono tabular-nums`,fd[e],n),...i,children:r})}function md(e){return e==null?`neutral`:e>=500?`destructive`:e>=400?`warning`:e>=300?`info`:`success`}function hd({status:e}){return(0,A.jsx)(Y,{tone:md(e),mono:!0,children:e??`—`})}var gd={GET:`info`,POST:`success`,PUT:`warning`,PATCH:`warning`,DELETE:`destructive`};function _d({method:e}){let t=e.toUpperCase();return(0,A.jsx)(Y,{tone:gd[t]??`neutral`,mono:!0,className:`min-w-14 justify-center`,children:t})}function vd(e){switch(e){case`error`:return`destructive`;case`warn`:return`warning`;case`success`:return`success`;case`debug`:return`neutral`;default:return`info`}}function yd({level:e}){return(0,A.jsx)(Y,{tone:vd(e),className:`min-w-14 justify-center`,children:e})}function bd({title:e,description:t,children:n}){return(0,A.jsxs)(`header`,{className:`mb-4 flex flex-wrap items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:e}),t?(0,A.jsx)(`p`,{className:`mt-0.5 max-w-prose text-sm text-muted-foreground`,children:t}):null]}),n?(0,A.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n}):null]})}function xd({items:e,label:t=`Summary`}){return(0,A.jsx)(`dl`,{"aria-label":t,className:`mb-4 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-[repeat(auto-fit,minmax(10rem,1fr))]`,children:e.map(e=>(0,A.jsxs)(`div`,{className:`min-w-0 rounded-xl border bg-card px-3.5 py-3`,children:[(0,A.jsx)(`dt`,{className:`truncate text-xs text-muted-foreground`,children:e.label}),(0,A.jsx)(`dd`,{className:F(`mt-1 truncate text-2xl font-semibold tracking-tight tabular-nums`,pd[e.tone??`neutral`]),children:e.value}),e.hint?(0,A.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:e.hint}):null]},e.label))})}function X({label:e,onSubmit:t,children:n,trailing:r}){return(0,A.jsxs)(`form`,{"aria-label":e,onSubmit:e=>{e.preventDefault(),t?.(e)},className:`mb-3 flex flex-wrap items-center gap-2 rounded-xl border bg-card p-2`,children:[n,r?(0,A.jsx)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2 pl-2`,children:r}):null]})}function Sd({label:e,className:t,...n}){return(0,A.jsxs)(`div`,{className:F(`relative min-w-48 flex-1`,t),children:[(0,A.jsx)(ws,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(od,{type:`search`,"aria-label":e,className:`w-full pl-8`,...n})]})}function Cd({label:e,options:t,value:n,onChange:r}){return(0,A.jsx)(`div`,{role:`group`,"aria-label":e,className:`inline-flex rounded-md border bg-muted/50 p-0.5`,children:t.map(e=>{let t=e.value===n;return(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>r(e.value),className:F(`inline-flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium whitespace-nowrap transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,t?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`),children:[e.label,e.count===void 0?null:(0,A.jsx)(`span`,{className:`text-[11px] tabular-nums opacity-70`,children:e.count})]},e.value)})})}function wd({shown:e,total:t,noun:n}){let r=e=>e===1?n:/[^aeiou]y$/.test(n)?`${n.slice(0,-1)}ies`:`${n}s`;return(0,A.jsx)(`span`,{role:`status`,className:`text-xs whitespace-nowrap text-muted-foreground tabular-nums`,children:t!==void 0&&t!==e?`${e} of ${t} ${r(t)}`:`${e} ${r(e)}`})}function Td({onClick:e}){return(0,A.jsxs)(R,{type:`button`,size:`xs`,variant:`ghost`,onClick:e,children:[(0,A.jsx)(Rs,{}),`Clear filters`]})}function Ed({label:e,className:t,children:n}){return(0,A.jsx)(`div`,{className:F(`overflow-hidden rounded-xl border bg-card`,t),children:(0,A.jsx)(du,{"aria-label":e,children:n})})}var Z=`h-9 bg-muted/40 text-xs font-medium text-muted-foreground`,Q=`text-right tabular-nums`;function Dd(e){return{tabIndex:0,className:`cursor-pointer focus-visible:bg-muted/60 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-ring/50`,onClick:e,onKeyDown:t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())}}}function Od({ms:e,max:t,text:n,tone:r=`bg-brand`}){let i=e&&t>0?Math.max(3,Math.min(100,e/t*100)):0;return(0,A.jsxs)(`div`,{className:`ml-auto flex w-24 flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`tabular-nums`,children:n}),(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,A.jsx)(`span`,{className:F(`block h-full rounded-full`,r),style:{width:`${i}%`}})})]})}function kd(e,t){if(!e.length)return null;let n=[...e].sort((e,t)=>e-t);return n[Math.max(0,Math.min(n.length-1,Math.ceil(t/100*n.length)-1))]??null}function Ad({title:e,actions:t,children:n,className:r}){return(0,A.jsxs)(`section`,{className:F(`rounded-xl border bg-card`,r),children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3.5 py-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t]}),(0,A.jsx)(`div`,{className:`space-y-2 p-3.5`,children:n})]})}function jd({items:e}){return(0,A.jsx)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2.5 text-sm sm:grid-cols-3`,children:e.map(e=>(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,A.jsx)(`dd`,{className:`mt-0.5 break-words tabular-nums`,children:e.value})]},e.label))})}function Md({children:e,value:t,className:n}){return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`pre`,{className:F(`max-h-80 overflow-auto rounded-lg border bg-muted/50 p-3 pr-20 font-mono text-xs leading-relaxed break-words whitespace-pre-wrap`,n),children:e}),(0,A.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,A.jsx)(Dc,{value:t??e,size:`xs`,variant:`ghost`})})]})}function $({onClick:e,children:t=`Back to the list`}){return(0,A.jsxs)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`-ml-2 mb-2`,onClick:e,children:[(0,A.jsx)(uo,{}),t]})}function Nd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pd({value:e,label:t,depth:n=0}){if(Array.isArray(e)||Nd(e)){let r=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e),i=Nd(e)&&typeof e[`Node Type`]==`string`?e[`Node Type`]:null;return(0,A.jsxs)(`details`,{open:n<3,className:`ml-3 text-xs`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer font-mono`,children:[t?`${t}: `:``,i??(Array.isArray(e)?`[${r.length}]`:`{${r.length}}`)]}),r.map(([e,t])=>(0,A.jsx)(Pd,{value:t,label:e,depth:n+1},e))]})}return(0,A.jsxs)(`div`,{className:`ml-6 font-mono text-xs break-words`,children:[t?(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[t,`: `]}):null,JSON.stringify(e)]})}function Fd({run:e}){let[t,n]=(0,_.useState)({type:`idle`});return(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(R,{size:`xs`,variant:`outline`,disabled:t.type===`running`,onClick:async()=>{n({type:`running`});try{n({type:`done`,outcome:await e()})}catch(e){n({type:`failed`,error:e})}},children:t.type===`running`?`Running EXPLAIN…`:`Explain`}),t.type===`running`?(0,A.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Asking the database for the plan.`}):null,t.type===`failed`?(0,A.jsx)(z,{error:t.error,title:`EXPLAIN failed`}):null,t.type===`done`?(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t.outcome.executing?`Executing plan: the database ran this query to measure it.`:`Plan only: the query was not run.`,t.outcome.instance?` Planned on ${t.outcome.instance}.`:``]}),(0,A.jsx)(`div`,{className:`max-h-96 overflow-auto rounded-md bg-muted p-2`,children:(0,A.jsx)(Pd,{value:t.outcome.plan})}),(0,A.jsxs)(`details`,{className:`text-xs`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer`,children:`Raw JSON`}),(0,A.jsx)(rd,{children:JSON.stringify(t.outcome.plan,null,2)})]})]}):null]})}var Id=e=>JSON.stringify(e,null,2)??`undefined`;function Ld({record:e}){let t={headers:e.headers,params:e.params,query:e.query,body:e.body,session:e.session,ip:e.ip},n=e.error?[e.error.phase,e.error.file,e.error.site].filter(Boolean).join(` · `):``;return(0,A.jsxs)(A.Fragment,{children:[e.error?(0,A.jsxs)(Ad,{title:`Error`,children:[(0,A.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-2.5 text-sm`,children:[(0,A.jsxs)(`div`,{children:[e.error.name,`: `,e.error.message]}),n?(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n}):null]}),e.error.stack?(0,A.jsx)(Md,{children:e.error.stack}):null]}):null,(0,A.jsx)(Ad,{title:`Request (redacted)`,children:(0,A.jsx)(Md,{children:Id(t)})}),(0,A.jsx)(Ad,{title:`Response`,children:(0,A.jsx)(Md,{children:Id({status:e.status,...e.response})})}),e.queries?.nPlusOne?.length?(0,A.jsx)(Ad,{title:`Queries (${e.queries.count})`,children:(0,A.jsx)(Md,{children:Id(e.queries)})}):null]})}function Rd(e){return e.sql||e.shape||`${e.collection||`collection`}.${e.command||`command`}\n${JSON.stringify(e.pipeline??{},null,2)}`}function zd(e){return e.driver===`postgres`&&/^(select|with)\b/i.test((e.sql||``).trim())}var Bd={phase:`var(--chart-3)`,query:`var(--chart-1)`,cache:`var(--chart-2)`};function Vd({request:e}){let t=[...e.phases.map(e=>({label:e.name,at:e.startedAt,duration:e.durationMs,kind:`phase`})),...e.queries.map(e=>({label:Rd(e).replace(/\s+/g,` `).slice(0,90),at:e.startedAt,duration:e.durationMs,kind:`query`})),...Array.isArray(e.cache)?e.cache.map(e=>({label:`${e.type} ${e.key||e.keys?.join(`, `)||``}`.trim(),at:e.at,duration:e.durationMs||0,kind:`cache`})):[]];if(!t.length)return(0,A.jsx)(U,{title:`No timed work recorded for this request.`});let n=Math.max(e.durationMs||0,1);return(0,A.jsxs)(`div`,{className:`space-y-1.5`,"aria-label":`Waterfall`,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[[`phase`,`query`,`cache`].map(e=>(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-sm`,style:{background:Bd[e]}}),e===`phase`?`Phases`:e===`query`?`Queries`:`Cache`]},e)),(0,A.jsxs)(`span`,{className:`ml-auto tabular-nums`,children:[`0 to `,J(n)]})]}),t.map((t,r)=>{let i=Math.max(0,Math.min(100,(t.at-e.startedAt)/n*100)),a=Math.max(.5,Math.min(100-i,t.duration/n*100));return(0,A.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,14rem)_1fr_4.5rem] items-center gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`truncate font-mono`,title:t.label,children:t.label}),(0,A.jsx)(`span`,{className:`relative h-3 rounded-sm bg-muted/70`,children:(0,A.jsx)(`span`,{className:`absolute inset-y-0 rounded-sm`,style:{left:`${i}%`,width:`${a}%`,background:Bd[t.kind]}})}),(0,A.jsx)(`span`,{className:`text-right tabular-nums`,children:J(t.duration)})]},r)})]})}function Hd({id:e}){let[t,n]=(0,_.useState)(null);return(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:async()=>{try{let{curl:t}=await k(`api/requests/${encodeURIComponent(e)}/curl`);await navigator.clipboard.writeText(t),n({tone:`ok`,text:`Copied. Redacted values stay redacted.`})}catch(e){let t=e instanceof Error?e.message:String(e);n({tone:`error`,text:`Could not copy the curl command: ${t} Try again, or copy it from the server's request log.`})}},children:`Copy as curl`}),t?(0,A.jsx)(`span`,{role:`status`,className:t.tone===`error`?`text-xs text-destructive`:`text-xs text-muted-foreground`,children:t.text}):null]})}function Ud({query:e,requestId:t,nPlusOne:n,session:r,slowest:i}){let a=r.mode===`development`,o=r.role===`admin`,s=a?zd(e):o&&!!e.shapeId;return(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border p-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(Y,{children:e.driver}),(0,A.jsx)(`span`,{className:`w-28`,children:(0,A.jsx)(Od,{ms:e.durationMs,max:i,text:J(e.durationMs)})}),(0,A.jsxs)(`span`,{className:`tabular-nums`,children:[q(e.rowCount),` rows`]}),n?(0,A.jsx)(Y,{tone:`warning`,children:`N+1`}):null,e.error?(0,A.jsx)(`span`,{className:`text-destructive`,children:e.error}):null]}),(0,A.jsx)(Md,{children:Rd(e)}),e.bindings?(0,A.jsx)(Md,{children:`bindings: ${JSON.stringify(e.bindings,null,2)}`}):null,s?(0,A.jsx)(Fd,{run:async()=>k(a?`api/requests/${encodeURIComponent(t)}/queries/${encodeURIComponent(e.id)}/explain`:`api/queries/${encodeURIComponent(e.shapeId??``)}/explain`,{method:`POST`})}):null]})}function Wd({requestId:e}){let{data:t,error:n,loading:r}=H(`api/ai?requestId=${encodeURIComponent(e)}`);return n?(0,A.jsx)(z,{error:n,title:`Could not load the AI runs`}):!t&&r?(0,A.jsx)(Ks,{rows:1}):t?.available?t.runs.length?(0,A.jsx)(`ul`,{className:`space-y-1`,children:t.runs.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`a`,{className:`block rounded-lg border p-2.5 text-sm hover:bg-muted/60`,href:`#ai/${encodeURIComponent(e.traceId)}`,children:[e.name,` · `,e.status,` · `,J(e.duration)]})},e.traceId))}):(0,A.jsx)(U,{title:`No AI runs collected for this request yet.`}):(0,A.jsx)(U,{title:t?.title??t?.message??`AI observation is not available.`})}function Gd({id:e,session:t,onClose:n}){let{data:r,error:i,loading:a,reload:o}=H(`api/requests/${encodeURIComponent(e)}`),s=t.mode===`development`;if(i&&!r)return(0,A.jsxs)(`div`,{children:[n?(0,A.jsx)($,{onClick:n}):null,(0,A.jsx)(z,{error:i,title:`Could not load this request`,onRetry:o})]});if(!r)return a?(0,A.jsx)(Ks,{rows:5}):null;let c=new Set(r.warnings.map(e=>e.shape)),l=Array.isArray(r.cache)?null:r.cache,u=Array.isArray(r.cache)?r.cache:null,d=r.partial===!0,f=Math.max(0,...r.queries.map(e=>e.durationMs));return(0,A.jsxs)(`section`,{"aria-label":`Request detail`,className:`space-y-3`,children:[(0,A.jsxs)(`div`,{children:[n?(0,A.jsx)($,{onClick:n,children:`Close request`}):null,(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(_d,{method:r.method}),(0,A.jsx)(hd,{status:r.status}),(0,A.jsx)(`h2`,{className:`min-w-0 font-mono text-base font-semibold break-all`,children:r.path})]})]}),(0,A.jsx)(jd,{items:[{label:`Duration`,value:J(r.durationMs)},{label:`Started`,value:(0,A.jsx)(ed,{at:r.startedAt})},{label:`Route`,value:r.route??`—`},{label:`Queries`,value:q(r.queryCount)},{label:`Warnings`,value:q(r.warningCount)},{label:`Id`,value:(0,A.jsx)(`span`,{className:`font-mono text-xs`,children:r.id})}]}),d?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,A.jsx)(Y,{children:`not sampled`}),` Kept because it was slow or failed. Phases, queries and logs were not recorded for it.`]}):null,r.error?(0,A.jsx)(`p`,{className:`text-sm text-destructive`,children:r.error}):null,r.warnings.length?(0,A.jsx)(Ad,{title:`Warnings`,children:r.warnings.map((e,t)=>(0,A.jsxs)(`p`,{className:`rounded-lg border border-warning/40 bg-warning/10 p-2.5 text-sm`,children:[e.message,` `,e.caller?(0,A.jsxs)(`a`,{className:`underline`,href:`vscode://file/${e.caller.file}:${e.caller.line}:${e.caller.column}`,children:[e.caller.file,`:`,e.caller.line]}):null]},t))}):null,(0,A.jsx)(Hd,{id:r.id}),r.record?(0,A.jsx)(Ld,{record:r.record}):null,(0,A.jsx)(Ad,{title:`Waterfall`,children:(0,A.jsx)(Vd,{request:r})}),(0,A.jsx)(Ad,{title:`Queries (${r.queries.length})`,children:r.queries.length?(0,A.jsxs)(`div`,{className:`space-y-2`,children:[r.queries.map(e=>(0,A.jsx)(Ud,{query:e,requestId:r.id,nPlusOne:c.has(e.shape??e.sql??``),session:t,slowest:f},e.id)),r.droppedQueries?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.droppedQueries,` more queries ran but were not kept (the per-request limit was reached).`]}):null]}):(0,A.jsx)(U,{title:`No queries recorded.`})}),l?(0,A.jsx)(Ad,{title:`Cache`,children:(0,A.jsxs)(`p`,{className:`text-sm tabular-nums`,children:[l.hits,` hits · `,l.misses,` misses · `,l.writes,` writes`]})}):u?.length?(0,A.jsx)(Ad,{title:`Cache`,children:(0,A.jsx)(`ul`,{className:`font-mono text-xs`,children:u.map((e,t)=>(0,A.jsxs)(`li`,{children:[e.type,` `,e.key||e.keys?.join(`, `)||``]},t))})}):null,(0,A.jsx)(Ad,{title:`Request logs`,children:r.logs.length?(0,A.jsx)(`ul`,{className:`space-y-2`,children:r.logs.map((e,t)=>(0,A.jsxs)(`li`,{className:`rounded-lg border p-2.5 text-sm`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(yd,{level:e.level}),(0,A.jsxs)(`span`,{children:[e.module,` · `,e.action,` · `,td(e.at)]})]}),(0,A.jsx)(`div`,{className:`mt-1 break-words`,children:e.message}),e.context===void 0?null:(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-xs`,children:`Context`}),(0,A.jsx)(id,{value:e.context})]})]},t))}):(0,A.jsx)(U,{title:`No logs recorded.`})}),s||r.mails?.length?(0,A.jsx)(Ad,{title:`Request mail`,children:r.mails?.length?(0,A.jsx)(`ul`,{className:`space-y-1`,children:r.mails.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`a`,{className:`block rounded-lg border p-2.5 text-sm hover:bg-muted/60`,href:`#mail/${encodeURIComponent(e)}`,children:[`Mail `,e]})},e))}):(0,A.jsx)(U,{title:`No mail captured.`})}):null,s?(0,A.jsx)(Ad,{title:`AI runs`,children:(0,A.jsx)(Wd,{requestId:r.id})}):null]})}var Kd={q:``,status:``,method:``,route:``,since:``},qd=[{value:``,label:`All`},{value:`2xx`,label:`2xx`},{value:`3xx`,label:`3xx`},{value:`4xx`,label:`4xx`},{value:`5xx`,label:`5xx`}],Jd=[{value:``,label:`Any time`},{value:`15m`,label:`Last 15 min`},{value:`1h`,label:`Last hour`},{value:`24h`,label:`Last 24 hours`}];function Yd({row:e,selected:t,onOpen:n,label:r,slowest:i}){let a=Dd(n);return(0,A.jsxs)(W,{"data-state":t?`selected`:void 0,"aria-current":t||void 0,...a,children:[(0,A.jsx)(K,{className:`w-16`,children:(0,A.jsx)(hd,{status:e.status})}),(0,A.jsxs)(K,{className:`max-w-0 min-w-56 whitespace-normal`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(_d,{method:e.method}),(0,A.jsx)(`div`,{className:`truncate font-mono text-xs`,title:e.path,children:e.path})]}),(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[e.persisted?(0,A.jsx)(Y,{tone:`brand`,children:`saved`}):null,e.partial?(0,A.jsx)(Y,{children:`not sampled`}):null,e.partial?null:(0,A.jsxs)(`span`,{className:`tabular-nums`,children:[e.queryCount,` queries`]}),e.warningCount?(0,A.jsx)(Y,{tone:`warning`,children:`⚠ ${e.warningCount}`}):null,r?(0,A.jsx)(`span`,{children:r}):null]})]}),(0,A.jsx)(K,{className:`w-28`,children:(0,A.jsx)(Od,{ms:e.durationMs,max:i,text:J(e.durationMs),tone:e.status&&e.status>=500?`bg-destructive`:`bg-brand`})}),(0,A.jsx)(K,{className:`w-24 text-right text-xs whitespace-nowrap text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.startedAt})})]})}function Xd({route:e,navigate:t,session:n}){let r=n.mode===`production`,i=n.role===`admin`,[a,o]=(0,_.useState)(Kd),[s,c]=(0,_.useState)(Kd),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null),h=Object.values(s).some(e=>e.trim()),{data:g,error:v,loading:y,reload:b}=H(`api/requests${dd(s)}`,{refreshMs:1e4}),{data:x}=H(r?`api/instances`:null),S=(0,_.useRef)(h);(0,_.useEffect)(()=>{S.current=h},[h]),lu([`request`],(0,_.useCallback)(e=>{if(e.type!==`request`||S.current)return;let t=e.data;u(e=>[t,...e.filter(e=>e.id!==t.id)].slice(0,200))},[]));let C=(0,_.useMemo)(()=>{if(!g)return[];if(h)return g;let e=new Set(l.map(e=>e.id));return[...l,...g.filter(t=>!e.has(t.id))].slice(0,200)},[g,l,h]),w=async()=>{try{await k(`api/requests`,{method:`DELETE`}),u([]),f(!1),m(null),t(``),b()}catch(e){m(e)}},T=C.flatMap(e=>e.durationMs==null?[]:[e.durationMs]),ee=T.length?Math.max(...T):0,te=C.filter(e=>e.status!=null),ne=te.filter(e=>(e.status??0)>=500).length,re=kd(T,95),ie=()=>{o(Kd),c(Kd)},ae=e=>{let t={...a,status:e};o(t),c(t)},oe=e=>t=>o(n=>({...n,[e]:t.target.value}));return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(bd,{title:`Requests`,description:r?`Sampled requests, plus slow and failed ones kept without a timeline.`:`Every request your app served, newest first. Open one to see its timeline, queries and logs.`,children:[(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:b,children:[(0,A.jsx)(vs,{}),`Refresh`]}),i?d?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(R,{size:`sm`,variant:`destructive`,onClick:w,children:`Confirm clear`}),(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>f(!1),children:`Cancel`})]}):(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>f(!0),children:`Clear`}):null]}),p?(0,A.jsx)(z,{error:p,title:`Could not clear the requests`,className:`mb-3`}):null,C.length?(0,A.jsx)(xd,{items:[{label:`Requests`,value:C.length,hint:h?`matching the filters`:`in the list`},{label:`Server errors`,value:te.length?Xu(ne/te.length*100):`—`,hint:`${ne} with a 5xx status`,tone:ne?`destructive`:`success`},{label:`p95 duration`,value:J(re),hint:`95 % finished faster`},{label:`Slowest`,value:J(ee||null),hint:`longest in the list`}]}):null,(0,A.jsxs)(X,{label:`Request filters`,onSubmit:()=>c(a),trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:C.length,noun:`request`}),h?(0,A.jsx)(Td,{onClick:ie}):null]}),children:[(0,A.jsx)(od,{type:`search`,placeholder:`Search url or id`,"aria-label":`Search url or id`,className:`min-w-44 flex-1`,value:a.q,onChange:oe(`q`)}),(0,A.jsx)(Cd,{label:`Status class`,options:qd,value:qd.some(e=>e.value===a.status)?a.status:`x`,onChange:ae}),(0,A.jsx)(od,{placeholder:`Status: 404 or 5xx`,"aria-label":`Status`,className:`w-36`,value:a.status,onChange:oe(`status`)}),(0,A.jsx)(od,{placeholder:`Method`,"aria-label":`Method`,className:`w-24`,value:a.method,onChange:oe(`method`)}),(0,A.jsx)(od,{placeholder:`Route`,"aria-label":`Route`,className:`w-32`,value:a.route,onChange:oe(`route`)}),(0,A.jsx)(sd,{"aria-label":`Since`,value:a.since,onChange:oe(`since`),children:Jd.map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,A.jsx)(R,{type:`submit`,size:`sm`,children:`Filter`})]}),(0,A.jsxs)(`div`,{className:e?`grid gap-4 xl:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`:void 0,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[v?(0,A.jsx)(z,{error:v,title:`Could not load the requests`,onRetry:b}):null,!g&&y?(0,A.jsx)(Ks,{}):null,g&&!C.length?(0,A.jsx)(U,{title:h?`No request matches these filters. Loosen or reset them.`:`No requests yet. Make a request to your app.`,hint:h?`Use Clear filters to see every request again.`:`New requests appear here as they arrive.`}):null,C.length?(0,A.jsxs)(Ed,{label:`Requests`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Status`}),(0,A.jsx)(G,{className:Z,children:`Request`}),(0,A.jsx)(G,{className:`${Z} text-right`,children:`Duration`}),(0,A.jsx)(G,{className:`${Z} text-right`,children:`When`})]})}),(0,A.jsx)(pu,{children:C.map(n=>(0,A.jsx)(Yd,{row:n,selected:n.id===e,onOpen:()=>t(n.id),slowest:ee,label:r?ud(n.instance,x?.instances):null},n.id))})]}):null]}),e?(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsx)(Gd,{id:e,session:n,onClose:()=>t(``)},e)}):null]})]})}function Zd({values:e,width:t=120,height:n=28,label:r,className:i}){if(e.length<2)return(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,role:`img`,"aria-label":r??`No trend yet`,children:`no trend yet`});let a=Math.min(...e),o=Math.max(...e)-a||1,s=t/(e.length-1),c=e.map((e,t)=>`${(t*s).toFixed(1)},${(n-2-(e-a)/o*(n-4)).toFixed(1)}`).join(` `);return(0,A.jsx)(`svg`,{viewBox:`0 0 ${t} ${n}`,width:t,height:n,role:`img`,"aria-label":r??`Trend`,className:i,children:(0,A.jsx)(`polyline`,{points:c,fill:`none`,stroke:`var(--chart-2)`,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`})})}function Qd({title:e,series:t,format:n,height:r=140,max:i}){let a=t.flatMap(e=>e.points);if(a.length<2)return(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e,`: waiting for more readings.`]});let o=Math.min(...a.map(e=>e.at)),s=Math.max(...a.map(e=>e.at)),c=i??(Math.max(...a.map(e=>e.value))||1),l=r-6-18,u=e=>56+(e-o)/(s-o||1)*420,d=e=>6+l-Math.min(e,c)/c*l,f=[0,.5,1].map(e=>e*c);return(0,A.jsxs)(`figure`,{className:`m-0`,children:[(0,A.jsxs)(`figcaption`,{className:`mb-1 flex flex-wrap items-center gap-3 text-xs`,children:[(0,A.jsx)(`span`,{className:`font-medium`,children:e}),t.map(e=>(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`inline-block h-0.5 w-3`,style:{background:e.color}}),e.name]},e.name))]}),(0,A.jsxs)(`svg`,{viewBox:`0 0 480 ${r}`,className:`w-full`,role:`img`,"aria-label":`${e}: ${t.map(e=>`${e.name} latest ${n(e.points.at(-1)?.value??0)}`).join(`, `)}`,children:[f.map(e=>(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`line`,{x1:56,x2:476,y1:d(e),y2:d(e),stroke:`var(--border)`,strokeWidth:1}),(0,A.jsx)(`text`,{x:52,y:d(e)+3,textAnchor:`end`,fontSize:9,fill:`var(--muted-foreground)`,children:n(e)})]},e)),t.map(e=>(0,A.jsx)(`polyline`,{fill:`none`,stroke:e.color,strokeWidth:1.5,strokeLinejoin:`round`,points:e.points.map(e=>`${u(e.at).toFixed(1)},${d(e.value).toFixed(1)}`).join(` `)},e.name)),(0,A.jsx)(`text`,{x:56,y:r-4,fontSize:9,fill:`var(--muted-foreground)`,children:new Date(o).toLocaleTimeString()}),(0,A.jsx)(`text`,{x:476,y:r-4,textAnchor:`end`,fontSize:9,fill:`var(--muted-foreground)`,children:new Date(s).toLocaleTimeString()})]})]})}var $d=[1,2,5,10,25,50,100,250,500,1e3,2500,5e3,1e4,3e4];function ef(e){let t=$d,n=t[e];return n===void 0?`> ${t.at(-1)} ms`:`${e===0?0:t[e-1]}–${n} ms`}function tf({histogram:e}){let t=e.counts,n=t.findIndex(e=>e>0);if(n===-1)return(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No timings recorded yet.`});let r=t.length-1-[...t].reverse().findIndex(e=>e>0),i=Math.max(...t,1);return(0,A.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,"aria-label":`Latency histogram`,children:t.slice(n,r+1).map((e,t)=>{let r=n+t;return(0,A.jsxs)(`li`,{className:`grid grid-cols-[6.5rem_1fr_3rem] items-center gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:ef(r)}),(0,A.jsx)(`span`,{className:`h-3 rounded-sm bg-muted`,children:(0,A.jsx)(`span`,{className:`block h-3 rounded-sm`,style:{width:`${e/i*100}%`,background:`var(--chart-2)`}})}),(0,A.jsx)(`span`,{className:`text-right tabular-nums`,children:e.toLocaleString(`en-US`)})]},r)})})}function nf({p50:e,p95:t,max:n}){let r=Math.max(n,t,e,1),i=e=>`${Math.min(100,e/r*100)}%`;return(0,A.jsxs)(`div`,{role:`img`,"aria-label":`p50 ${J(e)}, p95 ${J(t)}, max ${J(n)}`,className:`relative h-3 min-w-24 rounded-sm bg-muted`,children:[(0,A.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-sm opacity-40`,style:{width:i(n),background:`var(--chart-4)`}}),(0,A.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-sm opacity-70`,style:{width:i(t),background:`var(--chart-1)`}}),(0,A.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-sm`,style:{width:i(e),background:`var(--chart-2)`}})]})}function rf({title:e,description:t,legend:n,table:r,loading:i,className:a,children:o}){let[s,c]=(0,_.useState)(!1),l=(0,_.useId)();return(0,A.jsxs)(`section`,{"aria-labelledby":l,className:F(`min-w-0 rounded-xl border bg-card p-3.5 transition-opacity`,i&&`opacity-60`,a),children:[(0,A.jsxs)(`header`,{className:`mb-2 flex flex-wrap items-start justify-between gap-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h3`,{id:l,className:`text-sm font-semibold`,children:e}),t?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),r?(0,A.jsx)(`button`,{type:`button`,"aria-pressed":s,onClick:()=>c(e=>!e),className:`rounded-md border px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none aria-pressed:bg-muted aria-pressed:text-foreground`,children:`Table`}):null]}),n?(0,A.jsx)(`div`,{className:`mb-2`,children:n}):null,s&&r?(0,A.jsx)(`div`,{className:`max-h-80 overflow-auto`,children:r}):o]})}function af({items:e,shape:t=`rect`}){return e.length<2?null:(0,A.jsx)(`ul`,{"aria-label":`Legend`,className:`m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-xs`,children:e.map(e=>(0,A.jsxs)(`li`,{className:`inline-flex items-center gap-1.5 text-muted-foreground`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:F(`inline-block`,t===`line`?`h-0.5 w-3`:`size-2.5 rounded-sm`),style:{background:e.color}}),e.label]},e.key))})}function of({id:e,title:t,rows:n,total:r,left:i}){return(0,A.jsxs)(`div`,{id:e,role:`tooltip`,className:F(`pointer-events-none absolute top-1 z-10 min-w-40 max-w-64 rounded-lg border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md`,i>60?`-translate-x-[calc(100%+0.75rem)]`:`translate-x-3`),style:{left:`${i}%`},children:[(0,A.jsx)(`p`,{className:`mb-1 font-medium`,children:t}),(0,A.jsx)(`ul`,{className:`m-0 list-none space-y-0.5 p-0`,children:n.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:F(`inline-block shrink-0`,e.shape===`line`?`h-0.5 w-3`:`size-2.5 rounded-sm`),style:{background:e.color}}),(0,A.jsx)(`span`,{className:`font-semibold tabular-nums`,children:e.value}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.label})]},e.key))}),r===void 0?null:(0,A.jsxs)(`p`,{className:`mt-1 flex justify-between gap-3 border-t pt-1`,children:[(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`Total`}),(0,A.jsx)(`span`,{className:`font-semibold tabular-nums`,children:r})]})]})}var sf=36e5,cf=24*sf,lf=new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),uf=new Intl.DateTimeFormat(`en-US`,{weekday:`short`}),df=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`}),ff=e=>lf.format(e).replace(/^24:/,`00:`);function pf(e,t,n=1){if(t>=cf)return df.format(e);if(t>=6*sf)return`${uf.format(e)} ${ff(e)}`;let r=new Date(e),i=r.getHours()===0&&r.getMinutes()===0;return n===0||i?`${df.format(e)} ${ff(e)}`:ff(e)}function mf(e,t){return t>=cf?df.format(e):`${df.format(e)} ${ff(e)}`}function hf(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e));for(let n of[1,2,2.5,5,10])if(e<=n*t)return n*t;return 10*t}function gf(e){return`var(--series-${e})`}var _f=`var(--series-other)`,vf={uncached:gf(1),cached:gf(2),output:gf(3)},yf=`devtools.ai.series`;function bf(e){return e===`models`?yf:`${yf}.${e}`}var xf={slots:{},order:[]};function Sf(e,t){let n={...e.slots},r=e.order.filter(e=>e in n);for(let e of t){if(!(e in n)){let i=new Set(Object.values(n)),a=1;for(;a<=6&&i.has(a);)a+=1;if(a>6){let e=r.find(e=>!t.includes(e))??r[0];if(e===void 0)continue;a=n[e]??1,delete n[e],r=r.filter(t=>t!==e)}n[e]=a}r=[...r.filter(t=>t!==e),e]}return{slots:n,order:r}}function Cf(e){try{let t=sessionStorage.getItem(e),n=t?JSON.parse(t):null;if(n&&n.slots&&Array.isArray(n.order))return{slots:n.slots,order:n.order}}catch{}return xf}function wf(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function Tf(e,t=`models`){let n=`${t}\u0001${e.join(`\0`)}`;return(0,_.useMemo)(()=>{let n=bf(t),r=Sf(Cf(n),e);return wf(n,r),e=>gf(r.slots[e]??1)},[n])}var Ef=640,Df=220,Of=52,kf=8,Af=2,jf=4;function Mf(e,t,n,r){let i=Math.min(jf,n/2,r);return`M${e},${t+r}V${t+i}a${i},${i} 0 0 1 ${i},${-i}H${e+n-i}a${i},${i} 0 0 1 ${i},${i}V${t+r}Z`}function Nf({title:e,set:t,stepMs:n,format:r,color:i,emptyText:a,loading:o,description:s}){let[c,l]=(0,_.useState)(null),u=(0,_.useId)(),d=t.buckets.length,f=e=>e.other?_f:i(e.key),p=t.buckets.map((e,n)=>t.series.reduce((e,t)=>e+(t.values[n]??0),0)),m=p.reduce((e,t)=>e+t,0),h=(0,A.jsx)(af,{items:t.series.map(e=>({key:e.key,label:e.label,color:f(e)}))}),g=(0,A.jsxs)(`table`,{"aria-label":`${e} as a table`,className:`w-full text-xs tabular-nums`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 font-medium`,children:`Period`}),t.series.map(e=>(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 text-right font-medium`,children:e.label},e.key)),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 text-right font-medium`,children:`Total`})]})}),(0,A.jsx)(`tbody`,{children:t.buckets.map((e,i)=>(0,A.jsxs)(`tr`,{className:`border-t`,children:[(0,A.jsx)(`th`,{scope:`row`,className:`py-1 pr-3 text-left font-normal`,children:mf(e,n)}),t.series.map(e=>(0,A.jsx)(`td`,{className:`py-1 pr-3 text-right`,children:r(e.values[i]??0)},e.key)),(0,A.jsx)(`td`,{className:`py-1 text-right font-medium`,children:r(p[i]??0)})]},e))})]});if(!d||m===0)return(0,A.jsx)(rf,{title:e,loading:o,description:s,children:(0,A.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:a})});let v=hf(Math.max(...p)),y=582/d,b=Math.max(2,y-Math.min(4,y*.2)),x=e=>198-e/v*190,S=Math.ceil(d/6),C=`${e}: ${r(m)} in total over ${d} periods from ${mf(t.buckets[0]??0,n)}. Series: ${t.series.map(e=>e.label).join(`, `)}. Use the left and right arrow keys to read each period.`,w=e=>{if(e.key===`ArrowLeft`)l(e=>Math.max(0,(e??d)-1));else if(e.key===`ArrowRight`)l(e=>Math.min(d-1,(e??-1)+1));else if(e.key===`Home`)l(0);else if(e.key===`End`)l(d-1);else if(e.key===`Escape`)l(null);else return;e.preventDefault()},T=c===null?void 0:t.buckets[c];return(0,A.jsx)(rf,{title:e,loading:o,description:s,legend:h,table:g,children:(0,A.jsxs)(`div`,{role:`group`,tabIndex:0,"aria-label":C,"aria-describedby":c===null?void 0:u,onKeyDown:w,onFocus:()=>l(e=>e??d-1),onBlur:()=>l(null),onMouseLeave:()=>l(null),className:`relative rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,A.jsxs)(`svg`,{viewBox:`0 0 ${Ef} ${Df}`,className:`w-full`,"aria-hidden":`true`,children:[[0,.5,1].map(e=>(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`line`,{x1:Of,x2:634,y1:x(v*e),y2:x(v*e),stroke:`var(--border)`,strokeWidth:1}),(0,A.jsx)(`text`,{x:46,y:x(v*e)+3,textAnchor:`end`,fontSize:10,fill:`var(--muted-foreground)`,children:r(v*e)})]},e)),t.buckets.map((e,r)=>{let i=Of+r*y+(y-b)/2,a=0,o=t.series.map(e=>({series:e,value:e.values[r]??0})).filter(e=>e.value>0);return(0,A.jsxs)(`g`,{children:[o.map((e,t)=>{let n=x(a);a+=e.value;let r=x(a),s=Math.max(1,n-r),c={fill:f(e.series),stroke:`var(--card)`,strokeWidth:Af/2};return t===o.length-1?(0,A.jsx)(`path`,{d:Mf(i,r,b,s),...c},e.series.key):(0,A.jsx)(`rect`,{x:i,y:r,width:b,height:s,...c},e.series.key)}),c===r?(0,A.jsx)(`rect`,{x:Of+r*y,y:kf,width:y,height:190,fill:`var(--foreground)`,opacity:.06}):null,r%S===0?(0,A.jsx)(`text`,{x:Of+r*y+y/2,y:214,textAnchor:`middle`,fontSize:10,fill:`var(--muted-foreground)`,children:pf(e,n,r)}):null,(0,A.jsx)(`rect`,{"data-testid":`chart-hit`,x:Of+r*y,y:kf,width:y,height:190,fill:`transparent`,onMouseEnter:()=>l(r),onMouseMove:()=>l(r)})]},e)})]}),c!==null&&T!==void 0?(0,A.jsx)(of,{id:u,title:mf(T,n),left:(Of+c*y+y/2)/Ef*100,total:r(p[c]??0),rows:[...t.series].reverse().map(e=>({key:e.key,label:e.label,value:r(e.values[c]??0),color:f(e)}))}):null]})})}var Pf=640,Ff=200,If=52,Lf=8;function Rf({title:e,seriesName:t,points:n,stepMs:r,format:i,color:a,emptyText:o,loading:s,description:c}){let[l,u]=(0,_.useState)(null),d=(0,_.useId)(),f=n.length,p=n.filter(e=>e.rate!==null),m=(0,A.jsxs)(`table`,{"aria-label":`${e} as a table`,className:`w-full text-xs tabular-nums`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 font-medium`,children:`Period`}),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 text-right font-medium`,children:t}),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 text-right font-medium`,children:`Runs`}),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 text-right font-medium`,children:`Failed`})]})}),(0,A.jsx)(`tbody`,{children:n.map(e=>(0,A.jsxs)(`tr`,{className:`border-t`,children:[(0,A.jsx)(`th`,{scope:`row`,className:`py-1 pr-3 text-left font-normal`,children:mf(e.at,r)}),(0,A.jsx)(`td`,{className:`py-1 pr-3 text-right`,children:e.rate===null?`No runs`:i(e.rate)}),(0,A.jsx)(`td`,{className:`py-1 pr-3 text-right`,children:e.runs}),(0,A.jsx)(`td`,{className:`py-1 text-right`,children:e.errors})]},e.at))})]});if(!f||!p.length)return(0,A.jsx)(rf,{title:e,loading:s,description:c,children:(0,A.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:o})});let h=hf(Math.max(...p.map(e=>e.rate??0))),g=580/f,v=e=>If+e*g+g/2,y=e=>178-e/h*170,b=Math.ceil(f/6),x=[];n.forEach((e,t)=>{if(e.rate===null){x.push([]);return}x.length||x.push([]),x[x.length-1]?.push({index:t,rate:e.rate})});let S=x.filter(e=>e.length),C=`${e}: latest ${i(p.at(-1)?.rate??0)}, highest ${i(Math.max(...p.map(e=>e.rate??0)))} over ${f} periods. Use the left and right arrow keys to read each period.`,w=e=>{if(e.key===`ArrowLeft`)u(e=>Math.max(0,(e??f)-1));else if(e.key===`ArrowRight`)u(e=>Math.min(f-1,(e??-1)+1));else if(e.key===`Home`)u(0);else if(e.key===`End`)u(f-1);else if(e.key===`Escape`)u(null);else return;e.preventDefault()},T=l===null?void 0:n[l];return(0,A.jsx)(rf,{title:e,loading:s,description:c,table:m,children:(0,A.jsxs)(`div`,{role:`group`,tabIndex:0,"aria-label":C,"aria-describedby":l===null?void 0:d,onKeyDown:w,onFocus:()=>u(e=>e??f-1),onBlur:()=>u(null),onMouseLeave:()=>u(null),className:`relative rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,A.jsxs)(`svg`,{viewBox:`0 0 ${Pf} ${Ff}`,className:`w-full`,"aria-hidden":`true`,children:[[0,.5,1].map(e=>(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`line`,{x1:If,x2:632,y1:y(h*e),y2:y(h*e),stroke:`var(--border)`,strokeWidth:1}),(0,A.jsx)(`text`,{x:46,y:y(h*e)+3,textAnchor:`end`,fontSize:10,fill:`var(--muted-foreground)`,children:i(h*e)})]},e)),n.map((e,t)=>t%b===0?(0,A.jsx)(`text`,{x:v(t),y:194,textAnchor:`middle`,fontSize:10,fill:`var(--muted-foreground)`,children:pf(e.at,r,t)},e.at):null),l===null?null:(0,A.jsx)(`line`,{"data-testid":`crosshair`,x1:v(l),x2:v(l),y1:Lf,y2:178,stroke:`var(--muted-foreground)`,strokeWidth:1,strokeDasharray:`3 3`}),S.map(e=>e.length===1?(0,A.jsx)(`circle`,{"data-testid":`line-dot`,cx:v(e[0]?.index??0),cy:y(e[0]?.rate??0),r:4,fill:a,stroke:`var(--card)`,strokeWidth:2},e[0]?.index):(0,A.jsx)(`path`,{"data-testid":`line-segment`,d:e.map((e,t)=>`${t===0?`M`:`L`}${v(e.index).toFixed(1)},${y(e.rate).toFixed(1)}`).join(``),fill:`none`,stroke:a,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`},e[0]?.index)),T&&T.rate!==null?(0,A.jsx)(`circle`,{cx:v(l??0),cy:y(T.rate),r:4,fill:a,stroke:`var(--card)`,strokeWidth:2}):null,n.map((e,t)=>(0,A.jsx)(`rect`,{"data-testid":`chart-hit`,x:If+t*g,y:Lf,width:g,height:170,fill:`transparent`,onMouseEnter:()=>u(t),onMouseMove:()=>u(t)},e.at))]}),T?(0,A.jsx)(of,{id:d,title:mf(T.at,r),left:v(l??0)/Pf*100,rows:[{key:`rate`,label:t,value:T.rate===null?`No runs`:i(T.rate),color:a,shape:`line`},{key:`runs`,label:`runs`,value:String(T.runs),color:`transparent`},{key:`errors`,label:`failed`,value:String(T.errors),color:`transparent`}]}):null]})})}function zf({share:e,children:t}){let n=e>0?Math.max(3,Math.min(100,e*100)):0;return(0,A.jsxs)(`div`,{className:`ml-auto flex w-24 flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`tabular-nums`,children:t}),(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,A.jsx)(`span`,{className:`block h-full rounded-full bg-brand`,style:{width:`${n}%`}})})]})}function Bf(e,t,n){if(e===t)return`No change`;if(t===0)return`New`;let r=Math.abs((e-t)/t*100),i=r<1?`<1`:r<10?r.toFixed(1).replace(/\.0$/,``):Math.round(r);return`${e>t?`▲`:`▼`} ${i}% vs ${n}`}function Vf({current:e,previous:t,against:n,risingIsBad:r,previousComplete:i=!0}){return i?(0,A.jsx)(`span`,{className:F(`text-xs tabular-nums`,r&&e>t?`text-warning`:`text-muted-foreground`),children:Bf(e,t,n)}):(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`No earlier data`})}function Hf(){let{data:e,error:t,loading:n,reload:r}=H(`api/background`,{refreshMs:1e4});return(0,A.jsx)(`section`,{"aria-label":`Background queries`,className:`mt-4`,children:(0,A.jsxs)(Ad,{title:`Background queries (outside any request)`,children:[t?(0,A.jsx)(z,{error:t,title:`Could not load the background queries`,onRetry:r}):null,!e&&n?(0,A.jsx)(Ks,{rows:2}):null,e&&!e.queries.length?(0,A.jsx)(U,{title:`No background queries yet.`,hint:`Boot work, scheduler ticks and queue jobs that query the database show up here.`}):null,(0,A.jsx)(`div`,{className:`space-y-2`,children:e?.queries.map(e=>(0,A.jsxs)(`div`,{className:`space-y-1.5 rounded-lg border p-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(Y,{children:e.driver}),(0,A.jsx)(`span`,{className:`tabular-nums`,children:J(e.durationMs)})]}),(0,A.jsx)(Md,{children:e.sql||e.shape||`${e.collection??`collection`}.${e.command??`command`}`})]},e.id))})]})})}var Uf=100,Wf=[{value:`all`,label:`All`},{value:`slow`,label:`Slow`},{value:`nplus`,label:`N+1`},{value:`errors`,label:`Errors`}],Gf=[{value:`total`,label:`Total time`},{value:`p95`,label:`p95`},{value:`count`,label:`Count`},{value:`n+1`,label:`N+1`}];function Kf({shape:e,isAdmin:t,production:n,onClose:r}){let i=e.slowest;return(0,A.jsxs)(`section`,{"aria-label":`Query detail`,className:`space-y-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)($,{onClick:r,children:`Close query`}),(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,A.jsx)(Y,{children:e.driver}),e.connection]})]}),(0,A.jsx)(jd,{items:[{label:`Runs`,value:q(e.count)},{label:`p50`,value:J(e.p50Ms)},{label:`p95`,value:J(e.p95Ms)},{label:`Max`,value:J(e.histogram.maxMs)},{label:`Errors`,value:e.errors||`—`},{label:`Last seen`,value:(0,A.jsx)(ed,{at:e.lastSeen})}]}),(0,A.jsx)(Ad,{title:`Query shape`,children:(0,A.jsx)(Md,{children:e.shape})}),(0,A.jsx)(Ad,{title:`Latency`,children:(0,A.jsx)(tf,{histogram:e.histogram})}),(0,A.jsx)(Ad,{title:`Slowest example`,children:i?(0,A.jsxs)(`p`,{className:`text-sm`,children:[(0,A.jsx)(`span`,{className:`tabular-nums`,children:J(i.durationMs)}),` ·`,` `,(0,A.jsx)(ed,{at:i.at}),i.route?(0,A.jsxs)(A.Fragment,{children:[` · `,i.route]}):null,i.requestId?(0,A.jsxs)(A.Fragment,{children:[` `,`·`,` `,(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(i.requestId)}`,children:`open request`})]}):null]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No slow example kept yet.`})}),e.nPlusOne.requests?(0,A.jsxs)(`p`,{className:`rounded-lg border border-warning/40 bg-warning/10 p-2.5 text-sm`,children:[(0,A.jsx)(Y,{tone:`warning`,children:`N+1`}),` in `,e.nPlusOne.requests,` sampled requests, up to`,` `,e.nPlusOne.maxPerRequest,` runs in one request.`]}):null,t?(0,A.jsx)(Ad,{title:`EXPLAIN`,children:e.explainable?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Fd,{run:()=>k(`api/queries/${encodeURIComponent(e.id)}/explain`,{method:`POST`})}),n?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`EXPLAIN uses the slowest example, held by the instance that ran it. It only plans the query unless the project allows executing plans.`}):null]}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`EXPLAIN is not available for this query type (Postgres SELECT/WITH and MongoDB find, aggregate and count only).`})}):null]})}function qf({route:e,navigate:t,instance:n,session:r}){let[i,a]=(0,_.useState)(`total`),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`all`),u=r.mode===`production`,d=r.role===`admin`,{data:f,error:p,loading:m,reload:h}=H(`api/queries/stats${dd({sort:i,instance:n===`all`?void 0:n})}`,{refreshMs:1e4}),g=f?.shapes.find(t=>t.id===e),v=f?Math.round(f.sampleRate*1e3)/10:null,y=!!o.trim()||c!==`all`,b=(0,_.useMemo)(()=>{let e=o.trim().toLowerCase();return(f?.shapes??[]).filter(t=>e&&!t.shape.toLowerCase().includes(e)?!1:c===`slow`?t.p95Ms>=Uf:c===`nplus`?t.nPlusOne.requests>0:c!==`errors`||t.errors>0)},[f,o,c]),x=f?.shapes??[],S=x.filter(e=>e.p95Ms>=Uf).length,C=x.filter(e=>e.nPlusOne.requests>0).length,w=x.reduce((e,t)=>e+t.errors,0),T=Math.max(0,...b.map(e=>e.p95Ms));return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(bd,{title:`Queries`,description:f?`${v!==null&&v<100?`Counts come from sampled requests (${v} %).`:`Counts cover every request.`}`:`Database queries grouped by shape, with latency, errors and N+1 findings.`,children:[(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[`Sort by`,(0,A.jsx)(sd,{value:i,onChange:e=>a(e.target.value),children:Gf.map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:h,children:[(0,A.jsx)(vs,{}),`Refresh`]})]}),p?(0,A.jsx)(z,{error:p,title:`Could not load the query statistics`,onRetry:h}):null,!f&&m?(0,A.jsx)(Ks,{}):null,f&&!f.shapes.length?(0,A.jsx)(U,{title:`No queries recorded yet. Make requests that use the database; they appear here.`,hint:`Shapes appear after the first sampled request runs a query.`}):null,f?.shapes.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{items:[{label:`Query shapes`,value:q(x.length)},{label:`Total runs`,value:q(x.reduce((e,t)=>e+t.count,0))},{label:`Slow shapes`,value:q(S),hint:`p95 of ${Uf} ms or more`,tone:S?`warning`:`success`},{label:`N+1 shapes`,value:q(C),tone:C?`warning`:`success`},{label:`Failed runs`,value:q(w),tone:w?`destructive`:`success`}]}),(0,A.jsxs)(X,{label:`Query filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:b.length,total:x.length,noun:`shape`}),y?(0,A.jsx)(Td,{onClick:()=>{s(``),l(`all`)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Search queries`,placeholder:`Search query text`,value:o,onChange:e=>s(e.target.value)}),(0,A.jsx)(Cd,{label:`Show`,options:Wf,value:c,onChange:l})]}),(0,A.jsxs)(`div`,{className:e?`grid gap-4 xl:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]`:void 0,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:b.length?(0,A.jsxs)(Ed,{label:`Query statistics`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Shape`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Count`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p50`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Mean`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Max`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Errors`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`N+1`}),u?(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Instances`}):null]})}),(0,A.jsx)(pu,{children:b.map(n=>{let r=Dd(()=>t(n.id));return(0,A.jsxs)(W,{"data-state":n.id===e?`selected`:void 0,...r,children:[(0,A.jsx)(K,{className:`max-w-0 min-w-64 whitespace-normal`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(Y,{className:`mt-0.5`,children:n.driver}),(0,A.jsx)(`button`,{type:`button`,className:`line-clamp-2 min-w-0 text-left font-mono text-xs break-all focus-visible:outline-none`,title:n.shape,onClick:e=>{e.stopPropagation(),t(n.id)},children:n.shape.length>200?`${n.shape.slice(0,200)}…`:n.shape})]})}),(0,A.jsx)(K,{className:Q,children:q(n.count)}),(0,A.jsx)(K,{className:Q,children:J(n.p50Ms)}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(Od,{ms:n.p95Ms,max:T,text:J(n.p95Ms),tone:n.p95Ms>=Uf?`bg-warning`:`bg-brand`})}),(0,A.jsx)(K,{className:Q,children:J(n.meanMs)}),(0,A.jsx)(K,{className:Q,children:J(n.histogram.maxMs)}),(0,A.jsx)(K,{className:Q,children:n.errors||`—`}),(0,A.jsx)(K,{className:Q,children:n.nPlusOne.requests?(0,A.jsx)(Y,{tone:`warning`,mono:!0,children:n.nPlusOne.requests}):`—`}),u?(0,A.jsx)(K,{className:Q,children:n.instances.length}):null]},n.id)})})]}):(0,A.jsx)(U,{title:`No query matches these filters.`,hint:`Loosen the search or choose All.`})}),e?(0,A.jsx)(`div`,{className:`min-w-0`,children:g?(0,A.jsx)(Kf,{shape:g,isAdmin:d,production:u,onClose:()=>t(``)}):(0,A.jsx)(U,{title:`This query shape is no longer in the statistics. Pick another one.`,hint:`Statistics reset when the app restarts.`})}):null]})]}):null,f&&f.evicted?(0,A.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[f.evicted,` less recently used shapes were dropped to keep memory bounded.`]}):null,r.mode===`development`?(0,A.jsx)(Hf,{}):null]})}function Jf({route:e}){let t=e.phases.slice(0,8),n=Math.max(...t.map(e=>e.sumMs),1);return t.length?(0,A.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,"aria-label":`Slowest phases`,children:t.map(e=>(0,A.jsxs)(`li`,{className:`grid grid-cols-[10rem_1fr_6rem] items-center gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`truncate font-mono`,title:e.name,children:e.name}),(0,A.jsx)(`span`,{className:`h-3 rounded-sm bg-muted`,children:(0,A.jsx)(`span`,{className:`block h-3 rounded-sm`,style:{width:`${e.sumMs/n*100}%`,background:`var(--chart-3)`}})}),(0,A.jsxs)(`span`,{className:`text-right tabular-nums`,children:[J(e.sumMs/Math.max(e.count,1)),` avg`]})]},e.name))}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No phase timings for this route.`})}function Yf({instance:e}){let[t,n]=(0,_.useState)(`total`),[r,i]=(0,_.useState)(null),{data:a,error:o,loading:s,reload:c}=H(`api/routes/stats${dd({sort:t,instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),l=a?Math.round(a.sampleRate*1e3)/10:null,u=a?.routes??[],d=u.reduce((e,t)=>e+t.count,0),f=u.reduce((e,t)=>e+t.errors,0),p=Math.max(0,...u.map(e=>e.p95Ms));return(0,A.jsxs)(`section`,{"aria-label":`Route statistics`,children:[(0,A.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-base font-semibold`,children:`Route statistics`}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l!==null&&l<100?`Counts come from sampled requests (${l} %).`:`How long each route takes, slowest total first.`})]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[`Sort by`,(0,A.jsxs)(sd,{value:t,onChange:e=>n(e.target.value),children:[(0,A.jsx)(`option`,{value:`total`,children:`Total time`}),(0,A.jsx)(`option`,{value:`p95`,children:`p95`}),(0,A.jsx)(`option`,{value:`count`,children:`Count`}),(0,A.jsx)(`option`,{value:`errors`,children:`Errors`})]})]})]}),o?(0,A.jsx)(z,{error:o,title:`Could not load the route statistics`,onRetry:c}):null,!a&&s?(0,A.jsx)(Ks,{rows:3}):null,a&&!a.routes.length?(0,A.jsx)(U,{title:`No route timings yet. Make some requests to your app.`,hint:`Routes appear here after they serve a request.`}):null,a?.routes.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{label:`Route summary`,items:[{label:`Routes timed`,value:q(u.length)},{label:`Requests`,value:q(d)},{label:`Failed requests`,value:q(f),hint:`5xx or thrown errors`,tone:f?`destructive`:`success`},{label:`Slowest p95`,value:J(p)}]}),(0,A.jsxs)(Ed,{label:`Route statistics table`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Route`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Count`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p50`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`}),(0,A.jsx)(G,{className:Z,children:`Spread`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Errors`})]})}),(0,A.jsx)(pu,{children:a.routes.map(e=>(0,A.jsx)(Xf,{route:e,open:r===e.key,onToggle:()=>i(r===e.key?null:e.key)},e.key))})]})]}):null]})}function Xf({route:e,open:t,onToggle:n}){let r=Dd(n);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(W,{"data-state":t?`selected`:void 0,...r,children:[(0,A.jsx)(K,{className:`max-w-0 min-w-56 font-mono text-xs`,children:(0,A.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left focus-visible:outline-none`,title:e.key,"aria-expanded":t,onClick:e=>{e.stopPropagation(),n()},children:e.key})}),(0,A.jsx)(K,{className:Q,children:q(e.count)}),(0,A.jsx)(K,{className:Q,children:J(e.p50Ms)}),(0,A.jsx)(K,{className:Q,children:J(e.p95Ms)}),(0,A.jsx)(K,{children:(0,A.jsx)(nf,{p50:e.p50Ms,p95:e.p95Ms,max:e.histogram.maxMs})}),(0,A.jsx)(K,{className:Q,children:e.errors?(0,A.jsx)(Y,{tone:`destructive`,mono:!0,children:e.errors}):`—`})]}),t?(0,A.jsx)(W,{children:(0,A.jsxs)(K,{colSpan:6,className:`bg-muted/20`,children:[(0,A.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Slowest phases`}),(0,A.jsx)(Jf,{route:e})]})}):null]})}function Zf(){let{data:e,error:t,loading:n,reload:r}=H(`api/routes`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),c=i.toLowerCase(),l=e??[],u=[...new Set(l.map(e=>e.method.toUpperCase()))].sort(),d=l.filter(e=>(!o||e.method.toUpperCase()===o)&&`${e.method} ${e.path} ${e.name??``} ${(e.middleware??[]).join(` `)}`.toLowerCase().includes(c)),f=!!i||!!o;return(0,A.jsxs)(`section`,{"aria-label":`Route map`,className:`mt-8`,children:[(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsx)(`h3`,{className:`text-base font-semibold`,children:`Route map`}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Every route the app registered.`})]}),(0,A.jsxs)(X,{label:`Route filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:d.length,total:l.length,noun:`route`}),f?(0,A.jsx)(Td,{onClick:()=>{a(``),s(``)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Filter routes`,placeholder:`Filter routes`,value:i,onChange:e=>a(e.target.value)}),u.length>1?(0,A.jsx)(Cd,{label:`Method`,value:o,onChange:s,options:[{value:``,label:`All`},...u.map(e=>({value:e,label:e}))]}):null]}),t?(0,A.jsx)(z,{error:t,title:`Could not load the route map`,onRetry:r}):null,!e&&n?(0,A.jsx)(Ks,{rows:3}):null,e&&!d.length?(0,A.jsx)(U,{title:`No routes found.`,hint:f?`Clear the filters to see every route.`:`Register routes in your app and restart it.`}):null,d.length?(0,A.jsxs)(Ed,{label:`Route map table`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Method`}),(0,A.jsx)(G,{className:Z,children:`Path`}),(0,A.jsx)(G,{className:Z,children:`Name`}),(0,A.jsx)(G,{className:Z,children:`Middleware`})]})}),(0,A.jsx)(pu,{children:d.map((e,t)=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`w-24`,children:(0,A.jsx)(_d,{method:e.method})}),(0,A.jsx)(K,{className:`max-w-0 min-w-48 font-mono text-xs`,children:(0,A.jsx)(`div`,{className:`truncate`,title:e.path,children:e.path})}),(0,A.jsx)(K,{children:e.name||`—`}),(0,A.jsx)(K,{className:`text-xs whitespace-normal`,children:(e.middleware??[]).join(`, `)||`—`})]},`${e.method} ${e.path} ${t}`))})]}):null]})}function Qf({instance:e}){return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Routes`,description:`How each route performs, and the full map of routes your app registered.`}),(0,A.jsx)(Yf,{instance:e}),(0,A.jsx)(Zf,{})]})}function $f({label:e,value:t,trend:n}){return(0,A.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2.5`,children:[(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,A.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:t}),n?(0,A.jsx)(Zd,{values:n,width:110,height:24,label:`${e} trend`}):null]})}var ep=(e,t)=>e.map(e=>({at:e.at,value:t(e)}));function tp({entry:e}){let{snapshot:t,history:n}=e,r=[...n,t].filter((e,t,n)=>t===n.findIndex(t=>t.at===e.at)),i=Object.entries(t.gcByKind).filter(([,e])=>e.count>0),a=t.heapLimitBytes?t.heapUsedBytes/t.heapLimitBytes*100:null;return(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsxs)(Zs,{className:`text-base`,children:[e.instance.label,` `,(0,A.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· up `,Qu(t.uptimeSeconds),` · Node `,e.instance.nodeVersion]})]})}),(0,A.jsxs)($s,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-4`,children:[(0,A.jsx)($f,{label:`RSS`,value:Yu(t.rssBytes),trend:r.map(e=>e.rssBytes)}),(0,A.jsx)($f,{label:`Heap used`,value:`${Yu(t.heapUsedBytes)}${a===null?``:` (${a.toFixed(0)} % of limit)`}`,trend:r.map(e=>e.heapUsedBytes)}),(0,A.jsx)($f,{label:`Heap total / limit`,value:`${Yu(t.heapTotalBytes)} / ${Yu(t.heapLimitBytes)}`}),(0,A.jsx)($f,{label:`CPU`,value:Xu(t.cpuPercent),trend:r.map(e=>e.cpuPercent)}),(0,A.jsx)($f,{label:`Event loop delay p50`,value:J(t.eventLoopDelayP50Ms)}),(0,A.jsx)($f,{label:`Event loop delay p99`,value:J(t.eventLoopDelayP99Ms)}),(0,A.jsx)($f,{label:`Event loop delay max`,value:J(t.eventLoopDelayMaxMs)}),(0,A.jsx)($f,{label:`Event loop utilization`,value:Xu(t.eventLoopUtilization*100,0),trend:r.map(e=>e.eventLoopUtilization)}),(0,A.jsx)($f,{label:`GC runs (last interval)`,value:q(t.gcCount)}),(0,A.jsx)($f,{label:`GC pause (last interval)`,value:J(t.gcPauseMs)}),(0,A.jsx)($f,{label:`External memory`,value:Yu(t.externalBytes)})]}),(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,A.jsx)(Qd,{title:`Memory`,format:Yu,series:[{name:`RSS`,color:`var(--chart-1)`,points:ep(r,e=>e.rssBytes)},{name:`Heap used`,color:`var(--chart-2)`,points:ep(r,e=>e.heapUsedBytes)},{name:`Heap total`,color:`var(--chart-3)`,points:ep(r,e=>e.heapTotalBytes)}]}),(0,A.jsx)(Qd,{title:`Event loop delay`,format:e=>J(e),series:[{name:`p50`,color:`var(--chart-2)`,points:ep(r,e=>e.eventLoopDelayP50Ms)},{name:`p99`,color:`var(--chart-1)`,points:ep(r,e=>e.eventLoopDelayP99Ms)},{name:`max`,color:`var(--chart-4)`,points:ep(r,e=>e.eventLoopDelayMaxMs)}]}),(0,A.jsx)(Qd,{title:`CPU`,format:e=>Xu(e,0),series:[{name:`CPU`,color:`var(--chart-1)`,points:ep(r,e=>e.cpuPercent)}]}),(0,A.jsx)(Qd,{title:`Event loop utilization`,format:e=>Xu(e*100,0),max:1,series:[{name:`ELU`,color:`var(--chart-3)`,points:ep(r,e=>e.eventLoopUtilization)}]})]}),i.length?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Garbage collection since start:`,` `,i.map(([e,t])=>`${e} ${t.count} runs, ${J(t.pauseMs)} paused`).join(` · `)]}):null]})]})}function np({instance:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/resources${dd({instance:e===`all`?void 0:e})}`,{refreshMs:5e3}),a=t?.instances??[],o=e=>Math.max(0,...a.map(e));return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Resources`,description:`Memory, CPU, event loop and garbage collection of each running instance. Updated every 5 seconds.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:i,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),n?(0,A.jsx)(z,{error:n,title:`Could not load the resource readings`,onRetry:i}):null,!t&&r?(0,A.jsx)(Ks,{rows:3}):null,t&&!t.instances.length?(0,A.jsx)(U,{title:`No instance has reported its resources yet. Readings appear a few seconds after the app starts.`,hint:`If the app is running and this stays empty, check that the monitor is enabled.`}):null,a.length?(0,A.jsx)(xd,{items:[{label:`Instances`,value:q(a.length)},{label:`Highest memory (RSS)`,value:Yu(o(e=>e.snapshot.rssBytes))},{label:`Highest CPU`,value:Xu(o(e=>e.snapshot.cpuPercent))},{label:`Worst event loop p99`,value:J(o(e=>e.snapshot.eventLoopDelayP99Ms))}]}):null,(0,A.jsx)(`div`,{className:`space-y-4`,children:t?.instances.map(e=>(0,A.jsx)(tp,{entry:e},e.instance.id))})]})}function rp(e){return e===`ok`?(0,A.jsx)(Y,{tone:`success`,children:`ok`}):e===`error`?(0,A.jsx)(Y,{tone:`destructive`,children:`error`}):(0,A.jsx)(Y,{children:`unknown`})}function ip({history:e}){return e.length?(0,A.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-0.5 p-0`,"aria-label":`Health history, oldest first`,children:e.map(e=>(0,A.jsx)(`li`,{className:`h-6 w-2 rounded-sm`,style:{background:e.status===`ok`?`var(--success)`:`var(--destructive)`},title:`${new Date(e.at).toLocaleTimeString()}: ${e.status}${e.failed.length?` (${e.failed.join(`, `)})`:``}`},e.at))}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet.`})}function ap({instance:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/health${dd({instance:e===`all`?void 0:e})}`,{refreshMs:15e3}),a=t?.instances??[],o=a.filter(e=>e.report.status===`ok`).length,s=a.flatMap(e=>Object.values(e.report.checks)),c=s.filter(e=>!e).length;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Health`,description:`Readiness checks of each instance, updated every 15 seconds.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:i,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),n?(0,A.jsx)(z,{error:n,title:`Could not load the health checks`,onRetry:i}):null,!t&&r?(0,A.jsx)(Ks,{rows:3}):null,t&&!t.instances.length?(0,A.jsx)(U,{title:`No instance has reported a health check yet. The first check runs shortly after the app starts.`,hint:`Register readiness checks in your app to see them here.`}):null,a.length?(0,A.jsx)(xd,{items:[{label:`Instances`,value:q(a.length)},{label:`Ready`,value:`${o} / ${a.length}`,tone:o===a.length?`success`:`destructive`},{label:`Checks`,value:q(s.length)},{label:`Failing checks`,value:q(c),tone:c?`destructive`:`success`}]}):null,(0,A.jsx)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:a.map(({instance:e,report:t})=>{let n=Object.entries(t.checks);return(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsxs)(Zs,{className:`flex items-center gap-2 text-base`,children:[e.label,` `,rp(t.status)]})}),(0,A.jsxs)($s,{className:`space-y-3`,children:[(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Checked `,(0,A.jsx)(ed,{at:t.checkedAt})]}),n.length?(0,A.jsx)(`ul`,{className:`divide-y rounded-lg border text-sm`,children:n.map(([e,t])=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,title:e,children:e}),(0,A.jsx)(Y,{tone:t?`success`:`destructive`,children:t?`passing`:`failing`})]},e))}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No readiness checks are registered.`}),(0,A.jsx)(ip,{history:t.history})]})]},e.id)})})]})}var op=[{value:``,label:`All`},{value:`request`,label:`Requests`},{value:`log`,label:`Logs`}];function sp({instance:e,session:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),c=t.mode===`production`,{data:l,error:u,loading:d,reload:f}=H(`api/errors${dd({instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),{data:p}=H(c?`api/instances`:null),m=(0,_.useMemo)(()=>l?.groups??[],[l]),h=!!i.trim()||!!o,g=(0,_.useMemo)(()=>{let e=i.trim().toLowerCase();return m.filter(t=>(!o||t.source===o)&&(!e||`${t.message} ${t.name??``} ${t.route??``}`.toLowerCase().includes(e)))},[m,i,o]);return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Errors`,description:`Failed requests and error logs, grouped by message, route and source.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:f,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),u?(0,A.jsx)(z,{error:u,title:`Could not load the errors`,onRetry:f}):null,!l&&d?(0,A.jsx)(Ks,{}):null,l&&!l.groups.length?(0,A.jsx)(U,{title:`No errors recorded. Failed requests and error logs appear here.`,hint:`Nothing has failed since the app started.`}):null,m.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{items:[{label:`Error groups`,value:q(m.length),tone:`destructive`},{label:`Occurrences`,value:q(m.reduce((e,t)=>e+t.count,0))},{label:`From requests`,value:q(m.filter(e=>e.source===`request`).length),hint:`groups`},{label:`From logs`,value:q(m.filter(e=>e.source===`log`).length),hint:`groups`}]}),(0,A.jsxs)(X,{label:`Error filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:g.length,total:m.length,noun:`group`}),h?(0,A.jsx)(Td,{onClick:()=>{a(``),s(``)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Search errors`,placeholder:`Search message, name or route`,value:i,onChange:e=>a(e.target.value)}),(0,A.jsx)(Cd,{label:`Source`,options:op,value:o,onChange:s})]})]}):null,m.length&&!g.length?(0,A.jsx)(U,{title:`No error group matches these filters.`,hint:`Clear the filters to see every group.`}):null,g.length?(0,A.jsxs)(Ed,{label:`Error groups`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Message`}),(0,A.jsx)(G,{className:Z,children:`Route`}),(0,A.jsx)(G,{className:`${Z} text-right`,children:`Status`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Count`}),(0,A.jsx)(G,{className:Z,children:`First seen`}),(0,A.jsx)(G,{className:Z,children:`Last seen`}),c?(0,A.jsx)(G,{className:Z,children:`Instances`}):null]})}),(0,A.jsx)(pu,{children:g.map(e=>(0,A.jsx)(cp,{group:e,open:n===e.id,onToggle:()=>r(n===e.id?null:e.id),production:c,labels:e.instances.map(e=>ud(e,p?.instances)).join(`, `)},e.id))})]}):null]})}function cp({group:e,open:t,onToggle:n,production:r,labels:i}){let a=Dd(n);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(W,{"data-state":t?`selected`:void 0,...a,children:[(0,A.jsxs)(K,{className:`max-w-md min-w-64 whitespace-normal`,children:[(0,A.jsx)(`button`,{type:`button`,className:`text-left font-medium break-words focus-visible:outline-none`,"aria-expanded":t,onClick:e=>{e.stopPropagation(),n()},children:e.message}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[e.name?(0,A.jsx)(`span`,{className:`font-mono`,children:e.name}):null,e.source===`log`?(0,A.jsx)(Y,{children:`log`}):null]})]}),(0,A.jsx)(K,{className:`max-w-48 font-mono text-xs`,children:(0,A.jsx)(`div`,{className:`truncate`,title:e.route??void 0,children:e.route??`—`})}),(0,A.jsx)(K,{className:`text-right`,children:e.status==null?`—`:(0,A.jsx)(hd,{status:e.status})}),(0,A.jsx)(K,{className:`${Q} font-semibold`,children:q(e.count)}),(0,A.jsx)(K,{className:`text-xs text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.firstSeen})}),(0,A.jsx)(K,{className:`text-xs`,children:(0,A.jsx)(ed,{at:e.lastSeen})}),r?(0,A.jsx)(K,{className:`text-xs whitespace-normal`,children:i||`—`}):null]}),t?(0,A.jsx)(W,{children:(0,A.jsxs)(K,{colSpan:r?7:6,className:`bg-muted/20 whitespace-normal`,children:[e.stack?(0,A.jsx)(Md,{children:e.stack}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No stack was available for this error.`}),e.lastRequestId?(0,A.jsx)(`p`,{className:`mt-2 text-sm`,children:(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(e.lastRequestId)}`,children:`Open the last request`})}):null]})}):null]})}var lp=[``,`debug`,`info`,`warn`,`error`,`success`],up=300;function dp({instance:e,session:t}){let n=t.mode===`production`,[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)([]),{data:d,error:f,loading:p,reload:m}=H(`api/logs${dd({level:r,module:a,instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),{data:h}=H(n?`api/instances`:null);lu([`log`],(0,_.useCallback)(e=>{if(e.type!==`log`)return;let t=e.data;u(e=>[{...t,instance:t.instance??null},...e].slice(0,up))},[]));let g=(0,_.useMemo)(()=>{if(!d)return[];let e=d[0]?.at??0;return[...l.filter(t=>t.at>e&&(!r||t.level===r)&&(!a||t.module.toLowerCase().includes(a.toLowerCase()))),...d].slice(0,up)},[d,l,r,a]),v=(0,_.useMemo)(()=>{let e=s.trim().toLowerCase();return e?g.filter(t=>`${t.message} ${t.action}`.toLowerCase().includes(e)):g},[g,s]),y=!!r||!!a||!!s.trim(),b=e=>g.filter(t=>t.level===e).length;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Logs`,description:n?`Warnings and errors, without their context. Newest first.`:`What your app logged, newest first, with live entries as they arrive.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:m,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),g.length?(0,A.jsx)(xd,{items:[{label:`Entries`,value:q(g.length),hint:`loaded`},{label:`Errors`,value:q(b(`error`)),tone:b(`error`)?`destructive`:`success`},{label:`Warnings`,value:q(b(`warn`)),tone:b(`warn`)?`warning`:`success`},{label:`Modules`,value:q(new Set(g.map(e=>e.module)).size)}]}):null,(0,A.jsxs)(X,{label:`Log filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:v.length,total:g.length,noun:`entry`}),y?(0,A.jsx)(Td,{onClick:()=>{i(``),o(``),c(``)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Search messages`,placeholder:`Search messages`,value:s,onChange:e=>c(e.target.value)}),(0,A.jsx)(Sd,{label:`Filter module`,placeholder:`Filter module`,className:`max-w-56 min-w-36 flex-none`,value:a,onChange:e=>o(e.target.value)}),(0,A.jsx)(Cd,{label:`Level`,value:r,onChange:i,options:lp.map(e=>({value:e,label:e||`All`}))})]}),f?(0,A.jsx)(z,{error:f,title:`Could not load the logs`,onRetry:m}):null,!d&&p?(0,A.jsx)(Ks,{}):null,d&&!v.length?(0,A.jsx)(U,{title:`No logs found for these filters.`,hint:y?`Clear the filters, or pick a lower level to see more.`:`Entries appear here as your app logs them.`}):null,v.length?(0,A.jsxs)(Ed,{label:`Logs`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Time`}),(0,A.jsx)(G,{className:Z,children:`Level`}),(0,A.jsx)(G,{className:Z,children:`Source`}),(0,A.jsx)(G,{className:Z,children:`Message`})]})}),(0,A.jsx)(pu,{children:v.map((e,t)=>(0,A.jsxs)(W,{className:`align-top`,children:[(0,A.jsx)(K,{className:`w-24 text-xs text-muted-foreground tabular-nums`,title:new Date(e.at).toLocaleString(),children:td(e.at)}),(0,A.jsx)(K,{className:`w-20`,children:(0,A.jsx)(yd,{level:e.level})}),(0,A.jsxs)(K,{className:`max-w-48 text-xs`,children:[(0,A.jsxs)(`div`,{className:`truncate font-medium`,title:`${e.module} · ${e.action}`,children:[e.module,` · `,e.action]}),(0,A.jsxs)(`div`,{className:`flex gap-2 text-muted-foreground`,children:[n&&e.instance?(0,A.jsx)(`span`,{children:ud(e.instance,h?.instances)}):null,e.requestId?(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(e.requestId)}`,children:`request`}):null]})]}),(0,A.jsxs)(K,{className:`min-w-64 text-sm whitespace-normal`,children:[(0,A.jsx)(`div`,{className:`break-words`,children:e.message}),e.context===void 0?null:(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground`,children:`Context`}),(0,A.jsx)(id,{value:e.context})]})]})]},`${e.at}-${t}`))})]}):null]})}var fp={success:`bg-emerald-500`,failed:`bg-destructive`,skipped:`bg-muted-foreground/40`};function pp({runs:e}){return e?.length?(0,A.jsx)(`span`,{className:`inline-flex items-center gap-1`,"aria-label":`Recent runs`,children:e.map(e=>(0,A.jsx)(`span`,{role:`img`,"aria-label":`${e.outcome} run`,title:[`${e.outcome}, ${J(e.durationMs)}`,new Date(e.startedAt).toLocaleString(),e.error??e.skipReason].filter(Boolean).join(` - `),className:`inline-block h-3 w-1.5 rounded-sm ${fp[e.outcome]}`},e.startedAt+e.outcome))}):(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}function mp({report:e}){return e.available.scheduler?e.schedules.length?(0,A.jsxs)(Ed,{label:`Schedules`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Name`}),(0,A.jsx)(G,{className:Z,children:`Schedule`}),(0,A.jsx)(G,{className:Z,children:`Last run`}),(0,A.jsx)(G,{className:Z,children:`Next run`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Duration`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Failures`}),(0,A.jsx)(G,{className:Z,children:`Recent runs`}),(0,A.jsx)(G,{className:Z,children:`Last error`})]})}),(0,A.jsx)(pu,{children:e.schedules.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{className:`font-mono text-xs`,children:[e.name,` `,e.isRunning?(0,A.jsx)(Y,{tone:`info`,children:`running`}):null]}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.cron??e.interval??`—`}),(0,A.jsx)(K,{className:`text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.lastRunAt})}),(0,A.jsx)(K,{children:(0,A.jsx)(ed,{at:e.nextRunAt})}),(0,A.jsx)(K,{className:Q,children:J(e.lastDurationMs)}),(0,A.jsx)(K,{className:Q,children:q(e.runs)}),(0,A.jsx)(K,{className:Q,children:e.failures?(0,A.jsx)(Y,{tone:`destructive`,mono:!0,children:e.failures}):`—`}),(0,A.jsx)(K,{children:(0,A.jsx)(pp,{runs:e.recentRuns})}),(0,A.jsx)(K,{className:`max-w-xs text-xs whitespace-normal text-destructive`,children:e.lastError??`—`})]},e.name))})]}):(0,A.jsx)(U,{title:`No scheduled jobs are registered.`,hint:`Jobs you register with the scheduler appear here with their next run.`}):(0,A.jsx)(U,{title:`The scheduler is not installed in this app. Install @warlock.js/scheduler to see its jobs here.`,hint:`Add the package, register a job and restart the app.`})}function hp({report:e}){if(!e.available.queue)return(0,A.jsx)(U,{title:`The queue is not installed in this app. Install @warlock.js/queue to see its job counts here.`,hint:`Add the package, dispatch a job and restart the app.`});if(!e.queues.length)return(0,A.jsx)(U,{title:`No queue reported job counts.`,hint:`Counts appear once a queue has handled a job.`});let t=[...new Set(e.queues.flatMap(e=>Object.keys(e.counts)))];return(0,A.jsxs)(Ed,{label:`Queues`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Queue`}),t.length===0?(0,A.jsx)(G,{className:Z,children:`Counts`}):null,t.map(e=>(0,A.jsx)(G,{className:`${Z} ${Q}`,children:e},e))]})}),(0,A.jsx)(pu,{children:e.queues.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.name}),e.countsAvailable===!1?(0,A.jsx)(K,{colSpan:Math.max(t.length,1),className:`text-xs text-muted-foreground`,children:`Counts not available: this queue driver cannot count jobs.`}):null,e.countsAvailable===!1?null:t.map(t=>(0,A.jsx)(K,{className:`${Q} ${t===`failed`&&e.counts[t]?`font-semibold text-destructive`:``}`,children:q(e.counts[t]??0)},t))]},e.name))})]})}function gp({instance:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/jobs${dd({instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),a=(t?.instances??[]).map(e=>e.report),o=a.flatMap(e=>e.schedules),s=o.filter(e=>e.isRunning).length,c=o.filter(e=>e.lastError).length,l=a.flatMap(e=>e.queues).reduce((e,t)=>e+(t.counts.failed??0),0);return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Jobs`,description:`Scheduled jobs with their next run, and the job counts of each queue.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:i,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),n?(0,A.jsx)(z,{error:n,title:`Could not load the jobs`,onRetry:i}):null,!t&&r?(0,A.jsx)(Ks,{rows:3}):null,t&&!t.instances.length?(0,A.jsx)(U,{title:`No instance has reported its jobs yet.`,hint:`Reports arrive a few seconds after the app starts.`}):null,t?.instances.length?(0,A.jsx)(xd,{items:[{label:`Scheduled jobs`,value:q(o.length)},{label:`Running now`,value:q(s),tone:s?`info`:`neutral`},{label:`Jobs with a last error`,value:q(c),tone:c?`destructive`:`success`},{label:`Failed queue jobs`,value:q(l),tone:l?`destructive`:`success`}]}):null,(0,A.jsx)(`div`,{className:`space-y-4`,children:t?.instances.map(({instance:e,report:t})=>(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsx)(Zs,{className:`text-base`,children:e.label})}),(0,A.jsxs)($s,{className:`space-y-5`,children:[(0,A.jsxs)(`section`,{"aria-label":`Schedules on ${e.label}`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Schedules`}),(0,A.jsx)(mp,{report:t})]}),(0,A.jsxs)(`section`,{"aria-label":`Queues on ${e.label}`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Queues`}),(0,A.jsx)(hp,{report:t})]})]})]},e.id))})]})}function _p({id:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/mails/${encodeURIComponent(e)}`),[a,o]=(0,_.useState)(!0);if(n&&!t)return(0,A.jsx)(z,{error:n,title:`Could not load this message`,onRetry:i});if(!t)return r?(0,A.jsx)(Ks,{rows:4}):null;let s=[[`From`,t.from],[`To`,t.to?.join(`, `)],[`Cc`,t.cc?.join(`, `)],[`Bcc`,t.bcc?.join(`, `)],...Object.entries(t.headers??{})];return(0,A.jsxs)(`section`,{"aria-label":`Mail detail`,className:`space-y-3`,children:[(0,A.jsx)(`h2`,{className:`text-base font-semibold break-words`,children:t.subject||`(No subject)`}),(0,A.jsxs)(Ad,{title:`Headers`,children:[(0,A.jsx)(`table`,{className:`w-full text-sm`,children:(0,A.jsx)(`tbody`,{children:s.map(([e,t])=>(0,A.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,A.jsx)(`th`,{className:`w-24 py-1.5 pr-3 text-left align-top text-xs font-medium text-muted-foreground`,children:e}),(0,A.jsx)(`td`,{className:`py-1.5 break-all`,children:t||`—`})]},e))})}),t.requestId?(0,A.jsx)(`p`,{className:`text-sm`,children:(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(t.requestId)}`,children:`Open the request that sent it`})}):null]}),(0,A.jsx)(Ad,{title:`Body`,actions:(0,A.jsxs)(`div`,{className:`flex gap-1`,children:[(0,A.jsx)(cd,{active:a,onClick:()=>o(!0),children:`HTML`}),(0,A.jsx)(cd,{active:!a,onClick:()=>o(!1),children:`Text`})]}),children:a?(0,A.jsx)(`iframe`,{className:`h-96 w-full rounded-lg border bg-white`,sandbox:``,src:`api/mails/${encodeURIComponent(t.id)}/html`,title:`HTML email body`}):(0,A.jsx)(Md,{children:t.text||`No plain-text body.`})}),(0,A.jsx)(Ad,{title:`Attachments`,children:t.attachments?.length?(0,A.jsx)(`ul`,{className:`list-disc pl-5 text-sm`,children:t.attachments.map((e,t)=>(0,A.jsxs)(`li`,{children:[e.filename,` · `,e.contentType||`unknown type`,` · `,q(e.size),` `,`bytes`]},`${e.filename}-${t}`))}):(0,A.jsx)(U,{title:`No attachments.`})})]})}function vp({route:e,navigate:t}){let{data:n,error:r,loading:i,reload:a}=H(`api/mails`,{refreshMs:3e4}),[o,s]=(0,_.useState)([]);lu([`mail`],(0,_.useCallback)(e=>{if(e.type!==`mail`)return;let t=e.data;s(e=>[t,...e.filter(e=>e.id!==t.id)].slice(0,200))},[]));let c=(0,_.useMemo)(()=>{if(!n)return[];let e=new Set(o.map(e=>e.id));return[...o,...n.filter(t=>!e.has(t.id))]},[n,o]),[l,u]=(0,_.useState)(``),d=l.trim().toLowerCase(),f=d?c.filter(e=>`${e.subject} ${e.to.join(` `)}`.toLowerCase().includes(d)):c,p=new Set(c.flatMap(e=>e.to)).size,m=c.filter(e=>e.requestId).length;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Mail`,description:`Every email your app sent, caught here instead of delivered. Open one to check its headers and body.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:a,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),c.length?(0,A.jsx)(xd,{items:[{label:`Messages`,value:q(c.length)},{label:`Recipients`,value:q(p),hint:`distinct addresses`},{label:`Sent by a request`,value:q(m)},{label:`Latest`,value:(0,A.jsx)(ed,{at:c[0]?.capturedAt})}]}):null,(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[c.length?(0,A.jsx)(X,{label:`Mail filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:f.length,total:c.length,noun:`message`}),d?(0,A.jsx)(Td,{onClick:()=>u(``)}):null]}),children:(0,A.jsx)(Sd,{label:`Search mail`,placeholder:`Search subject or recipient`,value:l,onChange:e=>u(e.target.value)})}):null,r?(0,A.jsx)(z,{error:r,title:`Could not load the mailbox`,onRetry:a}):null,!n&&i?(0,A.jsx)(Ks,{}):null,n&&!c.length?(0,A.jsx)(U,{title:`No mail captured. Send an email from your app; it appears here.`,hint:`Messages arrive live; there is nothing to configure.`}):null,c.length&&!f.length?(0,A.jsx)(U,{title:`No message matches this search.`,hint:`Clear the search to see every message.`}):null,(0,A.jsx)(`div`,{className:`space-y-1.5`,children:f.map(n=>(0,A.jsxs)(ld,{selected:n.id===e,className:`rounded-xl bg-card p-3`,onClick:()=>t(n.id),children:[(0,A.jsx)(`div`,{className:`font-medium break-words`,children:n.subject||`(No subject)`}),(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:n.to.join(`, `)}),n.requestId?(0,A.jsx)(Y,{tone:`info`,children:`from a request`}):null,(0,A.jsx)(ed,{at:n.capturedAt,className:`ml-auto`})]})]},n.id))})]}),(0,A.jsx)(`div`,{className:`min-w-0`,children:e?(0,A.jsx)(_p,{id:e},e):(0,A.jsx)(U,{title:`Select a message to inspect it.`,hint:`Its headers, HTML body and attachments open here.`})})]})]})}function yp({answer:e}){return(0,A.jsxs)(`div`,{className:`flex flex-col items-center rounded-xl border border-dashed bg-card/50 px-6 py-10 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 grid size-10 place-items-center rounded-full bg-brand/10 text-brand`,children:(0,A.jsx)(As,{className:`size-5`,"aria-hidden":`true`})}),(0,A.jsx)(`p`,{className:`text-sm font-semibold`,children:e.title??`AI data is not available`}),e.message?(0,A.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:e.message}):null,e.command?(0,A.jsxs)(`div`,{className:`mt-4 flex max-w-full items-center gap-2 rounded-md border bg-muted px-3 py-2`,children:[(0,A.jsx)(`code`,{className:`overflow-x-auto font-mono text-xs`,children:e.command}),(0,A.jsx)(Dc,{value:e.command,size:`xs`})]}):null,e.detail?(0,A.jsx)(`p`,{className:`mt-4 max-w-md break-words rounded-md border bg-muted px-3 py-2 font-mono text-xs text-muted-foreground`,children:e.detail}):null]})}function bp(e){return e==null||Number.isNaN(e)?`—`:e===0?`$0`:e>=1?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:`$${e.toFixed(4)}`}function xp(e){if(e==null||Number.isNaN(e))return`—`;let t=(t,n)=>{let r=e/t;return`${r>=100?Math.round(r):r.toFixed(1).replace(/\.0$/,``)}${n}`};return e>=1e9?t(1e9,`B`):e>=1e6?t(1e6,`M`):e>=1e3?t(1e3,`k`):String(Math.round(e))}function Sp(e){if(e==null||Number.isNaN(e))return`—`;let t=e*100;return t===0?`0%`:t>0&&t<.05?`<0.1%`:t<10?`${t.toFixed(1).replace(/\.0$/,``)}%`:`${Math.round(t)}%`}function Cp(e){return e==null||Number.isNaN(e)?`—`:e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)} s`:`${(e/6e4).toFixed(1).replace(/\.0$/,``)} min`}function wp(e){if(e.preset===`24h`)return`previous 24 hours`;if(e.preset===`7d`)return`previous 7 days`;if(e.preset===`30d`)return`previous 30 days`;let t=Math.round((e.to-e.from)/36e5);return t<=48?`previous ${t} hours`:`previous ${Math.round(t/24)} days`}function Tp(){return(0,A.jsxs)(Y,{tone:`warning`,children:[(0,A.jsx)(Is,{className:`size-3`,"aria-hidden":`true`}),`No pricing`]})}function Ep({state:e}){return e===`missing`?(0,A.jsx)(Tp,{}):e===`no-tokens`?(0,A.jsxs)(Y,{tone:`neutral`,children:[(0,A.jsx)(Mo,{className:`size-3`,"aria-hidden":`true`}),`No tokens used`]}):e===`partial`?(0,A.jsxs)(Y,{tone:`info`,children:[(0,A.jsx)(Ao,{className:`size-3`,"aria-hidden":`true`}),`Partly priced`]}):(0,A.jsxs)(Y,{tone:`success`,children:[(0,A.jsx)(Oo,{className:`size-3`,"aria-hidden":`true`}),`Pricing set`]})}function Dp(e){return typeof e==`number`&&Number.isFinite(e)?e:e&&typeof e==`object`?Object.values(e).reduce((e,t)=>e+Dp(t),0):0}function Op(e){let t=e.children.reduce((e,t)=>e+Dp(t.usage?.cost),0),n=Math.max(0,Dp(e.usage?.cost)-t);return n>0?n:null}function kp(e){return Math.max(Op(e)??0,...e.children.map(kp))}function Ap(e,t){if(!(e===null||t<=0))return`color-mix(in srgb, var(--brand) ${(5+20*Math.min(1,e/t)).toFixed(1)}%, transparent)`}function jp(e){return e===`completed`||e===`ok`?`success`:e===`incomplete`?`warning`:e===`error`||e===`failed`?`destructive`:`neutral`}var Mp=e=>e==null?`—`:String(e);function Np(e,t){let n=e.inputIncludesCache===!1?`input excludes cache tokens`:`input includes cache tokens`;return`${Mp(e.input)} input · ${Mp(e.output)} output · ${Mp(e.cachedTokens)} cache read · ${Mp(e.cacheWriteTokens)} cache write · ${t==null?`no pricing`:`${bp(t)} estimated`} (${n})`}function Pp({run:e}){return(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(Y,{tone:jp(e.status),children:e.status}),(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.traceId.slice(0,8)}),e.cost===null&&e.usage.total>0?(0,A.jsx)(Tp,{}):null]}),(0,A.jsx)(`div`,{className:`font-medium break-words`,children:`${e.name} · ${e.status}${e.incomplete?` · Incomplete / truncated`:``} · ${e.duration} ms`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground break-words`,children:e.models.join(`, `)||`Model unreported`}),(0,A.jsx)(`p`,{className:`text-sm`,children:Np(e.usage,e.cost)}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`${e.toolCalls} tool calls · ${e.retries} retries${e.promptKey?` · prompt ${e.promptKey}`:``}`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`${e.traceId} · ${e.requestId?`Request ${e.requestId}`:`Background / no request id`}`})]})}function Fp({span:e,rootStartedAt:t,maxCost:n}){let r=e.status===`incomplete`||e.error?.type===`AgentIncompleteError`||e.error?.type===`AGENT_INCOMPLETE`,i=Date.parse(e.startedAt)-Date.parse(t),a=Op(e);return(0,A.jsxs)(`details`,{open:!0,className:`ml-3 border-l-2 pl-2`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer rounded-sm px-1 text-sm`,style:{background:Ap(a,n)},children:[`${e.type} ${e.name} · ${e.status}${r?` · Incomplete / truncated`:``} · +${i} ms · ${e.duration} ms`,a===null?null:(0,A.jsx)(`span`,{className:`ml-2 tabular-nums text-muted-foreground`,children:`· ${bp(a)} estimated`})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`${e.startedAt} → ${e.endedAt}`}),(0,A.jsx)(id,{value:{usage:e.usage,attributes:e.attributes,error:e.error}}),e.children.map((e,r)=>(0,A.jsx)(Fp,{span:e,rootStartedAt:t,maxCost:n},`${e.name}-${r}`))]})}function Ip({run:e,traceId:t,onClose:n}){let{data:r,error:i,loading:a,reload:o}=H(`api/ai/runs/${encodeURIComponent(t)}`);return(0,A.jsxs)(`section`,{"aria-label":`AI run detail`,className:`space-y-3 rounded-xl border bg-card p-3.5`,children:[(0,A.jsx)($,{onClick:n,children:`Close run`}),e?(0,A.jsx)(Pp,{run:e}):null,e?.requestId?(0,A.jsx)(`a`,{className:`inline-block rounded-md border px-3 py-1 text-sm hover:bg-muted/60 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,href:`#requests/${encodeURIComponent(e.requestId)}`,children:`Open HTTP request`}):null,i?(0,A.jsx)(z,{error:i,title:`Could not load this run's spans`,onRetry:o}):null,!r&&a?(0,A.jsx)(Ks,{rows:3}):null,r?(0,A.jsx)(Fp,{span:r.root,rootStartedAt:r.startedAt,maxCost:kp(r.root)}):null]})}var Lp={q:``,requestId:``,status:``,type:``,session:``,prompt:``,groupBy:``};function Rp(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r.trim()&&t.set(n,r.trim());let n=t.toString();return`api/ai/runs${n?`?${n}`:``}`}function zp(e,t){return e===`session`?{session:t.key}:e===`prompt`?{prompt:t.key}:{type:t.key}}function Bp({route:e,navigate:t}){let[n,r]=(0,_.useState)(Lp),[i,a]=(0,_.useState)(Lp),{data:o,error:s,loading:c,reload:l}=H(Rp(i));lu([`ai`],(0,_.useCallback)(()=>l(),[l]));let u=e=>{r(e),a(e),t(``)},d=Object.values(i).some(Boolean),f=(o?.available?o.runs:[]).find(t=>t.traceId===e);return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Runs`,description:`Every AI run your app made: tokens, estimated cost, retries and the span tree of each one.`}),(0,A.jsxs)(X,{label:`AI run filters`,onSubmit:()=>u(n),trailing:d?(0,A.jsx)(R,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>u(Lp),children:`Clear filters`}):void 0,children:[(0,A.jsx)(Sd,{label:`Search AI runs`,placeholder:`Search runs`,value:n.q,onChange:e=>r({...n,q:e.target.value})}),(0,A.jsx)(Sd,{label:`HTTP request id`,placeholder:`Request id`,value:n.requestId,onChange:e=>r({...n,requestId:e.target.value})}),(0,A.jsxs)(sd,{"aria-label":`Status`,value:n.status,onChange:e=>u({...n,status:e.target.value}),children:[(0,A.jsx)(`option`,{value:``,children:`Any status`}),(0,A.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,A.jsx)(`option`,{value:`failed`,children:`Failed`}),(0,A.jsx)(`option`,{value:`incomplete,max-iterations`,children:`Incomplete`})]}),(0,A.jsxs)(sd,{"aria-label":`Type`,value:n.type,onChange:e=>u({...n,type:e.target.value}),children:[(0,A.jsx)(`option`,{value:``,children:`Any type`}),(0,A.jsx)(`option`,{value:`agent`,children:`Agent`}),(0,A.jsx)(`option`,{value:`workflow`,children:`Workflow`}),(0,A.jsx)(`option`,{value:`supervisor`,children:`Supervisor`})]}),(0,A.jsxs)(sd,{"aria-label":`Group by`,value:n.groupBy,onChange:e=>u({...n,groupBy:e.target.value}),children:[(0,A.jsx)(`option`,{value:``,children:`Group by: None`}),(0,A.jsx)(`option`,{value:`session`,children:`Group by: Session`}),(0,A.jsx)(`option`,{value:`prompt`,children:`Group by: Prompt`}),(0,A.jsx)(`option`,{value:`type`,children:`Group by: Type`})]}),(0,A.jsx)(R,{type:`submit`,size:`sm`,children:`Filter / refresh`})]}),s?(0,A.jsx)(z,{error:s,title:`Could not load the AI runs`,onRetry:l}):null,!o&&c?(0,A.jsx)(Ks,{}):null,o&&!o.available?(0,A.jsx)(yp,{answer:o}):null,o?.available&&!o.runs.length?(0,A.jsx)(U,{title:`No AI runs yet. Enable Panoptic observation and execute a flow; runs appear when collection completes.`,hint:d?`No run matches these filters. Clear them to see all runs.`:void 0}):null,o?.available&&o.runs.length?(0,A.jsxs)(`div`,{className:F(`transition-opacity`,c&&`opacity-60`),children:[(0,A.jsx)(xd,{label:`AI runs summary`,items:[{label:`Runs`,value:q(o.stats.count)},{label:`Failed`,value:q(o.stats.failed),tone:o.stats.failed?`warning`:`success`},{label:`Estimated cost`,value:bp(o.stats.estimatedCostUsd),hint:o.stats.unpricedRuns?`Estimated from model pricing · ${q(o.stats.unpricedRuns)} unpriced ${o.stats.unpricedRuns===1?`run`:`runs`} not in the cost`:`Estimated from model pricing`},{label:`p50`,value:Cp(o.stats.p50Ms)},{label:`p95`,value:Cp(o.stats.p95Ms)}]}),o.groups?(0,A.jsx)(`div`,{className:`mb-4`,children:(0,A.jsxs)(Ed,{label:`Run groups`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Group by ${i.groupBy}`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Failed`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Estimated cost`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`})]})}),(0,A.jsx)(pu,{children:o.groups.map(e=>(0,A.jsxs)(W,{...Dd(()=>u({...i,groupBy:``,...zp(i.groupBy,e)})),"aria-label":`Show runs of ${e.label}`,children:[(0,A.jsx)(K,{className:`max-w-72 truncate font-medium`,children:e.label}),(0,A.jsx)(K,{className:Q,children:q(e.runs)}),(0,A.jsx)(K,{className:Q,children:q(e.failed)}),(0,A.jsx)(K,{className:Q,children:bp(e.estimatedCostUsd)}),(0,A.jsx)(K,{className:Q,children:Cp(e.p95Ms)})]},e.key))})]})}):null,(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`,children:[(0,A.jsx)(`div`,{className:`min-w-0 space-y-1.5`,children:o.runs.map(n=>(0,A.jsx)(ld,{selected:n.traceId===e,className:`rounded-xl bg-card p-3`,onClick:()=>t(n.traceId),children:(0,A.jsx)(Pp,{run:n})},n.traceId))}),(0,A.jsx)(`div`,{className:`min-w-0`,children:e?(0,A.jsx)(Ip,{run:f,traceId:e,onClose:()=>t(``)},e):(0,A.jsx)(U,{title:`Select a run to inspect tools, retries and compaction metadata.`,hint:`Its span tree opens here.`})})]})]}):null]})}function Vp({label:e,heading:t,rows:n,unpriced:r,onOpen:i}){return n.length?(0,A.jsxs)(Ed,{label:e,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:t}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Tokens`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Estimated cost`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Error rate`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`})]})}),(0,A.jsx)(pu,{children:n.map(e=>{let{totals:t}=e;return(0,A.jsxs)(W,{...i?{...Dd(()=>i(e)),"aria-label":`Open ${e.label}`}:{},children:[(0,A.jsxs)(K,{className:`max-w-64 truncate font-medium`,children:[e.label,r?.has(e.key)||t.cost.unpricedRuns>0?(0,A.jsx)(`span`,{className:`ml-2`,children:(0,A.jsx)(Tp,{})}):null]}),(0,A.jsx)(K,{className:Q,children:q(t.runs)}),(0,A.jsx)(K,{className:Q,children:xp(t.tokens.input+t.tokens.output)}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(zf,{share:e.share,children:t.cost.pricedRuns>0?bp(t.cost.estimatedUsd):`—`})}),(0,A.jsx)(K,{className:Q,children:Sp(t.errorRate)}),(0,A.jsx)(K,{className:Q,children:Cp(t.latency.p95Ms)})]},e.key)})})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing in this range.`})}var Hp=e=>e==null?`—`:String(e);function Up({run:e}){return(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,A.jsx)(Y,{tone:jp(e.status),children:e.status})}),(0,A.jsx)(`div`,{className:`font-medium`,children:`${e.agent} · ${e.status} · ${Hp(e.durationMs)} ms`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground break-words`,children:e.model}),(0,A.jsx)(`p`,{className:`text-sm`,children:`${e.turns} turns · ${e.toolCalls} tool calls · ${e.refusals} refused · ${e.usage.input} input · ${e.usage.output} output · ${Zu(e.cost)}`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`${e.runId}${e.requestId?` · Request ${e.requestId}`:``}`})]})}function Wp({call:e}){let t=[`${e.name} · ${e.status} · ${e.durationMs} ms`,...e.refusal?[`refused: ${e.refusal}`]:[],...e.error?[`error: ${e.error.message}`]:[]].join(` · `);return(0,A.jsxs)(`details`,{open:!!(e.refusal||e.error),className:`ml-3 border-l-2 pl-2`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t}),(0,A.jsx)(id,{value:{input:e.input,output:e.output}})]})}function Gp({turn:e}){let t=e.toolsOffered.reduce((e,t)=>e+t.tokens,0),n=e.cost==null?``:` · ${Zu(e.cost)}`;return(0,A.jsxs)(`details`,{open:!0,className:`rounded-lg border bg-card p-2.5`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`turn ${e.index} · ${Hp(e.finishReason)} · ${Math.round(e.durationMs)} ms · ${e.usage.input} input · ${e.usage.output} output${n}`}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`starts from ${e.input} · system prompt ${Hp(e.systemPromptHash)} · tools ${e.toolsHash}`}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tools offered (~${t} tokens): ${e.toolsOffered.map(e=>`${e.name}@${e.schemaHash.slice(0,8)}`).join(`, `)||`none`}`}),e.text?(0,A.jsx)(Md,{children:e.text}):null,e.toolCalls.map((e,t)=>(0,A.jsx)(Wp,{call:e},t)),e.contract.map((e,t)=>(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`contract: ${e.type}${e.tool?` ${e.tool}`:``}${e.name?` ${e.name}`:``}${e.reason?` (${e.reason})`:``}`},t)),e.error?(0,A.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error.message}):null]})}function Kp(e,t){if(!t)return`No earlier run of this agent to compare with.`;let n=e=>new Map(e.turns.flatMap(e=>e.toolsOffered).map(e=>[e.name,e.schemaHash])),r=n(e),i=n(t),a=[...r].filter(([e,t])=>i.has(e)&&i.get(e)!==t),o=[...r.keys()].filter(e=>!i.has(e)),s=[...i.keys()].filter(e=>!r.has(e)),c=e.systemPrompt?.hash===t.systemPrompt?.hash?`same`:`changed`;return c===`same`&&!a.length&&!o.length&&!s.length?`Same system prompt and tool definitions as ${t.runId}.`:`Against ${t.runId}: system prompt ${c}; tools changed: ${a.map(([e])=>e).join(`, `)||`none`}; added: ${o.join(`, `)||`none`}; removed: ${s.join(`, `)||`none`}.`}function qp({run:e,earlier:t,onClose:n}){let{data:r,error:i,loading:a,reload:o}=H(`api/ai/agent-runs/${encodeURIComponent(e.runId)}`),s=H(t?`api/ai/agent-runs/${encodeURIComponent(t.runId)}`:null),c=!!t&&!s.data&&!s.error;return(0,A.jsxs)(`section`,{"aria-label":`Agent run detail`,className:`space-y-2 rounded-xl border bg-card p-3.5`,children:[(0,A.jsx)($,{onClick:n,children:`Close run`}),(0,A.jsx)(Up,{run:e}),i?(0,A.jsx)(z,{error:i,title:`Could not load this agent run`,onRetry:o}):null,!r&&a?(0,A.jsx)(Ks,{rows:3}):null,r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Input: ${r.input}`}),r.systemPrompt?(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`System prompt ${r.systemPrompt.hash}`}),(0,A.jsx)(Md,{children:r.systemPrompt.text??`Text not kept (only the hash is recorded).`})]}):null,(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c?`Comparing with the earlier run…`:Kp(r,s.data)}),Object.entries(r.toolSchemas).map(([e,t])=>(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Tool ${t.name}@${e.slice(0,8)}`}),(0,A.jsx)(Md,{children:`${t.description}\n\n${t.schema??`Schema not kept.`}`})]},e)),r.turns.map(e=>(0,A.jsx)(Gp,{turn:e},e.index)),r.error?(0,A.jsx)(`p`,{className:`text-sm text-destructive`,children:r.error.message}):null]}):null]})}var Jp=-new Date().getTimezoneOffset();function Yp(){let{data:e,error:t,reload:n}=H(`api/ai/reports?range=24h&tz=${Jp}`,{refreshMs:6e4});return t?(0,A.jsx)(z,{error:t,title:`Could not load the agents of the last 24 hours`,onRetry:n,className:`mb-4`}):!e?.available||!e.topAgents.length?null:(0,A.jsxs)(`section`,{"aria-label":`Agents in the last 24 hours`,className:`mb-5`,children:[(0,A.jsx)(nd,{children:`Agents in the last 24 hours`}),(0,A.jsx)(Vp,{label:`Agents in the last 24 hours`,heading:`Agent`,rows:e.topAgents})]})}function Xp({route:e,navigate:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),{data:o,error:s,loading:c,reload:l}=H(`api/ai/agent-runs${i?`?requestId=${encodeURIComponent(i)}`:``}`);lu([`agent-trace`],(0,_.useCallback)(()=>l(),[l]));let u=o?.runs.find(t=>t.runId===e),d=u&&o?o.runs.slice(o.runs.indexOf(u)+1).find(e=>e.agent===u.agent):void 0,f=o?.runs??[];return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Agent runs`,description:`Each agent run with its prompt, tools, turns, tool calls and refusals.`}),(0,A.jsx)(Yp,{}),(0,A.jsxs)(X,{label:`Agent run filters`,onSubmit:()=>{a(n.trim()),t(``),l()},children:[(0,A.jsx)(od,{placeholder:`HTTP request id (empty for all runs)`,"aria-label":`Filter agent runs by HTTP request id`,className:`w-72 max-w-full`,value:n,onChange:e=>r(e.target.value)}),(0,A.jsx)(R,{type:`submit`,size:`sm`,children:`Filter / refresh`})]}),s?(0,A.jsx)(z,{error:s,title:`Could not load the agent runs`,onRetry:l}):null,!o&&c?(0,A.jsx)(Ks,{}):null,o&&!o.available?(0,A.jsx)(U,{title:o.message||`No agent traces yet.`,hint:`Agent traces need the AI package in development.`}):null,o?.available&&!o.runs.length?(0,A.jsx)(U,{title:`No agent runs yet. Execute an agent in development; runs appear as turns finish.`,hint:i?`This request id has no runs. Clear the filter to see all runs.`:void 0}):null,o?.available&&o.runs.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{items:[{label:`Runs`,value:q(f.length)},{label:`Turns`,value:q(f.reduce((e,t)=>e+t.turns,0))},{label:`Tool calls`,value:q(f.reduce((e,t)=>e+t.toolCalls,0))},{label:`Refused calls`,value:q(f.reduce((e,t)=>e+t.refusals,0)),tone:f.some(e=>e.refusals)?`warning`:`success`}]}),(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`,children:[(0,A.jsx)(`div`,{className:`min-w-0 space-y-1.5`,children:o.runs.map(n=>(0,A.jsx)(ld,{selected:n.runId===e,className:`rounded-xl bg-card p-3`,onClick:()=>t(n.runId),children:(0,A.jsx)(Up,{run:n})},n.runId))}),(0,A.jsx)(`div`,{className:`min-w-0`,children:u?(0,A.jsx)(qp,{run:u,earlier:d,onClose:()=>t(``)},u.runId):(0,A.jsx)(U,{title:`Select a run to inspect its prompt, tools, calls and refusals.`,hint:`The turn-by-turn trace opens here.`})})]})]}):null]})}var Zp=[{id:`scalar`,label:`Scalar`,src:`docs`},{id:`swagger`,label:`Swagger UI`,src:`docs/swagger`}],Qp=`warlock-devtools-docs-viewer`;function $p(){try{let e=localStorage.getItem(Qp);return Zp.find(t=>t.id===e)??Zp[0]}catch{return Zp[0]}}function em(e){try{localStorage.setItem(Qp,e)}catch{}}function tm(e){let[t,n]=(0,_.useState)($p);return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(bd,{title:`API`,description:`The reference for every route, generated from your app. Pick a viewer, or download the OpenAPI file or Postman collection.`,children:[(0,A.jsx)(R,{asChild:!0,variant:`outline`,size:`sm`,children:(0,A.jsxs)(`a`,{href:`api/openapi.json`,download:`openapi.json`,children:[(0,A.jsx)(Ko,{}),`OpenAPI JSON`]})}),(0,A.jsx)(R,{asChild:!0,variant:`outline`,size:`sm`,children:(0,A.jsxs)(`a`,{href:`api/postman.json`,download:`postman.json`,children:[(0,A.jsx)(Ko,{}),`Postman collection`]})})]}),(0,A.jsx)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,role:`group`,"aria-label":`Viewer`,children:Zp.map(e=>(0,A.jsx)(cd,{active:e.id===t.id,onClick:()=>{em(e.id),n(e)},children:e.label},e.id))}),(0,A.jsx)(`iframe`,{className:`h-[75vh] w-full rounded-xl border bg-background`,src:t.src,title:`API reference`},t.id)]})}function nm({api:e,errorTitle:t,children:n}){let{data:r,error:i,loading:a,reload:o}=e;return(0,A.jsxs)(A.Fragment,{children:[i?(0,A.jsx)(z,{error:i,title:t,onRetry:o,className:`mb-3`}):null,!r&&a?(0,A.jsx)(Ks,{}):null,r&&!r.available?(0,A.jsx)(yp,{answer:r}):null,r?.available?(0,A.jsx)(`div`,{className:F(`transition-opacity`,a&&`opacity-60`),children:n(r,a)}):null]})}function rm({tone:e=`warning`,children:t}){return(0,A.jsxs)(Vs,{variant:e,className:`mb-3`,children:[(0,A.jsx)(e===`warning`?Is:es,{"aria-hidden":`true`}),(0,A.jsx)(Us,{children:t})]})}var im=`AI observation is off, so new runs are not counted and the figures below are older ones. To count new runs, call ai.config({ panoptic: { observeAll: true } }) and restart the app.`;function am({items:e,label:t}){return(0,A.jsx)(`dl`,{"aria-label":t,className:`mb-4 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-[repeat(auto-fit,minmax(10.5rem,1fr))]`,children:e.map(e=>(0,A.jsxs)(`div`,{className:`min-w-0 rounded-xl border bg-card px-3.5 py-3`,children:[(0,A.jsx)(`dt`,{className:`truncate text-xs text-muted-foreground`,children:e.label}),(0,A.jsx)(`dd`,{className:F(`mt-1 truncate text-2xl font-semibold tracking-tight tabular-nums`,pd[e.tone??`neutral`]),children:e.value}),e.hint?(0,A.jsx)(`p`,{className:`mt-0.5 text-xs break-words text-muted-foreground`,children:e.hint}):null,e.delta?(0,A.jsx)(`p`,{className:`mt-0.5`,children:e.delta}):null]},e.label))})}var om=`devtools.ai.range`,sm=e=>e===`24h`||e===`7d`||e===`30d`;function cm(){try{let e=localStorage.getItem(om);return sm(e)?e:`24h`}catch{return`24h`}}function lm(e){if(e!==`custom`)try{localStorage.setItem(om,e)}catch{}}function um(e){let t=new URLSearchParams(e),n=t.get(`range`),r=Number(t.get(`from`)),i=Number(t.get(`to`)),a=n===`custom`&&Number.isFinite(r)&&Number.isFinite(i)&&r>0&&i>r;return{range:sm(n)?n:a?`custom`:cm(),from:a?r:null,to:a?i:null,agent:t.get(`agent`)??``,model:t.get(`model`)??``,provider:t.get(`provider`)??``}}function dm(e){let t=new URLSearchParams({range:e.range});e.range===`custom`&&e.from&&e.to&&(t.set(`from`,String(e.from)),t.set(`to`,String(e.to)));for(let n of[`agent`,`model`,`provider`]){let r=e[n];r&&t.set(n,r)}return t.toString()}function fm(e){let t=new URLSearchParams(dm(e));return t.set(`tz`,String(-new Date().getTimezoneOffset())),t.toString()}function pm(e,t,n={}){location.hash=`#${e}/${dm({...t,agent:``,model:``,provider:``,...n})}`}var mm=36e5,hm=[{value:`24h`,label:`24 h`},{value:`7d`,label:`7 d`},{value:`30d`,label:`30 d`},{value:`custom`,label:`Custom`}];function gm(e){return new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16)}function _m({label:e,all:t,value:n,options:r,onChange:i}){let a=n&&!r.includes(n)?[n,...r]:r;return(0,A.jsxs)(sd,{"aria-label":e,value:n,className:`max-w-48`,onChange:e=>i(e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:t}),a.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]})}function vm({state:e,filters:t,onChange:n}){let[r,i]=(0,_.useState)(e.range===`custom`),[a,o]=(0,_.useState)(e.from?gm(e.from):``),[s,c]=(0,_.useState)(e.to?gm(e.to):``),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(()=>gm(Date.now())),p=`${e.range}|${e.from}|${e.to}`,[m,h]=(0,_.useState)(p);m!==p&&(h(p),i(e.range===`custom`),o(e.from?gm(e.from):``),c(e.to?gm(e.to):``));let g=()=>{let t=new Date(a).getTime(),r=new Date(s).getTime();if(!Number.isFinite(t)||!Number.isFinite(r)){u(`Pick both a start and an end time, then apply.`);return}if(r<=t){u(`The end must be after the start. Pick a later end time.`);return}if(r>(Math.floor(Date.now()/mm)+1)*mm){u(`The end is in the future. Pick an end time up to now.`);return}u(null),n({...e,range:`custom`,from:t,to:r})},v=t=>n({...e,...t});return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(X,{label:`AI report filters`,children:[(0,A.jsx)(Cd,{label:`Date range`,options:hm,value:r?`custom`:e.range,onChange:e=>{if(e===`custom`){f(gm(Date.now())),i(!0);return}i(!1),u(null);let t=e;lm(t),v({range:t,from:null,to:null})}}),r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(od,{type:`datetime-local`,"aria-label":`Range start`,max:d,value:a,onChange:e=>o(e.target.value)}),(0,A.jsx)(od,{type:`datetime-local`,"aria-label":`Range end`,max:d,value:s,onChange:e=>c(e.target.value)}),(0,A.jsx)(R,{type:`button`,size:`sm`,onClick:g,children:`Apply range`})]}):null,(0,A.jsx)(_m,{label:`Agent`,all:`All agents`,value:e.agent,options:t?.agents??[],onChange:e=>v({agent:e})}),(0,A.jsx)(_m,{label:`Model`,all:`All models`,value:e.model,options:t?.models??[],onChange:e=>v({model:e})}),(0,A.jsx)(_m,{label:`Provider`,all:`All providers`,value:e.provider,options:t?.providers??[],onChange:e=>v({provider:e})})]}),l?(0,A.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-destructive`,children:l}):null]})}var ym=6e4;function bm(e,t){let n=H(`api/ai/${e}?${fm(t)}`,{refreshMs:ym});return{...n,refreshing:n.loading&&n.data!==void 0}}function xm(e,t){return{state:(0,_.useMemo)(()=>um(e),[e]),setState:e=>{lm(e.range),t(dm(e))}}}function Sm({report:e,refreshing:t,openModel:n,openAgent:r}){let{totals:i,previous:a,range:o}=e,s=wp(o),c=e.previousComplete!==!1,l=Tf(e.costByModel.series.filter(e=>!e.other).map(e=>e.key)),u=new Set(e.unpricedModels),d={...e.tokens,series:e.tokens.series.map(e=>({...e,label:{uncached:`Uncached input`,cached:`Cached input`,output:`Output`}[e.key]??e.label}))};return(0,A.jsxs)(A.Fragment,{children:[e.observationOff?(0,A.jsx)(rm,{tone:`info`,children:im}):null,e.unpricedModels.length?(0,A.jsx)(rm,{children:`${e.unpricedModels.length} ${e.unpricedModels.length===1?`model has`:`models have`} no pricing; their runs are not in the cost (${e.unpricedModels.join(`, `)}). Add pricing for them in the AI config to include them.`}):null,(0,A.jsx)(am,{label:`AI report summary`,items:[{label:`Estimated cost`,value:bp(i.cost.estimatedUsd),hint:i.cost.unpricedRuns>0?`Estimated from model pricing · ${q(i.cost.unpricedRuns)} unpriced runs`:`Estimated from model pricing`,delta:(0,A.jsx)(Vf,{current:i.cost.estimatedUsd,previous:a.cost.estimatedUsd,against:s,previousComplete:c})},{label:`Tokens`,value:xp(i.tokens.input+i.tokens.output),hint:`${xp(i.tokens.input)} in · ${xp(i.tokens.output)} out · ${xp(i.tokens.cached)} cached`,delta:(0,A.jsx)(Vf,{current:i.tokens.input+i.tokens.output,previous:a.tokens.input+a.tokens.output,against:s,previousComplete:c})},{label:`Agent runs`,value:q(i.runs),delta:(0,A.jsx)(Vf,{current:i.runs,previous:a.runs,against:s,previousComplete:c})},{label:`Error rate`,value:Sp(i.errorRate),tone:c&&i.errorRate>a.errorRate?`warning`:`neutral`,hint:`${q(i.failed+i.incomplete)} failed or incomplete`,delta:(0,A.jsx)(Vf,{current:i.errorRate,previous:a.errorRate,against:s,previousComplete:c,risingIsBad:!0})},{label:`p95 latency`,value:Cp(i.latency.p95Ms),delta:i.latency.p95Ms!==null&&a.latency.p95Ms!==null?(0,A.jsx)(Vf,{current:i.latency.p95Ms,previous:a.latency.p95Ms,against:s,previousComplete:c,risingIsBad:!0}):null}]}),(0,A.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,A.jsx)(Nf,{title:`Estimated cost by model`,description:`Estimated from model pricing; unpriced models are left out.`,set:e.costByModel,stepMs:o.stepMs,format:bp,color:l,loading:t,emptyText:`No priced runs in this range.`}),(0,A.jsx)(Nf,{title:`Tokens`,set:d,stepMs:o.stepMs,format:xp,color:e=>vf[e]??gf(1),loading:t,emptyText:`No tokens used in this range.`})]}),(0,A.jsx)(`div`,{className:`mt-4`,children:(0,A.jsx)(Rf,{title:`Error rate`,seriesName:`Error rate`,points:e.errorRate,stepMs:o.stepMs,format:Sp,color:gf(4),loading:t,emptyText:`No runs in this range, so there is no error rate.`})}),(0,A.jsx)(nd,{children:`Top agents`}),(0,A.jsx)(Vp,{label:`Top agents`,heading:`Agent`,rows:e.topAgents,onOpen:r}),(0,A.jsx)(nd,{children:`Top models`}),(0,A.jsx)(Vp,{label:`Top models`,heading:`Model`,rows:e.topModels,unpriced:u,onOpen:e=>n(e.key)})]})}function Cm({route:e,navigate:t}){let{state:n,setState:r}=xm(e,t),i=bm(`reports`,n),a=i.data?.available?i.data.filters:void 0;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Reports`,description:`Estimated cost, tokens, errors and latency of your AI runs over a date range. Kept as hourly totals, so they survive restarts.`}),(0,A.jsx)(vm,{state:n,filters:a,onChange:r}),(0,A.jsx)(nm,{api:i,errorTitle:`Could not load the AI report`,children:(e,t)=>(0,A.jsx)(Sm,{report:e,refreshing:t,openModel:e=>{pm(`ai-models`,n,{model:e})},openAgent:()=>{location.hash=`#agents`}})})]})}function wm({view:e,refreshing:t}){let n=Tf(e.runsByModel.series.filter(e=>!e.other).map(e=>e.key)),r=e.models.filter(e=>e.pricing===`missing`||e.pricing===`partial`).length,i=Math.max(0,...e.models.map(e=>e.totals.cost.estimatedUsd));return(0,A.jsxs)(A.Fragment,{children:[e.observationOff?(0,A.jsx)(rm,{tone:`info`,children:im}):null,(0,A.jsx)(am,{label:`Models summary`,items:[{label:`Models used`,value:q(e.models.length)},{label:`Estimated cost`,value:bp(e.totals.cost.estimatedUsd),hint:`Estimated from model pricing`},{label:`Unpriced models`,value:q(r),tone:r?`warning`:`neutral`,hint:r?`Their runs are not in the cost`:`Every model has pricing`},{label:`Fallback rate`,value:Sp(e.totals.runs?e.totals.fallbackRuns/e.totals.runs:0),hint:`${q(e.totals.fallbackRuns)} runs answered by a fallback model`}]}),(0,A.jsx)(Nf,{title:`Runs by model`,set:e.runsByModel,stepMs:e.range.stepMs,format:q,color:n,loading:t,emptyText:`No runs in this range.`}),(0,A.jsx)(nd,{children:`Models`}),e.models.length?(0,A.jsxs)(Ed,{label:`Models`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Model`}),(0,A.jsx)(G,{className:Z,children:`Provider`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Tokens in`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Tokens out`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Estimated cost`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Cost per run`}),(0,A.jsx)(G,{className:Z,children:`Pricing`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Fallback`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Error rate`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p50 / p95`}),(0,A.jsx)(G,{className:Z,children:`Agents`})]})}),(0,A.jsx)(pu,{children:e.models.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`max-w-56 truncate font-medium`,children:e.model}),(0,A.jsx)(K,{className:`text-muted-foreground`,children:e.provider}),(0,A.jsx)(K,{className:Q,children:q(e.totals.runs)}),(0,A.jsx)(K,{className:Q,children:xp(e.totals.tokens.input)}),(0,A.jsx)(K,{className:Q,children:xp(e.totals.tokens.output)}),(0,A.jsx)(K,{className:Q,children:e.pricing===`missing`||e.pricing===`no-tokens`?`—`:(0,A.jsx)(zf,{share:i>0?e.totals.cost.estimatedUsd/i:0,children:bp(e.totals.cost.estimatedUsd)})}),(0,A.jsx)(K,{className:Q,children:e.costPerRunUsd===null?`—`:bp(e.costPerRunUsd)}),(0,A.jsx)(K,{children:(0,A.jsx)(Ep,{state:e.pricing})}),(0,A.jsx)(K,{className:Q,children:Sp(e.fallbackRate)}),(0,A.jsx)(K,{className:Q,children:Sp(e.totals.errorRate)}),(0,A.jsx)(K,{className:Q,children:`${Cp(e.totals.latency.p50Ms)} / ${Cp(e.totals.latency.p95Ms)}`}),(0,A.jsx)(K,{className:`max-w-56 truncate text-xs text-muted-foreground`,children:e.agents.join(`, `)||`—`})]},e.key))})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No models used in this range.`})]})}function Tm({route:e,navigate:t}){let{state:n,setState:r}=xm(e,t),i=bm(`models`,n),a=i.data?.available?i.data.filters:void 0;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Models`,description:`Every model your AI runs used in the date range, with its cost, pricing state, latency and error rate.`}),(0,A.jsx)(vm,{state:n,filters:a,onChange:r}),(0,A.jsx)(nm,{api:i,errorTitle:`Could not load the models`,children:(e,t)=>(0,A.jsx)(wm,{view:e,refreshing:t})})]})}var Em=e=>e.map(e=>`${e.key} (${e.count})`).join(`, `)||`—`;function Dm({view:e,refreshing:t}){let n=Tf(e.overTime.series.filter(e=>!e.other).map(e=>e.key),`errors`),{totals:r,previous:i}=e,a=wp(e.range),o=r.failed+r.incomplete,s=i.failed+i.incomplete,c=e.previousComplete!==!1;return(0,A.jsxs)(A.Fragment,{children:[e.observationOff?(0,A.jsx)(rm,{tone:`info`,children:im}):null,(0,A.jsx)(am,{label:`Errors summary`,items:[{label:`Failed runs`,value:q(o),tone:o?`warning`:`neutral`,hint:`Failed plus incomplete`,delta:(0,A.jsx)(Vf,{current:o,previous:s,against:a,previousComplete:c,risingIsBad:!0})},{label:`Error rate`,value:Sp(r.errorRate),delta:(0,A.jsx)(Vf,{current:r.errorRate,previous:i.errorRate,against:a,previousComplete:c,risingIsBad:!0})},{label:`Refusals`,value:q(r.refusals),hint:`Provider refused or filtered`},{label:`Cancelled`,value:q(r.cancelled),hint:`Not counted as errors`}]}),(0,A.jsx)(Nf,{title:`Failed runs by category`,set:e.overTime,stepMs:e.range.stepMs,format:q,color:n,loading:t,emptyText:`No failed runs in this range.`}),(0,A.jsx)(nd,{children:`Categories`}),e.groups.length?(0,A.jsxs)(Ed,{label:`Failed runs by category`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Category`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Change`}),(0,A.jsx)(G,{className:Z,children:`Top models`}),(0,A.jsx)(G,{className:Z,children:`Top agents`})]})}),(0,A.jsx)(pu,{children:e.groups.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`font-medium`,children:e.label}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(zf,{share:e.share,children:q(e.count)})}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(Vf,{current:e.count,previous:e.previousCount,against:`previous period`,previousComplete:c,risingIsBad:!0})}),(0,A.jsx)(K,{className:`max-w-64 truncate text-xs text-muted-foreground`,children:Em(e.byModel)}),(0,A.jsx)(K,{className:`max-w-64 truncate text-xs text-muted-foreground`,children:Em(e.byAgent)})]},e.category))})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No failed runs in this range.`}),(0,A.jsx)(nd,{children:`Recent failed runs`}),e.recent===null?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Production keeps hourly totals, not run details. Open Runs in development (warlock dev) to see the failed runs themselves.`}):e.recent.length?(0,A.jsxs)(Ed,{label:`Recent failed runs`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`When`}),(0,A.jsx)(G,{className:Z,children:`Agent`}),(0,A.jsx)(G,{className:Z,children:`Model`}),(0,A.jsx)(G,{className:Z,children:`Category`}),(0,A.jsx)(G,{className:Z,children:`Error`}),(0,A.jsx)(G,{className:Z,children:`Run`})]})}),(0,A.jsx)(pu,{children:e.recent.map((e,t)=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`whitespace-nowrap text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.endedAt})}),(0,A.jsx)(K,{className:`font-medium`,children:e.agent}),(0,A.jsx)(K,{className:`text-muted-foreground`,children:e.model??`—`}),(0,A.jsx)(K,{children:(0,A.jsx)(Y,{tone:`destructive`,children:e.category})}),(0,A.jsxs)(K,{className:`max-w-md text-xs whitespace-normal break-words`,children:[e.code?(0,A.jsx)(`span`,{className:`font-mono`,children:e.code}):null,e.message?(0,A.jsx)(`span`,{className:`block text-muted-foreground`,children:e.message}):null]}),(0,A.jsx)(K,{children:(0,A.jsx)(`a`,{className:`text-brand underline-offset-2 hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,href:`#ai/${encodeURIComponent(e.traceId)}`,children:`Open run`})})]},`${e.traceId}:${t}`))})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No recent failed runs are kept in memory.`})]})}function Om({route:e,navigate:t}){let{state:n,setState:r}=xm(e,t),i=bm(`errors`,n),a=i.data?.available?i.data.filters:void 0;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Errors`,description:`Failed and incomplete AI runs grouped by what went wrong: rate limits, timeouts, refusals, provider errors and more.`}),(0,A.jsx)(vm,{state:n,filters:a,onChange:r}),(0,A.jsx)(nm,{api:i,errorTitle:`Could not load the AI errors`,children:(e,t)=>(0,A.jsx)(Dm,{view:e,refreshing:t})})]})}var km=`ai.config({
50
+ `);return(0,A.jsxs)(`div`,{className:`grid gap-4`,children:[(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Each code works once if you lose your authenticator. They are shown only now: save them somewhere safe before you continue.`}),(0,A.jsx)(`ul`,{className:`grid grid-cols-2 gap-2 rounded-md border bg-muted p-3 font-mono text-sm`,"aria-label":`Recovery codes`,children:e.map(e=>(0,A.jsx)(`li`,{children:e},e))}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(Dc,{value:a,label:`Copy codes`}),(0,A.jsxs)(R,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{let e=URL.createObjectURL(new Blob([`${a}\n`],{type:`text/plain`})),t=document.createElement(`a`);t.href=e,t.download=`warlock-devtools-recovery-codes.txt`,t.click(),URL.revokeObjectURL(e)},children:[(0,A.jsx)(Ko,{}),`Download .txt`]})]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),`I saved them`]}),(0,A.jsx)(R,{type:`button`,disabled:!r,onClick:t,children:n})]})}var kc=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(kc||{}),Ac=Object.defineProperty,jc=(e,t,n)=>t in e?Ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mc=(e,t,n)=>(jc(e,typeof t==`symbol`?t:t+``,n),n),Nc=[0,1],Pc=[1,0],Fc=[2,3],Ic=[3,2],Lc={L:Nc,M:Pc,Q:Fc,H:Ic},Rc=/^[0-9]*$/,zc=/^[A-Z0-9 $%*+.\/:-]*$/,Bc=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,Vc=1,Hc=40,Uc=3,Wc=3,Gc=40,Kc=10,qc=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Jc=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Yc=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,Mc(this,`size`),Mc(this,`mask`),Mc(this,`modules`,[]),Mc(this,`types`,[]),e<Vc||e>Hc)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size},()=>!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,kc.Timing),this.setFunctionModule(e,6,e%2==0,kc.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,Zc(r,e));this.setFunctionModule(8,7,Zc(r,6)),this.setFunctionModule(8,8,Zc(r,7)),this.setFunctionModule(7,8,Zc(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Zc(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Zc(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Zc(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=Zc(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,kc.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,kc.Alignment)}setFunctionModule(e,t,n,r=kc.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==fl(t,n))throw RangeError(`Invalid argument`);let r=Jc[n[0]][t],i=qc[n[0]][t],a=Math.floor(dl(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=pl(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=ml(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(dl(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=Zc(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Uc:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Gc),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Gc}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Uc:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Gc),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Gc}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Wc)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*Kc,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Xc(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Zc(e,t){return!!(e>>>t&1)}var Qc=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},$c=[1,10,12,14],el=[2,9,11,13],tl=[4,8,16,16];function nl(e,t){return e[Math.floor((t+7)/17)+1]}function rl(e){let t=[];for(let n of e)Xc(n,8,t);return new Qc(tl,e.length,t)}function il(e){if(!sl(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Xc(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Qc($c,e.length,t)}function al(e){if(!cl(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Bc.indexOf(e.charAt(n))*45;r+=Bc.indexOf(e.charAt(n+1)),Xc(r,11,t)}return n<e.length&&Xc(Bc.indexOf(e.charAt(n)),6,t),new Qc(el,e.length,t)}function ol(e){return e===``?[]:sl(e)?[il(e)]:cl(e)?[al(e)]:[rl(ul(e))]}function sl(e){return Rc.test(e)}function cl(e){return zc.test(e)}function ll(e,t){let n=0;for(let r of e){let e=nl(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function ul(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function dl(e){if(e<Vc||e>Hc)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function fl(e,t){return Math.floor(dl(e)/8)-qc[t[0]][e]*Jc[t[0]][e]}function pl(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=hl(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=hl(n,2)}return t}function ml(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=hl(t,e))}return n}function hl(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function gl(e,t,n=1,r=40,i=-1,a=!0){if(!(Vc<=n&&n<=r&&r<=Hc)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=fl(o,t)*8,i=ll(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Pc,Fc,Ic])a&&s<=fl(o,e)*8&&(t=e);let c=[];for(let t of e){Xc(t.mode[0],4,c),Xc(t.numChars,nl(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=fl(o,t)*8;Xc(0,Math.min(4,l-c.length),c),Xc(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Xc(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Yc(o,t,u,i)}function _l(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?ol(e):Array.isArray(e)?[rl(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=gl(c,Lc[n],i,a,o,r),u=vl({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function vl(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=kc.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function yl(e,t={}){let n=_l(e,t),{pixelSize:r=10,whiteColor:i=`white`,blackColor:a=`black`}=t,o=n.size*r,s=n.size*r,c=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${s} ${o}">`,l=[];for(let e=0;e<n.size;e++)for(let t=0;t<n.size;t++){let i=t*r,a=e*r;n.data[e][t]&&l.push(`M${i},${a}h${r}v${r}h-${r}z`)}return c+=`<rect fill="${i}" width="${s}" height="${o}"/>`,c+=`<path fill="${a}" d="${l.join(``)}"/>`,c+=`</svg>`,c}function bl({base:e,onConfirmed:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),c=e===`api/account`,l=rc(async()=>{r(await k(`${e}/totp/start`,{method:`POST`}))}),u=rc(async()=>{t(await k(`${e}/totp/confirm`,{method:`POST`,body:{code:i.trim(),...c?{current:o}:{}}})??{stage:`active`,csrf:null})});return n?(0,A.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),u.run()},children:[(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Scan the code with your authenticator app, or type the secret in by hand. Then enter the 6-digit code the app shows.`}),(0,A.jsx)(`div`,{role:`img`,"aria-label":`QR code for ${n.account}`,className:`mx-auto w-48 rounded-md bg-white p-2 [&>svg]:h-auto [&>svg]:w-full`,dangerouslySetInnerHTML:{__html:yl(n.uri)}}),(0,A.jsxs)(`p`,{className:`text-center text-sm`,children:[`Secret: `,(0,A.jsx)(`code`,{className:`font-mono break-all`,children:n.secret})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`totp-code`,children:`Code from the app`}),(0,A.jsx)(tc,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,required:!0,value:i,onChange:e=>a(e.target.value)})]}),c?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`totp-current`,children:`Current password`}),(0,A.jsx)(tc,{id:`totp-current`,type:`password`,autoComplete:`current-password`,required:!0,value:o,onChange:e=>s(e.target.value)})]}):null,(0,A.jsx)(z,{error:u.error}),(0,A.jsx)(R,{type:`submit`,disabled:u.pending,children:u.pending?`Checking…`:`Confirm the code`})]}):(0,A.jsxs)(`div`,{className:`grid gap-3`,children:[(0,A.jsx)(z,{error:l.error}),(0,A.jsx)(R,{type:`button`,disabled:l.pending,onClick:()=>void l.run(),children:l.pending?`Starting…`:`Set up an authenticator app`})]})}function xl({session:e,onStep:t,onSignOut:n}){let[r,i]=(0,_.useState)(null),a=e=>{e.csrf&&de(e.csrf),i(e)},o=rc(async()=>{a(await Tc(`api/auth`))});if(r){let e=r.recoveryCodes??[];return(0,A.jsx)(ec,{title:`Save your recovery codes`,wide:!0,children:e.length>0?(0,A.jsx)(Oc,{codes:e,onDone:()=>void t(r)}):(0,A.jsx)(R,{onClick:()=>void t(r),children:`Continue`})})}return(0,A.jsxs)(ec,{title:`Add a second sign-in step`,description:`Your account needs a second factor. Add one now; you will use it at every sign-in.`,wide:!0,children:[(0,A.jsx)(bl,{base:`api/auth`,onConfirmed:a}),e.methods?.passkeys?(0,A.jsxs)(`div`,{className:`grid gap-3 border-t pt-4`,children:[(0,A.jsx)(z,{error:o.error}),(0,A.jsx)(R,{type:`button`,variant:`outline`,disabled:o.pending,onClick:()=>void o.run(),children:o.pending?`Waiting for the passkey…`:`Add a passkey instead`})]}):null,(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:()=>void n(),children:`Sign out`})]})}function Sl({session:e,onStep:t,onSignOut:n}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),s=rc(async()=>{await t(await k(`api/auth/mfa`,{method:`POST`,body:r?{recoveryCode:a.trim()}:{code:a.trim()}}))}),c=rc(async()=>{await t(await Ec())});return(0,A.jsxs)(ec,{title:`Second step`,description:r?`Enter one of your recovery codes. Each works once.`:`Enter the 6-digit code from your authenticator app.`,children:[(0,A.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),s.run()},children:[(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`mfa-value`,children:r?`Recovery code`:`Code`}),(0,A.jsx)(tc,{id:`mfa-value`,required:!0,autoComplete:`one-time-code`,inputMode:r?`text`:`numeric`,value:a,onChange:e=>o(e.target.value)})]}),(0,A.jsx)(z,{error:s.error}),(0,A.jsx)(R,{type:`submit`,disabled:s.pending,children:s.pending?`Checking…`:`Verify`})]}),(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm underline underline-offset-4`,onClick:()=>{i(e=>!e),o(``),s.clear()},children:r?`Use the authenticator app`:`Use a recovery code`}),e.methods?.passkeys?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(z,{error:c.error}),(0,A.jsx)(R,{type:`button`,variant:`outline`,disabled:c.pending,onClick:()=>void c.run(),children:c.pending?`Waiting for the passkey…`:`Use a passkey`})]}):null,(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:()=>void n(),children:`Sign out`})]})}function Cl({onStep:e,onSignOut:t}){return(0,A.jsxs)(ec,{title:`Choose a new password`,description:`The password you signed in with was set for you. Choose your own to continue.`,children:[(0,A.jsx)(ic,{submitLabel:`Save the new password`,onSubmit:async({password:t})=>{await e(await k(`api/auth/password`,{method:`POST`,body:{password:t}}))}}),(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:()=>void t(),children:`Sign out`})]})}function wl({token:e,onStep:t,onCancel:n}){return(0,A.jsxs)(ec,{title:`Set up the first admin`,description:`Choose a password for the admin account. The setup link works once.`,children:[(0,A.jsx)(ic,{submitLabel:`Create the admin account`,onSubmit:async({password:n})=>{await t(await k(`api/auth/setup`,{method:`POST`,body:{token:e,password:n}}))}}),(0,A.jsx)(`button`,{type:`button`,className:`rounded-sm text-sm text-muted-foreground underline underline-offset-4 hover:text-foreground`,onClick:n,children:`Go to sign in`})]})}function Tl(e){let t=e.replace(/^#/,``);if(t.startsWith(`/`)){let[,e=``,n=``]=t.split(`/`);if(e===`setup`&&n)return{type:`setup`,token:decodeURIComponent(n)};if(e===`invite`&&n)return{type:`invite`,token:decodeURIComponent(n)};if(e===`share`)return{type:`share`,token:n?decodeURIComponent(n):null};if(e===`account`)return{type:`account`};if(e===`admin`){let e=n.split(`?`)[0];return{type:`admin`,page:e===`audit`||e===`settings`||e===`shares`?e:`users`}}return{type:`tab`,id:``,route:``}}let n=t.indexOf(`/`);return n===-1?{type:`tab`,id:t,route:``}:{type:`tab`,id:t.slice(0,n),route:t.slice(n+1)}}function El(){history.replaceState(null,``,location.pathname+location.search)}function Dl(e){return/^#?(\/share(\/|$)|share(\/|$))/.test(e)}function Ol(e){let t=e.replace(/^#/,``);return t===``||t.startsWith(`/`)||t===`share`?``:t.replace(/^share\//,``)}function kl(e){let t=e.split(`?`)[1];return t?new URLSearchParams(t).get(`panel`):null}var Al=`warlock-devtools-theme`,jl=`system`;function Ml(){try{let e=localStorage.getItem(Al);return e===`light`||e===`dark`?e:`system`}catch{return jl}}function Nl(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function Pl(e){let t=e===`dark`||e===`system`&&Nl();document.documentElement.classList.toggle(`dark`,t)}function Fl(){Pl(Ml())}var Il=new Set;function Ll(e){return Il.add(e),()=>Il.delete(e)}function Rl(){let e=(0,_.useSyncExternalStore)(Ll,Ml,()=>`system`);return(0,_.useEffect)(()=>{if(Pl(e),e!==`system`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>Pl(`system`);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),{choice:e,setChoice:(0,_.useCallback)(e=>{try{e===`system`?localStorage.removeItem(Al):localStorage.setItem(Al,e)}catch{jl=e}Pl(e),Il.forEach(e=>e())},[])}}var zl=`http://www.w3.org/2000/svg`;function Bl(e,t,n){for(let[n,r]of Object.entries(t))r!=null&&(n===`class`&&e instanceof HTMLElement?e.className=String(r):n===`text`?e.textContent=String(r):n.startsWith(`on`)&&typeof r==`function`?e.addEventListener(n.slice(2),r):e.setAttribute(n,String(r)));for(let t of Array.isArray(n)?n:[n])t!=null&&e.append(t)}function Vl(e,t={},n=[]){let r=document.createElement(e);return Bl(r,t,n),r}function Hl(e,t={},n=[]){let r=document.createElementNS(zl,e);return Bl(r,t,n),r}function Ul(e){return Vl(`p`,{class:`empty`,text:e})}function Wl(e,t=``){return`api/${e}${!t||t.startsWith(`/`)||t.startsWith(`?`)?t:`/${t}`}`}function Gl(e,t=``){return`#${e}${t?`/${t}`:``}`}async function Kl(e,t={}){let n=(t.method??`GET`).toUpperCase(),r=new Headers(t.headers),i=fe();n!==`GET`&&n!==`HEAD`&&i&&r.set(`X-Devtools-Csrf`,i);let a;try{a=await fetch(e,{...t,headers:r,credentials:`same-origin`})}catch{throw oe(),Object.assign(Error(`Could not reach the server. Check your connection and try again.`),{status:0})}if(te(a.status)?oe():se(),!a.ok&&a.status!==204){let t=a.statusText||`Request failed (${a.status})`,n=!1,r=a.headers.get(`x-request-id`);try{let e=await a.json();t=e.error||t,n=e.code!==void 0,typeof e.ref==`string`&&e.ref!==``&&(r=e.ref)}catch{}throw a.status===404&&!n&&window.dispatchEvent(new CustomEvent(D,{detail:{path:e}})),Object.assign(Error(t),{status:a.status,ref:r})}return a.status===204?void 0:a.json()}function B(e){return e.split(`/`).filter(e=>e!==``).map(encodeURIComponent).join(`/`)}function V(e){return new URL(e,document.baseURI).href}function ql(e=``){return`api/share/panel${!e||e.startsWith(`?`)||e.startsWith(`/`)?e:`/${e}`}`}function Jl({id:e,root:t,route:n,refresh:r,shared:i=!1,share:a=null}){return{id:e,root:t,route:n,api:(t,n)=>Kl(i?ql(t):Wl(e,t),n),asset:t=>V(i?`api/share/assets/${encodeURIComponent(t)}`:`panels/${e}/${encodeURIComponent(t)}`),file:t=>V(i?`api/share/files/${B(t)}`:`panels/${e}/files/${B(t)}`),shared:i,share:i?null:a,href:t=>i?`#share${t?`/${t}`:``}`:Gl(e,t),navigate(t){let n=i?`#share${t?`/${t}`:``}`:Gl(e,t);location.hash===n?r():location.hash=n},refresh:r,el:Vl,svg:Hl,empty:Ul}}var Yl=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Xl=function(e,t){return new URL(e,t).href},Zl={},Ql=function(e){return e.pathname.endsWith(`.css`)},$l=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Xl(t,n);let r=s(t);if(r.href in Zl)return;Zl[r.href]=!0;let i=Ql(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:Yl,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},eu=(e,t=!1)=>$l(()=>import(new URL(t?`api/share/view.js`:`panels/${e}/view.js`,location.href).href),[],import.meta.url),tu=new Map;function nu(e,t=!1){let n=t?`share:${e}`:e,r=tu.get(n);return r||(r=t?eu(e,!0):eu(e),r.catch(()=>tu.delete(n)),tu.set(n,r)),r}function ru({id:e,title:t,route:n,shared:r=!1,share:i=null}){let a=(0,_.useRef)(null),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let o=!0,c=a.current;if(!c)return;l(null),d(!c.hasChildNodes());let u=()=>s(e=>e+1);return(async()=>{let a;try{a=await nu(e,r)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`The ${t} panel's view module did not load (${n}). Check the server log.`)}if(typeof a?.default!=`function`)throw Error(`The ${t} panel's view module has no default export function. Check the panel package.`);let s=document.createElement(`section`);s.className=`panel`,s.dataset.panel=e;let l=await a.default(Jl({id:e,root:s,route:n,refresh:u,shared:r,share:i}));o&&(c.replaceChildren(l instanceof Node?l:s),d(!1))})().catch(e=>{o&&(l(e instanceof Error?e.message:String(e)),d(!1))}),()=>{o=!1}},[e,t,n,o,r,i?.enabled,i?.manageHref]),(0,A.jsxs)(A.Fragment,{children:[c?(0,A.jsx)(z,{message:c,title:`The ${t} panel could not be shown`}):null,u&&!c?(0,A.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2.5 rounded-xl border bg-card px-4 py-6 text-sm text-muted-foreground`,children:[(0,A.jsx)(is,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":`true`}),`Loading `,t,`…`]}):null,(0,A.jsx)(`div`,{ref:a,"data-panel-host":e})]})}var iu=`This link has expired or was revoked. Ask the person who shared it for a new one.`;function au(){Rl();let[e]=(0,_.useState)(()=>Tl(location.hash)),[t,n]=(0,_.useState)({type:`loading`}),[r,i]=(0,_.useState)(()=>Ol(location.hash)),[a,o]=(0,_.useState)(0);(0,_.useEffect)(()=>{let t=!0,r=e.type===`share`?e.token:null;return(r!==null&&a===0?k(`api/share/open`,{method:`POST`,body:{token:r}}):k(`api/share/info`)).then(e=>{t&&(r!==null&&/^#\/share\/./.test(location.hash)&&history.replaceState(null,``,`${location.pathname}${location.search}#/share`),n({type:`ready`,info:e}))},e=>{t&&n(e instanceof E&&e.status===404?{type:`closed`}:{type:`failed`,error:e})}),()=>{t=!1}},[e,a]),(0,_.useEffect)(()=>{let e=()=>i(Ol(location.hash));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let s=(0,_.useCallback)(()=>{n({type:`loading`}),o(e=>e+1)},[]);if(t.type===`loading`)return(0,A.jsx)(`main`,{className:`mx-auto max-w-sm p-8`,children:(0,A.jsx)(Ks,{rows:3})});if(t.type===`closed`)return(0,A.jsx)(ec,{title:`This link is not available`,children:(0,A.jsx)(`p`,{className:`text-sm`,children:iu})});if(t.type===`failed`)return(0,A.jsxs)(ec,{title:`The page could not be opened`,children:[(0,A.jsx)(z,{error:t.error}),(0,A.jsx)(R,{onClick:s,children:`Try again`})]});let{info:c}=t;return(0,A.jsxs)(`div`,{className:`min-h-screen`,children:[(0,A.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-b bg-card px-4 py-3.5 sm:px-6`,children:[(0,A.jsx)(Js,{}),(0,A.jsx)(`h1`,{className:`text-base font-semibold`,children:c.title}),(0,A.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:c.label}),(0,A.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground`,"data-testid":`share-expiry`,children:[`Read-only link · expires `,new Date(c.expiresAt).toLocaleDateString()]})]}),(0,A.jsx)(`main`,{className:`mx-auto w-full max-w-[110rem] px-4 py-6 sm:px-8`,children:(0,A.jsx)(ru,{id:c.panel,title:c.title,route:r,shared:!0})})]})}function ou(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t} s`:`${Math.floor(t/60)} min ${t%60} s`}function su(){let e=le(),[t,n]=(0,_.useState)(()=>Date.now());if((0,_.useEffect)(()=>{if(e.phase!==`down`)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e.phase]),e.phase===`online`)return null;let r=e.phase===`down`;return(0,A.jsx)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`connection-banner`,className:`sticky top-0 z-50 flex flex-wrap items-center justify-center gap-x-3 px-4 py-1.5 text-center text-sm font-medium ${r?`bg-warning text-background`:`bg-success text-background`}`,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{children:`Reconnecting to the app…`}),(0,A.jsx)(`span`,{className:`tabular-nums opacity-90`,children:ou(Math.max(t,e.since)-e.since)})]}):(0,A.jsx)(`span`,{children:`Reconnected`})})}function H(e,t={}){let[n,r]=(0,_.useState)(0),[i,a]=(0,_.useState)({key:null,data:void 0,error:void 0}),o=(0,_.useCallback)(()=>r(e=>e+1),[]),{generation:s}=le(),c=e===null?null:`${e}#${n}#${s}`;return(0,_.useEffect)(()=>{if(c===null||e===null)return;let t=new AbortController;return k(e,{signal:t.signal}).then(e=>{t.signal.aborted||a({key:c,data:e,error:void 0})},e=>{if(t.signal.aborted)return;let n=e instanceof E?e:new E(String(e),0);te(n.status)&&re()||a(e=>({key:c,data:e.data,error:n}))}),()=>t.abort()},[c,e]),cu(o,e===null?null:t.refreshMs??null),{data:i.data,error:i.error,loading:c!==null&&i.key!==c,reload:o}}function cu(e,t){let n=(0,_.useRef)(e);(0,_.useEffect)(()=>{n.current=e},[e]),(0,_.useEffect)(()=>{if(t===null)return;let e=setInterval(()=>{(typeof document>`u`||document.visibilityState!==`hidden`)&&n.current()},t);return()=>clearInterval(e)},[t])}function lu(e,t){let n=(0,_.useRef)(t),r=e.join(`,`);(0,_.useEffect)(()=>{n.current=t},[t]),(0,_.useEffect)(()=>{if(typeof EventSource>`u`)return;let e=null,t=1e3,i,a=!1,o=()=>{let s=new EventSource(`api/stream`);e=s,s.addEventListener(`open`,()=>{t=1e3,se()}),s.addEventListener(`error`,()=>{s.close(),oe(),!a&&(i=setTimeout(o,t),t=Math.min(t*2,3e4))});for(let e of r.split(`,`))e&&s.addEventListener(e,t=>{try{n.current({type:e,data:JSON.parse(t.data)})}catch{}})};return o(),()=>{a=!0,i&&clearTimeout(i),e?.close()}},[r])}function U({title:e,hint:t,icon:n=Qo,className:r}){return(0,A.jsxs)(`div`,{className:F(`flex flex-col items-center rounded-xl border border-dashed bg-card/50 px-6 py-10 text-center`,r),children:[(0,A.jsx)(`span`,{className:`mb-3 grid size-10 place-items-center rounded-full bg-brand/10 text-brand`,children:(0,A.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),(0,A.jsx)(`p`,{className:`text-sm font-semibold`,children:e}),t?(0,A.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:t}):null]})}var uu=class extends _.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}render(){if(this.state.error===null)return this.props.children;let e=this.state.error instanceof Error?` (${this.state.error.message})`:``;return(0,A.jsx)(z,{title:`The ${this.props.name} view could not be shown`,message:`It failed while drawing its data${e}. Open another tab, or reload the page; if it keeps failing, report it with the browser console output.`,onRetry:()=>this.setState({error:null})})}};function du({className:e,containerClassName:t,...n}){return(0,A.jsx)(`div`,{"data-slot":`table-container`,className:F(`relative max-h-[calc(100vh-14rem)] w-full overflow-auto rounded-lg border bg-card`,t),children:(0,A.jsx)(`table`,{"data-slot":`table`,className:F(`w-full caption-bottom text-sm tabular-nums`,e),...n})})}function fu({className:e,...t}){return(0,A.jsx)(`thead`,{"data-slot":`table-header`,className:F(`sticky top-0 z-10 bg-card shadow-[0_1px_0_var(--border)] [&_tr]:border-b`,e),...t})}function pu({className:e,...t}){return(0,A.jsx)(`tbody`,{"data-slot":`table-body`,className:F(`[&_tr:last-child]:border-0`,e),...t})}function W({className:e,...t}){return(0,A.jsx)(`tr`,{"data-slot":`table-row`,className:F(`border-b transition-colors hover:bg-muted/60 data-[state=selected]:bg-accent`,e),...t})}function G({className:e,...t}){return(0,A.jsx)(`th`,{"data-slot":`table-head`,className:F(`h-10 px-3 text-left align-middle text-xs font-semibold whitespace-nowrap text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function K({className:e,...t}){return(0,A.jsx)(`td`,{"data-slot":`table-cell`,className:F(`px-3 py-2.5 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function mu({...e}){return(0,A.jsx)(ei,{"data-slot":`dialog`,...e})}function hu({...e}){return(0,A.jsx)(ii,{"data-slot":`dialog-portal`,...e})}function gu({className:e,...t}){return(0,A.jsx)(oi,{"data-slot":`dialog-overlay`,className:F(`fixed inset-0 z-50 animate-dt-fade bg-black/50 backdrop-blur-[2px]`,e),...t})}function _u({className:e,children:t,showCloseButton:n=!0,...r}){return(0,A.jsxs)(hu,{"data-slot":`dialog-portal`,children:[(0,A.jsx)(gu,{}),(0,A.jsxs)(ui,{"data-slot":`dialog-content`,className:F(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-2xl outline-none sm:max-w-lg`,e),...r,children:[t,n&&(0,A.jsxs)(_i,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,A.jsx)(Rs,{}),(0,A.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function vu({className:e,...t}){return(0,A.jsx)(`div`,{"data-slot":`dialog-header`,className:F(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function yu({className:e,showCloseButton:t=!1,children:n,...r}){return(0,A.jsxs)(`div`,{"data-slot":`dialog-footer`,className:F(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,A.jsx)(_i,{asChild:!0,children:(0,A.jsx)(R,{variant:`outline`,children:`Close`})})]})}function bu({className:e,...t}){return(0,A.jsx)(mi,{"data-slot":`dialog-title`,className:F(`text-lg leading-none font-semibold`,e),...t})}function xu({className:e,...t}){return(0,A.jsx)(hi,{"data-slot":`dialog-description`,className:F(`text-sm text-muted-foreground`,e),...t})}function Su({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=`Confirm`,destructive:a=!1,requireText:o,requirePassword:s=!1,onConfirm:c}){let[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(e);return e!==v&&(y(e),e&&(f(null),m(``),g(``))),(0,A.jsx)(mu,{open:e,onOpenChange:e=>l?void 0:t(e),children:(0,A.jsxs)(_u,{children:[(0,A.jsxs)(vu,{children:[(0,A.jsx)(bu,{children:n}),(0,A.jsx)(xu,{asChild:!0,children:(0,A.jsx)(`div`,{children:r})})]}),o?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsxs)(nc,{htmlFor:`confirm-text`,children:[`Type `,(0,A.jsx)(`code`,{className:`font-mono`,children:o}),` to continue`]}),(0,A.jsx)(tc,{id:`confirm-text`,value:p,autoComplete:`off`,onChange:e=>m(e.target.value)})]}):null,s?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`confirm-password`,children:`Current password`}),(0,A.jsx)(tc,{id:`confirm-password`,type:`password`,autoComplete:`current-password`,value:h,onChange:e=>g(e.target.value)})]}):null,(0,A.jsx)(z,{error:d}),(0,A.jsxs)(yu,{children:[(0,A.jsx)(R,{variant:`outline`,disabled:l,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsx)(R,{variant:a?`destructive`:`default`,disabled:l||o!==void 0&&p!==o||s&&h===``,onClick:async()=>{u(!0),f(null);try{await c({password:h}),t(!1)}catch(e){f(e)}finally{u(!1)}},children:l?`Working…`:i})]})]})})}function Cu(e,t=Date.now()){let n=t-e,r=Math.abs(n);return r<5e3?`just now`:(e=>n>=0?`${e} ago`:`in ${e}`)(r<6e4?`${Math.round(r/1e3)} s`:r<36e5?`${Math.round(r/6e4)} min`:r<864e5?`${Math.round(r/36e5)} h`:`${Math.round(r/864e5)} d`)}function wu({at:e,fallback:t=`never`,className:n}){let[r,i]=(0,_.useState)(()=>Date.now());return(0,_.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),3e4);return()=>clearInterval(e)},[]),e==null?(0,A.jsx)(`span`,{className:n,children:t}):(0,A.jsx)(`time`,{className:n,dateTime:new Date(e).toISOString(),title:new Date(e).toLocaleString(),children:Cu(e,r)})}function Tu(){let[e,t]=(0,_.useState)(!1);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Password`}),(0,A.jsx)(Qs,{children:`Changing it asks for the current one.`})]}),(0,A.jsxs)($s,{className:`grid max-w-sm gap-3`,children:[(0,A.jsx)(ic,{requireCurrent:!0,submitLabel:`Change password`,onSubmit:async({current:e,password:t})=>{let n=await k(`api/account/password`,{method:`POST`,body:{current:e,password:t}});n?.csrf&&de(n.csrf)},onDone:()=>t(!0)}),e?(0,A.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Password changed.`}):null]})]})}function Eu({account:e,reload:t}){let[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Authenticator app`}),(0,A.jsx)(Qs,{children:e.twoFactor.totp?`An authenticator app is set up.`:`No authenticator app yet.`})]}),(0,A.jsx)($s,{className:`grid max-w-md gap-3`,children:o?(0,A.jsx)(Oc,{codes:o,onDone:()=>{s(null),t()}}):e.twoFactor.totp?(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{variant:`outline`,onClick:()=>a(!0),children:`Remove the authenticator app`})}):n?(0,A.jsx)(bl,{base:`api/account`,onConfirmed:e=>{r(!1),e.recoveryCodes?.length?s(e.recoveryCodes):t()}}):(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{onClick:()=>r(!0),children:`Add an authenticator app`})})}),(0,A.jsx)(Su,{open:i,onOpenChange:a,title:`Remove the authenticator app?`,description:`You will no longer be asked for its code. If it is your only second factor, the server refuses and says what to add first.`,confirmLabel:`Remove`,destructive:!0,requirePassword:!0,onConfirm:async({password:e})=>{await k(`api/account/totp`,{method:`DELETE`,body:{current:e}}),t()}})]})}function Du({account:e,reload:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),o=e.twoFactor.passkeys;return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Passkeys`}),(0,A.jsx)(Qs,{children:`Sign in with a device key instead of a code.`})]}),(0,A.jsxs)($s,{className:`grid max-w-xl gap-3`,children:[o.length===0?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No passkeys yet.`}):(0,A.jsx)(`ul`,{className:`grid gap-2`,children:o.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,A.jsxs)(`span`,{children:[e.name,` `,(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· last used `,(0,A.jsx)(wu,{at:e.lastUsedAt})]})]}),(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>r(e.id),children:`Remove`})]},e.id))}),(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{onClick:()=>a(!0),children:`Add a passkey`})})]}),(0,A.jsx)(Su,{open:i,onOpenChange:a,title:`Add a passkey`,description:`Enter your current password, then follow your browser's passkey prompt.`,confirmLabel:`Continue`,requirePassword:!0,onConfirm:async({password:e})=>{await Tc(`api/account`,e),t()}}),(0,A.jsx)(Su,{open:n!==null,onOpenChange:e=>!e&&r(null),title:`Remove this passkey?`,description:`It will stop working for sign-in. If it is your only second factor, the server refuses and says what to add first.`,confirmLabel:`Remove`,destructive:!0,requirePassword:!0,onConfirm:async({password:e})=>{await k(`api/account/passkeys/${encodeURIComponent(n??``)}`,{method:`DELETE`,body:{current:e}}),t()}})]})}function Ou({account:e,reload:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(null),o=rc(async()=>{let e=await k(`api/account/recovery-codes`,{method:`POST`,body:{code:n.trim()}});r(``),a(e.codes)}),s=rc(async()=>{await Ec(`api/account`);let e=await k(`api/account/recovery-codes`,{method:`POST`,body:{}});a(e.codes)}),c=e.twoFactor.totp,l=e.twoFactor.passkeys.length>0;return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Recovery codes`}),(0,A.jsxs)(Qs,{children:[e.twoFactor.recoveryCodesLeft,` left. Making new ones replaces the old ones.`]})]}),(0,A.jsx)($s,{className:`grid max-w-md gap-3`,children:i?(0,A.jsx)(Oc,{codes:i,onDone:()=>{a(null),t()}}):(0,A.jsxs)(A.Fragment,{children:[c?(0,A.jsxs)(`form`,{className:`grid gap-3`,onSubmit:e=>{e.preventDefault(),o.run()},children:[(0,A.jsx)(nc,{htmlFor:`regen-code`,children:`Current code from your authenticator app`}),(0,A.jsx)(tc,{id:`regen-code`,inputMode:`numeric`,autoComplete:`one-time-code`,required:!0,value:n,onChange:e=>r(e.target.value)}),(0,A.jsx)(z,{error:o.error}),(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{type:`submit`,disabled:o.pending,children:o.pending?`Working…`:`Make new recovery codes`})})]}):null,l?(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(z,{error:s.error}),(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{variant:c?`outline`:`default`,disabled:s.pending,onClick:()=>void s.run(),children:s.pending?`Waiting for the passkey…`:`Make new recovery codes with a passkey`})})]}):null,!c&&!l?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add an authenticator app or a passkey first; recovery codes come with it.`}):null]})})]})}function ku(){let e=H(`api/account/sessions`),[t,n]=(0,_.useState)(null);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Sessions`}),(0,A.jsx)(Qs,{children:`Where you are signed in. Revoke any you do not recognise.`})]}),(0,A.jsxs)($s,{children:[e.error&&!e.data?(0,A.jsx)(z,{error:e.error}):null,!e.data&&!e.error?(0,A.jsx)(Ks,{rows:2}):null,e.data?(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`Browser`}),(0,A.jsx)(G,{children:`IP`}),(0,A.jsx)(G,{children:`Last active`}),(0,A.jsx)(G,{})]})}),(0,A.jsx)(pu,{children:e.data.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{className:`max-w-64 truncate`,title:e.userAgent??void 0,children:[e.userAgent??`Unknown`,` `,e.current?(0,A.jsx)(qa,{children:`This session`}):null]}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.ip??`—`}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:e.lastSeenAt})}),(0,A.jsx)(K,{className:`text-right`,children:e.current?null:(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>n(e),children:`Revoke`})})]},e.id))})]}):null]}),(0,A.jsx)(Su,{open:t!==null,onOpenChange:e=>!e&&n(null),title:`Revoke this session?`,description:`That browser is signed out at once.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:async()=>{await k(`api/account/sessions/${t?.id??``}`,{method:`DELETE`}),e.reload()}})]})}function Au(){let e=H(`api/account`);return e.error&&!e.data?(0,A.jsx)(z,{error:e.error}):e.data?(0,A.jsxs)(`div`,{className:`mx-auto grid max-w-3xl gap-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Account`}),(0,A.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[e.data.email,` `,(0,A.jsx)(qa,{variant:`brand`,children:e.data.role})]})]}),(0,A.jsx)(Tu,{}),(0,A.jsx)(Eu,{account:e.data,reload:e.reload}),(0,A.jsx)(Du,{account:e.data,reload:e.reload}),(0,A.jsx)(Ou,{account:e.data,reload:e.reload}),(0,A.jsx)(ku,{})]}):(0,A.jsx)(Ks,{})}var ju=(0,_.createContext)(null);function Mu(){let e=(0,_.useContext)(ju);if(!e)throw Error(`useSession was called outside the dashboard shell.`);return e}var Nu=50,Pu=`admin.seeded,admin.reset,setup.completed,login.succeeded,login.failed,login.blocked,mfa.succeeded,mfa.failed,mfa.enrolled,mfa.removed,recovery-code.used,recovery-codes.regenerated,passkey.added,passkey.removed,password.changed,logout,session.revoked,invite.created,invite.revoked,invite.accepted,account.role-changed,account.removed,account.mfa-reset,account.signed-out,dashboard.disabled,dashboard.enabled,dashboard.locked,explain.run,requests.cleared,panel.action`.split(`,`),Fu=new Set([`login.failed`,`mfa.failed`,`login.blocked`,`dashboard.locked`]);function Iu(e,t,n){let r=new URLSearchParams({limit:String(Nu)});return e&&r.set(`type`,e),t&&r.set(`account`,t),n!==void 0&&r.set(`before`,String(n)),`api/admin/audit?${r.toString()}`}function Lu(){let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1),f=H(`api/admin/users`),p=(e,t)=>{e(t),a(null),l(null)};(0,_.useEffect)(()=>{let t=!0;return k(Iu(e,n)).then(e=>{t&&(a(e),s(e.length>=Nu))},e=>{t&&l(e)}),()=>{t=!1}},[e,n]);let m=(0,_.useCallback)(async()=>{let t=i?.at(-1);if(t){d(!0),l(null);try{let r=await k(Iu(e,n,t.at));a(e=>{let t=new Set((e??[]).map(e=>e.id));return[...e??[],...r.filter(e=>!t.has(e.id))]}),s(r.length>=Nu)}catch(e){l(e)}finally{d(!1)}}},[i,e,n]);return(0,A.jsxs)(`div`,{className:`grid gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,A.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Event type`,(0,A.jsxs)(`select`,{className:`h-9 rounded-lg border border-input bg-card px-2.5 shadow-xs focus-visible:ring-[3px] focus-visible:ring-ring/50 max-md:h-10`,value:e,onChange:e=>p(t,e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`All events`}),Pu.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]})]}),(0,A.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Account`,(0,A.jsxs)(`select`,{className:`h-9 rounded-lg border border-input bg-card px-2.5 shadow-xs focus-visible:ring-[3px] focus-visible:ring-ring/50 max-md:h-10`,value:n,onChange:e=>p(r,e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`All accounts`}),f.data?.accounts.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.email},e.id))]})]})]}),(0,A.jsx)(z,{error:c}),!i&&!c?(0,A.jsx)(Ks,{}):null,i&&i.length===0?(0,A.jsx)(U,{title:`No audit entries match.`,hint:`Clear a filter to see more.`}):null,i&&i.length>0?(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`When`}),(0,A.jsx)(G,{children:`Event`}),(0,A.jsx)(G,{children:`Account`}),(0,A.jsx)(G,{children:`IP`}),(0,A.jsx)(G,{children:`Detail`}),(0,A.jsx)(G,{children:`Ref`})]})}),(0,A.jsx)(pu,{children:i.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`whitespace-nowrap`,children:new Date(e.at).toLocaleString()}),(0,A.jsx)(K,{children:(0,A.jsx)(qa,{variant:Fu.has(e.type)?`destructive`:`secondary`,children:e.type})}),(0,A.jsx)(K,{children:e.email??`—`}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.ip??`—`}),(0,A.jsx)(K,{className:`max-w-64 truncate font-mono text-xs`,children:Object.entries(e.detail).map(([e,t])=>`${e}=${String(t)}`).join(` `)}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.ref})]},e.id))})]}):null,i&&o?(0,A.jsx)(`div`,{children:(0,A.jsx)(R,{variant:`outline`,disabled:u,onClick:()=>void m(),children:u?`Loading…`:`Load older`})}):null]})}function Ru(){let{markDisabled:e}=Mu(),[t,n]=(0,_.useState)(!1);return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Disable the dashboard`}),(0,A.jsx)(Qs,{children:`Closes the dashboard on every instance within seconds. It stays closed after a restart.`})]}),(0,A.jsx)($s,{children:(0,A.jsx)(R,{variant:`destructive`,onClick:()=>n(!0),children:`Disable the dashboard`})}),(0,A.jsx)(Su,{open:t,onOpenChange:n,title:`Disable the dashboard?`,description:(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`p`,{children:[`Every instance answers as if the page did not exist, and every session ends. Only someone with shell access can open it again: run `,(0,A.jsx)(`code`,{children:`warlock devtools:enable`}),`, or deploy with a new `,(0,A.jsx)(`code`,{children:`DEVTOOLS_PATH`}),`.`]})}),confirmLabel:`Disable the dashboard`,destructive:!0,requireText:`disable`,onConfirm:async()=>{await k(`api/admin/disable`,{method:`POST`,body:{confirm:`disable`}}),e()}})]})}var zu=80;function Bu({list:e,open:t,onOpenChange:n,onCreated:r}){let i=kl(location.hash),[a,o]=(0,_.useState)(e.panels.find(e=>e.id===i)?.id??e.panels[0]?.id??``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(String(Math.min(7,e.maxDays))),d=rc(async()=>{let e=await k(`api/admin/shares`,{method:`POST`,body:{panel:a,label:s.trim(),days:Number(l)}});c(``),r(e),n(!1)});return(0,A.jsx)(mu,{open:t,onOpenChange:n,children:(0,A.jsxs)(_u,{children:[(0,A.jsxs)(vu,{children:[(0,A.jsx)(bu,{children:`Create a share link`}),(0,A.jsx)(xu,{children:`Anyone with the link can read the shared view of the panel until the link expires or you revoke it. They need no account and cannot change anything.`})]}),(0,A.jsxs)(`form`,{className:`grid gap-3`,onSubmit:e=>{e.preventDefault(),d.run()},children:[(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`share-panel`,children:`Panel`}),(0,A.jsx)(`select`,{id:`share-panel`,className:`h-9 rounded-md border bg-background px-2 text-sm`,value:a,onChange:e=>o(e.target.value),children:e.panels.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`share-label`,children:`Label`}),(0,A.jsx)(tc,{id:`share-label`,required:!0,maxLength:zu,placeholder:`Who or what is this link for?`,value:s,onChange:e=>c(e.target.value)})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsxs)(nc,{htmlFor:`share-days`,children:[`Days until it expires (1 to `,e.maxDays,`)`]}),(0,A.jsx)(tc,{id:`share-days`,type:`number`,required:!0,min:1,max:e.maxDays,step:1,value:l,onChange:e=>u(e.target.value)})]}),(0,A.jsx)(z,{error:d.error}),(0,A.jsxs)(yu,{children:[(0,A.jsx)(R,{type:`button`,variant:`ghost`,onClick:()=>n(!1),children:`Cancel`}),(0,A.jsx)(R,{type:`submit`,disabled:d.pending||e.panels.length===0,children:d.pending?`Creating…`:`Create link`})]})]})]})})}function Vu(e){return(0,A.jsx)(qa,{variant:e.status===`active`?`default`:`outline`,children:e.status})}function Hu(){let e=H(`api/admin/shares`),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),l=e.data,u=e=>l?.panels.find(t=>t.id===e)?.title??e,d=l?.shares.filter(e=>e.status===`active`).length??0;return(0,A.jsxs)(`div`,{className:`grid gap-4`,children:[(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Share links`}),(0,A.jsx)(Qs,{children:`A read-only link opens one panel's shared view without an account. The link is shown once, expires on its own and can be revoked at any time.`})]}),(0,A.jsxs)($s,{className:`flex flex-wrap gap-2`,children:[(0,A.jsx)(R,{onClick:()=>n(!0),disabled:!l||l.panels.length===0,children:`Create a link`}),(0,A.jsx)(R,{variant:`outline`,disabled:d===0,onClick:()=>c(!0),children:`Revoke all links`})]})]}),r?(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsxs)(Zs,{children:[`Link for `,r.share.label]}),(0,A.jsx)(Qs,{children:`This link is shown only now. Copy it and hand it over; it cannot be shown again.`})]}),(0,A.jsxs)($s,{className:`grid gap-2`,children:[(0,A.jsx)(`code`,{className:`font-mono text-xs break-all`,"data-testid":`share-link`,children:r.url}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(Dc,{value:r.url,label:`Copy link`}),(0,A.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>i(null),children:`Hide`})]})]})]}):null,e.error&&!l?(0,A.jsx)(z,{error:e.error,onRetry:e.reload}):null,!l&&!e.error?(0,A.jsx)(Ks,{}):null,l&&l.panels.length===0?(0,A.jsx)(U,{title:`No panel can be shared.`,hint:`A panel needs a shared view (share) before it can have links. Add a panel that declares one, such as the Grimoire panel.`}):null,l&&l.shares.length===0&&l.panels.length>0?(0,A.jsx)(U,{title:`No links yet.`,hint:`Create a link to share a panel read-only.`}):null,l&&l.shares.length>0?(0,A.jsx)(Ys,{children:(0,A.jsx)($s,{children:(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`Label`}),(0,A.jsx)(G,{children:`Panel`}),(0,A.jsx)(G,{children:`Status`}),(0,A.jsx)(G,{children:`Expires`}),(0,A.jsx)(G,{children:`Last used`}),(0,A.jsx)(G,{children:`Uses`}),(0,A.jsx)(G,{})]})}),(0,A.jsx)(pu,{children:l.shares.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{children:[e.label,e.createdBy?(0,A.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`by `,e.createdBy]}):null]}),(0,A.jsx)(K,{children:u(e.panel)}),(0,A.jsx)(K,{children:Vu(e)}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:e.expiresAt})}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:e.lastUsedAt})}),(0,A.jsx)(K,{children:e.uses}),(0,A.jsx)(K,{className:`text-right`,children:e.status===`active`?(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>o(e),children:`Revoke`}):null})]},e.id))})]})})}):null,l&&t?(0,A.jsx)(Bu,{list:l,open:!0,onOpenChange:n,onCreated:t=>{i(t),e.reload()}}):null,a?(0,A.jsx)(Su,{open:!0,onOpenChange:e=>!e&&o(null),title:`Revoke the link "${a.label}"?`,description:`The link stops working within a few seconds, on every instance.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:async()=>{await k(`api/admin/shares/${a.id}`,{method:`DELETE`}),e.reload()}}):null,s?(0,A.jsx)(Su,{open:!0,onOpenChange:e=>!e&&c(!1),title:`Revoke every share link?`,description:`All ${d} active links stop working within a few seconds. This cannot be undone.`,confirmLabel:`Revoke all`,destructive:!0,requireText:`revoke all`,onConfirm:async()=>{await k(`api/admin/shares/revoke-all`,{method:`POST`}),e.reload()}}):null]})}function Uu(e){return`${location.origin}${location.pathname}#/invite/${e}`}function Wu({onCreated:e}){let[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(`viewer`),[a,o]=(0,_.useState)(null),s=rc(async()=>{let i=await k(`api/admin/invites`,{method:`POST`,body:{email:t.trim(),role:r}});o(i),n(``),e()});return(0,A.jsxs)(Ys,{children:[(0,A.jsxs)(Xs,{children:[(0,A.jsx)(Zs,{children:`Invite someone`}),(0,A.jsx)(Qs,{children:`You get a link to hand over. It works once and expires in 24 hours. No email is sent.`})]}),(0,A.jsxs)($s,{className:`grid gap-3`,children:[(0,A.jsxs)(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:e=>{e.preventDefault(),s.run()},children:[(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`invite-email`,children:`Email`}),(0,A.jsx)(tc,{id:`invite-email`,type:`email`,required:!0,value:t,onChange:e=>n(e.target.value)})]}),(0,A.jsxs)(`div`,{className:`grid gap-2`,children:[(0,A.jsx)(nc,{htmlFor:`invite-role`,children:`Role`}),(0,A.jsxs)(`select`,{id:`invite-role`,className:`h-9 rounded-md border bg-background px-2 text-sm`,value:r,onChange:e=>i(e.target.value),children:[(0,A.jsx)(`option`,{value:`viewer`,children:`Viewer`}),(0,A.jsx)(`option`,{value:`admin`,children:`Admin`})]})]}),(0,A.jsx)(R,{type:`submit`,disabled:s.pending,children:s.pending?`Creating…`:`Create invite`})]}),(0,A.jsx)(z,{error:s.error}),a?(0,A.jsxs)(`div`,{className:`grid gap-2 rounded-md border bg-muted p-3 text-sm`,children:[(0,A.jsxs)(`p`,{children:[`Invite for `,(0,A.jsx)(`strong`,{children:a.invite.email}),` (expires`,` `,(0,A.jsx)(wu,{at:a.invite.expiresAt}),`). This link is shown only now:`]}),(0,A.jsx)(`code`,{className:`font-mono text-xs break-all`,"data-testid":`invite-link`,children:Uu(a.token)}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(Dc,{value:Uu(a.token),label:`Copy link`}),(0,A.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>o(null),children:`Hide`})]})]}):null]})]})}function Gu(e){switch(e.type){case`role`:return{title:`Make ${e.account.email} ${e.role===`admin`?`an admin`:`a viewer`}?`,description:e.role===`admin`?`Admins manage users and can turn the dashboard off. They are asked to add a second factor at the next sign-in.`:`They lose access to user management and settings.`,label:`Change role`};case`remove`:return{title:`Remove ${e.account.email}?`,description:`The account and its sessions are deleted. This cannot be undone.`,label:`Remove`};case`reset-mfa`:return{title:`Reset the second factor of ${e.account.email}?`,description:`Their authenticator app, passkeys and recovery codes are removed. They add new ones at the next sign-in.`,label:`Reset`};case`sign-out`:return{title:`Sign ${e.account.email} out everywhere?`,description:`Every browser session of this account ends at once.`,label:`Sign out`};case`revoke`:return{title:`Revoke the invite for ${e.invite.email}?`,description:`The link stops working.`,label:`Revoke`}}}function Ku(){let{session:e}=Mu(),t=H(`api/admin/users`),[n,r]=(0,_.useState)(null),i=async()=>{if(n){switch(n.type){case`role`:await k(`api/admin/users/${n.account.id}`,{method:`PATCH`,body:{role:n.role}});break;case`remove`:await k(`api/admin/users/${n.account.id}`,{method:`DELETE`});break;case`reset-mfa`:await k(`api/admin/users/${n.account.id}/reset-mfa`,{method:`POST`});break;case`sign-out`:await k(`api/admin/users/${n.account.id}/sign-out`,{method:`POST`});break;case`revoke`:await k(`api/admin/invites/${n.invite.id}`,{method:`DELETE`})}t.reload()}},a=n?Gu(n):null;return(0,A.jsxs)(`div`,{className:`grid gap-4`,children:[(0,A.jsx)(Wu,{onCreated:t.reload}),t.error&&!t.data?(0,A.jsx)(z,{error:t.error}):null,!t.data&&!t.error?(0,A.jsx)(Ks,{}):null,t.data?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsx)(Zs,{children:`Accounts`})}),(0,A.jsx)($s,{children:(0,A.jsxs)(du,{children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{children:`Email`}),(0,A.jsx)(G,{children:`Role`}),(0,A.jsx)(G,{children:`Second factor`}),(0,A.jsx)(G,{children:`Last sign-in`}),(0,A.jsx)(G,{})]})}),(0,A.jsx)(pu,{children:t.data.accounts.map(t=>{let n=t.id===e.account?.id;return(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{children:[t.email,` `,n?(0,A.jsx)(qa,{variant:`outline`,children:`You`}):null]}),(0,A.jsx)(K,{children:t.role}),(0,A.jsx)(K,{children:t.twoFactor.totp||t.twoFactor.passkeys.length>0?`On`:`Off`}),(0,A.jsx)(K,{children:(0,A.jsx)(wu,{at:t.lastLoginAt})}),(0,A.jsx)(K,{className:`flex flex-wrap justify-end gap-1`,children:n?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`role`,account:t,role:t.role===`admin`?`viewer`:`admin`}),children:t.role===`admin`?`Make viewer`:`Make admin`}),(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`reset-mfa`,account:t}),children:`Reset second factor`}),(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`sign-out`,account:t}),children:`Sign out everywhere`}),(0,A.jsx)(R,{size:`xs`,variant:`destructive`,onClick:()=>r({type:`remove`,account:t}),children:`Remove`})]})})]},t.id)})})]})})]}),(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsx)(Zs,{children:`Pending invites`})}),(0,A.jsx)($s,{children:t.data.invites.filter(e=>e.usedAt===null).length===0?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No pending invites.`}):(0,A.jsx)(du,{children:(0,A.jsx)(pu,{children:t.data.invites.filter(e=>e.usedAt===null).map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{children:e.email}),(0,A.jsx)(K,{children:e.role}),(0,A.jsxs)(K,{children:[`expires `,(0,A.jsx)(wu,{at:e.expiresAt})]}),(0,A.jsx)(K,{className:`text-right`,children:(0,A.jsx)(R,{size:`xs`,variant:`outline`,onClick:()=>r({type:`revoke`,invite:e}),children:`Revoke`})})]},e.id))})})})]})]}):null,a?(0,A.jsx)(Su,{open:!0,onOpenChange:e=>!e&&r(null),title:a.title,description:a.description,confirmLabel:a.label,destructive:n?.type===`remove`,onConfirm:i}):null]})}var qu=[{id:`users`,label:`Users and invites`},{id:`audit`,label:`Audit log`},{id:`settings`,label:`Settings`},{id:`shares`,label:`Share links`}];function Ju({page:e}){let{session:t}=Mu();return t.role!==`admin`||t.mode!==`production`?(0,A.jsx)(U,{title:`This page is for admins.`,hint:`Ask an admin of this dashboard to change your role, or sign in with an admin account.`}):(0,A.jsxs)(`div`,{className:`mx-auto grid max-w-6xl gap-5`,children:[(0,A.jsx)(`nav`,{"aria-label":`Admin pages`,className:`flex gap-1 overflow-x-auto rounded-lg border bg-card p-1 text-sm`,children:qu.filter(e=>e.id!==`shares`||t.share?.enabled).map(t=>(0,A.jsx)(`a`,{href:`#/admin/${t.id}`,"aria-current":t.id===e?`page`:void 0,className:F(`flex min-h-8 items-center rounded-md px-3 whitespace-nowrap transition-colors max-md:min-h-10`,t.id===e?`bg-brand/10 font-semibold text-brand`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`),children:t.label},t.id))}),e===`users`?(0,A.jsx)(Ku,{}):e===`audit`?(0,A.jsx)(Lu,{}):e===`shares`&&t.share?.enabled?(0,A.jsx)(Hu,{}):(0,A.jsx)(Ru,{})]})}function q(e){return e==null||Number.isNaN(e)?`—`:e.toLocaleString(`en-US`)}function J(e){return e==null||Number.isNaN(e)?`—`:e>=1e4?`${(e/1e3).toFixed(1)} s`:e>=1e3?`${(e/1e3).toFixed(2)} s`:e>=100?`${Math.round(e)} ms`:e>=10?`${e.toFixed(1)} ms`:`${e.toFixed(e<1?2:1)} ms`}function Yu(e){if(e==null||Number.isNaN(e))return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${r===0?n:n.toFixed(n>=100?0:1)} ${t[r]}`}function Xu(e,t=1){return e==null||Number.isNaN(e)?`—`:`${e.toFixed(t)} %`}function Zu(e){return e==null?`unpriced`:`$${e.toFixed(6)} USD`}function Qu(e){return e<60?`${Math.round(e)} s`:e<3600?`${Math.floor(e/60)} min`:e<86400?`${(e/3600).toFixed(1)} h`:`${(e/86400).toFixed(1)} d`}function $u(e,t=Date.now()){let n=Math.round((t-e)/1e3),r=Math.abs(n),i=r<5?`just now`:Qu(r);return r<5?i:n>=0?`${i} ago`:`in ${i}`}function ed({at:e,className:t}){return e==null?(0,A.jsx)(`span`,{className:t,children:`—`}):(0,A.jsx)(`time`,{dateTime:new Date(e).toISOString(),title:new Date(e).toLocaleString(),className:t,children:$u(e)})}function td(e){return e==null?`—`:new Date(e).toLocaleTimeString()}function nd({children:e}){return(0,A.jsx)(`h3`,{className:`mt-6 mb-2 text-sm font-semibold text-foreground`,children:e})}function rd({children:e,className:t}){return(0,A.jsx)(`pre`,{className:F(`max-h-80 overflow-auto rounded-lg border bg-muted p-3 font-mono text-xs leading-relaxed break-words whitespace-pre-wrap`,t),children:e})}function id({value:e}){return(0,A.jsx)(rd,{children:JSON.stringify(e,null,2)??`undefined`})}var ad=`h-8 rounded-lg border border-input bg-card px-2.5 text-sm shadow-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 max-md:h-10`;function od({className:e,...t}){return(0,A.jsx)(`input`,{className:F(ad,e),...t})}function sd({className:e,...t}){return(0,A.jsx)(`select`,{className:F(ad,e),...t})}function cd({active:e,children:t,...n}){return(0,A.jsx)(R,{type:`button`,size:`sm`,variant:e?`brand`:`outline`,"aria-pressed":e,...n,children:t})}function ld({selected:e,className:t,...n}){return(0,A.jsx)(`button`,{type:`button`,"aria-current":e?`true`:void 0,className:F(`block w-full rounded-lg border bg-card p-2.5 text-left text-sm transition-colors hover:bg-muted/60 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,e&&`border-brand bg-brand/10`,t),...n})}function ud(e,t){return e?t?.find(t=>t.id===e)?.label??e:`—`}function dd(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){if(r==null)continue;let e=String(r).trim();e&&t.set(n,e)}let n=t.toString();return n?`?${n}`:``}var fd={success:`border-success/25 bg-success/10 text-success`,warning:`border-warning/30 bg-warning/10 text-warning`,info:`border-info/25 bg-info/10 text-info`,destructive:`border-destructive/25 bg-destructive/10 text-destructive`,brand:`border-brand/25 bg-brand/10 text-brand`,neutral:`border-border bg-muted text-muted-foreground`},pd={success:`text-success`,warning:`text-warning`,info:`text-info`,destructive:`text-destructive`,brand:`text-brand`,neutral:`text-foreground`};function Y({tone:e=`neutral`,mono:t,className:n,children:r,...i}){return(0,A.jsx)(`span`,{className:F(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs leading-none font-medium whitespace-nowrap`,t&&`font-mono tabular-nums`,fd[e],n),...i,children:r})}function md(e){return e==null?`neutral`:e>=500?`destructive`:e>=400?`warning`:e>=300?`info`:`success`}function hd({status:e}){return(0,A.jsx)(Y,{tone:md(e),mono:!0,children:e??`—`})}var gd={GET:`info`,POST:`success`,PUT:`warning`,PATCH:`warning`,DELETE:`destructive`};function _d({method:e}){let t=e.toUpperCase();return(0,A.jsx)(Y,{tone:gd[t]??`neutral`,mono:!0,className:`min-w-14 justify-center`,children:t})}function vd(e){switch(e){case`error`:return`destructive`;case`warn`:return`warning`;case`success`:return`success`;case`debug`:return`neutral`;default:return`info`}}function yd({level:e}){return(0,A.jsx)(Y,{tone:vd(e),className:`min-w-14 justify-center`,children:e})}function bd({title:e,description:t,children:n}){return(0,A.jsxs)(`header`,{className:`mb-4 flex flex-wrap items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:e}),t?(0,A.jsx)(`p`,{className:`mt-0.5 max-w-prose text-sm text-muted-foreground`,children:t}):null]}),n?(0,A.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n}):null]})}function xd({items:e,label:t=`Summary`}){return(0,A.jsx)(`dl`,{"aria-label":t,className:`mb-4 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-[repeat(auto-fit,minmax(10rem,1fr))]`,children:e.map(e=>(0,A.jsxs)(`div`,{className:`min-w-0 rounded-xl border bg-card px-3.5 py-3`,children:[(0,A.jsx)(`dt`,{className:`truncate text-xs text-muted-foreground`,children:e.label}),(0,A.jsx)(`dd`,{className:F(`mt-1 truncate text-2xl font-semibold tracking-tight tabular-nums`,pd[e.tone??`neutral`]),children:e.value}),e.hint?(0,A.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:e.hint}):null]},e.label))})}function X({label:e,onSubmit:t,children:n,trailing:r}){return(0,A.jsxs)(`form`,{"aria-label":e,onSubmit:e=>{e.preventDefault(),t?.(e)},className:`mb-3 flex flex-wrap items-center gap-2 rounded-xl border bg-card p-2`,children:[n,r?(0,A.jsx)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2 pl-2`,children:r}):null]})}function Sd({label:e,className:t,...n}){return(0,A.jsxs)(`div`,{className:F(`relative min-w-48 flex-1`,t),children:[(0,A.jsx)(ws,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(od,{type:`search`,"aria-label":e,className:`w-full pl-8`,...n})]})}function Cd({label:e,options:t,value:n,onChange:r}){return(0,A.jsx)(`div`,{role:`group`,"aria-label":e,className:`inline-flex rounded-md border bg-muted/50 p-0.5`,children:t.map(e=>{let t=e.value===n;return(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>r(e.value),className:F(`inline-flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium whitespace-nowrap transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,t?`bg-background text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`),children:[e.label,e.count===void 0?null:(0,A.jsx)(`span`,{className:`text-[11px] tabular-nums opacity-70`,children:e.count})]},e.value)})})}function wd({shown:e,total:t,noun:n}){let r=e=>e===1?n:/[^aeiou]y$/.test(n)?`${n.slice(0,-1)}ies`:`${n}s`;return(0,A.jsx)(`span`,{role:`status`,className:`text-xs whitespace-nowrap text-muted-foreground tabular-nums`,children:t!==void 0&&t!==e?`${e} of ${t} ${r(t)}`:`${e} ${r(e)}`})}function Td({onClick:e}){return(0,A.jsxs)(R,{type:`button`,size:`xs`,variant:`ghost`,onClick:e,children:[(0,A.jsx)(Rs,{}),`Clear filters`]})}function Ed({label:e,className:t,children:n}){return(0,A.jsx)(`div`,{className:F(`overflow-hidden rounded-xl border bg-card`,t),children:(0,A.jsx)(du,{"aria-label":e,children:n})})}var Z=`h-9 bg-muted/40 text-xs font-medium text-muted-foreground`,Q=`text-right tabular-nums`;function Dd(e){return{tabIndex:0,className:`cursor-pointer focus-visible:bg-muted/60 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-ring/50`,onClick:e,onKeyDown:t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())}}}function Od({ms:e,max:t,text:n,tone:r=`bg-brand`}){let i=e&&t>0?Math.max(3,Math.min(100,e/t*100)):0;return(0,A.jsxs)(`div`,{className:`ml-auto flex w-24 flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`tabular-nums`,children:n}),(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,A.jsx)(`span`,{className:F(`block h-full rounded-full`,r),style:{width:`${i}%`}})})]})}function kd(e,t){if(!e.length)return null;let n=[...e].sort((e,t)=>e-t);return n[Math.max(0,Math.min(n.length-1,Math.ceil(t/100*n.length)-1))]??null}function Ad({title:e,actions:t,children:n,className:r}){return(0,A.jsxs)(`section`,{className:F(`rounded-xl border bg-card`,r),children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-3.5 py-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t]}),(0,A.jsx)(`div`,{className:`space-y-2 p-3.5`,children:n})]})}function jd({items:e}){return(0,A.jsx)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2.5 text-sm sm:grid-cols-3`,children:e.map(e=>(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,A.jsx)(`dd`,{className:`mt-0.5 break-words tabular-nums`,children:e.value})]},e.label))})}function Md({children:e,value:t,className:n}){return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`pre`,{className:F(`max-h-80 overflow-auto rounded-lg border bg-muted/50 p-3 pr-20 font-mono text-xs leading-relaxed break-words whitespace-pre-wrap`,n),children:e}),(0,A.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,A.jsx)(Dc,{value:t??e,size:`xs`,variant:`ghost`})})]})}function $({onClick:e,children:t=`Back to the list`}){return(0,A.jsxs)(R,{type:`button`,size:`sm`,variant:`ghost`,className:`-ml-2 mb-2`,onClick:e,children:[(0,A.jsx)(uo,{}),t]})}function Nd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pd({value:e,label:t,depth:n=0}){if(Array.isArray(e)||Nd(e)){let r=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e),i=Nd(e)&&typeof e[`Node Type`]==`string`?e[`Node Type`]:null;return(0,A.jsxs)(`details`,{open:n<3,className:`ml-3 text-xs`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer font-mono`,children:[t?`${t}: `:``,i??(Array.isArray(e)?`[${r.length}]`:`{${r.length}}`)]}),r.map(([e,t])=>(0,A.jsx)(Pd,{value:t,label:e,depth:n+1},e))]})}return(0,A.jsxs)(`div`,{className:`ml-6 font-mono text-xs break-words`,children:[t?(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[t,`: `]}):null,JSON.stringify(e)]})}function Fd({run:e}){let[t,n]=(0,_.useState)({type:`idle`});return(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(R,{size:`xs`,variant:`outline`,disabled:t.type===`running`,onClick:async()=>{n({type:`running`});try{n({type:`done`,outcome:await e()})}catch(e){n({type:`failed`,error:e})}},children:t.type===`running`?`Running EXPLAIN…`:`Explain`}),t.type===`running`?(0,A.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Asking the database for the plan.`}):null,t.type===`failed`?(0,A.jsx)(z,{error:t.error,title:`EXPLAIN failed`}):null,t.type===`done`?(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t.outcome.executing?`Executing plan: the database ran this query to measure it.`:`Plan only: the query was not run.`,t.outcome.instance?` Planned on ${t.outcome.instance}.`:``]}),(0,A.jsx)(`div`,{className:`max-h-96 overflow-auto rounded-md bg-muted p-2`,children:(0,A.jsx)(Pd,{value:t.outcome.plan})}),(0,A.jsxs)(`details`,{className:`text-xs`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer`,children:`Raw JSON`}),(0,A.jsx)(rd,{children:JSON.stringify(t.outcome.plan,null,2)})]})]}):null]})}var Id=e=>JSON.stringify(e,null,2)??`undefined`;function Ld({record:e}){let t={headers:e.headers,params:e.params,query:e.query,body:e.body,session:e.session,ip:e.ip},n=e.error?[e.error.phase,e.error.file,e.error.site].filter(Boolean).join(` · `):``;return(0,A.jsxs)(A.Fragment,{children:[e.error?(0,A.jsxs)(Ad,{title:`Error`,children:[(0,A.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-2.5 text-sm`,children:[(0,A.jsxs)(`div`,{children:[e.error.name,`: `,e.error.message]}),n?(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n}):null]}),e.error.stack?(0,A.jsx)(Md,{children:e.error.stack}):null]}):null,(0,A.jsx)(Ad,{title:`Request (redacted)`,children:(0,A.jsx)(Md,{children:Id(t)})}),(0,A.jsx)(Ad,{title:`Response`,children:(0,A.jsx)(Md,{children:Id({status:e.status,...e.response})})}),e.queries?.nPlusOne?.length?(0,A.jsx)(Ad,{title:`Queries (${e.queries.count})`,children:(0,A.jsx)(Md,{children:Id(e.queries)})}):null]})}function Rd(e){return e.sql||e.shape||`${e.collection||`collection`}.${e.command||`command`}\n${JSON.stringify(e.pipeline??{},null,2)}`}function zd(e){return e.driver===`postgres`&&/^(select|with)\b/i.test((e.sql||``).trim())}var Bd={phase:`var(--chart-3)`,query:`var(--chart-1)`,cache:`var(--chart-2)`};function Vd({request:e}){let t=[...e.phases.map(e=>({label:e.name,at:e.startedAt,duration:e.durationMs,kind:`phase`})),...e.queries.map(e=>({label:Rd(e).replace(/\s+/g,` `).slice(0,90),at:e.startedAt,duration:e.durationMs,kind:`query`})),...Array.isArray(e.cache)?e.cache.map(e=>({label:`${e.type} ${e.key||e.keys?.join(`, `)||``}`.trim(),at:e.at,duration:e.durationMs||0,kind:`cache`})):[]];if(!t.length)return(0,A.jsx)(U,{title:`No timed work recorded for this request.`});let n=Math.max(e.durationMs||0,1);return(0,A.jsxs)(`div`,{className:`space-y-1.5`,"aria-label":`Waterfall`,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[[`phase`,`query`,`cache`].map(e=>(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-sm`,style:{background:Bd[e]}}),e===`phase`?`Phases`:e===`query`?`Queries`:`Cache`]},e)),(0,A.jsxs)(`span`,{className:`ml-auto tabular-nums`,children:[`0 to `,J(n)]})]}),t.map((t,r)=>{let i=Math.max(0,Math.min(100,(t.at-e.startedAt)/n*100)),a=Math.max(.5,Math.min(100-i,t.duration/n*100));return(0,A.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,14rem)_1fr_4.5rem] items-center gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`truncate font-mono`,title:t.label,children:t.label}),(0,A.jsx)(`span`,{className:`relative h-3 rounded-sm bg-muted/70`,children:(0,A.jsx)(`span`,{className:`absolute inset-y-0 rounded-sm`,style:{left:`${i}%`,width:`${a}%`,background:Bd[t.kind]}})}),(0,A.jsx)(`span`,{className:`text-right tabular-nums`,children:J(t.duration)})]},r)})]})}function Hd({id:e}){let[t,n]=(0,_.useState)(null);return(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:async()=>{try{let{curl:t}=await k(`api/requests/${encodeURIComponent(e)}/curl`);await navigator.clipboard.writeText(t),n({tone:`ok`,text:`Copied. Redacted values stay redacted.`})}catch(e){let t=e instanceof Error?e.message:String(e);n({tone:`error`,text:`Could not copy the curl command: ${t} Try again, or copy it from the server's request log.`})}},children:`Copy as curl`}),t?(0,A.jsx)(`span`,{role:`status`,className:t.tone===`error`?`text-xs text-destructive`:`text-xs text-muted-foreground`,children:t.text}):null]})}function Ud({query:e,requestId:t,nPlusOne:n,session:r,slowest:i}){let a=r.mode===`development`,o=r.role===`admin`,s=a?zd(e):o&&!!e.shapeId;return(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border p-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(Y,{children:e.driver}),(0,A.jsx)(`span`,{className:`w-28`,children:(0,A.jsx)(Od,{ms:e.durationMs,max:i,text:J(e.durationMs)})}),(0,A.jsxs)(`span`,{className:`tabular-nums`,children:[q(e.rowCount),` rows`]}),n?(0,A.jsx)(Y,{tone:`warning`,children:`N+1`}):null,e.error?(0,A.jsx)(`span`,{className:`text-destructive`,children:e.error}):null]}),(0,A.jsx)(Md,{children:Rd(e)}),e.bindings?(0,A.jsx)(Md,{children:`bindings: ${JSON.stringify(e.bindings,null,2)}`}):null,s?(0,A.jsx)(Fd,{run:async()=>k(a?`api/requests/${encodeURIComponent(t)}/queries/${encodeURIComponent(e.id)}/explain`:`api/queries/${encodeURIComponent(e.shapeId??``)}/explain`,{method:`POST`})}):null]})}function Wd({requestId:e}){let{data:t,error:n,loading:r}=H(`api/ai?requestId=${encodeURIComponent(e)}`);return n?(0,A.jsx)(z,{error:n,title:`Could not load the AI runs`}):!t&&r?(0,A.jsx)(Ks,{rows:1}):t?.available?t.runs.length?(0,A.jsx)(`ul`,{className:`space-y-1`,children:t.runs.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`a`,{className:`block rounded-lg border p-2.5 text-sm hover:bg-muted/60`,href:`#ai/${encodeURIComponent(e.traceId)}`,children:[e.name,` · `,e.status,` · `,J(e.duration)]})},e.traceId))}):(0,A.jsx)(U,{title:`No AI runs collected for this request yet.`}):(0,A.jsx)(U,{title:t?.title??t?.message??`AI observation is not available.`})}function Gd({id:e,session:t,onClose:n}){let{data:r,error:i,loading:a,reload:o}=H(`api/requests/${encodeURIComponent(e)}`),s=t.mode===`development`;if(i&&!r)return(0,A.jsxs)(`div`,{children:[n?(0,A.jsx)($,{onClick:n}):null,(0,A.jsx)(z,{error:i,title:`Could not load this request`,onRetry:o})]});if(!r)return a?(0,A.jsx)(Ks,{rows:5}):null;let c=new Set(r.warnings.map(e=>e.shape)),l=Array.isArray(r.cache)?null:r.cache,u=Array.isArray(r.cache)?r.cache:null,d=r.partial===!0,f=Math.max(0,...r.queries.map(e=>e.durationMs));return(0,A.jsxs)(`section`,{"aria-label":`Request detail`,className:`space-y-3`,children:[(0,A.jsxs)(`div`,{children:[n?(0,A.jsx)($,{onClick:n,children:`Close request`}):null,(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(_d,{method:r.method}),(0,A.jsx)(hd,{status:r.status}),(0,A.jsx)(`h2`,{className:`min-w-0 font-mono text-base font-semibold break-all`,children:r.path})]})]}),(0,A.jsx)(jd,{items:[{label:`Duration`,value:J(r.durationMs)},{label:`Started`,value:(0,A.jsx)(ed,{at:r.startedAt})},{label:`Route`,value:r.route??`—`},{label:`Queries`,value:q(r.queryCount)},{label:`Warnings`,value:q(r.warningCount)},{label:`Id`,value:(0,A.jsx)(`span`,{className:`font-mono text-xs`,children:r.id})}]}),d?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,A.jsx)(Y,{children:`not sampled`}),` Kept because it was slow or failed. Phases, queries and logs were not recorded for it.`]}):null,r.error?(0,A.jsx)(`p`,{className:`text-sm text-destructive`,children:r.error}):null,r.warnings.length?(0,A.jsx)(Ad,{title:`Warnings`,children:r.warnings.map((e,t)=>(0,A.jsxs)(`p`,{className:`rounded-lg border border-warning/40 bg-warning/10 p-2.5 text-sm`,children:[e.message,` `,e.caller?(0,A.jsxs)(`a`,{className:`underline`,href:`vscode://file/${e.caller.file}:${e.caller.line}:${e.caller.column}`,children:[e.caller.file,`:`,e.caller.line]}):null]},t))}):null,(0,A.jsx)(Hd,{id:r.id}),r.record?(0,A.jsx)(Ld,{record:r.record}):null,(0,A.jsx)(Ad,{title:`Waterfall`,children:(0,A.jsx)(Vd,{request:r})}),(0,A.jsx)(Ad,{title:`Queries (${r.queries.length})`,children:r.queries.length?(0,A.jsxs)(`div`,{className:`space-y-2`,children:[r.queries.map(e=>(0,A.jsx)(Ud,{query:e,requestId:r.id,nPlusOne:c.has(e.shape??e.sql??``),session:t,slowest:f},e.id)),r.droppedQueries?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.droppedQueries,` more queries ran but were not kept (the per-request limit was reached).`]}):null]}):(0,A.jsx)(U,{title:`No queries recorded.`})}),l?(0,A.jsx)(Ad,{title:`Cache`,children:(0,A.jsxs)(`p`,{className:`text-sm tabular-nums`,children:[l.hits,` hits · `,l.misses,` misses · `,l.writes,` writes`]})}):u?.length?(0,A.jsx)(Ad,{title:`Cache`,children:(0,A.jsx)(`ul`,{className:`font-mono text-xs`,children:u.map((e,t)=>(0,A.jsxs)(`li`,{children:[e.type,` `,e.key||e.keys?.join(`, `)||``]},t))})}):null,(0,A.jsx)(Ad,{title:`Request logs`,children:r.logs.length?(0,A.jsx)(`ul`,{className:`space-y-2`,children:r.logs.map((e,t)=>(0,A.jsxs)(`li`,{className:`rounded-lg border p-2.5 text-sm`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(yd,{level:e.level}),(0,A.jsxs)(`span`,{children:[e.module,` · `,e.action,` · `,td(e.at)]})]}),(0,A.jsx)(`div`,{className:`mt-1 break-words`,children:e.message}),e.context===void 0?null:(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-xs`,children:`Context`}),(0,A.jsx)(id,{value:e.context})]})]},t))}):(0,A.jsx)(U,{title:`No logs recorded.`})}),s||r.mails?.length?(0,A.jsx)(Ad,{title:`Request mail`,children:r.mails?.length?(0,A.jsx)(`ul`,{className:`space-y-1`,children:r.mails.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`a`,{className:`block rounded-lg border p-2.5 text-sm hover:bg-muted/60`,href:`#mail/${encodeURIComponent(e)}`,children:[`Mail `,e]})},e))}):(0,A.jsx)(U,{title:`No mail captured.`})}):null,s?(0,A.jsx)(Ad,{title:`AI runs`,children:(0,A.jsx)(Wd,{requestId:r.id})}):null]})}var Kd={q:``,status:``,method:``,route:``,since:``},qd=[{value:``,label:`All`},{value:`2xx`,label:`2xx`},{value:`3xx`,label:`3xx`},{value:`4xx`,label:`4xx`},{value:`5xx`,label:`5xx`}],Jd=[{value:``,label:`Any time`},{value:`15m`,label:`Last 15 min`},{value:`1h`,label:`Last hour`},{value:`24h`,label:`Last 24 hours`}];function Yd({row:e,selected:t,onOpen:n,label:r,slowest:i}){let a=Dd(n);return(0,A.jsxs)(W,{"data-state":t?`selected`:void 0,"aria-current":t||void 0,...a,children:[(0,A.jsx)(K,{className:`w-16`,children:(0,A.jsx)(hd,{status:e.status})}),(0,A.jsxs)(K,{className:`max-w-0 min-w-56 whitespace-normal`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(_d,{method:e.method}),(0,A.jsx)(`div`,{className:`truncate font-mono text-xs`,title:e.path,children:e.path})]}),(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[e.persisted?(0,A.jsx)(Y,{tone:`brand`,children:`saved`}):null,e.partial?(0,A.jsx)(Y,{children:`not sampled`}):null,e.partial?null:(0,A.jsxs)(`span`,{className:`tabular-nums`,children:[e.queryCount,` queries`]}),e.warningCount?(0,A.jsx)(Y,{tone:`warning`,children:`⚠ ${e.warningCount}`}):null,r?(0,A.jsx)(`span`,{children:r}):null]})]}),(0,A.jsx)(K,{className:`w-28`,children:(0,A.jsx)(Od,{ms:e.durationMs,max:i,text:J(e.durationMs),tone:e.status&&e.status>=500?`bg-destructive`:`bg-brand`})}),(0,A.jsx)(K,{className:`w-24 text-right text-xs whitespace-nowrap text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.startedAt})})]})}function Xd({route:e,navigate:t,session:n}){let r=n.mode===`production`,i=n.role===`admin`,[a,o]=(0,_.useState)(Kd),[s,c]=(0,_.useState)(Kd),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null),h=Object.values(s).some(e=>e.trim()),{data:g,error:v,loading:y,reload:b}=H(`api/requests${dd(s)}`,{refreshMs:1e4}),{data:x}=H(r?`api/instances`:null),S=(0,_.useRef)(h);(0,_.useEffect)(()=>{S.current=h},[h]),lu([`request`],(0,_.useCallback)(e=>{if(e.type!==`request`||S.current)return;let t=e.data;u(e=>[t,...e.filter(e=>e.id!==t.id)].slice(0,200))},[]));let C=(0,_.useMemo)(()=>{if(!g)return[];if(h)return g;let e=new Set(l.map(e=>e.id));return[...l,...g.filter(t=>!e.has(t.id))].slice(0,200)},[g,l,h]),w=async()=>{try{await k(`api/requests`,{method:`DELETE`}),u([]),f(!1),m(null),t(``),b()}catch(e){m(e)}},T=C.flatMap(e=>e.durationMs==null?[]:[e.durationMs]),ee=T.length?Math.max(...T):0,te=C.filter(e=>e.status!=null),ne=te.filter(e=>(e.status??0)>=500).length,re=kd(T,95),ie=()=>{o(Kd),c(Kd)},ae=e=>{let t={...a,status:e};o(t),c(t)},oe=e=>t=>o(n=>({...n,[e]:t.target.value}));return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(bd,{title:`Requests`,description:r?`Sampled requests, plus slow and failed ones kept without a timeline.`:`Every request your app served, newest first. Open one to see its timeline, queries and logs.`,children:[(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:b,children:[(0,A.jsx)(vs,{}),`Refresh`]}),i?d?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(R,{size:`sm`,variant:`destructive`,onClick:w,children:`Confirm clear`}),(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>f(!1),children:`Cancel`})]}):(0,A.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>f(!0),children:`Clear`}):null]}),p?(0,A.jsx)(z,{error:p,title:`Could not clear the requests`,className:`mb-3`}):null,C.length?(0,A.jsx)(xd,{items:[{label:`Requests`,value:C.length,hint:h?`matching the filters`:`in the list`},{label:`Server errors`,value:te.length?Xu(ne/te.length*100):`—`,hint:`${ne} with a 5xx status`,tone:ne?`destructive`:`success`},{label:`p95 duration`,value:J(re),hint:`95 % finished faster`},{label:`Slowest`,value:J(ee||null),hint:`longest in the list`}]}):null,(0,A.jsxs)(X,{label:`Request filters`,onSubmit:()=>c(a),trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:C.length,noun:`request`}),h?(0,A.jsx)(Td,{onClick:ie}):null]}),children:[(0,A.jsx)(od,{type:`search`,placeholder:`Search url or id`,"aria-label":`Search url or id`,className:`min-w-44 flex-1`,value:a.q,onChange:oe(`q`)}),(0,A.jsx)(Cd,{label:`Status class`,options:qd,value:qd.some(e=>e.value===a.status)?a.status:`x`,onChange:ae}),(0,A.jsx)(od,{placeholder:`Status: 404 or 5xx`,"aria-label":`Status`,className:`w-36`,value:a.status,onChange:oe(`status`)}),(0,A.jsx)(od,{placeholder:`Method`,"aria-label":`Method`,className:`w-24`,value:a.method,onChange:oe(`method`)}),(0,A.jsx)(od,{placeholder:`Route`,"aria-label":`Route`,className:`w-32`,value:a.route,onChange:oe(`route`)}),(0,A.jsx)(sd,{"aria-label":`Since`,value:a.since,onChange:oe(`since`),children:Jd.map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,A.jsx)(R,{type:`submit`,size:`sm`,children:`Filter`})]}),(0,A.jsxs)(`div`,{className:e?`grid gap-4 xl:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`:void 0,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[v?(0,A.jsx)(z,{error:v,title:`Could not load the requests`,onRetry:b}):null,!g&&y?(0,A.jsx)(Ks,{}):null,g&&!C.length?(0,A.jsx)(U,{title:h?`No request matches these filters. Loosen or reset them.`:`No requests yet. Make a request to your app.`,hint:h?`Use Clear filters to see every request again.`:`New requests appear here as they arrive.`}):null,C.length?(0,A.jsxs)(Ed,{label:`Requests`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Status`}),(0,A.jsx)(G,{className:Z,children:`Request`}),(0,A.jsx)(G,{className:`${Z} text-right`,children:`Duration`}),(0,A.jsx)(G,{className:`${Z} text-right`,children:`When`})]})}),(0,A.jsx)(pu,{children:C.map(n=>(0,A.jsx)(Yd,{row:n,selected:n.id===e,onOpen:()=>t(n.id),slowest:ee,label:r?ud(n.instance,x?.instances):null},n.id))})]}):null]}),e?(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsx)(Gd,{id:e,session:n,onClose:()=>t(``)},e)}):null]})]})}function Zd({values:e,width:t=120,height:n=28,label:r,className:i}){if(e.length<2)return(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,role:`img`,"aria-label":r??`No trend yet`,children:`no trend yet`});let a=Math.min(...e),o=Math.max(...e)-a||1,s=t/(e.length-1),c=e.map((e,t)=>`${(t*s).toFixed(1)},${(n-2-(e-a)/o*(n-4)).toFixed(1)}`).join(` `);return(0,A.jsx)(`svg`,{viewBox:`0 0 ${t} ${n}`,width:t,height:n,role:`img`,"aria-label":r??`Trend`,className:i,children:(0,A.jsx)(`polyline`,{points:c,fill:`none`,stroke:`var(--chart-2)`,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`})})}function Qd({title:e,series:t,format:n,height:r=140,max:i}){let a=t.flatMap(e=>e.points);if(a.length<2)return(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e,`: waiting for more readings.`]});let o=Math.min(...a.map(e=>e.at)),s=Math.max(...a.map(e=>e.at)),c=i??(Math.max(...a.map(e=>e.value))||1),l=r-6-18,u=e=>56+(e-o)/(s-o||1)*420,d=e=>6+l-Math.min(e,c)/c*l,f=[0,.5,1].map(e=>e*c);return(0,A.jsxs)(`figure`,{className:`m-0`,children:[(0,A.jsxs)(`figcaption`,{className:`mb-1 flex flex-wrap items-center gap-3 text-xs`,children:[(0,A.jsx)(`span`,{className:`font-medium`,children:e}),t.map(e=>(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`inline-block h-0.5 w-3`,style:{background:e.color}}),e.name]},e.name))]}),(0,A.jsxs)(`svg`,{viewBox:`0 0 480 ${r}`,className:`w-full`,role:`img`,"aria-label":`${e}: ${t.map(e=>`${e.name} latest ${n(e.points.at(-1)?.value??0)}`).join(`, `)}`,children:[f.map(e=>(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`line`,{x1:56,x2:476,y1:d(e),y2:d(e),stroke:`var(--border)`,strokeWidth:1}),(0,A.jsx)(`text`,{x:52,y:d(e)+3,textAnchor:`end`,fontSize:9,fill:`var(--muted-foreground)`,children:n(e)})]},e)),t.map(e=>(0,A.jsx)(`polyline`,{fill:`none`,stroke:e.color,strokeWidth:1.5,strokeLinejoin:`round`,points:e.points.map(e=>`${u(e.at).toFixed(1)},${d(e.value).toFixed(1)}`).join(` `)},e.name)),(0,A.jsx)(`text`,{x:56,y:r-4,fontSize:9,fill:`var(--muted-foreground)`,children:new Date(o).toLocaleTimeString()}),(0,A.jsx)(`text`,{x:476,y:r-4,textAnchor:`end`,fontSize:9,fill:`var(--muted-foreground)`,children:new Date(s).toLocaleTimeString()})]})]})}var $d=[1,2,5,10,25,50,100,250,500,1e3,2500,5e3,1e4,3e4];function ef(e){let t=$d,n=t[e];return n===void 0?`> ${t.at(-1)} ms`:`${e===0?0:t[e-1]}–${n} ms`}function tf({histogram:e}){let t=e.counts,n=t.findIndex(e=>e>0);if(n===-1)return(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No timings recorded yet.`});let r=t.length-1-[...t].reverse().findIndex(e=>e>0),i=Math.max(...t,1);return(0,A.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,"aria-label":`Latency histogram`,children:t.slice(n,r+1).map((e,t)=>{let r=n+t;return(0,A.jsxs)(`li`,{className:`grid grid-cols-[6.5rem_1fr_3rem] items-center gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:ef(r)}),(0,A.jsx)(`span`,{className:`h-3 rounded-sm bg-muted`,children:(0,A.jsx)(`span`,{className:`block h-3 rounded-sm`,style:{width:`${e/i*100}%`,background:`var(--chart-2)`}})}),(0,A.jsx)(`span`,{className:`text-right tabular-nums`,children:e.toLocaleString(`en-US`)})]},r)})})}function nf({p50:e,p95:t,max:n}){let r=Math.max(n,t,e,1),i=e=>`${Math.min(100,e/r*100)}%`;return(0,A.jsxs)(`div`,{role:`img`,"aria-label":`p50 ${J(e)}, p95 ${J(t)}, max ${J(n)}`,className:`relative h-3 min-w-24 rounded-sm bg-muted`,children:[(0,A.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-sm opacity-40`,style:{width:i(n),background:`var(--chart-4)`}}),(0,A.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-sm opacity-70`,style:{width:i(t),background:`var(--chart-1)`}}),(0,A.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-sm`,style:{width:i(e),background:`var(--chart-2)`}})]})}function rf({title:e,description:t,legend:n,table:r,loading:i,className:a,children:o}){let[s,c]=(0,_.useState)(!1),l=(0,_.useId)();return(0,A.jsxs)(`section`,{"aria-labelledby":l,className:F(`min-w-0 rounded-xl border bg-card p-3.5 transition-opacity`,i&&`opacity-60`,a),children:[(0,A.jsxs)(`header`,{className:`mb-2 flex flex-wrap items-start justify-between gap-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h3`,{id:l,className:`text-sm font-semibold`,children:e}),t?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null]}),r?(0,A.jsx)(`button`,{type:`button`,"aria-pressed":s,onClick:()=>c(e=>!e),className:`rounded-md border px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none aria-pressed:bg-muted aria-pressed:text-foreground`,children:`Table`}):null]}),n?(0,A.jsx)(`div`,{className:`mb-2`,children:n}):null,s&&r?(0,A.jsx)(`div`,{className:`max-h-80 overflow-auto`,children:r}):o]})}function af({items:e,shape:t=`rect`}){return e.length<2?null:(0,A.jsx)(`ul`,{"aria-label":`Legend`,className:`m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-xs`,children:e.map(e=>(0,A.jsxs)(`li`,{className:`inline-flex items-center gap-1.5 text-muted-foreground`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:F(`inline-block`,t===`line`?`h-0.5 w-3`:`size-2.5 rounded-sm`),style:{background:e.color}}),e.label]},e.key))})}function of({id:e,title:t,rows:n,total:r,left:i}){return(0,A.jsxs)(`div`,{id:e,role:`tooltip`,className:F(`pointer-events-none absolute top-1 z-10 min-w-40 max-w-64 rounded-lg border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md`,i>60?`-translate-x-[calc(100%+0.75rem)]`:`translate-x-3`),style:{left:`${i}%`},children:[(0,A.jsx)(`p`,{className:`mb-1 font-medium`,children:t}),(0,A.jsx)(`ul`,{className:`m-0 list-none space-y-0.5 p-0`,children:n.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,className:F(`inline-block shrink-0`,e.shape===`line`?`h-0.5 w-3`:`size-2.5 rounded-sm`),style:{background:e.color}}),(0,A.jsx)(`span`,{className:`font-semibold tabular-nums`,children:e.value}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.label})]},e.key))}),r===void 0?null:(0,A.jsxs)(`p`,{className:`mt-1 flex justify-between gap-3 border-t pt-1`,children:[(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`Total`}),(0,A.jsx)(`span`,{className:`font-semibold tabular-nums`,children:r})]})]})}var sf=36e5,cf=24*sf,lf=new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),uf=new Intl.DateTimeFormat(`en-US`,{weekday:`short`}),df=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`}),ff=e=>lf.format(e).replace(/^24:/,`00:`);function pf(e,t,n=1){if(t>=cf)return df.format(e);if(t>=6*sf)return`${uf.format(e)} ${ff(e)}`;let r=new Date(e),i=r.getHours()===0&&r.getMinutes()===0;return n===0||i?`${df.format(e)} ${ff(e)}`:ff(e)}function mf(e,t){return t>=cf?df.format(e):`${df.format(e)} ${ff(e)}`}function hf(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e));for(let n of[1,2,2.5,5,10])if(e<=n*t)return n*t;return 10*t}function gf(e){return`var(--series-${e})`}var _f=`var(--series-other)`,vf={uncached:gf(1),cached:gf(2),output:gf(3)},yf=`devtools.ai.series`;function bf(e){return e===`models`?yf:`${yf}.${e}`}var xf={slots:{},order:[]};function Sf(e,t){let n={...e.slots},r=e.order.filter(e=>e in n);for(let e of t){if(!(e in n)){let i=new Set(Object.values(n)),a=1;for(;a<=6&&i.has(a);)a+=1;if(a>6){let e=r.find(e=>!t.includes(e))??r[0];if(e===void 0)continue;a=n[e]??1,delete n[e],r=r.filter(t=>t!==e)}n[e]=a}r=[...r.filter(t=>t!==e),e]}return{slots:n,order:r}}function Cf(e){try{let t=sessionStorage.getItem(e),n=t?JSON.parse(t):null;if(n&&n.slots&&Array.isArray(n.order))return{slots:n.slots,order:n.order}}catch{}return xf}function wf(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}}function Tf(e,t=`models`){let n=`${t}\u0001${e.join(`\0`)}`;return(0,_.useMemo)(()=>{let n=bf(t),r=Sf(Cf(n),e);return wf(n,r),e=>gf(r.slots[e]??1)},[n])}var Ef=640,Df=220,Of=52,kf=8,Af=2,jf=4;function Mf(e,t,n,r){let i=Math.min(jf,n/2,r);return`M${e},${t+r}V${t+i}a${i},${i} 0 0 1 ${i},${-i}H${e+n-i}a${i},${i} 0 0 1 ${i},${i}V${t+r}Z`}function Nf({title:e,set:t,stepMs:n,format:r,color:i,emptyText:a,loading:o,description:s}){let[c,l]=(0,_.useState)(null),u=(0,_.useId)(),d=t.buckets.length,f=e=>e.other?_f:i(e.key),p=t.buckets.map((e,n)=>t.series.reduce((e,t)=>e+(t.values[n]??0),0)),m=p.reduce((e,t)=>e+t,0),h=(0,A.jsx)(af,{items:t.series.map(e=>({key:e.key,label:e.label,color:f(e)}))}),g=(0,A.jsxs)(`table`,{"aria-label":`${e} as a table`,className:`w-full text-xs tabular-nums`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 font-medium`,children:`Period`}),t.series.map(e=>(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 text-right font-medium`,children:e.label},e.key)),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 text-right font-medium`,children:`Total`})]})}),(0,A.jsx)(`tbody`,{children:t.buckets.map((e,i)=>(0,A.jsxs)(`tr`,{className:`border-t`,children:[(0,A.jsx)(`th`,{scope:`row`,className:`py-1 pr-3 text-left font-normal`,children:mf(e,n)}),t.series.map(e=>(0,A.jsx)(`td`,{className:`py-1 pr-3 text-right`,children:r(e.values[i]??0)},e.key)),(0,A.jsx)(`td`,{className:`py-1 text-right font-medium`,children:r(p[i]??0)})]},e))})]});if(!d||m===0)return(0,A.jsx)(rf,{title:e,loading:o,description:s,children:(0,A.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:a})});let v=hf(Math.max(...p)),y=582/d,b=Math.max(2,y-Math.min(4,y*.2)),x=e=>198-e/v*190,S=Math.ceil(d/6),C=`${e}: ${r(m)} in total over ${d} periods from ${mf(t.buckets[0]??0,n)}. Series: ${t.series.map(e=>e.label).join(`, `)}. Use the left and right arrow keys to read each period.`,w=e=>{if(e.key===`ArrowLeft`)l(e=>Math.max(0,(e??d)-1));else if(e.key===`ArrowRight`)l(e=>Math.min(d-1,(e??-1)+1));else if(e.key===`Home`)l(0);else if(e.key===`End`)l(d-1);else if(e.key===`Escape`)l(null);else return;e.preventDefault()},T=c===null?void 0:t.buckets[c];return(0,A.jsx)(rf,{title:e,loading:o,description:s,legend:h,table:g,children:(0,A.jsxs)(`div`,{role:`group`,tabIndex:0,"aria-label":C,"aria-describedby":c===null?void 0:u,onKeyDown:w,onFocus:()=>l(e=>e??d-1),onBlur:()=>l(null),onMouseLeave:()=>l(null),className:`relative rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,A.jsxs)(`svg`,{viewBox:`0 0 ${Ef} ${Df}`,className:`w-full`,"aria-hidden":`true`,children:[[0,.5,1].map(e=>(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`line`,{x1:Of,x2:634,y1:x(v*e),y2:x(v*e),stroke:`var(--border)`,strokeWidth:1}),(0,A.jsx)(`text`,{x:46,y:x(v*e)+3,textAnchor:`end`,fontSize:10,fill:`var(--muted-foreground)`,children:r(v*e)})]},e)),t.buckets.map((e,r)=>{let i=Of+r*y+(y-b)/2,a=0,o=t.series.map(e=>({series:e,value:e.values[r]??0})).filter(e=>e.value>0);return(0,A.jsxs)(`g`,{children:[o.map((e,t)=>{let n=x(a);a+=e.value;let r=x(a),s=Math.max(1,n-r),c={fill:f(e.series),stroke:`var(--card)`,strokeWidth:Af/2};return t===o.length-1?(0,A.jsx)(`path`,{d:Mf(i,r,b,s),...c},e.series.key):(0,A.jsx)(`rect`,{x:i,y:r,width:b,height:s,...c},e.series.key)}),c===r?(0,A.jsx)(`rect`,{x:Of+r*y,y:kf,width:y,height:190,fill:`var(--foreground)`,opacity:.06}):null,r%S===0?(0,A.jsx)(`text`,{x:Of+r*y+y/2,y:214,textAnchor:`middle`,fontSize:10,fill:`var(--muted-foreground)`,children:pf(e,n,r)}):null,(0,A.jsx)(`rect`,{"data-testid":`chart-hit`,x:Of+r*y,y:kf,width:y,height:190,fill:`transparent`,onMouseEnter:()=>l(r),onMouseMove:()=>l(r)})]},e)})]}),c!==null&&T!==void 0?(0,A.jsx)(of,{id:u,title:mf(T,n),left:(Of+c*y+y/2)/Ef*100,total:r(p[c]??0),rows:[...t.series].reverse().map(e=>({key:e.key,label:e.label,value:r(e.values[c]??0),color:f(e)}))}):null]})})}var Pf=640,Ff=200,If=52,Lf=8;function Rf({title:e,seriesName:t,points:n,stepMs:r,format:i,color:a,emptyText:o,loading:s,description:c}){let[l,u]=(0,_.useState)(null),d=(0,_.useId)(),f=n.length,p=n.filter(e=>e.rate!==null),m=(0,A.jsxs)(`table`,{"aria-label":`${e} as a table`,className:`w-full text-xs tabular-nums`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 font-medium`,children:`Period`}),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 text-right font-medium`,children:t}),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 text-right font-medium`,children:`Runs`}),(0,A.jsx)(`th`,{scope:`col`,className:`py-1 text-right font-medium`,children:`Failed`})]})}),(0,A.jsx)(`tbody`,{children:n.map(e=>(0,A.jsxs)(`tr`,{className:`border-t`,children:[(0,A.jsx)(`th`,{scope:`row`,className:`py-1 pr-3 text-left font-normal`,children:mf(e.at,r)}),(0,A.jsx)(`td`,{className:`py-1 pr-3 text-right`,children:e.rate===null?`No runs`:i(e.rate)}),(0,A.jsx)(`td`,{className:`py-1 pr-3 text-right`,children:e.runs}),(0,A.jsx)(`td`,{className:`py-1 text-right`,children:e.errors})]},e.at))})]});if(!f||!p.length)return(0,A.jsx)(rf,{title:e,loading:s,description:c,children:(0,A.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:o})});let h=hf(Math.max(...p.map(e=>e.rate??0))),g=580/f,v=e=>If+e*g+g/2,y=e=>178-e/h*170,b=Math.ceil(f/6),x=[];n.forEach((e,t)=>{if(e.rate===null){x.push([]);return}x.length||x.push([]),x[x.length-1]?.push({index:t,rate:e.rate})});let S=x.filter(e=>e.length),C=`${e}: latest ${i(p.at(-1)?.rate??0)}, highest ${i(Math.max(...p.map(e=>e.rate??0)))} over ${f} periods. Use the left and right arrow keys to read each period.`,w=e=>{if(e.key===`ArrowLeft`)u(e=>Math.max(0,(e??f)-1));else if(e.key===`ArrowRight`)u(e=>Math.min(f-1,(e??-1)+1));else if(e.key===`Home`)u(0);else if(e.key===`End`)u(f-1);else if(e.key===`Escape`)u(null);else return;e.preventDefault()},T=l===null?void 0:n[l];return(0,A.jsx)(rf,{title:e,loading:s,description:c,table:m,children:(0,A.jsxs)(`div`,{role:`group`,tabIndex:0,"aria-label":C,"aria-describedby":l===null?void 0:d,onKeyDown:w,onFocus:()=>u(e=>e??f-1),onBlur:()=>u(null),onMouseLeave:()=>u(null),className:`relative rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,A.jsxs)(`svg`,{viewBox:`0 0 ${Pf} ${Ff}`,className:`w-full`,"aria-hidden":`true`,children:[[0,.5,1].map(e=>(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`line`,{x1:If,x2:632,y1:y(h*e),y2:y(h*e),stroke:`var(--border)`,strokeWidth:1}),(0,A.jsx)(`text`,{x:46,y:y(h*e)+3,textAnchor:`end`,fontSize:10,fill:`var(--muted-foreground)`,children:i(h*e)})]},e)),n.map((e,t)=>t%b===0?(0,A.jsx)(`text`,{x:v(t),y:194,textAnchor:`middle`,fontSize:10,fill:`var(--muted-foreground)`,children:pf(e.at,r,t)},e.at):null),l===null?null:(0,A.jsx)(`line`,{"data-testid":`crosshair`,x1:v(l),x2:v(l),y1:Lf,y2:178,stroke:`var(--muted-foreground)`,strokeWidth:1,strokeDasharray:`3 3`}),S.map(e=>e.length===1?(0,A.jsx)(`circle`,{"data-testid":`line-dot`,cx:v(e[0]?.index??0),cy:y(e[0]?.rate??0),r:4,fill:a,stroke:`var(--card)`,strokeWidth:2},e[0]?.index):(0,A.jsx)(`path`,{"data-testid":`line-segment`,d:e.map((e,t)=>`${t===0?`M`:`L`}${v(e.index).toFixed(1)},${y(e.rate).toFixed(1)}`).join(``),fill:`none`,stroke:a,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`},e[0]?.index)),T&&T.rate!==null?(0,A.jsx)(`circle`,{cx:v(l??0),cy:y(T.rate),r:4,fill:a,stroke:`var(--card)`,strokeWidth:2}):null,n.map((e,t)=>(0,A.jsx)(`rect`,{"data-testid":`chart-hit`,x:If+t*g,y:Lf,width:g,height:170,fill:`transparent`,onMouseEnter:()=>u(t),onMouseMove:()=>u(t)},e.at))]}),T?(0,A.jsx)(of,{id:d,title:mf(T.at,r),left:v(l??0)/Pf*100,rows:[{key:`rate`,label:t,value:T.rate===null?`No runs`:i(T.rate),color:a,shape:`line`},{key:`runs`,label:`runs`,value:String(T.runs),color:`transparent`},{key:`errors`,label:`failed`,value:String(T.errors),color:`transparent`}]}):null]})})}function zf({share:e,children:t}){let n=e>0?Math.max(3,Math.min(100,e*100)):0;return(0,A.jsxs)(`div`,{className:`ml-auto flex w-24 flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`tabular-nums`,children:t}),(0,A.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,A.jsx)(`span`,{className:`block h-full rounded-full bg-brand`,style:{width:`${n}%`}})})]})}function Bf(e,t,n){if(e===t)return`No change`;if(t===0)return`New`;let r=Math.abs((e-t)/t*100),i=r<1?`<1`:r<10?r.toFixed(1).replace(/\.0$/,``):Math.round(r);return`${e>t?`▲`:`▼`} ${i}% vs ${n}`}function Vf({current:e,previous:t,against:n,risingIsBad:r,previousComplete:i=!0}){return i?(0,A.jsx)(`span`,{className:F(`text-xs tabular-nums`,r&&e>t?`text-warning`:`text-muted-foreground`),children:Bf(e,t,n)}):(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`No earlier data`})}function Hf(){let{data:e,error:t,loading:n,reload:r}=H(`api/background`,{refreshMs:1e4});return(0,A.jsx)(`section`,{"aria-label":`Background queries`,className:`mt-4`,children:(0,A.jsxs)(Ad,{title:`Background queries (outside any request)`,children:[t?(0,A.jsx)(z,{error:t,title:`Could not load the background queries`,onRetry:r}):null,!e&&n?(0,A.jsx)(Ks,{rows:2}):null,e&&!e.queries.length?(0,A.jsx)(U,{title:`No background queries yet.`,hint:`Boot work, scheduler ticks and queue jobs that query the database show up here.`}):null,(0,A.jsx)(`div`,{className:`space-y-2`,children:e?.queries.map(e=>(0,A.jsxs)(`div`,{className:`space-y-1.5 rounded-lg border p-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(Y,{children:e.driver}),(0,A.jsx)(`span`,{className:`tabular-nums`,children:J(e.durationMs)})]}),(0,A.jsx)(Md,{children:e.sql||e.shape||`${e.collection??`collection`}.${e.command??`command`}`})]},e.id))})]})})}var Uf=100,Wf=[{value:`all`,label:`All`},{value:`slow`,label:`Slow`},{value:`nplus`,label:`N+1`},{value:`errors`,label:`Errors`}],Gf=[{value:`total`,label:`Total time`},{value:`p95`,label:`p95`},{value:`count`,label:`Count`},{value:`n+1`,label:`N+1`}];function Kf({shape:e,isAdmin:t,production:n,onClose:r}){let i=e.slowest;return(0,A.jsxs)(`section`,{"aria-label":`Query detail`,className:`space-y-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)($,{onClick:r,children:`Close query`}),(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,A.jsx)(Y,{children:e.driver}),e.connection]})]}),(0,A.jsx)(jd,{items:[{label:`Runs`,value:q(e.count)},{label:`p50`,value:J(e.p50Ms)},{label:`p95`,value:J(e.p95Ms)},{label:`Max`,value:J(e.histogram.maxMs)},{label:`Errors`,value:e.errors||`—`},{label:`Last seen`,value:(0,A.jsx)(ed,{at:e.lastSeen})}]}),(0,A.jsx)(Ad,{title:`Query shape`,children:(0,A.jsx)(Md,{children:e.shape})}),(0,A.jsx)(Ad,{title:`Latency`,children:(0,A.jsx)(tf,{histogram:e.histogram})}),(0,A.jsx)(Ad,{title:`Slowest example`,children:i?(0,A.jsxs)(`p`,{className:`text-sm`,children:[(0,A.jsx)(`span`,{className:`tabular-nums`,children:J(i.durationMs)}),` ·`,` `,(0,A.jsx)(ed,{at:i.at}),i.route?(0,A.jsxs)(A.Fragment,{children:[` · `,i.route]}):null,i.requestId?(0,A.jsxs)(A.Fragment,{children:[` `,`·`,` `,(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(i.requestId)}`,children:`open request`})]}):null]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No slow example kept yet.`})}),e.nPlusOne.requests?(0,A.jsxs)(`p`,{className:`rounded-lg border border-warning/40 bg-warning/10 p-2.5 text-sm`,children:[(0,A.jsx)(Y,{tone:`warning`,children:`N+1`}),` in `,e.nPlusOne.requests,` sampled requests, up to`,` `,e.nPlusOne.maxPerRequest,` runs in one request.`]}):null,t?(0,A.jsx)(Ad,{title:`EXPLAIN`,children:e.explainable?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Fd,{run:()=>k(`api/queries/${encodeURIComponent(e.id)}/explain`,{method:`POST`})}),n?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`EXPLAIN uses the slowest example, held by the instance that ran it. It only plans the query unless the project allows executing plans.`}):null]}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`EXPLAIN is not available for this query type (Postgres SELECT/WITH and MongoDB find, aggregate and count only).`})}):null]})}function qf({route:e,navigate:t,instance:n,session:r}){let[i,a]=(0,_.useState)(`total`),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`all`),u=r.mode===`production`,d=r.role===`admin`,{data:f,error:p,loading:m,reload:h}=H(`api/queries/stats${dd({sort:i,instance:n===`all`?void 0:n})}`,{refreshMs:1e4}),g=f?.shapes.find(t=>t.id===e),v=f?Math.round(f.sampleRate*1e3)/10:null,y=!!o.trim()||c!==`all`,b=(0,_.useMemo)(()=>{let e=o.trim().toLowerCase();return(f?.shapes??[]).filter(t=>e&&!t.shape.toLowerCase().includes(e)?!1:c===`slow`?t.p95Ms>=Uf:c===`nplus`?t.nPlusOne.requests>0:c!==`errors`||t.errors>0)},[f,o,c]),x=f?.shapes??[],S=x.filter(e=>e.p95Ms>=Uf).length,C=x.filter(e=>e.nPlusOne.requests>0).length,w=x.reduce((e,t)=>e+t.errors,0),T=Math.max(0,...b.map(e=>e.p95Ms));return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(bd,{title:`Queries`,description:f?`${v!==null&&v<100?`Counts come from sampled requests (${v} %).`:`Counts cover every request.`}`:`Database queries grouped by shape, with latency, errors and N+1 findings.`,children:[(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[`Sort by`,(0,A.jsx)(sd,{value:i,onChange:e=>a(e.target.value),children:Gf.map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:h,children:[(0,A.jsx)(vs,{}),`Refresh`]})]}),p?(0,A.jsx)(z,{error:p,title:`Could not load the query statistics`,onRetry:h}):null,!f&&m?(0,A.jsx)(Ks,{}):null,f&&!f.shapes.length?(0,A.jsx)(U,{title:`No queries recorded yet. Make requests that use the database; they appear here.`,hint:`Shapes appear after the first sampled request runs a query.`}):null,f?.shapes.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{items:[{label:`Query shapes`,value:q(x.length)},{label:`Total runs`,value:q(x.reduce((e,t)=>e+t.count,0))},{label:`Slow shapes`,value:q(S),hint:`p95 of ${Uf} ms or more`,tone:S?`warning`:`success`},{label:`N+1 shapes`,value:q(C),tone:C?`warning`:`success`},{label:`Failed runs`,value:q(w),tone:w?`destructive`:`success`}]}),(0,A.jsxs)(X,{label:`Query filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:b.length,total:x.length,noun:`shape`}),y?(0,A.jsx)(Td,{onClick:()=>{s(``),l(`all`)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Search queries`,placeholder:`Search query text`,value:o,onChange:e=>s(e.target.value)}),(0,A.jsx)(Cd,{label:`Show`,options:Wf,value:c,onChange:l})]}),(0,A.jsxs)(`div`,{className:e?`grid gap-4 xl:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]`:void 0,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:b.length?(0,A.jsxs)(Ed,{label:`Query statistics`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Shape`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Count`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p50`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Mean`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Max`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Errors`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`N+1`}),u?(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Instances`}):null]})}),(0,A.jsx)(pu,{children:b.map(n=>{let r=Dd(()=>t(n.id));return(0,A.jsxs)(W,{"data-state":n.id===e?`selected`:void 0,...r,children:[(0,A.jsx)(K,{className:`max-w-0 min-w-64 whitespace-normal`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(Y,{className:`mt-0.5`,children:n.driver}),(0,A.jsx)(`button`,{type:`button`,className:`line-clamp-2 min-w-0 text-left font-mono text-xs break-all focus-visible:outline-none`,title:n.shape,onClick:e=>{e.stopPropagation(),t(n.id)},children:n.shape.length>200?`${n.shape.slice(0,200)}…`:n.shape})]})}),(0,A.jsx)(K,{className:Q,children:q(n.count)}),(0,A.jsx)(K,{className:Q,children:J(n.p50Ms)}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(Od,{ms:n.p95Ms,max:T,text:J(n.p95Ms),tone:n.p95Ms>=Uf?`bg-warning`:`bg-brand`})}),(0,A.jsx)(K,{className:Q,children:J(n.meanMs)}),(0,A.jsx)(K,{className:Q,children:J(n.histogram.maxMs)}),(0,A.jsx)(K,{className:Q,children:n.errors||`—`}),(0,A.jsx)(K,{className:Q,children:n.nPlusOne.requests?(0,A.jsx)(Y,{tone:`warning`,mono:!0,children:n.nPlusOne.requests}):`—`}),u?(0,A.jsx)(K,{className:Q,children:n.instances.length}):null]},n.id)})})]}):(0,A.jsx)(U,{title:`No query matches these filters.`,hint:`Loosen the search or choose All.`})}),e?(0,A.jsx)(`div`,{className:`min-w-0`,children:g?(0,A.jsx)(Kf,{shape:g,isAdmin:d,production:u,onClose:()=>t(``)}):(0,A.jsx)(U,{title:`This query shape is no longer in the statistics. Pick another one.`,hint:`Statistics reset when the app restarts.`})}):null]})]}):null,f&&f.evicted?(0,A.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[f.evicted,` less recently used shapes were dropped to keep memory bounded.`]}):null,r.mode===`development`?(0,A.jsx)(Hf,{}):null]})}function Jf({route:e}){let t=e.phases.slice(0,8),n=Math.max(...t.map(e=>e.sumMs),1);return t.length?(0,A.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,"aria-label":`Slowest phases`,children:t.map(e=>(0,A.jsxs)(`li`,{className:`grid grid-cols-[10rem_1fr_6rem] items-center gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`truncate font-mono`,title:e.name,children:e.name}),(0,A.jsx)(`span`,{className:`h-3 rounded-sm bg-muted`,children:(0,A.jsx)(`span`,{className:`block h-3 rounded-sm`,style:{width:`${e.sumMs/n*100}%`,background:`var(--chart-3)`}})}),(0,A.jsxs)(`span`,{className:`text-right tabular-nums`,children:[J(e.sumMs/Math.max(e.count,1)),` avg`]})]},e.name))}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No phase timings for this route.`})}function Yf({instance:e}){let[t,n]=(0,_.useState)(`total`),[r,i]=(0,_.useState)(null),{data:a,error:o,loading:s,reload:c}=H(`api/routes/stats${dd({sort:t,instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),l=a?Math.round(a.sampleRate*1e3)/10:null,u=a?.routes??[],d=u.reduce((e,t)=>e+t.count,0),f=u.reduce((e,t)=>e+t.errors,0),p=Math.max(0,...u.map(e=>e.p95Ms));return(0,A.jsxs)(`section`,{"aria-label":`Route statistics`,children:[(0,A.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-base font-semibold`,children:`Route statistics`}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l!==null&&l<100?`Counts come from sampled requests (${l} %).`:`How long each route takes, slowest total first.`})]}),(0,A.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[`Sort by`,(0,A.jsxs)(sd,{value:t,onChange:e=>n(e.target.value),children:[(0,A.jsx)(`option`,{value:`total`,children:`Total time`}),(0,A.jsx)(`option`,{value:`p95`,children:`p95`}),(0,A.jsx)(`option`,{value:`count`,children:`Count`}),(0,A.jsx)(`option`,{value:`errors`,children:`Errors`})]})]})]}),o?(0,A.jsx)(z,{error:o,title:`Could not load the route statistics`,onRetry:c}):null,!a&&s?(0,A.jsx)(Ks,{rows:3}):null,a&&!a.routes.length?(0,A.jsx)(U,{title:`No route timings yet. Make some requests to your app.`,hint:`Routes appear here after they serve a request.`}):null,a?.routes.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{label:`Route summary`,items:[{label:`Routes timed`,value:q(u.length)},{label:`Requests`,value:q(d)},{label:`Failed requests`,value:q(f),hint:`5xx or thrown errors`,tone:f?`destructive`:`success`},{label:`Slowest p95`,value:J(p)}]}),(0,A.jsxs)(Ed,{label:`Route statistics table`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Route`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Count`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p50`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`}),(0,A.jsx)(G,{className:Z,children:`Spread`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Errors`})]})}),(0,A.jsx)(pu,{children:a.routes.map(e=>(0,A.jsx)(Xf,{route:e,open:r===e.key,onToggle:()=>i(r===e.key?null:e.key)},e.key))})]})]}):null]})}function Xf({route:e,open:t,onToggle:n}){let r=Dd(n);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(W,{"data-state":t?`selected`:void 0,...r,children:[(0,A.jsx)(K,{className:`max-w-0 min-w-56 font-mono text-xs`,children:(0,A.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left focus-visible:outline-none`,title:e.key,"aria-expanded":t,onClick:e=>{e.stopPropagation(),n()},children:e.key})}),(0,A.jsx)(K,{className:Q,children:q(e.count)}),(0,A.jsx)(K,{className:Q,children:J(e.p50Ms)}),(0,A.jsx)(K,{className:Q,children:J(e.p95Ms)}),(0,A.jsx)(K,{children:(0,A.jsx)(nf,{p50:e.p50Ms,p95:e.p95Ms,max:e.histogram.maxMs})}),(0,A.jsx)(K,{className:Q,children:e.errors?(0,A.jsx)(Y,{tone:`destructive`,mono:!0,children:e.errors}):`—`})]}),t?(0,A.jsx)(W,{children:(0,A.jsxs)(K,{colSpan:6,className:`bg-muted/20`,children:[(0,A.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Slowest phases`}),(0,A.jsx)(Jf,{route:e})]})}):null]})}function Zf(){let{data:e,error:t,loading:n,reload:r}=H(`api/routes`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),c=i.toLowerCase(),l=e??[],u=[...new Set(l.map(e=>e.method.toUpperCase()))].sort(),d=l.filter(e=>(!o||e.method.toUpperCase()===o)&&`${e.method} ${e.path} ${e.name??``} ${(e.middleware??[]).join(` `)}`.toLowerCase().includes(c)),f=!!i||!!o;return(0,A.jsxs)(`section`,{"aria-label":`Route map`,className:`mt-8`,children:[(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsx)(`h3`,{className:`text-base font-semibold`,children:`Route map`}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Every route the app registered.`})]}),(0,A.jsxs)(X,{label:`Route filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:d.length,total:l.length,noun:`route`}),f?(0,A.jsx)(Td,{onClick:()=>{a(``),s(``)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Filter routes`,placeholder:`Filter routes`,value:i,onChange:e=>a(e.target.value)}),u.length>1?(0,A.jsx)(Cd,{label:`Method`,value:o,onChange:s,options:[{value:``,label:`All`},...u.map(e=>({value:e,label:e}))]}):null]}),t?(0,A.jsx)(z,{error:t,title:`Could not load the route map`,onRetry:r}):null,!e&&n?(0,A.jsx)(Ks,{rows:3}):null,e&&!d.length?(0,A.jsx)(U,{title:`No routes found.`,hint:f?`Clear the filters to see every route.`:`Register routes in your app and restart it.`}):null,d.length?(0,A.jsxs)(Ed,{label:`Route map table`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Method`}),(0,A.jsx)(G,{className:Z,children:`Path`}),(0,A.jsx)(G,{className:Z,children:`Name`}),(0,A.jsx)(G,{className:Z,children:`Middleware`})]})}),(0,A.jsx)(pu,{children:d.map((e,t)=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`w-24`,children:(0,A.jsx)(_d,{method:e.method})}),(0,A.jsx)(K,{className:`max-w-0 min-w-48 font-mono text-xs`,children:(0,A.jsx)(`div`,{className:`truncate`,title:e.path,children:e.path})}),(0,A.jsx)(K,{children:e.name||`—`}),(0,A.jsx)(K,{className:`text-xs whitespace-normal`,children:(e.middleware??[]).join(`, `)||`—`})]},`${e.method} ${e.path} ${t}`))})]}):null]})}function Qf({instance:e}){return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Routes`,description:`How each route performs, and the full map of routes your app registered.`}),(0,A.jsx)(Yf,{instance:e}),(0,A.jsx)(Zf,{})]})}function $f({label:e,value:t,trend:n}){return(0,A.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-2.5`,children:[(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,A.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:t}),n?(0,A.jsx)(Zd,{values:n,width:110,height:24,label:`${e} trend`}):null]})}var ep=(e,t)=>e.map(e=>({at:e.at,value:t(e)}));function tp({entry:e}){let{snapshot:t,history:n}=e,r=[...n,t].filter((e,t,n)=>t===n.findIndex(t=>t.at===e.at)),i=Object.entries(t.gcByKind).filter(([,e])=>e.count>0),a=t.heapLimitBytes?t.heapUsedBytes/t.heapLimitBytes*100:null;return(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsxs)(Zs,{className:`text-base`,children:[e.instance.label,` `,(0,A.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· up `,Qu(t.uptimeSeconds),` · Node `,e.instance.nodeVersion]})]})}),(0,A.jsxs)($s,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-4`,children:[(0,A.jsx)($f,{label:`RSS`,value:Yu(t.rssBytes),trend:r.map(e=>e.rssBytes)}),(0,A.jsx)($f,{label:`Heap used`,value:`${Yu(t.heapUsedBytes)}${a===null?``:` (${a.toFixed(0)} % of limit)`}`,trend:r.map(e=>e.heapUsedBytes)}),(0,A.jsx)($f,{label:`Heap total / limit`,value:`${Yu(t.heapTotalBytes)} / ${Yu(t.heapLimitBytes)}`}),(0,A.jsx)($f,{label:`CPU`,value:Xu(t.cpuPercent),trend:r.map(e=>e.cpuPercent)}),(0,A.jsx)($f,{label:`Event loop delay p50`,value:J(t.eventLoopDelayP50Ms)}),(0,A.jsx)($f,{label:`Event loop delay p99`,value:J(t.eventLoopDelayP99Ms)}),(0,A.jsx)($f,{label:`Event loop delay max`,value:J(t.eventLoopDelayMaxMs)}),(0,A.jsx)($f,{label:`Event loop utilization`,value:Xu(t.eventLoopUtilization*100,0),trend:r.map(e=>e.eventLoopUtilization)}),(0,A.jsx)($f,{label:`GC runs (last interval)`,value:q(t.gcCount)}),(0,A.jsx)($f,{label:`GC pause (last interval)`,value:J(t.gcPauseMs)}),(0,A.jsx)($f,{label:`External memory`,value:Yu(t.externalBytes)})]}),(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,A.jsx)(Qd,{title:`Memory`,format:Yu,series:[{name:`RSS`,color:`var(--chart-1)`,points:ep(r,e=>e.rssBytes)},{name:`Heap used`,color:`var(--chart-2)`,points:ep(r,e=>e.heapUsedBytes)},{name:`Heap total`,color:`var(--chart-3)`,points:ep(r,e=>e.heapTotalBytes)}]}),(0,A.jsx)(Qd,{title:`Event loop delay`,format:e=>J(e),series:[{name:`p50`,color:`var(--chart-2)`,points:ep(r,e=>e.eventLoopDelayP50Ms)},{name:`p99`,color:`var(--chart-1)`,points:ep(r,e=>e.eventLoopDelayP99Ms)},{name:`max`,color:`var(--chart-4)`,points:ep(r,e=>e.eventLoopDelayMaxMs)}]}),(0,A.jsx)(Qd,{title:`CPU`,format:e=>Xu(e,0),series:[{name:`CPU`,color:`var(--chart-1)`,points:ep(r,e=>e.cpuPercent)}]}),(0,A.jsx)(Qd,{title:`Event loop utilization`,format:e=>Xu(e*100,0),max:1,series:[{name:`ELU`,color:`var(--chart-3)`,points:ep(r,e=>e.eventLoopUtilization)}]})]}),i.length?(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Garbage collection since start:`,` `,i.map(([e,t])=>`${e} ${t.count} runs, ${J(t.pauseMs)} paused`).join(` · `)]}):null]})]})}function np({instance:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/resources${dd({instance:e===`all`?void 0:e})}`,{refreshMs:5e3}),a=t?.instances??[],o=e=>Math.max(0,...a.map(e));return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Resources`,description:`Memory, CPU, event loop and garbage collection of each running instance. Updated every 5 seconds.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:i,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),n?(0,A.jsx)(z,{error:n,title:`Could not load the resource readings`,onRetry:i}):null,!t&&r?(0,A.jsx)(Ks,{rows:3}):null,t&&!t.instances.length?(0,A.jsx)(U,{title:`No instance has reported its resources yet. Readings appear a few seconds after the app starts.`,hint:`If the app is running and this stays empty, check that the monitor is enabled.`}):null,a.length?(0,A.jsx)(xd,{items:[{label:`Instances`,value:q(a.length)},{label:`Highest memory (RSS)`,value:Yu(o(e=>e.snapshot.rssBytes))},{label:`Highest CPU`,value:Xu(o(e=>e.snapshot.cpuPercent))},{label:`Worst event loop p99`,value:J(o(e=>e.snapshot.eventLoopDelayP99Ms))}]}):null,(0,A.jsx)(`div`,{className:`space-y-4`,children:t?.instances.map(e=>(0,A.jsx)(tp,{entry:e},e.instance.id))})]})}function rp(e){return e===`ok`?(0,A.jsx)(Y,{tone:`success`,children:`ok`}):e===`error`?(0,A.jsx)(Y,{tone:`destructive`,children:`error`}):(0,A.jsx)(Y,{children:`unknown`})}function ip({history:e}){return e.length?(0,A.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-0.5 p-0`,"aria-label":`Health history, oldest first`,children:e.map(e=>(0,A.jsx)(`li`,{className:`h-6 w-2 rounded-sm`,style:{background:e.status===`ok`?`var(--success)`:`var(--destructive)`},title:`${new Date(e.at).toLocaleTimeString()}: ${e.status}${e.failed.length?` (${e.failed.join(`, `)})`:``}`},e.at))}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet.`})}function ap({instance:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/health${dd({instance:e===`all`?void 0:e})}`,{refreshMs:15e3}),a=t?.instances??[],o=a.filter(e=>e.report.status===`ok`).length,s=a.flatMap(e=>Object.values(e.report.checks)),c=s.filter(e=>!e).length;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Health`,description:`Readiness checks of each instance, updated every 15 seconds.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:i,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),n?(0,A.jsx)(z,{error:n,title:`Could not load the health checks`,onRetry:i}):null,!t&&r?(0,A.jsx)(Ks,{rows:3}):null,t&&!t.instances.length?(0,A.jsx)(U,{title:`No instance has reported a health check yet. The first check runs shortly after the app starts.`,hint:`Register readiness checks in your app to see them here.`}):null,a.length?(0,A.jsx)(xd,{items:[{label:`Instances`,value:q(a.length)},{label:`Ready`,value:`${o} / ${a.length}`,tone:o===a.length?`success`:`destructive`},{label:`Checks`,value:q(s.length)},{label:`Failing checks`,value:q(c),tone:c?`destructive`:`success`}]}):null,(0,A.jsx)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:a.map(({instance:e,report:t})=>{let n=Object.entries(t.checks);return(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsxs)(Zs,{className:`flex items-center gap-2 text-base`,children:[e.label,` `,rp(t.status)]})}),(0,A.jsxs)($s,{className:`space-y-3`,children:[(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Checked `,(0,A.jsx)(ed,{at:t.checkedAt})]}),n.length?(0,A.jsx)(`ul`,{className:`divide-y rounded-lg border text-sm`,children:n.map(([e,t])=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,title:e,children:e}),(0,A.jsx)(Y,{tone:t?`success`:`destructive`,children:t?`passing`:`failing`})]},e))}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No readiness checks are registered.`}),(0,A.jsx)(ip,{history:t.history})]})]},e.id)})})]})}var op=[{value:``,label:`All`},{value:`request`,label:`Requests`},{value:`log`,label:`Logs`}];function sp({instance:e,session:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),c=t.mode===`production`,{data:l,error:u,loading:d,reload:f}=H(`api/errors${dd({instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),{data:p}=H(c?`api/instances`:null),m=(0,_.useMemo)(()=>l?.groups??[],[l]),h=!!i.trim()||!!o,g=(0,_.useMemo)(()=>{let e=i.trim().toLowerCase();return m.filter(t=>(!o||t.source===o)&&(!e||`${t.message} ${t.name??``} ${t.route??``}`.toLowerCase().includes(e)))},[m,i,o]);return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Errors`,description:`Failed requests and error logs, grouped by message, route and source.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:f,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),u?(0,A.jsx)(z,{error:u,title:`Could not load the errors`,onRetry:f}):null,!l&&d?(0,A.jsx)(Ks,{}):null,l&&!l.groups.length?(0,A.jsx)(U,{title:`No errors recorded. Failed requests and error logs appear here.`,hint:`Nothing has failed since the app started.`}):null,m.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{items:[{label:`Error groups`,value:q(m.length),tone:`destructive`},{label:`Occurrences`,value:q(m.reduce((e,t)=>e+t.count,0))},{label:`From requests`,value:q(m.filter(e=>e.source===`request`).length),hint:`groups`},{label:`From logs`,value:q(m.filter(e=>e.source===`log`).length),hint:`groups`}]}),(0,A.jsxs)(X,{label:`Error filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:g.length,total:m.length,noun:`group`}),h?(0,A.jsx)(Td,{onClick:()=>{a(``),s(``)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Search errors`,placeholder:`Search message, name or route`,value:i,onChange:e=>a(e.target.value)}),(0,A.jsx)(Cd,{label:`Source`,options:op,value:o,onChange:s})]})]}):null,m.length&&!g.length?(0,A.jsx)(U,{title:`No error group matches these filters.`,hint:`Clear the filters to see every group.`}):null,g.length?(0,A.jsxs)(Ed,{label:`Error groups`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Message`}),(0,A.jsx)(G,{className:Z,children:`Route`}),(0,A.jsx)(G,{className:`${Z} text-right`,children:`Status`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Count`}),(0,A.jsx)(G,{className:Z,children:`First seen`}),(0,A.jsx)(G,{className:Z,children:`Last seen`}),c?(0,A.jsx)(G,{className:Z,children:`Instances`}):null]})}),(0,A.jsx)(pu,{children:g.map(e=>(0,A.jsx)(cp,{group:e,open:n===e.id,onToggle:()=>r(n===e.id?null:e.id),production:c,labels:e.instances.map(e=>ud(e,p?.instances)).join(`, `)},e.id))})]}):null]})}function cp({group:e,open:t,onToggle:n,production:r,labels:i}){let a=Dd(n);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(W,{"data-state":t?`selected`:void 0,...a,children:[(0,A.jsxs)(K,{className:`max-w-md min-w-64 whitespace-normal`,children:[(0,A.jsx)(`button`,{type:`button`,className:`text-left font-medium break-words focus-visible:outline-none`,"aria-expanded":t,onClick:e=>{e.stopPropagation(),n()},children:e.message}),(0,A.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[e.name?(0,A.jsx)(`span`,{className:`font-mono`,children:e.name}):null,e.source===`log`?(0,A.jsx)(Y,{children:`log`}):null]})]}),(0,A.jsx)(K,{className:`max-w-48 font-mono text-xs`,children:(0,A.jsx)(`div`,{className:`truncate`,title:e.route??void 0,children:e.route??`—`})}),(0,A.jsx)(K,{className:`text-right`,children:e.status==null?`—`:(0,A.jsx)(hd,{status:e.status})}),(0,A.jsx)(K,{className:`${Q} font-semibold`,children:q(e.count)}),(0,A.jsx)(K,{className:`text-xs text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.firstSeen})}),(0,A.jsx)(K,{className:`text-xs`,children:(0,A.jsx)(ed,{at:e.lastSeen})}),r?(0,A.jsx)(K,{className:`text-xs whitespace-normal`,children:i||`—`}):null]}),t?(0,A.jsx)(W,{children:(0,A.jsxs)(K,{colSpan:r?7:6,className:`bg-muted/20 whitespace-normal`,children:[e.stack?(0,A.jsx)(Md,{children:e.stack}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No stack was available for this error.`}),e.lastRequestId?(0,A.jsx)(`p`,{className:`mt-2 text-sm`,children:(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(e.lastRequestId)}`,children:`Open the last request`})}):null]})}):null]})}var lp=[``,`debug`,`info`,`warn`,`error`,`success`],up=300;function dp({instance:e,session:t}){let n=t.mode===`production`,[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)([]),{data:d,error:f,loading:p,reload:m}=H(`api/logs${dd({level:r,module:a,instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),{data:h}=H(n?`api/instances`:null);lu([`log`],(0,_.useCallback)(e=>{if(e.type!==`log`)return;let t=e.data;u(e=>[{...t,instance:t.instance??null},...e].slice(0,up))},[]));let g=(0,_.useMemo)(()=>{if(!d)return[];let e=d[0]?.at??0;return[...l.filter(t=>t.at>e&&(!r||t.level===r)&&(!a||t.module.toLowerCase().includes(a.toLowerCase()))),...d].slice(0,up)},[d,l,r,a]),v=(0,_.useMemo)(()=>{let e=s.trim().toLowerCase();return e?g.filter(t=>`${t.message} ${t.action}`.toLowerCase().includes(e)):g},[g,s]),y=!!r||!!a||!!s.trim(),b=e=>g.filter(t=>t.level===e).length;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Logs`,description:n?`Warnings and errors, without their context. Newest first.`:`What your app logged, newest first, with live entries as they arrive.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:m,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),g.length?(0,A.jsx)(xd,{items:[{label:`Entries`,value:q(g.length),hint:`loaded`},{label:`Errors`,value:q(b(`error`)),tone:b(`error`)?`destructive`:`success`},{label:`Warnings`,value:q(b(`warn`)),tone:b(`warn`)?`warning`:`success`},{label:`Modules`,value:q(new Set(g.map(e=>e.module)).size)}]}):null,(0,A.jsxs)(X,{label:`Log filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:v.length,total:g.length,noun:`entry`}),y?(0,A.jsx)(Td,{onClick:()=>{i(``),o(``),c(``)}}):null]}),children:[(0,A.jsx)(Sd,{label:`Search messages`,placeholder:`Search messages`,value:s,onChange:e=>c(e.target.value)}),(0,A.jsx)(Sd,{label:`Filter module`,placeholder:`Filter module`,className:`max-w-56 min-w-36 flex-none`,value:a,onChange:e=>o(e.target.value)}),(0,A.jsx)(Cd,{label:`Level`,value:r,onChange:i,options:lp.map(e=>({value:e,label:e||`All`}))})]}),f?(0,A.jsx)(z,{error:f,title:`Could not load the logs`,onRetry:m}):null,!d&&p?(0,A.jsx)(Ks,{}):null,d&&!v.length?(0,A.jsx)(U,{title:`No logs found for these filters.`,hint:y?`Clear the filters, or pick a lower level to see more.`:`Entries appear here as your app logs them.`}):null,v.length?(0,A.jsxs)(Ed,{label:`Logs`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Time`}),(0,A.jsx)(G,{className:Z,children:`Level`}),(0,A.jsx)(G,{className:Z,children:`Source`}),(0,A.jsx)(G,{className:Z,children:`Message`})]})}),(0,A.jsx)(pu,{children:v.map((e,t)=>(0,A.jsxs)(W,{className:`align-top`,children:[(0,A.jsx)(K,{className:`w-24 text-xs text-muted-foreground tabular-nums`,title:new Date(e.at).toLocaleString(),children:td(e.at)}),(0,A.jsx)(K,{className:`w-20`,children:(0,A.jsx)(yd,{level:e.level})}),(0,A.jsxs)(K,{className:`max-w-48 text-xs`,children:[(0,A.jsxs)(`div`,{className:`truncate font-medium`,title:`${e.module} · ${e.action}`,children:[e.module,` · `,e.action]}),(0,A.jsxs)(`div`,{className:`flex gap-2 text-muted-foreground`,children:[n&&e.instance?(0,A.jsx)(`span`,{children:ud(e.instance,h?.instances)}):null,e.requestId?(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(e.requestId)}`,children:`request`}):null]})]}),(0,A.jsxs)(K,{className:`min-w-64 text-sm whitespace-normal`,children:[(0,A.jsx)(`div`,{className:`break-words`,children:e.message}),e.context===void 0?null:(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground`,children:`Context`}),(0,A.jsx)(id,{value:e.context})]})]})]},`${e.at}-${t}`))})]}):null]})}var fp={success:`bg-emerald-500`,failed:`bg-destructive`,skipped:`bg-muted-foreground/40`};function pp({runs:e}){return e?.length?(0,A.jsx)(`span`,{className:`inline-flex items-center gap-1`,"aria-label":`Recent runs`,children:e.map(e=>(0,A.jsx)(`span`,{role:`img`,"aria-label":`${e.outcome} run`,title:[`${e.outcome}, ${J(e.durationMs)}`,new Date(e.startedAt).toLocaleString(),e.error??e.skipReason].filter(Boolean).join(` - `),className:`inline-block h-3 w-1.5 rounded-sm ${fp[e.outcome]}`},e.startedAt+e.outcome))}):(0,A.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}function mp({report:e}){return e.available.scheduler?e.schedules.length?(0,A.jsxs)(Ed,{label:`Schedules`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Name`}),(0,A.jsx)(G,{className:Z,children:`Schedule`}),(0,A.jsx)(G,{className:Z,children:`Last run`}),(0,A.jsx)(G,{className:Z,children:`Next run`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Duration`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Failures`}),(0,A.jsx)(G,{className:Z,children:`Recent runs`}),(0,A.jsx)(G,{className:Z,children:`Last error`})]})}),(0,A.jsx)(pu,{children:e.schedules.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsxs)(K,{className:`font-mono text-xs`,children:[e.name,` `,e.isRunning?(0,A.jsx)(Y,{tone:`info`,children:`running`}):null]}),(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.cron??e.interval??`—`}),(0,A.jsx)(K,{className:`text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.lastRunAt})}),(0,A.jsx)(K,{children:(0,A.jsx)(ed,{at:e.nextRunAt})}),(0,A.jsx)(K,{className:Q,children:J(e.lastDurationMs)}),(0,A.jsx)(K,{className:Q,children:q(e.runs)}),(0,A.jsx)(K,{className:Q,children:e.failures?(0,A.jsx)(Y,{tone:`destructive`,mono:!0,children:e.failures}):`—`}),(0,A.jsx)(K,{children:(0,A.jsx)(pp,{runs:e.recentRuns})}),(0,A.jsx)(K,{className:`max-w-xs text-xs whitespace-normal text-destructive`,children:e.lastError??`—`})]},e.name))})]}):(0,A.jsx)(U,{title:`No scheduled jobs are registered.`,hint:`Jobs you register with the scheduler appear here with their next run.`}):(0,A.jsx)(U,{title:`The scheduler is not installed in this app. Install @warlock.js/scheduler to see its jobs here.`,hint:`Add the package, register a job and restart the app.`})}function hp({report:e}){if(!e.available.queue)return(0,A.jsx)(U,{title:`The queue is not installed in this app. Install @warlock.js/queue to see its job counts here.`,hint:`Add the package, dispatch a job and restart the app.`});if(!e.queues.length)return(0,A.jsx)(U,{title:`No queue reported job counts.`,hint:`Counts appear once a queue has handled a job.`});let t=[...new Set(e.queues.flatMap(e=>Object.keys(e.counts)))];return(0,A.jsxs)(Ed,{label:`Queues`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Queue`}),t.length===0?(0,A.jsx)(G,{className:Z,children:`Counts`}):null,t.map(e=>(0,A.jsx)(G,{className:`${Z} ${Q}`,children:e},e))]})}),(0,A.jsx)(pu,{children:e.queues.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`font-mono text-xs`,children:e.name}),e.countsAvailable===!1?(0,A.jsx)(K,{colSpan:Math.max(t.length,1),className:`text-xs text-muted-foreground`,children:`Counts not available: this queue driver cannot count jobs.`}):null,e.countsAvailable===!1?null:t.map(t=>(0,A.jsx)(K,{className:`${Q} ${t===`failed`&&e.counts[t]?`font-semibold text-destructive`:``}`,children:q(e.counts[t]??0)},t))]},e.name))})]})}function gp({instance:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/jobs${dd({instance:e===`all`?void 0:e})}`,{refreshMs:1e4}),a=(t?.instances??[]).map(e=>e.report),o=a.flatMap(e=>e.schedules),s=o.filter(e=>e.isRunning).length,c=o.filter(e=>e.lastError).length,l=a.flatMap(e=>e.queues).reduce((e,t)=>e+(t.counts.failed??0),0);return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Jobs`,description:`Scheduled jobs with their next run, and the job counts of each queue.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:i,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),n?(0,A.jsx)(z,{error:n,title:`Could not load the jobs`,onRetry:i}):null,!t&&r?(0,A.jsx)(Ks,{rows:3}):null,t&&!t.instances.length?(0,A.jsx)(U,{title:`No instance has reported its jobs yet.`,hint:`Reports arrive a few seconds after the app starts.`}):null,t?.instances.length?(0,A.jsx)(xd,{items:[{label:`Scheduled jobs`,value:q(o.length)},{label:`Running now`,value:q(s),tone:s?`info`:`neutral`},{label:`Jobs with a last error`,value:q(c),tone:c?`destructive`:`success`},{label:`Failed queue jobs`,value:q(l),tone:l?`destructive`:`success`}]}):null,(0,A.jsx)(`div`,{className:`space-y-4`,children:t?.instances.map(({instance:e,report:t})=>(0,A.jsxs)(Ys,{children:[(0,A.jsx)(Xs,{children:(0,A.jsx)(Zs,{className:`text-base`,children:e.label})}),(0,A.jsxs)($s,{className:`space-y-5`,children:[(0,A.jsxs)(`section`,{"aria-label":`Schedules on ${e.label}`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Schedules`}),(0,A.jsx)(mp,{report:t})]}),(0,A.jsxs)(`section`,{"aria-label":`Queues on ${e.label}`,children:[(0,A.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Queues`}),(0,A.jsx)(hp,{report:t})]})]})]},e.id))})]})}function _p({id:e}){let{data:t,error:n,loading:r,reload:i}=H(`api/mails/${encodeURIComponent(e)}`),[a,o]=(0,_.useState)(!0);if(n&&!t)return(0,A.jsx)(z,{error:n,title:`Could not load this message`,onRetry:i});if(!t)return r?(0,A.jsx)(Ks,{rows:4}):null;let s=[[`From`,t.from],[`To`,t.to?.join(`, `)],[`Cc`,t.cc?.join(`, `)],[`Bcc`,t.bcc?.join(`, `)],...Object.entries(t.headers??{})];return(0,A.jsxs)(`section`,{"aria-label":`Mail detail`,className:`space-y-3`,children:[(0,A.jsx)(`h2`,{className:`text-base font-semibold break-words`,children:t.subject||`(No subject)`}),(0,A.jsxs)(Ad,{title:`Headers`,children:[(0,A.jsx)(`table`,{className:`w-full text-sm`,children:(0,A.jsx)(`tbody`,{children:s.map(([e,t])=>(0,A.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,A.jsx)(`th`,{className:`w-24 py-1.5 pr-3 text-left align-top text-xs font-medium text-muted-foreground`,children:e}),(0,A.jsx)(`td`,{className:`py-1.5 break-all`,children:t||`—`})]},e))})}),t.requestId?(0,A.jsx)(`p`,{className:`text-sm`,children:(0,A.jsx)(`a`,{className:`underline`,href:`#requests/${encodeURIComponent(t.requestId)}`,children:`Open the request that sent it`})}):null]}),(0,A.jsx)(Ad,{title:`Body`,actions:(0,A.jsxs)(`div`,{className:`flex gap-1`,children:[(0,A.jsx)(cd,{active:a,onClick:()=>o(!0),children:`HTML`}),(0,A.jsx)(cd,{active:!a,onClick:()=>o(!1),children:`Text`})]}),children:a?(0,A.jsx)(`iframe`,{className:`h-96 w-full rounded-lg border bg-white`,sandbox:``,src:`api/mails/${encodeURIComponent(t.id)}/html`,title:`HTML email body`}):(0,A.jsx)(Md,{children:t.text||`No plain-text body.`})}),(0,A.jsx)(Ad,{title:`Attachments`,children:t.attachments?.length?(0,A.jsx)(`ul`,{className:`list-disc pl-5 text-sm`,children:t.attachments.map((e,t)=>(0,A.jsxs)(`li`,{children:[e.filename,` · `,e.contentType||`unknown type`,` · `,q(e.size),` `,`bytes`]},`${e.filename}-${t}`))}):(0,A.jsx)(U,{title:`No attachments.`})})]})}function vp({route:e,navigate:t}){let{data:n,error:r,loading:i,reload:a}=H(`api/mails`,{refreshMs:3e4}),[o,s]=(0,_.useState)([]);lu([`mail`],(0,_.useCallback)(e=>{if(e.type!==`mail`)return;let t=e.data;s(e=>[t,...e.filter(e=>e.id!==t.id)].slice(0,200))},[]));let c=(0,_.useMemo)(()=>{if(!n)return[];let e=new Set(o.map(e=>e.id));return[...o,...n.filter(t=>!e.has(t.id))]},[n,o]),[l,u]=(0,_.useState)(``),d=l.trim().toLowerCase(),f=d?c.filter(e=>`${e.subject} ${e.to.join(` `)}`.toLowerCase().includes(d)):c,p=new Set(c.flatMap(e=>e.to)).size,m=c.filter(e=>e.requestId).length;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Mail`,description:`Every email your app sent, caught here instead of delivered. Open one to check its headers and body.`,children:(0,A.jsxs)(R,{size:`sm`,variant:`outline`,onClick:a,children:[(0,A.jsx)(vs,{}),`Refresh`]})}),c.length?(0,A.jsx)(xd,{items:[{label:`Messages`,value:q(c.length)},{label:`Recipients`,value:q(p),hint:`distinct addresses`},{label:`Sent by a request`,value:q(m)},{label:`Latest`,value:(0,A.jsx)(ed,{at:c[0]?.capturedAt})}]}):null,(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[c.length?(0,A.jsx)(X,{label:`Mail filters`,trailing:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(wd,{shown:f.length,total:c.length,noun:`message`}),d?(0,A.jsx)(Td,{onClick:()=>u(``)}):null]}),children:(0,A.jsx)(Sd,{label:`Search mail`,placeholder:`Search subject or recipient`,value:l,onChange:e=>u(e.target.value)})}):null,r?(0,A.jsx)(z,{error:r,title:`Could not load the mailbox`,onRetry:a}):null,!n&&i?(0,A.jsx)(Ks,{}):null,n&&!c.length?(0,A.jsx)(U,{title:`No mail captured. Send an email from your app; it appears here.`,hint:`Messages arrive live; there is nothing to configure.`}):null,c.length&&!f.length?(0,A.jsx)(U,{title:`No message matches this search.`,hint:`Clear the search to see every message.`}):null,(0,A.jsx)(`div`,{className:`space-y-1.5`,children:f.map(n=>(0,A.jsxs)(ld,{selected:n.id===e,className:`rounded-xl bg-card p-3`,onClick:()=>t(n.id),children:[(0,A.jsx)(`div`,{className:`font-medium break-words`,children:n.subject||`(No subject)`}),(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:n.to.join(`, `)}),n.requestId?(0,A.jsx)(Y,{tone:`info`,children:`from a request`}):null,(0,A.jsx)(ed,{at:n.capturedAt,className:`ml-auto`})]})]},n.id))})]}),(0,A.jsx)(`div`,{className:`min-w-0`,children:e?(0,A.jsx)(_p,{id:e},e):(0,A.jsx)(U,{title:`Select a message to inspect it.`,hint:`Its headers, HTML body and attachments open here.`})})]})]})}function yp({answer:e}){return(0,A.jsxs)(`div`,{className:`flex flex-col items-center rounded-xl border border-dashed bg-card/50 px-6 py-10 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 grid size-10 place-items-center rounded-full bg-brand/10 text-brand`,children:(0,A.jsx)(As,{className:`size-5`,"aria-hidden":`true`})}),(0,A.jsx)(`p`,{className:`text-sm font-semibold`,children:e.title??`AI data is not available`}),e.message?(0,A.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:e.message}):null,e.command?(0,A.jsxs)(`div`,{className:`mt-4 flex max-w-full items-center gap-2 rounded-md border bg-muted px-3 py-2`,children:[(0,A.jsx)(`code`,{className:`overflow-x-auto font-mono text-xs`,children:e.command}),(0,A.jsx)(Dc,{value:e.command,size:`xs`})]}):null,e.detail?(0,A.jsx)(`p`,{className:`mt-4 max-w-md break-words rounded-md border bg-muted px-3 py-2 font-mono text-xs text-muted-foreground`,children:e.detail}):null]})}function bp(e){return e==null||Number.isNaN(e)?`—`:e===0?`$0`:e>=1?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:`$${e.toFixed(4)}`}function xp(e){if(e==null||Number.isNaN(e))return`—`;let t=(t,n)=>{let r=e/t;return`${r>=100?Math.round(r):r.toFixed(1).replace(/\.0$/,``)}${n}`};return e>=1e9?t(1e9,`B`):e>=1e6?t(1e6,`M`):e>=1e3?t(1e3,`k`):String(Math.round(e))}function Sp(e){if(e==null||Number.isNaN(e))return`—`;let t=e*100;return t===0?`0%`:t>0&&t<.05?`<0.1%`:t<10?`${t.toFixed(1).replace(/\.0$/,``)}%`:`${Math.round(t)}%`}function Cp(e){return e==null||Number.isNaN(e)?`—`:e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)} s`:`${(e/6e4).toFixed(1).replace(/\.0$/,``)} min`}function wp(e){if(e.preset===`24h`)return`previous 24 hours`;if(e.preset===`7d`)return`previous 7 days`;if(e.preset===`30d`)return`previous 30 days`;let t=Math.round((e.to-e.from)/36e5);return t<=48?`previous ${t} hours`:`previous ${Math.round(t/24)} days`}function Tp(){return(0,A.jsxs)(Y,{tone:`warning`,children:[(0,A.jsx)(Is,{className:`size-3`,"aria-hidden":`true`}),`No pricing`]})}function Ep({state:e}){return e===`missing`?(0,A.jsx)(Tp,{}):e===`no-tokens`?(0,A.jsxs)(Y,{tone:`neutral`,children:[(0,A.jsx)(Mo,{className:`size-3`,"aria-hidden":`true`}),`No tokens used`]}):e===`partial`?(0,A.jsxs)(Y,{tone:`info`,children:[(0,A.jsx)(Ao,{className:`size-3`,"aria-hidden":`true`}),`Partly priced`]}):(0,A.jsxs)(Y,{tone:`success`,children:[(0,A.jsx)(Oo,{className:`size-3`,"aria-hidden":`true`}),`Pricing set`]})}function Dp(e){return typeof e==`number`&&Number.isFinite(e)?e:e&&typeof e==`object`?Object.values(e).reduce((e,t)=>e+Dp(t),0):0}function Op(e){let t=e.children.reduce((e,t)=>e+Dp(t.usage?.cost),0),n=Math.max(0,Dp(e.usage?.cost)-t);return n>0?n:null}function kp(e){return Math.max(Op(e)??0,...e.children.map(kp))}function Ap(e,t){if(!(e===null||t<=0))return`color-mix(in srgb, var(--brand) ${(5+20*Math.min(1,e/t)).toFixed(1)}%, transparent)`}function jp(e){return e===`completed`||e===`ok`?`success`:e===`incomplete`?`warning`:e===`error`||e===`failed`?`destructive`:`neutral`}var Mp=e=>e==null?`—`:String(e);function Np(e,t){let n=e.inputIncludesCache===!1?`input excludes cache tokens`:`input includes cache tokens`;return`${Mp(e.input)} input · ${Mp(e.output)} output · ${Mp(e.cachedTokens)} cache read · ${Mp(e.cacheWriteTokens)} cache write · ${t==null?`no pricing`:`${bp(t)} estimated`} (${n})`}function Pp({run:e}){return(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(Y,{tone:jp(e.status),children:e.status}),(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.traceId.slice(0,8)}),e.cost===null&&e.usage.total>0?(0,A.jsx)(Tp,{}):null]}),(0,A.jsx)(`div`,{className:`font-medium break-words`,children:`${e.name} · ${e.status}${e.incomplete?` · Incomplete / truncated`:``} · ${e.duration} ms`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground break-words`,children:e.models.join(`, `)||`Model unreported`}),(0,A.jsx)(`p`,{className:`text-sm`,children:Np(e.usage,e.cost)}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`${e.toolCalls} tool calls · ${e.retries} retries${e.promptKey?` · prompt ${e.promptKey}`:``}`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`${e.traceId} · ${e.requestId?`Request ${e.requestId}`:`Background / no request id`}`})]})}function Fp({span:e,rootStartedAt:t,maxCost:n}){let r=e.status===`incomplete`||e.error?.type===`AgentIncompleteError`||e.error?.type===`AGENT_INCOMPLETE`,i=Date.parse(e.startedAt)-Date.parse(t),a=Op(e);return(0,A.jsxs)(`details`,{open:!0,className:`ml-3 border-l-2 pl-2`,children:[(0,A.jsxs)(`summary`,{className:`cursor-pointer rounded-sm px-1 text-sm`,style:{background:Ap(a,n)},children:[`${e.type} ${e.name} · ${e.status}${r?` · Incomplete / truncated`:``} · +${i} ms · ${e.duration} ms`,a===null?null:(0,A.jsx)(`span`,{className:`ml-2 tabular-nums text-muted-foreground`,children:`· ${bp(a)} estimated`})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`${e.startedAt} → ${e.endedAt}`}),(0,A.jsx)(id,{value:{usage:e.usage,attributes:e.attributes,error:e.error}}),e.children.map((e,r)=>(0,A.jsx)(Fp,{span:e,rootStartedAt:t,maxCost:n},`${e.name}-${r}`))]})}function Ip({run:e,traceId:t,onClose:n}){let{data:r,error:i,loading:a,reload:o}=H(`api/ai/runs/${encodeURIComponent(t)}`);return(0,A.jsxs)(`section`,{"aria-label":`AI run detail`,className:`space-y-3 rounded-xl border bg-card p-3.5`,children:[(0,A.jsx)($,{onClick:n,children:`Close run`}),e?(0,A.jsx)(Pp,{run:e}):null,e?.requestId?(0,A.jsx)(`a`,{className:`inline-block rounded-md border px-3 py-1 text-sm hover:bg-muted/60 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,href:`#requests/${encodeURIComponent(e.requestId)}`,children:`Open HTTP request`}):null,i?(0,A.jsx)(z,{error:i,title:`Could not load this run's spans`,onRetry:o}):null,!r&&a?(0,A.jsx)(Ks,{rows:3}):null,r?(0,A.jsx)(Fp,{span:r.root,rootStartedAt:r.startedAt,maxCost:kp(r.root)}):null]})}var Lp={q:``,requestId:``,status:``,type:``,session:``,prompt:``,groupBy:``};function Rp(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r.trim()&&t.set(n,r.trim());let n=t.toString();return`api/ai/runs${n?`?${n}`:``}`}function zp(e,t){return e===`session`?{session:t.key}:e===`prompt`?{prompt:t.key}:{type:t.key}}function Bp({route:e,navigate:t}){let[n,r]=(0,_.useState)(Lp),[i,a]=(0,_.useState)(Lp),{data:o,error:s,loading:c,reload:l}=H(Rp(i));lu([`ai`],(0,_.useCallback)(()=>l(),[l]));let u=e=>{r(e),a(e),t(``)},d=Object.values(i).some(Boolean),f=(o?.available?o.runs:[]).find(t=>t.traceId===e);return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Runs`,description:`Every AI run your app made: tokens, estimated cost, retries and the span tree of each one.`}),(0,A.jsxs)(X,{label:`AI run filters`,onSubmit:()=>u(n),trailing:d?(0,A.jsx)(R,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>u(Lp),children:`Clear filters`}):void 0,children:[(0,A.jsx)(Sd,{label:`Search AI runs`,placeholder:`Search runs`,value:n.q,onChange:e=>r({...n,q:e.target.value})}),(0,A.jsx)(Sd,{label:`HTTP request id`,placeholder:`Request id`,value:n.requestId,onChange:e=>r({...n,requestId:e.target.value})}),(0,A.jsxs)(sd,{"aria-label":`Status`,value:n.status,onChange:e=>u({...n,status:e.target.value}),children:[(0,A.jsx)(`option`,{value:``,children:`Any status`}),(0,A.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,A.jsx)(`option`,{value:`failed`,children:`Failed`}),(0,A.jsx)(`option`,{value:`incomplete,max-iterations`,children:`Incomplete`})]}),(0,A.jsxs)(sd,{"aria-label":`Type`,value:n.type,onChange:e=>u({...n,type:e.target.value}),children:[(0,A.jsx)(`option`,{value:``,children:`Any type`}),(0,A.jsx)(`option`,{value:`agent`,children:`Agent`}),(0,A.jsx)(`option`,{value:`workflow`,children:`Workflow`}),(0,A.jsx)(`option`,{value:`supervisor`,children:`Supervisor`})]}),(0,A.jsxs)(sd,{"aria-label":`Group by`,value:n.groupBy,onChange:e=>u({...n,groupBy:e.target.value}),children:[(0,A.jsx)(`option`,{value:``,children:`Group by: None`}),(0,A.jsx)(`option`,{value:`session`,children:`Group by: Session`}),(0,A.jsx)(`option`,{value:`prompt`,children:`Group by: Prompt`}),(0,A.jsx)(`option`,{value:`type`,children:`Group by: Type`})]}),(0,A.jsx)(R,{type:`submit`,size:`sm`,children:`Filter / refresh`})]}),s?(0,A.jsx)(z,{error:s,title:`Could not load the AI runs`,onRetry:l}):null,!o&&c?(0,A.jsx)(Ks,{}):null,o&&!o.available?(0,A.jsx)(yp,{answer:o}):null,o?.available&&!o.runs.length?(0,A.jsx)(U,{title:`No AI runs yet. Enable Panoptic observation and execute a flow; runs appear when collection completes.`,hint:d?`No run matches these filters. Clear them to see all runs.`:void 0}):null,o?.available&&o.runs.length?(0,A.jsxs)(`div`,{className:F(`transition-opacity`,c&&`opacity-60`),children:[(0,A.jsx)(xd,{label:`AI runs summary`,items:[{label:`Runs`,value:q(o.stats.count)},{label:`Failed`,value:q(o.stats.failed),tone:o.stats.failed?`warning`:`success`},{label:`Estimated cost`,value:bp(o.stats.estimatedCostUsd),hint:o.stats.unpricedRuns?`Estimated from model pricing · ${q(o.stats.unpricedRuns)} unpriced ${o.stats.unpricedRuns===1?`run`:`runs`} not in the cost`:`Estimated from model pricing`},{label:`p50`,value:Cp(o.stats.p50Ms)},{label:`p95`,value:Cp(o.stats.p95Ms)}]}),o.groups?(0,A.jsx)(`div`,{className:`mb-4`,children:(0,A.jsxs)(Ed,{label:`Run groups`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Group by ${i.groupBy}`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Failed`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Estimated cost`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`})]})}),(0,A.jsx)(pu,{children:o.groups.map(e=>(0,A.jsxs)(W,{...Dd(()=>u({...i,groupBy:``,...zp(i.groupBy,e)})),"aria-label":`Show runs of ${e.label}`,children:[(0,A.jsx)(K,{className:`max-w-72 truncate font-medium`,children:e.label}),(0,A.jsx)(K,{className:Q,children:q(e.runs)}),(0,A.jsx)(K,{className:Q,children:q(e.failed)}),(0,A.jsx)(K,{className:Q,children:bp(e.estimatedCostUsd)}),(0,A.jsx)(K,{className:Q,children:Cp(e.p95Ms)})]},e.key))})]})}):null,(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`,children:[(0,A.jsx)(`div`,{className:`min-w-0 space-y-1.5`,children:o.runs.map(n=>(0,A.jsx)(ld,{selected:n.traceId===e,className:`rounded-xl bg-card p-3`,onClick:()=>t(n.traceId),children:(0,A.jsx)(Pp,{run:n})},n.traceId))}),(0,A.jsx)(`div`,{className:`min-w-0`,children:e?(0,A.jsx)(Ip,{run:f,traceId:e,onClose:()=>t(``)},e):(0,A.jsx)(U,{title:`Select a run to inspect tools, retries and compaction metadata.`,hint:`Its span tree opens here.`})})]})]}):null]})}function Vp({label:e,heading:t,rows:n,unpriced:r,onOpen:i}){return n.length?(0,A.jsxs)(Ed,{label:e,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:t}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Tokens`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Estimated cost`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Error rate`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p95`})]})}),(0,A.jsx)(pu,{children:n.map(e=>{let{totals:t}=e;return(0,A.jsxs)(W,{...i?{...Dd(()=>i(e)),"aria-label":`Open ${e.label}`}:{},children:[(0,A.jsxs)(K,{className:`max-w-64 truncate font-medium`,children:[e.label,r?.has(e.key)||t.cost.unpricedRuns>0?(0,A.jsx)(`span`,{className:`ml-2`,children:(0,A.jsx)(Tp,{})}):null]}),(0,A.jsx)(K,{className:Q,children:q(t.runs)}),(0,A.jsx)(K,{className:Q,children:xp(t.tokens.input+t.tokens.output)}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(zf,{share:e.share,children:t.cost.pricedRuns>0?bp(t.cost.estimatedUsd):`—`})}),(0,A.jsx)(K,{className:Q,children:Sp(t.errorRate)}),(0,A.jsx)(K,{className:Q,children:Cp(t.latency.p95Ms)})]},e.key)})})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing in this range.`})}var Hp=e=>e==null?`—`:String(e);function Up({run:e}){return(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,A.jsx)(Y,{tone:jp(e.status),children:e.status})}),(0,A.jsx)(`div`,{className:`font-medium`,children:`${e.agent} · ${e.status} · ${Hp(e.durationMs)} ms`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground break-words`,children:e.model}),(0,A.jsx)(`p`,{className:`text-sm`,children:`${e.turns} turns · ${e.toolCalls} tool calls · ${e.refusals} refused · ${e.usage.input} input · ${e.usage.output} output · ${Zu(e.cost)}`}),(0,A.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`${e.runId}${e.requestId?` · Request ${e.requestId}`:``}`})]})}function Wp({call:e}){let t=[`${e.name} · ${e.status} · ${e.durationMs} ms`,...e.refusal?[`refused: ${e.refusal}`]:[],...e.error?[`error: ${e.error.message}`]:[]].join(` · `);return(0,A.jsxs)(`details`,{open:!!(e.refusal||e.error),className:`ml-3 border-l-2 pl-2`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t}),(0,A.jsx)(id,{value:{input:e.input,output:e.output}})]})}function Gp({turn:e}){let t=e.toolsOffered.reduce((e,t)=>e+t.tokens,0),n=e.cost==null?``:` · ${Zu(e.cost)}`;return(0,A.jsxs)(`details`,{open:!0,className:`rounded-lg border bg-card p-2.5`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`turn ${e.index} · ${Hp(e.finishReason)} · ${Math.round(e.durationMs)} ms · ${e.usage.input} input · ${e.usage.output} output${n}`}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`starts from ${e.input} · system prompt ${Hp(e.systemPromptHash)} · tools ${e.toolsHash}`}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tools offered (~${t} tokens): ${e.toolsOffered.map(e=>`${e.name}@${e.schemaHash.slice(0,8)}`).join(`, `)||`none`}`}),e.text?(0,A.jsx)(Md,{children:e.text}):null,e.toolCalls.map((e,t)=>(0,A.jsx)(Wp,{call:e},t)),e.contract.map((e,t)=>(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`contract: ${e.type}${e.tool?` ${e.tool}`:``}${e.name?` ${e.name}`:``}${e.reason?` (${e.reason})`:``}`},t)),e.error?(0,A.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error.message}):null]})}function Kp(e,t){if(!t)return`No earlier run of this agent to compare with.`;let n=e=>new Map(e.turns.flatMap(e=>e.toolsOffered).map(e=>[e.name,e.schemaHash])),r=n(e),i=n(t),a=[...r].filter(([e,t])=>i.has(e)&&i.get(e)!==t),o=[...r.keys()].filter(e=>!i.has(e)),s=[...i.keys()].filter(e=>!r.has(e)),c=e.systemPrompt?.hash===t.systemPrompt?.hash?`same`:`changed`;return c===`same`&&!a.length&&!o.length&&!s.length?`Same system prompt and tool definitions as ${t.runId}.`:`Against ${t.runId}: system prompt ${c}; tools changed: ${a.map(([e])=>e).join(`, `)||`none`}; added: ${o.join(`, `)||`none`}; removed: ${s.join(`, `)||`none`}.`}function qp({run:e,earlier:t,onClose:n}){let{data:r,error:i,loading:a,reload:o}=H(`api/ai/agent-runs/${encodeURIComponent(e.runId)}`),s=H(t?`api/ai/agent-runs/${encodeURIComponent(t.runId)}`:null),c=!!t&&!s.data&&!s.error;return(0,A.jsxs)(`section`,{"aria-label":`Agent run detail`,className:`space-y-2 rounded-xl border bg-card p-3.5`,children:[(0,A.jsx)($,{onClick:n,children:`Close run`}),(0,A.jsx)(Up,{run:e}),i?(0,A.jsx)(z,{error:i,title:`Could not load this agent run`,onRetry:o}):null,!r&&a?(0,A.jsx)(Ks,{rows:3}):null,r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Input: ${r.input}`}),r.systemPrompt?(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`System prompt ${r.systemPrompt.hash}`}),(0,A.jsx)(Md,{children:r.systemPrompt.text??`Text not kept (only the hash is recorded).`})]}):null,(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c?`Comparing with the earlier run…`:Kp(r,s.data)}),Object.entries(r.toolSchemas).map(([e,t])=>(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Tool ${t.name}@${e.slice(0,8)}`}),(0,A.jsx)(Md,{children:`${t.description}\n\n${t.schema??`Schema not kept.`}`})]},e)),r.turns.map(e=>(0,A.jsx)(Gp,{turn:e},e.index)),r.error?(0,A.jsx)(`p`,{className:`text-sm text-destructive`,children:r.error.message}):null]}):null]})}var Jp=-new Date().getTimezoneOffset();function Yp(){let{data:e,error:t,reload:n}=H(`api/ai/reports?range=24h&tz=${Jp}`,{refreshMs:6e4});return t?(0,A.jsx)(z,{error:t,title:`Could not load the agents of the last 24 hours`,onRetry:n,className:`mb-4`}):!e?.available||!e.topAgents.length?null:(0,A.jsxs)(`section`,{"aria-label":`Agents in the last 24 hours`,className:`mb-5`,children:[(0,A.jsx)(nd,{children:`Agents in the last 24 hours`}),(0,A.jsx)(Vp,{label:`Agents in the last 24 hours`,heading:`Agent`,rows:e.topAgents})]})}function Xp({route:e,navigate:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),{data:o,error:s,loading:c,reload:l}=H(`api/ai/agent-runs${i?`?requestId=${encodeURIComponent(i)}`:``}`);lu([`agent-trace`],(0,_.useCallback)(()=>l(),[l]));let u=o?.runs.find(t=>t.runId===e),d=u&&o?o.runs.slice(o.runs.indexOf(u)+1).find(e=>e.agent===u.agent):void 0,f=o?.runs??[];return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Agent runs`,description:`Each agent run with its prompt, tools, turns, tool calls and refusals.`}),(0,A.jsx)(Yp,{}),(0,A.jsxs)(X,{label:`Agent run filters`,onSubmit:()=>{a(n.trim()),t(``),l()},children:[(0,A.jsx)(od,{placeholder:`HTTP request id (empty for all runs)`,"aria-label":`Filter agent runs by HTTP request id`,className:`w-72 max-w-full`,value:n,onChange:e=>r(e.target.value)}),(0,A.jsx)(R,{type:`submit`,size:`sm`,children:`Filter / refresh`})]}),s?(0,A.jsx)(z,{error:s,title:`Could not load the agent runs`,onRetry:l}):null,!o&&c?(0,A.jsx)(Ks,{}):null,o&&!o.available?(0,A.jsx)(U,{title:o.message||`No agent traces yet.`,hint:`Agent traces need the AI package in development.`}):null,o?.available&&!o.runs.length?(0,A.jsx)(U,{title:`No agent runs yet. Execute an agent in development; runs appear as turns finish.`,hint:i?`This request id has no runs. Clear the filter to see all runs.`:void 0}):null,o?.available&&o.runs.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(xd,{items:[{label:`Runs`,value:q(f.length)},{label:`Turns`,value:q(f.reduce((e,t)=>e+t.turns,0))},{label:`Tool calls`,value:q(f.reduce((e,t)=>e+t.toolCalls,0))},{label:`Refused calls`,value:q(f.reduce((e,t)=>e+t.refusals,0)),tone:f.some(e=>e.refusals)?`warning`:`success`}]}),(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]`,children:[(0,A.jsx)(`div`,{className:`min-w-0 space-y-1.5`,children:o.runs.map(n=>(0,A.jsx)(ld,{selected:n.runId===e,className:`rounded-xl bg-card p-3`,onClick:()=>t(n.runId),children:(0,A.jsx)(Up,{run:n})},n.runId))}),(0,A.jsx)(`div`,{className:`min-w-0`,children:u?(0,A.jsx)(qp,{run:u,earlier:d,onClose:()=>t(``)},u.runId):(0,A.jsx)(U,{title:`Select a run to inspect its prompt, tools, calls and refusals.`,hint:`The turn-by-turn trace opens here.`})})]})]}):null]})}var Zp=[{id:`scalar`,label:`Scalar`,src:`docs`},{id:`swagger`,label:`Swagger UI`,src:`docs/swagger`}],Qp=`warlock-devtools-docs-viewer`;function $p(){try{let e=localStorage.getItem(Qp);return Zp.find(t=>t.id===e)??Zp[0]}catch{return Zp[0]}}function em(e){try{localStorage.setItem(Qp,e)}catch{}}function tm(e){let[t,n]=(0,_.useState)($p);return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(bd,{title:`API`,description:`The reference for every route, generated from your app. Pick a viewer, or download the OpenAPI file or Postman collection.`,children:[(0,A.jsx)(R,{asChild:!0,variant:`outline`,size:`sm`,children:(0,A.jsxs)(`a`,{href:`api/openapi.json`,download:`openapi.json`,children:[(0,A.jsx)(Ko,{}),`OpenAPI JSON`]})}),(0,A.jsx)(R,{asChild:!0,variant:`outline`,size:`sm`,children:(0,A.jsxs)(`a`,{href:`api/postman.json`,download:`postman.json`,children:[(0,A.jsx)(Ko,{}),`Postman collection`]})})]}),(0,A.jsx)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,role:`group`,"aria-label":`Viewer`,children:Zp.map(e=>(0,A.jsx)(cd,{active:e.id===t.id,onClick:()=>{em(e.id),n(e)},children:e.label},e.id))}),(0,A.jsx)(`iframe`,{className:`h-[75vh] w-full rounded-xl border bg-background`,src:t.src,title:`API reference`},t.id)]})}function nm({api:e,errorTitle:t,children:n}){let{data:r,error:i,loading:a,reload:o}=e;return(0,A.jsxs)(A.Fragment,{children:[i?(0,A.jsx)(z,{error:i,title:t,onRetry:o,className:`mb-3`}):null,!r&&a?(0,A.jsx)(Ks,{}):null,r&&!r.available?(0,A.jsx)(yp,{answer:r}):null,r?.available?(0,A.jsx)(`div`,{className:F(`transition-opacity`,a&&`opacity-60`),children:n(r,a)}):null]})}function rm({tone:e=`warning`,children:t}){return(0,A.jsxs)(Vs,{variant:e,className:`mb-3`,children:[(0,A.jsx)(e===`warning`?Is:es,{"aria-hidden":`true`}),(0,A.jsx)(Us,{children:t})]})}var im=`AI observation is off, so new runs are not counted and the figures below are older ones. To count new runs, call ai.config({ panoptic: { observeAll: true } }) and restart the app.`;function am({items:e,label:t}){return(0,A.jsx)(`dl`,{"aria-label":t,className:`mb-4 grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-[repeat(auto-fit,minmax(10.5rem,1fr))]`,children:e.map(e=>(0,A.jsxs)(`div`,{className:`min-w-0 rounded-xl border bg-card px-3.5 py-3`,children:[(0,A.jsx)(`dt`,{className:`truncate text-xs text-muted-foreground`,children:e.label}),(0,A.jsx)(`dd`,{className:F(`mt-1 truncate text-2xl font-semibold tracking-tight tabular-nums`,pd[e.tone??`neutral`]),children:e.value}),e.hint?(0,A.jsx)(`p`,{className:`mt-0.5 text-xs break-words text-muted-foreground`,children:e.hint}):null,e.delta?(0,A.jsx)(`p`,{className:`mt-0.5`,children:e.delta}):null]},e.label))})}var om=`devtools.ai.range`,sm=e=>e===`24h`||e===`7d`||e===`30d`;function cm(){try{let e=localStorage.getItem(om);return sm(e)?e:`24h`}catch{return`24h`}}function lm(e){if(e!==`custom`)try{localStorage.setItem(om,e)}catch{}}function um(e){let t=new URLSearchParams(e),n=t.get(`range`),r=Number(t.get(`from`)),i=Number(t.get(`to`)),a=n===`custom`&&Number.isFinite(r)&&Number.isFinite(i)&&r>0&&i>r;return{range:sm(n)?n:a?`custom`:cm(),from:a?r:null,to:a?i:null,agent:t.get(`agent`)??``,model:t.get(`model`)??``,provider:t.get(`provider`)??``}}function dm(e){let t=new URLSearchParams({range:e.range});e.range===`custom`&&e.from&&e.to&&(t.set(`from`,String(e.from)),t.set(`to`,String(e.to)));for(let n of[`agent`,`model`,`provider`]){let r=e[n];r&&t.set(n,r)}return t.toString()}function fm(e){let t=new URLSearchParams(dm(e));return t.set(`tz`,String(-new Date().getTimezoneOffset())),t.toString()}function pm(e,t,n={}){location.hash=`#${e}/${dm({...t,agent:``,model:``,provider:``,...n})}`}var mm=36e5,hm=[{value:`24h`,label:`24 h`},{value:`7d`,label:`7 d`},{value:`30d`,label:`30 d`},{value:`custom`,label:`Custom`}];function gm(e){return new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16)}function _m({label:e,all:t,value:n,options:r,onChange:i}){let a=n&&!r.includes(n)?[n,...r]:r;return(0,A.jsxs)(sd,{"aria-label":e,value:n,className:`max-w-48`,onChange:e=>i(e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:t}),a.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))]})}function vm({state:e,filters:t,onChange:n}){let[r,i]=(0,_.useState)(e.range===`custom`),[a,o]=(0,_.useState)(e.from?gm(e.from):``),[s,c]=(0,_.useState)(e.to?gm(e.to):``),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(()=>gm(Date.now())),p=`${e.range}|${e.from}|${e.to}`,[m,h]=(0,_.useState)(p);m!==p&&(h(p),i(e.range===`custom`),o(e.from?gm(e.from):``),c(e.to?gm(e.to):``));let g=()=>{let t=new Date(a).getTime(),r=new Date(s).getTime();if(!Number.isFinite(t)||!Number.isFinite(r)){u(`Pick both a start and an end time, then apply.`);return}if(r<=t){u(`The end must be after the start. Pick a later end time.`);return}if(r>(Math.floor(Date.now()/mm)+1)*mm){u(`The end is in the future. Pick an end time up to now.`);return}u(null),n({...e,range:`custom`,from:t,to:r})},v=t=>n({...e,...t});return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(X,{label:`AI report filters`,children:[(0,A.jsx)(Cd,{label:`Date range`,options:hm,value:r?`custom`:e.range,onChange:e=>{if(e===`custom`){f(gm(Date.now())),i(!0);return}i(!1),u(null);let t=e;lm(t),v({range:t,from:null,to:null})}}),r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(od,{type:`datetime-local`,"aria-label":`Range start`,max:d,value:a,onChange:e=>o(e.target.value)}),(0,A.jsx)(od,{type:`datetime-local`,"aria-label":`Range end`,max:d,value:s,onChange:e=>c(e.target.value)}),(0,A.jsx)(R,{type:`button`,size:`sm`,onClick:g,children:`Apply range`})]}):null,(0,A.jsx)(_m,{label:`Agent`,all:`All agents`,value:e.agent,options:t?.agents??[],onChange:e=>v({agent:e})}),(0,A.jsx)(_m,{label:`Model`,all:`All models`,value:e.model,options:t?.models??[],onChange:e=>v({model:e})}),(0,A.jsx)(_m,{label:`Provider`,all:`All providers`,value:e.provider,options:t?.providers??[],onChange:e=>v({provider:e})})]}),l?(0,A.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-destructive`,children:l}):null]})}var ym=6e4;function bm(e,t){let n=H(`api/ai/${e}?${fm(t)}`,{refreshMs:ym});return{...n,refreshing:n.loading&&n.data!==void 0}}function xm(e,t){return{state:(0,_.useMemo)(()=>um(e),[e]),setState:e=>{lm(e.range),t(dm(e))}}}function Sm({report:e,refreshing:t,openModel:n,openAgent:r}){let{totals:i,previous:a,range:o}=e,s=wp(o),c=e.previousComplete!==!1,l=Tf(e.costByModel.series.filter(e=>!e.other).map(e=>e.key)),u=new Set(e.unpricedModels),d={...e.tokens,series:e.tokens.series.map(e=>({...e,label:{uncached:`Uncached input`,cached:`Cached input`,output:`Output`}[e.key]??e.label}))};return(0,A.jsxs)(A.Fragment,{children:[e.observationOff?(0,A.jsx)(rm,{tone:`info`,children:im}):null,e.unpricedModels.length?(0,A.jsx)(rm,{children:`${e.unpricedModels.length} ${e.unpricedModels.length===1?`model has`:`models have`} no pricing; their runs are not in the cost (${e.unpricedModels.join(`, `)}). Add pricing for them in the AI config to include them.`}):null,(0,A.jsx)(am,{label:`AI report summary`,items:[{label:`Estimated cost`,value:bp(i.cost.estimatedUsd),hint:i.cost.unpricedRuns>0?`Estimated from model pricing · ${q(i.cost.unpricedRuns)} unpriced runs`:`Estimated from model pricing`,delta:(0,A.jsx)(Vf,{current:i.cost.estimatedUsd,previous:a.cost.estimatedUsd,against:s,previousComplete:c})},{label:`Tokens`,value:xp(i.tokens.input+i.tokens.output),hint:`${xp(i.tokens.input)} in · ${xp(i.tokens.output)} out · ${xp(i.tokens.cached)} cached`,delta:(0,A.jsx)(Vf,{current:i.tokens.input+i.tokens.output,previous:a.tokens.input+a.tokens.output,against:s,previousComplete:c})},{label:`Agent runs`,value:q(i.runs),delta:(0,A.jsx)(Vf,{current:i.runs,previous:a.runs,against:s,previousComplete:c})},{label:`Error rate`,value:Sp(i.errorRate),tone:c&&i.errorRate>a.errorRate?`warning`:`neutral`,hint:`${q(i.failed+i.incomplete)} failed or incomplete`,delta:(0,A.jsx)(Vf,{current:i.errorRate,previous:a.errorRate,against:s,previousComplete:c,risingIsBad:!0})},{label:`p95 latency`,value:Cp(i.latency.p95Ms),delta:i.latency.p95Ms!==null&&a.latency.p95Ms!==null?(0,A.jsx)(Vf,{current:i.latency.p95Ms,previous:a.latency.p95Ms,against:s,previousComplete:c,risingIsBad:!0}):null}]}),(0,A.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,A.jsx)(Nf,{title:`Estimated cost by model`,description:`Estimated from model pricing; unpriced models are left out.`,set:e.costByModel,stepMs:o.stepMs,format:bp,color:l,loading:t,emptyText:`No priced runs in this range.`}),(0,A.jsx)(Nf,{title:`Tokens`,set:d,stepMs:o.stepMs,format:xp,color:e=>vf[e]??gf(1),loading:t,emptyText:`No tokens used in this range.`})]}),(0,A.jsx)(`div`,{className:`mt-4`,children:(0,A.jsx)(Rf,{title:`Error rate`,seriesName:`Error rate`,points:e.errorRate,stepMs:o.stepMs,format:Sp,color:gf(4),loading:t,emptyText:`No runs in this range, so there is no error rate.`})}),(0,A.jsx)(nd,{children:`Top agents`}),(0,A.jsx)(Vp,{label:`Top agents`,heading:`Agent`,rows:e.topAgents,onOpen:r}),(0,A.jsx)(nd,{children:`Top models`}),(0,A.jsx)(Vp,{label:`Top models`,heading:`Model`,rows:e.topModels,unpriced:u,onOpen:e=>n(e.key)})]})}function Cm({route:e,navigate:t}){let{state:n,setState:r}=xm(e,t),i=bm(`reports`,n),a=i.data?.available?i.data.filters:void 0;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Reports`,description:`Estimated cost, tokens, errors and latency of your AI runs over a date range. Kept as hourly totals, so they survive restarts.`}),(0,A.jsx)(vm,{state:n,filters:a,onChange:r}),(0,A.jsx)(nm,{api:i,errorTitle:`Could not load the AI report`,children:(e,t)=>(0,A.jsx)(Sm,{report:e,refreshing:t,openModel:e=>{pm(`ai-models`,n,{model:e})},openAgent:()=>{location.hash=`#agents`}})})]})}function wm({view:e,refreshing:t}){let n=Tf(e.runsByModel.series.filter(e=>!e.other).map(e=>e.key)),r=e.models.filter(e=>e.pricing===`missing`||e.pricing===`partial`).length,i=Math.max(0,...e.models.map(e=>e.totals.cost.estimatedUsd));return(0,A.jsxs)(A.Fragment,{children:[e.observationOff?(0,A.jsx)(rm,{tone:`info`,children:im}):null,(0,A.jsx)(am,{label:`Models summary`,items:[{label:`Models used`,value:q(e.models.length)},{label:`Estimated cost`,value:bp(e.totals.cost.estimatedUsd),hint:`Estimated from model pricing`},{label:`Unpriced models`,value:q(r),tone:r?`warning`:`neutral`,hint:r?`Their runs are not in the cost`:`Every model has pricing`},{label:`Fallback rate`,value:Sp(e.totals.runs?e.totals.fallbackRuns/e.totals.runs:0),hint:`${q(e.totals.fallbackRuns)} runs answered by a fallback model`}]}),(0,A.jsx)(Nf,{title:`Runs by model`,set:e.runsByModel,stepMs:e.range.stepMs,format:q,color:n,loading:t,emptyText:`No runs in this range.`}),(0,A.jsx)(nd,{children:`Models`}),e.models.length?(0,A.jsxs)(Ed,{label:`Models`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Model`}),(0,A.jsx)(G,{className:Z,children:`Provider`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Tokens in`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Tokens out`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Estimated cost`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Cost per run`}),(0,A.jsx)(G,{className:Z,children:`Pricing`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Fallback`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Error rate`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`p50 / p95`}),(0,A.jsx)(G,{className:Z,children:`Agents`})]})}),(0,A.jsx)(pu,{children:e.models.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`max-w-56 truncate font-medium`,children:e.model}),(0,A.jsx)(K,{className:`text-muted-foreground`,children:e.provider}),(0,A.jsx)(K,{className:Q,children:q(e.totals.runs)}),(0,A.jsx)(K,{className:Q,children:xp(e.totals.tokens.input)}),(0,A.jsx)(K,{className:Q,children:xp(e.totals.tokens.output)}),(0,A.jsx)(K,{className:Q,children:e.pricing===`missing`||e.pricing===`no-tokens`?`—`:(0,A.jsx)(zf,{share:i>0?e.totals.cost.estimatedUsd/i:0,children:bp(e.totals.cost.estimatedUsd)})}),(0,A.jsx)(K,{className:Q,children:e.costPerRunUsd===null?`—`:bp(e.costPerRunUsd)}),(0,A.jsx)(K,{children:(0,A.jsx)(Ep,{state:e.pricing})}),(0,A.jsx)(K,{className:Q,children:Sp(e.fallbackRate)}),(0,A.jsx)(K,{className:Q,children:Sp(e.totals.errorRate)}),(0,A.jsx)(K,{className:Q,children:`${Cp(e.totals.latency.p50Ms)} / ${Cp(e.totals.latency.p95Ms)}`}),(0,A.jsx)(K,{className:`max-w-56 truncate text-xs text-muted-foreground`,children:e.agents.join(`, `)||`—`})]},e.key))})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No models used in this range.`})]})}function Tm({route:e,navigate:t}){let{state:n,setState:r}=xm(e,t),i=bm(`models`,n),a=i.data?.available?i.data.filters:void 0;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Models`,description:`Every model your AI runs used in the date range, with its cost, pricing state, latency and error rate.`}),(0,A.jsx)(vm,{state:n,filters:a,onChange:r}),(0,A.jsx)(nm,{api:i,errorTitle:`Could not load the models`,children:(e,t)=>(0,A.jsx)(wm,{view:e,refreshing:t})})]})}var Em=e=>e.map(e=>`${e.key} (${e.count})`).join(`, `)||`—`;function Dm({view:e,refreshing:t}){let n=Tf(e.overTime.series.filter(e=>!e.other).map(e=>e.key),`errors`),{totals:r,previous:i}=e,a=wp(e.range),o=r.failed+r.incomplete,s=i.failed+i.incomplete,c=e.previousComplete!==!1;return(0,A.jsxs)(A.Fragment,{children:[e.observationOff?(0,A.jsx)(rm,{tone:`info`,children:im}):null,(0,A.jsx)(am,{label:`Errors summary`,items:[{label:`Failed runs`,value:q(o),tone:o?`warning`:`neutral`,hint:`Failed plus incomplete`,delta:(0,A.jsx)(Vf,{current:o,previous:s,against:a,previousComplete:c,risingIsBad:!0})},{label:`Error rate`,value:Sp(r.errorRate),delta:(0,A.jsx)(Vf,{current:r.errorRate,previous:i.errorRate,against:a,previousComplete:c,risingIsBad:!0})},{label:`Refusals`,value:q(r.refusals),hint:`Provider refused or filtered`},{label:`Cancelled`,value:q(r.cancelled),hint:`Not counted as errors`}]}),(0,A.jsx)(Nf,{title:`Failed runs by category`,set:e.overTime,stepMs:e.range.stepMs,format:q,color:n,loading:t,emptyText:`No failed runs in this range.`}),(0,A.jsx)(nd,{children:`Categories`}),e.groups.length?(0,A.jsxs)(Ed,{label:`Failed runs by category`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`Category`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Runs`}),(0,A.jsx)(G,{className:`${Z} ${Q}`,children:`Change`}),(0,A.jsx)(G,{className:Z,children:`Top models`}),(0,A.jsx)(G,{className:Z,children:`Top agents`})]})}),(0,A.jsx)(pu,{children:e.groups.map(e=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`font-medium`,children:e.label}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(zf,{share:e.share,children:q(e.count)})}),(0,A.jsx)(K,{className:Q,children:(0,A.jsx)(Vf,{current:e.count,previous:e.previousCount,against:`previous period`,previousComplete:c,risingIsBad:!0})}),(0,A.jsx)(K,{className:`max-w-64 truncate text-xs text-muted-foreground`,children:Em(e.byModel)}),(0,A.jsx)(K,{className:`max-w-64 truncate text-xs text-muted-foreground`,children:Em(e.byAgent)})]},e.category))})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No failed runs in this range.`}),(0,A.jsx)(nd,{children:`Recent failed runs`}),e.recent===null?(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Production keeps hourly totals, not run details. Open Runs in development (warlock dev) to see the failed runs themselves.`}):e.recent.length?(0,A.jsxs)(Ed,{label:`Recent failed runs`,children:[(0,A.jsx)(fu,{children:(0,A.jsxs)(W,{children:[(0,A.jsx)(G,{className:Z,children:`When`}),(0,A.jsx)(G,{className:Z,children:`Agent`}),(0,A.jsx)(G,{className:Z,children:`Model`}),(0,A.jsx)(G,{className:Z,children:`Category`}),(0,A.jsx)(G,{className:Z,children:`Error`}),(0,A.jsx)(G,{className:Z,children:`Run`})]})}),(0,A.jsx)(pu,{children:e.recent.map((e,t)=>(0,A.jsxs)(W,{children:[(0,A.jsx)(K,{className:`whitespace-nowrap text-muted-foreground`,children:(0,A.jsx)(ed,{at:e.endedAt})}),(0,A.jsx)(K,{className:`font-medium`,children:e.agent}),(0,A.jsx)(K,{className:`text-muted-foreground`,children:e.model??`—`}),(0,A.jsx)(K,{children:(0,A.jsx)(Y,{tone:`destructive`,children:e.category})}),(0,A.jsxs)(K,{className:`max-w-md text-xs whitespace-normal break-words`,children:[e.code?(0,A.jsx)(`span`,{className:`font-mono`,children:e.code}):null,e.message?(0,A.jsx)(`span`,{className:`block text-muted-foreground`,children:e.message}):null]}),(0,A.jsx)(K,{children:(0,A.jsx)(`a`,{className:`text-brand underline-offset-2 hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,href:`#ai/${encodeURIComponent(e.traceId)}`,children:`Open run`})})]},`${e.traceId}:${t}`))})]}):(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No recent failed runs are kept in memory.`})]})}function Om({route:e,navigate:t}){let{state:n,setState:r}=xm(e,t),i=bm(`errors`,n),a=i.data?.available?i.data.filters:void 0;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(bd,{title:`Errors`,description:`Failed and incomplete AI runs grouped by what went wrong: rate limits, timeouts, refusals, provider errors and more.`}),(0,A.jsx)(vm,{state:n,filters:a,onChange:r}),(0,A.jsx)(nm,{api:i,errorTitle:`Could not load the AI errors`,children:(e,t)=>(0,A.jsx)(Dm,{view:e,refreshing:t})})]})}var km=`ai.config({
51
51
  panoptic: {
52
52
  evaluate: {
53
53
  model: openai.model({ name: "gpt-4o-mini" }),