fest-gateway 0.5.0 → 0.5.2

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.
@@ -52,5 +52,5 @@ Error generating stack: `+e.message+`
52
52
  - \`null\` or \`undefined\` if the progress is indeterminate.
53
53
 
54
54
  Defaulting to \`null\`.`}Il(Ql,`getInvalidValueError`);var $l=Ul,eu=Gl,tu=Object.defineProperty,G=(e,t)=>tu(e,`name`,{value:t,configurable:!0}),nu=[` `,`Enter`,`ArrowUp`,`ArrowDown`],ru=[` `,`Enter`],K=`Select`,[iu,au,ou]=Vr(K),[su,cu]=Lr(K,[ou,sl]),lu=sl(),[uu,du]=su(K),[fu,pu]=su(K);function mu(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=lu(t),[_,v]=y.useState(null),[x,S]=y.useState(null),[C,w]=y.useState(!1),T=Ii(l),[E,D]=mi({prop:r,defaultProp:i??!1,onChange:a,caller:K}),[O,k]=mi({prop:o,defaultProp:s,onChange:c,caller:K}),A=y.useRef(null),j=y.useRef(O);y.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=G(()=>k(j.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,k]);let M=!_||!!m||!!_.closest(`form`),[ee,N]=y.useState(new Set),P=Mi(),F=Array.from(ee).map(e=>e.props.value).join(`;`),I=y.useCallback(e=>{N(t=>new Set(t).add(e))},[]),te=y.useCallback(e=>{N(t=>{let n=new Set(t);return n.delete(e),n})},[]),ne={required:p,trigger:_,onTriggerChange:v,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:P,value:O,onValueChange:k,open:E,onOpenChange:D,dir:T,triggerPointerDownPosRef:A,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:ee,nativeSelectKey:F,isFormControl:M};return(0,b.jsx)(Cl,{...g,children:(0,b.jsx)(uu,{scope:t,...ne,children:(0,b.jsx)(iu.Provider,{scope:t,children:(0,b.jsx)(fu,{scope:t,onNativeOptionAdd:I,onNativeOptionRemove:te,children:q(h)?h(ne):n})})})})}G(mu,`SelectProvider`);var hu=G(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,b.jsx)(mu,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,b.jsxs)(b.Fragment,{children:[n,e?(0,b.jsx)(ed,{__scopeSelect:t}):null]})})},`Select`),gu=`SelectTrigger`,_u=y.forwardRef(G(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=lu(n),o=du(gu,n),s=o.disabled||r,c=cr(t,o.onTriggerChange),l=au(n),u=y.useRef(`touch`),[d,f,p]=td(e=>{let t=l().filter(e=>!e.disabled),n=nd(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=G(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,b.jsx)(wl,{asChild:!0,...a,children:(0,b.jsx)(Or.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":J(o.value)?``:void 0,...i,ref:c,onClick:V(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:V(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:V(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&nu.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),vu=`SelectValue`,yu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=du(vu,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=cr(t,c.onValueNodeChange);ai(()=>{l(u)},[l,u]);let f=J(c.value);return(0,b.jsx)(Or.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,b.jsx)(y.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),bu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,b.jsx)(Or.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[xu,Su]=su(`SelectPortal`,{forceMount:void 0}),Cu=G(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,b.jsx)(xu,{scope:e.__scopeSelect,forceMount:n,children:(0,b.jsx)(ga,{asChild:!0,...r})})},`SelectPortal`),wu=`SelectContent`,Tu=y.forwardRef(G(function(e,t){let n=Su(wu,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=du(wu,e.__scopeSelect),[o,s]=y.useState();return ai(()=>{s(new DocumentFragment)},[]),(0,b.jsx)(Si,{present:r||a.open,children:({present:e})=>e?(0,b.jsx)(ju,{...i,ref:t}):(0,b.jsx)(Eu,{...i,fragment:o})})},`SelectContent`)),Eu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Tr.createPortal((0,b.jsx)(Ou,{scope:n,children:(0,b.jsx)(iu.Slot,{scope:n,children:(0,b.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Du=10,[Ou,ku]=su(wu),Au=dr(`SelectContent.RemoveScroll`),ju=y.forwardRef(G(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=du(wu,n),[x,S]=y.useState(null),[C,w]=y.useState(null),T=cr(t,S),[E,D]=y.useState(null),[O,k]=y.useState(null),A=au(n),[j,M]=y.useState(!1),ee=y.useRef(!1);y.useEffect(()=>{if(x)return Bo(x)},[x]),Sa();let N=y.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&C&&(C.scrollTop=0),n===r&&C&&(C.scrollTop=C.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,C]),P=y.useCallback(()=>N([E,x]),[N,E,x]);y.useEffect(()=>{j&&P()},[j,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=v;y.useEffect(()=>{if(x){let e={x:0,y:0},t=G(t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},`handlePointerMove`),n=G(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(x)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null},`handlePointerUp`);return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[x,F,I]),y.useEffect(()=>{let e=G(()=>F(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[te,ne]=td(e=>{let t=A().filter(e=>!e.disabled),n=nd(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),re=y.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&(D(e),r&&(ee.current=!0))},[v.value]),ie=y.useCallback(()=>x?.focus(),[x]),ae=y.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&k(e)},[v.value]),oe=r===`popper`?Nu:Mu,se=oe===Nu?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,b.jsx)(Ou,{scope:n,content:x,viewport:C,onViewportChange:w,itemRefCallback:re,selectedItem:E,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:P,selectedItemText:O,position:r,isPositioned:j,searchRef:te,children:(0,b.jsx)(Mo,{as:Au,allowPinchZoom:!0,children:(0,b.jsx)(ra,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:V(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,b.jsx)(qi,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,b.jsx)(oe,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...se,onPlaced:()=>M(!0),ref:T,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:V(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Mu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=du(wu,n),o=ku(wu,n),[s,c]=y.useState(null),[l,u]=y.useState(null),d=cr(t,u),f=au(n),p=y.useRef(!1),m=y.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,x=y.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Du,d=Pl(a,[Du,Math.max(Du,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Du,d=Pl(a,[Du,Math.max(Du,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Du*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Du,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Du}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);ai(()=>x(),[x]);let[S,C]=y.useState();ai(()=>{l&&C(window.getComputedStyle(l).zIndex)},[l]);let w=y.useCallback(e=>{e&&m.current===!0&&(x(),v?.(),m.current=!1)},[x,v]);return(0,b.jsx)(Pu,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:w,children:(0,b.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:S},children:(0,b.jsx)(Or.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Nu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Du,...a}=e,o=lu(n);return(0,b.jsx)(Tl,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[Pu,Fu]=su(wu,{}),Iu=`SelectViewport`,Lu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=ku(Iu,n),o=Fu(Iu,n),s=cr(t,a.onViewportChange),c=y.useRef(0);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,b.jsx)(iu.Slot,{scope:n,children:(0,b.jsx)(Or.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:V(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Du*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Ru,zu]=su(`SelectGroup`),Bu=`SelectItem`,[Vu,Hu]=su(Bu),Uu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=du(Bu,n),c=ku(Bu,n),l=s.value===r,[u,d]=y.useState(a??``),[f,p]=y.useState(!1),m=cr(t,zi(e=>c.itemRefCallback?.(e,r,i))),h=Mi(),g=y.useRef(`touch`),_=G(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,b.jsx)(Vu,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:y.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,b.jsx)(iu.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,b.jsx)(Or.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:V(o.onFocus,()=>p(!0)),onBlur:V(o.onBlur,()=>p(!1)),onClick:V(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:V(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:V(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:V(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:V(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:V(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(ru.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Wu=`SelectItemText`,Gu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=du(Wu,n),s=ku(Wu,n),c=Hu(Wu,n),l=pu(Wu,n),[u,d]=y.useState(null),f=zi(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=cr(t,d,c.onItemTextChange,f),m=u?.textContent,h=y.useMemo(()=>(0,b.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return ai(()=>(g(h),()=>_(h)),[g,_,h]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Or.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!J(o.value)?Tr.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),Ku=`SelectItemIndicator`,qu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,...r}=e;return Hu(Ku,n).isSelected?(0,b.jsx)(Or.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Ju=`SelectScrollUpButton`,Yu=y.forwardRef(G(function(e,t){let n=ku(Ju,e.__scopeSelect),r=Fu(Ju,e.__scopeSelect),[i,a]=y.useState(!1),o=cr(t,r.onScrollButtonChange);return ai(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};G(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,b.jsx)(Qu,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Xu=`SelectScrollDownButton`,Zu=y.forwardRef(G(function(e,t){let n=ku(Xu,e.__scopeSelect),r=Fu(Xu,e.__scopeSelect),[i,a]=y.useState(!1),o=cr(t,r.onScrollButtonChange);return ai(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};G(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,b.jsx)(Qu,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Qu=y.forwardRef(G(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=ku(`SelectScrollButton`,n),o=y.useRef(null),s=au(n),c=y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return y.useEffect(()=>()=>c(),[c]),ai(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,b.jsx)(Or.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:V(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:V(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:V(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),$u=`SelectBubbleInput`,ed=y.forwardRef(G(function({__scopeSelect:e,...t},n){let r=du($u,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=y.useRef(null),m=cr(n,p),h=i??``,g=jl(h),_=Array.from(d).some(e=>(e.props.value??``)===``);return y.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(g!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[g,h]),(0,b.jsxs)(Or.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...Mr,...t.style},ref:m,defaultValue:h,children:[J(i)&&!_?(0,b.jsx)(`option`,{value:``}):null,Array.from(d)]},f)},`SelectBubbleInput`));function q(e){return typeof e==`function`}G(q,`isFunction`);function J(e){return e===``||e===void 0}G(J,`shouldShowPlaceholder`);function td(e){let t=zi(e),n=y.useRef(``),r=y.useRef(0),i=y.useCallback(e=>{let i=n.current+e;t(i),G((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=y.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}G(td,`useTypeaheadSearch`);function nd(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=rd(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}G(nd,`findNextItem`);function rd(e,t){return e.map((n,r)=>e[(t+r)%e.length])}G(rd,`wrapArray`);var id=Object.defineProperty,ad=(e,t)=>id(e,`name`,{value:t,configurable:!0}),[od,sd]=Lr(`Tooltip`,[sl]),cd=sl(),ld=`TooltipProvider`,ud=700,dd=`tooltip.open`,[fd,pd]=od(ld),md=ad(e=>{let{__scopeTooltip:t,delayDuration:n=ud,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=y.useRef(!0),s=y.useRef(!1),c=y.useRef(0);return y.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,b.jsx)(fd,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:y.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),hd=`Tooltip`,[gd,_d]=od(hd),vd=ad(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=pd(hd,e.__scopeTooltip),l=cd(t),[u,d]=y.useState(null),[f,p]=y.useState(void 0),m=Mi(),h=y.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=y.useRef(!1),[x,S]=mi({prop:r,defaultProp:i??!1,onChange:ad(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(dd))):c.onClose(),a?.(e)},`onChange`),caller:hd}),C=y.useMemo(()=>x?v.current?`delayed-open`:`instant-open`:`closed`,[x]),w=y.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,S(!0)},[S]),T=y.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S(!1)},[S]),E=y.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,S(!0),h.current=0},_)},[_,S]);y.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let D=f??m;return(0,b.jsx)(Cl,{...l,children:(0,b.jsx)(gd,{scope:t,contentId:D,setContentId:p,open:x,stateAttribute:C,trigger:u,onTriggerChange:d,onTriggerEnter:y.useCallback(()=>{c.isOpenDelayedRef.current?E():w()},[c.isOpenDelayedRef,E,w]),onTriggerLeave:y.useCallback(()=>{g?T():(window.clearTimeout(h.current),h.current=0)},[T,g]),onOpen:w,onClose:T,disableHoverableContent:g,children:n})})},`Tooltip`),yd=`TooltipTrigger`,bd=y.forwardRef(ad(function(e,t){let{__scopeTooltip:n,...r}=e,i=_d(yd,n),a=pd(yd,n),o=cd(n),s=cr(t,y.useRef(null),i.onTriggerChange),c=y.useRef(!1),l=y.useRef(!1),u=y.useCallback(()=>c.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,b.jsx)(wl,{asChild:!0,...o,children:(0,b.jsx)(Or.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:V(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:V(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:V(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:V(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:V(e.onBlur,i.onClose),onClick:V(e.onClick,i.onClose)})})},`TooltipTrigger`)),xd=`TooltipPortal`,[Sd,Cd]=od(xd,{forceMount:void 0}),wd=ad(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=_d(xd,t);return(0,b.jsx)(Sd,{scope:t,forceMount:n,children:(0,b.jsx)(Si,{present:n||a.open,children:(0,b.jsx)(ga,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),Td=`TooltipContent`,Ed=y.forwardRef(ad(function(e,t){let n=Cd(Td,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=_d(Td,e.__scopeTooltip);return(0,b.jsx)(Si,{present:r||o.open,children:o.disableHoverableContent?(0,b.jsx)(kd,{side:i,...a,ref:t}):(0,b.jsx)(Dd,{side:i,...a,ref:t})})},`TooltipContent`)),Dd=y.forwardRef(ad(function(e,t){let n=_d(Td,e.__scopeTooltip),r=pd(Td,e.__scopeTooltip),i=y.useRef(null),a=cr(t,i),[o,s]=y.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=y.useCallback(()=>{s(null),d(!1)},[d]),p=y.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Md(r,jd(r,n.getBoundingClientRect())),a=Nd(t.getBoundingClientRect()),o=Fd([...i,...a]);s(o),d(!0)},[d]);return y.useEffect(()=>()=>f(),[f]),y.useEffect(()=>{if(c&&u){let e=ad(e=>p(e,u),`handleTriggerLeave`),t=ad(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),y.useEffect(()=>{if(o){let e=ad(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Pd(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,b.jsx)(kd,{...e,ref:a})},`TooltipContentHoverable`)),Od=mr(`TooltipContent`),kd=y.forwardRef(ad(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=_d(Td,n),u=cd(n),{onClose:d}=l;y.useEffect(()=>(document.addEventListener(dd,d),()=>document.removeEventListener(dd,d)),[d]),y.useEffect(()=>{if(l.trigger){let e=ad(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return ai(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,b.jsx)(qi,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,b.jsxs)(Tl,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,b.jsx)(Od,{children:r}),i?(0,b.jsx)(Nr,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),Ad=y.forwardRef(ad(function(e,t){let{__scopeTooltip:n,...r}=e,i=cd(n);return(0,b.jsx)(El,{...i,...r,ref:t})},`TooltipArrow`));function jd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}ad(jd,`getExitSideFromRect`);function Md(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}ad(Md,`getPaddedExitPoints`);function Nd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}ad(Nd,`getPointsFromRect`);function Pd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}ad(Pd,`isPointInPolygon`);function Fd(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Id(t)}ad(Fd,`getHull`);function Id(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}ad(Id,`getHullPresorted`);var Ld=md,Rd=vd,zd=bd,Bd=wd,Vd=Ed,Hd=Ad,Ud=pn(`group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-semibold whitespace-nowrap transition-colors duration-200 ease-[var(--nf-ease-soft)] outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-[var(--nf-purple-10)] hover:text-[var(--nf-midnight)]`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-link underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function Wd({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?fr:`button`;return(0,b.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:rr(Ud({variant:t,size:n,className:e})),...i})}function Gd({...e}){return(0,b.jsx)(hu,{"data-slot":`select`,...e})}function Kd({...e}){return(0,b.jsx)(yu,{"data-slot":`select-value`,...e})}function qd({className:e,size:t=`default`,children:n,...r}){return(0,b.jsxs)(_u,{"data-slot":`select-trigger`,"data-size":t,className:rr(`flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,b.jsx)(bu,{asChild:!0,children:(0,b.jsx)(bt,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Jd({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,b.jsx)(Cu,{children:(0,b.jsxs)(Tu,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:rr(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,b.jsx)(Xd,{}),(0,b.jsx)(Lu,{"data-position":n,className:rr(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,b.jsx)(Zd,{})]})})}function Yd({className:e,children:t,...n}){return(0,b.jsxs)(Uu,{"data-slot":`select-item`,className:rr(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,b.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,b.jsx)(qu,{children:(0,b.jsx)(vt,{className:`pointer-events-none`})})}),(0,b.jsx)(Gu,{children:t})]})}function Xd({className:e,...t}){return(0,b.jsx)(Yu,{"data-slot":`select-scroll-up-button`,className:rr(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,b.jsx)(St,{})})}function Zd({className:e,...t}){return(0,b.jsx)(Zu,{"data-slot":`select-scroll-down-button`,className:rr(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,b.jsx)(bt,{})})}var Qd=typeof document>`u`?`/`:new URL(`.`,document.baseURI).href;function $d(e){return new URL(e.replace(/^\/+/,``),Qd).href}async function ef(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r!==void 0&&r!==``&&n.set(e,r);let r=n.toString(),i=await fetch($d(`api/${e}${r===``?``:`?${r}`}`),{headers:{accept:`application/json`}});if(i.status===401&&window.dispatchEvent(new Event(`fest:unauthenticated`)),!i.ok){let e=`HTTP ${i.status}`;try{let t=await i.json();typeof t.error==`string`&&(e=t.error)}catch{}throw Error(e)}return await i.json()}var tf=e=>({from:String(e.fromMs),to:String(e.toMs)}),nf={overview:e=>ef(`overview`,tf(e)),users:e=>ef(`users`,tf(e)),models:e=>ef(`models`,tf(e)),errors:e=>ef(`errors`,tf(e)),quota:()=>ef(`quota`,{}),audit:()=>ef(`audit`,{}),routing:()=>ef(`routing`,{}),requests:(e,t)=>ef(`requests`,{userId:e.userId,model:e.model,credentialOrigin:e.credentialOrigin,sessionId:e.sessionId,errorsOnly:e.errorsOnly===!0?`1`:void 0,before:t==null?void 0:String(t),limit:`50`})};function rf({className:e,size:t=`default`,...n}){return(0,b.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:rr(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-lg bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg`,e),...n})}function af({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`card-header`,className:rr(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function of({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`card-title`,className:rr(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function sf({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`card-description`,className:rr(`text-sm text-muted-foreground`,e),...t})}function cf({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`card-action`,className:rr(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function lf({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`card-content`,className:rr(`px-(--card-spacing)`,e),...t})}var uf=pn(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-colors focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-link underline-offset-4 hover:underline`,ok:`bg-tint-ok text-status-ok`,warn:`bg-tint-warn text-status-warn`,bad:`bg-tint-bad text-status-bad`,info:`bg-tint-info text-status-info`,sub:`bg-tint-sub text-status-sub`,muted:`bg-muted text-muted-foreground`}},defaultVariants:{variant:`default`}});function df({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?fr:`span`;return(0,b.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:rr(uf({variant:t}),e),...r})}function ff({className:e,value:t,...n}){return(0,b.jsx)($l,{"data-slot":`progress`,className:rr(`relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted`,e),...n,children:(0,b.jsx)(eu,{"data-slot":`progress-indicator`,className:`size-full flex-1 bg-primary transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})})}function pf({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`skeleton`,className:rr(`animate-pulse rounded-md bg-muted`,e),...t})}function mf({delayDuration:e=0,...t}){return(0,b.jsx)(Ld,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function hf({...e}){return(0,b.jsx)(Rd,{"data-slot":`tooltip`,...e})}function Y({...e}){return(0,b.jsx)(zd,{"data-slot":`tooltip-trigger`,...e})}function gf({className:e,sideOffset:t=0,children:n,...r}){return(0,b.jsx)(Bd,{children:(0,b.jsxs)(Vd,{"data-slot":`tooltip-content`,sideOffset:t,className:rr(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,b.jsx)(Hd,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[var(--nf-radius-xs)] bg-foreground fill-foreground`})]})})}function _f({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,b.jsx)(`table`,{"data-slot":`table`,className:rr(`w-full caption-bottom text-sm`,e),...t})})}function vf({className:e,...t}){return(0,b.jsx)(`thead`,{"data-slot":`table-header`,className:rr(`bg-table-head text-table-head-foreground [&_tr]:border-b-2 [&_tr]:border-table-head-rule`,e),...t})}function yf({className:e,...t}){return(0,b.jsx)(`tbody`,{"data-slot":`table-body`,className:rr(`[&_tr:last-child]:border-0`,e),...t})}function bf({className:e,...t}){return(0,b.jsx)(`tr`,{"data-slot":`table-row`,className:rr(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function xf({className:e,...t}){return(0,b.jsx)(`th`,{"data-slot":`table-head`,className:rr(`h-9 px-2 text-left align-middle font-serif text-[0.8125rem] font-bold whitespace-nowrap text-current first:rounded-tl-md last:rounded-tr-md [&:has([role=checkbox])]:pr-0`,e),...t})}function X({className:e,...t}){return(0,b.jsx)(`td`,{"data-slot":`table-cell`,className:rr(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}var Sf={ok:`text-status-ok`,warn:`text-status-warn`,bad:`text-status-bad`,info:`text-status-info`,sub:`text-status-sub`,muted:`text-muted-foreground`};function Cf(e,t){return t===void 0||t===``?e:(0,b.jsxs)(hf,{children:[(0,b.jsx)(Y,{asChild:!0,children:e}),(0,b.jsx)(gf,{className:`whitespace-pre-line`,children:t})]})}function wf({title:e,subtitle:t,right:n,children:r}){return(0,b.jsxs)(rf,{className:`mb-4`,children:[(e!==void 0||n!==void 0)&&(0,b.jsxs)(af,{children:[e!==void 0&&(0,b.jsx)(of,{children:e}),t!==void 0&&(0,b.jsx)(sf,{className:`max-w-[70ch] text-xs`,children:t}),n!==void 0&&(0,b.jsx)(cf,{children:n})]}),(0,b.jsx)(lf,{children:r})]})}function Tf({label:e,value:t,note:n,tone:r}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[0.8125rem] font-medium text-muted-foreground`,children:e}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xl font-semibold ${r===void 0?``:Sf[r]}`,children:t}),n!==void 0&&(0,b.jsx)(`div`,{className:`mt-0.5 text-[11.5px] text-muted-foreground`,children:n})]})}var Ef=({children:e})=>(0,b.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] gap-3.5`,children:e});function Df({children:e,tone:t=`muted`,title:n}){return Cf((0,b.jsx)(df,{variant:t,children:e}),n)}function Of({value:e,tone:t=`info`,label:n}){return e===null||!Number.isFinite(e)?(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`n/a`}):(0,b.jsx)(ff,{value:Math.max(0,Math.min(1,e))*100,"aria-label":n??`utilisation`,className:`my-1 h-1.5 min-w-[90px] ${{ok:`[&_[data-slot=progress-indicator]]:bg-status-ok`,warn:`[&_[data-slot=progress-indicator]]:bg-status-warn`,bad:`[&_[data-slot=progress-indicator]]:bg-status-bad`,info:`[&_[data-slot=progress-indicator]]:bg-status-info`}[t]}`})}var kf=({children:e,title:t})=>Cf((0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e}),t);function Af({isPending:e,error:t,isEmpty:n,emptyText:r=`No traffic in this range.`,children:i}){return t==null?e?(0,b.jsxs)(`div`,{className:`space-y-2 py-2`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,b.jsx)(pf,{className:`h-8 w-full`}),(0,b.jsx)(pf,{className:`h-8 w-[85%]`}),(0,b.jsx)(pf,{className:`h-8 w-[70%]`})]}):n===!0?(0,b.jsx)(`p`,{className:`py-3.5 text-muted-foreground`,children:r}):(0,b.jsx)(b.Fragment,{children:i}):(0,b.jsxs)(`p`,{className:`py-3.5 text-status-bad`,children:[`Could not load: `,String(t.message??t)]})}var jf=e=>({label:e,num:!0});function Mf({head:e,children:t}){return(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(_f,{children:[(0,b.jsx)(vf,{children:(0,b.jsx)(bf,{children:e.map(e=>{let t=typeof e==`string`?e:e.label;return(0,b.jsx)(xf,{className:`whitespace-nowrap${typeof e==`string`?``:` num text-right`}`,children:t},t)})})}),(0,b.jsx)(yf,{children:t})]})})}var Nf=pn(`group/alert relative grid w-full gap-0.5 rounded-md border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`border-border bg-muted text-foreground`,destructive:`border-destructive/30 bg-tint-bad text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current`,warning:`border-status-warn/40 bg-tint-warn text-status-warn *:data-[slot=alert-description]:text-status-warn/90 *:[svg]:text-current`}},defaultVariants:{variant:`default`}});function Pf({className:e,variant:t,...n}){return(0,b.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:rr(Nf({variant:t}),e),...n})}function Ff({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`alert-description`,className:rr(`text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),...t})}function If({ids:e}){return(0,b.jsx)(`div`,{className:`mono flex flex-col gap-0.5`,children:e.map(e=>(0,b.jsx)(`span`,{children:e},e))})}function Lf({route:e}){return e.shadows.length+e.outranked.length===0?(0,b.jsx)(kf,{children:`—`}):(0,b.jsxs)(`div`,{className:`mono flex flex-col gap-0.5`,children:[e.shadows.map(e=>(0,b.jsx)(`span`,{children:e},e)),e.outranked.map(e=>(0,b.jsx)(kf,{title:`Taken by the more specific rule “${e.takenBy}”, which wins regardless of file order. This rule still claims every other id its pattern matches.`,children:(0,b.jsx)(`span`,{className:`line-through`,children:e.model})},e.model))]})}var Rf=({route:e})=>e.upstream===null?(0,b.jsx)(Df,{tone:`ok`,title:`Deliberately kept on the caller's own credential.`,children:`pass through`}):(0,b.jsx)(Df,{tone:`warn`,title:`Served on a credential the server holds — org spend.`,children:e.upstream}),zf=({route:e})=>e.model===null?(0,b.jsx)(kf,{children:`unchanged`}):(0,b.jsx)(`span`,{className:`mono`,children:e.model});function Bf(){let e=nt({queryKey:[`routing`],queryFn:nf.routing,staleTime:3e5,refetchInterval:!1}),t=e.data,n=t?.upstreams??[],r=t?.routes??[],i=n.filter(e=>!e.credentialPresent),a=e=>e.shadows.length+e.outranked.length>0,o=r.filter(e=>e.upstream===null),s=r.filter(e=>e.upstream!==null&&a(e)),c=r.filter(e=>e.upstream!==null&&!a(e)),l=e.isPending,u=t!==void 0&&!t.enabled,d=l||t?.enabled===!0;return(0,b.jsxs)(b.Fragment,{children:[i.length>0&&(0,b.jsx)(Pf,{variant:`destructive`,className:`mb-4`,children:(0,b.jsxs)(Ff,{children:[i.map(e=>e.credentialSource).join(`, `),` `,i.length===1?`is`:`are`,` not set on the Fest server. Every request matching a route that targets `,i.length===1?`this upstream`:`these upstreams`,` will be`,` `,(0,b.jsx)(`strong`,{children:`refused`}),` — Fest will not quietly serve it on a developer's subscription instead.`]})}),(0,b.jsx)(wf,{title:`Upstreams`,subtitle:`Where traffic can go, and whether this server can actually reach it. Credentials are shown as references — the config holds {env:NAME}, never a value, so there is nothing secret on this screen to redact.`,right:t===void 0?void 0:(0,b.jsx)(Df,{tone:t.enabled?`info`:`muted`,title:`table version ${t.version}`,children:t.enabled?`v${t.version.slice(0,8)}`:`not configured`}),children:(0,b.jsx)(Af,{isPending:l,error:e.error,isEmpty:u,emptyText:`No routing configured. Every request passes through to Anthropic on the caller's own credential — the safe default. Set FEST_ROUTES to change that.`,children:(0,b.jsx)(Mf,{head:[`Upstream`,`Adapter`,`Endpoint`,`Credential`,`Rules`,`Transforms`],children:n.map(e=>{let t=r.filter(t=>t.upstream===e.id);return(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.id}),(0,b.jsx)(X,{children:e.adapter}),(0,b.jsx)(X,{className:`mono`,children:e.baseUrl}),(0,b.jsxs)(X,{children:[(0,b.jsx)(`span`,{className:`mono`,children:e.credentialSource}),` `,(0,b.jsx)(Df,{tone:e.credentialPresent?`ok`:`bad`,children:e.credentialPresent?`set`:`not set`})]}),(0,b.jsx)(X,{className:`num`,children:t.length===0?(0,b.jsx)(kf,{title:`No rule targets this upstream. An anthropic adapter is still reachable as the default for unrouted Anthropic models in the key posture.`,children:`default only`}):t.length}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:e.transforms.join(`; `)})})]},e.id)})})})}),d&&(0,b.jsx)(wf,{title:`Substitutions`,subtitle:`Rules that change where a model Anthropic already offers comes from. A developer asks for it by its usual name and gets it from somewhere else, on a credential the server holds — which is org spend, and the reason this screen exists.`,children:(0,b.jsx)(Af,{isPending:l,error:e.error,isEmpty:s.length===0,emptyText:`No rule claims a model Anthropic offers. Every base model still resolves the way a developer would expect.`,children:(0,b.jsx)(Mf,{head:[`Rule`,`Pattern`,`Substitutes for`,`Goes to`,`Sent as`,`Also listed as`],children:s.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.id}),(0,b.jsx)(X,{className:`mono`,children:e.match}),(0,b.jsx)(X,{children:(0,b.jsx)(Lf,{route:e})}),(0,b.jsx)(X,{children:(0,b.jsx)(Rf,{route:e})}),(0,b.jsx)(X,{children:(0,b.jsx)(zf,{route:e})}),(0,b.jsx)(X,{children:e.menuIds.length===0?(0,b.jsx)(kf,{title:`Claude Code dedupes gateway entries against its built-in list, so a substituted id shows no destination in the picker. An expose alias is how a developer gets to see where it goes.`,children:`no alias`}):(0,b.jsx)(If,{ids:e.menuIds})})]},e.id))})})}),d&&(0,b.jsx)(wf,{title:`Models this gateway adds`,subtitle:`Ids that exist only behind Fest. They take nothing away from a developer: they appear under “From gateway” in the /model menu, and choosing one is a deliberate act.`,children:(0,b.jsx)(Af,{isPending:l,error:e.error,isEmpty:c.length===0,emptyText:`No rule adds a model. Routing here only changes where existing models come from.`,children:(0,b.jsx)(Mf,{head:[`Rule`,`Pattern`,`Appears in /model as`,`Goes to`,`Sent as`],children:c.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.id}),(0,b.jsx)(X,{className:`mono`,children:e.match}),(0,b.jsx)(X,{children:e.menuIds.length===0?(0,b.jsx)(kf,{title:`Not published in the menu: a wildcard has no single id to list, and Claude Code drops any id not matching /(claude|anthropic)/i. The rule still applies to a request that asks for a matching id.`,children:`not listed — request by id`}):(0,b.jsx)(If,{ids:e.menuIds})}),(0,b.jsx)(X,{children:(0,b.jsx)(Rf,{route:e})}),(0,b.jsx)(X,{children:(0,b.jsx)(zf,{route:e})})]},e.id))})})}),o.length>0&&(0,b.jsx)(wf,{title:`Kept on the caller's credential`,subtitle:`Carve-outs: rules that match, and then deliberately do nothing. This is how a broad substitution keeps its exceptions on a developer's own subscription.`,children:(0,b.jsx)(Mf,{head:[`Rule`,`Pattern`,`Substitutes for`,`Goes to`],children:o.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.id}),(0,b.jsx)(X,{className:`mono`,children:e.match}),(0,b.jsx)(X,{children:(0,b.jsx)(Lf,{route:e})}),(0,b.jsx)(X,{children:(0,b.jsx)(Rf,{route:e})})]},e.id))})}),r.length>0&&(0,b.jsxs)(`p`,{className:`max-w-[70ch] text-xs text-muted-foreground`,children:[`Rules are listed in `,(0,b.jsx)(`strong`,{children:`evaluation order`}),` within each table — exact matches first, then longest wildcard, then file order. That is not the order they appear in the file, and “substitutes for” already has precedence applied: a catch-all is not credited with a model an exact rule above it takes.`]})]})}function Vf(e){let t=new EventSource($d(`api/live`));return t.addEventListener(`open`,()=>{e.onStatus?.(!0),e.onReconnect?.()}),t.addEventListener(`error`,()=>{e.onStatus?.(!1)}),t.addEventListener(`usage`,t=>{try{let n=JSON.parse(t.data);n.rows.length>0&&e.onRows(n.rows)}catch{}}),()=>t.close()}Object.freeze({inputTokens:0,cacheReadTokens:0,cacheWrite5mTokens:0,cacheWrite1hTokens:0,outputTokens:0,webSearches:0});var Hf=[`ok`,`preflight_refused`];function Z(e){return!Hf.includes(e)}var Uf=new Intl.NumberFormat(`en-US`),Wf=new Intl.NumberFormat(`en-US`,{style:`percent`,maximumFractionDigits:1}),Gf=e=>Uf.format(e);function Kf(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}k`:e<1e9?`${(e/1e6).toFixed(+(e<1e7))}M`:`${(e/1e9).toFixed(1)}B`}var qf=(e,t)=>t>0?`≥ ${e}`:e,Jf=e=>e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`;function Yf(e){return qf(`$${e.pricedCostUsd.toFixed(4)}`,e.unpricedRequests)}function Xf(e){return qf(`~$${e.notionalCostUsd.toFixed(2)}`,e.notionalUnpricedRequests)}var Zf=e=>e===null?`n/a`:Wf.format(e);function Qf(e){return e===null||!Number.isFinite(e)?`n/a`:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(e<1e4?2:1)}s`}var $f=e=>e.inputTokens+e.cacheReadTokens+e.cacheWrite5mTokens+e.cacheWrite1hTokens,ep=e=>e.cacheWrite5mTokens+e.cacheWrite1hTokens,tp=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),np=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`});function rp(e){let t=new Date(e);return new Date().toDateString()===t.toDateString()?tp.format(t):`${np.format(t)} ${tp.format(t)}`}function ip(e,t=Date.now()){if(e===null)return`n/a`;let n=e-t,r=Math.round(Math.abs(n)/6e4),i=r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`;return n>=0?`in ${i}`:`${i} ago`}var ap={inbound_subscription:`Developer subscription`,inbound_key:`Developer API key`,fallback_server:`Server-held key`,none:`No credential`},op=e=>ap[e]??e,sp={"claude-code":`Claude Code`,codex:`Codex`,copilot:`Copilot`},cp=e=>e===null||e===``?`Unknown client`:sp[e]??e;function lp(e,t){return t!=null&&t!==``?t.replace(/@.*$/,``):e===null||e===``?`unattributed`:e.length>16?`${e.slice(0,14)}…`:e}var up=e=>e===null||e===``?`unresolved`:e.split(`/`).pop()??e,dp=60,fp=e=>Z(e.status);function pp(e){return{id:e.id,at:e.startedAt,userId:e.userId,email:null,model:e.servedModel??``,client:e.client??``,origin:e.credentialOrigin,status:e.status,pipeline:e.pipeline,costUsd:e.costUsd,notionalCostUsd:e.notionalCostUsd,subscription:e.costBasis===`subscription`,context:$f(e.usage),cacheWrite:ep(e.usage),output:e.usage.outputTokens,durationMs:e.durationMs}}function mp(e){let[t,n]=(0,y.useState)([]),[r,i]=(0,y.useState)(()=>Date.now());(0,y.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),2e3);return()=>clearInterval(e)},[]);let a=(0,y.useRef)(e);a.current=e;let o=(0,y.useCallback)(e=>{if(e.length===0)return;let t=Date.now()-a.current;n(n=>{let r=new Set(n.map(e=>e.id)),i=[...n];for(let t of e)r.has(t.id)||i.push(pp(t));return i.filter(e=>e.at>=t)})},[]),s=(0,y.useCallback)(e=>o(e),[o]);return{window:(0,y.useMemo)(()=>{let n=r-e,i=t.filter(e=>e.at>=n),a=e/dp,o=Math.floor(r/a)*a,s=Array(dp).fill(0),c=Array(dp).fill(0);for(let e of i){let t=59-Math.floor((o-e.at)/a);t<0||t>=dp||(s[t]=(s[t]??0)+1,fp(e)&&(c[t]=(c[t]??0)+1))}let l=s.map((e,t)=>({startMs:o-(59-t)*a,count:e,errors:c[t]??0})),u=i.length,d=i.filter(fp).length;return{events:i,buckets:l,total:u,errors:d,perMinute:u/(e/6e4),errorRatio:u===0?null:d/u,windowMs:e}},[t,r,e]),add:o,seed:s}}var hp=`fest-live-measure`,gp=[{id:`tokens`,label:`Tokens`,hint:`Raw throughput: context, cache writes and output.`},{id:`billed`,label:`Billed $`,hint:`What the org is charged. Usage absorbed by a developer's own subscription is excluded.`},{id:`value`,label:`Value $`,hint:`What this work would cost at published API rates, subscription usage included.`}];function _p(){return{context:0,cacheWrite:0,output:0,billedUsd:0,billedUnpriced:0,subscriptionRequests:0,valueUsd:0,valueUnpriced:0}}function vp(e,t){e.context+=t.context,e.cacheWrite+=t.cacheWrite,e.output+=t.output,t.subscription?e.subscriptionRequests+=1:t.costUsd===null?e.billedUnpriced+=1:e.billedUsd+=t.costUsd,t.notionalCostUsd===null?e.valueUnpriced+=1:e.valueUsd+=t.notionalCostUsd}function yp(e,t){e.context+=t.context,e.cacheWrite+=t.cacheWrite,e.output+=t.output,e.billedUsd+=t.billedUsd,e.billedUnpriced+=t.billedUnpriced,e.subscriptionRequests+=t.subscriptionRequests,e.valueUsd+=t.valueUsd,e.valueUnpriced+=t.valueUnpriced}var bp=e=>e.context+e.cacheWrite+e.output;function xp(e,t){switch(t){case`tokens`:return bp(e);case`billed`:return e.billedUsd;case`value`:return e.valueUsd}}function Sp(e,t){switch(t){case`tokens`:return!1;case`billed`:return e.billedUnpriced>0;case`value`:return e.valueUnpriced>0}}function Cp(e,t,n=!1){switch(t){case`tokens`:return Kf(Math.round(e));case`billed`:return qf(Jf(e),+!!n);case`value`:return qf(`~${Jf(e)}`,+!!n)}}function wp(e){return(t,n)=>xp(n.tally,e)-xp(t.tally,e)||bp(n.tally)-bp(t.tally)||n.requests-t.requests||t.key.localeCompare(n.key)}function Tp(e){switch(e){case`tokens`:return`total tokens`;case`billed`:return`billed spend`;case`value`:return`value at list rates`}}function Ep(e){switch(e){case`tokens`:return`tokens`;case`billed`:return`billed $`;case`value`:return`value $`}}function Dp(e){switch(e){case`tokens`:return{label:`Tokens`,note:`per minute`};case`billed`:return{label:`Billed`,note:`per minute, org spend`};case`value`:return{label:`Value`,note:`per minute, at list rates`}}}function Op(e,t,n){return n===0||t===`tokens`||xp(e,t)>0?null:t===`billed`?e.subscriptionRequests===n?`All traffic in this window ran on developer subscriptions — no org spend.`:e.billedUnpriced>0?`Nothing in this window could be priced.`:`No org spend in this window.`:`No published rates for the models in this window.`}var kp=600,Ap=72,jp=8,Mp=72,Np=1.25;function Pp(e){return e<5?`var(--model-${e+1})`:`var(--muted-foreground)`}function Fp({events:e,windowMs:t,models:n,live:r,measure:i}){let a=(0,y.useRef)(null),{bars:o,barW:s,anchor:c,peak:l,peakTally:u,sliceMs:d}=(0,y.useMemo)(()=>{let r=Date.now(),a=t/Mp,o=Math.floor((r-t*Np)/a),s=Math.floor(r/a),c=new Map;for(let t of e){let e=Math.floor(t.at/a);if(e<o||e>s)continue;let n=c.get(e);n===void 0&&(n={byModel:new Map,tally:_p()},c.set(e,n));let r=_p();vp(r,t),n.byModel.set(t.model,(n.byModel.get(t.model)??0)+xp(r,i)),vp(n.tally,t)}let l=0,u=_p();for(let e of c.values()){let t=0;for(let n of e.byModel.values())t+=n;t>l&&(l=t,u=e.tally)}let d=l===0?0:64/l,f=n.length>0?n:[...new Set(e.map(e=>e.model))],p=[];for(let[e,n]of c){let i=[],o=0;for(let e of f){let t=n.byModel.get(e);if(t===void 0||t===0)continue;let r=t*d;o+=r,i.push({model:e,y:Ap-o,h:r})}for(let[e,t]of n.byModel){if(f.includes(e))continue;let n=t*d;o+=n,i.push({model:e,y:Ap-o,h:n})}p.push({key:e,x:kp*(1+(e*a-r)/t),segments:i})}return{bars:p,barW:Math.max(1.5,kp*a/t-1),anchor:r,peak:l,peakTally:u,sliceMs:a}},[e,t,n,i]);(0,y.useLayoutEffect)(()=>{let e=a.current;if(e===null)return;let n=()=>{let n=(Date.now()-c)/t*kp;e.setAttribute(`transform`,`translate(${(-n).toFixed(2)} 0)`)};if(n(),window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let r=0,i=()=>{n(),r=requestAnimationFrame(i)};return r=requestAnimationFrame(i),()=>cancelAnimationFrame(r)},[c,t]);let f=e=>{let t=n.indexOf(e);return Pp(t===-1?99:t)},p=jp/Ap*100,m=Op((0,y.useMemo)(()=>{let t=_p();for(let n of e)vp(t,n);return t},[e]),i,e.length);return(0,b.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg bg-card ring-1 ring-foreground/10 transition-opacity ${r?``:`opacity-60`}`,children:[(0,b.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-10`,children:[l>0&&(0,b.jsx)(`div`,{className:`absolute left-1.5 -translate-y-1/2 rounded bg-card/85 px-1 text-[10px] text-muted-foreground tabular-nums`,style:{top:`${p}%`},children:Cp(l,i,Sp(u,i))}),(0,b.jsx)(`div`,{className:`absolute bottom-0.5 left-1.5 rounded bg-card/85 px-1 text-[10px] text-muted-foreground`,children:`0`}),(0,b.jsxs)(`div`,{className:`absolute right-1.5 bottom-0.5 rounded bg-card/85 px-1 text-[10px] text-muted-foreground`,children:[Ep(i),` per `,Math.round(d/1e3),`s`]}),m!==null&&(0,b.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center px-6`,children:(0,b.jsx)(`span`,{className:`rounded bg-card/85 px-1.5 py-0.5 text-center text-[11px] text-muted-foreground`,children:m})})]}),(0,b.jsxs)(`svg`,{viewBox:`0 0 ${kp} ${Ap}`,preserveAspectRatio:`none`,className:`h-[72px] w-full`,role:`img`,"aria-label":`${Tp(i)} by model over the last ${Math.round(t/6e4)} minutes`,children:[(0,b.jsxs)(`defs`,{children:[(0,b.jsxs)(`linearGradient`,{id:`pulse-mask`,x1:`0`,y1:`0`,x2:`1`,y2:`0`,children:[(0,b.jsx)(`stop`,{offset:`0%`,stopColor:`black`}),(0,b.jsx)(`stop`,{offset:`10%`,stopColor:`white`}),(0,b.jsx)(`stop`,{offset:`100%`,stopColor:`white`})]}),(0,b.jsx)(`mask`,{id:`pulse-edge`,children:(0,b.jsx)(`rect`,{x:`0`,y:`0`,width:kp,height:Ap,fill:`url(#pulse-mask)`})})]}),(0,b.jsx)(`g`,{mask:`url(#pulse-edge)`,children:(0,b.jsx)(`g`,{ref:a,children:o.map(e=>(0,b.jsx)(`g`,{children:e.segments.map(t=>(0,b.jsx)(`rect`,{x:e.x,y:t.y,width:s,height:Math.max(1,t.h),fill:f(t.model)},t.model))},e.key))})}),l>0&&(0,b.jsx)(`line`,{x1:`0`,y1:jp,x2:kp,y2:jp,stroke:`var(--border)`,strokeWidth:`1`,strokeDasharray:`3 3`,vectorEffect:`non-scaling-stroke`}),(0,b.jsx)(`line`,{x1:`0`,y1:71.5,x2:kp,y2:71.5,stroke:`var(--border)`,strokeWidth:`1`,vectorEffect:`non-scaling-stroke`})]})]})}var Ip=pn(`group/button-group flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg!`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg!`}},defaultVariants:{orientation:`horizontal`}});function Lp({className:e,orientation:t,...n}){return(0,b.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:rr(Ip({orientation:t}),e),...n})}function Rp({connected:e,paused:t,perMinute:n}){let r=e?t?`paused`:`live`:`reconnecting`,i={live:`text-status-ok`,paused:`text-status-warn`,reconnecting:`text-status-bad`}[r],a={live:`live`,paused:`paused`,reconnecting:`reconnecting…`}[r];return(0,b.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium ${i}`,role:`status`,children:[(0,b.jsxs)(`span`,{className:`relative flex size-2`,children:[r===`live`&&(0,b.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-current opacity-70 motion-reduce:hidden`}),(0,b.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-current`})]}),r===`live`&&(0,b.jsx)(Ht,{className:`size-3.5`,"aria-hidden":`true`}),r===`paused`&&(0,b.jsx)(At,{className:`size-3.5`,"aria-hidden":`true`}),r===`reconnecting`&&(0,b.jsx)(Bt,{className:`size-3.5`,"aria-hidden":`true`}),(0,b.jsx)(`span`,{children:a}),e&&(0,b.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:n<.1?`idle`:`≈${n.toFixed(1)}/min`})]})}var zp=[{id:`60000`,label:`Last 1 min`},{id:`300000`,label:`Last 5 min`},{id:`900000`,label:`Last 15 min`},{id:`3600000`,label:`Last hour`}];function Bp({windowMs:e,onWindowMs:t,measure:n,onMeasure:r,connected:i,paused:a,onPaused:o,perMinute:s}){return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsxs)(Gd,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,b.jsx)(qd,{size:`sm`,className:`w-[150px]`,"aria-label":`Rolling window length`,children:(0,b.jsx)(Kd,{})}),(0,b.jsx)(Jd,{children:zp.map(e=>(0,b.jsx)(Yd,{value:e.id,children:e.label},e.id))})]}),(0,b.jsx)(Lp,{"aria-label":`Measure`,children:gp.map(e=>(0,b.jsx)(Wd,{type:`button`,size:`sm`,variant:e.id===n?`default`:`outline`,"aria-pressed":e.id===n,title:e.hint,onClick:()=>r(e.id),children:e.label},e.id))}),(0,b.jsxs)(Wd,{type:`button`,size:`sm`,variant:a?`default`:`outline`,onClick:()=>o(!a),children:[a?(0,b.jsx)(Mt,{}):(0,b.jsx)(At,{}),a?`Resume`:`Pause`]}),(0,b.jsx)(`div`,{className:`ml-auto`,children:(0,b.jsx)(Rp,{connected:i,paused:a,perMinute:s})})]})}var Vp=.5;function Hp(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Up(e,t=450){let[n,r]=(0,y.useState)(e),i=(0,y.useRef)(0),a=(0,y.useRef)(e),o=(0,y.useRef)(0);return(0,y.useEffect)(()=>{if(Hp()){r(e);return}a.current=n,o.current=performance.now();let s=n=>{let c=Math.min(1,(n-o.current)/t),l=1-(1-c)**3,u=a.current+(e-a.current)*l;r(Math.abs(e-u)<Vp?e:u),c<1&&(i.current=requestAnimationFrame(s))};return i.current=requestAnimationFrame(s),()=>cancelAnimationFrame(i.current)},[e,t]),n}function Wp({label:e,value:t,note:n,tone:r}){return(0,b.jsxs)(`div`,{className:`rounded-lg bg-card px-4 py-3 ring-1 ring-foreground/10`,children:[(0,b.jsx)(`div`,{className:`text-[0.8125rem] font-medium text-muted-foreground`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-2xl font-semibold tabular-nums ${r===`ok`?`text-status-ok`:r===`warn`?`text-status-warn`:r===`bad`?`text-status-bad`:r===`sub`?`text-status-sub`:``}`,children:t}),n!==void 0&&(0,b.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:n})]})}function Gp({perMinute:e,measure:t,rate:n,rateLowerBound:r,errorRatio:i,developers:a,subscriptionShare:o,serverKeyRequests:s}){let c=Up(e),l=Up(n),u=Up(a),d=Up((i??0)*100),f=Up((o??0)*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] gap-3`,children:[(0,b.jsx)(Wp,{label:`Requests`,value:`${c.toFixed(1)}`,note:`per minute`}),(0,b.jsx)(Wp,{label:Dp(t).label,value:Cp(l,t,r),note:Dp(t).note,...t===`value`?{tone:`sub`}:{}}),(0,b.jsx)(Wp,{label:`Failing`,value:i===null?`—`:`${d.toFixed(0)}%`,note:i===null?`no traffic yet`:`of this window`,...i!==null&&i>0?{tone:`bad`}:{}}),(0,b.jsx)(Wp,{label:`Developers`,value:`${Math.round(u)}`,note:`active in window`}),(0,b.jsx)(Wp,{label:`On own subscription`,value:o===null?`—`:`${f.toFixed(0)}%`,note:s===0?`no org spend in window`:`${s} on a server-held key`,...s>0?{tone:`warn`}:{tone:`ok`}})]})}var Kp=40;function qp({entry:e,rank:t,peak:n,measure:r}){let i=xp(e.tally,r),a=Up(n===0?0:i/n*100),o=Up(i);return(0,b.jsxs)(`div`,{className:`absolute inset-x-0 flex h-10 items-center gap-3 px-1 transition-transform duration-500 ease-out motion-reduce:transition-none`,style:{transform:`translateY(${t*Kp}px)`},children:[(0,b.jsx)(`div`,{className:`flex w-[42%] min-w-0 items-center gap-2`,children:e.label}),(0,b.jsxs)(hf,{children:[(0,b.jsx)(Y,{asChild:!0,children:(0,b.jsx)(`div`,{className:`relative flex-1 cursor-default`,children:(0,b.jsx)(`div`,{className:`h-5 overflow-hidden rounded-md bg-muted/60`,children:(0,b.jsx)(`div`,{className:`h-full rounded-md bg-primary/80 transition-[width] duration-500 ease-out motion-reduce:transition-none`,style:{width:`${a}%`}})})})}),(0,b.jsx)(gf,{children:(0,b.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,b.jsxs)(`span`,{children:[`Context `,Gf(e.tally.context)]}),(0,b.jsxs)(`span`,{children:[`Cache write `,Gf(e.tally.cacheWrite)]}),(0,b.jsxs)(`span`,{children:[`Output `,Gf(e.tally.output)]}),(0,b.jsxs)(`span`,{className:`text-background/70`,children:[Gf(e.requests),` request`,e.requests===1?``:`s`]}),r===`billed`&&e.tally.subscriptionRequests>0&&(0,b.jsxs)(`span`,{className:`text-background/70`,children:[Gf(e.tally.subscriptionRequests),` on subscription, never billed`]}),Sp(e.tally,r)&&(0,b.jsxs)(`span`,{className:`text-background/70`,children:[Gf(r===`billed`?e.tally.billedUnpriced:e.tally.valueUnpriced),` `,`not priced`]})]})})]}),(0,b.jsxs)(`div`,{className:`w-24 shrink-0 text-right text-xs tabular-nums`,children:[(0,b.jsx)(`div`,{className:`font-medium`,children:Cp(o,r,Sp(e.tally,r))}),(0,b.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[e.requests,` req`,e.errors>0&&(0,b.jsxs)(`span`,{className:`text-status-bad`,children:[` · `,e.errors,` err`]})]})]})]})}function Jp({title:e,entries:t,emptyText:n,measure:r,limit:i=6}){let a=[...t].sort(wp(r)).slice(0,i),o=a[0]===void 0?0:xp(a[0].tally,r),s=_p(),c=0;for(let e of a)yp(s,e.tally),c+=e.requests;let l=Op(s,r,c);return(0,b.jsxs)(`div`,{className:`rounded-lg bg-card p-4 ring-1 ring-foreground/10`,children:[(0,b.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`,children:[(0,b.jsx)(`h2`,{className:`text-[0.8125rem] font-medium text-muted-foreground`,children:e}),(0,b.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Tp(r)})]}),l!==null&&(0,b.jsx)(`p`,{className:`mb-2 text-[11px] text-muted-foreground`,children:l}),a.length===0?(0,b.jsx)(`p`,{className:`py-6 text-center text-xs text-muted-foreground`,children:n}):(0,b.jsx)(`div`,{className:`relative`,style:{height:a.length*Kp},children:a.map((e,t)=>(0,b.jsx)(qp,{entry:e,rank:t,peak:o,measure:r},e.key))})]})}function Yp(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function Xp(e){let t=e.replace(/@.*$/,``).split(/[.\-_\s]+/).filter(e=>e.length>0);return((t[0]?.[0]??e[0]??`?`)+(t.length>1?t[1]?.[0]??``:``)).toUpperCase()}function Zp({userId:e,label:t}){if(e===null||e===``)return(0,b.jsxs)(hf,{children:[(0,b.jsx)(Y,{asChild:!0,children:(0,b.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full border border-dashed border-status-warn text-[10px] font-semibold text-status-warn`,"aria-label":`unattributed`,children:`?`})}),(0,b.jsx)(gf,{children:`No Fest identity token was presented, so this usage lands in nobody's column.`})]});let n=Yp(e);return(0,b.jsxs)(hf,{children:[(0,b.jsx)(Y,{asChild:!0,children:(0,b.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold`,style:{background:`oklch(0.7 0.12 ${n} / 0.22)`,color:`oklch(0.72 0.14 ${n})`},"aria-label":t,children:Xp(t)})}),(0,b.jsx)(gf,{children:t})]})}function Qp(){try{let e=window.localStorage.getItem(hp);return e===`tokens`||e===`billed`||e===`value`?e:null}catch{return null}}function $p(){let[e,t]=(0,y.useState)(()=>Qp()??`tokens`);return{measure:e,setMeasure:(0,y.useCallback)(e=>{t(e);try{window.localStorage.setItem(hp,e)}catch{}},[])}}var em=3e5;function tm(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i===void 0&&(i={requests:0,errors:0,tally:_p()},n.set(e,i)),i.requests+=1,Z(r.status)&&(i.errors+=1),vp(i.tally,r)}return n}function nm(){let e=S(),[t,n]=(0,y.useState)(em),{measure:r,setMeasure:i}=$p(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),{window:l,add:u,seed:d}=mp(t),f=(0,y.useRef)(s);f.current=s;let p=(0,y.useRef)(u);p.current=u;let m=nt({queryKey:[`requests`,`live-seed`],queryFn:()=>nf.requests({},null),staleTime:15e3}),h=nt({queryKey:[`users`,`identities`],queryFn:()=>nf.users(Zt(`30d`)),staleTime:3e5}),g=(0,y.useMemo)(()=>new Map((h.data?.rows??[]).map(e=>[e.userId,e.email])),[h.data]),_=(0,y.useRef)(d);_.current=d,(0,y.useEffect)(()=>{m.data!==void 0&&_.current(m.data.rows)},[m.data]),(0,y.useEffect)(()=>Vf({onStatus:o,onReconnect:()=>{e.invalidateQueries({queryKey:[`requests`,`live-seed`]})},onRows:e=>{f.current||p.current(e)}}),[e]);let v=l.events,x=(0,y.useMemo)(()=>[...tm(v,e=>e.model).entries()].map(([e,t])=>({key:e,...t})).sort(wp(r)).map((e,t)=>({key:e.key,label:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`inline-block size-2 shrink-0 rounded-sm`,style:{background:Pp(t)}}),(0,b.jsx)(`span`,{className:`mono truncate text-xs`,title:e.key===``?`unresolved`:e.key,children:up(e.key)})]}),requests:e.requests,errors:e.errors,tally:e.tally})),[v,r]),C=(0,y.useMemo)(()=>[...tm(v,e=>e.userId??``).entries()].map(([e,t])=>{let n=e===``?null:e,r=lp(n,g.get(e)??null);return{key:e===``?`unattributed`:e,label:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Zp,{userId:n,label:r}),(0,b.jsx)(`span`,{className:`truncate text-xs`,children:r})]}),requests:t.requests,errors:t.errors,tally:t.tally}}),[v,g]),w=(0,y.useMemo)(()=>[...tm(v,e=>e.client).entries()].map(([e,t])=>({key:e===``?`unknown`:e,label:(0,b.jsx)(`span`,{className:`truncate text-xs ${e===``?`text-muted-foreground`:``}`,title:e===``?`The client could not be told from its headers.`:void 0,children:cp(e)}),requests:t.requests,errors:t.errors,tally:t.tally})),[v]),T=(0,y.useMemo)(()=>[...x].sort(wp(r)).map(e=>e.key),[x,r]),E=(0,y.useMemo)(()=>[...tm(v,e=>e.origin).entries()].map(([e,t])=>({origin:e,...t})).sort((e,t)=>t.requests-e.requests),[v]),D=(0,y.useMemo)(()=>{let e=t/6e4,n=_p();for(let e of v)vp(n,e);let i=v.filter(e=>e.origin===`inbound_subscription`).length,a=v.filter(e=>e.origin===`fallback_server`).length,o=new Set(v.map(e=>e.userId??``)).size;return{perMinute:l.total/e,rate:xp(n,r)/e,rateLowerBound:Sp(n,r),errorRatio:l.errorRatio,developers:o,subscriptionShare:l.total===0?null:i/l.total,serverKeyRequests:a,spend:Yf({pricedCostUsd:n.billedUsd,unpricedRequests:n.billedUnpriced}),value:Xf({notionalCostUsd:n.valueUsd,notionalUnpricedRequests:n.valueUnpriced}),subscriptionRequests:n.subscriptionRequests}},[v,l,t,r]);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,b.jsx)(Bp,{windowMs:t,onWindowMs:n,measure:r,onMeasure:i,connected:a,paused:s,onPaused:c,perMinute:D.perMinute}),(0,b.jsx)(Fp,{events:v,windowMs:t,models:T,live:a&&!s,measure:r}),T.length>0&&(0,b.jsxs)(`div`,{className:`-mt-1 flex flex-wrap gap-x-4 gap-y-1 px-1`,children:[T.slice(0,5).map((e,t)=>(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`inline-block size-2 rounded-sm`,style:{background:Pp(t)}}),(0,b.jsx)(`span`,{className:`mono`,title:e===``?`unresolved`:e,children:up(e)})]},e)),T.length>5&&(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`inline-block size-2 rounded-sm`,style:{background:Pp(99)}}),T.length-5,` more`]})]}),(0,b.jsx)(Gp,{perMinute:D.perMinute,measure:r,rate:D.rate,rateLowerBound:D.rateLowerBound,errorRatio:D.errorRatio,developers:D.developers,subscriptionShare:D.subscriptionShare,serverKeyRequests:D.serverKeyRequests}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(340px,1fr))] gap-3`,children:[(0,b.jsx)(Jp,{title:`By model`,entries:x,emptyText:`No traffic in this window yet.`,measure:r}),(0,b.jsx)(Jp,{title:`By user`,entries:C,emptyText:`No traffic in this window yet.`,measure:r}),(0,b.jsx)(Jp,{title:`By client`,entries:w,emptyText:`No traffic in this window yet.`,measure:r})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-card p-4 ring-1 ring-foreground/10`,children:[(0,b.jsxs)(`div`,{className:`mb-3 flex items-baseline justify-between gap-3`,children:[(0,b.jsx)(`h2`,{className:`text-[0.8125rem] font-medium text-muted-foreground`,children:`Who paid, in this window`}),(0,b.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[D.subscriptionRequests,` absorbed by subscriptions`]})]}),(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-end gap-x-8 gap-y-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[0.8125rem] font-medium text-muted-foreground`,children:`Billed`}),(0,b.jsx)(`div`,{className:`num mt-0.5 text-xl font-semibold`,children:D.spend}),(0,b.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`org spend`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[0.8125rem] font-medium text-muted-foreground`,children:`Value at list rates`}),(0,b.jsx)(`div`,{className:`num mt-0.5 text-xl font-semibold text-status-sub`,children:D.value}),(0,b.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`all usage, incl. subscription`})]})]}),E.length===0?(0,b.jsx)(`p`,{className:`py-4 text-center text-xs text-muted-foreground`,children:`Nothing has run through the gateway in this window.`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-muted`,children:E.map(e=>(0,b.jsx)(`div`,{className:`transition-[width] duration-500 ease-out motion-reduce:transition-none ${e.origin===`inbound_subscription`?`bg-status-ok`:e.origin===`fallback_server`?`bg-status-warn`:e.origin===`inbound_key`?`bg-status-info`:`bg-muted-foreground`}`,style:{width:`${e.requests/Math.max(1,l.total)*100}%`}},e.origin))}),(0,b.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1`,children:E.map(e=>(0,b.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,b.jsx)(df,{variant:e.origin===`inbound_subscription`?`ok`:e.origin===`fallback_server`?`warn`:`muted`,children:op(e.origin)}),(0,b.jsx)(`span`,{className:`text-muted-foreground tabular-nums`,children:e.requests})]},e.origin))})]})]})]})}function rm(e,t){let n=im(e),r=n?e():e;if(typeof r!=`function`||typeof r.copy!=`function`||typeof r.domain!=`function`||typeof r.range!=`function`)throw TypeError(`A scale factory must return a copyable scale with domain and range methods`);let i=r.copy();if(n){let e=am(i,t.values,t.includeZero);e&&i.domain(e)}return cm(i,t.nice,t.niceCount),i}function im(e){return typeof e==`function`&&!(`copy`in e)}function am(e,t,n=!1){if(typeof e.bandwidth==`function`||typeof e.ticks!=`function`){let e=[],n=new Set,r=new Set;for(let i of t){if(!vm(i))continue;let t=i instanceof Date,a=t?i.getTime():i,o=t?r:n;o.has(a)||(o.add(a),e.push(i))}return e.length?e:void 0}let r=t.filter(vm);if(!r.length)return;if(e.domain().some(e=>e instanceof Date)){let e=r.filter(e=>e instanceof Date);if(e.length!==r.length)throw TypeError(`A temporal scale factory requires Date channel values`);let t=1/0,n=-1/0;for(let r of e){let e=r.getTime();t=Math.min(t,e),n=Math.max(n,e)}if(!Number.isFinite(t)||!Number.isFinite(n))throw TypeError(`A temporal scale factory requires Date channel values`);if(t===n){let e=432e5;t-=e,n+=e}return[new Date(t),new Date(n)]}let i=1/0,a=-1/0;for(let e of r){if(!ym(e))throw TypeError(`A quantitative scale factory requires numeric values`);i=Math.min(i,e),a=Math.max(a,e)}if(!Number.isFinite(i)||!Number.isFinite(a))throw TypeError(`A quantitative scale factory requires numeric values`);let o=om(e);if(n){if(o)throw TypeError(`An inferred log scale cannot include an implicit zero baseline`);i=Math.min(0,i),a=Math.max(0,a)}if(sm(e,i,a),i===a){if(i===0)return[0,1];let e=Math.abs(i)*.05||1;i-=e,a+=e}return[i,a]}function om(e){return`base`in e&&typeof e.base==`function`}function sm(e,t,n){if(om(e)&&(t===0||n===0||t<0&&n>0))throw TypeError(`An inferred log domain cannot include or cross zero`)}function cm(e,t,n=5){if(!t)return;let r=e;if(typeof r.nice!=`function`)throw TypeError(`This scale does not support nicening`);r.nice(typeof t==`number`?t:n)}function lm(e,t,n){if(t?.scale){let r=fm(t.scale),i=r?t.scale():t.scale;if(typeof i!=`function`||typeof i.copy!=`function`)throw TypeError(`A color scale must be callable and copyable`);if(r&&(typeof i.domain!=`function`||typeof i.range!=`function`))throw TypeError(`A color scale factory must return a scale with domain and range methods`);let a=i.copy(),o=gm(a);if(r){let n=a;t.range?.length&&n.range(t.range);let r=t.domain??pm(n,e);(t.domain!==void 0||r.length)&&n.domain(r);let i=n.range();if(!i.length||i.some(e=>typeof e!=`string`))throw TypeError(`A color-scale factory requires a string range`)}if(t.nice){let e=a.nice;if(typeof e!=`function`)throw TypeError(`This color scale does not support nicening`);e.call(a,typeof t.nice==`number`?t.nice:5)}let s=a.domain?.()??t.domain??[],c=(a.range?.()??t.range??n.palette).map(String);return{type:`configured`,kind:o,domain:s,range:c,map:e=>{if(e==null)return c[0]??`currentColor`;let t=a(e);return t==null?`currentColor`:String(t)}}}if(t?.resolver)return t.resolver.resolve({values:e,domain:t.domain,range:t.range,theme:n});let r=t?.range?.length?t.range:n.palette,i=um(t?.domain??e),a=i.map(Q);return{type:`ordinal`,kind:`categorical`,domain:i,range:r,map:e=>{if(e==null)return r[0]??`currentColor`;let t=a.indexOf(Q(e));return t<0&&(t=a.push(Q(e))-1),r[t%r.length]??`currentColor`}}}function um(e){return[...new Set(e.filter(dm))]}function dm(e){return typeof e==`string`||typeof e==`number`}function fm(e){return typeof e==`function`&&!(`copy`in e)}function pm(e,t){let n=t.filter(dm),r=e.quantiles,i=e.thresholds;if(r)return mm(n);if(e.invertExtent&&!i)throw TypeError(`Threshold color-scale factory requires an explicit domain`);if(e.ticks||i){let t=mm(n),r=1/0,a=-1/0;for(let e of t)r=Math.min(r,e),a=Math.max(a,e);if(!Number.isFinite(r)||!Number.isFinite(a))return[];if(sm(e,r,a),r===a){if(r===0)a=1;else{let e=Math.abs(r)*.05||1;r-=e,a+=e}}if(i)return[r,a];let o=Math.max(2,e.domain().length,e.range().length);return Array.from({length:o},(e,t)=>r+(a-r)*t/(o-1))}return um(n)}function mm(e){let t=e.filter(e=>typeof e==`number`&&Number.isFinite(e));return t.length!==e.length&&hm(),t}function hm(){throw TypeError(`A quantitative color-scale factory requires numeric values`)}function gm(e){return e.quantiles?e.invertExtent?`quantile`:`continuous`:e.thresholds?`quantize`:e.invertExtent?`threshold`:e.ticks?`continuous`:`categorical`}function Q(e){return e instanceof Date?`date:${e.getTime()}`:typeof e==`string`?`string:${e.length}:${e}`:`${typeof e}:${String(e)}`}var _m=new WeakSet;function vm(e){return typeof e==`string`||e instanceof Date&&Number.isFinite(e.getTime())||ym(e)}function ym(e){return typeof e==`number`&&Number.isFinite(e)}function bm(e,t,n){return{initialize:r=>{let i=Cm(e(r)),a=t===void 0||i.motion!==void 0?i:{...i,motion:t};return n===void 0?a:xm(a,n)},...t===void 0?{}:{motion:t},...n===void 0?{}:{renderer:n}}}function xm(e,t){let n=e.render,r=e.resolveLayout;return{...e,render:e=>Sm(n(e),t),...r?{resolveLayout(e){let n=r(e);return{...n,render:e=>Sm(n.render(e),t)}}}:{}}}function Sm(e,t){return{...e,nodes:e.nodes.map(e=>({...e,renderer:t})),...e.focusGuides?{focusGuides:e.focusGuides.map(e=>({...e,renderer:t}))}:{}}}function Cm(e){return typeof e.render==`function`?e:{...e,render:()=>{throw TypeError(`Mark "${e.id}" must resolve its layout before rendering`)}}}function wm(e,t){return t?.length?{data:e,definitions:t}:void 0}function Tm(e,t,n,r,i){return typeof e==`function`?e(t,{index:n,data:r}):e??i}function Em(e,t,n){return typeof t==`function`?e.map((n,r)=>t(n,{index:r,data:e})):t===void 0?e.map((t,r)=>n(t,{index:r,data:e})):e.map(e=>typeof e==`object`&&e?e[t]:void 0)}function Dm(e,t,n={}){if(t!==void 0)return Em(e,t,(e,{index:t})=>t);let r=[e.map(e=>typeof e==`object`&&e?e.id:void 0),e.map(e=>{if(typeof e!=`object`||!e)return;let t=e.data;return typeof t==`object`&&t?t.id:void 0}),...n.candidates??[]];for(let t of r){if(t.length!==e.length)continue;let r=t.map(Om);if(r.every(e=>e!==void 0)&&km(r,n.groups))return r}return Am(n.markId,n.candidates,n.warningIdentity),e.map((e,t)=>t)}function Om(e){if(dm(e))return e;if(e instanceof Date&&Number.isFinite(e.getTime()))return`date:${e.getTime()}`}function km(e,t){let n=new Set;for(let r=0;r<e.length;r+=1){let i=JSON.stringify([Q(t?.[r]??null),Q(e[r])]);if(n.has(i))return!1;n.add(i)}return!0}function Am(e,t,n){e&&t?.length&&n&&_m.has(n)}function jm(e){return function(){return e}}Array.prototype.slice;function Mm(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Nm(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n<o;++n)for(i=a,a=e[t[n]],r=0;r<s;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Pm(e){for(var t=e.length,n=Array(t);--t>=0;)n[t]=t;return n}function Fm(e,t){return e[t]}function Im(e){let t=[];return t.key=e,t}function Lm(){var e=jm([]),t=Pm,n=Nm,r=Fm;function i(i){var a=Array.from(e.apply(this,arguments),Im),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o<s;++o)(a[o][c]=[0,+r(e,a[o].key,c,i)]).data=e;for(o=0,l=Mm(t(a));o<s;++o)a[l[o]].index=o;return n(a,l),a}return i.keys=function(t){return arguments.length?(e=typeof t==`function`?t:jm(Array.from(t)),i):e},i.value=function(e){return arguments.length?(r=typeof e==`function`?e:jm(+e),i):r},i.order=function(e){return arguments.length?(t=e==null?Pm:typeof e==`function`?e:jm(Array.from(e)),i):t},i.offset=function(e){return arguments.length?(n=e??Nm,i):n},i}function Rm(e,t){if((r=e.length)>0){for(var n,r,i=0,a=e[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=e[n][i][1]||0;if(o)for(n=0;n<r;++n)e[n][i][1]/=o}Nm(e,t)}}function zm(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,a=r.length;n<a;++n){for(var o=0,s=0;o<i;++o)s+=e[o][n][1]||0;r[n][1]+=r[n][0]=-s/2}Nm(e,t)}}function Bm(e,t){if((o=e.length)>0&&(a=(i=e[t[0]]).length)>0){for(var n=0,r=1,i,a,o;r<a;++r){for(var s=0,c=0,l=0;s<o;++s){for(var u=e[t[s]],d=u[r][1]||0,f=(d-(u[r-1][1]||0))/2,p=0;p<s;++p){var m=e[t[p]],h=m[r][1]||0,g=m[r-1][1]||0;f+=h-g}c+=d,l+=f*d}i[r-1][1]+=i[r-1][0]=n,c&&(n-=l/c)}i[r-1][1]+=i[r-1][0]=n,Nm(e,t)}}function Vm(e){var t=e.map(Hm);return Pm(e).sort(function(e,n){return t[e]-t[n]})}function Hm(e){for(var t=-1,n=0,r=e.length,i,a=-1/0;++t<r;)(i=+e[t][1])>a&&(a=i,n=t);return n}function Um(e){for(var t=0,n=-1,r=e.length,i;++n<r;)(i=+e[n][1])&&(t+=i);return t}function Wm(e){var t=e.length,n,r,i=e.map(Um),a=Vm(e),o=0,s=0,c=[],l=[];for(n=0;n<t;++n)r=a[n],o<s?(o+=i[r],c.push(r)):(s+=i[r],l.push(r));return l.reverse().concat(c)}function Gm(e,t={}){let n=qm(t);if(e.length===0)return new Map;let r=[],i=new Map,a=[],o=new Set;for(let t of e){let e=Q(t.position);i.has(e)||(i.set(e,r.length),r.push(t.position));let n=Q(t.series);o.has(n)||(o.add(n),a.push(t.series))}let s=r.map(()=>Object.create(null)),c=new Map;for(let t of e){let e=i.get(Q(t.position)),n=Q(t.series),r=`${e}:${n}`;if(c.has(r))throw TypeError(`A stack requires at most one value for each position and series; duplicate ${String(t.position)} / ${String(t.series)}`);c.set(r,t.index),s[e][n]=t.value}let l=t.order===`inside-out`;if(n!==void 0&&e.some(({value:e})=>e<0))throw TypeError(`A stack anchor requires nonnegative values`);let u=eh(e,a,t.order);t.reverse&&!l&&u.reverse();let d=u.map(Q),f=t.anchor?Nm:t.offset===`normalize`?Rm:t.offset===`center`?zm:t.offset===`wiggle`?Bm:Km,p=Lm().keys(d).value((e,t)=>e[t]??0).offset(f);l&&p.order(t.reverse?e=>Wm(e).reverse():Wm);let m=p(s);t.anchor&&n!==void 0&&Jm(m,t.anchor.series,n),t.offset===`wiggle`&&Ym(m);let h=new Map;return m.forEach(e=>{let t=e.key;e.forEach((e,n)=>{let r=c.get(`${n}:${t}`);r!==void 0&&h.set(r,{start:e[0],end:e[1]})})}),h}function Km(e,t){if(e.length===0)return;let n=e.map(e=>{let t=!1,n=!1;for(let[r,i]of e){let e=i-r;e<0?t=!0:e>0&&(n=!0)}return t&&!n}),r=e[t[0]].length;for(let i=0;i<r;i+=1){let r=0,a=0;for(let o of t){let t=e[o][i],s=t[1]-t[0];s>0?(t[0]=r,t[1]=r+=s):s<0?(t[1]=a,t[0]=a+=s):s===0?t[0]=t[1]=n[o]?a:r:(t[0]=0,t[1]=s)}}}function qm(e){let t=e.anchor;if(!t)return;if(e.offset!==void 0&&e.offset!==`diverging`)throw TypeError(`A stack anchor can only be used with the diverging offset`);let n=t.fraction??.5;if(!Number.isFinite(n)||n<0||n>1)throw TypeError(`A stack anchor fraction must be between zero and one`);return n}function Jm(e,t,n){let r=Q(t),i=e.find(e=>e.key===r);if(!i)throw TypeError(`Stack anchor series "${String(t)}" is not in the resolved series order`);i.forEach((t,r)=>{let i=t[0]+(t[1]-t[0])*n;for(let t of e){let e=t[r];e&&(e[0]-=i,e[1]-=i)}})}function Ym(e){let t=1/0;for(let n of e)for(let e of n)t=Math.min(t,e[0]);if(Number.isFinite(t)&&t!==0)for(let n of e)for(let e of n)e[0]-=t,e[1]-=t}function Xm(e,t,n,r={},i=`value`){let a=[];for(let r=0;r<e.length;r+=1){let o=e[r],s=t[r];if(!Qm(o)||!$m(s))continue;let c=n[r];a.push({index:r,position:o,value:s,series:Zm(c)?c:i===`index`?r:`value`})}let o=Gm(a,r),s=Array.from({length:e.length},()=>void 0),c=Array.from({length:e.length},()=>void 0);for(let[e,t]of o)s[e]=t.start,c[e]=t.end;return{starts:s,ends:c}}function Zm(e){return typeof e==`string`||typeof e==`number`}function Qm(e){return typeof e==`string`||$m(e)||e instanceof Date&&Number.isFinite(e.getTime())}function $m(e){return typeof e==`number`&&Number.isFinite(e)}function eh(e,t,n){if(Array.isArray(n)){let e=[...n],r=new Set(e.map(Q));return[...e,...t.filter(e=>!r.has(Q(e)))]}if(n!==`ascending`&&n!==`descending`)return[...t];let r=new Map(t.map(e=>[Q(e),0]));for(let t of e){let e=Q(t.series);r.set(e,(r.get(e)??0)+Math.abs(t.value))}return[...t].sort((e,t)=>{let i=(r.get(Q(e))??0)-(r.get(Q(t))??0);return n===`ascending`?i:-i})}function th(e,t){let n=rm(e,{values:t.values,includeZero:t.includeZero,nice:t.options?.nice,niceCount:t.tickCount}),r=oh(n.domain()),i=nh(n,t,r),a=n.bandwidth!==void 0,o=a&&t.channel===`y`?[Math.min(...t.range),Math.max(...t.range)]:t.range,s=t.options?.reverse?[o[1],o[0]]:o;n.range(s);let c=oh(n.domain());if(i&&(!ih(c,i.domain)||!ah(n,i.domain,s)))throw TypeError(`Chart viewport "${t.id}" requires independent configurable domain and range capabilities`);let l=t.options?.axis===!1?void 0:t.options?.axis?.ticks,u=l===!1?void 0:l,d=u?.values??n.ticks?.(t.tickCount)??c,f=n.tickFormat?.(t.tickCount),p=n.bandwidth?.()??0,m=e=>{let t=n(e);return t===void 0?NaN:t+p/2},h=n.invert?e=>n.invert(e-p/2):void 0;return{id:t.id,type:a?`band`:`configured`,domain:c,map:m,...h?{invert:h}:{},ticks:d.map(e=>({value:e,position:m(e),label:u?.format?.(e)??f?.(e)??mh(e)})),bandwidth:p,...i?{viewport:{contentDomain:r,domain:i.domain,translate:i.translate,map:e=>m(e)+i.translate}}:{}}}function nh(e,t,n){let r=t.options?.viewport;if(!r)return;let i=e;if(e.bandwidth!==void 0||typeof e.ticks!=`function`||typeof i.invert!=`function`)throw TypeError(`Chart viewport "${t.id}" requires a continuous numeric or temporal scale`);if(typeof i.clamp==`function`&&i.clamp()===!0)throw TypeError(`Chart viewport "${t.id}" does not support a clamped scale`);let a=r.domain;(a.length!==2||!uh(a[0],a[1]))&&ph(t.id);let o=dh(a[0]),s=dh(a[1]);(!Number.isFinite(o)||!Number.isFinite(s)||o===s)&&ph(t.id),ch(e,t.id,n,a);let c=r.translate??0;if(!Number.isFinite(c))throw TypeError(`Chart viewport "${t.id}" translate must be a finite number`);ih(e.domain(),a)&&rh(e,[a[1],a[0]],t.id),rh(e,a,t.id);let l=oh(e.domain());return(l.length!==2||!uh(l[0],l[1]))&&sh(t.id),{domain:l,translate:c}}function rh(e,t,n){let r=e.domain;try{r.call(e,[...t])}catch{sh(n)}ih(e.domain(),t)||sh(n)}function ih(e,t){return e.length===t.length&&e.every((e,n)=>fh(e,t[n]))}function ah(e,t,n){let r=e(t[0]),i=e(t[1]);return r!==void 0&&i!==void 0&&Number.isFinite(r)&&Number.isFinite(i)&&Math.abs(r-n[0])<=1e-6&&Math.abs(i-n[1])<=1e-6}function oh(e){return e.map(e=>e instanceof Date?new Date(e.getTime()):e)}function sh(e){throw TypeError(`Chart viewport "${e}" requires a scale with a configurable domain`)}function ch(e,t,n,r){if(!om(e))return;let i=lh(n),a=lh(r);if(i===void 0||a===void 0||i!==a)throw TypeError(`Chart viewport "${t}" logarithmic content and viewport domains must be finite, nonzero, and stay on the same side of zero`)}function lh(e){let t;for(let n of e){if(typeof n!=`number`||!Number.isFinite(n)||n===0)return;let e=Math.sign(n);if(t!==void 0&&e!==t)return;t=e}return t}function uh(e,t){return typeof e==`number`&&typeof t==`number`||e instanceof Date&&t instanceof Date}function dh(e){return e instanceof Date?e.getTime():e}function fh(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function ph(e){throw TypeError(`Chart viewport "${e}" domain must contain two distinct finite numbers or Dates`)}function mh(e){return e instanceof Date?e.toLocaleDateString():String(e)}var hh=16,gh=400,_h={fontFamily:`sans-serif`,fontStyle:`normal`,fontStretch:`normal`,letterSpacing:0,direction:`inherit`,fontScale:1};function vh(e,t){if(e===`middle`)return`middle`;let n=t!==`rtl`;return e===`left`?n?`start`:`end`:n?`end`:`start`}function yh(e,t,n){return t===`middle`?-e/2:t===`start`==(n!==`rtl`)?0:-e}function bh(e,t){let n=kh(t.fontScale,1),r=Dh(t.fontSize,hh)*n,i=Dh(t.fontWeight,gh),a=Oh(t.letterSpacing,0)*n;if(!e||r===0)return{x:0,y:0,width:0,height:0};let o=0;for(let t of e)o+=Eh(t);let s=1+(Math.min(900,Math.max(100,i))-400)/12500,c=Math.max(0,o*r*s+Math.max(0,Array.from(e).length-1)*a),l=r;return{x:yh(c,t.anchor,t.direction),y:t.baseline===`middle`?-l/2:t.baseline===`hanging`?0:-r*.8,width:c,height:l}}function xh(e,t=bh){let n=Dh(e.fontSize,hh),r=e.anchor??`start`,i=e.baseline??`auto`,a=e.text.length===0?{x:0,y:0,width:0,height:0}:t(e.text,{fontSize:n,fontWeight:e.fontWeight,..._h,anchor:r,baseline:i}),o=Oh(a.x,0),s=Oh(a.y,0),c=Dh(a.width,0),l=Dh(a.height,0),u={x:e.x+o,y:e.y+s,width:c,height:l};return e.rotate?Th(u,e.x,e.y,e.rotate):u}function Sh(e=bh,t={}){let n={..._h,...t,fontFamily:t.fontFamily||_h.fontFamily,fontStyle:t.fontStyle||_h.fontStyle,fontStretch:t.fontStretch||_h.fontStretch,letterSpacing:Oh(t.letterSpacing,0),fontScale:kh(t.fontScale,1)};return(t,r)=>e(t,{...r,...n})}function Ch(e,t,n){wh(t,0,0,(t,r,i)=>{let a=t.style;if(!(a?.strokeWidth!==void 0||a?.lineCap!==void 0&&a.lineCap!==`butt`)||a?.stroke===`none`)return;let o=a?.strokeWidth??1;if(!Number.isFinite(o)||o<=0)return;let s=o/2,c=t.x1+r,l=t.x2+r,u=t.y1+i,d=t.y2+i,f=l-c,p=d-u,m=Math.hypot(f,p),h=m>0?f/m:0,g=m>0?p/m:0,_=a?.lineCap&&a.lineCap!==`butt`?s:0,v=Math.abs(g)*s+Math.abs(h)*_,y=Math.abs(h)*s+Math.abs(g)*_,b=Math.min(c,l)-v,x=Math.max(c,l)+v,S=Math.min(u,d)-y,C=Math.max(u,d)+y;e.top=Math.max(e.top,n.y-S),e.right=Math.max(e.right,x-n.x-n.width),e.bottom=Math.max(e.bottom,C-n.y-n.height),e.left=Math.max(e.left,n.x-b)})}function wh(e,t,n,r){if(e.kind===`rule`){r(e,t,n);return}if(e.kind!==`group`)return;let i=t+(e.translateX??0),a=n+(e.translateY??0);for(let t of e.children)wh(t,i,a,r)}function Th(e,t,n,r){let i=r*Math.PI/180,a=Math.cos(i),o=Math.sin(i),s=e.x+e.width/2-t,c=e.y+e.height/2-n,l=Math.abs(e.width*a)+Math.abs(e.height*o),u=Math.abs(e.width*o)+Math.abs(e.height*a),d=s*a-c*o+t,f=s*o+c*a+n;return{x:d-l/2,y:f-u/2,width:l,height:u}}function Eh(e){return/\s/u.test(e)?.33:/[\u0300-\u036f]/u.test(e)?0:/[ilI1|!.,:;'`]/u.test(e)?.28:/[mwMW@#%&]/u.test(e)?.9:/[A-Z]/u.test(e)?.64:/[0-9]/u.test(e)?.56:e.codePointAt(0)>127?1:.54}function Dh(e,t){return e!==void 0&&Number.isFinite(e)&&e>=0?e:t}function Oh(e,t){return e!==void 0&&Number.isFinite(e)?e:t}function kh(e,t){return e!==void 0&&Number.isFinite(e)&&e>0?e:t}function Ah(e,t,n){let[r,i,a,o]=e??[0,0,0,0],s=[Mh(r),Mh(i),Mh(a),Mh(o)],c=Nh(t),l=Nh(n),u=Math.min(1,Ph(c,s[0]+s[1]),Ph(c,s[3]+s[2]),Ph(l,s[0]+s[3]),Ph(l,s[1]+s[2]));return u===1?s:[s[0]*u,s[1]*u,s[2]*u,s[3]*u]}function jh(e,t,n,r,i){let a=Fh(e,t,n,r),[o,s,c,l]=Ah(i,a.width,a.height),u=a.x,d=a.y,f=u+a.width,p=d+a.height;return[`M${Ih(u+o)},${Ih(d)}`,`H${Ih(f-s)}`,`A${Ih(s)},${Ih(s)} 0 0 1 ${Ih(f)},${Ih(d+s)}`,`V${Ih(p-c)}`,`A${Ih(c)},${Ih(c)} 0 0 1 ${Ih(f-c)},${Ih(p)}`,`H${Ih(u+l)}`,`A${Ih(l)},${Ih(l)} 0 0 1 ${Ih(u)},${Ih(p-l)}`,`V${Ih(d+o)}`,`A${Ih(o)},${Ih(o)} 0 0 1 ${Ih(u+o)},${Ih(d)}`,`Z`].join(``)}function Mh(e){return Number.isFinite(e)&&e>0?e:0}function Nh(e){return Number.isFinite(e)?Math.abs(e):0}function Ph(e,t){return t===0?1:e/t}function Fh(e,t,n,r){let i=e+n,a=t+r;return{x:Math.min(e,i),y:Math.min(t,a),width:Math.abs(n),height:Math.abs(r)}}function Ih(e){return String(Math.round(e*100)/100)}var Lh=Math.PI*2;function Rh(e,t,n,r,i,a,o){let s=Bh(e,t,n,r),c=s.x,l=s.y,u=c+s.width,d=l+s.height;if(!(a>=c&&a<=u&&o>=l&&o<=d))return!1;let[f,p,m,h]=Ah(i,s.width,s.height);return a<c+f&&o<l+f?Vh(a,o,c+f,l+f,f):a>u-p&&o<l+p?Vh(a,o,u-p,l+p,p):a>u-m&&o>d-m?Vh(a,o,u-m,d-m,m):a<c+h&&o>d-h?Vh(a,o,c+h,d-h,h):!0}function zh(e,t,n,r,i,a,o){if(Rh(e,t,n,r,i,a,o))return 0;let s=Bh(e,t,n,r),c=s.x,l=s.y,u=c+s.width,d=l+s.height,[f,p,m,h]=Ah(i,s.width,s.height);return Math.min(Uh(c+f,l,u-p,l,a,o),Uh(u,l+p,u,d-m,a,o),Uh(u-m,d,c+h,d,a,o),Uh(c,d-h,c,l+f,a,o),Hh(a,o,c+f,l+f,f,Math.PI,Math.PI*1.5),Hh(a,o,u-p,l+p,p,Math.PI*1.5,Lh),Hh(a,o,u-m,d-m,m,0,Math.PI*.5),Hh(a,o,c+h,d-h,h,Math.PI*.5,Math.PI))}function Bh(e,t,n,r){let i=e+n,a=t+r;return{x:Math.min(e,i),y:Math.min(t,a),width:Math.abs(n),height:Math.abs(r)}}function Vh(e,t,n,r,i){let a=e-n,o=t-r;return a*a+o*o<=i*i}function Hh(e,t,n,r,i,a,o){if(i===0)return Wh(e,t,n,r);let s=Math.atan2(t-r,e-n);return s<0&&(s+=Lh),s>=a&&s<=o?(Math.hypot(e-n,t-r)-i)**2:Math.min(Wh(e,t,n+Math.cos(a)*i,r+Math.sin(a)*i),Wh(e,t,n+Math.cos(o)*i,r+Math.sin(o)*i))}function Uh(e,t,n,r,i,a){let o=n-e,s=r-t,c=o*o+s*s;if(c===0)return Wh(i,a,e,t);let l=Math.max(0,Math.min(1,((i-e)*o+(a-t)*s)/c));return Wh(i,a,e+l*o,t+l*s)}function Wh(e,t,n,r){return(e-n)**2+(t-r)**2}var Gh=new WeakMap;function Kh(e,t,n,r){let i,a=1/0;for(let r=e.length;r--;){let o=e[r],s=o.x-t,c=o.y-n,l=s*s+c*c;l<=a&&(i=o,a=l)}return i&&a<=Math.max(0,r)**2?i:null}function qh(e,t,n,r,i=e.points){let a=Yh(e),o=i===e.points?void 0:new Set(i);if(!a.targets.length&&!a.attachedPoints.size)return Kh(i,t,n,r);let s=Jh(e,t,n,i);if(s)return s.point;let c,l,u=1/0,d=1/0;for(let e of a.targets){let r=e.node.interaction;if(!Qh(r,o))continue;let i=r.affinity??`xy`;if(i===`geometry`)continue;let a=i===`x`?`x`:i===`y`?`y`:void 0,s=a?gg(e.bounds,a===`x`?t:n,a):eg(e,t,n);if(s>u)continue;let f=a?eg(e,t,n):s;(s<u||s===u&&f<d)&&(l=r,c=void 0,u=s,d=f)}if(u!==0)for(let e of i){if(a.attachedPoints.has(e))continue;let r=e.x-t,i=e.y-n,o=r*r+i*i;o<u&&(c=e,l=void 0,u=o,d=o)}return u>Math.max(0,r)**2?null:c??(l?Zh(l,t,n,o):void 0)??null}function Jh(e,t,n,r=e.points){let i=Yh(e),a=r===e.points?void 0:new Set(r);for(let e=i.targets.length;e--;){let r=i.targets[e];if(hg(r.bounds,t,n)&&$h(r,t,n)){let e=r.node.interaction,i=Zh(e,t,n,a),o=e.point?!0:e.points.length>0;if(i||!a||!o)return{point:i}}}return null}function Yh(e){let t=Gh.get(e);if(t)return t;let n=[],r=new Set;Xh(e.nodes,0,0,void 0,n,r);let i={targets:n,attachedPoints:r};return Gh.set(e,i),i}function Xh(e,t,n,r,i,a){for(let o of e){if(o.kind===`group`){if(o.focus)continue;let e=t+(o.translateX??0),s=n+(o.translateY??0),c=o.clip?fg(o.clip,e,s):void 0,l=r===null?null:mg(r,c);Xh(o.children,e,s,l,i,a);continue}if(o.kind===`label`||!o.interaction)continue;if(o.interaction.point)a.add(o.interaction.point);else for(let e of o.interaction.points)a.add(e);if(r===null)continue;let e=tg(o);if(!e)continue;let s=fg(e,t,n),c=r?mg(s,r):s;c!=null&&i.push({node:o,offsetX:t,offsetY:n,bounds:c,clip:r})}}function Zh(e,t,n,r){if(e.point)return!r||r.has(e.point)?e.point:null;let i=e.affinity??`xy`,a,o=1/0,s=1/0;for(let c of e.points){if(r&&!r.has(c))continue;let e=c.x-t,l=c.y-n,u=e*e+l*l,d=i===`x`?e*e:i===`y`?l*l:u;(d<o||d===o&&u<s)&&(a=c,o=d,s=u)}return a??null}function Qh(e,t){return t?e.point?t.has(e.point):e.points.some(e=>t.has(e)):!0}function $h(e,t,n){let r=t-e.offsetX,i=n-e.offsetY,{node:a}=e;switch(a.kind){case`rect`:return a.cornerRadii===void 0?ng(a,r,i):Rh(a.x,a.y,a.width,a.height,a.cornerRadii,r,i);case`dot`:{let e=r-a.x,t=i-a.y,n=Math.max(0,a.radius);return e*e+t*t<=n*n}case`area`:return a.polygons===void 0?ig(a.points,r,i):ag(a.polygons,r,i);case`polyline`:return sg(a.points,r,i,!1)<=vg(a)**2;case`rule`:return cg(a.x1,a.y1,a.x2,a.y2,r,i)<=vg(a)**2}}function eg(e,t,n){let r=t-e.offsetX,i=n-e.offsetY,{node:a}=e,o;switch(a.kind){case`rect`:o=a.cornerRadii===void 0?a.radius?rg(a,r,i):_g(a,r,i):zh(a.x,a.y,a.width,a.height,a.cornerRadii,r,i);break;case`dot`:{let e=r-a.x,t=i-a.y,n=Math.max(0,Math.sqrt(e*e+t*t)-Math.max(0,a.radius));o=n*n;break}case`area`:o=a.polygons===void 0?sg(a.points,r,i,!0):og(a.polygons,r,i);break;case`polyline`:{let e=sg(a.points,r,i,!1),t=Math.max(0,Math.sqrt(e)-vg(a));o=t*t;break}case`rule`:{let e=cg(a.x1,a.y1,a.x2,a.y2,r,i),t=Math.max(0,Math.sqrt(e)-vg(a));o=t*t;break}}return e.clip?Math.max(o,_g(e.clip,t,n)):o}function tg(e){switch(e.kind){case`rect`:return dg(e);case`dot`:{let t=Math.max(0,e.radius);return{x:e.x-t,y:e.y-t,width:t*2,height:t*2}}case`area`:return e.polygons===void 0?lg(e.points):ug(e.polygons);case`polyline`:{let t=lg(e.points);return t?pg(t,vg(e)):null}case`rule`:return pg({x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)},vg(e))}}function ng(e,t,n){let r=dg(e);if(!hg(r,t,n))return!1;let i=Math.max(0,Math.min(e.radius??0,r.width/2,r.height/2));if(i===0||t>=r.x+i&&t<=r.x+r.width-i||n>=r.y+i&&n<=r.y+r.height-i)return!0;let a=t<r.x+i?r.x+i:r.x+r.width-i,o=n<r.y+i?r.y+i:r.y+r.height-i,s=t-a,c=n-o;return s*s+c*c<=i*i}function rg(e,t,n){let r=dg(e),i=r.width/2,a=r.height/2,o=Math.max(0,Math.min(e.radius??0,i,a)),s=Math.abs(t-(r.x+i))-(i-o),c=Math.abs(n-(r.y+a))-(a-o),l=Math.sqrt(Math.max(0,s)**2+Math.max(0,c)**2)-o;return Math.max(0,l)**2}function ig(e,t,n){let r=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){let o=e[i],s=e[a];o[1]>n!=s[1]>n&&t<(s[0]-o[0])*(n-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}return r}function ag(e,t,n){return e.some(([e,...r])=>!e||!ig(e,t,n)?!1:!r.some(e=>ig(e,t,n)))}function og(e,t,n){let r=1/0;for(let i of e)for(let e of i)r=Math.min(r,sg(e,t,n,!0));return r}function sg(e,t,n,r){if(!e.length)return 1/0;if(e.length===1){let r=e[0];return(r[0]-t)**2+(r[1]-n)**2}let i=1/0,a=r?e.length:Math.max(0,e.length-1);for(let r=0;r<a;r+=1){let a=e[r],o=e[(r+1)%e.length];i=Math.min(i,cg(a[0],a[1],o[0],o[1],t,n))}return i}function cg(e,t,n,r,i,a){let o=n-e,s=r-t,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((i-e)*o+(a-t)*s)/c)):0,u=i-(e+l*o),d=a-(t+l*s);return u*u+d*d}function lg(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)Number.isFinite(a[0])&&Number.isFinite(a[1])&&(t=Math.min(t,a[0]),n=Math.min(n,a[1]),r=Math.max(r,a[0]),i=Math.max(i,a[1]));return Number.isFinite(t)?{x:t,y:n,width:r-t,height:i-n}:null}function ug(e){return lg(e.flatMap(e=>e.flat()))}function dg(e){return{x:Math.min(e.x,e.x+e.width),y:Math.min(e.y,e.y+e.height),width:Math.abs(e.width),height:Math.abs(e.height)}}function fg(e,t,n){let r=dg(e);return{...r,x:r.x+t,y:r.y+n}}function pg(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function mg(e,t){if(!e)return t;if(!t)return e;let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i<n||a<r?null:{x:n,y:r,width:i-n,height:a-r}}function hg(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function gg(e,t,n){let r=n===`x`?e.x:e.y,i=n===`x`?e.width:e.height,a=t<r?r-t:t>r+i?t-r-i:0;return a*a}function _g(e,t,n){let r=dg(e),i=t<r.x?r.x-t:t>r.x+r.width?t-r.x-r.width:0,a=n<r.y?r.y-n:n>r.y+r.height?n-r.y-r.height:0;return i*i+a*a}function vg(e){return Math.max(0,e.style?.strokeWidth??1)/2}var yg=new WeakMap;function bg(e,t,n){let r=yg.get(e);r?r[t]=n:yg.set(e,{[t]:n})}function xg(e,t){return yg.get(e)?.[t]??e[t]}var Sg=Symbol();function Cg(e,t){return e===`x`||e===`y`?e:t[Sg]}function wg(e,t){return[`x`,`y`].some(n=>(e.scales[n]?.viewport?.translate??0)!==(t.scales[n]?.viewport?.translate??0))}function Tg(e,t){return e.map(e=>e.kind===`group`?{...e,children:Tg(e.children,t),...e.focus?{focus:{...e.focus,points:e.focus.points.map(t)}}:{},...e.states?{states:{...e.states,points:e.states.points.map(t)}}:{}}:e.kind===`label`||!e.interaction?e:{...e,interaction:e.interaction.point?{...e.interaction,point:t(e.interaction.point)}:{...e.interaction,points:e.interaction.points.map(t)}})}var Eg=Symbol(`chart-scene-source`),Dg=Symbol(`default-focus-layer`);function Og(e){return e.focus&&Object.assign(e.focus,{[Dg]:!0}),e}function kg(e){return e.focus?.[Dg]===!0}var Ag={foreground:`currentColor`,muted:`currentColor`,grid:`currentColor`,background:`transparent`,palette:[`var(--ts-chart-1, #2563eb)`,`var(--ts-chart-2, #f97316)`,`var(--ts-chart-3, #10b981)`,`var(--ts-chart-4, #8b5cf6)`,`var(--ts-chart-5, #ec4899)`,`var(--ts-chart-6, #06b6d4)`]};function jg(e,t){return t?typeof e==`function`?{chart:e,...t}:{...e,...t}:typeof e==`function`?{chart:e}:e}function Mg(e,t,n={}){return Pg(e,t,e=>{if(!e.options?.scale)throw TypeError(`Chart scale "${e.id}" requires a configured scale`);return Ng(e.options.scale,e)},n)}function Ng(e,t){if(typeof e==`function`)return th(e,t);if(t.options?.viewport)throw TypeError(`Chart viewport "${t.id}" requires a configured or inferable continuous scale`);return e.resolve(t)}function Pg(e,t,n,r){let i=w_(t.width),a=w_(t.height),o={...r,measureText:Sh(r.measureText,r.typography)},s={...Ag,...o.defaultTheme,palette:o.defaultTheme?.palette??Ag.palette},c={...s,...e.theme,palette:e.theme?.palette??s.palette},l=e.marks.map((e,t)=>e.initialize({markIndex:t})),{margin:u,chart:d,scales:f,axes:p,marks:m,colors:h,legend:g,legendBounds:_,positionScales:v,scaleGuides:y,gridScales:b}=Yg(e,l,i,a,c,Gg(e,Wg(l)),n,o),x=[],S=[],C=[],w=[],T=m.findIndex(e=>!e.focus&&!e.focusGuideOnly);m.forEach((e,t)=>{let n=Ig(e,`x`,v,f),r=Ig(e,`y`,v,f),s=n!==void 0,l=r!==void 0,u=new Map,p=t=>{let i=u.get(t);if(i)return i;let a=s||l?{...t,x:t.x+(n??0),y:t.y+(r??0)}:t;return Fg(a,e,f,n,r),u.set(t,a),a},m=e.render({markIndex:t,surface:{x:0,y:0,width:i,height:a},chart:d,scales:f,theme:c,color:h.map,colors:h,layout:o});g?.filterMark&&(m=g.filterMark(m,{seriesFromColor:e.seriesFromColor})),e.postDomain&&(m=e.postDomain(m));let _=Hg(m.nodes,m.points),y=s||l?Tg(m.nodes,p):m.nodes,b=_.map(p),E=[],D=T<0||t<T?`under`:`over`;for(let e of m.focusGuides??[])w.push({...e,placement:e.placement??D});if(e.focus){let t=e.focus.retarget===!0;E.push({kind:`group`,key:`focus:${e.id}`,className:`ts-chart__focus-layer`,ariaHidden:!0,focus:{markId:e.id,match:e.focus.match??`primary`,anchors:m.focusAnchors??_,points:b,placement:D,...t?{retarget:!0,candidates:y}:{}},children:t?[]:y})}else{let t=b;if(e.states)E.push({kind:`group`,key:`states:${e.id}`,children:y,states:{data:e.states.data,definitions:e.states.definitions,points:t}});else for(let e of y)E.push(e);for(let e of t)C.push(e);t.length&&S.push({markId:e.id,points:t,clipped:s||l})}x.push({key:e.id,nodes:E,translateX:n,translateY:r})});let E=Rg(x,d),D=[{kind:`group`,key:`marks`,className:`ts-chart__marks`,clip:e.clip?d:void 0,children:E}];b.length&&D.unshift(l_(d,b,c)),y.length&&D.push(p);let O=[],k=new Set;for(let t of e.controls??[]){if(!t.id.trim())throw TypeError(`Chart control ids must be nonempty`);if(k.has(t.id))throw TypeError(`Duplicate chart control id "${t.id}"`);k.add(t.id);let e=t.resolve({chart:d,scales:f,colors:h,theme:c,width:i,height:a});e.nodes&&D.push(...e.nodes),e.controls&&O.push(...e.controls)}if(g&&_){let e={colors:h,chart:d,bounds:_,theme:c,layout:o,width:i,height:a,direction:o.typography?.direction};D.push(g.render(e)),g.control&&O.push(g.control(e))}let A=new Set;for(let e of O){let t=`${e.extension.id}:${e.key}`;if(A.has(t))throw TypeError(`Duplicate chart host control "${t}"`);A.add(t)}let j=e.focusRing??c.focusRing;if(e.focus!==!1&&j!==!1&&C.length){let e=typeof j==`object`?j:void 0,t=o_(e?.radius,5),n=e?.fill??`var(--ts-chart-focus-fill, Canvas)`,r=e?.stroke,i=o_(e?.strokeWidth,2.5);for(let e of S)D.push(Og({kind:`group`,key:`default-focus:${e.markId}`,className:`ts-chart__focus-layer ts-chart__focus-layer--default`,ariaHidden:!0,clip:e.clipped?d:void 0,focus:{match:`primary`,anchors:e.points,points:e.points,placement:`over`},children:e.points.map(e=>({kind:`dot`,key:e.key,x:e.x,y:e.y,radius:t,style:{fill:n,stroke:r??e.color,strokeWidth:i}}))}))}return{width:i,height:a,margin:u,chart:d,nodes:D,points:C,scales:f,colors:h,gradients:e.gradients??[],theme:c,...o.typography?.direction===void 0?{}:{direction:o.typography.direction},...O.length?{controls:O}:{},...w.length?{focusGuides:w}:{},[Eg]:[e,l]}}function Fg(e,t,n,r,i){a(`x`,e.xValue,e.x,r),a(`y`,e.yValue,e.y,i);function a(r,i,a,o){let s=t.channels[r]?.scale,c=s===void 0?void 0:n[s];if(!c||c.type===`none`)return;let l=c.map(i)+(o??0);Number.isFinite(l)&&l!==a&&bg(e,r,l)}}function Ig(e,t,n,r){let i=e.viewport?.[t];if(i!==`fixed`){for(let r of n)if(r.channel===t&&r.scale.viewport&&Object.values(e.channels).some(e=>e.scale===r.id))return r.scale.viewport.translate;return i===`content`?r[t]?.viewport?.translate:void 0}}function Lg(e,t){return[`x`,`y`].some(n=>t.some(t=>t.channel===n&&t.scale.viewport&&e.viewport?.[n]!==`fixed`&&(e.viewport?.[n]===`content`||Object.values(e.channels).some(e=>e.scale===t.id))))}function Rg(e,t){return e.flatMap(e=>e.translateX===void 0&&e.translateY===void 0?[...e.nodes]:[{kind:`group`,key:`viewport-clip:${e.key}`,className:`ts-chart__viewport-clip`,clip:t,children:[{kind:`group`,key:`viewport-content:${e.key}`,className:`ts-chart__viewport-content`,...e.translateX===void 0?{}:{translateX:e.translateX},...e.translateY===void 0?{}:{translateY:e.translateY},children:e.nodes}]}])}function zg(e,t,n,r=1/0,i=e.points){return qh(e,t,n,r,i)}function Bg(e,t=e.points){if(!Object.values(e.scales).some(e=>e.viewport))return t;let{x:n,y:r,width:i,height:a}=e.chart,o=n+i,s=r+a,c=t.filter(t=>!Vg(e,t)||t.x>=n&&t.x<=o&&t.y>=r&&t.y<=s);return c.length===t.length?t:c}function Vg(e,t){let n=e[Eg]?.[1].find(e=>e.id===t.markId);return!n||[`x`,`y`].some(t=>{let r=n.viewport?.[t];return r===`fixed`?!1:r===`content`&&e.scales[t]?.viewport?!0:Object.entries(n.channels).some(([n,r])=>n===t&&r.scale!==void 0&&e.scales[r.scale]?.viewport!==void 0)})}function Hg(e,t){let n=t?[...t]:[],r=new Set(n),i=e=>{for(let t of e){if(t.kind===`group`){t.focus||i(t.children);continue}if(t.kind===`label`||!t.interaction)continue;let e=t.interaction;if(e.point)r.has(e.point)||(r.add(e.point),n.push(e.point));else for(let t of e.points)r.has(t)||(r.add(t),n.push(t))}};return i(e),n}function Ug(e,t){let n=[],r=!1,i=!1;for(let a of e)for(let e of Object.values(a.channels))if(e.scale===t){i=!0;for(let t of e.values)n.push(t);r||=e.includeZero??!1}return{values:n,includeZero:r,materialized:i}}function Wg(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.channels)){let i=r.scale;if(i===void 0)continue;let a=Cg(e,r);if(i===`color`){if(a)throw TypeError(`Position scales cannot use reserved ID "color"`);continue}let o=t.get(i)??{values:[],includeZero:!1,materialized:!1};if(a&&o.channel&&o.channel!==a)throw TypeError(`Chart scale "${i}" cannot materialize both x and y channels`);o.channel??=a,o.materialized||=!n.focusGuideOnly,o.includeZero||=r.includeZero??!1;for(let e of r.values)o.values.push(e);t.set(i,o)}return t}function Gg(e,t){let n=e.scales;if(!n||!Object.hasOwn(n,`x`)||!Object.hasOwn(n,`y`))throw TypeError("Chart scales must define reserved `x` and `y` entries");for(let e of t.keys())if(!Object.hasOwn(n,e))throw TypeError(`Chart scale "${e}" is used by a mark but is not configured`);return Object.entries(n).map(([e,n])=>{if(e===`color`)throw TypeError(`Position scales cannot use reserved ID "color"`);let r=t.get(e)??{values:[],includeZero:!1,materialized:!1},i=e===`x`||e===`y`?e:void 0,a=n?.channel;if(!i&&n!==null&&!a)throw TypeError(`Named chart scale "${e}" requires channel: "x" or channel: "y"`);let o=i??a??r.channel??`x`;if(a&&a!==o||r.channel&&r.channel!==o)throw TypeError(`Chart scale "${e}" is configured for ${o} but is used as ${r.channel??a}`);let s=n?.side??(o===`x`?`bottom`:`left`);if(o===`x`&&s!==`top`&&s!==`bottom`||o===`y`&&s!==`left`&&s!==`right`)throw TypeError(`Chart scale "${e}" uses ${o} and cannot render an axis on the ${s} side`);return{id:e,channel:o,side:s,options:n,channels:r}})}var Kg=4,qg=4,Jg=.25;function Yg(e,t,n,r,i,a,o,s){let c=t_(e.margin),l=r_(s_(e.guides!==!1&&a.some(Xg)?Kg:0),c),u=l;for(let e=0;e<qg;e+=1){let e=p(l),t=m(e);if(u=r_(t,c,u),i_(l,t))return e;l=t}let d=p(u),f=r_(m(d),c,u);return i_(u,f)||(d=p(f)),d;function p(c){let l={x:c.left,y:c.top,width:Math.max(1,n-c.left-c.right),height:Math.max(1,r-c.top-c.bottom)},u={},d=[];for(let e of a){let{id:t,channel:n,options:r,channels:i}=e,a=p_(r,n===`x`?l.width:l.height,n===`x`?92:48,n===`x`?8:7),s=n===`x`?[l.x,l.x+l.width]:[l.y+l.height,l.y],c=r==null?c_(t,i.materialized,r):o({id:t,channel:n,values:i.values,range:s,options:r,tickCount:a,includeZero:i.includeZero});u[t]=c,d.push({...e,scale:c})}let f=Qg(t,{chart:l,scales:u,theme:i,layout:s}),p=lm(Ug(f,`color`).values,e.color,i);if(p.kind!==`categorical`&&f.some(e=>e.seriesFromColor))throw TypeError(`A continuous color channel cannot infer series identity; supply z explicitly`);let m=p.domain.length?e.color?.legend:void 0;if(m?.seriesVisible&&p.kind!==`categorical`)throw TypeError(`An interactive color legend requires a categorical color scale`);let h=m?.height(p.domain.length,{colors:p,chart:l,bounds:{x:l.x,y:0,width:l.width,height:0},theme:i,layout:s,width:n,height:r,direction:s.typography?.direction}),g=m&&h!==void 0?{x:l.x,y:m.placement===`bottom`?r-h:0,width:l.width,height:h}:void 0,_=e.guides===!1?[]:d.filter(Xg),v=e.guides===!1?[]:d.filter(Zg),y=u_(l,_,i,n,s.measureText,s.typography?.direction===`rtl`);return v.length&&Ch(y.margin,l_(l,v,i),l),{margin:c,chart:l,scales:u,axes:y.axes,positionScales:d,scaleGuides:_,gridScales:v,guideMargin:y.margin,marks:f,colors:p,legend:m,legendBounds:g}}function m(t){let a=t.guideMargin;if(t.legend){let e=t.legend.height(t.colors.domain.length,{colors:t.colors,chart:t.chart,bounds:{x:t.chart.x,y:0,width:t.chart.width,height:0},theme:i,layout:s,width:n,height:r,direction:s.typography?.direction});t.legend.placement===`bottom`?c.bottom===void 0&&(a.bottom+=e):c.top===void 0&&(a.top=Math.max(a.top,e))}return e.clip||t.marks.forEach((e,o)=>{if(Lg(e,t.positionScales))return;let c=e.layoutLabels?.({markIndex:o,surface:{x:0,y:0,width:n,height:r},chart:t.chart,scales:t.scales,theme:i,color:t.colors.map,colors:t.colors,layout:s});for(let e of c??[])$g(a,t.chart,e,s.measureText)}),r_(a,c)}}function Xg(e){return e.options!=null&&e.options.axis!==!1}function Zg(e){return e.options!=null&&!!e.options.grid}function Qg(e,t){return e.map((e,n)=>{if(typeof e.resolveLayout!=`function`)return e;let r=e.resolveLayout({...t,markIndex:n});return{id:e.id,channels:r.channels??e.channels,viewport:e.viewport,focusGuideOnly:e.focusGuideOnly,seriesFromColor:e.seriesFromColor,focus:e.focus,states:r.states??e.states,postDomain:r.postDomain??e.postDomain,layoutLabels:r.layoutLabels??e.layoutLabels,render:r.render}})}function $g(e,t,n,r){let i=xh(n,r);return n.text&&e_(e,t,i),i}function e_(e,t,n){e.top=Math.max(e.top,t.y-n.y+Kg),e.right=Math.max(e.right,n.x+n.width-t.x-t.width+Kg),e.bottom=Math.max(e.bottom,n.y+n.height-t.y-t.height+Kg),e.left=Math.max(e.left,t.x-n.x+Kg)}function t_(e){if(typeof e==`number`)return s_(a_(e));if(!e)return{};let t={};for(let n of n_)e[n]!==void 0&&(t[n]=a_(e[n]));return t}var n_=[`top`,`right`,`bottom`,`left`];function r_(e,t,n){let r={...e};for(let i of n_)r[i]=t[i]??(n?Math.max(n[i],e[i]):e[i]);return r}function i_(e,t){return n_.every(n=>Math.abs(e[n]-t[n])<=Jg)}function a_(e){return e!==void 0&&Number.isFinite(e)?Math.max(0,e):0}function o_(e,t){return e!==void 0&&Number.isFinite(e)&&e>=0?e:t}function s_(e){return{top:e,right:e,bottom:e,left:e}}function c_(e,t,n){if(t)throw TypeError(n===null?`Chart scale "${e}" cannot be null when a mark materializes its channel`:`Chart scale "${e}" requires a configured scale when a mark materializes its channel`);return{id:e,type:`none`,domain:[],map:()=>{throw TypeError(`Chart scale "${e}" is not configured`)},ticks:[],bandwidth:0}}function l_(e,t,n){let r=[];for(let n of t){if(!n.options?.grid)continue;let t=d_(n.options.grid);for(let i of n.scale.ticks){let a=`${n.id}-grid:${Q(i.value)}`;r.push(n.channel===`x`?{kind:`rule`,key:a,x1:i.position,x2:i.position,y1:e.y,y2:e.y+e.height,...t?{style:t}:{}}:{kind:`rule`,key:a,x1:e.x,x2:e.x+e.width,y1:i.position,y2:i.position,...t?{style:t}:{}})}}return{kind:`group`,key:`grid`,className:`ts-chart__grid`,ariaHidden:!0,children:r,style:{stroke:n.grid,strokeOpacity:.11,strokeWidth:1}}}function u_(e,t,n,r,i,a=!1){let o=[],s=s_(t.length?Kg:0),c={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},u=e.x+e.width,d=e.y+e.height;for(let n of t){let t=f_(m_(n.options)?.line),r=c[n.side]+(l[n.side]>0?t:0);s[n.side]=Math.max(s[n.side],r+Kg);let i=n.side===`top`?e.y-r:n.side===`right`?u+r:n.side===`bottom`?d+r:e.x-r,a=i,o=t=>{e_(s,e,t),a=n.side===`top`?Math.min(a,t.y):n.side===`right`?Math.max(a,t.x+t.width):n.side===`bottom`?Math.max(a,t.y+t.height):Math.min(a,t.x)},f=e=>{a=n.side===`top`||n.side===`left`?Math.min(a,e):Math.max(a,e)};n.channel===`x`?p(n,i,o,f):m(n,i,o,f);let h=n.side===`top`?e.y-a:n.side===`right`?a-u:n.side===`bottom`?a-d:e.x-a;c[n.side]=Math.max(r,h)+8,l[n.side]+=1}let f={kind:`group`,key:`axes`,className:`ts-chart__axes`,ariaHidden:!0,children:o};return Ch(s,f,e),{axes:f,margin:s};function p(t,s,c,l){let d=m_(t.options),f=t.side===`bottom`,p=f?1:-1;d?.line!==!1&&(o.push({kind:`rule`,key:`${t.id}-axis`,x1:e.x,x2:u,y1:s,y2:s,style:h(d?.line)}),l(s+p*f_(d?.line)));let m=d?.ticks===!1?[]:t.scale.ticks,g=a_(d?.ticks===!1?0:d?.ticks?.size??4),_=a_(d?.ticks===!1?0:d?.ticks?.padding??4),v=h_(d),y=v===!1?[]:__(t,g_(t.scale,t.options,v),s,g,_,v,r,n,i,a),b=v===!1?[]:y_(y,v,t.scale.type===`band`),x=s;for(let e of m){if(g<=0)continue;let n=s+p*g;l(n),x=f?Math.max(x,n):Math.min(x,n),o.push({kind:`rule`,key:`${t.id}-tick-rule:${Q(e.value)}`,x1:e.position,x2:e.position,y1:s,y2:n,style:h()})}for(let e of b)c(e.bounds),x=f?Math.max(x,e.bounds.y+e.bounds.height):Math.min(x,e.bounds.y),o.push(e.label);let S=d?.label,C=typeof S==`string`?S:S?.text;if(!C)return;let w=typeof S==`object`?S:void 0,T=w?.offset??`auto`,E=T!==`auto`,D={kind:`label`,key:`${t.id}-label`,x:e.x+e.width/2,y:E?s+p*Math.max(0,a_(T)):x+p*8,text:C,anchor:`middle`,baseline:f&&!E?`hanging`:`auto`,fontSize:w?.fontSize??(r<360?10:11),fontWeight:w?.fontWeight??600,style:{fill:w?.fill??n.foreground,...w?.opacity===void 0?{fillOpacity:.76}:{opacity:w.opacity}}};c(xh(D,i)),o.push(D)}function m(t,s,c,l){let u=m_(t.options),f=t.side===`right`,p=f?1:-1;u?.line!==!1&&(o.push({kind:`rule`,key:`${t.id}-axis`,x1:s,x2:s,y1:e.y,y2:d,style:h(u?.line)}),l(s+p*f_(u?.line)));let m=u?.ticks===!1?[]:t.scale.ticks,g=a_(u?.ticks===!1?0:u?.ticks?.size??4),_=a_(u?.ticks===!1?0:u?.ticks?.padding??4),v=h_(u),y=v===!1?[]:__(t,g_(t.scale,t.options,v),s,g,_,v,r,n,i,a),b=v===!1?[]:y_(y,v,!1),x=s;for(let e of m){if(g<=0)continue;let n=s+p*g;l(n),x=f?Math.max(x,n):Math.min(x,n),o.push({kind:`rule`,key:`${t.id}-tick-rule:${Q(e.value)}`,x1:s,x2:n,y1:e.position,y2:e.position,style:h()})}for(let e of b)c(e.bounds),x=f?Math.max(x,e.bounds.x+e.bounds.width):Math.min(x,e.bounds.x),o.push(e.label);let S=u?.label,C=typeof S==`string`?S:S?.text;if(!C)return;let w=typeof S==`object`?S:void 0,T={kind:`label`,key:`${t.id}-label`,x:s,y:e.y+e.height/2,text:C,anchor:`middle`,baseline:`middle`,rotate:f?90:-90,fontSize:w?.fontSize??11,fontWeight:w?.fontWeight??600,style:{fill:w?.fill??n.foreground,...w?.opacity===void 0?{fillOpacity:.76}:{opacity:w.opacity}}},E=w?.offset??`auto`;if(E!==`auto`)T.x=s+p*Math.max(0,a_(E));else{let e=xh({...T,x:0,y:0},i);T.x=f?x+8-e.x:x-8-(e.x+e.width)}c(xh(T,i)),o.push(T)}function h(e){return{stroke:n.foreground,strokeOpacity:.28,...d_(e)??{}}}}function d_(e){if(!e||typeof e!=`object`)return;let t={};return e.stroke!==void 0&&(t.stroke=e.stroke),e.strokeOpacity!==void 0&&(t.strokeOpacity=e.strokeOpacity),e.strokeWidth!==void 0&&(t.strokeWidth=e.strokeWidth),e.strokeDasharray!==void 0&&(t.strokeDasharray=e.strokeDasharray),e.lineCap!==void 0&&(t.lineCap=e.lineCap),Object.keys(t).length?t:void 0}function f_(e){if(!e||typeof e!=`object`||e.stroke===`none`)return 0;let t=e.strokeWidth;return t!==void 0&&Number.isFinite(t)&&t>0?t/2:0}function p_(e,t,n,r){let i=e?.axis===!1?void 0:e?.axis?.ticks;if(i===!1)return Math.max(2,Math.min(r,Math.floor(t/n)));let a=i??{};if([a.count!==void 0,a.spacing!==void 0,a.values!==void 0].filter(Boolean).length>1)throw TypeError(`Axis ticks accept only one candidate policy: count, spacing, or values`);if(a.values)return Math.max(1,a.values.length);if(a.count!==void 0)return Math.max(1,Math.floor(a_(a.count)));if(a.spacing!==void 0){let e=Math.max(1,a_(a.spacing));return Math.max(1,Math.floor(t/e))}return Math.max(2,Math.min(r,Math.floor(t/n)))}function m_(e){if(e&&e.axis!==!1)return e.axis??{}}function h_(e){return e?.ticks===!1||e?.tickLabels===!1?!1:e?.tickLabels??{}}function g_(e,t,n){let r=(typeof n.thin==`object`?n.thin:void 0)?.keep??[];if(!r.length)return e.ticks;let i=t?.axis===!1||t?.axis?.ticks===!1?void 0:t?.axis?.ticks?.format,a=e.ticks.map(e=>({...e,hard:r.some(t=>Q(t)===Q(e.value))})),o=new Set(a.map(e=>Q(e.value)));for(let t of r){let n=e.map(t);!o.has(Q(t))&&Number.isFinite(n)&&a.push({value:t,position:n,label:i?.(t)??C_(t),hard:!0})}return a}function __(e,t,n,r,i,a,o,s,c,l=!1){let u=o<360?10:11,d=e.side===`bottom`||e.side===`right`,f=d?1:-1;return t.map((t,o)=>{let p={value:t.value,index:o,position:t.position,bandwidth:e.scale.bandwidth},m=a.rotate,h=v_(a.fontSize,p)??u,g=v_(a.fontWeight,p),_=v_(a.opacity,p),v=v_(a.dx,p)??0,y=v_(a.dy,p)??0,b=e.channel===`y`?vh(d?`left`:`right`,l?`rtl`:`ltr`):(m??0)<0?vh(`right`,l?`rtl`:`ltr`):(m??0)>0?vh(`left`,l?`rtl`:`ltr`):`middle`,x=v_(a.anchor,p)??b,S=e.channel===`x`?{kind:`label`,key:`${e.id}-tick-label:${Q(t.value)}`,x:t.position+v,y:n+f*(r+i+h*.8)+y,text:t.label,anchor:x,rotate:m,fontSize:h,fontWeight:g,style:{fill:s.muted,..._===void 0?{fillOpacity:.68}:{opacity:_}}}:{kind:`label`,key:`${e.id}-tick-label:${Q(t.value)}`,x:n+f*(r+i)+v,y:t.position+y,text:t.label,anchor:x,baseline:`middle`,rotate:m,fontSize:h,fontWeight:g,style:{fill:s.muted,..._===void 0?{fillOpacity:.68}:{opacity:_}}};return{value:t.value,label:S,bounds:xh(S,c),hard:t.hard??!1}})}function v_(e,t){return typeof e==`function`?e(t):e}function y_(e,t,n){if(t.thin===!1||e.length<2)return[...e];let r=typeof t.thin==`object`?t.thin:{},i=Math.max(0,a_(r.minGap??4)),a=e.filter(e=>e.hard),o=e.filter(e=>!e.hard);if((r.priority===`ends`||n)&&o.length){let e=o[0],t=o.at(-1);x_(e,a,i)||a.push(e),t!==e&&!x_(t,a,i)&&a.push(t)}let s=b_(o.filter(e=>!a.includes(e)));for(let e of s)x_(e,a,i)||a.push(e);let c=new Set(a);return e.filter(e=>c.has(e))}function b_(e){if(e.length<3)return[...e];let t=[],n=[e];for(;n.length;){let e=n.shift();if(!e.length)continue;let r=Math.floor(e.length/2);t.push(e[r]),n.push(e.slice(0,r),e.slice(r+1))}return t}function x_(e,t,n){return t.some(t=>S_(e.bounds,t.bounds,n))}function S_(e,t,n){return!(e.x+e.width+n<=t.x||t.x+t.width+n<=e.x||e.y+e.height+n<=t.y||t.y+t.height+n<=e.y)}function C_(e){return e instanceof Date?e.toLocaleDateString():String(e)}function w_(e){return Number.isFinite(e)?Math.max(1,e):1}function T_(e={}){let t={...Ag,...e.defaultTheme,palette:e.defaultTheme?.palette??Ag.palette};return{render(e,n,r){if(!E_(e))return Mg(e,n,{...r,defaultTheme:t});let{chart:i,...a}=e;return Mg({...i({width:n.width,height:n.height,defaultTheme:t}),...a},n,{...r,defaultTheme:t})},destroy(){}}}function E_(e){return`chart`in e&&typeof e.chart==`function`}function D_(e){let t=e.width??e.initialWidth??640,n=typeof e.aspectRatio==`number`&&Number.isFinite(e.aspectRatio)&&e.aspectRatio>0?e.aspectRatio:void 0;return{aspectRatio:n,initialWidth:t,initialHeight:e.height??(n===void 0?320:t/n)}}function O_(e,t=0){return e.keyboard===!1||e.focus===!1||e.cursor?.mode===`free`?-1:t}function k_(e){let t=e.ownerDocument.defaultView,n=t?.CanvasRenderingContext2D?e.ownerDocument.createElement(`canvas`).getContext(`2d`):null,r=o(),i=M_(r),a=new Map;return{measureText(e,t){if(!n)return bh(e,t);let o=`${i}\0${t.fontSize}\0${t.fontWeight??``}\0${t.fontFamily}\0${t.fontStyle}\0${t.fontStretch}\0${t.letterSpacing}\0${t.direction}\0${t.locale??``}\0${t.fontScale}\0${t.anchor}\0${t.baseline}\0${e}`,s=a.get(o);if(s)return s;A_(n,r.weight,t);let c=j_(n.measureText(e),t);return a.set(o,c),c},typography(){return{fontFamily:r.family,fontStyle:r.style,fontStretch:r.stretch,letterSpacing:r.letterSpacing,direction:r.direction}},refresh(){let e=o(),t=M_(e);return t!==i&&(r=e,i=t,a.clear(),!0)},invalidate(){a.clear()}};function o(){let n=t?.getComputedStyle(e);return{family:n?.fontFamily||`sans-serif`,style:n?.fontStyle||`normal`,stretch:N_(n?.fontStretch),weight:n?.fontWeight||`400`,direction:n?.direction===`rtl`?`rtl`:n?.direction===`ltr`?`ltr`:`inherit`,letterSpacing:P_(n?.letterSpacing)}}}function A_(e,t,n){let r=F_(n.fontScale,1),i=n.fontSize*r,a=n.fontWeight??t;e.font=[n.fontStyle,a,`${i}px`,n.fontFamily].join(` `),`fontStretch`in e&&(e.fontStretch=N_(n.fontStretch)),e.textAlign=n.anchor===`middle`?`center`:n.anchor,e.textBaseline=n.baseline===`auto`?`alphabetic`:n.baseline,e.direction=n.direction,`letterSpacing`in e&&(e.letterSpacing=`${n.letterSpacing*r}px`)}function j_(e,t){let n=t.fontSize*F_(t.fontScale,1),r=e.actualBoundingBoxLeft,i=e.actualBoundingBoxRight,a=e.actualBoundingBoxAscent,o=e.actualBoundingBoxDescent;if([r,i,a,o].every(e=>Number.isFinite(e))&&(r+i>0||e.width===0)&&(a+o>0||e.width===0))return{x:-r,y:-a,width:r+i,height:a+o};let s=Number.isFinite(e.width)?Math.max(0,e.width):0;return{x:yh(s,t.anchor,t.direction),y:t.baseline===`middle`?-n/2:t.baseline===`hanging`?0:-n*.8,width:s,height:n}}function M_(e){return[e.family,e.style,e.stretch,e.weight,e.direction,e.letterSpacing].join(`\0`)}function N_(e){if(e===`ultra-condensed`||e===`extra-condensed`||e===`condensed`||e===`semi-condensed`||e===`normal`||e===`semi-expanded`||e===`expanded`||e===`extra-expanded`||e===`ultra-expanded`)return e;let t=Number.parseFloat(e??``);return Number.isFinite(t)?t<=50?`ultra-condensed`:t<=62.5?`extra-condensed`:t<=75?`condensed`:t<=87.5?`semi-condensed`:t<112.5?`normal`:t<125?`semi-expanded`:t<150?`expanded`:t<200?`extra-expanded`:`ultra-expanded`:`normal`}function P_(e){let t=Number.parseFloat(e??``);return Number.isFinite(t)?t:0}function F_(e,t){return e!==void 0&&Number.isFinite(e)&&e>0?e:t}var I_={resolve:()=>[],group:()=>[],navigation:()=>[]},L_=V_(`x`,!0),R_=V_(`y`,!0),z_=V_(`x`,!1),B_=V_(`y`,!1);function V_(e,t){let n=t=>xg(t,e),r=t=>e===`x`?t.y:t.x;return{resolve(i,a){let{x:o,y:s,maxDistance:c}=a,l=e===`x`?o:s,u,d=c;for(let e of i){let t=Math.abs(n(e)-l);t>=d||(u=e,d=t)}if(!u)return[];let f=H_(i,u,n),p=e===`x`?s:o,m=f.reduce((e,t)=>Math.abs(r(t)-p)<Math.abs(r(e)-p)?t:e,u);return t?[m,...f.filter(e=>e!==m)]:[m]},group(e,r){let{point:i}=r;return t?H_(e,i,n):[i]},navigation(e){let r=[...e].sort((e,t)=>e.x-t.x||e.y-t.y);if(!t)return r;let i=new Map;for(let e of r){let t=Q(n(e));i.has(t)||i.set(t,e)}return[...i.values()]}}}function H_(e,t,n){let r=Q(n(t)),i=new Map;i.set(Q(t.group),t);for(let t of e){if(Q(n(t))!==r)continue;let e=Q(t.group);i.has(e)||i.set(e,t)}return[t,...[...i.values()].sort((e,t)=>e.y-t.y).filter(e=>e!==t)]}function U_(e){if(e!==!1){if(typeof e!=`string`)return e;switch(e){case`nearest-x`:return z_;case`nearest-y`:return B_;case`group-x`:return L_;case`group-y`:return R_;case`nearest`:return}}}function W_(e,t,n,r,i,a=e.points){let o=U_(t);if(o){if(a===e.points&&(o===z_||o===B_||o===L_||o===R_)){let t=Jh(e,n,r);if(t)return t.point?o.group(a,{point:t.point}):[]}return o.resolve(a,{x:n,y:r,maxDistance:i})}}function G_(e,t){return e===t||e!==null&&t!==null&&e.key===t.key&&e.markId===t.markId&&e.datumIndex===t.datumIndex}function K_(e,t){let n=e.filter(e=>e.key===t.key);if(n.length<2)return n[0]??null;let r=typeof t.datum;if(t.datum!==null&&(r===`object`||r===`function`)){let e=n.find(e=>e.datum===t.datum);if(e)return e}return n.find(e=>e.markId===t.markId&&Object.is(e.group,t.group)&&Z_(e.xValue,t.xValue)&&Z_(e.yValue,t.yValue))??n.find(e=>e.markId===t.markId&&e.datumIndex===t.datumIndex)??n[0]??null}function q_(e,t,n){let r=t?e.findIndex(e=>G_(e,t)):-1,i;switch(n){case`ArrowRight`:case`ArrowDown`:i=Math.min(e.length-1,r+1);break;case`ArrowLeft`:case`ArrowUp`:i=Math.max(0,r<0?0:r-1);break;case`Home`:i=0;break;case`End`:i=e.length-1;break;default:return}return e[i]??null}function J_(e,t,n){let r=n===`ArrowRight`||n===`ArrowDown`?1:n===`ArrowLeft`||n===`ArrowUp`?-1:n===`Home`?0:n===`End`?2:void 0;if(r===void 0)return;if(!e.length)return null;let i=t?e.findIndex(e=>G_(e,t)):-1;if(!t||i<0||r===0||r===2)return Y_(e,r===2);let a=null,o=-1;for(let n=0;n<e.length;n+=1){let s=e[n];if(!s)continue;let c=X_(s,n,t,i);r>0&&c<=0||r<0&&c>=0||(!a||r*X_(s,n,a,o)<0)&&(a=s,o=n)}return a??t}function Y_(e,t){let n=e[0]??null,r=0;for(let i=1;i<e.length;i+=1){let a=e[i];if(!a||!n)continue;let o=X_(a,i,n,r);(t&&o>0||!t&&o<0)&&(n=a,r=i)}return n}function X_(e,t,n,r){return e.x-n.x||e.y-n.y||t-r}function Z_(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Q_(e){let t=e.use;if(t.__chartExtensionType!==`cursor`)throw TypeError(`A chart cursor requires a cursor host extension.`);return t.create(e.controller)}function $_(e,t){return(tv(e.nodes,t)??ev(e.focusGuides,t))?.compose(t)??t}function ev(e,t){for(let n of e??[])if(n.renderer!==void 0&&n.renderer!==t)return nv(n.renderer)}function tv(e,t){for(let n of e){if(n.renderer!==void 0&&n.renderer!==t)return nv(n.renderer);if(n.kind===`group`){let e=tv(n.children,t);if(e)return e}}}function nv(e){if(typeof e.compose!=`function`)throw TypeError(`Mark renderer "${e.id}" cannot compose chart layers`);return e}function rv(e,t,n=T_()){sv(t.definition.tooltip);let r=t,i,a,o=null,s=`pointer`,c=null,l=null,u=null,d,f,p,m=!1,h,g=!1,_=!1,v,y,b=!1,x=!1,S,C,w=!1,T,E=new Map,D,O,k,A,j,M,ee=null,N=!1,P=e.style.position,F=e.ownerDocument.defaultView,I=F?.getComputedStyle(e).position,te=!I||I===`static`,ne=k_(e),re=e.ownerDocument.fonts;te&&(e.style.position=`relative`);let ie=(t=!1,n=`update`)=>{if(g)return;t&&!r.measureText&&ne.refresh();let d=o,f=ee,p=j;i=av(Me()),a=i;let m=$_(i,r.renderer);v?v.renderer!==m&&(y?.(),y=void 0,Ge(),Pe(),v.destroy(),e.replaceChildren(),v=m.mount(e,de),ze(),_=!1):(v=m.mount(e,de),ze()),b=!0;try{v.render(i,{ariaLabel:r.ariaLabel,ariaDescription:r.ariaDescription,className:r.className,tabIndex:O_(r.definition,r.tabIndex),idPrefix:r.idPrefix,animation:_?hv(r.definition.svgAnimation,e,n):void 0})}finally{b=!1}Ne(),_=!0;let h=Le();T=r.definition.focus===!1?void 0:r.definition.spatialIndex?.(Bg(i,i.points),{scene:i});let x=pe();if(j=x,x)he(!0);else if(p)ee=null,o=null,u=null,l=null,c=null,z(null,[]),d&&(r.onFocusChange?.(null),r.onFocusGroupChange?.([]));else{ee=null;let e=(c===`pointer`||c===`controlled`&&s===`pointer`)&&u===null?l:null,t=e?Ie(e.x,e.y,Ve()):d?(()=>{let e=K_(h,d);return e?Re(e,h):[]})():[],n=t[0]??null;o=n,n||(u=null),(d||n||f)&&(e||(s=`restored`),z(n,t),r.onFocusChange?.(n),r.onFocusGroupChange?.(t))}let S=r.onRender;S&&S({container:e,scene:i,surface:v,interaction:xe})},ae=()=>r.width===void 0,oe=()=>r.height===void 0&&!cv(r.aspectRatio),se=t=>{let n=F?.getComputedStyle(e),r=lv(n?.paddingLeft)+lv(n?.paddingRight),i=lv(n?.paddingTop)+lv(n?.paddingBottom),a=lv(n?.borderLeftWidth)+lv(n?.borderRightWidth),o=lv(n?.borderTopWidth)+lv(n?.borderBottomWidth);return{width:uv(n?.width,n?.boxSizing,t?.width,r,a),height:uv(n?.height,n?.boxSizing,t?.height,i,o)}},ce=()=>{let t=ae(),n=oe(),i=(t||n)&&!f?e.getBoundingClientRect():void 0,a=t||n?f??se(i):void 0;return{width:r.width??a?.width,height:n?a?.height:void 0}},le=()=>{let e=ce();return ae()&&e.width!==void 0&&e.width!==i.width||oe()&&e.height!==void 0&&e.height!==i.height},ue=()=>{if(d?.disconnect(),d=void 0,f=void 0,!ae()&&!oe())return;let t=F?.ResizeObserver;t&&(d=new t(t=>{let n=t.find(t=>t.target===e)??t[0];f=n?{width:fv(n.contentRect.width),height:fv(n.contentRect.height)}:void 0,le()&&de(!1,`resize`)}),d.observe(e))},de=(e=!1,t=`layout`)=>{if(m||=e,h=h===`layout`||t===`layout`?`layout`:`resize`,p===void 0){if(!F?.requestAnimationFrame){let e=m||le();m=!1;let t=h??`layout`;h=void 0,e&&ie(!0,t);return}p=F.requestAnimationFrame(()=>{p=void 0;let e=m||le();m=!1;let t=h??`layout`;h=void 0,e&&ie(!0,t)})}},fe=()=>{g||r.measureText||(ne.invalidate(),de(!0))},pe=()=>r.definition.cursor,L=()=>D?.getState()?.pinned===!0,R=()=>u!==null||L(),me=()=>{let e=pe();e&&(N=!0);let t=e?.controller,n=e?.mode,r=e?.mode===`focus`?e.match??`xy`:void 0;(t!==D?.controller||n!==O||r!==k||e?.use!==A)&&(M?.(),M=void 0,D?.destroy(),D=e?Q_(e):void 0,O=n,k=r,A=e?.use,M=D?.subscribe(()=>{!g&&_&&he(!1)}))},he=e=>{let t=pe();if(!t){ee=null;return}let n=D;if(!n)return;let a=n.getState();(a?.source!==`pointer`||!n.owns(a))&&(l=null),ee=n.resolvePresentation(i,t,a);let c=o;if(t.mode===`focus`){let i=U_(r.definition.focus),l=n.resolveFocus(Le(),t,a,i),d=l[0]??null;a&&(s=a.source),u=a?.pinned&&d?d.key:null,o=d,z(d,l),(!G_(c,d)||e&&(c!==null||d!==null))&&(r.onFocusChange?.(d),r.onFocusGroupChange?.(l));return}u=null,o=null,z(null,[]),c&&(r.onFocusChange?.(null),r.onFocusGroupChange?.([]))},ge=(e,t=R())=>{let n=pe();if(n?.mode!==`focus`)return!1;let r=D;if(!r)return!1;let a=e[0];return a?(r.publish(r.createFocusState(i,n,{primary:a,group:e,source:s,pinned:t})),!0):(r.clearOwnedTransient(),!0)},_e=(e,t=!1)=>{let n=e[0]??null;if(!ge(e)){if(G_(n,o)){o=n,t&&z(n,e);return}o=n,z(n,e),r.onFocusChange?.(n),r.onFocusGroupChange?.(e)}},ve=()=>{let t=pe();if(!o&&!u&&!D?.getState())return;let n=!!C?.contains(e.ownerDocument.activeElement);u=null,l=null,c=null,t?D?.clear():_e([]);let r=v?.element;n&&r&&`focus`in r&&typeof r.focus==`function`&&(w=!0,r.focus())},z=(e,t)=>{x=!0;let n;try{let r=e?{primary:e,group:t,source:s,pinned:R()}:null;n=N?v?.paintFocus(r,l,ee):v?.paintFocus(r,l)}finally{x=!1}a=n??i,He(e,t)},ye=(e,t)=>{let n=v?.clientToScene?.(i,e,t);return n?{position:n,points:Ie(n.x,n.y,Ve())}:null},be=(e,t)=>{let n=ye(e,t);return l=n?.position??null,n?.points??[]},xe={clientToScene(e,t){return g?null:v?.clientToScene?.(i,e,t)??null},resolvePointer(e,t){if(g)return null;let n=ye(e,t),r=n?.points[0];return n&&r?{position:n.position,point:r,points:n.points}:null},setControlledFocus(e,t={}){if(g)return;if(c=`controlled`,!e){s=t.source??`programmatic`,l=null,u=null,_e([]),c=null;return}let n,r;ov(e)?(n=e,r=e.point):(n=null,r=e),s=t.source??(n===null?`programmatic`:`pointer`);let i=Le(),a=K_(i,r);if(l=n?.position??null,!a){u=null,_e([]),c=null;return}let d=Re(a,i);if(u=t.pinned&&(Ke()||pe()?.pin===!0)?a.key:null,G_(a,o)){o=a,z(a,d);return}_e(d)}},Se=(e,t)=>{let n=v?.clientToScene?.(i,e,t);return l=n??null,n},Ce=(e,t)=>{let n=pe();if(n?.mode!==`free`)return!1;if(L())return!0;let r=Se(e,t);if(!r||!mv(i,r))return l=null,D?.clearOwnedTransient(),!0;let a=D;return a?(a.publish(a.createFreeState(i,n,r,`pointer`,!1)),!0):!1},we=e=>{if(Fe(e.target)){R()||(l=null,_e([]));return}r.definition.pointer===!1||R()||(c=`pointer`,s=`pointer`,!Ce(e.clientX,e.clientY)&&_e(be(e.clientX,e.clientY),qe()))},Te=e=>{r.definition.pointer===!1||R()||(c=`pointer`,s=`pointer`,Ce(e.clientX,e.clientY))},Ee=({relatedTarget:t})=>{r.definition.pointer!==!1&&c===`pointer`&&!R()&&!(F&&t instanceof F.Node&&e.contains(t))&&(l=null,pe()?D?.clearOwnedTransient():_e([]),c=null)},De=({relatedTarget:t})=>{c===`keyboard`&&!u&&!(F&&t instanceof F.Node&&e.contains(t))&&(l=null,pe()?D?.clearOwnedTransient():_e([]),c=null)},Oe=t=>{if(r.definition.pointer===!1||u===null||L())return;let n=t.composedPath();n.includes(e)||n.some(e=>F&&e instanceof F.Node&&C?.contains(e))||ve()},ke=t=>{if(Fe(t.target)||r.definition.pointer===!1)return;let n=C,i=e.ownerDocument.defaultView?.Node,a=i?t.composedPath().some(e=>e instanceof i&&n?.contains(e)):n?.contains(t.target);if(n&&a)return;c=`pointer`;let o=pe();if(o?.mode===`free`){D?.getState()||Ce(t.clientX,t.clientY);let e=D?.getState();o.pin&&e&&(e.pinned?D?.clear():D?.publish({...e,pinned:!0})),r.onSelect?.(null);return}let l=be(t.clientX,t.clientY);s=`pointer`;let d=l[0]??null,f=!1,p=Ke()||o?.pin===!0;p&&(R()?(u=null,f=!0,o&&D?.clear()):d&&(u=d.key,f=!0)),o&&p&&f&&!u||_e(l,f),r.definition.selection?.change(d,`pointer`),r.onSelect?.(d)},Ae=e=>{if(Fe(e.target))return;let t=pe();if(e.key===`Escape`&&D?.getState()){e.preventDefault(),ve();return}if(e.key===`Escape`&&u){e.preventDefault(),ve();return}if(r.definition.keyboard===!1||t?.mode===`free`)return;let n=Le();if(!n.length)return;if(e.key===`Enter`||e.key===` `){if(!o)return;e.preventDefault();let n=o,i=Ke()||t?.pin===!0;t?.mode===`focus`&&i?R()?(u=null,D?.clear()):(u=n.key,ge(Re(n),!0)):Ke()&&(u=u?null:n.key,z(n,Re(n))),r.definition.selection?.change(n,`keyboard`),r.onSelect?.(n);return}let i=pv(r.definition.focus),a=i?q_(i.navigation(n),o,e.key):J_(n,o,e.key);a!==void 0&&(e.preventDefault(),l=null,c=`keyboard`,s=`keyboard`,_e(a?Re(a):[]))},je=e=>{if(Fe(e.target)){u||(l=null,_e([]));return}if(e.target===v?.element&&w){w=!1;return}if(r.definition.keyboard!==!1&&pe()?.mode!==`free`&&e.target===v?.element&&!o){let e=pv(r.definition.focus),t=Le(),n=e?e.navigation(t)[0]:J_(t,null,`Home`);l=null,c=`keyboard`,s=`keyboard`,_e(n?Re(n):[])}};return e.addEventListener(`pointermove`,we),e.addEventListener(`pointerdown`,Te),e.addEventListener(`pointercancel`,Ee),e.addEventListener(`mouseleave`,Ee),e.addEventListener(`click`,ke),e.addEventListener(`keydown`,Ae),e.addEventListener(`focusin`,je),e.addEventListener(`focusout`,De),re?.addEventListener?.(`loadingdone`,fe),me(),ie(),ue(),e.ownerDocument.addEventListener(`pointerdown`,Oe,!0),{interaction:xe,update(e){if(g)return;sv(e.definition.tooltip);let t=e.measureText===void 0&&ne.refresh(),n=r.definition!==e.definition,i=r.height!==e.height||r.aspectRatio!==e.aspectRatio||r.width!==e.width||r.initialWidth!==e.initialWidth,a=r.idPrefix!==e.idPrefix||r.renderer!==e.renderer||r.measureText!==e.measureText||t,s=n||i||r.ariaLabel!==e.ariaLabel||r.ariaDescription!==e.ariaDescription||r.className!==e.className||r.tabIndex!==e.tabIndex||r.idPrefix!==e.idPrefix||r.renderer!==e.renderer||r.measureText!==e.measureText||t,d=r.width!==e.width||r.height!==e.height||r.aspectRatio!==e.aspectRatio,f=r.definition.pointer!==!1&&e.definition.pointer===!1&&c===`pointer`;r=e,me(),We(),f&&(l=null,u=null,c=null,_e([])),Ke()||(u=null),s?ie(!1,a?`layout`:i?`resize`:`update`):pe()?he(!1):o&&z(o,Re(o)),d&&ue()},getScene:()=>i,destroy(){g||(g=!0,d?.disconnect(),M?.(),M=void 0,D?.destroy(),D=void 0,O=void 0,k=void 0,A=void 0,re?.removeEventListener?.(`loadingdone`,fe),p!==void 0&&F?.cancelAnimationFrame?.(p),Ge(),Pe(),y?.(),y=void 0,v?.destroy(),n.destroy(),e.removeEventListener(`pointermove`,we),e.removeEventListener(`pointerdown`,Te),e.removeEventListener(`pointercancel`,Ee),e.removeEventListener(`mouseleave`,Ee),e.removeEventListener(`click`,ke),e.removeEventListener(`keydown`,Ae),e.removeEventListener(`focusin`,je),e.removeEventListener(`focusout`,De),e.ownerDocument.removeEventListener(`pointerdown`,Oe,!0),e.replaceChildren(),te&&e.style.position===`relative`&&(e.style.position=P))}};function Me(){let e=ce(),t=e.width??(_?i.width:r.initialWidth??640);return n.render(r.definition,{width:t,height:r.height??(cv(r.aspectRatio)?t/r.aspectRatio:e.height??(_?i.height:320))},{measureText:r.measureText??ne.measureText,typography:ne.typography()})}function Ne(){let t=new Set;for(let n of i.controls??[]){let r=n.extension,a=`${r.id}:${n.key}`;t.add(a);let o=E.get(a);o&&o.extension!==r&&(o.instance.destroy(),E.delete(a),o=void 0),o||(o={extension:r,instance:r.create({container:e,surface:v})},E.set(a,o)),o.instance.update(n,i)}for(let[e,n]of E)t.has(e)||(n.instance.destroy(),E.delete(e))}function Pe(){for(let e of E.values())e.instance.destroy();E.clear()}function Fe(e){for(let t of E.values())if(t.instance.contains?.(e))return!0;return!1}function Ie(e,t,n){let o=Le(),s=pv(r.definition.focus),c=W_(a,s,e,t,n,o);if(c)return c;let l=v?.getPresentationPoints?.()===void 0?T&&a===i?T.findNearest(e,t,n):zg(a,e,t,n,o):Kh(o,e,t,n),u=l?K_(o,l):null;return u?[u]:[]}function Le(){let e=v?.getPresentationPoints?.()??a.points;return Bg(i,e)}function Re(e,t=Le()){return pv(r.definition.focus)?.group(t,{point:e})??[e]}function ze(){y=v?.subscribePresentationPoints?.(Be)}function Be(e){if(g||b||x)return;if(pe()){he(!1);return}let t=Bg(i,e);if(l&&u===null){_e(Ie(l.x,l.y,Ve()),!0);return}if(!o)return;let n=K_(t,o);_e(n?Re(n,t):[],!0)}function Ve(){return r.definition.maxFocusDistance??48}function He(t,n){let a=sv(r.definition.tooltip);if(!a||!t||!v){C?.hide();return}if(S!==a.extension||!C){Ge(),S=a.extension;let t=v.renderer.capabilities?.tooltipMotion;C=a.extension.create({container:e,motion:t?.protocol===1?t.createController({container:e,transition:Ue}):void 0,dismiss:ve,bodyChange:()=>r.onTooltipBodyChange})}let o=C;o.update(a.options),o.paint({point:t,points:n,scene:i,surface:v,pointer:l,focus:{primary:t,group:n,source:s,pinned:R()},pinned:R()})}function Ue(){let e=r.definition.motion;return e===!1?!1:typeof e==`function`?void 0:e?.transition}function We(){let e=sv(r.definition.tooltip);e?e.extension===S?C?.update(e.options):Ge():(C?.update(iv),C?.hide())}function Ge(){C?.destroy(),C=void 0,S=void 0}function Ke(){let e=sv(r.definition.tooltip);return!!(e&&e.options.sticky!==!1)}function qe(){let e=sv(r.definition.tooltip)?.options.anchor;return e===`pointer`||typeof e==`function`||typeof e==`object`&&(e.x===`pointer`||e.y===`pointer`)}}var iv={};function av(e){let t=new Set((e.controls??[]).flatMap(e=>e.fallbackNodeKey?[e.fallbackNodeKey]:[]));return t.size?{...e,nodes:e.nodes.filter(e=>!t.has(e.key))}:e}function ov(e){return`position`in e&&`point`in e&&`points`in e}function sv(e){if(!e)return null;let t=`create`in e?e:e.use;if(t.__chartTooltipHost!==`dom`)throw TypeError(`DOM chart hosts require a tooltip extension from @tanstack/charts/tooltip.`);let n=t;return`create`in e?{extension:n,options:iv}:{extension:n,options:e}}function cv(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function lv(e){return dv(e)??0}function uv(e,t,n,r,i){let a=cv(n)?dv(e):void 0,o=a===void 0?(n??0)-r-i:a-(t===`border-box`?r+i:0);return cv(o)?o:void 0}function dv(e){let t=/^(-?(?:\d+(?:\.\d*)?|\.\d+))px$/i.exec(e?.trim()??``);if(!t)return;let n=Number(t[1]);return Number.isFinite(n)?n:void 0}function fv(e){return cv(e)?e:void 0}function pv(e){return e===!1?I_:U_(e)}function mv(e,t){return t.x>=e.chart.x&&t.x<=e.chart.x+e.chart.width&&t.y>=e.chart.y&&t.y<=e.chart.y+e.chart.height}function hv(e,t,n){let r=e===!0?{}:e||void 0;if(!r||n===`layout`||n===`resize`&&r.resize!==!0||(r.respectReducedMotion??!0)&&t.ownerDocument.defaultView?.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)return;let{resize:i,...a}=r;return a}var gv=new Set([`cx`,`cy`,`d`,`fill-opacity`,`font-size`,`font-weight`,`fx`,`fy`,`height`,`opacity`,`r`,`rx`,`stroke-opacity`,`stroke-width`,`transform`,`width`,`x`,`x1`,`x2`,`y`,`y1`,`y2`]);function _v(e,t,n){let r=e.ownerDocument.createElement(`template`);r.innerHTML=t;let i=r.content.firstElementChild;if(!i)return()=>{};let a=e.firstElementChild;if(!a||a.namespaceURI!==i.namespaceURI||a.localName!==i.localName)return e.replaceChildren(i),()=>{};let o=[];return yv(a,i,n?o:void 0),n?Cv(e,o,n):()=>{}}function vv(e,t,n){let r=e.ownerDocument.createElement(`template`);r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`;let i=r.content.firstElementChild?.firstElementChild;if(!i)return()=>{};if(e.namespaceURI!==i.namespaceURI||e.localName!==i.localName)return e.replaceWith(i),()=>{};let a=[];return yv(e,i,n?a:void 0),n?Cv(e,a,n):()=>{}}function yv(e,t,n){if(bv(e,t,n),!t.firstElementChild){if(e.firstElementChild)for(let t of[...e.children])n?Sv(t,n):t.remove();else e.textContent!==t.textContent&&(e.textContent=t.textContent);return}let r=[...e.children],i=[...t.children],a=Dv(r),o=Ov(i),s=new Set,c=e.firstElementChild;i.forEach((t,r)=>{let i=o[r],l=a.get(i),u;l&&l.namespaceURI===t.namespaceURI&&l.localName===t.localName?(u=l,s.add(l),u!==c&&e.insertBefore(u,c),yv(u,t,n)):l&&e.localName===`defs`?(u=t.cloneNode(!0),l.replaceWith(u),l!==c&&e.insertBefore(u,c)):(u=t.cloneNode(!0),e.insertBefore(u,c),xv(u,t,n)),c=u.nextElementSibling});for(let t of r)!s.has(t)&&t.parentElement===e&&(n?Sv(t,n):t.remove())}function bv(e,t,n){let r=new Set(t.getAttributeNames());for(let t of e.getAttributeNames())r.has(t)||e.removeAttribute(t);for(let i of r){let r=t.getAttribute(i),a=e.getAttribute(i);if(r===a)continue;let o=n&&a!==null&&r!==null&&gv.has(i)?Tv(i,a,r):void 0;o&&n?n.push({element:e,name:i,interpolate:o,target:r}):r!==null&&e.setAttribute(i,r)}}function xv(e,t,n){if(!n)return;let r=t.getAttribute(`opacity`),i=r??`1`;e.setAttribute(`opacity`,`0`),n.push({element:e,name:`opacity`,interpolate:e=>String(Number(i)*Math.max(0,Math.min(1,e))),target:r})}function Sv(e,t){let n=Number(e.getAttribute(`opacity`)??1),r=Number.isFinite(n)?n:1;t.push({element:e,name:`opacity`,interpolate:e=>String(r*(1-e)),target:`0`,removeOnFinish:!0})}function Cv(e,t,n){if(!t.length)return()=>{};let r=e.ownerDocument.defaultView,i=r?.requestAnimationFrame?.bind(r),a=r?.cancelAnimationFrame?.bind(r),o=Math.max(0,n.duration??240);if(!i||!a||o===0)return wv(t),()=>{};let s=0,c=!1,l,u=kv(n.easing??`ease-out`),d=e=>{if(c)return;l??=e;let n=Math.min(1,(e-l)/o),r=u(n);for(let e of t)e.element.setAttribute(e.name,e.interpolate(r));n<1?s=i(d):wv(t)};return s=i(d),()=>{c=!0,a(s)}}function wv(e){for(let t of e){if(t.removeOnFinish){t.element.remove();continue}t.target===null?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,t.target)}}function Tv(e,t,n){let r=e===`d`,i=Ev(t,r),a=Ev(n,r);if(i.skeleton!==a.skeleton||i.values.length!==a.values.length||!i.values.length)return;let o=a.skeleton;return e=>{let t=0;return o.replaceAll(/[#!]/g,n=>{let r=i.values[t],o=a.values[t];return t+=1,Av(n===`!`?o:r+(o-r)*e)})}}function Ev(e,t=!1){let n=[],r=``,i=``,a=0,o=0;for(;o<e.length;){let s=e.slice(o),c=a%7,l=t&&/a/i.test(i)&&c>2&&c<5,u=l?/^[01]/u.exec(s):/^-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/iu.exec(s);if(u){n.push(Number(u[0])),r+=l?`!`:`#`,a+=1,o+=u[0].length;continue}let d=e[o];r+=d,t&&/[a-z]/i.test(d)&&(i=d,a=0),o+=1}return{skeleton:r,values:n}}function Dv(e){let t=new Map;return Ov(e).forEach((n,r)=>{t.set(n,e[r])}),t}function Ov(e){let t=new Map;return e.map(e=>{let n=e.getAttribute(`data-ts-key`);if(n)return`key:${n}`;let r=t.get(e.localName)??0;return t.set(e.localName,r+1),`tag:${e.localName}:${r}`})}function kv(e){if(typeof e==`function`)return e;switch(e){case`linear`:return e=>e;case`ease-in`:return e=>e*e;case`ease-in-out`:return e=>e<.5?2*e*e:1-(-2*e+2)**2/2;case`ease`:case`ease-out`:return e=>1-(1-e)**3}}function Av(e){return String(Math.round(e*1e3)/1e3)}function $(e){return String(Math.round(e*100)/100)}var jv={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`},Mv=/[&<>\u0000-\u0008\u000b\u000c\u000e-\u001f\ufffe\uffff]|\p{Cs}/gu;function Nv(e){return jv[e]??`�`}function Pv(e){return e.replace(Mv,Nv)}function Fv(e){return e.replace(Mv,Nv).replace(/"/g,jv[`"`])}var Iv=new WeakMap;function Lv(e){return Iv.get(e)}function Rv(e,t,n){let r=Iv.get(e);Iv.set(e,t);try{return n()}finally{r?Iv.set(e,r):Iv.delete(e)}}function zv(e,t,n){let r=t.idPrefix??``,i=t.className?`ts-chart ${t.className}`:`ts-chart`,a=t.ariaDescription?`<desc>${Pv(t.ariaDescription)}</desc>`:``,o=n?.renderDefinitions?.(e,r)??``,s=e.direction===`ltr`||e.direction===`rtl`?` direction="${e.direction}"`:``,c=e.theme.background===`transparent`?``:Uv({kind:`rect`,key:`background`,x:0,y:0,width:e.width,height:e.height,style:{fill:e.theme.background}},n,r);return`<svg class="${Fv(i)}" width="100%" height="100%" viewBox="0 0 ${$(e.width)} ${$(e.height)}" role="img" aria-roledescription="chart" aria-label="${Fv(t.ariaLabel)}" tabindex="${$(t.tabIndex??0)}"${s} style="display:block;overflow:visible">${a}${o}${c}${Bv(e.nodes,r,n,Lv(t))}</svg>`}function Bv(e,t=``,n,r){let i=``;for(let a of e)i+=Uv(a,n,t,r);return i}function Vv(e,t,n=``,r){return`<g data-ts-key="focus-guide-layer:${t}" class="ts-chart__focus-guide-layer ts-chart__focus-guide-layer--${t}" data-ts-focus-layer="${t}" data-ts-focus-guide-layer="${t}" aria-hidden="true" visibility="${e.length?`visible`:`hidden`}">${Bv(e,n,r??Hv)}</g>`}var Hv={renderGroup:Kv};function Uv(e,t,n,r){let i=Jv(e,t,n);switch(e.kind){case`group`:{let a=e.translateX===void 0&&e.translateY===void 0?``:` transform="translate(${$(e.translateX??0)} ${$(e.translateY??0)})"`,o=t?.renderGroup?.(e,n);return`<g${i}${a}${e.focus?` data-ts-focus-layer="${e.focus.placement}"${e.focus.retarget?` data-ts-focus-retarget="true"`:``} visibility="hidden"`:``}${o?.attributes??``}>${o?.content??``}${Bv(r?.(e)??e.children,n,t,r)}</g>`}case`rule`:return`<line${i} x1="${$(e.x1)}" y1="${$(e.y1)}" x2="${$(e.x2)}" y2="${$(e.y2)}"/>`;case`polyline`:return`<path${i} d="${Fv(e.path??Gv(e.points,!1))}" vector-effect="non-scaling-stroke"/>`;case`area`:{let t=e.polygons===void 0?e.path??Gv(e.points,!0):Wv(e.polygons),n=e.polygons===void 0?``:` fill-rule="evenodd"`;return`<path${i} d="${Fv(t)}"${n} vector-effect="non-scaling-stroke"/>`}case`dot`:return`<circle${i} cx="${$(e.x)}" cy="${$(e.y)}" r="${$(e.radius)}"/>`;case`rect`:return e.cornerRadii===void 0?`<rect${i} x="${$(e.x)}" y="${$(e.y)}" width="${$(e.width)}" height="${$(e.height)}"${e.radius===void 0?``:` rx="${$(e.radius)}"`}/>`:`<path${i} d="${jh(e.x,e.y,e.width,e.height,e.cornerRadii)}"/>`;case`label`:{let t=e.rotate===void 0?``:` transform="rotate(${$(e.rotate)} ${$(e.x)} ${$(e.y)})"`,n=e.anchor?` text-anchor="${e.anchor}"`:``,r=e.baseline?` dominant-baseline="${e.baseline}"`:``,a=e.fontSize===void 0?``:` font-size="${$(e.fontSize)}"`,o=e.fontWeight===void 0?``:` font-weight="${$(e.fontWeight)}"`;return`<text${i} x="${$(e.x)}" y="${$(e.y)}"${n}${r}${t}${a}${o} font-family="inherit">${Pv(e.text)}</text>`}}}function Wv(e){return e.flatMap(e=>e).filter(e=>e.length>0).map(e=>Gv(e,!0)).join(``)}function Gv(e,t){return`${e.map(([e,t],n)=>`${n===0?`M`:`L`}${$(e)},${$(t)}`).join(``)}${t?`Z`:``}`}function Kv(e,t){if(!e.clip)return;let n=t.replaceAll(/[^a-zA-Z0-9_-]/g,``),r=`${n?`${n}-`:``}ts-chart-clip-${qv(e.key)}`;return{attributes:` clip-path="url(#${r})"`,content:`<defs data-ts-key="${Fv(`${e.key}:clip-defs`)}"><clipPath id="${r}"><rect x="${$(e.clip.x)}" y="${$(e.clip.y)}" width="${$(e.clip.width)}" height="${$(e.clip.height)}"/></clipPath></defs>`}}function qv(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)}function Jv(e,t,n){return`${` data-ts-key="${Fv(e.key)}"`}${e.className?` class="${Fv(e.className)}"`:``}${e.ariaHidden?` aria-hidden="true"`:``}${Yv(e.style,t,n)}`}function Yv(e,t,n){return e?Zv(`fill`,Xv(e.fill,t,n))+Zv(`fill-opacity`,e.fillOpacity)+Zv(`stroke`,Xv(e.stroke,t,n))+Zv(`stroke-opacity`,e.strokeOpacity)+Zv(`stroke-width`,e.strokeWidth)+Zv(`opacity`,e.opacity)+Zv(`stroke-linecap`,e.lineCap)+Zv(`stroke-linejoin`,e.lineJoin)+Zv(`stroke-dasharray`,e.strokeDasharray):``}function Xv(e,t,n){return e&&t?.resolvePaint?t.resolvePaint(e,n):e}function Zv(e,t){return t==null?``:` ${e}="${typeof t==`number`?$(t):Fv(t)}"`}function Qv(e,t){let n=new Set(e.gradients.map(e=>e.id));return zv(e,t,{renderDefinitions:(e,t)=>$v(e,ty(t)),renderGroup:Kv,resolvePaint:n.size?(e,t)=>{let r=/^url\(#([^)]+)\)$/.exec(e)?.[1];return r&&n.has(r)?`url(#${ey(ty(t),r)})`:e}:void 0})}function $v(e,t){return e.gradients.length?`<defs data-ts-key="gradients">${e.gradients.map(e=>{let n=0,r=e.stops.map((t,r)=>{let i=Math.max(n,ry(t.offset));return n=i,`<stop data-ts-key="gradient:${Fv(e.id)}:stop:${r}" offset="${ny(i)}" stop-color="${Fv(t.color)}"${t.opacity===void 0?``:` stop-opacity="${$(t.opacity)}"`}/>`}).join(``);if(e.type===`radial`){let n=e.cx??.5,i=e.cy??.5;return`<radialGradient data-ts-key="gradient:${Fv(e.id)}" id="${Fv(ey(t,e.id))}" cx="${ny(n)}" cy="${ny(i)}" r="${ny(e.r??.5)}" fx="${ny(e.fx??n)}" fy="${ny(e.fy??i)}">${r}</radialGradient>`}return`<linearGradient data-ts-key="gradient:${Fv(e.id)}" id="${Fv(ey(t,e.id))}" x1="${ny(e.x1??0)}" y1="${ny(e.y1??1)}" x2="${ny(e.x2??0)}" y2="${ny(e.y2??0)}">${r}</linearGradient>`}).join(``)}</defs>`:``}function ey(e,t){return e?`${e}-${t}`:t}function ty(e){return e.replaceAll(/[^a-zA-Z0-9_-]/g,``)}function ny(e){return`${$(ry(e)*100)}%`}function ry(e){return Number.isNaN(e)?0:Math.max(0,Math.min(1,e))}function iy(e){let t=new Map,n=new Map,r=(e,t,n)=>{let r=e.get(t);r?r.push(n):e.set(t,[n])};for(let i of e){r(n,i.markId,i);let e=i.key.length;for(;e>0;)r(t,i.key.slice(0,e),i),e=i.key.lastIndexOf(`:`,e-1)}return{points:e,keys:t,marks:n}}function ay(e,t,n,r=t){if(e.kind===`group`){let n=e.focusCandidateIndex;if(n!==void 0&&Number.isInteger(n)&&n>=0){let e=t[n];if(e)return[e]}}if(e.pointOwner){let n=sy(e.pointOwner,t);if(n.length)return n}if(`interaction`in e&&e.interaction){let n=(e.interaction.point?[e.interaction.point]:e.interaction.points).flatMap(e=>sy(e,t));if(n.length)return n}return oy(e.key,t,n,r)}function oy(e,t,n,r=t){let i=e=>e===void 0?[]:t===n.points?e:e.filter(e=>t.includes(e)),a=i(n.keys.get(e)),o=a.filter(t=>t.key===e);if(o.length)return o;let s=e;for(;s.includes(`:`);){let e=s.lastIndexOf(`:`);s=s.slice(0,e);let t=i(n.keys.get(s)).filter(e=>e.key===s);if(t.length)return t}if(a.length)return a;let c=i(n.marks.get(e));return c.length?c:r}function sy(e,t){let n=t.filter(t=>t===e);if(n.length)return n;let r=t.filter(t=>t.key===e.key);if(r.length)return r;let i=t.filter(t=>Object.is(t.datum,e.datum)&&(cy(e.datum)||t.datumIndex===e.datumIndex));return i.length===1?i:[]}function cy(e){return typeof e==`object`&&!!e||typeof e==`function`}var ly=[];function uy(e,t,n,r){let i=[],a=[];if(!r&&!t)return{under:i,over:a};for(let o of e.focusGuides??[]){let s=t&&Ey(o,t)?t:null;if(!r&&t&&!s)continue;let c=o.resolve({scene:e,guide:o,focus:s,pointer:n,cursor:r});c&&(o.placement===`under`?i:a).push(c)}return{under:i,over:a}}function dy(e,t){if(!t)return{scene:e,retargeted:!1};let n=!1,r=e=>e.map(e=>{if(e.kind!==`group`)return e;if(e.focus?.retarget){let r=e.focus.points.filter(n=>by(n,t,e.focus.match)),i=iy(e.focus.points),a=_y(gy(e.focus.candidates??e.children,r,e.focus.points,i),r,e.focus.points,i,e.key);return a.length?(n=!0,{...e,focus:{...e.focus,activePoints:r},children:a}):e}let i=r(e.children);return i.some((t,n)=>t!==e.children[n])?{...e,children:i}:e}),i=r(e.nodes);return n?{scene:{...e,nodes:i},retargeted:n}:{scene:e,retargeted:n}}function fy(e,t){if(!e.focus||!t)return new Set;let n=new Set;return Ty(py(e,t),e=>n.add(e.key)),n}function py(e,t){let n=e.focus;if(n.retarget)return e.children;if(n.anchors){let r=n.anchors.filter(e=>by(e,t,n.match));return hy(e.children,r)}let r=n.points.filter(e=>by(e,t,n.match));return my(e.children,r,n.points)}function my(e,t,n){return gy(e,t,n,iy(n))}function hy(e,t){let n=[];for(let r of e){if(r.kind!==`group`){t.some(e=>Sy(r.key,e.key))&&n.push(r);continue}let e=hy(r.children,t);e.length?n.push({...r,children:e}):t.some(e=>e.key.startsWith(`${r.key}:`))&&n.push(r)}return n}function gy(e,t,n,r){let i=[];for(let a of e){if(a.kind!==`group`){ay(a,n,r,ly).some(e=>t.includes(e))&&i.push(a);continue}let e=yy(a,n);if(e){t.includes(e)&&i.push(a);continue}let o=vy(a,n,r);if(o.length){o.some(e=>t.includes(e))&&i.push(a);continue}let s=ay(a,n,r,ly),c=s.length?s:n,l=gy(a.children,t,c,r);l.length&&i.push({...a,children:l})}return i}function _y(e,t,n,r,i){let a=new Map(t.map((e,t)=>[e,t])),o=(e,t)=>{let s=ay(e,n,r,ly).filter(e=>a.has(e)),c=s.length===1?s[0]:void 0,l=e.key;if(c&&e.key!==c.markId){let n=`${i}:selection:${a.get(c)??0}`;l=e.key===c.key?n:e.key.startsWith(`${c.key}:`)?`${n}${e.key.slice(c.key.length)}`:c.key.startsWith(`${e.key}:`)?`${n}:ancestor:${t}`:`${n}:node:${t}`}return e.kind===`group`?{...e,key:l,children:e.children.map((e,n)=>o(e,`${t}:${n}`))}:{...e,key:l}};return e.map((e,t)=>o(e,String(t)))}function vy(e,t,n){let r=yy(e,t);if(r)return[r];if(e.pointOwner){let r=ay(e,t,n,ly);if(r.length)return r}let i=n.keys.get(e.key)?.filter(t=>t.key===e.key);return i===void 0?ly:i.filter(e=>t.includes(e))}function yy(e,t){let n=e.focusCandidateIndex;if(!(n===void 0||!Number.isInteger(n)||n<0))return t[n]}function by(e,t,n){return n===`x`?e.xValue!==void 0&&Cy(e.xValue,t.primary.xValue):n===`y`?e.yValue!==void 0&&Cy(e.yValue,t.primary.yValue):n===`series`?Cy(e.group,t.primary.group):n===`key`?e.key===t.primary.key||e.datum===t.primary.datum:n===`group`?t.group.some(t=>xy(e,t)):xy(e,t.primary)}function xy(e,t){return e===t||e.key===t.key?!0:Object.is(e.datum,t.datum)?wy(e.datum)||e.datumIndex===t.datumIndex:!1}function Sy(e,t){return e===t||e.startsWith(`${t}:`)||t.startsWith(`${e}:`)}function Cy(e,t){return Q(e)===Q(t)}function wy(e){return typeof e==`object`&&!!e||typeof e==`function`}function Ty(e,t){for(let n of e)t(n),n.kind===`group`&&Ty(n.children,t)}function Ey(e,t){return e.scope===void 0||t.primary.key===e.scope||t.primary.key.startsWith(`${e.scope}:`)}function Dy(e,t,n,r,i,a){let o=Py(e.ownerDocument,i({...t,nodes:[n]},r)),s=o&&Iy(o,n.key);if(!o||!s||s.localName!==`g`)throw Error(`The SVG renderer must preserve a g[data-ts-key="${n.key}"] element when serializing focus guides.`);return a&&(s.classList.add(`ts-chart__focus-guide-layer`,`ts-chart__focus-guide-layer--${a}`),s.setAttribute(`data-ts-focus-layer`,a),s.setAttribute(`data-ts-focus-guide-layer`,a),s.setAttribute(`aria-hidden`,`true`),s.setAttribute(`visibility`,n.children.length?`visible`:`hidden`),ky(e.ownerDocument,s,n.children,a,r.idPrefix??``)),Ay(e,o,s,n.key),s.outerHTML}function Oy(e,t,n,r,i,a){let o={kind:`group`,key:`focus-guide-layer:${r}`,className:`ts-chart__focus-guide-layer ts-chart__focus-guide-layer--${r}`,ariaHidden:!0,children:n};return Dy(e,{...t,focusGuides:void 0},o,i,a,r)}function ky(e,t,n,r,i){let a=Fy(e,Vv(n,r,i));if(a)for(let e of Ly(a)){let n=e.getAttribute(`clip-path`),r=e.getAttribute(`data-ts-key`);if(!n||!r)continue;let i=Iy(t,r);if(!i||i.hasAttribute(`clip-path`))continue;i.setAttribute(`clip-path`,n);let o=Iy(a,`${r}:clip-defs`);o&&i.insertBefore(o.cloneNode(!0),i.firstChild)}}function Ay(e,t,n,r){let i=[...My(n)],a=new Set,o;for(;i.length;){let s=i.shift();if(!s||a.has(s)||(a.add(s),Ny(n,s)||jy(e,s)))continue;let c=Ny(t,s);if(!c)continue;o||(o=e.ownerDocument.createElementNS(`http://www.w3.org/2000/svg`,`defs`),o.setAttribute(`data-ts-key`,`${r}:renderer-defs`),n.insertBefore(o,n.firstChild));let l=c.cloneNode(!0);o.append(l),i.push(...My(l))}}function jy(e,t){let n=Ny(e,t);return n?.closest(`[data-ts-focus-guide-layer]`)?void 0:n}function My(e){let t=new Set;for(let n of[e,...e.querySelectorAll(`*`)])for(let e of n.attributes){for(let n of e.value.matchAll(/url\(#([^)]+)\)/g))n[1]&&t.add(n[1]);(e.localName===`href`||e.name===`xlink:href`)&&e.value.startsWith(`#`)&&t.add(e.value.slice(1))}return t}function Ny(e,t){return[...e.getAttribute(`id`)===t?[e]:[],...e.querySelectorAll(`[id]`)].find(e=>e.getAttribute(`id`)===t)}function Py(e,t){let n=e.createElement(`template`);n.innerHTML=t.trim();let r=n.content.firstElementChild;return r?.localName===`svg`?r:void 0}function Fy(e,t){let n=e.createElement(`template`);return n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,n.content.firstElementChild?.firstElementChild??void 0}function Iy(e,t){return Ly(e).find(e=>e.getAttribute(`data-ts-key`)===t)}function Ly(e){return[...e.hasAttribute(`data-ts-key`)?[e]:[],...e.querySelectorAll(`[data-ts-key]`)]}function Ry(e){let t={};if(!e)return t;for(let n of[`under`,`over`]){let r=Uy(e,n);r&&(t[n]=r,r.remove())}return t}function zy(e,t,n=()=>!0){for(let r of[`under`,`over`]){let i=t[r];i&&n(r)&&Hy(e,i,r)}}function By(e,t){let n=Uy(e,t);if(n)return n;let r=e.ownerDocument.createElementNS(`http://www.w3.org/2000/svg`,`g`);return r.dataset.tsKey=`focus-guide-layer:${t}`,r.dataset.tsFocusLayer=t,r.dataset.tsFocusGuideLayer=t,r.setAttribute(`class`,`ts-chart__focus-guide-layer ts-chart__focus-guide-layer--${t}`),r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`visibility`,`hidden`),Hy(e,r,t),r}function Vy(e,t){Uy(e,t)?.remove()}function Hy(e,t,n){if(n===`under`){let n=[...e.children].find(e=>e.getAttribute(`data-ts-key`)===`grid`||e.getAttribute(`data-ts-key`)===`marks`||e.classList.contains(`ts-chart__grid`)||e.classList.contains(`ts-chart__marks`));e.insertBefore(t,n??null)}else e.append(t)}function Uy(e,t){return[...e.children].find(e=>e.localName===`g`&&e.getAttribute(`data-ts-focus-guide-layer`)===t)}function Wy(e,t,n=null){if(!t||!Gy(e.nodes))return{scene:e};let r,i={},a=(e,o,s,c,l)=>e.map(e=>{let u=e.kind===`group`?e.states:void 0,d=u?.points??o,f=u?.definitions??s,p=u?.data??c,m=u?iy(u.points):l,h=d?m?ay(e,d,m):d:Qy,g=e.kind!==`group`&&f&&p&&h.length?Ky(e,h,p,f,t,n):{node:e};if(g.transition){r=$y(r,g.transition);for(let e of h)i[e.markId]=$y(i[e.markId],g.transition)}let _=g.node;return _.kind===`group`?{..._,children:a(_.children,h.length?h:d,f,p,m)}:_}),o=a(e.nodes);return{scene:{...e,nodes:o},transition:r,...Object.keys(i).length?{transitions:i}:{}}}function Gy(e){return e.some(e=>e.kind===`group`&&(e.states!==void 0||Gy(e.children)))}function Ky(e,t,n,r,i,a){let o=e,s;for(let e of r){let r=qy(t,n,e,i,a);r&&(o=Yy(o,e.style,r),e.transition&&(s=$y(s,e.transition)))}return{node:o,transition:s}}function qy(e,t,n,r,i){if(!(typeof n.when!=`function`&&n.when.focus===`unmatched`&&e.some(e=>by(e,r,`group`))))for(let a of e){let e={datum:a.datum,index:a.datumIndex,data:t,point:a,focus:r,pointer:i,matches:e=>by(a,r,e)};if(typeof n.when==`function`?n.when(e):Jy(n.when,e))return e}}function Jy(e,t){let n=e.source;return n!==void 0&&!(Array.isArray(n)?n.includes(t.focus.source):n===t.focus.source)||e.pinned!==void 0&&e.pinned!==t.focus.pinned?!1:e.focus===`unmatched`?!t.matches(`group`):t.matches(e.focus)}function Yy(e,t,n){let r={...e.style};for(let e of Xy){let i=Zy(t[e],n);i!==void 0&&(r[e]=i)}let i={...e,style:r},a=Zy(t.dx,n)??0,o=Zy(t.dy,n)??0,s=Zy(t.r,n),c=Zy(t.radius,n),l=Zy(t.inset,n),u=Zy(t.fontSize,n),d=Zy(t.fontWeight,n),f=Zy(t.rotate,n);switch(i.kind){case`dot`:i={...i,x:i.x+a,y:i.y+o,radius:s??i.radius};break;case`rect`:{let e=i.inset??0,t=Math.max(0,l??e);if(Number.isFinite(i.maxThickness)&&(i.insetAxis===`x`||i.insetAxis===`y`)){let n=(i.insetAxis===`x`?i.width:i.height)+e*2,r=Math.max(0,n-t*2);t=(n-Math.min(r,Math.max(0,i.maxThickness)))/2}let n=t-e,r=i.insetAxis===`y`?0:n,s=i.insetAxis===`x`?0:n,u=Math.max(0,i.width-r*2),d=Math.max(0,i.height-s*2),f=i.cornerRadii!==void 0,p=c===void 0?i.cornerRadii:typeof c==`number`?f?[c,c,c,c]:void 0:c;i={...i,x:i.x+r+a,y:i.y+s+o,width:u,height:d,radius:c===void 0?i.radius:typeof c==`number`&&!f?c:void 0,cornerRadii:p,inset:t};break}case`label`:i={...i,x:i.x+a,y:i.y+o,fontSize:u??i.fontSize,fontWeight:d??i.fontWeight,rotate:f??i.rotate}}return i}var Xy=[`fill`,`fillOpacity`,`stroke`,`strokeOpacity`,`strokeWidth`,`opacity`,`strokeDasharray`];function Zy(e,t){return typeof e==`function`?e(t):e}var Qy=[];function $y(e,t){return!e||e.type!==t.type?t:e.type===`spring`&&t.type===`spring`?{...e,...t}:e.type!==`tween`||t.type!==`tween`?t:{...e,...t,duration:Math.max(e.duration??250,t.duration??250)}}function eb(e,t){if(!e||e.type!==`tween`||(e.respectReducedMotion??!0)&&t.ownerDocument.defaultView?.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)return;let{type:n,...r}=e;return r}function tb(e,t,n,r){let i=e.getScreenCTM?.();if(!i){let i=e.getBoundingClientRect();return!i.width||!i.height?null:{x:(n-i.left)/i.width*t.width,y:(r-i.top)/i.height*t.height}}let a;try{a=i.inverse()}catch{return null}let o=a.a*n+a.c*r+a.e,s=a.b*n+a.d*r+a.f;return!Number.isFinite(o)||!Number.isFinite(s)?null:{x:o,y:s}}function nb(e=Qv){let t={id:`svg`,prerender:(t,n)=>ib(t,n,null,e),mount(n){let r=()=>{},i=()=>{},a,o,s,c=!1,l=!1,u=null,d=!1,f=()=>{let e=n.querySelector(`svg.ts-chart`);if(!e)throw Error(`The SVG renderer must produce an svg.ts-chart root element.`);return e},p=()=>{d||(d=!0,a&&o&&rb(f(),a,u,o,e,`all`))};return{renderer:t,get element(){return f()},render(t,m){let h=!!(a&&wg(a,t));m.animation&&p(),r(),i(),i=()=>{};let g=!!a?.focusGuides?.length,_=g?Ry(f()):{};r=_v(n,d?e(t,m):ib(t,m,u,e),h?void 0:m.animation),g&&zy(f(),_,e=>t.focusGuides?.some(t=>t.placement===e)===!0),a=t,o=m,s=void 0,c=!1,l=!1},clientToScene(e,t,n){return tb(f(),e,t,n)},paintFocus(t,m,h){if(!a||!o)return;let g=Wy(a,t,m),_=dy(g.scene,t),v=s,y=eb(g.transition??v,n);if(y&&p(),_.scene!==a||c||l||v){i(),i=()=>{};let a=Ry(f());r(),r=_v(n,d?e(_.scene,o):ib(_.scene,o,t,e),y),zy(f(),a)}return l=_.retargeted,c=!!(t&&g.scene!==a),s=t?g.transition??v:void 0,u=t,rb(f(),_.scene,t,o,e,!d),i(),i=ab(f(),_.scene,t,m,h,o,e),_.scene},destroy(){r(),i()}}}};return t}function rb(e,t,n,r,i,a){let o=ob(t.nodes);e.querySelectorAll(`[data-ts-focus-layer]:not([data-ts-focus-guide-layer])`).forEach((s,c)=>{let l=o[c];if(l&&a&&kg(l)){let o=a===`all`?l.children:n?py(l,n):[],c=[...s.children].filter(e=>e.localName===`circle`);(c.length!==o.length||c.some((e,t)=>e.getAttribute(`data-ts-key`)!==o[t]?.key))&&vv(s,Dy(e,t,{...l,children:o},r,i))}let u=l?fy(l,n):new Set;s.setAttribute(`visibility`,n&&u.size?`visible`:`hidden`),s.querySelectorAll(`[data-ts-key]`).forEach(e=>{let t=e.dataset.tsKey;e.setAttribute(`visibility`,t&&u.has(t)?`visible`:`hidden`)})})}function ib(e,t,n,r){return Rv(t,e=>kg(e)?n?py(e,n):[]:void 0,()=>r(e,t))}function ab(e,t,n,r,i,a,o){let s=uy(t,n,r,i),c=[];for(let n of[`under`,`over`]){if(!t.focusGuides?.some(e=>e.placement===n)){Vy(e,n);continue}let r=By(e,n),i=s[n];if(!i.length){r.setAttribute(`visibility`,`hidden`);continue}let l=o===Qv?Vv(i,n,a.idPrefix??``):Oy(e,t,i,n,a,o);c.push(vv(r,l))}return()=>c.forEach(e=>e())}function ob(e){let t=[];for(let n of e)n.kind===`group`&&(n.focus?t.push(n):t.push(...ob(n.children)));return t}function sb(e){let t=T_(),n=e,r,i=()=>t??=T_();return{prerender(){let e=D_(n),t=i().render(n.definition,{width:e.initialWidth,height:e.initialHeight},{measureText:n.measureText});return $_(t,n.renderer).prerender(t,{ariaLabel:n.ariaLabel,ariaDescription:n.ariaDescription,className:n.className,tabIndex:O_(n.definition,n.tabIndex),idPrefix:n.idPrefix})},mount(e){if(r)throw Error(`This chart adapter is already mounted.`);r=rv(e,n,i())},update(e){n=e,r?.update(e)},getScene(){return r?.getScene()},destroy(){r?(r.destroy(),r=void 0,t=void 0):t&&=(t.destroy(),void 0)}}}var cb=class extends Map{constructor(e,t=fb){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(lb(this,e))}has(e){return super.has(lb(this,e))}set(e,t){return super.set(ub(this,e),t)}delete(e){return super.delete(db(this,e))}};function lb({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function ub({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function db({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function fb(e){return typeof e==`object`&&e?e.valueOf():e}function pb(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function mb(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}var hb=Symbol(`implicit`);function gb(){var e=new cb,t=[],n=[],r=hb;function i(i){let a=e.get(i);if(a===void 0){if(r!==hb)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new cb;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return gb(t,n).unknown(r)},mb.apply(i,arguments),i}function _b(){var e=gb().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=pb(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return _b(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},mb.apply(d(),arguments)}function vb(e){return e?.some(({style:e})=>{let t=e.radius;return typeof t==`function`||Array.isArray(t)})??!1}function yb(e,t){return e===void 0?t?{cornerRadii:[0,0,0,0]}:{}:typeof e==`number`?t?{cornerRadii:[e,e,e,e]}:{radius:e}:{cornerRadii:e}}var bb=Symbol(`scene-motion-node`);function xb(e,t,n,r,i,a={},o=`value`){let s=wb(e,t,n,r,i,o),c=Tb(s,a.order);a.reverse&&c.reverse();let l=new Map(c.map((e,t)=>[Q(e),t])),u=[...s].sort((e,t)=>l.get(Q(e.series))-l.get(Q(t.series))),d=Array.from({length:e.length}),f=Sb(s),p=Sb(u),m=a.offset===void 0||a.offset===`diverging`;for(let[e,t]of p){let n=f.get(e);if(m){let e=Math.min(...t.flatMap(e=>[e.start,e.end]));Math.max(...t.flatMap(e=>[e.start,e.end]))>0&&Cb(t,n,`max`,d),e<0&&Cb(t,n,`min`,d)}else{let e=t[0].start,r=t.at(-1).end,i;if(r<e)i=`min`;else if(r>e)i=`max`;else{let n=Math.min(...t.flatMap(e=>[e.start,e.end])),r=Math.max(...t.flatMap(e=>[e.start,e.end]));i=e-n>r-e?`min`:`max`}Cb(t,n,i,d)}}return d}function Sb(e){let t=new Map;for(let n of e){if(n.value===0||n.start===n.end)continue;let e=Q(n.position),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Cb(e,t,n,r){if(e.length===0)return;let i=Math[n](...e.flatMap(e=>[e.start,e.end]));for(let e of t){let t=e.start===i,n=e.end===i;if(!t&&!n)continue;let a=r[e.index];r[e.index]={start:a?.start===!0||t,end:a?.end===!0||n}}}function wb(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s+=1){let c=e[s],l=t[s],u=r[s],d=i[s];if(!Db(c)||!Ob(l)||!Ob(u)||!Ob(d))continue;let f=n[s];o.push({index:s,position:c,value:l,start:u,end:d,series:Eb(f)?f:a===`index`?s:`value`})}return o}function Tb(e,t){let n=[],r=new Set;for(let t of e){let e=Q(t.series);r.has(e)||(r.add(e),n.push(t.series))}if(Array.isArray(t)){let e=[...t],r=new Set(e.map(Q));return[...e,...n.filter(e=>!r.has(Q(e)))]}if(t===`inside-out`){let t=[],r=new Map;for(let n of e){let e=Q(n.position);r.has(e)||(r.set(e,t.length),t.push(n.position))}return Wm(n.map(n=>{let i=Q(n),a=t.map(()=>[0,0]);for(let t of e)Q(t.series)===i&&(a[r.get(Q(t.position))][1]=t.value);return a})).map(e=>n[e])}if(t!==`ascending`&&t!==`descending`)return n;let i=new Map(n.map(e=>[Q(e),0]));for(let t of e){let e=Q(t.series);i.set(e,(i.get(e)??0)+Math.abs(t.value))}return n.sort((e,n)=>{let r=(i.get(Q(e))??0)-(i.get(Q(n))??0);return t===`ascending`?r:-r})}function Eb(e){return typeof e==`string`||typeof e==`number`}function Db(e){return typeof e==`string`||Ob(e)||e instanceof Date&&Number.isFinite(e.getTime())}function Ob(e){return typeof e==`number`&&Number.isFinite(e)}function kb(e,t={}){let n=Array.isArray(e)?e:Array.from(e),r=t.xScale??`x`,i=t.yScale??`y`,a=typeof t.radius==`function`||vb(t.states);return bm(({markIndex:e})=>{let o=t.id??`bar-y-${e}`,s=Em(n,t.x,(e,{index:t})=>t),c=zb(n,t.y??t.y2,e=>typeof e==`number`?e:void 0),l=Em(n,t.z,()=>null),u=t.color===void 0?l:Em(n,t.color,()=>null),d=t.z===void 0&&t.color!==void 0?u:l,f=t.y1!==void 0||t.y2!==void 0;if(f&&t.layout?.type===`stack`)throw TypeError(`A bar with explicit y1 or y2 endpoints cannot also configure a stack layout`);let p=t.layout?.type===`group`;jb(t.radius,f,p,`y`);let m=t.layout?.type===`stack`?t.layout:void 0,h=Nb(t.radius)?t.radius:void 0,g=m?.offset===void 0||m.offset===`diverging`,_=!f&&!p?Xm(s,c,d,m,`index`):void 0,v=_&&h&&(h.stack??`outer`)===`outer`?xb(s,c,d,_.starts,_.ends,m,`index`):void 0,y=f?zb(n,t.y1,()=>0):_?.starts??n.map(()=>0),b=f?zb(n,t.y2??t.y,()=>void 0):p?c:_.ends,x=Lb(s),S=p||!f&&x?d:l,C=Dm(n,t.key,{groups:S,candidates:[s],markId:o,warningIdentity:t});return{id:o,states:wm(n,t.states),seriesFromColor:t.z===void 0&&t.color!==void 0&&(p||x),channels:{x:{scale:r,values:s.filter(vm)},y:{scale:i,values:[...b.filter(ym),...y.filter(ym)],includeZero:t.y1===void 0},color:{scale:`color`,values:u.filter(dm)}},render:({scales:e,chart:l,color:d})=>{let f=e[r].bandwidth||Rb(e[r],s,l.width,n.length),p=Ib(t.layout?.type===`group`?t.layout:void 0,S,f),m=p?.bandwidth??f,h=Fb(m,t.inset,t.maxThickness),x=[];return n.forEach((l,w)=>{let T=s[w],E=c[w],D=y[w],O=b[w];if(!vm(T)||!ym(E)||!ym(D)||!ym(O))return;let k=S[w]??null,A=p?.map(k)??0,j=d(u[w]),M=Tm(t.fill,l,w,n,j),ee=Tm(t.stroke,l,w,n,`none`),N=Tm(t.strokeDasharray,l,w,n,`none`),P=e[r].map(T),F=e[i].map(D),I=e[i].map(O),te=_&&g&&E<0?`start`:`end`,ne=te===`start`?F:I,re=te===`start`?I:F,ie=v?.[w],ae=P-f/2+A+h.inset,oe=Math.min(F,I),se=h.size,ce=Math.abs(F-I),le=`${o}:${Q(k)}:${Q(C[w])}`,ue=Mb(t.radius,l,w,n,`y`,ne,re,v!==void 0,ie,F,I,a),de={key:le,markId:o,group:k,groupLabel:k==null?o:String(k),datum:l,datumIndex:w,xValue:T,yValue:E,y1Value:D,y2Value:O,yInterval:`difference`,x:P-f/2+A+m/2,y:ne,color:M},fe={kind:`rect`,key:le,x:ae,y:oe,width:se,height:ce,...ue,inset:h.inset,insetAxis:`x`,...h.maximum===void 0?{}:{maxThickness:h.maximum},interaction:{point:de,affinity:`x`},style:{fill:M,fillOpacity:t.fillOpacity,stroke:ee,strokeOpacity:t.strokeOpacity,strokeWidth:t.strokeWidth,strokeDasharray:N},[bb]:{bar:{baseline:re}}};x.push(fe)}),{nodes:[{kind:`group`,key:o,className:`ts-chart__bar ts-chart__bar-y`,ariaHidden:!0,children:x}]}}}},t.motion,t.renderer)}function Ab(e,t={}){let n=Array.isArray(e)?e:Array.from(e),r=t.xScale??`x`,i=t.yScale??`y`,a=typeof t.radius==`function`||vb(t.states);return bm(({markIndex:e})=>{let o=t.id??`bar-x-${e}`,s=zb(n,t.x??t.x2,e=>typeof e==`number`?e:void 0),c=Em(n,t.y,(e,{index:t})=>t),l=Em(n,t.z,()=>null),u=t.color===void 0?l:Em(n,t.color,()=>null),d=t.z===void 0&&t.color!==void 0?u:l,f=t.x1!==void 0||t.x2!==void 0;if(f&&t.layout?.type===`stack`)throw TypeError(`A bar with explicit x1 or x2 endpoints cannot also configure a stack layout`);let p=t.layout?.type===`group`;jb(t.radius,f,p,`x`);let m=t.layout?.type===`stack`?t.layout:void 0,h=Nb(t.radius)?t.radius:void 0,g=m?.offset===void 0||m.offset===`diverging`,_=!f&&!p?Xm(c,s,d,m,`index`):void 0,v=_&&h&&(h.stack??`outer`)===`outer`?xb(c,s,d,_.starts,_.ends,m,`index`):void 0,y=f?zb(n,t.x1,()=>0):_?.starts??n.map(()=>0),b=f?zb(n,t.x2??t.x,()=>void 0):p?s:_.ends,x=Lb(c),S=p||!f&&x?d:l,C=Dm(n,t.key,{groups:S,candidates:[c],markId:o,warningIdentity:t});return{id:o,states:wm(n,t.states),seriesFromColor:t.z===void 0&&t.color!==void 0&&(p||x),channels:{x:{scale:r,values:[...b.filter(ym),...y.filter(ym)],includeZero:t.x1===void 0},y:{scale:i,values:c.filter(vm)},color:{scale:`color`,values:u.filter(dm)}},render:({scales:e,chart:l,color:d})=>{let f=e[i].bandwidth||Rb(e[i],c,l.height,n.length),p=Ib(t.layout?.type===`group`?t.layout:void 0,S,f),m=p?.bandwidth??f,h=Fb(m,t.inset,t.maxThickness),x=[];return n.forEach((l,w)=>{let T=s[w],E=y[w],D=b[w],O=c[w];if(!ym(T)||!ym(E)||!ym(D)||!vm(O))return;let k=S[w]??null,A=p?.map(k)??0,j=d(u[w]),M=Tm(t.fill,l,w,n,j),ee=Tm(t.stroke,l,w,n,`none`),N=Tm(t.strokeDasharray,l,w,n,`none`),P=e[r].map(E),F=e[r].map(D),I=_&&g&&T<0?`start`:`end`,te=I===`start`?P:F,ne=I===`start`?F:P,re=v?.[w],ie=e[i].map(O),ae=ie-f/2+A+h.inset,oe=Math.min(P,F),se=Math.abs(P-F),ce=h.size,le=`${o}:${Q(k)}:${Q(C[w])}`,ue=Mb(t.radius,l,w,n,`x`,te,ne,v!==void 0,re,P,F,a),de={key:le,markId:o,group:k,groupLabel:k==null?o:String(k),datum:l,datumIndex:w,xValue:T,yValue:O,x1Value:E,x2Value:D,xInterval:`difference`,x:te,y:ie-f/2+A+m/2,color:M},fe={kind:`rect`,key:le,x:oe,y:ae,width:se,height:ce,...ue,inset:h.inset,insetAxis:`y`,...h.maximum===void 0?{}:{maxThickness:h.maximum},interaction:{point:de,affinity:`y`},style:{fill:M,fillOpacity:t.fillOpacity,stroke:ee,strokeOpacity:t.strokeOpacity,strokeWidth:t.strokeWidth,strokeDasharray:N},[bb]:{bar:{baseline:ne}}};x.push(fe)}),{nodes:[{kind:`group`,key:o,className:`ts-chart__bar ts-chart__bar-x`,ariaHidden:!0,children:x}]}}}},t.motion,t.renderer)}function jb(e,t,n,r){if(Nb(e)&&e.stack===`outer`){if(t)throw TypeError(`Bar radius stack "outer" requires an implicit ${r} extent`);if(n)throw TypeError(`Bar radius stack "outer" cannot be used with a group layout`)}}function Mb(e,t,n,r,i,a,o,s,c,l,u,d){if(e===void 0)return yb(void 0,d);if(Nb(e)){let d=Tm(e.end,t,n,r,0);if(a===o)return{cornerRadii:[0,0,0,0]};if(s){if(!c)return{cornerRadii:[0,0,0,0]};if(c.start&&c.end)return{cornerRadii:[d,d,d,d]};let e=c.start;return{cornerRadii:Pb(d,i,e?l:u,e?u:l)}}return{cornerRadii:Pb(d,i,a,o)}}return yb(Tm(e,t,n,r,0),d)}function Nb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pb(e,t,n,r){return t===`y`?n<=r?[e,e,0,0]:[0,0,e,e]:n<=r?[e,0,0,e]:[0,e,e,0]}function Fb(e,t,n){let r=Math.max(0,t??0),i=Math.max(0,e),a=Math.max(0,i-r*2),o=Number.isFinite(n),s=o?Math.max(0,n):a,c=Math.min(a,s);return{inset:(i-c)/2,maximum:o?s:void 0,size:c}}function Ib(e,t,n){if(!e)return;let r=rm(e.scale??(()=>_b().padding(Number.isFinite(e.padding)?Math.max(0,e.padding):.1)),{values:t});r.range([0,n]);let i=r.bandwidth?.();if(i===void 0)throw TypeError(`A grouped bar layout requires a D3 band scale`);return{bandwidth:i,map(e){if(e===null)throw TypeError(`A grouped bar requires an explicit z channel or a discrete color channel`);let t=r(e);if(t===void 0||!Number.isFinite(t))throw TypeError(`Bar group value "${String(e)}" is outside the group layout scale domain`);return t}}}function Lb(e){let t=new Set;for(let n of e){if(!vm(n))continue;let e=Q(n);if(t.has(e))return!0;t.add(e)}return!1}function Rb(e,t,n,r){let i=[...new Set(t.filter(vm).map(e.map).filter(e=>Number.isFinite(e)))].sort((e,t)=>e-t),a=1/0;for(let e=1;e<i.length;e+=1)a=Math.min(a,i[e]-i[e-1]);return Number.isFinite(a)?a*.8:Math.min(48,n/Math.max(2,r+1)*.8)}function zb(e,t,n){return typeof t==`number`?e.map(()=>t):Em(e,t,n)}function Bb(e,t=String){return e.domain.map(n=>({key:Q(n),value:n,label:t(n),color:e.map(n)}))}function Vb(e,t,n){let r=Math.max(1,Math.min(e||1,Math.floor(t/n)||1));return{columns:r,rows:Math.ceil(e/r),itemWidth:t/r}}function Hb(e={}){let t=Xb({label:e.label,width:e.width,format:e.format,placement:e.placement}),n=e.items,r=Math.max(64,e.itemWidth??110);return{placement:e.placement,height(i,a){if(Kb(a.colors.kind))return t.height(i,a);if(n)return 18+n(a,r,e.label);let o=e.label?13:0,s=Vb(i,a.chart.width,r);return 18+o+s.rows*19},render(i){if(Wb(i.colors.kind))return t.render(i);if(Gb(i.colors.kind))return qb(e,i);let{bounds:a,theme:o,direction:s}=i,c=[];if(n)c.push(...n(i,r,e.label,!0));else{let t=e.label?13:0;e.label&&c.push({kind:`label`,key:`legend-label`,x:a.x,y:a.y+11,text:e.label,anchor:vh(`left`,s),fontSize:11,fontWeight:600,style:{fill:o.foreground,fillOpacity:.78}}),c.push(...Ub(i,t,r))}return{kind:`group`,key:`legend`,className:`ts-chart__legend`,ariaHidden:!0,children:c}}}}function Ub({colors:e,bounds:t,theme:n,direction:r},i,a){let o=Bb(e),s=Vb(o.length,t.width,a),c=[];return o.forEach((e,a)=>{let o=a%s.columns,l=Math.floor(a/s.columns),u=t.x+o*s.itemWidth,d=t.y+10+i+l*19;c.push({kind:`dot`,key:`legend-dot:${e.key}`,x:u+4,y:d,radius:4,style:{fill:e.color}},{kind:`label`,key:`legend-label:${e.key}`,x:u+13,y:d,text:e.label,anchor:vh(`left`,r),baseline:`middle`,fontSize:11,style:{fill:n.foreground,fillOpacity:.76}})}),c}function Wb(e){return e===`continuous`}function Gb(e){return e===`quantile`||e===`quantize`||e===`threshold`}function Kb(e){return Wb(e)||Gb(e)}function qb(e,{colors:t,bounds:n,theme:r,direction:i}){let a=Math.min(n.width,Math.max(80,e.width??240)),o=n.x,s=n.y+(e.label?20:7),c=a/Math.max(1,t.range.length),l=e.format??(e=>String(e)),u=[];e.label&&u.push({kind:`label`,key:`legend-label`,x:o,y:n.y+10,text:e.label,anchor:vh(`left`,i),fontSize:11,fontWeight:600,style:{fill:r.foreground,fillOpacity:.78}}),t.range.forEach((e,t)=>{u.push({kind:`rect`,key:`legend-step:${t}`,x:o+t*c,y:s,width:c+.5,height:8,style:{fill:e}})});let d=Jb(t),f=t.domain[0],p=t.domain.at(-1);return(t.kind===`threshold`?d.map((e,t)=>({value:e,index:t+1,side:`middle`})):[...typeof f==`number`?[{value:f,index:0,side:`left`}]:[],...d.map((e,t)=>({value:e,index:t+1,side:`middle`})),...typeof p==`number`?[{value:p,index:t.range.length,side:`right`}]:[]]).forEach(({value:e,index:t,side:n})=>{u.push({kind:`label`,key:`legend-step-label:${t}:${e}`,x:o+t*c,y:s+21,text:l(e),anchor:vh(n,i),fontSize:10,style:{fill:r.muted,fillOpacity:.72}})}),{kind:`group`,key:`legend`,className:`ts-chart__legend ts-chart__legend--stepped`,ariaHidden:!0,children:u}}function Jb(e){if(e.thresholds)return e.thresholds.filter(Number.isFinite);let t=e.domain.filter(e=>typeof e==`number`&&Number.isFinite(e));if(e.kind===`threshold`)return t;let n=t.slice().sort((e,t)=>e-t),r=n[0],i=n.at(-1);if(r===void 0||i===void 0)return[];let a=e.range.length;return e.kind===`quantize`?Array.from({length:Math.max(0,a-1)},(e,t)=>r+(i-r)*(t+1)/a):e.kind===`quantile`?Array.from({length:Math.max(0,a-1)},(e,t)=>Yb(n,(t+1)/a)).filter(Number.isFinite):[]}function Yb(e,t){let n=e.length;if(n===0)return NaN;if(t<=0||n<2)return e[0]??NaN;if(t>=1)return e[n-1]??NaN;let r=(n-1)*t,i=Math.floor(r),a=e[i]??NaN;return a+((e[i+1]??a)-a)*(r-i)}function Xb(e={}){return{placement:e.placement,height(){return e.label?55:42},render({colors:t,bounds:n,theme:r,direction:i}){let a=t.domain[0],o=t.domain.at(-1);if(typeof a!=`number`||typeof o!=`number`)throw TypeError(`A gradient legend requires a numeric color-scale domain`);let s=Math.max(2,Math.floor(e.steps??32)),c=Math.min(n.width,Math.max(80,e.width??240)),l=n.x,u=n.y+(e.label?20:7),d=c/s,f=e.format??(e=>String(e)),p=[];e.label&&p.push({kind:`label`,key:`legend-label`,x:l,y:n.y+10,text:e.label,anchor:vh(`left`,i),fontSize:11,fontWeight:600,style:{fill:r.foreground,fillOpacity:.78}});for(let e=0;e<s;e+=1){let n=e/(s-1),r=a+(o-a)*n;p.push({kind:`rect`,key:`legend-gradient:${e}`,x:l+e*d,y:u,width:d+.5,height:8,style:{fill:t.map(r)}})}return p.push({kind:`label`,key:`legend-gradient:min`,x:l,y:u+21,text:f(a),anchor:vh(`left`,i),fontSize:10,style:{fill:r.muted,fillOpacity:.72}},{kind:`label`,key:`legend-gradient:max`,x:l+c,y:u+21,text:f(o),anchor:vh(`right`,i),fontSize:10,style:{fill:r.muted,fillOpacity:.72}}),{kind:`group`,key:`legend`,className:`ts-chart__legend ts-chart__legend--gradient`,ariaHidden:!0,children:p}}}}function Zb(e={}){return{type:`stack`,...e}}function Qb(e){return e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`}function $b(e){let t=[],n=new Map;for(let r of e){let e=Qb(r);n.has(e)||(n.set(e,t.length),t.push(r))}return{domain:t,index:n}}function ex(e,t,n){let r=[],i=new Map,a=[],o=[0,1],s=1,c=+!e,l=!1,u=+!!e,d=0,f=.5,p=(e=>{let t=i.get(Qb(e));return t===void 0?void 0:a[t]}),m=()=>{let e=r.length,t=o[1]<o[0],n=t?o[1]:o[0],i=t?o[0]:o[1];return s=(i-n)/Math.max(1,e-u+d*2),l&&(s=Math.floor(s)),n+=(i-n-s*(e-u))*f,c=s*(1-u),l&&(n=Math.round(n),c=Math.round(c)),a=Array.from({length:e},(e,t)=>n+s*t),t&&a.reverse(),p};if(p.domain=(e=>{if(e===void 0)return r.slice();let t=$b(e);return r=t.domain,i=t.index,m()}),p.range=(e=>e===void 0?[...o]:(o=tx(e),m())),p.rangeRound=e=>(o=tx(e),l=!0,m()),p.bandwidth=()=>c,p.step=()=>s,p.round=(e=>e===void 0?l:(l=!!e,m())),p.padding=(e=>e===void 0?u:(d=nx(e),u=Math.min(1,d),m())),p.paddingInner=(e=>e===void 0?u:(u=Math.min(1,nx(e)),m())),p.paddingOuter=(e=>e===void 0?d:(d=nx(e),m())),p.align=(e=>e===void 0?f:(f=Math.max(0,Math.min(1,nx(e))),m())),p.copy=()=>ex(!1,r,o).round(l).paddingInner(u).paddingOuter(d).align(f),e){let e=p;e.bandwidth=()=>0,e.padding=p.paddingOuter,e.copy=()=>ex(!0,r,o).round(l).padding(d).align(f),delete e.paddingInner,delete e.paddingOuter}return m(),n===void 0?t!==void 0&&p.range(t):p.domain(t).range(n),p}function tx(e){let t=Array.from(e,nx);if(t.length!==2||t.some(e=>!Number.isFinite(e)))throw TypeError(`A scale range requires exactly two finite numbers`);return[t[0],t[1]]}function nx(e){return Number(e)}function rx(e,t){return ex(!1,e,t)}var ix=[1,2,5,10];function ax(e,t,n){if(!(n>0))return[];if(e===t)return[e];let r=t<e,i=cx(r?t:e,r?e:t,n);return i.lastIndex>=i.firstIndex?Array.from({length:i.lastIndex-i.firstIndex+1},(e,t)=>px(r?i.lastIndex-t:i.firstIndex+t,i.interval)):[]}function ox(e,t,n){return cx(e,t,n).interval}function sx(e,t,n){let r=t<e,i=ox(r?t:e,r?e:t,n),a=i<0?-1/i:i;return r?-a:a}function cx(e,t,n){let r=n;for(;;){let n=lx(e,t,r),i=dx(e,n),a=fx(t,n);if(a>=i||!(r>=.5&&r<2))return{firstIndex:i,lastIndex:a,interval:n};r*=2}}function lx(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=10**i,o=ux(r/a);return i<0?-(10**-i)/o:a*o}function ux(e){let t=ix[0];for(let n of ix.slice(1)){if(!(e>=Math.sqrt(t*n)))break;t=n}return t}function dx(e,t){let n=t<0?e*-t:e/t,r=Math.round(n);return r<n?r+1:r}function fx(e,t){let n=t<0?e*-t:e/t,r=Math.round(n);return r>n?r-1:r}function px(e,t){return t<0?e/-t:e*t}function mx(e,t){let n=[0,1],r=[0,1],i=!1,a=(e=>{if(e!=null&&Number.isFinite(Number(e)))return hx(Number(e),n,r,i)});return a.domain=(e=>e===void 0?[...n]:(n=gx(e,`domain`),a)),a.range=(e=>e===void 0?[...r]:(r=gx(e,`range`),a)),a.invert=e=>hx(e,r,n,i),a.clamp=(e=>e===void 0?i:(i=!!e,a)),a.ticks=(e=10)=>ax(n[0],n[1],e),a.tickFormat=(e=10)=>{let t=Math.abs(sx(n[0],n[1],e)),r=t>0&&t<1?Math.min(20,Math.max(0,-Math.floor(Math.log10(t)))):0;return e=>{let t=r?e.toFixed(r):String(e);return t===`-0`?`0`:t}},a.nice=(e=10)=>{let t=n[0],r=n[1],i=0,o=1;r<t&&([t,r]=[r,t],[i,o]=[o,i]);let s;for(let a=10;a>0;a--){let a=ox(t,r,e);if(a===s){let e=[...n];e[i]=t,e[o]=r,n=e;break}if(a>0)t=Math.floor(t/a)*a,r=Math.ceil(r/a)*a;else if(a<0)t=Math.ceil(t*a)/a,r=Math.floor(r*a)/a;else break;s=a}return a},a.copy=()=>mx(n,r).clamp(i),t===void 0?e!==void 0&&a.range(e):a.domain(e).range(t),a}function hx(e,t,n,r){let i=t[1]-t[0],a=i?(e-t[0])/i:.5;return r&&(a=Math.max(0,Math.min(1,a))),n[0]+a*(n[1]-n[0])}function gx(e,t){let n=Array.from(e,Number);if(n.length!==2||n.some(e=>!Number.isFinite(e)))throw TypeError(`A linear scale ${t} requires exactly two finite numbers`);return[n[0],n[1]]}var _x=[`top`,`bottom`,`right`,`left`];function vx(e,t,n,r,i){let a=i!==void 0&&Number.isFinite(i)?Math.max(0,i):10,o=n.left+8,s=n.top+8,c=Math.max(o,n.right-8-t.width),l=Math.max(s,n.bottom-8-t.height),u=(r===void 0||r===`auto`?_x:Array.isArray(r)?r.length?r:_x:[r]).map(n=>yx(n,e.x,e.y,t.width,t.height,a)),d=u[0],f=bx(d,t.width,t.height,n,8);for(let e of u){let r=bx(e,t.width,t.height,n,8);if(r===0){d=e;break}r<f&&(d=e,f=r)}return{left:xx(d.left,o,c),top:xx(d.top,s,l),placement:d.placement}}function yx(e,t,n,r,i,a){let o=e.endsWith(`right`)||e===`right`?1:e.endsWith(`left`)||e===`left`?-1:0,s=e.startsWith(`bottom`)||e===`bottom`?1:e.startsWith(`top`)||e===`top`?-1:0;return{placement:e,left:t+(o-1)*r/2+o*a,top:n+(s-1)*i/2+s*a}}function bx(e,t,n,r,i){return Math.max(0,r.left+i-e.left)+Math.max(0,e.left+t+i-r.right)+Math.max(0,r.top+i-e.top)+Math.max(0,e.top+n+i-r.bottom)}function xx(e,t,n){return Math.max(t,Math.min(n,e))}function Sx(e,t,n,r,i,a){let o=e.offsetWidth,s=e.offsetHeight,c=vx({x:t,y:n},{width:o,height:s},r,i,a);e.style.left=`${c.left}px`,e.style.top=`${c.top}px`,e.dataset.placement=c.placement}function Cx(e,t,n){if(n===`focus`)return[...e];if(typeof n==`function`)return[...e].sort(n);if(n!==`color-domain`){let t=e[0],n=t!==void 0&&e.every(e=>Rx(e.xValue,t.xValue)),r=t!==void 0&&e.every(e=>Rx(e.yValue,t.yValue));return[...e].sort((e,t)=>r&&!n?e.x-t.x||e.y-t.y:e.y-t.y||e.x-t.x)}return[...e].sort((e,n)=>Lx(t,e.group)-Lx(t,n.group))}function wx(e,t,n=!1,r,i){let a=e[0];if(!a)return{rows:[]};let o={...Dx(t,n,r),primaryPoint:i},s=r?.content?.(e,o);if(s!==void 0)return s;let c=r?.formatGroup?.(e,o)??r?.format?.(i??a,o);return c===void 0?Ox(e,t,r,o):c}function Tx(e,t,n,r,i,a={primary:e,group:t,source:`programmatic`,pinned:!1}){let o={x:e.x,y:e.y},s=i?.anchor??`point`;if(s===`point`)return o;if(s===`pointer`)return r??o;if(s===`group-center`){let n=e.x,r=e.x,i=e.y,a=e.y;for(let e of t)n=Math.min(n,e.x),r=Math.max(r,e.x),i=Math.min(i,e.y),a=Math.max(a,e.y);return{x:(n+r)/2,y:(i+a)/2}}if(typeof s==`object`)return{x:Ix(`x`,s.x,e,t,n,r,o.x),y:Ix(`y`,s.y,e,t,n,r,o.y)};let c=s(t,{focus:a,pointer:r,plot:n.chart,surface:{width:n.width,height:n.height},scales:n.scales});return c&&Number.isFinite(c.x)&&Number.isFinite(c.y)?c:o}function Ex(e){return e instanceof Date?Number.isNaN(+e)?`Invalid Date`:e.toISOString().replace(`T00:00:00.000Z`,``):typeof e==`number`?e.toLocaleString():String(e)}function Dx(e,t,n){let r=Ax(n?.items,`x`),i=Ax(n?.items,`y`);return{pinned:t,xLabel:r?.label??Fx(e,`x-label`)??`x`,yLabel:i?.label??Fx(e,`y-label`)??`y`,formatX:Ex,formatY:Ex}}function Ox(e,t,n,r){let i=e[0];if(!i)return{rows:[]};let a=Ax(n?.items,`x`),o=Ax(n?.items,`y`),s=Ax(n?.items,`group`),c=e.length>1&&e.every(e=>Rx(e.xValue,i.xValue)),l=e.length>1&&e.every(e=>Rx(e.yValue,i.yValue));if(c||l){let n=c?`x`:`y`,l=c?a:o,u=l?.label??Fx(t,`${n}-label`),d=Px(i,n,l,r);return{title:u?`${u}: ${d}`:d,rows:e.map(e=>({label:Nx(e,s,r),value:Px(e,c?`y`:`x`,c?o:a,r),color:e.color,active:e===r.primaryPoint}))}}if(e.length>1)return{rows:e.map(e=>({label:Nx(e,s,r),value:`${Px(e,`x`,a,r)} \xB7 ${Px(e,`y`,o,r)}`,color:e.color,active:e===r.primaryPoint}))};let u=n?.items;return{title:i.group==null||u?.some(Mx)?void 0:Nx(i,s,r),color:i.group==null||u?.some(Mx)?void 0:i.color,rows:u?kx(i,u,r):[{label:r.xLabel,value:Px(i,`x`,a,r)},{label:r.yLabel,value:Px(i,`y`,o,r)}]}}function kx(e,t,n){return t.flatMap(t=>{if(typeof t==`string`)return t===`group`?[{label:`Group`,value:e.groupLabel,color:e.color}]:[{label:t===`x`?n.xLabel:n.yLabel,value:Px(e,t,void 0,n)}];if(`channel`in t){let r=t.text?.(e,n);return t.text&&r==null?[]:t.channel===`group`?[{label:t.label??`Group`,value:r??e.groupLabel,color:e.color}]:[{label:t.label??(t.channel===`x`?n.xLabel:n.yLabel),value:r??Px(e,t.channel,void 0,n)}]}if(`field`in t){let r=e.datum[t.field];if(r==null)return[];let i=t.text?.(e,n);return t.text&&i==null?[]:[{label:t.label??t.field,value:i??Ex(r)}]}let r=t.text(e,n);return r==null?[]:[{label:t.label??t.id,value:r}]})}function Ax(e,t){let n=e?.find(e=>jx(e)===t);return typeof n==`object`&&`channel`in n?n:void 0}function jx(e){return typeof e==`string`?e:`channel`in e?e.channel:void 0}function Mx(e){return jx(e)===`group`}function Nx(e,t,n){return t?.text?.(e,n)??e.groupLabel}function Px(e,t,n,r){let i=n?.text?.(e,r);if(i!=null)return i;let a=t===`x`?e.x1Value:e.y1Value,o=t===`x`?e.x2Value:e.y2Value,s=t===`x`?e.xInterval:e.yInterval;return s===`difference`&&typeof a==`number`&&typeof o==`number`?Ex(o-a):s===`range`&&a!==void 0&&o!==void 0&&!Rx(a,o)?`${Ex(a)}\u2013${Ex(o)}`:Ex(t===`x`?e.xValue:e.yValue)}function Fx(e,t){let n=e.nodes.find(e=>e.kind===`group`&&e.key===`axes`);if(n?.kind!==`group`)return;let r=n.children.find(e=>e.key===t);return r?.kind===`label`?r.text:void 0}function Ix(e,t,n,r,i,a,o){if(t===`point`)return e===`x`?n.x:n.y;if(t===`pointer`)return a?.[e]??o;if(t===`value`){let t=e===`x`?n.xValue:n.yValue,r=i.scales[e],a=(r?.viewport?.map??r?.map)?.(t);return a!==void 0&&Number.isFinite(a)?a:o}if(t===`group-center`){let t=e===`x`?n.x:n.y,i=t;for(let n of r){let r=e===`x`?n.x:n.y;t=Math.min(t,r),i=Math.max(i,r)}return(t+i)/2}let s=i.chart;if(e===`x`){if(t===`plot-left`)return s.x;if(t===`plot-center`)return s.x+s.width/2;if(t===`plot-right`)return s.x+s.width}else{if(t===`plot-top`)return s.y;if(t===`plot-center`)return s.y+s.height/2;if(t===`plot-bottom`)return s.y+s.height}return o}function Lx(e,t){let n=t==null?-1:e.colors.domain.indexOf(t);return n<0?2**53-1:n}function Rx(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}var zx={id:`tooltip`,__chartExtensionType:`tooltip`,__chartTooltipHost:`dom`,create:Bx};function Bx(e){let t={},n,r,i,a=!1,o,s=[],c=!1,l=!1,u,d=null,f,p,m,h,{container:g}=e,_=g.ownerDocument.defaultView,v=e.motion;function y(e){t!==e&&(l=!0),t=e,n&&T()}function b(e){if(u?.point!==e.point&&(l=!0),u=e,t.visibility===`pinned`&&!e.pinned){A();return}let n=x();T();let r=v?.beforePaint(n);n.style.visibility=`hidden`,n.removeAttribute(`hidden`),n.className=t.className?`ts-chart-tooltip ${t.className}`:`ts-chart-tooltip`;let i=Cx(e.points,e.scene,t.sort),a=wx(i,e.scene,e.pinned,t,e.point),o=D(n,i,a,e.pinned);o||(typeof a==`string`?Ux(n,a):Wx(n,a)),Kx(n,a,o,e.pinned),n.style.pointerEvents=e.pinned?`auto`:`none`,n.style.userSelect=e.pinned?`text`:`none`,n.dataset.sticky=String(e.pinned),d=Tx(e.point,i,e.scene,e.pointer,t,e.focus),w(),n.style.removeProperty(`visibility`),r&&v?.afterPaint(n,r,t.motion)}function x(){return n||(n=Hx(g.ownerDocument),n.addEventListener(`keydown`,S),p=_?.ResizeObserver?new _.ResizeObserver(C):void 0,p?.observe(n),g.append(n),n)}function S(t){t.key===`Escape`&&u?.pinned&&(t.preventDefault(),t.stopPropagation(),e.dismiss())}function C(){if(u&&d&&f===void 0){if(!_?.requestAnimationFrame){w();return}f=_.requestAnimationFrame(()=>{f=void 0,w()})}}function w(){if(u&&n&&d){if(h){h.position({scene:u.scene,surface:u.surface,anchor:d,placement:t.placement,offset:t.offset})||n.setAttribute(`hidden`,``);return}Sx(n,d.x,d.y,{left:0,top:0,right:u.scene.width,bottom:u.scene.height},t.placement,t.offset)}}function T(){if(!n)return;let e=t.portal,r=e?`create`in e?e:e.use:void 0,i=e&&`use`in e?e:{};r===m?h?.update(i):(h?.destroy(),h=void 0,m=r,r?h=r.create({container:g,element:n,schedulePosition:C},i):E())}function E(){n&&(n.parentNode!==g&&g.append(n),n.removeAttribute(`popover`),delete n.dataset.tsChartTooltipPortal,Object.assign(n.style,{position:`absolute`,zIndex:`1`,right:`auto`,bottom:`auto`,margin:`0`}))}function D(t,n,d,f){let p=e.bodyChange();if(!p)return k(),!1;i!==p&&(i?.(null),i=p,a=!1,r=void 0),r||(r=t.ownerDocument.createElement(`div`),r.className=`ts-chart-tooltip__body`,t.replaceChildren(r)),r.toggleAttribute(`inert`,!f),Gx(t,d);let m=l||!a||o!==u?.scene||c!==f||!Vx(n,s);return l=!1,a=!0,o=u?.scene,s=n,c=f,m&&p({element:r,primaryPoint:u?.point,points:n,content:d,pinned:f,dismiss:e.dismiss}),!0}function O(){a&&(a=!1,i?.(null))}function k(){O(),i=void 0,r=void 0,o=void 0,s=[]}function A(){u=void 0,d=null;let e=n;if(!e||e.hidden){h?.hide(),O();return}let r=()=>{h?.hide(),e.setAttribute(`hidden`,``),O()};v?.hide(e,t.motion,r)||r()}function j(){A(),k(),h?.destroy(),h=void 0,m=void 0,f!==void 0&&(_?.cancelAnimationFrame?.(f),f=void 0),v?.destroy(n),p?.disconnect(),p=void 0,n?.remove(),n=void 0}return{update:y,paint:b,hide:A,contains:e=>!!(e&&n?.contains(e)),destroy:j}}function Vx(e,t){return e.length===t.length&&e.every((e,n)=>e.key===t[n]?.key&&e.markId===t[n]?.markId&&e.datumIndex===t[n]?.datumIndex)}function Hx(e){let t=e.createElement(`div`);return t.className=`ts-chart-tooltip`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),Object.assign(t.style,{position:`absolute`,zIndex:`1`,maxWidth:`var(--ts-chart-tooltip-max-width, min(24rem, 80%))`,padding:`var(--ts-chart-tooltip-padding, 0.4rem 0.55rem)`,border:`var(--ts-chart-tooltip-border, 1px solid color-mix(in srgb, CanvasText 18%, transparent))`,borderRadius:`var(--ts-chart-tooltip-border-radius, 0.45rem)`,background:`var(--ts-chart-tooltip-background, Canvas)`,color:`var(--ts-chart-tooltip-color, CanvasText)`,boxShadow:`var(--ts-chart-tooltip-shadow, 0 6px 24px rgb(0 0 0 / 0.14))`,font:`var(--ts-chart-tooltip-font, 500 0.75rem/1.3 system-ui, sans-serif)`,pointerEvents:`none`,overflowWrap:`anywhere`}),t.hidden=!0,t}function Ux(e,t){Gx(e,t),e.textContent=t}function Wx(e,t){let n=e.ownerDocument,r=[];if(t.title){let e=n.createElement(`div`);e.className=`ts-chart-tooltip__title`,e.style.cssText=`display:flex;align-items:center;gap:.4rem;font-weight:650;margin-bottom:${t.rows.length?`.3rem`:`0`}`,t.color&&e.append(qx(n,t.color)),e.append(t.title),r.push(e)}if(t.rows.length){let e=n.createElement(`div`);e.className=`ts-chart-tooltip__rows`,e.setAttribute(`aria-hidden`,`true`);for(let r of t.rows){let t=n.createElement(`div`);t.className=`ts-chart-tooltip__row`,t.style.cssText=`display:grid;grid-template-columns:.55rem minmax(0,1fr) auto;align-items:center;column-gap:.4rem`,t.dataset.active=String(r.active===!0),r.active&&(t.style.fontWeight=`var(--ts-chart-tooltip-active-row-font-weight, 700)`,t.style.background=`var(--ts-chart-tooltip-active-row-background, color-mix(in srgb, currentColor 12%, transparent))`,t.style.borderRadius=`var(--ts-chart-tooltip-active-row-border-radius, .2rem)`,t.style.boxShadow=`var(--ts-chart-tooltip-active-row-shadow, 0 0 0 2px color-mix(in srgb, currentColor 12%, transparent))`);let i=r.color?qx(n,r.color):n.createElement(`span`),a=n.createElement(`span`);a.textContent=r.label;let o=n.createElement(`span`);o.textContent=r.value,o.style.cssText=`text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap`,t.append(i,a,o),e.append(t)}r.push(e)}e.replaceChildren(...r),Gx(e,t)}function Gx(e,t){if(typeof t==`string`){e.removeAttribute(`aria-label`),e.style.whiteSpace=`pre-wrap`;return}e.style.whiteSpace=`normal`,e.setAttribute(`aria-label`,[t.title,...t.rows.map(e=>`${e.label}: ${e.value}`)].filter(Boolean).join(`
55
- `))}function Kx(e,t,n,r){if(n&&typeof t==`string`&&e.setAttribute(`aria-label`,t),n&&r){e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-modal`,`false`),e.removeAttribute(`aria-live`);return}e.setAttribute(`role`,`status`),e.setAttribute(`aria-live`,`polite`),e.removeAttribute(`aria-modal`),!n&&typeof t==`string`&&e.removeAttribute(`aria-label`)}function qx(e,t){let n=e.createElement(`span`);return n.className=`ts-chart-tooltip__swatch`,n.setAttribute(`aria-hidden`,`true`),n.style.cssText=`display:block;width:.55rem;height:.55rem;border-radius:.15rem;box-shadow:inset 0 0 0 1px rgb(0 0 0/.12)`,n.style.background=t,n}var Jx=()=>()=>{},Yx=()=>!1,Xx=()=>!0,Zx=typeof document>`u`?y.useEffect:y.useLayoutEffect,Qx=y.memo(y.forwardRef(function({markup:e},t){return(0,b.jsx)(`div`,{ref:t,className:`ts-chart-surface`,style:{width:`100%`,height:`100%`},dangerouslySetInnerHTML:{__html:e}})}),()=>!0);function $x(e){let{ariaLabel:t,ariaDescription:n,height:r,aspectRatio:i,width:a,initialWidth:o=640,className:s,style:c,tabIndex:l,idPrefix:u,renderer:d,measureText:f,onFocusChange:p,onFocusGroupChange:m,onSelect:h,onRender:g,onTooltipBodyChange:_}=e,v=y.useId(),x=u??`ts-chart-${v.replaceAll(/[^a-zA-Z0-9_-]/g,``)}`,S=typeof i==`number`&&Number.isFinite(i)&&i>0?i:void 0,C=S===void 0?void 0:String(S),w=y.useRef(null),T=y.useRef(null),E={renderer:d,ariaLabel:t,ariaDescription:n,height:r,aspectRatio:S,width:a,initialWidth:o,tabIndex:l,idPrefix:x,measureText:f,onFocusChange:p,onFocusGroupChange:m,onSelect:h,onRender:g,onTooltipBodyChange:_,definition:e.definition};T.current??=sb(E);let D=T.current,O=y.useSyncExternalStore(Jx,Yx,Xx),k=y.useRef(null);k.current??=O?D.prerender():``;let A=y.useRef(!1);return Zx(()=>{let e=w.current;e&&(D.update(E),A.current||=(D.mount(e),!0))},[D,E]),Zx(()=>()=>{D.destroy(),A.current=!1},[D]),(0,b.jsx)(`div`,{className:s?`ts-chart-host ${s}`:`ts-chart-host`,style:{position:`relative`,width:a===void 0?`100%`:a,height:r??(S?void 0:320),aspectRatio:r===void 0?C:void 0,...c},children:(0,b.jsx)(Qx,{ref:w,markup:k.current})})}function eS(e){return(0,b.jsx)(tS,{...e})}function tS(e){let t=e.renderSvg??Qv,n=y.useMemo(()=>nb(t),[t]),r=y.useMemo(()=>{if(e.onRender)return t=>{let n=t.surface.defaultElement??t.surface.element,r=t.container.ownerDocument.defaultView?.SVGSVGElement;if(!r||!(n instanceof r))throw TypeError(`Expected the SVG chart surface.`);e.onRender?.({container:t.container,scene:t.scene,surface:t.surface,svg:n,interaction:t.interaction})}},[e.onRender]),i={...e,renderer:n,onRender:r};return(0,b.jsx)($x,{...i})}var nS=36e5;function rS(e,t,n=168){if(!Number.isFinite(e)||!Number.isFinite(t)||t<e)return[];let r=Math.floor(t/nS)*nS,i=Math.floor(e/nS)*nS,a=Math.floor((r-i)/nS)+1,o=r-(Math.min(a,n)-1)*nS,s=[];for(let e=o;e<=r;e+=nS)s.push(e);return s}function iS(e,t,n,r,i=168){let a=new Map(e.map(e=>[e.hourStart,e]));return rS(t,n,i).map(e=>r(e,a.get(e)))}function aS(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function oS(){let{theme:e}=on();return(0,y.useMemo)(()=>({ok:aS(`--status-ok`),warn:aS(`--status-warn`),bad:aS(`--status-bad`),info:aS(`--status-info`),sub:aS(`--status-sub`),muted:aS(`--muted-foreground`)}),[e])}var sS=[`Input`,`Cache read`,`Cache write 5m`,`Cache write 1h`],cS=[`inbound_subscription`,`inbound_key`,`fallback_server`,`none`];function lS(){let e=oS();return(0,y.useMemo)(()=>[e.info,e.ok,e.sub,e.warn],[e])}function uS(){let e=oS();return(0,y.useMemo)(()=>({inbound_subscription:e.ok,inbound_key:e.info,fallback_server:e.warn,none:e.muted}),[e])}function dS({items:e}){return(0,b.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-3.5 text-xs text-muted-foreground`,children:e.map(e=>(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`span`,{className:`mr-1.5 inline-block size-2.5 rounded-sm align-middle`,style:{background:e.color}}),e.label]},e.label))})}function fS(e,t){let n=new Date(e),r=String(n.getHours()).padStart(2,`0`);return t&&n.getHours()===0?`${n.getMonth()+1}/${n.getDate()}`:r}function pS({series:e,fromMs:t,toMs:n}){let r=(0,y.useMemo)(()=>iS(e,t,n,(e,t)=>{let n=t?.usage;return[{hour:e,bucket:`Input`,tokens:n?.inputTokens??0},{hour:e,bucket:`Cache read`,tokens:n?.cacheReadTokens??0},{hour:e,bucket:`Cache write 5m`,tokens:n?.cacheWrite5mTokens??0},{hour:e,bucket:`Cache write 1h`,tokens:n?.cacheWrite1hTokens??0}]}).flat(),[e,t,n]),i=n-t>864e5,a=lS(),o=(0,y.useMemo)(()=>jg({marks:[kb(r,{x:`hour`,y:`tokens`,color:`bucket`,layout:Zb({order:[...sS]})})],scales:{x:{scale:()=>rx().padding(.2),axis:{ticks:{spacing:64,format:e=>fS(e,i)}}},y:{scale:mx,nice:!0,grid:!0,axis:{label:`Tokens`,ticks:{format:e=>Kf(e)}}}},color:{domain:[...sS],range:[...a],legend:Hb({label:`Bucket`})},tooltip:zx}),[r,i,a]);return(0,b.jsx)(`div`,{className:`mt-1`,children:(0,b.jsx)(eS,{definition:o,height:240,ariaLabel:`Tokens per hour by billing bucket`,ariaDescription:`Stacked hourly token counts split into input, cache read, and 5-minute and 1-hour cache writes.`})})}function mS({rows:e}){let t=(0,y.useMemo)(()=>[...e].filter(e=>e.requests>0).sort((e,t)=>cS.indexOf(e.credentialOrigin)-cS.indexOf(t.credentialOrigin)).map(e=>({lane:`Requests`,origin:ap[e.credentialOrigin]??e.credentialOrigin,requests:e.requests})),[e]),n=(0,y.useMemo)(()=>t.map(e=>e.origin),[t]),r=uS(),i=(0,y.useMemo)(()=>jg({marks:[Ab(t,{x:`requests`,y:`lane`,color:`origin`,layout:Zb({order:n}),radius:4})],scales:{x:{scale:mx,nice:!0,axis:{label:`Requests`}},y:{scale:()=>rx().padding(.55)}},color:{domain:n,range:n.map(e=>r[cS.find(t=>ap[t]===e)??`none`]??``)},tooltip:zx}),[t,n,r]);return(0,b.jsx)(`div`,{className:`mt-1`,children:(0,b.jsx)(eS,{definition:i,height:96,ariaLabel:`Requests by credential origin`,ariaDescription:`A single stacked bar showing what share of requests ran on a developer's own subscription versus a server-held key.`})})}var hS=[`<1s`,`1–3s`,`3–10s`,`10–30s`,`30–60s`,`≥60s`];function gS({buckets:e}){let t=(0,y.useMemo)(()=>hS.map((t,n)=>({label:t,count:e[n]??0})),[e]),n=oS(),r=(0,y.useMemo)(()=>jg({marks:[kb(t,{x:`label`,y:`count`,fill:n.info,radius:3})],scales:{x:{scale:()=>rx().padding(.25),axis:{label:`Duration`}},y:{scale:mx,nice:!0,grid:!0,axis:{label:`Requests`}}},tooltip:zx}),[t,n]);return(0,b.jsx)(`div`,{className:`mt-1`,children:(0,b.jsx)(eS,{definition:r,height:200,ariaLabel:`Request duration histogram`,ariaDescription:`Request counts in six fixed duration buckets, from under one second to sixty seconds and over.`})})}var _S=.8,vS=.95,yS=e=>e===null?`muted`:e>=vS?`bad`:e>=_S?`warn`:`ok`,bS=e=>e===null?`info`:e>=vS?`bad`:e>=_S?`warn`:`ok`;function xS({range:e}){let t=oS(),n=uS(),r=[{label:`Input`,color:t.info},{label:`Cache read`,color:t.ok},{label:`Cache write 5m`,color:t.sub},{label:`Cache write 1h`,color:t.warn}],i=nt({queryKey:[`overview`,e.fromMs,e.toMs],queryFn:()=>nf.overview(e)}),a=nt({queryKey:[`quota`],queryFn:nf.quota}),o=i.data,s=o?.totals,c=o?.sink,l=Qt(e),u=o?.byCredentialOrigin??[],d=u.reduce((e,t)=>e+t.requests,0),f=e=>d===0?0:(u.find(t=>t.credentialOrigin===e)?.requests??0)/d,p=u.find(e=>e.credentialOrigin===`fallback_server`)?.requests??0;return(0,b.jsxs)(b.Fragment,{children:[p>0&&(0,b.jsx)(Pf,{variant:`warning`,className:`mb-4`,children:(0,b.jsxs)(Ff,{children:[Gf(p),` request`,p===1?``:`s`,` in this range ran on a `,(0,b.jsx)(`strong`,{children:`server-held key`}),` rather than a developer's own subscription. That is org spend, and it is billed to whoever owns that key — check the Models screen for which model triggered the substitution, and Routing for the rule that did it.`]})}),c!==void 0&&c.dropped>0&&(0,b.jsx)(Pf,{variant:`destructive`,className:`mb-4`,children:(0,b.jsxs)(Ff,{children:[`The metering queue dropped `,Gf(c.dropped),` record`,c.dropped===1?``:`s`,` under load. Every number on this dashboard is therefore a lower bound. Requests themselves were unaffected — the proxy sheds metrics before it sheds traffic.`]})}),(0,b.jsx)(wf,{title:`This range`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,isEmpty:s?.requests===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Requests`,value:Gf(s?.requests??0)}),(0,b.jsx)(Tf,{label:`Errors`,value:Gf(s?.errors??0),tone:(s?.errors??0)>0?`bad`:`muted`,note:s===void 0||s.requests===0?void 0:Zf(s.errors/s.requests)}),(0,b.jsx)(Tf,{label:`Context tokens`,value:s===void 0?`—`:Kf($f(s.usage)),note:`input + cache read + cache write`}),(0,b.jsx)(Tf,{label:`Output tokens`,value:s===void 0?`—`:Kf(s.usage.outputTokens)}),(0,b.jsx)(Tf,{label:`Cache hit ratio`,value:Zf(s?.cacheHitRatio??null),note:`cache reads / context`,tone:(s?.cacheHitRatio??0)>.5?`ok`:`muted`}),(0,b.jsx)(Tf,{label:`Org spend`,value:s===void 0?`—`:Yf(s),note:`${Gf(s?.subscriptionRequests??0)} subscription requests excluded`}),(0,b.jsx)(Tf,{label:`Value at list rates`,value:s===void 0?`—`:Xf(s),tone:`sub`,note:`all usage, incl. subscription`})]}),s!==void 0&&s.requests>0&&(0,b.jsx)(`p`,{className:`mt-3`,children:(0,b.jsxs)(kf,{children:[(0,b.jsxs)(`strong`,{children:[Yf(s),` billed`]}),` to the org ·`,` `,(0,b.jsxs)(`strong`,{children:[Xf(s),` of work`]}),` at published API rates. The gap is what developers' own subscriptions absorbed — real usage the org was never invoiced for. The two are deliberately not added together: one is an invoice, the other is what the work was worth.`]})})]})}),(0,b.jsx)(wf,{title:`Who paid for this traffic`,subtitle:`Subscription usage and metered spend are shown side by side and never added: a request a developer's own plan absorbed cost the org nothing, which is not the same as costing zero.`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,isEmpty:d===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`On own subscription`,value:Zf(f(`inbound_subscription`)),note:`${Gf(u.find(e=>e.credentialOrigin===`inbound_subscription`)?.requests??0)} requests`,tone:`ok`}),(0,b.jsx)(Tf,{label:`On a server-held key`,value:Zf(f(`fallback_server`)),note:`${Gf(p)} requests`,tone:p>0?`warn`:`muted`}),(0,b.jsx)(Tf,{label:`Absorbed by subscriptions`,value:Gf(s?.subscriptionRequests??0),note:`real usage, no org spend`,tone:`muted`})]}),(0,b.jsx)(mS,{rows:u}),(0,b.jsx)(dS,{items:cS.filter(e=>u.some(t=>t.credentialOrigin===e&&t.requests>0)).map(e=>({label:ap[e]??e,color:n[e]??``}))}),(0,b.jsx)(Mf,{head:[`Credential origin`,jf(`Requests`),jf(`People`),jf(`Errors`),jf(`Tokens`),jf(`Cost`),jf(`At list rates`)],children:u.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:(0,b.jsx)(Df,{tone:e.credentialOrigin===`inbound_subscription`?`ok`:e.credentialOrigin===`fallback_server`?`warn`:`muted`,children:op(e.credentialOrigin)})}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.distinctUsers)}),(0,b.jsx)(X,{className:`num`,children:e.errors===0?(0,b.jsx)(kf,{children:`0`}):e.errors}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.inputTokens+e.usage.cacheReadTokens+e.usage.cacheWrite5mTokens+e.usage.cacheWrite1hTokens+e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{title:`A subscription absorbed every request in this row, so no dollar figure applies.`,children:`subscription`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.credentialOrigin))})]})}),(0,b.jsx)(wf,{title:`By client`,subtitle:`Which coding agent sent the traffic: Claude Code, Codex or Copilot. Read from raw request rows, because the hourly rollup has no client dimension — so this empties for ranges older than raw-row retention.`,children:(0,b.jsx)(Af,{isPending:i.isPending,error:i.error,isEmpty:(o?.byClient.length??0)===0,children:(0,b.jsx)(Mf,{head:[`Client`,jf(`Requests`),jf(`Errors`),jf(`Tokens`),jf(`Cost`),jf(`At list rates`)],children:(o?.byClient??[]).map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.client===``?(0,b.jsx)(kf,{title:`The client could not be told from its headers, or the row predates client tracking.`,children:cp(e.client)}):cp(e.client)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:e.errors===0?(0,b.jsx)(kf,{children:`0`}):e.errors}),(0,b.jsx)(X,{className:`num`,children:Kf($f(e.usage)+e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{title:`A subscription absorbed every request in this row, so no dollar figure applies.`,children:`subscription`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.client))})})}),(0,b.jsx)(wf,{title:`Tokens per hour`,subtitle:`The four buckets are disjoint: input excludes cache reads and writes, so the stack height is the context consumed, not a double count.`,children:(0,b.jsx)(Af,{isPending:i.isPending,error:i.error,isEmpty:(o?.series.length??0)===0,children:o!==void 0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(pS,{series:o.series,fromMs:e.fromMs,toMs:e.toMs}),(0,b.jsx)(dS,{items:r})]})})}),(0,b.jsx)(wf,{title:`Latency`,subtitle:l?`Exact: this range is short enough that the server reads raw request rows.`:`Percentiles are interpolated from six fixed buckets — a p95 of 24s means “somewhere in 10–30s”. Narrow the range to under two hours for exact figures.`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,isEmpty:(o?.latency.count??0)===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Median`,value:Qf(o?.latency.p50Ms??null),note:l?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`p95`,value:Qf(o?.latency.p95Ms??null),note:l?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`Mean TTFB`,value:Qf(o?.latency.avgTtfbMs??null),note:`time to first byte`}),(0,b.jsx)(Tf,{label:`Slowest`,value:Qf(o?.latency.maxDurationMs??null)})]}),o!==void 0&&(0,b.jsx)(gS,{buckets:o.latency.buckets})]})}),(0,b.jsx)(wf,{title:`Metering pipeline`,subtitle:`Usage records are queued and written in batches off the request path. A hard crash loses at most one flush interval — right for telemetry, wrong for a chargeback ledger.`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Written`,value:Gf(c?.written??0)}),(0,b.jsx)(Tf,{label:`Queued`,value:Gf(c?.queued??0),tone:`muted`}),(0,b.jsx)(Tf,{label:`Dropped`,value:Gf(c?.dropped??0),tone:(c?.dropped??0)>0?`bad`:`muted`,note:`queue overflow`}),(0,b.jsx)(Tf,{label:`Write errors`,value:Gf(c?.writeErrors??0),tone:(c?.writeErrors??0)>0?`bad`:`muted`}),(0,b.jsx)(Tf,{label:`Last flush`,value:c?.lastFlushMs===null||c===void 0?`—`:Qf(c.lastFlushMs)})]}),c!==void 0&&c.trailErrors>0&&(0,b.jsx)(`p`,{children:(0,b.jsxs)(kf,{children:[Gf(c.trailErrors),` JSONL trail write`,c.trailErrors===1?``:`s`,` failed. The trail is a convenience copy; the database is the record, so this is not data loss.`]})})]})}),(0,b.jsx)(wf,{title:`Rate-limit headroom, per developer`,subtitle:`The latest quota Anthropic reported for each person. This is the scarce resource on a subscription — not money. It reads raw request rows, so it empties as retention removes them.`,children:(0,b.jsx)(Af,{isPending:a.isPending,error:a.error,isEmpty:(a.data?.rows.length??0)===0,emptyText:`No quota headers observed yet. They arrive on every subscription response, so this fills in as soon as someone runs a turn.`,children:(0,b.jsx)(Mf,{head:[`Developer`,`5-hour window`,`7-day window`,`Binding`,`Overage`,`Observed`],children:(a.data?.rows??[]).map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:lp(e.userId,e.email)}),(0,b.jsxs)(X,{children:[(0,b.jsx)(`span`,{className:Sf[yS(e.fiveHourUtilization)],children:Zf(e.fiveHourUtilization)}),(0,b.jsx)(Of,{value:e.fiveHourUtilization,tone:bS(e.fiveHourUtilization),label:`5-hour utilisation`}),(0,b.jsxs)(kf,{children:[`resets `,ip(e.fiveHourResetAt)]})]}),(0,b.jsxs)(X,{children:[(0,b.jsx)(`span`,{className:Sf[yS(e.sevenDayUtilization)],children:Zf(e.sevenDayUtilization)}),(0,b.jsx)(Of,{value:e.sevenDayUtilization,tone:bS(e.sevenDayUtilization),label:`7-day utilisation`}),(0,b.jsxs)(kf,{children:[`resets `,ip(e.sevenDayResetAt)]})]}),(0,b.jsx)(X,{children:e.claim===null?(0,b.jsx)(kf,{children:`n/a`}):(0,b.jsx)(Df,{tone:`info`,children:e.claim})}),(0,b.jsx)(X,{children:e.overageStatus===null?(0,b.jsx)(kf,{children:`n/a`}):(0,b.jsx)(Df,{tone:e.overageStatus===`allowed`?`ok`:`warn`,title:e.overageReason??void 0,children:e.overageStatus})}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:rp(e.observedAt)})})]},e.userId??`unattributed`))})})})]})}function SS({range:e}){let t=nt({queryKey:[`users`,e.fromMs,e.toMs],queryFn:()=>nf.users(e)}),n=[...t.data?.rows??[]].sort((e,t)=>t.requests-e.requests),r=n.find(e=>e.userId===``);return(0,b.jsxs)(b.Fragment,{children:[r!==void 0&&r.requests>0&&(0,b.jsx)(Pf,{variant:`warning`,className:`mb-4`,children:(0,b.jsxs)(Ff,{children:[Gf(r.requests),` request`,r.requests===1?``:`s`,` arrived with no Fest identity token and could not be attributed to anyone. Issue a token with`,` `,(0,b.jsx)(`code`,{className:`mono`,children:`fest token create <email>`}),` and set`,` `,(0,b.jsx)(`code`,{className:`mono`,children:`FEST_REQUIRE_IDENTITY=true`}),` once every developer has one.`]})}),(0,b.jsx)(wf,{title:`Usage by developer`,subtitle:`Subscription requests are counted but never billed: they consumed a developer's own rate-limit window rather than org budget. “At list rates” is what that work would have cost on the API — value, not spend, and never added to it.`,children:(0,b.jsx)(Af,{isPending:t.isPending,error:t.error,isEmpty:n.length===0,children:(0,b.jsx)(Mf,{head:[`Developer`,jf(`Requests`),jf(`On subscription`),jf(`Errors`),jf(`Context`),jf(`Output`),jf(`Cache hit`),jf(`Org spend`),jf(`At list rates`)],children:n.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.userId===``?(0,b.jsx)(Df,{tone:`warn`,title:`No identity token was presented on these requests.`,children:`unattributed`}):lp(e.userId,e.email)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(`span`,{className:`text-status-ok`,children:`all`}):Gf(e.subscriptionRequests)}),(0,b.jsx)(X,{className:`num`,children:e.errors===0?(0,b.jsx)(kf,{children:`0`}):(0,b.jsx)(`span`,{className:`text-status-bad`,children:e.errors})}),(0,b.jsx)(X,{className:`num`,children:Kf($f(e.usage))}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:Zf(e.cacheHitRatio)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{children:`none`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.userId===``?`unattributed`:e.userId))})})})]})}function CS({range:e}){let t=nt({queryKey:[`models`,e.fromMs,e.toMs],queryFn:()=>nf.models(e)}),n=[...t.data?.rows??[]].sort((e,t)=>t.requests-e.requests);return(0,b.jsx)(wf,{title:`Usage by model`,subtitle:`Token buckets are disjoint billing buckets — input excludes cache reads and writes — so the columns add up to context, not to a double count. “At list rates” prices every request, including the subscription ones org spend excludes.`,children:(0,b.jsx)(Af,{isPending:t.isPending,error:t.error,isEmpty:n.length===0,children:(0,b.jsx)(Mf,{head:[`Model`,jf(`Requests`),jf(`Input`),jf(`Cache read`),jf(`Cache write 5m`),jf(`Cache write 1h`),jf(`Output`),jf(`Cache hit`),jf(`Org spend`),jf(`At list rates`)],children:n.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{className:`mono`,title:e.servedModel,children:e.servedModel===``?(0,b.jsx)(kf,{children:`unresolved`}):up(e.servedModel)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.inputTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.cacheReadTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.cacheWrite5mTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.cacheWrite1hTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:Zf(e.cacheHitRatio)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{children:`none`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.servedModel===``?`unresolved`:e.servedModel))})})})}var wS={identity_denied:`A Fest identity token was missing, unknown or revoked.`,client_abort:`The developer cancelled mid-turn. Normal, not a fault.`,stream_error:`The upstream stream ended badly after headers were sent.`,upstream_error:`Anthropic (or the substitute provider) returned an error.`,bad_request:`The request was malformed before it reached an upstream.`};function TS(e,t){return e!==null&&wS[e]!==void 0?wS[e]??``:t===401?`Expected: the client refreshes its own token and retries. Fest forwards 401s untouched so that works.`:t===429?`Rate limited. Check the quota panel on Routing.`:t!==null&&t>=500?`Upstream server error.`:``}function ES({range:e}){let t=nt({queryKey:[`errors`,e.fromMs,e.toMs],queryFn:()=>nf.errors(e)}),n=t.data?.rows??[],r=n.reduce((e,t)=>e+t.count,0),i=Qt(e);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(wf,{title:`Failures in this range`,subtitle:`Read from raw request rows, not the hourly rollup — the rollup keeps a count but not a reason. This view therefore goes blank for ranges older than raw-row retention.`,children:(0,b.jsxs)(Af,{isPending:t.isPending,error:t.error,isEmpty:n.length===0,emptyText:`No failures recorded in this range.`,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Failed requests`,value:Gf(r),tone:r>0?`bad`:`ok`}),(0,b.jsx)(Tf,{label:`Distinct causes`,value:Gf(n.length)})]}),(0,b.jsx)(Mf,{head:[`Cause`,jf(`HTTP`),jf(`Count`),`What it means`],children:n.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.errorType===null?(0,b.jsx)(kf,{children:`no error type`}):(0,b.jsx)(Df,{tone:e.errorType===`client_abort`?`muted`:`bad`,children:e.errorType})}),(0,b.jsx)(X,{className:`num`,children:e.httpStatus??(0,b.jsx)(kf,{children:`—`})}),(0,b.jsx)(X,{className:`num`,children:Gf(e.count)}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:TS(e.errorType,e.httpStatus)})})]},`${e.errorType??`none`}:${e.httpStatus??`none`}`))})]})}),(0,b.jsx)(wf,{title:`Latency, all requests`,subtitle:i?`Exact: this range reads raw request rows.`:`Interpolated from six fixed buckets; treat the percentiles as approximate.`,children:(0,b.jsxs)(Af,{isPending:t.isPending,error:t.error,isEmpty:(t.data?.latency.count??0)===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Median`,value:Qf(t.data?.latency.p50Ms??null),note:i?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`p95`,value:Qf(t.data?.latency.p95Ms??null),note:i?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`Slowest`,value:Qf(t.data?.latency.maxDurationMs??null)})]}),t.data!==void 0&&(0,b.jsx)(gS,{buckets:t.data.latency.buckets})]})})]})}var DS={ok:`ok`,denied:`bad`,error:`warn`};function OS(){let e=nt({queryKey:[`audit`],queryFn:()=>nf.audit()});return(0,b.jsx)(wf,{title:`Audit log`,subtitle:(0,b.jsx)(b.Fragment,{children:`Administrative actions, kept in the database rather than the application log — logs rotate and containers are replaced, but “who minted this token” is asked months later. No credential and no prompt text is ever recorded here.`}),children:(0,b.jsx)(Af,{isPending:e.isPending,error:e.error,isEmpty:e.data!==void 0&&e.data.rows.length===0,emptyText:`Nothing recorded yet.`,children:(0,b.jsx)(Mf,{head:[`When`,`Actor`,`Action`,`Target`,`Outcome`,`Detail`,`From`],children:(e.data?.rows??[]).map(e=>{let t=DS[e.outcome];return(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:rp(e.at)}),(0,b.jsx)(X,{children:e.actorLabel===``?(0,b.jsx)(kf,{children:`—`}):e.actorLabel}),(0,b.jsx)(X,{children:e.action}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:e.target===``?`—`:e.target})}),(0,b.jsx)(X,{className:t===void 0?``:Sf[t],children:e.outcome}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:Object.keys(e.detail).length===0?`—`:JSON.stringify(e.detail)})}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:e.ip===``?`—`:e.ip})})]},e.seq)})})})})}async function kS(){let e=await fetch($d(`api/auth/me`),{headers:{accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}async function AS(e,t){return fetch($d(e),{method:`POST`,headers:{accept:`application/json`,...t===void 0?{}:{"content-type":`application/json`}},...t===void 0?{}:{body:JSON.stringify(t)}})}async function jS(e,t){let n=await AS(`/api/auth/login`,{email:e,password:t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error??`HTTP ${n.status}`);return r}async function MS(){let e=await AS(`/api/auth/logout`);if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`HTTP ${e.status}`)}}function NS({className:e,type:t,...n}){return(0,b.jsx)(`input`,{type:t,"data-slot":`input`,className:rr(`h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function PS({className:e,...t}){return(0,b.jsx)(Ol,{"data-slot":`label`,className:rr(`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})}var FS={google:`Google`,github:`GitHub`};function IS({setupRequired:e,oauthProviders:t,onSignedIn:n}){let[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),d=new URLSearchParams(window.location.search).get(`auth_error`);async function f(e){e.preventDefault(),u(!0),c(null);try{await jS(r,a),n()}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}return(0,b.jsx)(`div`,{className:`grid min-h-screen place-items-center p-6`,children:(0,b.jsxs)(`div`,{className:`w-full max-w-[380px] rounded-lg bg-card p-6 ring-1 ring-foreground/10`,children:[(0,b.jsx)(`div`,{className:`-mx-2.5`,children:(0,b.jsx)(nC,{})}),d!==null&&(0,b.jsx)(`p`,{className:`mt-4 text-sm text-status-bad`,role:`alert`,children:d}),e&&(0,b.jsxs)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:[`Nobody has claimed this deployment yet, so it is running open on loopback.`,t.length>0?` Sign in below to become its owner, or create an account from the host:`:` Create an owner account on the host:`]}),t.length>0&&(0,b.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[t.map(e=>(0,b.jsx)(Wd,{variant:`outline`,asChild:!0,children:(0,b.jsxs)(`a`,{href:$d(`api/auth/oauth/${e}/start`),children:[`Continue with `,FS[e]??e]})},e)),!e&&(0,b.jsx)(`p`,{className:`mt-1 text-center text-[13px] text-muted-foreground`,children:`or sign in with a password`})]}),e?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`pre`,{className:`mt-4 overflow-x-auto rounded-md bg-muted p-3 font-mono text-xs`,children:`fest admin create you@corp.test`}),(0,b.jsx)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:`The password is printed once. Until then Fest will refuse to listen on any interface other than loopback.`})]}):(0,b.jsxs)(`form`,{onSubmit:e=>void f(e),className:`mt-4 flex flex-col gap-2`,children:[(0,b.jsx)(PS,{htmlFor:`email`,className:`text-muted-foreground`,children:`Email`}),(0,b.jsx)(NS,{id:`email`,type:`email`,autoComplete:`username`,value:r,onChange:e=>i(e.target.value),required:!0}),(0,b.jsx)(PS,{htmlFor:`password`,className:`mt-2 text-muted-foreground`,children:`Password`}),(0,b.jsx)(NS,{id:`password`,type:`password`,autoComplete:`current-password`,value:a,onChange:e=>o(e.target.value),required:!0}),s!==null&&(0,b.jsx)(`p`,{className:`text-sm text-status-bad`,role:`alert`,children:s}),(0,b.jsx)(Wd,{type:`submit`,disabled:l,className:`mt-4`,children:l?`Signing in…`:`Sign in`})]}),(0,b.jsxs)(`p`,{className:`mt-5 text-[11.5px] leading-relaxed text-muted-foreground`,children:[`Accounts are created from the host with `,(0,b.jsx)(`code`,{className:`mono`,children:`fest admin create`}),`. There is no self-registration and no email reset.`]})]})})}var LS=`fest-cli-authorize`;function RS(e){try{let t=new URL(e);return t.protocol===`http:`&&(t.hostname===`127.0.0.1`||t.hostname===`localhost`)}catch{return!1}}function zS(){let e=new URLSearchParams(window.location.search).get(`cli_authorize`);e!==null&&RS(e)&&sessionStorage.setItem(LS,e)}typeof window<`u`&&zS();function BS(e){(0,y.useEffect)(()=>{if(!e)return;let t=sessionStorage.getItem(LS);t!==null&&(sessionStorage.removeItem(LS),window.location.assign($d(`api/auth/cli/authorize?cli_redirect_uri=${encodeURIComponent(t)}`)))},[e])}async function VS(e){try{if(navigator.clipboard!==void 0&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function HS({command:e,className:t}){let[n,r]=(0,y.useState)(`idle`),i=(0,y.useRef)(null),a=(0,y.useCallback)(()=>{VS(e).then(e=>{r(e?`copied`:`failed`),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>r(`idle`),1600)})},[e]);return(0,b.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":`Copy: ${e}`,title:`Copy to clipboard`,className:rr(`group flex w-full items-center gap-3 rounded-lg bg-muted/60 px-3 py-2 text-left`,`ring-1 ring-foreground/10 transition-colors hover:bg-muted hover:ring-foreground/20`,`focus-visible:ring-2 focus-visible:ring-status-sub focus-visible:outline-none`,t),children:[(0,b.jsxs)(`span`,{className:`mono min-w-0 flex-1 truncate text-[12.5px] text-foreground`,children:[(0,b.jsx)(`span`,{className:`mr-2 text-muted-foreground select-none`,children:`$`}),e]}),(0,b.jsx)(`span`,{className:rr(`flex shrink-0 items-center gap-1 text-[11px] transition-colors`,n===`copied`?`text-status-ok`:`text-muted-foreground group-hover:text-foreground`),children:n===`copied`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(vt,{className:`size-3.5`}),` Copied`]}):n===`failed`?(0,b.jsx)(b.Fragment,{children:`Select and copy`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(wt,{className:`size-3.5`}),` Copy`]})})]})}var US=`fest-setup-cli-expanded`,WS=`fest-setup-cli-client`,GS=({children:e})=>(0,b.jsx)(`code`,{className:`mono text-foreground`,children:e}),KS=[{id:`claude`,label:`Claude Code`,name:`Claude Code`,body:`Runs Claude Code with the environment already pointed here. Your own subscription pays, and Fest never stores your credential.`,command:`fest claude`,note:(0,b.jsxs)(b.Fragment,{children:[`Make sure `,(0,b.jsx)(GS,{children:`ANTHROPIC_API_KEY`}),` and `,(0,b.jsx)(GS,{children:`ANTHROPIC_AUTH_TOKEN`}),` are unset — either one drops you off your own subscription onto whatever credential this server holds.`]})},{id:`codex`,label:`Codex`,name:`Codex`,body:`Runs Codex on its own login, pointed here. A ChatGPT login means your plan pays; an API key means its owner does. Your ~/.codex config is left untouched.`,command:`fest codex`,note:(0,b.jsxs)(b.Fragment,{children:[`Sign in to Codex first with `,(0,b.jsx)(GS,{children:`codex login`}),`. On a machine with a ChatGPT login,`,` `,(0,b.jsx)(GS,{children:`fest codex key`}),` uses your `,(0,b.jsx)(GS,{children:`OPENAI_API_KEY`}),` instead.`]})},{id:`copilot`,label:`Copilot`,name:`Copilot CLI`,body:`Runs Copilot CLI in bring-your-own-key mode with Fest as its provider. Your API key pays — never your Copilot seat, whose traffic Fest does not relay.`,command:`fest copilot`,note:(0,b.jsxs)(b.Fragment,{children:[`Set `,(0,b.jsx)(GS,{children:`ANTHROPIC_API_KEY`}),` to an API key, not a Claude subscription token. Without one,`,` `,(0,b.jsx)(GS,{children:`fest copilot gw`}),` uses this gateway's own routes.`]})}];function qS(){let e=localStorage.getItem(WS);return KS.some(t=>t.id===e)?e:`claude`}function JS(){let e=localStorage.getItem(US);return e===`1`||e!==`0`&&null}var YS=2592e6;function XS(){return Qd.replace(/\/+$/,``)}function ZS(e){let[t,n]=(0,y.useState)(JS),r=Date.now(),i=nt({queryKey:[`setup-cli-usage`,e],queryFn:()=>nf.users({fromMs:r-YS,toMs:r}),enabled:e!==void 0,staleTime:6e4});if(e===void 0||!i.isSuccess)return null;let a=i.data.rows.find(t=>t.userId===e),o=a!==void 0&&a.requests>0;return{hasSessions:o,expanded:t??!o,setExpanded:e=>{localStorage.setItem(US,e?`1`:`0`),n(e)}}}function QS({state:e}){return(0,b.jsxs)(Wd,{type:`button`,variant:`outline`,size:`sm`,"aria-expanded":e.expanded,onClick:()=>e.setExpanded(!e.expanded),children:[(0,b.jsx)(Rt,{className:`size-3.5`}),`Setup CLI`]})}function $S({state:e}){let[t,n]=(0,y.useState)(qS);if(!e.expanded)return null;let{hasSessions:r,setExpanded:i}=e,a=XS(),o=KS.find(e=>e.id===t)??KS[0],s=e=>{localStorage.setItem(WS,e),n(e)},c=[{icon:Rt,title:`Install the CLI`,body:`Node 22.18 or newer. The package is fest-gateway; the command is fest.`,command:`npm install -g fest-gateway`},{icon:Et,title:`Sign in to this gateway`,body:`Opens a browser, then stores an identity token in ~/.fest. This is what attributes your usage to you.`,command:`fest login --server ${a}`},{icon:Pt,title:`Start a session`,body:o.body,command:o.command}];return(0,b.jsxs)(`section`,{"aria-labelledby":`setup-cli-heading`,className:`relative mb-5 overflow-hidden rounded-lg bg-card ring-1 ring-status-sub/30`,children:[(0,b.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 bg-gradient-to-br from-status-sub/8 via-transparent to-transparent`}),(0,b.jsxs)(`div`,{className:`relative p-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsxs)(`h2`,{id:`setup-cli-heading`,className:`text-base font-medium text-foreground`,children:[`Point `,o.name,` at Fest`]}),(0,b.jsx)(`p`,{className:`mt-1 max-w-[68ch] text-[13px] text-muted-foreground`,children:r?`Three commands to run ${o.name} through this gateway — on a new machine, or for someone you are setting up.`:`Nothing has come through on your account yet. Three commands and your next ${o.name} session runs through this gateway, metered here.`})]}),(0,b.jsx)(Lp,{"aria-label":`Coding agent`,className:`-mt-1 shrink-0`,children:KS.map(e=>(0,b.jsx)(Wd,{type:`button`,size:`sm`,variant:e.id===t?`default`:`outline`,"aria-pressed":e.id===t,onClick:()=>s(e.id),children:e.label},e.id))}),(0,b.jsxs)(Wd,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`Hide setup instructions`,"aria-expanded":!0,onClick:()=>i(!1),className:`-mt-1 shrink-0 text-muted-foreground`,children:[(0,b.jsx)(St,{className:`size-4`}),`Hide`]})]}),(0,b.jsx)(`ol`,{className:`mt-4 grid gap-3 md:grid-cols-3`,children:c.map((e,t)=>(0,b.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-lg bg-background/40 p-3 ring-1 ring-foreground/5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-status-sub/15 text-[11px] font-semibold text-status-sub`,children:t+1}),(0,b.jsx)(e.icon,{className:`size-3.5 shrink-0 text-status-sub`}),(0,b.jsx)(`h3`,{className:`truncate text-[13px] font-medium text-foreground`,children:e.title})]}),(0,b.jsx)(`p`,{className:`text-[12px] leading-relaxed text-muted-foreground`,children:e.body}),(0,b.jsx)(HS,{command:e.command,className:`mt-auto`})]},e.title))}),(0,b.jsxs)(`p`,{className:`mt-3 flex items-start gap-2 text-[12px] text-muted-foreground`,children:[(0,b.jsx)(vt,{className:`mt-0.5 size-3.5 shrink-0 text-status-ok`}),(0,b.jsx)(`span`,{children:o.note})]})]})]})}var eC=`https://github.com/cliftonc/fest-gateway`;function tC(){let e=S(),t=nt({queryKey:[`me`],queryFn:kS,refetchInterval:!1,staleTime:1/0});return(0,y.useEffect)(()=>{let t=()=>void e.invalidateQueries({queryKey:[`me`]});return window.addEventListener(`fest:unauthenticated`,t),()=>window.removeEventListener(`fest:unauthenticated`,t)},[e]),BS(t.data?.authenticated===!0),t.isPending?(0,b.jsx)(`div`,{className:`p-6 text-muted-foreground`,children:`Loading…`}):t.isError?(0,b.jsx)(`div`,{className:`grid min-h-screen place-items-center p-6`,children:(0,b.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg bg-card p-6 ring-1 ring-foreground/10`,children:[(0,b.jsx)(nC,{}),(0,b.jsxs)(`p`,{className:`mt-4 text-status-bad`,children:[`Cannot reach the gateway: `,t.error.message]})]})}):t.data.authenticated?(0,b.jsx)(iC,{user:t.data.user,onSignedOut:()=>void e.invalidateQueries()}):(0,b.jsx)(IS,{setupRequired:t.data.setupRequired,oauthProviders:t.data.oauthProviders,onSignedIn:()=>void e.invalidateQueries()})}function nC(){return(0,b.jsxs)(`div`,{className:`flex items-start gap-2.5 px-2.5`,children:[(0,b.jsx)(sn,{className:`mt-0.5 h-5 w-5 shrink-0 text-foreground`}),(0,b.jsx)(`div`,{className:`leading-tight`,children:(0,b.jsx)(`div`,{className:`text-[17px] font-semibold tracking-[0.02em]`,children:`Fest`})})]})}function rC(){let{theme:e,toggleTheme:t}=on();return(0,b.jsx)(Wd,{type:`button`,variant:`ghost`,size:`icon`,onClick:t,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,children:e===`dark`?(0,b.jsx)(It,{}):(0,b.jsx)(Ot,{})})}function iC({user:e,onSignedOut:t}){let n=qt(),[r,i]=(0,y.useState)(`24h`),[a,o]=(0,y.useState)(null),s=Zt(r),c=ZS(e?.id),l=n!==`live`&&n!==`routing`;return(0,b.jsxs)(`div`,{className:`grid h-screen grid-cols-[210px_1fr] overflow-hidden`,children:[(0,b.jsxs)(`nav`,{className:`flex flex-col gap-1 overflow-y-auto border-r bg-sidebar p-3 pt-4.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-2 pb-3.5`,children:[(0,b.jsx)(nC,{}),(0,b.jsx)(`a`,{href:eC,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`Fest on GitHub`,title:`Fest on GitHub`,className:`mt-0.5 shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,b.jsx)(cn,{className:`size-4`})})]}),Wt.filter(t=>t!==`admin`||e?.role!==`member`).map(e=>(0,b.jsx)(`a`,{href:Jt(e),"aria-current":e===n?`page`:void 0,className:`block rounded-md px-2.5 py-1.5 text-sidebar-foreground no-underline hover:bg-sidebar-accent aria-[current=page]:bg-sidebar-primary aria-[current=page]:font-medium aria-[current=page]:text-sidebar-primary-foreground`,children:B[e]},e)),(0,b.jsxs)(`div`,{className:`mt-auto p-2.5 text-[11.5px] text-muted-foreground`,children:[e!==void 0&&(0,b.jsxs)(`div`,{className:`mb-3 flex flex-col gap-1.5`,children:[(0,b.jsx)(`span`,{className:`truncate text-foreground`,title:e.email,children:e.email}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(Wd,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{o(null),MS().then(t).catch(e=>o(e instanceof Error?e.message:`sign out failed`))},children:`Sign out`}),(0,b.jsx)(rC,{})]}),a!==null&&(0,b.jsx)(`span`,{className:`text-status-bad`,children:a})]}),`Metadata only — no prompts or responses are captured, and no credential is ever stored.`]})]}),(0,b.jsx)(`main`,{className:`overflow-y-auto`,children:(0,b.jsxs)(`div`,{className:`max-w-[1400px] px-6 pt-5 pb-15`,children:[(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-4`,children:[(0,b.jsx)(`h1`,{className:`text-xl font-medium`,children:B[n]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c!==null&&(0,b.jsx)(QS,{state:c}),l&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`label`,{htmlFor:`range`,className:`ml-1 text-xs text-muted-foreground`,children:`Range`}),(0,b.jsxs)(Gd,{value:r,onValueChange:i,children:[(0,b.jsx)(qd,{id:`range`,size:`sm`,className:`w-[150px]`,children:(0,b.jsx)(Kd,{})}),(0,b.jsx)(Jd,{children:Xt.map(e=>(0,b.jsx)(Yd,{value:e.id,children:e.label},e.id))})]})]})]})]}),c!==null&&(0,b.jsx)($S,{state:c}),n===`live`&&(0,b.jsx)(nm,{}),n===`routing`&&(0,b.jsx)(Bf,{}),n===`stats`&&(0,b.jsx)(xS,{range:s}),n===`users`&&(0,b.jsx)(SS,{range:s}),n===`models`&&(0,b.jsx)(CS,{range:s}),n===`errors`&&(0,b.jsx)(ES,{range:s}),n===`admin`&&(0,b.jsx)(OS,{})]})})]})}var aC=new Ue({defaultOptions:{queries:{staleTime:3e4,refetchInterval:6e4,refetchOnWindowFocus:!0,retry:!1}}}),oC=document.getElementById(`root`);if(oC===null)throw Error(`fest: #root is missing from index.html`);(0,Ut.createRoot)(oC).render((0,b.jsx)(y.StrictMode,{children:(0,b.jsx)(an,{children:(0,b.jsx)(C,{client:aC,children:(0,b.jsx)(mf,{delayDuration:200,children:(0,b.jsx)(tC,{})})})})}));
56
- //# sourceMappingURL=index-BClCav9v.js.map
55
+ `))}function Kx(e,t,n,r){if(n&&typeof t==`string`&&e.setAttribute(`aria-label`,t),n&&r){e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-modal`,`false`),e.removeAttribute(`aria-live`);return}e.setAttribute(`role`,`status`),e.setAttribute(`aria-live`,`polite`),e.removeAttribute(`aria-modal`),!n&&typeof t==`string`&&e.removeAttribute(`aria-label`)}function qx(e,t){let n=e.createElement(`span`);return n.className=`ts-chart-tooltip__swatch`,n.setAttribute(`aria-hidden`,`true`),n.style.cssText=`display:block;width:.55rem;height:.55rem;border-radius:.15rem;box-shadow:inset 0 0 0 1px rgb(0 0 0/.12)`,n.style.background=t,n}var Jx=()=>()=>{},Yx=()=>!1,Xx=()=>!0,Zx=typeof document>`u`?y.useEffect:y.useLayoutEffect,Qx=y.memo(y.forwardRef(function({markup:e},t){return(0,b.jsx)(`div`,{ref:t,className:`ts-chart-surface`,style:{width:`100%`,height:`100%`},dangerouslySetInnerHTML:{__html:e}})}),()=>!0);function $x(e){let{ariaLabel:t,ariaDescription:n,height:r,aspectRatio:i,width:a,initialWidth:o=640,className:s,style:c,tabIndex:l,idPrefix:u,renderer:d,measureText:f,onFocusChange:p,onFocusGroupChange:m,onSelect:h,onRender:g,onTooltipBodyChange:_}=e,v=y.useId(),x=u??`ts-chart-${v.replaceAll(/[^a-zA-Z0-9_-]/g,``)}`,S=typeof i==`number`&&Number.isFinite(i)&&i>0?i:void 0,C=S===void 0?void 0:String(S),w=y.useRef(null),T=y.useRef(null),E={renderer:d,ariaLabel:t,ariaDescription:n,height:r,aspectRatio:S,width:a,initialWidth:o,tabIndex:l,idPrefix:x,measureText:f,onFocusChange:p,onFocusGroupChange:m,onSelect:h,onRender:g,onTooltipBodyChange:_,definition:e.definition};T.current??=sb(E);let D=T.current,O=y.useSyncExternalStore(Jx,Yx,Xx),k=y.useRef(null);k.current??=O?D.prerender():``;let A=y.useRef(!1);return Zx(()=>{let e=w.current;e&&(D.update(E),A.current||=(D.mount(e),!0))},[D,E]),Zx(()=>()=>{D.destroy(),A.current=!1},[D]),(0,b.jsx)(`div`,{className:s?`ts-chart-host ${s}`:`ts-chart-host`,style:{position:`relative`,width:a===void 0?`100%`:a,height:r??(S?void 0:320),aspectRatio:r===void 0?C:void 0,...c},children:(0,b.jsx)(Qx,{ref:w,markup:k.current})})}function eS(e){return(0,b.jsx)(tS,{...e})}function tS(e){let t=e.renderSvg??Qv,n=y.useMemo(()=>nb(t),[t]),r=y.useMemo(()=>{if(e.onRender)return t=>{let n=t.surface.defaultElement??t.surface.element,r=t.container.ownerDocument.defaultView?.SVGSVGElement;if(!r||!(n instanceof r))throw TypeError(`Expected the SVG chart surface.`);e.onRender?.({container:t.container,scene:t.scene,surface:t.surface,svg:n,interaction:t.interaction})}},[e.onRender]),i={...e,renderer:n,onRender:r};return(0,b.jsx)($x,{...i})}var nS=36e5;function rS(e,t,n=168){if(!Number.isFinite(e)||!Number.isFinite(t)||t<e)return[];let r=Math.floor(t/nS)*nS,i=Math.floor(e/nS)*nS,a=Math.floor((r-i)/nS)+1,o=r-(Math.min(a,n)-1)*nS,s=[];for(let e=o;e<=r;e+=nS)s.push(e);return s}function iS(e,t,n,r,i=168){let a=new Map(e.map(e=>[e.hourStart,e]));return rS(t,n,i).map(e=>r(e,a.get(e)))}function aS(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function oS(){let{theme:e}=on();return(0,y.useMemo)(()=>({ok:aS(`--status-ok`),warn:aS(`--status-warn`),bad:aS(`--status-bad`),info:aS(`--status-info`),sub:aS(`--status-sub`),muted:aS(`--muted-foreground`)}),[e])}var sS=[`Input`,`Cache read`,`Cache write 5m`,`Cache write 1h`],cS=[`inbound_subscription`,`inbound_key`,`fallback_server`,`none`];function lS(){let e=oS();return(0,y.useMemo)(()=>[e.info,e.ok,e.sub,e.warn],[e])}function uS(){let e=oS();return(0,y.useMemo)(()=>({inbound_subscription:e.ok,inbound_key:e.info,fallback_server:e.warn,none:e.muted}),[e])}function dS({items:e}){return(0,b.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-3.5 text-xs text-muted-foreground`,children:e.map(e=>(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`span`,{className:`mr-1.5 inline-block size-2.5 rounded-sm align-middle`,style:{background:e.color}}),e.label]},e.label))})}function fS(e,t){let n=new Date(e),r=String(n.getHours()).padStart(2,`0`);return t&&n.getHours()===0?`${n.getMonth()+1}/${n.getDate()}`:r}function pS({series:e,fromMs:t,toMs:n}){let r=(0,y.useMemo)(()=>iS(e,t,n,(e,t)=>{let n=t?.usage;return[{hour:e,bucket:`Input`,tokens:n?.inputTokens??0},{hour:e,bucket:`Cache read`,tokens:n?.cacheReadTokens??0},{hour:e,bucket:`Cache write 5m`,tokens:n?.cacheWrite5mTokens??0},{hour:e,bucket:`Cache write 1h`,tokens:n?.cacheWrite1hTokens??0}]}).flat(),[e,t,n]),i=n-t>864e5,a=lS(),o=(0,y.useMemo)(()=>jg({marks:[kb(r,{x:`hour`,y:`tokens`,color:`bucket`,layout:Zb({order:[...sS]})})],scales:{x:{scale:()=>rx().padding(.2),axis:{ticks:{spacing:64,format:e=>fS(e,i)}}},y:{scale:mx,nice:!0,grid:!0,axis:{label:`Tokens`,ticks:{format:e=>Kf(e)}}}},color:{domain:[...sS],range:[...a],legend:Hb({label:`Bucket`})},tooltip:zx}),[r,i,a]);return(0,b.jsx)(`div`,{className:`mt-1`,children:(0,b.jsx)(eS,{definition:o,height:240,ariaLabel:`Tokens per hour by billing bucket`,ariaDescription:`Stacked hourly token counts split into input, cache read, and 5-minute and 1-hour cache writes.`})})}function mS({rows:e}){let t=(0,y.useMemo)(()=>[...e].filter(e=>e.requests>0).sort((e,t)=>cS.indexOf(e.credentialOrigin)-cS.indexOf(t.credentialOrigin)).map(e=>({lane:`Requests`,origin:ap[e.credentialOrigin]??e.credentialOrigin,requests:e.requests})),[e]),n=(0,y.useMemo)(()=>t.map(e=>e.origin),[t]),r=uS(),i=(0,y.useMemo)(()=>jg({marks:[Ab(t,{x:`requests`,y:`lane`,color:`origin`,layout:Zb({order:n}),radius:4})],scales:{x:{scale:mx,nice:!0,axis:{label:`Requests`}},y:{scale:()=>rx().padding(.55)}},color:{domain:n,range:n.map(e=>r[cS.find(t=>ap[t]===e)??`none`]??``)},tooltip:zx}),[t,n,r]);return(0,b.jsx)(`div`,{className:`mt-1`,children:(0,b.jsx)(eS,{definition:i,height:96,ariaLabel:`Requests by credential origin`,ariaDescription:`A single stacked bar showing what share of requests ran on a developer's own subscription versus a server-held key.`})})}var hS=[`<1s`,`1–3s`,`3–10s`,`10–30s`,`30–60s`,`≥60s`];function gS({buckets:e}){let t=(0,y.useMemo)(()=>hS.map((t,n)=>({label:t,count:e[n]??0})),[e]),n=oS(),r=(0,y.useMemo)(()=>jg({marks:[kb(t,{x:`label`,y:`count`,fill:n.info,radius:3})],scales:{x:{scale:()=>rx().padding(.25),axis:{label:`Duration`}},y:{scale:mx,nice:!0,grid:!0,axis:{label:`Requests`}}},tooltip:zx}),[t,n]);return(0,b.jsx)(`div`,{className:`mt-1`,children:(0,b.jsx)(eS,{definition:r,height:200,ariaLabel:`Request duration histogram`,ariaDescription:`Request counts in six fixed duration buckets, from under one second to sixty seconds and over.`})})}var _S=.8,vS=.95,yS=e=>e===null?`muted`:e>=vS?`bad`:e>=_S?`warn`:`ok`,bS=e=>e===null?`info`:e>=vS?`bad`:e>=_S?`warn`:`ok`;function xS({range:e}){let t=oS(),n=uS(),r=[{label:`Input`,color:t.info},{label:`Cache read`,color:t.ok},{label:`Cache write 5m`,color:t.sub},{label:`Cache write 1h`,color:t.warn}],i=nt({queryKey:[`overview`,e.fromMs,e.toMs],queryFn:()=>nf.overview(e)}),a=nt({queryKey:[`quota`],queryFn:nf.quota}),o=i.data,s=o?.totals,c=o?.sink,l=Qt(e),u=o?.byCredentialOrigin??[],d=u.reduce((e,t)=>e+t.requests,0),f=e=>d===0?0:(u.find(t=>t.credentialOrigin===e)?.requests??0)/d,p=u.find(e=>e.credentialOrigin===`fallback_server`)?.requests??0;return(0,b.jsxs)(b.Fragment,{children:[p>0&&(0,b.jsx)(Pf,{variant:`warning`,className:`mb-4`,children:(0,b.jsxs)(Ff,{children:[Gf(p),` request`,p===1?``:`s`,` in this range ran on a `,(0,b.jsx)(`strong`,{children:`server-held key`}),` rather than a developer's own subscription. That is org spend, and it is billed to whoever owns that key — check the Models screen for which model triggered the substitution, and Routing for the rule that did it.`]})}),c!==void 0&&c.dropped>0&&(0,b.jsx)(Pf,{variant:`destructive`,className:`mb-4`,children:(0,b.jsxs)(Ff,{children:[`The metering queue dropped `,Gf(c.dropped),` record`,c.dropped===1?``:`s`,` under load. Every number on this dashboard is therefore a lower bound. Requests themselves were unaffected — the proxy sheds metrics before it sheds traffic.`]})}),(0,b.jsx)(wf,{title:`This range`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,isEmpty:s?.requests===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Requests`,value:Gf(s?.requests??0)}),(0,b.jsx)(Tf,{label:`Errors`,value:Gf(s?.errors??0),tone:(s?.errors??0)>0?`bad`:`muted`,note:s===void 0||s.requests===0?void 0:Zf(s.errors/s.requests)}),(0,b.jsx)(Tf,{label:`Context tokens`,value:s===void 0?`—`:Kf($f(s.usage)),note:`input + cache read + cache write`}),(0,b.jsx)(Tf,{label:`Output tokens`,value:s===void 0?`—`:Kf(s.usage.outputTokens)}),(0,b.jsx)(Tf,{label:`Cache hit ratio`,value:Zf(s?.cacheHitRatio??null),note:`cache reads / context`,tone:(s?.cacheHitRatio??0)>.5?`ok`:`muted`}),(0,b.jsx)(Tf,{label:`Org spend`,value:s===void 0?`—`:Yf(s),note:`${Gf(s?.subscriptionRequests??0)} subscription requests excluded`}),(0,b.jsx)(Tf,{label:`Value at list rates`,value:s===void 0?`—`:Xf(s),tone:`sub`,note:`all usage, incl. subscription`})]}),s!==void 0&&s.requests>0&&(0,b.jsx)(`p`,{className:`mt-3`,children:(0,b.jsxs)(kf,{children:[(0,b.jsxs)(`strong`,{children:[Yf(s),` billed`]}),` to the org ·`,` `,(0,b.jsxs)(`strong`,{children:[Xf(s),` of work`]}),` at published API rates. The gap is what developers' own subscriptions absorbed — real usage the org was never invoiced for. The two are deliberately not added together: one is an invoice, the other is what the work was worth.`]})})]})}),(0,b.jsx)(wf,{title:`Who paid for this traffic`,subtitle:`Subscription usage and metered spend are shown side by side and never added: a request a developer's own plan absorbed cost the org nothing, which is not the same as costing zero.`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,isEmpty:d===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`On own subscription`,value:Zf(f(`inbound_subscription`)),note:`${Gf(u.find(e=>e.credentialOrigin===`inbound_subscription`)?.requests??0)} requests`,tone:`ok`}),(0,b.jsx)(Tf,{label:`On a server-held key`,value:Zf(f(`fallback_server`)),note:`${Gf(p)} requests`,tone:p>0?`warn`:`muted`}),(0,b.jsx)(Tf,{label:`Absorbed by subscriptions`,value:Gf(s?.subscriptionRequests??0),note:`real usage, no org spend`,tone:`muted`})]}),(0,b.jsx)(mS,{rows:u}),(0,b.jsx)(dS,{items:cS.filter(e=>u.some(t=>t.credentialOrigin===e&&t.requests>0)).map(e=>({label:ap[e]??e,color:n[e]??``}))}),(0,b.jsx)(Mf,{head:[`Credential origin`,jf(`Requests`),jf(`People`),jf(`Errors`),jf(`Tokens`),jf(`Cost`),jf(`At list rates`)],children:u.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:(0,b.jsx)(Df,{tone:e.credentialOrigin===`inbound_subscription`?`ok`:e.credentialOrigin===`fallback_server`?`warn`:`muted`,children:op(e.credentialOrigin)})}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.distinctUsers)}),(0,b.jsx)(X,{className:`num`,children:e.errors===0?(0,b.jsx)(kf,{children:`0`}):e.errors}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.inputTokens+e.usage.cacheReadTokens+e.usage.cacheWrite5mTokens+e.usage.cacheWrite1hTokens+e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{title:`A subscription absorbed every request in this row, so no dollar figure applies.`,children:`subscription`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.credentialOrigin))})]})}),(0,b.jsx)(wf,{title:`By client`,subtitle:`Which coding agent sent the traffic: Claude Code, Codex or Copilot. Read from raw request rows, because the hourly rollup has no client dimension — so this empties for ranges older than raw-row retention.`,children:(0,b.jsx)(Af,{isPending:i.isPending,error:i.error,isEmpty:(o?.byClient.length??0)===0,children:(0,b.jsx)(Mf,{head:[`Client`,jf(`Requests`),jf(`Errors`),jf(`Tokens`),jf(`Cost`),jf(`At list rates`)],children:(o?.byClient??[]).map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.client===``?(0,b.jsx)(kf,{title:`The client could not be told from its headers, or the row predates client tracking.`,children:cp(e.client)}):cp(e.client)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:e.errors===0?(0,b.jsx)(kf,{children:`0`}):e.errors}),(0,b.jsx)(X,{className:`num`,children:Kf($f(e.usage)+e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{title:`A subscription absorbed every request in this row, so no dollar figure applies.`,children:`subscription`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.client))})})}),(0,b.jsx)(wf,{title:`Tokens per hour`,subtitle:`The four buckets are disjoint: input excludes cache reads and writes, so the stack height is the context consumed, not a double count.`,children:(0,b.jsx)(Af,{isPending:i.isPending,error:i.error,isEmpty:(o?.series.length??0)===0,children:o!==void 0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(pS,{series:o.series,fromMs:e.fromMs,toMs:e.toMs}),(0,b.jsx)(dS,{items:r})]})})}),(0,b.jsx)(wf,{title:`Latency`,subtitle:l?`Exact: this range is short enough that the server reads raw request rows.`:`Percentiles are interpolated from six fixed buckets — a p95 of 24s means “somewhere in 10–30s”. Narrow the range to under two hours for exact figures.`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,isEmpty:(o?.latency.count??0)===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Median`,value:Qf(o?.latency.p50Ms??null),note:l?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`p95`,value:Qf(o?.latency.p95Ms??null),note:l?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`Mean TTFB`,value:Qf(o?.latency.avgTtfbMs??null),note:`time to first byte`}),(0,b.jsx)(Tf,{label:`Slowest`,value:Qf(o?.latency.maxDurationMs??null)})]}),o!==void 0&&(0,b.jsx)(gS,{buckets:o.latency.buckets})]})}),(0,b.jsx)(wf,{title:`Metering pipeline`,subtitle:`Usage records are queued and written in batches off the request path. A hard crash loses at most one flush interval — right for telemetry, wrong for a chargeback ledger.`,children:(0,b.jsxs)(Af,{isPending:i.isPending,error:i.error,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Written`,value:Gf(c?.written??0)}),(0,b.jsx)(Tf,{label:`Queued`,value:Gf(c?.queued??0),tone:`muted`}),(0,b.jsx)(Tf,{label:`Dropped`,value:Gf(c?.dropped??0),tone:(c?.dropped??0)>0?`bad`:`muted`,note:`queue overflow`}),(0,b.jsx)(Tf,{label:`Write errors`,value:Gf(c?.writeErrors??0),tone:(c?.writeErrors??0)>0?`bad`:`muted`}),(0,b.jsx)(Tf,{label:`Last flush`,value:c?.lastFlushMs===null||c===void 0?`—`:Qf(c.lastFlushMs)})]}),c!==void 0&&c.trailErrors>0&&(0,b.jsx)(`p`,{children:(0,b.jsxs)(kf,{children:[Gf(c.trailErrors),` JSONL trail write`,c.trailErrors===1?``:`s`,` failed. The trail is a convenience copy; the database is the record, so this is not data loss.`]})})]})}),(0,b.jsx)(wf,{title:`Rate-limit headroom, per developer`,subtitle:`The latest quota Anthropic reported for each person. This is the scarce resource on a subscription — not money. It reads raw request rows, so it empties as retention removes them.`,children:(0,b.jsx)(Af,{isPending:a.isPending,error:a.error,isEmpty:(a.data?.rows.length??0)===0,emptyText:`No quota headers observed yet. They arrive on every subscription response, so this fills in as soon as someone runs a turn.`,children:(0,b.jsx)(Mf,{head:[`Developer`,`5-hour window`,`7-day window`,`Binding`,`Overage`,`Observed`],children:(a.data?.rows??[]).map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:lp(e.userId,e.email)}),(0,b.jsxs)(X,{children:[(0,b.jsx)(`span`,{className:Sf[yS(e.fiveHourUtilization)],children:Zf(e.fiveHourUtilization)}),(0,b.jsx)(Of,{value:e.fiveHourUtilization,tone:bS(e.fiveHourUtilization),label:`5-hour utilisation`}),(0,b.jsxs)(kf,{children:[`resets `,ip(e.fiveHourResetAt)]})]}),(0,b.jsxs)(X,{children:[(0,b.jsx)(`span`,{className:Sf[yS(e.sevenDayUtilization)],children:Zf(e.sevenDayUtilization)}),(0,b.jsx)(Of,{value:e.sevenDayUtilization,tone:bS(e.sevenDayUtilization),label:`7-day utilisation`}),(0,b.jsxs)(kf,{children:[`resets `,ip(e.sevenDayResetAt)]})]}),(0,b.jsx)(X,{children:e.claim===null?(0,b.jsx)(kf,{children:`n/a`}):(0,b.jsx)(Df,{tone:`info`,children:e.claim})}),(0,b.jsx)(X,{children:e.overageStatus===null?(0,b.jsx)(kf,{children:`n/a`}):(0,b.jsx)(Df,{tone:e.overageStatus===`allowed`?`ok`:`warn`,title:e.overageReason??void 0,children:e.overageStatus})}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:rp(e.observedAt)})})]},e.userId??`unattributed`))})})})]})}function SS({range:e}){let t=nt({queryKey:[`users`,e.fromMs,e.toMs],queryFn:()=>nf.users(e)}),n=[...t.data?.rows??[]].sort((e,t)=>t.requests-e.requests),r=n.find(e=>e.userId===``);return(0,b.jsxs)(b.Fragment,{children:[r!==void 0&&r.requests>0&&(0,b.jsx)(Pf,{variant:`warning`,className:`mb-4`,children:(0,b.jsxs)(Ff,{children:[Gf(r.requests),` request`,r.requests===1?``:`s`,` arrived with no Fest identity token and could not be attributed to anyone. Issue a token with`,` `,(0,b.jsx)(`code`,{className:`mono`,children:`fest token create <email>`}),` and set`,` `,(0,b.jsx)(`code`,{className:`mono`,children:`FEST_REQUIRE_IDENTITY=true`}),` once every developer has one.`]})}),(0,b.jsx)(wf,{title:`Usage by developer`,subtitle:`Subscription requests are counted but never billed: they consumed a developer's own rate-limit window rather than org budget. “At list rates” is what that work would have cost on the API — value, not spend, and never added to it.`,children:(0,b.jsx)(Af,{isPending:t.isPending,error:t.error,isEmpty:n.length===0,children:(0,b.jsx)(Mf,{head:[`Developer`,jf(`Requests`),jf(`On subscription`),jf(`Errors`),jf(`Context`),jf(`Output`),jf(`Cache hit`),jf(`Org spend`),jf(`At list rates`)],children:n.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.userId===``?(0,b.jsx)(Df,{tone:`warn`,title:`No identity token was presented on these requests.`,children:`unattributed`}):lp(e.userId,e.email)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(`span`,{className:`text-status-ok`,children:`all`}):Gf(e.subscriptionRequests)}),(0,b.jsx)(X,{className:`num`,children:e.errors===0?(0,b.jsx)(kf,{children:`0`}):(0,b.jsx)(`span`,{className:`text-status-bad`,children:e.errors})}),(0,b.jsx)(X,{className:`num`,children:Kf($f(e.usage))}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:Zf(e.cacheHitRatio)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{children:`none`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.userId===``?`unattributed`:e.userId))})})})]})}function CS({range:e}){let t=nt({queryKey:[`models`,e.fromMs,e.toMs],queryFn:()=>nf.models(e)}),n=[...t.data?.rows??[]].sort((e,t)=>t.requests-e.requests);return(0,b.jsx)(wf,{title:`Usage by model`,subtitle:`Token buckets are disjoint billing buckets — input excludes cache reads and writes — so the columns add up to context, not to a double count. “At list rates” prices every request, including the subscription ones org spend excludes.`,children:(0,b.jsx)(Af,{isPending:t.isPending,error:t.error,isEmpty:n.length===0,children:(0,b.jsx)(Mf,{head:[`Model`,jf(`Requests`),jf(`Input`),jf(`Cache read`),jf(`Cache write 5m`),jf(`Cache write 1h`),jf(`Output`),jf(`Cache hit`),jf(`Org spend`),jf(`At list rates`)],children:n.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{className:`mono`,title:e.servedModel,children:e.servedModel===``?(0,b.jsx)(kf,{children:`unresolved`}):up(e.servedModel)}),(0,b.jsx)(X,{className:`num`,children:Gf(e.requests)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.inputTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.cacheReadTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.cacheWrite5mTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.cacheWrite1hTokens)}),(0,b.jsx)(X,{className:`num`,children:Kf(e.usage.outputTokens)}),(0,b.jsx)(X,{className:`num`,children:Zf(e.cacheHitRatio)}),(0,b.jsx)(X,{className:`num`,children:e.subscriptionRequests===e.requests?(0,b.jsx)(kf,{children:`none`}):Yf(e)}),(0,b.jsx)(X,{className:`num text-status-sub`,children:Xf(e)})]},e.servedModel===``?`unresolved`:e.servedModel))})})})}var wS={identity_denied:`A Fest identity token was missing, unknown or revoked.`,client_abort:`The developer cancelled mid-turn. Normal, not a fault.`,stream_error:`The upstream stream ended badly after headers were sent.`,upstream_error:`Anthropic (or the substitute provider) returned an error.`,bad_request:`The request was malformed before it reached an upstream.`};function TS(e,t){return e!==null&&wS[e]!==void 0?wS[e]??``:t===401?`Expected: the client refreshes its own token and retries. Fest forwards 401s untouched so that works.`:t===429?`Rate limited. Check the quota panel on Routing.`:t!==null&&t>=500?`Upstream server error.`:``}function ES({range:e}){let t=nt({queryKey:[`errors`,e.fromMs,e.toMs],queryFn:()=>nf.errors(e)}),n=t.data?.rows??[],r=n.reduce((e,t)=>e+t.count,0),i=Qt(e);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(wf,{title:`Failures in this range`,subtitle:`Read from raw request rows, not the hourly rollup — the rollup keeps a count but not a reason. This view therefore goes blank for ranges older than raw-row retention.`,children:(0,b.jsxs)(Af,{isPending:t.isPending,error:t.error,isEmpty:n.length===0,emptyText:`No failures recorded in this range.`,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Failed requests`,value:Gf(r),tone:r>0?`bad`:`ok`}),(0,b.jsx)(Tf,{label:`Distinct causes`,value:Gf(n.length)})]}),(0,b.jsx)(Mf,{head:[`Cause`,jf(`HTTP`),jf(`Count`),`What it means`],children:n.map(e=>(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:e.errorType===null?(0,b.jsx)(kf,{children:`no error type`}):(0,b.jsx)(Df,{tone:e.errorType===`client_abort`?`muted`:`bad`,children:e.errorType})}),(0,b.jsx)(X,{className:`num`,children:e.httpStatus??(0,b.jsx)(kf,{children:`—`})}),(0,b.jsx)(X,{className:`num`,children:Gf(e.count)}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:TS(e.errorType,e.httpStatus)})})]},`${e.errorType??`none`}:${e.httpStatus??`none`}`))})]})}),(0,b.jsx)(wf,{title:`Latency, all requests`,subtitle:i?`Exact: this range reads raw request rows.`:`Interpolated from six fixed buckets; treat the percentiles as approximate.`,children:(0,b.jsxs)(Af,{isPending:t.isPending,error:t.error,isEmpty:(t.data?.latency.count??0)===0,children:[(0,b.jsxs)(Ef,{children:[(0,b.jsx)(Tf,{label:`Median`,value:Qf(t.data?.latency.p50Ms??null),note:i?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`p95`,value:Qf(t.data?.latency.p95Ms??null),note:i?`exact`:`approx.`}),(0,b.jsx)(Tf,{label:`Slowest`,value:Qf(t.data?.latency.maxDurationMs??null)})]}),t.data!==void 0&&(0,b.jsx)(gS,{buckets:t.data.latency.buckets})]})})]})}var DS={ok:`ok`,denied:`bad`,error:`warn`};function OS(){let e=nt({queryKey:[`audit`],queryFn:()=>nf.audit()});return(0,b.jsx)(wf,{title:`Audit log`,subtitle:(0,b.jsx)(b.Fragment,{children:`Administrative actions, kept in the database rather than the application log — logs rotate and containers are replaced, but “who minted this token” is asked months later. No credential and no prompt text is ever recorded here.`}),children:(0,b.jsx)(Af,{isPending:e.isPending,error:e.error,isEmpty:e.data!==void 0&&e.data.rows.length===0,emptyText:`Nothing recorded yet.`,children:(0,b.jsx)(Mf,{head:[`When`,`Actor`,`Action`,`Target`,`Outcome`,`Detail`,`From`],children:(e.data?.rows??[]).map(e=>{let t=DS[e.outcome];return(0,b.jsxs)(bf,{children:[(0,b.jsx)(X,{children:rp(e.at)}),(0,b.jsx)(X,{children:e.actorLabel===``?(0,b.jsx)(kf,{children:`—`}):e.actorLabel}),(0,b.jsx)(X,{children:e.action}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:e.target===``?`—`:e.target})}),(0,b.jsx)(X,{className:t===void 0?``:Sf[t],children:e.outcome}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:Object.keys(e.detail).length===0?`—`:JSON.stringify(e.detail)})}),(0,b.jsx)(X,{children:(0,b.jsx)(kf,{children:e.ip===``?`—`:e.ip})})]},e.seq)})})})})}async function kS(){let e=await fetch($d(`api/auth/me`),{headers:{accept:`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}async function AS(e,t){return fetch($d(e),{method:`POST`,headers:{accept:`application/json`,...t===void 0?{}:{"content-type":`application/json`}},...t===void 0?{}:{body:JSON.stringify(t)}})}async function jS(e,t){let n=await AS(`/api/auth/login`,{email:e,password:t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error??`HTTP ${n.status}`);return r}async function MS(){let e=await AS(`/api/auth/logout`);if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`HTTP ${e.status}`)}}function NS({className:e,type:t,...n}){return(0,b.jsx)(`input`,{type:t,"data-slot":`input`,className:rr(`h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function PS({className:e,...t}){return(0,b.jsx)(Ol,{"data-slot":`label`,className:rr(`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})}var FS={google:`Google`,github:`GitHub`};function IS({setupRequired:e,oauthProviders:t,onSignedIn:n}){let[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),d=new URLSearchParams(window.location.search).get(`auth_error`);async function f(e){e.preventDefault(),u(!0),c(null);try{await jS(r,a),n()}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}return(0,b.jsx)(`div`,{className:`grid min-h-screen place-items-center p-6`,children:(0,b.jsxs)(`div`,{className:`w-full max-w-[380px] rounded-lg bg-card p-6 ring-1 ring-foreground/10`,children:[(0,b.jsx)(`div`,{className:`-mx-2.5`,children:(0,b.jsx)(nC,{})}),d!==null&&(0,b.jsx)(`p`,{className:`mt-4 text-sm text-status-bad`,role:`alert`,children:d}),e&&(0,b.jsxs)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:[`Nobody has claimed this deployment yet, so it is running open on loopback.`,t.length>0?` Sign in below to become its owner, or create an account from the host:`:` Create an owner account on the host:`]}),t.length>0&&(0,b.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[t.map(e=>(0,b.jsx)(Wd,{variant:`outline`,asChild:!0,children:(0,b.jsxs)(`a`,{href:$d(`api/auth/oauth/${e}/start`),children:[`Continue with `,FS[e]??e]})},e)),!e&&(0,b.jsx)(`p`,{className:`mt-1 text-center text-[13px] text-muted-foreground`,children:`or sign in with a password`})]}),e?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`pre`,{className:`mt-4 overflow-x-auto rounded-md bg-muted p-3 font-mono text-xs`,children:`fest admin create you@corp.test`}),(0,b.jsx)(`p`,{className:`mt-2 text-[13px] text-muted-foreground`,children:`The password is printed once. Until then Fest will refuse to listen on any interface other than loopback.`})]}):(0,b.jsxs)(`form`,{onSubmit:e=>void f(e),className:`mt-4 flex flex-col gap-2`,children:[(0,b.jsx)(PS,{htmlFor:`email`,className:`text-muted-foreground`,children:`Email`}),(0,b.jsx)(NS,{id:`email`,type:`email`,autoComplete:`username`,value:r,onChange:e=>i(e.target.value),required:!0}),(0,b.jsx)(PS,{htmlFor:`password`,className:`mt-2 text-muted-foreground`,children:`Password`}),(0,b.jsx)(NS,{id:`password`,type:`password`,autoComplete:`current-password`,value:a,onChange:e=>o(e.target.value),required:!0}),s!==null&&(0,b.jsx)(`p`,{className:`text-sm text-status-bad`,role:`alert`,children:s}),(0,b.jsx)(Wd,{type:`submit`,disabled:l,className:`mt-4`,children:l?`Signing in…`:`Sign in`})]}),(0,b.jsxs)(`p`,{className:`mt-5 text-[11.5px] leading-relaxed text-muted-foreground`,children:[`Accounts are created from the host with `,(0,b.jsx)(`code`,{className:`mono`,children:`fest admin create`}),`. There is no self-registration and no email reset.`]})]})})}var LS=`fest-cli-authorize`;function RS(e){try{let t=new URL(e);return t.protocol===`http:`&&(t.hostname===`127.0.0.1`||t.hostname===`localhost`)}catch{return!1}}function zS(){let e=new URLSearchParams(window.location.search).get(`cli_authorize`);e!==null&&RS(e)&&sessionStorage.setItem(LS,e)}typeof window<`u`&&zS();function BS(e){(0,y.useEffect)(()=>{if(!e)return;let t=sessionStorage.getItem(LS);t!==null&&(sessionStorage.removeItem(LS),window.location.assign($d(`api/auth/cli/authorize?cli_redirect_uri=${encodeURIComponent(t)}`)))},[e])}async function VS(e){try{if(navigator.clipboard!==void 0&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function HS({command:e,className:t}){let[n,r]=(0,y.useState)(`idle`),i=(0,y.useRef)(null),a=(0,y.useCallback)(()=>{VS(e).then(e=>{r(e?`copied`:`failed`),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>r(`idle`),1600)})},[e]);return(0,b.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":`Copy: ${e}`,title:`Copy to clipboard`,className:rr(`group flex w-full items-center gap-3 rounded-lg bg-muted/60 px-3 py-2 text-left`,`ring-1 ring-foreground/10 transition-colors hover:bg-muted hover:ring-foreground/20`,`focus-visible:ring-2 focus-visible:ring-status-sub focus-visible:outline-none`,t),children:[(0,b.jsxs)(`span`,{className:`mono min-w-0 flex-1 truncate text-[12.5px] text-foreground`,children:[(0,b.jsx)(`span`,{className:`mr-2 text-muted-foreground select-none`,children:`$`}),e]}),(0,b.jsx)(`span`,{className:rr(`flex shrink-0 items-center gap-1 text-[11px] transition-colors`,n===`copied`?`text-status-ok`:`text-muted-foreground group-hover:text-foreground`),children:n===`copied`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(vt,{className:`size-3.5`}),` Copied`]}):n===`failed`?(0,b.jsx)(b.Fragment,{children:`Select and copy`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(wt,{className:`size-3.5`}),` Copy`]})})]})}var US=`fest-setup-cli-expanded`,WS=`fest-setup-cli-client`,GS=({children:e})=>(0,b.jsx)(`code`,{className:`mono text-foreground`,children:e}),KS=[{id:`claude`,label:`Claude Code`,name:`Claude Code`,body:`Runs Claude Code with the environment already pointed here. Your own subscription pays, and Fest never stores your credential.`,command:`fest claude`,note:(0,b.jsxs)(b.Fragment,{children:[`Make sure `,(0,b.jsx)(GS,{children:`ANTHROPIC_API_KEY`}),` and `,(0,b.jsx)(GS,{children:`ANTHROPIC_AUTH_TOKEN`}),` are unset — either one drops you off your own subscription onto whatever credential this server holds.`]})},{id:`codex`,label:`Codex`,name:`Codex`,body:`Runs Codex on its own login, pointed here. A ChatGPT login means your plan pays; an API key means its owner does. Your ~/.codex config is left untouched.`,command:`fest codex`,note:(0,b.jsxs)(b.Fragment,{children:[`Sign in to Codex first with `,(0,b.jsx)(GS,{children:`codex login`}),`. On a machine with a ChatGPT login,`,` `,(0,b.jsx)(GS,{children:`fest codex key`}),` uses your `,(0,b.jsx)(GS,{children:`OPENAI_API_KEY`}),` instead.`]})},{id:`copilot`,label:`Copilot`,name:`Copilot CLI`,body:`Runs Copilot CLI on its own GitHub login, pointed here. Your Copilot plan pays; your GitHub token is passed through to GitHub and never stored.`,command:`fest copilot`,note:(0,b.jsxs)(b.Fragment,{children:[`Sign in to Copilot first with `,(0,b.jsx)(GS,{children:`copilot`}),` and `,(0,b.jsx)(GS,{children:`/login`}),`. To pay with a model key instead, `,(0,b.jsx)(GS,{children:`fest copilot anthropic`}),` uses your `,(0,b.jsx)(GS,{children:`ANTHROPIC_API_KEY`}),` `,`and `,(0,b.jsx)(GS,{children:`fest copilot gw`}),` uses this gateway's own routes.`]})}];function qS(){let e=localStorage.getItem(WS);return KS.some(t=>t.id===e)?e:`claude`}function JS(){let e=localStorage.getItem(US);return e===`1`||e!==`0`&&null}var YS=2592e6;function XS(){return Qd.replace(/\/+$/,``)}function ZS(e){let[t,n]=(0,y.useState)(JS),r=Date.now(),i=nt({queryKey:[`setup-cli-usage`,e],queryFn:()=>nf.users({fromMs:r-YS,toMs:r}),enabled:e!==void 0,staleTime:6e4});if(e===void 0||!i.isSuccess)return null;let a=i.data.rows.find(t=>t.userId===e),o=a!==void 0&&a.requests>0;return{hasSessions:o,expanded:t??!o,setExpanded:e=>{localStorage.setItem(US,e?`1`:`0`),n(e)}}}function QS({state:e}){return(0,b.jsxs)(Wd,{type:`button`,variant:`outline`,size:`sm`,"aria-expanded":e.expanded,onClick:()=>e.setExpanded(!e.expanded),children:[(0,b.jsx)(Rt,{className:`size-3.5`}),`Setup CLI`]})}function $S({state:e}){let[t,n]=(0,y.useState)(qS);if(!e.expanded)return null;let{hasSessions:r,setExpanded:i}=e,a=XS(),o=KS.find(e=>e.id===t)??KS[0],s=e=>{localStorage.setItem(WS,e),n(e)},c=[{icon:Rt,title:`Install the CLI`,body:`Node 22.18 or newer. The package is fest-gateway; the command is fest.`,command:`npm install -g fest-gateway`},{icon:Et,title:`Sign in to this gateway`,body:`Opens a browser, then stores an identity token in ~/.fest. This is what attributes your usage to you.`,command:`fest login --server ${a}`},{icon:Pt,title:`Start a session`,body:o.body,command:o.command}];return(0,b.jsxs)(`section`,{"aria-labelledby":`setup-cli-heading`,className:`relative mb-5 overflow-hidden rounded-lg bg-card ring-1 ring-status-sub/30`,children:[(0,b.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 bg-gradient-to-br from-status-sub/8 via-transparent to-transparent`}),(0,b.jsxs)(`div`,{className:`relative p-5`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsxs)(`h2`,{id:`setup-cli-heading`,className:`text-base font-medium text-foreground`,children:[`Point `,o.name,` at Fest`]}),(0,b.jsx)(`p`,{className:`mt-1 max-w-[68ch] text-[13px] text-muted-foreground`,children:r?`Three commands to run ${o.name} through this gateway — on a new machine, or for someone you are setting up.`:`Nothing has come through on your account yet. Three commands and your next ${o.name} session runs through this gateway, metered here.`})]}),(0,b.jsx)(Lp,{"aria-label":`Coding agent`,className:`-mt-1 shrink-0`,children:KS.map(e=>(0,b.jsx)(Wd,{type:`button`,size:`sm`,variant:e.id===t?`default`:`outline`,"aria-pressed":e.id===t,onClick:()=>s(e.id),children:e.label},e.id))}),(0,b.jsxs)(Wd,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`Hide setup instructions`,"aria-expanded":!0,onClick:()=>i(!1),className:`-mt-1 shrink-0 text-muted-foreground`,children:[(0,b.jsx)(St,{className:`size-4`}),`Hide`]})]}),(0,b.jsx)(`ol`,{className:`mt-4 grid gap-3 md:grid-cols-3`,children:c.map((e,t)=>(0,b.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-lg bg-background/40 p-3 ring-1 ring-foreground/5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-status-sub/15 text-[11px] font-semibold text-status-sub`,children:t+1}),(0,b.jsx)(e.icon,{className:`size-3.5 shrink-0 text-status-sub`}),(0,b.jsx)(`h3`,{className:`truncate text-[13px] font-medium text-foreground`,children:e.title})]}),(0,b.jsx)(`p`,{className:`text-[12px] leading-relaxed text-muted-foreground`,children:e.body}),(0,b.jsx)(HS,{command:e.command,className:`mt-auto`})]},e.title))}),(0,b.jsxs)(`p`,{className:`mt-3 flex items-start gap-2 text-[12px] text-muted-foreground`,children:[(0,b.jsx)(vt,{className:`mt-0.5 size-3.5 shrink-0 text-status-ok`}),(0,b.jsx)(`span`,{children:o.note})]})]})]})}var eC=`https://github.com/cliftonc/fest-gateway`;function tC(){let e=S(),t=nt({queryKey:[`me`],queryFn:kS,refetchInterval:!1,staleTime:1/0});return(0,y.useEffect)(()=>{let t=()=>void e.invalidateQueries({queryKey:[`me`]});return window.addEventListener(`fest:unauthenticated`,t),()=>window.removeEventListener(`fest:unauthenticated`,t)},[e]),BS(t.data?.authenticated===!0),t.isPending?(0,b.jsx)(`div`,{className:`p-6 text-muted-foreground`,children:`Loading…`}):t.isError?(0,b.jsx)(`div`,{className:`grid min-h-screen place-items-center p-6`,children:(0,b.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg bg-card p-6 ring-1 ring-foreground/10`,children:[(0,b.jsx)(nC,{}),(0,b.jsxs)(`p`,{className:`mt-4 text-status-bad`,children:[`Cannot reach the gateway: `,t.error.message]})]})}):t.data.authenticated?(0,b.jsx)(iC,{user:t.data.user,onSignedOut:()=>void e.invalidateQueries()}):(0,b.jsx)(IS,{setupRequired:t.data.setupRequired,oauthProviders:t.data.oauthProviders,onSignedIn:()=>void e.invalidateQueries()})}function nC(){return(0,b.jsxs)(`div`,{className:`flex items-start gap-2.5 px-2.5`,children:[(0,b.jsx)(sn,{className:`mt-0.5 h-5 w-5 shrink-0 text-foreground`}),(0,b.jsx)(`div`,{className:`leading-tight`,children:(0,b.jsx)(`div`,{className:`text-[17px] font-semibold tracking-[0.02em]`,children:`Fest`})})]})}function rC(){let{theme:e,toggleTheme:t}=on();return(0,b.jsx)(Wd,{type:`button`,variant:`ghost`,size:`icon`,onClick:t,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,children:e===`dark`?(0,b.jsx)(It,{}):(0,b.jsx)(Ot,{})})}function iC({user:e,onSignedOut:t}){let n=qt(),[r,i]=(0,y.useState)(`24h`),[a,o]=(0,y.useState)(null),s=Zt(r),c=ZS(e?.id),l=n!==`live`&&n!==`routing`;return(0,b.jsxs)(`div`,{className:`grid h-screen grid-cols-[210px_1fr] overflow-hidden`,children:[(0,b.jsxs)(`nav`,{className:`flex flex-col gap-1 overflow-y-auto border-r bg-sidebar p-3 pt-4.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-2 pb-3.5`,children:[(0,b.jsx)(nC,{}),(0,b.jsx)(`a`,{href:eC,target:`_blank`,rel:`noreferrer noopener`,"aria-label":`Fest on GitHub`,title:`Fest on GitHub`,className:`mt-0.5 shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,b.jsx)(cn,{className:`size-4`})})]}),Wt.filter(t=>t!==`admin`||e?.role!==`member`).map(e=>(0,b.jsx)(`a`,{href:Jt(e),"aria-current":e===n?`page`:void 0,className:`block rounded-md px-2.5 py-1.5 text-sidebar-foreground no-underline hover:bg-sidebar-accent aria-[current=page]:bg-sidebar-primary aria-[current=page]:font-medium aria-[current=page]:text-sidebar-primary-foreground`,children:B[e]},e)),(0,b.jsxs)(`div`,{className:`mt-auto p-2.5 text-[11.5px] text-muted-foreground`,children:[e!==void 0&&(0,b.jsxs)(`div`,{className:`mb-3 flex flex-col gap-1.5`,children:[(0,b.jsx)(`span`,{className:`truncate text-foreground`,title:e.email,children:e.email}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(Wd,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{o(null),MS().then(t).catch(e=>o(e instanceof Error?e.message:`sign out failed`))},children:`Sign out`}),(0,b.jsx)(rC,{})]}),a!==null&&(0,b.jsx)(`span`,{className:`text-status-bad`,children:a})]}),`Metadata only — no prompts or responses are captured, and no credential is ever stored.`]})]}),(0,b.jsx)(`main`,{className:`overflow-y-auto`,children:(0,b.jsxs)(`div`,{className:`max-w-[1400px] px-6 pt-5 pb-15`,children:[(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-4`,children:[(0,b.jsx)(`h1`,{className:`text-xl font-medium`,children:B[n]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c!==null&&(0,b.jsx)(QS,{state:c}),l&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`label`,{htmlFor:`range`,className:`ml-1 text-xs text-muted-foreground`,children:`Range`}),(0,b.jsxs)(Gd,{value:r,onValueChange:i,children:[(0,b.jsx)(qd,{id:`range`,size:`sm`,className:`w-[150px]`,children:(0,b.jsx)(Kd,{})}),(0,b.jsx)(Jd,{children:Xt.map(e=>(0,b.jsx)(Yd,{value:e.id,children:e.label},e.id))})]})]})]})]}),c!==null&&(0,b.jsx)($S,{state:c}),n===`live`&&(0,b.jsx)(nm,{}),n===`routing`&&(0,b.jsx)(Bf,{}),n===`stats`&&(0,b.jsx)(xS,{range:s}),n===`users`&&(0,b.jsx)(SS,{range:s}),n===`models`&&(0,b.jsx)(CS,{range:s}),n===`errors`&&(0,b.jsx)(ES,{range:s}),n===`admin`&&(0,b.jsx)(OS,{})]})})]})}var aC=new Ue({defaultOptions:{queries:{staleTime:3e4,refetchInterval:6e4,refetchOnWindowFocus:!0,retry:!1}}}),oC=document.getElementById(`root`);if(oC===null)throw Error(`fest: #root is missing from index.html`);(0,Ut.createRoot)(oC).render((0,b.jsx)(y.StrictMode,{children:(0,b.jsx)(an,{children:(0,b.jsx)(C,{client:aC,children:(0,b.jsx)(mf,{delayDuration:200,children:(0,b.jsx)(tC,{})})})})}));
56
+ //# sourceMappingURL=index-DJb4NfM5.js.map