@usex/mikrotik-mcp 5.13.0 → 5.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -174,7 +174,7 @@ html[data-beui-vt="blinds"]::view-transition-new(root) {
174
174
  from { --beui-vt-slat: -20px; }
175
175
  to { --beui-vt-slat: 72px; }
176
176
  }
177
- `,HO={"top-left":`inset(0 100% 100% 0)`,"top-right":`inset(0 0 100% 100%)`,"bottom-left":`inset(100% 100% 0 0)`,"bottom-right":`inset(100% 0 0 100%)`,center:`inset(50% 50% 50% 50%)`,"bottom-up":`inset(100% 0 0 0)`},UO={"top-left":`0% 0%`,"top-right":`100% 0%`,"bottom-left":`0% 100%`,"bottom-right":`100% 100%`,center:`50% 50%`,"bottom-up":`50% 100%`};function WO({variant:e=`rectangle`,start:t=`bottom-up`}={}){let[n,r]=JO(),i=RD()??!1,[a,o]=(0,v.useState)(!1);(0,v.useEffect)(()=>o(!0),[]),(0,v.useEffect)(()=>{if(document.getElementById(BO))return;let e=document.createElement(`style`);e.id=BO,e.textContent=VO,document.head.appendChild(e)},[]);let s=a&&n===`dark`;return{isDark:s,mounted:a,toggle:()=>{let n=s?`light`:`dark`;if(i||!(`startViewTransition`in document)){r(n);return}let a=document.documentElement;e===`rectangle`?(a.style.setProperty(`--beui-vt-from`,HO[t]),a.dataset.beuiVt=`rect`):e===`blinds`?a.dataset.beuiVt=`blinds`:(a.style.setProperty(`--beui-vt-origin`,UO[t]),a.dataset.beuiVt=e),document.startViewTransition(()=>r(n)).finished.finally(()=>{delete a.dataset.beuiVt})}}}function GO({variant:e=`rectangle`,start:t=`bottom-up`,className:n,iconClassName:r,...i}){let{isDark:a,mounted:o,toggle:s}=WO({variant:e,start:t});return(0,G.jsx)(`button`,{type:`button`,"aria-label":o&&a?`Switch to light mode`:`Switch to dark mode`,onClick:s,className:J(`flex items-center justify-center`,n),...i,children:o?(0,G.jsx)(zO,{value:a?`dark`:`light`,animation:`blur`,className:r,children:a?(0,G.jsx)(Hd,{className:r}):(0,G.jsx)(Iu,{className:r})}):(0,G.jsx)(`span`,{className:r,"aria-hidden":`true`})})}var KO=`mt-theme`;function qO(){try{return localStorage.getItem(KO)===`light`?`light`:`dark`}catch{return`dark`}}function JO(){let[e,t]=(0,v.useState)(qO);return(0,v.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e===`dark`)},[e]),[e,(0,v.useCallback)(e=>{t(e);try{localStorage.setItem(KO,e)}catch{}},[])]}function YO(){return(0,G.jsx)(GO,{variant:`circle`,className:`size-9 rounded-md hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,iconClassName:`size-4`})}function XO(e){let[t]=JO();return(0,G.jsx)(MO,{theme:t,className:`toaster group`,position:`bottom-right`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground`,error:`group-[.toast]:text-destructive`,success:`group-[.toast]:text-foreground`}},...e})}function ZO({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,G.jsx)(`table`,{"data-slot":`table`,className:K(`w-full caption-bottom text-sm`,e),...t})})}function QO({className:e,...t}){return(0,G.jsx)(`thead`,{"data-slot":`table-header`,className:K(`[&_tr]:border-b`,e),...t})}function $O({className:e,...t}){return(0,G.jsx)(`tbody`,{"data-slot":`table-body`,className:K(`[&_tr:last-child]:border-0`,e),...t})}function ek({className:e,...t}){return(0,G.jsx)(`tr`,{"data-slot":`table-row`,className:K(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function tk({className:e,...t}){return(0,G.jsx)(`th`,{"data-slot":`table-head`,className:K(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function nk({className:e,...t}){return(0,G.jsx)(`td`,{"data-slot":`table-cell`,className:K(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function rk({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card`,className:K(`flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm`,e),...t})}function pre({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-header`,className:K(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function mre({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-title`,className:K(`leading-none font-semibold`,e),...t})}function hre({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-content`,className:K(`px-6`,e),...t})}function X({title:e,extra:t,children:n,className:r}){return(0,G.jsxs)(rk,{className:K(`dashboard-panel gap-0 py-5`,r),children:[e!=null&&(0,G.jsxs)(pre,{className:`flex flex-row flex-wrap items-center gap-3 px-5 pb-3`,children:[(0,G.jsx)(mre,{className:`text-base font-semibold`,children:e}),t!=null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`flex-1`}),t]})]}),(0,G.jsx)(hre,{className:`px-5`,children:n})]})}function ik({k:e,v:t,sub:n,cls:r}){return(0,G.jsxs)(rk,{className:`dashboard-stat gap-2 px-4 py-4`,children:[(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs tracking-wide uppercase`,children:e}),(0,G.jsxs)(`div`,{className:K(`text-2xl font-semibold tabular-nums`,r),children:[t,n!=null&&(0,G.jsxs)(`small`,{className:`text-muted-foreground ml-1 text-sm`,children:[` `,n]})]})]})}function ak({rows:e}){let t=Math.max(1,...e.map(e=>e.value));return(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_1fr_auto] items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,title:e.label,children:e.label}),(0,G.jsx)(`div`,{className:`bg-muted h-2 overflow-hidden rounded-full`,children:(0,G.jsx)(`div`,{className:K(`h-full rounded-full`,!e.color&&`bg-brand`),style:{width:`${e.value/t*100}%`,background:e.color}})}),(0,G.jsx)(`span`,{className:`text-xs tabular-nums`,children:e.sub??String(e.value)})]},e.label))})}function ok({text:e,label:t=`Copy`,className:n,icon:r=!1,title:i}){let[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>void(s.current&&clearTimeout(s.current)),[]),(0,G.jsxs)(nO,{type:`button`,variant:`outline`,size:r?`icon-sm`:`sm`,className:n,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{o(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>o(!1),1400)},()=>{})},title:i??`Copy to clipboard`,"aria-label":i??`Copy to clipboard`,children:[a?(0,G.jsx)(cl,{className:`text-success`}):r?(0,G.jsx)(Pl,{}):t,a&&(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`Copied!`})]})}var gre=[50,100,200,500,1e3,2e3],_re={initial:{opacity:0,filter:`blur(6px)`},animate:{opacity:1,filter:`blur(0px)`},exit:e=>e?{}:{opacity:0,filter:`blur(6px)`}},vre={initial:{opacity:0},animate:{opacity:1},exit:e=>e?{}:{opacity:0}},yre=(0,v.forwardRef)(({children:e,as:t=`div`,className:n,onMouseLeave:r,pillClassName:i,pillContainerClassName:a,inset:o=20,...s},c)=>{let[l,u]=(0,v.useState)(null),d=(0,v.useId)(),f=RD(),p=v.Children.toArray(e).filter(v.isValidElement).map((e,t)=>{let n=e,r=n.key?String(n.key):`item-${t}`;return(0,v.cloneElement)(n,{key:r,className:J(`relative`,n.props.className),onMouseEnter:()=>{n.props.onMouseEnter?.(),u(r)}},(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(BE,{custom:l!==null,children:l===null?null:(0,G.jsx)(q.div,{variants:f?vre:_re,initial:`initial`,animate:`animate`,exit:`exit`,custom:l!==null,className:J(`pointer-events-none absolute inset-y-0`,a),style:{left:-o,right:-o},children:l===r?(0,G.jsx)(q.div,{layoutId:`shared-bg-${d}`,transition:f?{duration:0}:ZD,className:J(`pointer-events-none h-full w-full rounded-2xl bg-primary/[0.06]`,i)}):null})}),(0,G.jsx)(`div`,{className:`relative z-10`,children:n.props.children})]}))}),m=e=>{u(null),r?.(e)};return t===`ul`?(0,G.jsx)(q.ul,{...s,ref:c,layoutRoot:!0,onMouseLeave:m,className:J(`flex w-full flex-col`,n),children:p}):(0,G.jsx)(q.div,{...s,ref:c,layoutRoot:!0,onMouseLeave:m,className:J(`flex w-full flex-col`,n),children:p})}),sk=`(max-width: 899px)`,bre=`b`,ck={duration:.36,ease:Kne},xre={type:`spring`,stiffness:380,damping:35,mass:.75},Sre={duration:.2,delay:.08,ease:qD},Cre={duration:.12,ease:qD},lk={duration:.18,ease:qD},uk={closed:{opacity:0,clipPath:`inset(0 0 100% 0 round 8px)`,transition:{duration:.14,ease:qD,staggerChildren:.025,staggerDirection:-1}},open:{opacity:1,clipPath:`inset(0 0 0% 0 round 8px)`,transition:{duration:.2,delayChildren:.035,ease:qD,staggerChildren:.045}}},dk={closed:{opacity:0,y:-6,filter:`blur(3px)`},open:{opacity:1,y:0,filter:`blur(0px)`,transition:lk}},fk={duration:.16,ease:qD},pk=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex='-1'])`].join(`,`);function mk(e){let t=window.matchMedia(sk);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function hk(){return window.matchMedia(sk).matches}function gk(){return!1}function _k(){return(0,v.useSyncExternalStore)(mk,hk,gk)}var vk=(0,v.createContext)(null),yk=(0,v.createContext)(null);function bk(){let e=(0,v.useContext)(vk);if(!e)throw Error(`useAnimatedSidebar must be used inside AnimatedSidebarProvider.`);return e}function xk(){let e=(0,v.useContext)(yk);if(!e)throw Error(`Animated Sidebar parts must be used inside AnimatedSidebar.`);return e}function Sk({children:e,open:t,defaultOpen:n=!0,onOpenChange:r,openMobile:i,defaultOpenMobile:a=!1,onOpenMobileChange:o,className:s,style:c,...l}){let[u,d]=(0,v.useState)(n),[f,p]=(0,v.useState)(a),m=_k(),h=RD()??!1,g=(0,v.useId)(),_=(0,v.useRef)(null),y=t??u,b=i??f,x=(0,v.useCallback)(e=>{t===void 0&&d(e),r?.(e)},[r,t]),S=(0,v.useCallback)(e=>{i===void 0&&p(e),o?.(e)},[o,i]),C=(0,v.useCallback)(()=>{m?S(!b):x(!y)},[y,m,b,x,S]);return(0,v.useEffect)(()=>{let e=e=>{e.key.toLowerCase()===bre&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]),(0,G.jsx)(vk.Provider,{value:{isMobile:m,layoutId:`${g}-active`,open:y,openMobile:b,reduce:h,setOpen:x,setOpenMobile:S,state:y?`expanded`:`collapsed`,toggleSidebar:C,triggerRef:_},children:(0,G.jsx)(`div`,{...l,"data-slot":`sidebar-wrapper`,"data-state":y?`expanded`:`collapsed`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`4.25rem`,"--sidebar-width-mobile":`18rem`,...c},className:J(`group/sidebar-wrapper flex min-h-svh w-full min-w-0`,s),children:e})})}function Ck({ariaLabel:e,children:t,className:n,side:r}){let i=bk(),a=(0,v.useRef)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!i.openMobile),u=(0,v.useRef)(i.openMobile),d=(0,v.useCallback)(()=>{let e=a.current;e&&!e.contains(document.activeElement)&&([...e.querySelectorAll(pk)].find(e=>e.getClientRects().length>0&&!e.closest(`[inert], [hidden]`))??e).focus({preventScroll:!0})},[]);return(0,v.useEffect)(()=>s(!0),[]),(0,v.useEffect)(()=>{u.current=i.openMobile,i.openMobile&&l(!1)},[i.openMobile]),(0,v.useEffect)(()=>{if(!i.openMobile)return;let e=document.body,t=window.scrollY,n={left:e.style.left,overflow:e.style.overflow,position:e.style.position,right:e.style.right,top:e.style.top};e.style.position=`fixed`,e.style.top=`-${t}px`,e.style.left=`0`,e.style.right=`0`,e.style.overflow=`hidden`;let r=requestAnimationFrame(d);return()=>{cancelAnimationFrame(r),e.style.position=n.position,e.style.top=n.top,e.style.left=n.left,e.style.right=n.right,e.style.overflow=n.overflow,window.scrollTo(0,t),i.triggerRef.current?.focus({preventScroll:!0})}},[i.openMobile,i.triggerRef,d]),o?(0,Ff.createPortal)((0,G.jsxs)(`div`,{className:J(`pointer-events-none fixed left-0 top-0 z-[45] size-0 min-[900px]:hidden`,c&&!i.openMobile?`invisible`:`visible`),children:[(0,G.jsx)(q.button,{type:`button`,"aria-label":`Close sidebar`,tabIndex:i.openMobile?0:-1,initial:!1,animate:{opacity:+!!i.openMobile},transition:i.reduce?fk:ck,onClick:()=>i.setOpenMobile(!1),className:J(`fixed inset-0 bg-black/40`,i.openMobile?`pointer-events-auto`:`pointer-events-none`)}),(0,G.jsx)(q.div,{ref:a,role:`dialog`,"aria-modal":`true`,"aria-label":e,"aria-hidden":!i.openMobile,inert:!i.openMobile,tabIndex:-1,"data-mobile":`true`,"data-state":i.openMobile?`expanded`:`collapsed`,"data-side":r,initial:!1,animate:{opacity:i.reduce?+!!i.openMobile:1,x:i.reduce?0:i.openMobile?`0%`:r===`left`?`-100%`:`100%`},transition:i.reduce?fk:ck,onAnimationComplete:()=>{u.current?d():l(!0)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),i.setOpenMobile(!1);return}if(e.key!==`Tab`)return;let t=a.current?Array.from(a.current.querySelectorAll(pk)).filter(e=>e.getClientRects().length>0&&!e.closest(`[inert], [hidden]`)):[];if(t.length===0){e.preventDefault(),a.current?.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())},className:J(`pointer-events-auto fixed inset-y-0 flex h-dvh w-(--sidebar-width-mobile) max-w-[88vw] flex-col overflow-hidden`,`border-border bg-background shadow-2xl will-change-transform`,r===`left`?`left-0 border-r`:`right-0 border-l`,!i.openMobile&&`pointer-events-none`,n),children:(0,G.jsx)(yk.Provider,{value:{collapsed:!1,collapsible:`none`,side:r},children:t})})]}),document.body):null}var wk=(0,v.forwardRef)(({side:e=`left`,variant:t=`sidebar`,collapsible:n=`icon`,ariaLabel:r=`Sidebar`,children:i,className:a,panelClassName:o,style:s,...c},l)=>{let u=bk(),d=n!==`none`&&!u.open,f=d&&n===`offcanvas`,p=f?`0px`:d?`var(--sidebar-width-icon)`:`var(--sidebar-width)`;return u.isMobile?(0,G.jsx)(Ck,{ariaLabel:r,className:a,side:e,children:i}):(0,G.jsx)(q.aside,{...c,ref:l,initial:!1,"aria-label":r,"data-slot":`sidebar`,"data-state":d?`collapsed`:`expanded`,"data-collapsible":n,"data-variant":t,"data-side":e,animate:{width:p},transition:u.reduce?{duration:0}:xre,style:s,className:J(`group/sidebar relative hidden h-auto shrink-0 min-[900px]:block will-change-[width]`,`peer`,e===`right`&&`order-last`,a),children:(0,G.jsx)(q.div,{initial:!1,animate:{opacity:+!f,x:f?e===`left`?`-100%`:`100%`:`0%`},transition:u.reduce?fk:ck,className:J(`sticky top-0 flex h-svh w-full flex-col overflow-hidden bg-background`,n===`offcanvas`&&`w-[var(--sidebar-width)]`,t===`sidebar`&&(e===`left`?`border-border border-r`:`border-border border-l`),t===`floating`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl border border-border shadow-sm`,t===`inset`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl`,o),children:(0,G.jsx)(yk.Provider,{value:{collapsed:d,collapsible:n,side:e},children:i})})})}),Tk=(0,v.forwardRef)(({className:e,onClick:t,type:n=`button`,...r},i)=>{let a=bk(),o=a.isMobile?a.openMobile:a.open;return(0,G.jsx)(`button`,{...r,ref:e=>{a.triggerRef.current=e,typeof i==`function`?i(e):i&&(i.current=e)},type:n,"aria-label":r[`aria-label`]??`Toggle sidebar`,"aria-expanded":o,"data-slot":`sidebar-trigger`,"data-state":o?`expanded`:`collapsed`,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:J(`inline-flex size-10 shrink-0 items-center justify-center rounded-xl outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,e)})});(0,v.forwardRef)(({className:e,onClick:t,type:n=`button`,...r},i)=>{let a=bk();return(0,G.jsx)(`button`,{...r,ref:i,type:n,"aria-label":r[`aria-label`]??`Close sidebar`,onClick:e=>{t?.(e),!e.defaultPrevented&&(a.isMobile?a.setOpenMobile(!1):a.setOpen(!1))},className:J(`inline-flex size-10 shrink-0 items-center justify-center rounded-xl outline-none`,`focus-visible:ring-2 focus-visible:ring-ring`,e)})}),(0,v.forwardRef)(({className:e,onClick:t,type:n=`button`,...r},i)=>{let a=bk(),o=xk();return(0,G.jsx)(`button`,{...r,ref:i,type:n,"data-side":o.side,"aria-label":r[`aria-label`]??`Toggle sidebar`,title:`Toggle sidebar`,tabIndex:-1,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:J(`absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 outline-none md:block`,`after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent after:transition-colors hover:after:bg-border`,`data-[side=right]:right-0 data-[side=right]:translate-x-1/2 data-[side=left]:left-full`,e)})}),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(q.main,{...t,ref:n,"data-slot":`sidebar-inset`,className:J(`relative flex min-h-svh min-w-0 flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl md:peer-data-[variant=inset]:shadow-sm`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-header`,className:J(`flex shrink-0 flex-col gap-2 p-3`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-content`,className:J(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-2`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-footer`,className:J(`flex shrink-0 flex-col gap-2 border-border border-t p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group`,className:J(`flex w-full min-w-0 flex-col px-1 py-1.5`,e)})),(0,v.forwardRef)(({children:e,className:t,...n},r)=>{let{collapsed:i}=xk();return(0,G.jsx)(`div`,{...n,ref:r,"aria-hidden":i,"data-slot":`sidebar-group-label`,className:J(`mb-1 h-7 overflow-hidden px-2 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-opacity`,i?`opacity-0`:`opacity-100`,t),children:e})}),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group-content`,className:J(`w-full min-w-0`,e)})),(0,v.forwardRef)(({children:e,className:t,...n},r)=>(0,G.jsx)(yre,{...n,ref:r,as:`ul`,inset:0,pillClassName:`rounded-xl bg-muted/70`,pillContainerClassName:`inset-y-auto top-0 h-9`,"data-slot":`sidebar-menu`,className:J(`flex w-full min-w-0 list-none flex-col gap-0.5`,t),children:e})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(q.li,{...t,ref:n,layout:`position`,transition:ZD,"data-slot":`sidebar-menu-item`,className:J(`relative`,e)})),(0,v.forwardRef)(({open:e,children:t,className:n,...r},i)=>{let a=bk(),o=xk();return(0,G.jsx)(BE,{initial:!1,mode:`popLayout`,children:e&&!o.collapsed?(0,v.createElement)(q.ul,{...r,ref:i,key:`sidebar-submenu`,variants:a.reduce?void 0:uk,initial:!a.reduce&&`closed`,animate:a.reduce?{opacity:1}:`open`,exit:a.reduce?{opacity:0}:`closed`,transition:a.reduce?{duration:.12}:void 0,"data-slot":`sidebar-menu-sub`,className:J(`relative mt-1 ml-5 flex min-w-0 flex-col gap-0.5 border-border border-l pl-3`,n)},t):null})}),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(q.li,{...t,ref:n,variants:dk,"data-slot":`sidebar-menu-sub-item`,className:J(`relative min-w-0`,e)}));function Ek({children:e,icon:t,badge:n,accessibleLabel:r,href:i,isActive:a=!1,ariaExpanded:o,disabled:s=!1,closeOnSelect:c,target:l,rel:u,onSelect:d,className:f,activeLayoutId:p}){let m=bk(),h=xk(),g=typeof e==`string`?e:void 0,_=e=>{if(s){e.preventDefault();return}if(i&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))return;i&&d&&e.preventDefault(),d?.();let t=c??o===void 0;m.isMobile&&t&&m.setOpenMobile(!1),o!==void 0&&h.collapsed&&!m.isMobile&&m.setOpen(!0)},v=(0,G.jsxs)(G.Fragment,{children:[a?(0,G.jsx)(q.span,{layoutId:p?`${m.layoutId}-${p}`:m.layoutId,transition:m.reduce?{duration:0}:ZD,className:`absolute inset-0 rounded-xl bg-muted`}):null,t?(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`relative z-10 grid size-5 shrink-0 place-items-center`,children:t}):null,(0,G.jsx)(q.span,{initial:!1,animate:{opacity:+!h.collapsed,x:h.collapsed?-4:0},transition:m.reduce?fk:h.collapsed?Cre:Sre,"aria-hidden":h.collapsed,"data-slot":`sidebar-menu-label`,className:J(`relative z-10 min-w-0 flex-1 truncate`,h.collapsed&&`pointer-events-none`),children:e}),n&&!h.collapsed?(0,G.jsx)(`span`,{className:`relative z-10 shrink-0 text-xs text-muted-foreground`,children:n}):null,o===void 0?null:(0,G.jsx)(q.span,{"aria-hidden":`true`,initial:!1,animate:{opacity:+!h.collapsed,rotate:o?90:0,x:h.collapsed?4:0},transition:m.reduce?{duration:0}:ZD,className:`relative z-10 grid size-4 shrink-0 place-items-center text-muted-foreground`,children:(0,G.jsx)(fl,{className:`size-3.5`})})]}),y=J(`relative flex min-h-9 w-full min-w-0 items-center gap-2.5 overflow-hidden rounded-xl px-3 text-left text-sm font-medium outline-none`,`text-muted-foreground transition-colors hover:text-foreground`,`focus-visible:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring`,a&&`text-foreground`,s&&`cursor-not-allowed opacity-40`,f);return i?(0,G.jsx)(q.a,{href:i,target:l,rel:u??(l===`_blank`?`noreferrer noopener`:void 0),"aria-current":a?`page`:void 0,"aria-expanded":o,"aria-disabled":s||void 0,"aria-label":r??(h.collapsed?g:void 0),title:h.collapsed?r??g:void 0,tabIndex:s?-1:void 0,onClick:_,whileTap:m.reduce||s?void 0:{scale:.98},transition:YD,className:y,children:v}):(0,G.jsx)(q.button,{type:`button`,disabled:s,"aria-current":a?`page`:void 0,"aria-expanded":o,"aria-label":r??(h.collapsed?g:void 0),title:h.collapsed?r??g:void 0,onClick:_,whileTap:m.reduce||s?void 0:{scale:.98},transition:YD,className:y,children:v})}var Dk=(0,v.forwardRef)(({label:e,value:t,defaultValue:n,onChange:r,onInputChange:i,onFocus:a,onBlur:o,error:s,reserveErrorLine:c=!1,success:l,leftIcon:u,rightIcon:d,className:f,classNames:p,disabled:m,id:h,type:g,..._},y)=>{let b=(0,v.useId)(),x=h??b,S=RD(),C=t!==void 0,[w,T]=(0,v.useState)(n??``),E=C?t??``:w,[D,O]=(0,v.useState)(!1),k=(0,v.useRef)(null),A=!!s,j=typeof s==`string`?s:null,M=l?null:d;(0,v.useEffect)(()=>{k.current&&!S&&A&&KD(k.current,{x:[0,-6,6,-4,4,-2,0]},{duration:.45})},[A,S]);let N=e=>{C||T(e),r?.(e)};return(0,G.jsxs)(`div`,{className:J(`flex flex-col gap-1.5`,f,p?.root),children:[e?(0,G.jsx)(`label`,{htmlFor:x,className:J(`px-1 text-sm font-medium text-foreground`,p?.label),children:e}):null,(0,G.jsxs)(`div`,{ref:k,"data-state":A?`error`:l?`success`:D?`focused`:`idle`,className:J(`relative h-11 overflow-hidden rounded-full border transition-colors duration-200`,`border-border`,D&&!A&&`border-foreground/40 ring-2 ring-ring/40`,A&&`border-destructive ring-2 ring-destructive/25`,m&&`opacity-60`,p?.field),children:[u?(0,G.jsx)(`span`,{className:J(`pointer-events-none absolute left-3 top-1/2 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:h-4 [&_svg]:w-4`,p?.leftIcon),children:u}):null,(0,G.jsx)(`input`,{ref:y,id:x,type:g,value:g===`file`?void 0:E,disabled:m,"aria-invalid":A||void 0,"aria-describedby":j?`${x}-error`:void 0,..._,onChange:e=>{g!==`file`&&N(e.target.value),i?.(e)},onFocus:e=>{O(!0),a?.(e)},onBlur:e=>{O(!1),o?.(e)},className:J(`peer h-full w-full bg-transparent text-base leading-6 text-foreground caret-foreground outline-none`,`placeholder:text-muted-foreground/60`,u?`pl-10`:`pl-3.5`,M||l?`pr-10`:`pr-3.5`,m&&`cursor-not-allowed`,p?.input)}),l?(0,G.jsx)(q.svg,{viewBox:`0 0 24 24`,fill:`none`,className:J(`absolute right-3.5 top-1/2 h-5 w-5 -translate-y-1/2 text-(--color-success)`,p?.successIcon),children:(0,G.jsx)(q.path,{d:`M5 12.5l4.5 4.5L19 7.5`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:S?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:{duration:.35,ease:`easeOut`}})}):M?(0,G.jsx)(`span`,{className:J(`absolute right-0 top-0 flex h-full items-center text-muted-foreground [&_button]:grid [&_button]:size-11 [&_button]:place-items-center [&_svg]:h-4 [&_svg]:w-4`,p?.rightIcon),children:M}):null]}),(0,G.jsx)(`div`,{className:c?`min-h-4`:`contents`,children:(0,G.jsx)(BE,{initial:!1,children:j?(0,G.jsx)(q.p,{id:`${x}-error`,role:`alert`,initial:S?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},animate:{opacity:1,y:0,filter:`blur(0px)`},exit:S?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},transition:{duration:.2},className:J(`px-1 text-xs text-destructive`,p?.errorMessage),children:j}):null})})]})});function Ok({className:e,value:t,defaultValue:n,onChange:r,...i}){return(0,G.jsx)(Dk,{...i,"data-slot":`input`,value:t==null?void 0:String(t),defaultValue:n==null?void 0:String(n),onInputChange:r,className:`min-w-0`,classNames:{field:`h-9 rounded-xl`,input:K(`text-[13px] leading-5`,e)}})}var kk=[{id:`home-internet`,label:`Home Internet`,sub:`Understand slowdowns, manage your household & compare paths`},{id:`overview`,label:`Overview`,sub:`Calls, latency & risk at a glance`},{id:`devices`,label:`Devices`,sub:`Connectivity radar & system health`},{id:`clients`,label:`Clients`,sub:`Connected LAN devices — usage, block/allow, pin IP`},{id:`investigations`,label:`Investigations`,sub:`Client and service evidence across routers`},{id:`service-contracts`,label:`Service Health`,sub:`Approved endpoint checks, contracts and evidence`},{id:`aaa`,label:`RADIUS & UM`,sub:`RADIUS client & User Manager RADIUS server`},{id:`topology`,label:`Topology`,sub:`Layer-2 neighbours via MNDP / CDP / LLDP`},{id:`round-trip`,label:`Round-trip Lab`,sub:`Forward and return paths across snapshots`},{id:`fabric`,label:`L2 Fabric`,sub:`Which host sits on which physical bridge port`},{id:`vulns`,label:`Vulnerabilities`,sub:`Published CVEs matched to this version, ranked by real exposure`},{id:`access`,label:`Access Scope`,sub:`What this session may call — and what it blocked`},{id:`packets`,label:`Packets`,sub:`Live TZSP capture & decode`},{id:`flows`,label:`Flows`,sub:`NetFlow/IPFIX top talkers, conversations & anomalies`},{id:`snapshots`,label:`Snapshots`,sub:`Config history & time-travel diff`},{id:`drift`,label:`Drift Guard`,sub:`Golden config baselines & live drift detection`},{id:`attacks`,label:`Attacks`,sub:`Live attack incidents, evidence and guarded blocking`},{id:`policies`,label:`Policies`,sub:`Your own compliance rules, linted against config`},{id:`explain`,label:`Explain`,sub:`Config → architecture document, diagram and consequence diffs`},{id:`simulator`,label:`Simulator`,sub:`Trace a hypothetical packet — no device touched`},{id:`schedules`,label:`Schedules`,sub:`Auditors on a cron — alerting only on what changed`},{id:`txn`,label:`Transactions`,sub:`Cross-device two-phase commit — prepare, verify, commit everywhere`},{id:`plan`,label:`Change Plan`,sub:`Dry-run intended RouterOS commands`},{id:`s3`,label:`S3 Backups`,sub:`List, download & delete S3 backup objects`},{id:`backups`,label:`Backups`,sub:`Local config vault — create, restore, manage`},{id:`modules`,label:`Modules`,sub:`Enable/disable tool modules — curate the surface`},{id:`config`,label:`Config`,sub:`Effective configuration & safe editor`},{id:`memory`,label:`Memory`,sub:`Knowledge graph — entities, relations & observations`},{id:`alerts`,label:`Alerts`,sub:`Rules that reach out — Slack, Discord, ntfy, webhook, MCP`},{id:`releases`,label:`Releases`,sub:`Update, downgrade & read every version's notes`},{id:`capsman`,label:`CAPsMAN`,sub:`Wi-Fi fabric: coverage, weak signal, load, FT & HA`},{id:`feed`,label:`Live Feed`,sub:`Every tool call, in real time`}],Ak=[{id:`observe`,label:`Observe`,views:[`overview`,`home-internet`,`devices`,`clients`,`feed`]},{id:`investigate`,label:`Investigate`,views:[`investigations`,`service-contracts`,`round-trip`,`topology`,`fabric`,`flows`,`packets`]},{id:`protect`,label:`Protect`,views:[`attacks`,`vulns`,`policies`,`access`,`aaa`,`capsman`]},{id:`operate`,label:`Operate`,views:[`plan`,`simulator`,`txn`,`snapshots`,`drift`,`backups`,`s3`,`schedules`,`explain`]},{id:`workspace`,label:`Workspace`,views:[`modules`,`config`,`memory`,`alerts`,`releases`]}];function jk(e){return Ak.find(t=>t.views.includes(e))??Ak[0]}function Mk(e){let t=e.replace(/^#\/?/,``);return kk.find(e=>e.id===t)?.id??null}function Nk(e){let t=e.trim().toLowerCase().split(/\s+/).filter(Boolean);return Ak.map(e=>({...e,items:e.views.map(e=>kk.find(t=>t.id===e)).filter(n=>t.every(t=>`${n.label} ${n.sub} ${e.label}`.toLowerCase().includes(t)))})).filter(e=>e.items.length>0)}var Pk=`mt-pinned-pages`,Fk=new Set(kk.map(e=>e.id));function Ik(e){try{let t=JSON.parse(e??`[]`);return Array.isArray(t)?[...new Set(t.filter(e=>typeof e==`string`&&Fk.has(e)))]:[]}catch{return[]}}function Lk(e){try{return Ik((e??window.localStorage).getItem(Pk))}catch{return[]}}function Rk(e,t){try{return(t??window.localStorage).setItem(Pk,JSON.stringify(e)),!0}catch{return!1}}function zk(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}var Bk=e=>e<1?`<1ms`:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`;function Vk(e){let t=[`B`,`KiB`,`MiB`,`GiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(+!!n)} ${t[n]}`}var Hk=e=>new Date(e).toLocaleTimeString(void 0,{hour12:!1}),Uk=e=>e.toLocaleString(),Wk=e=>e==null?`?`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),Gk={cpu:`var(--chart-1)`,mem:`var(--chart-5)`,disk:`var(--chart-2)`,latency:`var(--chart-4)`},Kk={READ:`var(--chart-3)`,WRITE:`var(--chart-1)`,WRITE_IDEMPOTENT:`var(--chart-2)`,DESTRUCTIVE:`var(--chart-4)`,DANGEROUS:`var(--destructive)`},qk={READ:`border-chart-3/40 text-chart-3`,WRITE:`border-chart-1/40 text-chart-1`,WRITE_IDEMPOTENT:`border-chart-2/40 text-chart-2`,DESTRUCTIVE:`border-chart-4/40 text-chart-4`,DANGEROUS:`border-destructive/40 text-destructive`},Jk=[[`5m`,3e5],[`15m`,9e5],[`1h`,36e5],[`6h`,216e5],[`24h`,864e5]],Yk=1e4,Xk={neutral:`border-border bg-card text-muted-foreground`,info:`border-primary/30 bg-primary/10 text-primary`,success:`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`border-destructive/30 bg-destructive/10 text-destructive`,loading:`border-primary/30 bg-primary/10 text-primary`},Zk={sm:`h-6 gap-1.5 px-2 text-[11px]`,md:`h-8 gap-2 px-3 text-xs`},Qk={sm:`h-3 w-3`,md:`h-3.5 w-3.5`},$k={neutral:wl,info:gu,success:cl,warning:Jd,danger:df,loading:wu},eA={initial:{opacity:.72,y:`80%`,scale:.92,rotate:-8,filter:`blur(6px)`},animate:{opacity:1,y:`0%`,scale:1,rotate:0,filter:`blur(0px)`,transition:{y:{type:`spring`,stiffness:210,damping:24,mass:.85},scale:{type:`spring`,stiffness:250,damping:24,mass:.75},rotate:{duration:.28,ease:qD},opacity:{duration:.28,ease:qD},filter:{duration:.42,ease:qD}}},exit:{opacity:.5,y:`-80%`,scale:.96,rotate:8,filter:`blur(6px)`,transition:{duration:.22,ease:qD}}},tA={initial:{opacity:.76,y:`85%`,filter:`blur(6px)`},animate:{opacity:1,y:`0%`,filter:`blur(0px)`,transition:{y:{type:`spring`,stiffness:210,damping:24,mass:.85},opacity:{duration:.3,ease:qD},filter:{duration:.42,ease:qD}}},exit:{opacity:.5,y:`-85%`,filter:`blur(6px)`,transition:{duration:.2,ease:qD}}};function nA({status:e=`neutral`,size:t=`md`,children:n,icon:r,showIcon:i=!0,pulse:a=e===`loading`,contentKey:o,className:s,...c}){let l=RD(),u=$k[e],d=o??(typeof n==`string`||typeof n==`number`?n:e);return(0,G.jsxs)(q.span,{layout:!l,transition:l?{duration:0}:{type:`spring`,stiffness:420,damping:30,mass:.7},className:J(`relative inline-flex shrink-0 items-center overflow-hidden whitespace-nowrap rounded-full border font-medium tabular-nums`,`transition-colors duration-300`,Xk[e],Zk[t],s),...c,children:[a&&!l?(0,G.jsx)(q.span,{"aria-hidden":!0,className:`absolute inset-0 rounded-full bg-current opacity-10`,animate:{scale:[.94,1.08,.94],opacity:[.08,.16,.08]},transition:{duration:1.6,repeat:1/0,ease:`easeInOut`}}):null,i?(0,G.jsx)(`span`,{className:`relative z-10 inline-flex items-center justify-center overflow-hidden`,children:(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:(0,G.jsx)(q.span,{"aria-hidden":!0,"data-badge-icon":!0,variants:eA,initial:!l&&`initial`,animate:l?{opacity:1}:`animate`,exit:l?void 0:`exit`,className:`inline-flex will-change-transform`,children:e===`loading`&&!l&&!r?(0,G.jsx)(q.span,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:`linear`},className:`inline-flex`,children:(0,G.jsx)(u,{className:Qk[t]})}):r??(0,G.jsx)(u,{className:Qk[t]})},e)})}):null,n==null?null:(0,G.jsx)(`span`,{className:`relative z-10 inline-flex overflow-hidden`,children:(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:(0,G.jsx)(q.span,{"data-badge-label":!0,variants:tA,initial:!l&&`initial`,animate:l?{opacity:1}:`animate`,exit:l?void 0:`exit`,className:`inline-block will-change-transform`,children:n},d)})})]})}var rA={"home-internet":`5.12.0`,overview:null,devices:null,clients:null,investigations:null,"service-contracts":null,"round-trip":null,aaa:null,topology:null,fabric:null,vulns:null,access:null,packets:null,flows:null,snapshots:null,drift:null,policies:null,simulator:null,schedules:null,explain:null,attacks:null,txn:null,plan:null,s3:null,backups:null,modules:null,config:null,memory:null,alerts:null,releases:null,capsman:null,feed:null};function iA(e){return e?.trim().match(/^v?((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?)(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/)?.[1]??null}function aA(e,t){let n=iA(rA[e]);return n&&n===iA(t)?n:null}function oA({view:e,version:t,placement:n=`menu`}){let r=aA(e,t);if(!r)return null;let i=`New in v${r}`,a=`${i} · Highlighted for this release, even after you visit.`;return n===`icon`?(0,G.jsx)(`span`,{className:`feature-new-dot`,title:a,"aria-label":i,"data-feature-release":r}):(0,G.jsx)(nA,{status:`info`,size:`sm`,pulse:!1,icon:(0,G.jsx)(Pd,{size:12}),showIcon:n===`page`,className:`feature-new-badge feature-new-${n}`,title:a,"aria-label":i,"data-feature-release":r,children:n===`page`?`New in v${r}`:`NEW`})}function sA({mode:e}){return(0,G.jsxs)(`span`,{className:`shell-stream`,"data-connected":e!==`off`,title:`Dashboard event stream, not router health`,children:[(0,G.jsx)(`span`,{className:`shell-stream-dot`,"aria-hidden":`true`}),e===`off`?`Stream offline`:`Live stream`,e!==`off`&&(0,G.jsx)(`span`,{className:`shell-stream-protocol`,children:e.toUpperCase()})]})}function cA({view:e,onNavigate:t,renderIcon:n,onMobileOpenChange:r,liveMode:i,version:a,transport:o,eventCount:s,feedCount:c,firingCount:l,releaseAvailable:u,onReleaseNotes:d,controls:f}){let p=bk(),m=!p.open&&!p.isMobile,[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(()=>Lk()),[b,x]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>{e.storageArea===window.localStorage&&(e.key===`mt-pinned-pages`||e.key===null)&&(y(Ik(e.newValue)),x(``))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let S=jk(e).id,[C,w]=(0,v.useState)(()=>({view:e,expanded:new Set([S])})),T=C.view===e?C.expanded:new Set([S]);(0,v.useEffect)(()=>{let e=window.matchMedia(`(min-width: 900px)`),t=()=>{e.matches&&r(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[r]);let E=Nk(h),D=e=>{t(e),r(!1),g(``)},O=e=>{let t=zk(_,e);y(t);let n=Rk(t),r=kk.find(t=>t.id===e).label;x(`${r} ${t.includes(e)?`pinned`:`unpinned`}.${n?``:` Browser storage unavailable; kept for this session only.`}`)},k=(t,r,i=!1)=>{let o=_.includes(t.id),s=aA(t.id,a);return(0,G.jsxs)(`div`,{className:`shell-nav-row`,children:[(0,G.jsx)(Ek,{href:`#${t.id}`,accessibleLabel:s?`${t.label} · New in v${s}`:void 0,isActive:e===t.id,activeLayoutId:i?`pinned`:`categories`,className:`shell-nav-link`,onSelect:()=>D(t.id),icon:(0,G.jsxs)(G.Fragment,{children:[n(t.id),m&&(0,G.jsx)(oA,{view:t.id,version:a,placement:`icon`})]}),badge:(0,G.jsxs)(`span`,{className:`shell-nav-badges`,children:[(0,G.jsx)(oA,{view:t.id,version:a}),t.id===`alerts`&&l>0&&(0,G.jsx)(`span`,{className:`shell-nav-count shell-nav-count-alert`,children:l}),t.id===`feed`&&c>0&&(0,G.jsx)(`span`,{className:`shell-nav-count`,children:c>999?`999+`:c})]}),children:t.label}),(0,G.jsx)(nO,{variant:`ghost`,size:`icon-xs`,type:`button`,className:`shell-pin-toggle`,"aria-label":`${o?`Unpin`:`Pin`} ${t.label}`,"aria-pressed":o,title:`${o?`Unpin`:`Pin`} ${t.label}`,onClick:()=>{O(t.id),i&&document.getElementById(`${r}-search`)?.focus()},children:o?(0,G.jsx)(Wu,{size:13,"aria-hidden":`true`}):(0,G.jsx)(Ku,{size:13,"aria-hidden":`true`})})]},t.id)};return(0,G.jsxs)(wk,{ariaLabel:`Dashboard navigation`,collapsible:`icon`,className:p.isMobile?`shell-mobile-nav`:`shell-animated-sidebar`,panelClassName:`shell-sidebar`,children:[p.isMobile&&(0,G.jsxs)(nO,{variant:`ghost`,size:`sm`,onClick:()=>p.setOpenMobile(!1),className:`self-end`,children:[(0,G.jsx)(df,{size:14}),`Close navigation`]}),(t=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`a`,{href:`#overview`,className:`shell-brand`,onClick:e=>{e.preventDefault(),D(`overview`)},"aria-label":`MikroTik MCP overview`,children:[(0,G.jsx)(`span`,{className:`shell-brand-mark`,"aria-hidden":`true`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,children:[(0,G.jsx)(`path`,{d:`M10 11 20 21 30 11M20 21v10`,stroke:`currentColor`,strokeWidth:`2`}),(0,G.jsx)(`circle`,{cx:`10`,cy:`11`,r:`3`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`30`,cy:`11`,r:`3`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`20`,cy:`31`,r:`3`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`20`,cy:`21`,r:`4`,fill:`currentColor`})]})}),(0,G.jsxs)(`span`,{children:[(0,G.jsxs)(`strong`,{children:[`MikroTik `,(0,G.jsx)(`span`,{children:`MCP`})]}),(0,G.jsx)(`small`,{children:`Network operations`})]})]}),(0,G.jsxs)(`div`,{className:`shell-workspace`,children:[(0,G.jsx)(`span`,{className:`shell-workspace-icon`,children:(0,G.jsx)(Pc,{size:17,"aria-hidden":`true`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Observability`}),(0,G.jsx)(`span`,{children:o?`${o.toUpperCase()} workspace`:`Dashboard workspace`})]}),(0,G.jsx)(`span`,{className:`shell-workspace-indicator`,"aria-hidden":`true`})]}),(0,G.jsxs)(`div`,{className:`shell-nav-search`,children:[(0,G.jsx)(md,{size:15,"aria-hidden":`true`}),(0,G.jsx)(Ok,{id:`${t}-search`,"aria-label":`Find a page`,placeholder:`Find a page…`,value:h,onChange:e=>g(e.target.value)}),h&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Clear page search`,onClick:()=>{g(``),document.getElementById(`${t}-search`)?.focus()},children:(0,G.jsx)(df,{size:14})})]}),(0,G.jsxs)(`nav`,{className:`shell-nav`,"aria-label":`Dashboard navigation`,children:[!h.trim()&&(0,G.jsxs)(`section`,{className:`shell-pinned`,"aria-label":`Pinned pages`,children:[(0,G.jsxs)(`div`,{className:`shell-pinned-heading`,children:[(0,G.jsx)(Ku,{size:12,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:`Pinned`}),(0,G.jsx)(`span`,{children:_.length})]}),_.length>0?(0,G.jsx)(`div`,{className:`shell-nav-track`,children:_.map(e=>k(kk.find(t=>t.id===e),t,!0))}):(0,G.jsx)(`p`,{className:`shell-pin-hint`,children:`Pin your go-to pages for quick access.`})]}),(0,G.jsx)(`p`,{className:b.includes(`unavailable`)?`shell-pin-hint`:`sr-only`,role:`status`,children:b}),E.map(n=>{let r=m||!!h.trim()||T.has(n.id);return(0,G.jsxs)(`section`,{className:`shell-nav-group`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`shell-group-heading`,"aria-expanded":r,"aria-controls":`${t}-${n.id}`,onClick:()=>w(()=>{let t=new Set(T);return t.has(n.id)?t.delete(n.id):t.add(n.id),{view:e,expanded:t}}),children:[(0,G.jsx)(`span`,{children:n.label}),(0,G.jsxs)(`span`,{className:`shell-group-meta`,children:[n.views.includes(`alerts`)&&l>0&&(0,G.jsx)(`span`,{className:`shell-alert-dot`,"aria-label":`${l} alerts firing`}),r?(0,G.jsx)(ul,{size:13}):(0,G.jsx)(fl,{size:13})]})]}),(0,G.jsx)(`div`,{id:`${t}-${n.id}`,className:`shell-nav-track`,hidden:!r,children:n.items.map(e=>k(e,t))})]},n.id)}),E.length===0&&(0,G.jsxs)(`div`,{className:`shell-nav-empty`,role:`status`,children:[(0,G.jsx)(md,{size:20}),(0,G.jsx)(`strong`,{children:`No matching pages`}),(0,G.jsx)(`span`,{children:`Try “flows”, “backup” or “router”.`})]})]}),(0,G.jsxs)(`footer`,{className:`shell-sidebar-footer`,children:[(0,G.jsxs)(`div`,{className:`shell-instance`,children:[(0,G.jsx)(sA,{mode:i}),(0,G.jsx)(`span`,{children:s==null?`Waiting for server`:`${Uk(s)} recorded events`})]}),(0,G.jsx)(`div`,{className:`shell-server-controls`,children:f}),(0,G.jsxs)(`button`,{type:`button`,className:`shell-version`,disabled:!d,onClick:d,children:[(0,G.jsxs)(`span`,{children:[`MikroTik MCP `,(0,G.jsx)(`b`,{children:a?`v${a}`:`—`})]}),u?(0,G.jsx)(`span`,{className:`shell-release-dot`,"aria-label":`New release available`}):(0,G.jsx)(Wc,{size:13,"aria-hidden":`true`})]})]})]}))(p.isMobile?`mobile-nav`:`desktop-nav`)]})}var lA=(0,v.createContext)(null),uA={type:`spring`,duration:.8,bounce:.2},dA={type:`spring`,duration:.8,bounce:.35},fA=32,pA=126,mA=37;function hA(){let e=(0,v.useRef)(null),[t,n]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let t=e.current;t&&n({width:t.offsetWidth,height:t.offsetHeight})},[]),(0,v.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n({width:t.offsetWidth,height:t.offsetHeight})});return r.observe(t),()=>r.disconnect()},[]),[e,t]}function gA({keyId:e,children:t,className:n,ref:r}){let i=RD(),a=(0,v.useContext)(lA)?.anchor===`bottom`;return(0,G.jsx)(q.div,{ref:r,initial:i?{opacity:0,filter:`blur(0px)`}:{opacity:0,scale:a?1:.9,y:a?0:-8,filter:`blur(5px)`},animate:i?{opacity:1,filter:`blur(0px)`}:{opacity:1,scale:1,y:0,filter:`blur(0px)`},exit:i?{opacity:0,filter:`blur(0px)`,transition:{duration:.1}}:{opacity:0,scale:a?1:.9,y:a?0:-6,filter:`blur(0px)`,transition:{duration:.08,ease:qD}},transition:i?{duration:.1}:a?{duration:.16,ease:qD}:dA,style:{transformOrigin:a?`bottom center`:`top center`},className:J(`flex items-center justify-center`,n),children:t},e)}function _A({view:e,compact:t,children:n,className:r,announce:i=!0,anchor:a=`top`}){let o=RD(),s=e!==null,[c,l]=hA(),u=(0,v.useMemo)(()=>({view:e,anchor:a}),[e,a]);return(0,G.jsx)(lA.Provider,{value:u,children:(0,G.jsx)(q.div,{"data-anchor":a,role:i?`status`:void 0,"aria-live":i?`polite`:void 0,initial:!1,animate:l?{width:l.width,height:l.height}:{width:pA,height:mA},transition:o?{duration:0}:a===`bottom`?{duration:.26,ease:qD}:uA,style:{borderRadius:fA},className:J(`relative inline-flex justify-center overflow-hidden`,a===`bottom`?`items-end`:`items-start`,`bg-foreground text-background shadow-2xl`,r),children:(0,G.jsxs)(`div`,{ref:c,className:`relative w-max shrink-0`,children:[(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:!s&&t?(0,G.jsx)(gA,{keyId:`compact`,className:`min-h-[37px] min-w-[126px] gap-2 px-4 py-1.5 text-xs font-medium`,children:t},`compact`):null}),n]})})})}function vA({id:e,children:t,className:n}){let r=(0,v.useContext)(lA);if(!r)throw Error(`DynamicIslandView must be used inside <DynamicIsland>`);let i=r.view===e;return(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:i?(0,G.jsx)(gA,{keyId:e,className:J(`px-6 py-4`,n),children:t}):null})}var yA=[.16,1,.3,1],bA={enter:({direction:e,reduceMotion:t})=>({opacity:0,transform:t?`none`:`translateY(${e===`up`?`45%`:`-45%`})`}),visible:{opacity:1,transform:`translateY(0%)`},exit:({direction:e,reduceMotion:t})=>({opacity:0,transform:t?`none`:`translateY(${e===`up`?`-45%`:`45%`})`})};function xA({value:e,animationKey:t,direction:n=`up`,duration:r=.18,stagger:i=.006,suffixLength:a=0,className:o,glyphClassName:s,suffixClassName:c}){let l=RD()??!1,u=String(e),d=Math.max(0,u.length-Math.max(0,a)),f={direction:n,reduceMotion:l},p=Array.from(u,(e,t)=>({character:e,id:`glyph-${t}`,position:t}));return(0,G.jsxs)(`span`,{"data-slot":`digit-swap`,"data-direction":n,className:K(`inline-flex items-center whitespace-nowrap`,o),children:[(0,G.jsx)(`span`,{className:`sr-only`,children:u}),(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex items-center`,children:p.map(({character:e,id:n,position:a})=>{if(e===` `)return(0,G.jsx)(`span`,{className:`inline-block w-[0.7ch]`},n);let o=t===void 0?`${n}-${e}`:`${n}-${e}-${t}`;return(0,G.jsx)(`span`,{"data-slot":`digit-swap-glyph`,className:`relative inline-block h-[1.1em] w-[1ch] shrink-0 overflow-hidden align-bottom`,children:(0,G.jsx)(BE,{initial:!1,custom:f,children:(0,G.jsx)(q.span,{custom:f,variants:bA,initial:`enter`,animate:`visible`,exit:`exit`,transition:{duration:l?Math.min(r,.12):r,delay:l?0:a*i,ease:yA},className:K(`absolute inset-0 flex items-center justify-center leading-none`,s,a>=d?c:void 0),children:e},o)})},n)})})]})}var SA=(0,v.createContext)(null);function CA(){let e=(0,v.useContext)(SA);if(!e)throw Error(`Tabs.* must be used inside <Tabs>`);return e}var wA={type:`spring`,stiffness:170,damping:30,mass:1.2};function TA({defaultValue:e,value:t,onValueChange:n,variant:r=`pill`,children:i,className:a}){let[o,s]=(0,v.useState)(e??``),c=(0,v.useId)(),l=RD(),u=t!==void 0,d=u?t:o,f=(0,v.useCallback)(e=>{u||s(e),n?.(e)},[u,n]),p=(0,v.useMemo)(()=>({value:d,setValue:f,layoutId:c,variant:r}),[d,c,f,r]);return(0,G.jsx)(ZE,{transition:l?{duration:0}:wA,children:(0,G.jsx)(SA.Provider,{value:p,children:(0,G.jsx)(q.div,{layoutRoot:!0,className:a,children:i})})})}var EA={pill:`inline-flex items-center gap-1 rounded-full bg-card p-1`,underline:`inline-flex items-center gap-1 border-b border-border`,segment:`inline-flex items-center gap-0 rounded-lg bg-card p-0.5`};function DA({children:e,className:t,onKeyDown:n,...r}){let{variant:i}=CA();return(0,G.jsx)(`div`,{...r,role:`tablist`,className:J(EA[i],t),onKeyDown:e=>{if(n?.(e),e.defaultPrevented)return;let t=Array.from(e.currentTarget.querySelectorAll(`[role="tab"]:not(:disabled)`)),r=t.indexOf(document.activeElement),i=e.key===`Home`?t[0]:e.key===`End`?t.at(-1):e.key===`ArrowRight`?t[(r+1)%t.length]:e.key===`ArrowLeft`?t[(r-1+t.length)%t.length]:null;i&&(e.preventDefault(),i.focus(),i.click())},children:e})}function OA({value:e,children:t,className:n,indicatorClassName:r,disabled:i,onClick:a,...o}){let{value:s,setValue:c,layoutId:l,variant:u}=CA(),d=s===e,f={...o,id:`${l}-tab-${e}`,"aria-controls":`${l}-panel-${e}`,"data-state":d?`active`:`inactive`,tabIndex:d?0:-1,disabled:i,onClick:t=>{a?.(t),!t.defaultPrevented&&!i&&c(e)}};if(u===`underline`)return(0,G.jsxs)(`button`,{...f,type:`button`,role:`tab`,"aria-selected":d,className:J(`relative isolate px-3 pb-2.5 pt-1 -mb-px text-sm font-medium transition-colors min-h-[44px] inline-flex items-center`,d?`text-foreground`:`text-muted-foreground hover:text-foreground`,n),children:[t,d?(0,G.jsx)(q.span,{layoutId:l,layout:`position`,className:J(`absolute -bottom-px left-0 right-0 h-px bg-primary`,r)}):null]});let p=u===`pill`?`rounded-full`:`rounded-md`;return(0,G.jsxs)(`div`,{className:`relative`,children:[d?(0,G.jsx)(q.span,{layoutId:l,layout:`position`,style:{borderRadius:u===`pill`?9999:8},className:J(`absolute inset-0 bg-primary`,p,r)}):null,(0,G.jsx)(`button`,{...f,type:`button`,role:`tab`,"aria-selected":d,className:J(`relative z-10 inline-flex items-center justify-center whitespace-nowrap bg-transparent px-3.5 py-1.5 text-sm font-medium outline-none`,`transition-colors`,d?`text-primary-foreground`:`text-muted-foreground hover:text-foreground`,p,n),children:t})]})}function kA({value:e,children:t,className:n,forceMount:r}){let{value:i,layoutId:a}=CA(),o=RD(),s=i===e;return!s&&!r?null:(0,G.jsx)(q.div,{role:`tabpanel`,hidden:!s,id:`${a}-panel-${e}`,"aria-labelledby":`${a}-tab-${e}`,tabIndex:0,initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},transition:{duration:.18,ease:qD},className:J(`mt-4`,n),children:t},e)}function AA({className:e,...t}){return(0,G.jsx)(TA,{...t,variant:`segment`,className:K(`flex min-w-0 flex-col gap-2`,e)})}function jA({className:e,...t}){return(0,G.jsx)(DA,{...t,className:K(`w-fit max-w-full gap-1 rounded-xl border p-1`,e)})}function MA({className:e,...t}){return(0,G.jsx)(OA,{...t,className:K(`gap-1.5 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`,e)})}function NA({className:e,...t}){return(0,G.jsx)(kA,{...t,className:K(`flex-1 outline-none`,e)})}var PA=3e4;function FA(e,t,n=PA){return typeof e==`number`&&Number.isFinite(e)&&e>0&&t>=e&&t-e<=n}function IA(e,t,n){return e.disabled?`disabled`:!n||!FA(e.status.checkedAt,t,12e4)?`unknown`:e.status.reachable===!0?`reachable`:e.status.reachable===!1?`unreachable`:`unknown`}function LA({mode:e,paused:t,now:n,liveEvent:r,liveEventAt:i,pool:a,poolAt:o,alerts:s,alertsAt:c}){if(e===`off`)return{kind:`offline`,label:`Stream offline`,detail:`Reconnecting automatically`};if(t)return{kind:`paused`,label:`Dashboard paused`,detail:`Displayed activity is frozen`};let l=r&&FA(i,n,1e4);return l&&r.isError?{kind:`error`,label:`Tool call failed`,detail:r.tool}:s!=null&&s>0&&FA(c,n,45e3)?{kind:`alerts`,label:`Alerts need attention`,detail:`Active alert rules`,count:s}:a?.enabled&&FA(o,n)&&Number.isFinite(a.aggregate.totalInflight)&&a.aggregate.totalInflight>0?{kind:`busy`,label:`SSH channels busy`,detail:`Observed in the connection pool`,count:a.aggregate.totalInflight}:l?{kind:`completed`,label:`Tool call completed`,detail:r.tool}:{kind:`listening`,label:`Listening for activity`,detail:e===`sse`?`SSE fallback connected`:`WebSocket connected`}}function RA(e){return Number.isFinite(e.durationMs)&&e.durationMs>=0?e.ts+e.durationMs:NaN}function zA(e,t){let n=new Set;return e.filter(e=>{let r=RA(e);return!e.id||n.has(e.id)||!Number.isFinite(r)||r>t?!1:(n.add(e.id),!0)}).sort((e,t)=>RA(t)-RA(e)).slice(0,4)}function BA(e,t){if(e==null||!Number.isFinite(e)||e<=0||e>t)return`Not observed`;let n=Math.floor((t-e)/1e3);return n<5?`Just now`:n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}var VA={offline:Qd,paused:Bu,error:vl,alerts:Qc,busy:Pc,completed:cl,listening:ed};function HA(e){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(`pulse`),[a,o]=(0,v.useState)(Date.now),s=Math.max(a,e.statsAt??0,e.poolAt??0,e.alertsAt??0,e.liveEventAt??0),c=(0,v.useRef)(null),l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(!1);(0,v.useEffect)(()=>{let e=setInterval(()=>{document.visibilityState===`visible`&&o(Date.now())},1e3),t=()=>o(Date.now());return document.addEventListener(`visibilitychange`,t),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,t)}},[]),(0,v.useEffect)(()=>{if(!t){d.current&&l.current?.focus({preventScroll:!0}),d.current=!1;return}u.current?.focus({preventScroll:!0});let e=e=>{c.current?.contains(e.target)||n(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[t]);let f=LA({...e,now:s}),p=VA[f.kind],m=e.mode!==`off`&&!e.paused,h=m&&FA(e.statsAt,s),g=m&&FA(e.poolAt,s),_=m&&FA(e.alertsAt,s,45e3),y=(0,v.useMemo)(()=>zA(e.events,s),[e.events,s]),b=e.devices?.devices??[],x=b.filter(e=>IA(e,s,m)===`reachable`).length,S=e.stats?.series.filter(e=>Number.isFinite(e.ok)&&Number.isFinite(e.error)&&e.ok>=0&&e.error>=0).slice(-18)??[],C=Math.max(1,...S.map(e=>e.ok+e.error)),w=()=>{d.current=!0,n(!1)},T=t=>{n(!1),e.onNavigate(t)},E=e.stats?`${Math.round(e.stats.windowMs/6e4)} min window`:`Waiting for analytics`,D=(e,t=Uk)=>e!=null&&Number.isFinite(e)?t(e):`—`;return(0,G.jsxs)(`aside`,{ref:c,className:`operations-island-anchor`,"aria-label":`Operations Island`,onKeyDown:e=>{e.key===`Escape`&&t&&(e.preventDefault(),e.stopPropagation(),w())},"data-signal":f.kind,children:[(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:f.label}),(0,G.jsx)(_A,{announce:!1,anchor:`bottom`,view:t?`operations`:null,className:`operations-island`,compact:(0,G.jsxs)(nO,{ref:l,variant:`ghost`,className:`island-compact`,"aria-label":`Open Operations Island: ${f.label}`,"aria-expanded":t,"aria-controls":`operations-island-panel`,onClick:()=>n(!0),children:[(0,G.jsx)(`span`,{className:`island-signal-icon`,children:(0,G.jsx)(p,{size:17})}),(0,G.jsxs)(`span`,{className:`island-compact-copy`,children:[(0,G.jsx)(`strong`,{children:f.label}),(0,G.jsx)(`span`,{children:f.detail})]}),f.count==null?(0,G.jsxs)(`span`,{className:`island-equalizer`,"data-moving":f.kind===`busy`,"aria-hidden":`true`,children:[(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{})]}):(0,G.jsx)(`span`,{className:`island-count`,children:(0,G.jsx)(xA,{value:f.count})}),(0,G.jsx)(ml,{size:14,className:`island-chevron`})]}),children:(0,G.jsx)(vA,{id:`operations`,className:`island-expanded-slot`,children:(0,G.jsxs)(`section`,{id:`operations-island-panel`,className:`island-panel`,"aria-label":`Operations summary`,children:[(0,G.jsxs)(`header`,{className:`island-header`,children:[(0,G.jsx)(`span`,{className:`island-signal-icon`,children:(0,G.jsx)(p,{size:20})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{children:`OPERATIONS PULSE`}),(0,G.jsx)(`h2`,{children:f.label})]}),(0,G.jsx)(nO,{ref:u,size:`icon-sm`,variant:`ghost`,className:`island-close`,"aria-label":`Collapse Operations Island`,onClick:w,children:(0,G.jsx)(df,{size:16})})]}),(0,G.jsxs)(`div`,{className:`island-connection`,children:[(0,G.jsx)(`span`,{className:m?`island-dot is-connected`:`island-dot`}),(0,G.jsx)(`span`,{children:e.mode===`off`?`Disconnected · last-known data only`:e.paused?`Stream connected · dashboard updates paused`:`${e.mode.toUpperCase()} connected · no extra router probes`})]}),(0,G.jsxs)(AA,{value:r,onValueChange:i,className:`island-tabs`,children:[(0,G.jsxs)(jA,{"aria-label":`Operations views`,className:`island-tab-list`,children:[(0,G.jsxs)(MA,{value:`pulse`,children:[(0,G.jsx)(Pc,{size:13}),`Pulse`]}),(0,G.jsxs)(MA,{value:`fleet`,children:[(0,G.jsx)(ud,{size:13}),`Routers`]}),(0,G.jsxs)(MA,{value:`activity`,children:[(0,G.jsx)(El,{size:13}),`Activity`]})]}),(0,G.jsxs)(NA,{value:`pulse`,className:`island-tab-panel`,children:[(0,G.jsxs)(`div`,{className:`island-chart-heading`,children:[(0,G.jsx)(`span`,{children:`TOOL CALL VOLUME`}),(0,G.jsx)(`span`,{children:E})]}),(0,G.jsx)(`div`,{className:`island-volume`,"aria-hidden":`true`,"data-stale":!h,children:S.some(e=>e.ok+e.error>0)?S.map(e=>(0,G.jsxs)(`div`,{className:`island-bar-track`,children:[(0,G.jsx)(`span`,{className:`island-bar-ok`,style:{height:`${e.ok/C*100}%`}}),(0,G.jsx)(`span`,{className:`island-bar-error`,style:{height:`${e.error/C*100}%`}})]},e.t)):(0,G.jsx)(`span`,{className:`island-empty-chart`,children:e.stats?`No calls in this window`:`Waiting for recorded activity`})}),(0,G.jsxs)(`div`,{className:`island-chart-caption`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`i`,{}),`Successful `,(0,G.jsx)(`i`,{className:`is-error`}),`Failed`]}),(0,G.jsxs)(`span`,{children:[h?`Updated`:`Snapshot`,` · `,BA(e.statsAt,s)]})]}),(0,G.jsxs)(`div`,{className:`island-metrics`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{children:`Calls / min`}),(0,G.jsx)(`strong`,{children:D(e.stats?.callsPerMin,e=>e.toFixed(1))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{children:`Tool p95`}),(0,G.jsx)(`strong`,{children:D(e.stats&&e.stats.total>0?e.stats.latency.p95:void 0,Bk)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{children:`Failed calls`}),(0,G.jsx)(`strong`,{className:e.stats?.errors?`island-error-text`:``,children:D(e.stats?.errors)})]})]}),(0,G.jsxs)(`div`,{className:`island-insights`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(ou,{size:13}),g&&e.pool?e.pool.enabled?`${e.pool.aggregate.totalInflight} SSH channels in flight`:`SSH pooling disabled`:`SSH pool status unavailable`]}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(Qc,{size:13}),_&&e.alerts!=null?`${e.alerts} active alert rules`:`Alert status unavailable`]})]}),(0,G.jsxs)(nO,{variant:`ghost`,className:`island-link`,onClick:()=>T(`overview`),children:[`Open analytics`,(0,G.jsx)(Wc,{size:14})]})]}),(0,G.jsxs)(NA,{value:`fleet`,className:`island-tab-panel`,children:[(0,G.jsxs)(`div`,{className:`island-chart-heading`,children:[(0,G.jsx)(`span`,{children:`LAST ROUTER CHECKS`}),(0,G.jsx)(`span`,{children:e.devices?`${x} / ${b.filter(e=>!e.disabled).length} reachable`:`Not loaded`})]}),(0,G.jsx)(`div`,{className:`island-scroll-list`,children:b.length?b.map(e=>{let t=IA(e,s,m);return(0,G.jsxs)(`div`,{className:`island-device`,"data-state":t,children:[(0,G.jsx)(`span`,{className:`island-router-icon`,children:(0,G.jsx)(ud,{size:18})}),(0,G.jsxs)(`div`,{className:`island-row-copy`,children:[(0,G.jsx)(`strong`,{children:e.name}),(0,G.jsxs)(`span`,{children:[t===`unknown`?`Unknown / stale`:t,` ·`,` `,BA(e.status.checkedAt,s)]})]}),(0,G.jsx)(`span`,{className:`island-device-latency`,children:t===`reachable`&&e.status.latencyMs!=null?Bk(e.status.latencyMs):`—`})]},e.name)}):(0,G.jsx)(`p`,{className:`island-empty`,children:`Router status has not loaded. No healthy state is assumed.`})}),(0,G.jsx)(`p`,{className:`island-footnote`,children:`Management reachability is not proof of client or VPN health.`}),(0,G.jsxs)(nO,{variant:`ghost`,className:`island-link`,onClick:()=>T(`devices`),children:[`Open devices`,(0,G.jsx)(Wc,{size:14})]})]}),(0,G.jsxs)(NA,{value:`activity`,className:`island-tab-panel`,children:[(0,G.jsxs)(`div`,{className:`island-chart-heading`,children:[(0,G.jsx)(`span`,{children:`RECORDED COMPLETIONS`}),(0,G.jsxs)(`span`,{children:[`Latest `,y.length]})]}),(0,G.jsx)(`div`,{className:`island-scroll-list`,children:y.length?y.map(t=>(0,G.jsxs)(nO,{variant:`ghost`,className:`island-event`,onClick:()=>{n(!1),e.onEvent(t)},children:[(0,G.jsx)(`span`,{className:t.isError?`island-error-text`:`island-success-text`,children:t.isError?(0,G.jsx)(vl,{size:16}):(0,G.jsx)(cl,{size:16})}),(0,G.jsxs)(`span`,{className:`island-row-copy`,children:[(0,G.jsx)(`strong`,{children:t.tool}),(0,G.jsxs)(`span`,{children:[t.device??`Server`,` · `,BA(RA(t),s)]})]}),(0,G.jsxs)(`span`,{className:`island-event-duration`,children:[Bk(t.durationMs),(0,G.jsx)(Wc,{size:12})]})]},t.id)):(0,G.jsx)(`p`,{className:`island-empty`,children:`No recorded calls yet. Activity appears when MCP tools complete.`})}),(0,G.jsx)(`p`,{className:`island-footnote`,children:`Completed tool calls, not a live packet trace. Open a call for its evidence.`}),(0,G.jsxs)(nO,{variant:`ghost`,className:`island-link`,onClick:()=>T(`feed`),children:[`Open Live Feed`,(0,G.jsx)(Wc,{size:14})]})]})]}),(0,G.jsxs)(`footer`,{className:`island-footer`,children:[(0,G.jsx)(ed,{size:11}),(0,G.jsx)(`span`,{children:`OBSERVE ONLY`}),(0,G.jsx)(`span`,{children:`No configuration changes`})]})]})})})]})}function UA(e,t){try{e.setPointerCapture(t)}catch{}}var WA=e=>e.pointerType!==`touch`&&e.buttons===0,GA={active:!1,startX:0,startY:0,pointerId:null},KA={duration:.9,ease:JD,repeat:1/0},qA={duration:1.2,ease:JD,repeat:1/0},JA={duration:.16,ease:qD};function YA(e,t){return t*(1-Math.exp(-Math.max(0,e)/t))}function XA({progress:e,status:t,reduce:n}){let r=ID(e,[0,1],[-7,0]),i=ID(e,[0,1],[-10,0]),a=ID(e,[0,.55,1],[.68,1.1,.92]),o=t===`ready`,s=t===`refreshing`;return(0,G.jsx)(q.span,{style:n?void 0:{y:r,rotate:i,scaleY:a},className:`block h-9 w-9 origin-bottom`,children:(0,G.jsxs)(q.svg,{"aria-hidden":`true`,viewBox:`0 0 36 36`,style:{opacity:1},className:`h-full w-full overflow-visible`,animate:s?n?{opacity:[.55,1,.55]}:{y:[0,-2,0],rotate:[-3,3,-3]}:n?{opacity:1}:{y:0,rotate:0,scale:o?1.08:1},transition:s?n?qA:KA:XD,children:[(0,G.jsxs)(q.g,{style:{transformOrigin:`18px 18px`},animate:s&&!n?{rotate:[0,360]}:n?void 0:{rotate:o?0:-35},transition:s?n?qA:KA:XD,className:J(`transition-opacity duration-150`,o||s?`opacity-100`:`opacity-0`),children:[(0,G.jsx)(`path`,{d:`M18 2.5a15.5 15.5 0 0 1 12.7 6.6`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,className:`text-muted-foreground`}),(0,G.jsx)(`circle`,{cx:`31.3`,cy:`10.2`,r:`2.2`,className:`fill-foreground`})]}),(0,G.jsx)(`rect`,{x:`7`,y:`7`,width:`22`,height:`22`,rx:`9`,className:`fill-foreground`}),(0,G.jsxs)(q.g,{style:{opacity:1,transformOrigin:`18px 16px`},animate:s&&!n?{scaleY:[1,1,.15,1,1]}:n?{opacity:1}:{scaleY:o?1.18:1},transition:s&&!n?KA:XD,children:[(0,G.jsx)(`circle`,{cx:`14.2`,cy:`16`,r:`1.45`,className:`fill-background`}),(0,G.jsx)(`circle`,{cx:`21.8`,cy:`16`,r:`1.45`,className:`fill-background`})]}),(0,G.jsx)(`path`,{d:`M14.5 21h7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,className:J(`text-background transition-opacity duration-150`,o||s?`opacity-0`:`opacity-100`)}),(0,G.jsx)(`path`,{d:`M14 20.5c1 2.4 7 2.4 8 0`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,className:J(`text-background transition-opacity duration-150`,o?`opacity-100`:`opacity-0`)}),(0,G.jsx)(`circle`,{cx:`18`,cy:`21`,r:`1.6`,className:J(`fill-background transition-opacity duration-150`,s?`opacity-100`:`opacity-0`)})]})})}function ZA({onRefresh:e,children:t,refreshing:n=!1,disabled:r=!1,threshold:i=76,maxPull:a=132,holdDistance:o=68,pullingLabel:s=`Pull to refresh`,releaseLabel:c=`Release to refresh`,refreshingLabel:l=`Refreshing`,ariaLabel:u=`Refreshable content`,className:d,contentClassName:f,indicatorClassName:p,handleOnly:m=!1,onRefreshError:h}){let g=(0,v.useRef)(null),_=(0,v.useRef)({...GA}),y=(0,v.useRef)(null),b=(0,v.useRef)(`idle`),x=(0,v.useRef)(r),S=(0,v.useRef)(n),C=(0,v.useRef)(n),[w,T]=(0,v.useState)(`idle`),[E,D]=(0,v.useState)(!1),O=RD(),k=Math.max(24,i),A=Math.max(a,k+24),j=Math.min(Math.max(0,o),k),M=PD(0),N=ID(M,[0,k],[0,1]),P=ID(M,[0,10,k],[0,.45,1]),F=ID(M,[0,k],[.86,1]),I=n||E;x.current=r,S.current=n,C.current=I;let ee=(0,v.useCallback)(e=>{b.current!==e&&(b.current=e,T(e))},[]),L=(0,v.useCallback)(e=>{if(y.current?.stop(),O){M.set(e);return}y.current=KD(M,e,Jne)},[O,M]),R=(0,v.useCallback)(e=>{if(x.current||C.current)return;y.current?.stop();let t=YA(e,A);M.set(t),ee(t>=k?`ready`:`pulling`)},[A,k,ee,M]),te=(0,v.useCallback)(async()=>{if(!(x.current||C.current)){C.current=!0,D(!0),ee(`refreshing`),L(j);try{await e()}catch(e){h?.(e)}finally{D(!1),S.current||(C.current=!1,ee(`idle`),L(0))}}},[e,h,j,ee,L]),z=(0,v.useCallback)(e=>!(e instanceof Element)||e.closest(`button, a, input, textarea, select, [contenteditable="true"], [role="button"]`)?!1:!m||!!e.closest(`[data-refresh-handle]`),[m]),ne=(0,v.useCallback)(()=>{_.current={...GA},C.current||(ee(`idle`),L(0))},[ee,L]),re=(0,v.useCallback)(()=>{let e=M.get()>=k&&!x.current&&!C.current;if(_.current={...GA},e){te();return}ee(`idle`),L(0)},[k,te,ee,L,M]);(0,v.useEffect)(()=>{if(I){ee(`refreshing`),L(j);return}b.current===`refreshing`&&(ee(`idle`),L(0))},[I,j,ee,L]),(0,v.useEffect)(()=>{let e=g.current;if(!e)return;let t=t=>{if(t.touches.length!==1||!z(t.target)||e.scrollTop>0||x.current||C.current)return;let n=t.touches[0];_.current={active:!0,startX:n.clientX,startY:n.clientY,pointerId:null}},n=t=>{let n=_.current,r=t.touches[0];if(!n.active||!r)return;let i=r.clientX-n.startX,a=r.clientY-n.startY;if(e.scrollTop>0||a<0){_.current={...GA};return}Math.abs(i)>a||(t.preventDefault(),R(a))},r=()=>{_.current.active&&re()};return e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`touchmove`,n,{passive:!1}),e.addEventListener(`touchend`,r),e.addEventListener(`touchcancel`,ne),()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchmove`,n),e.removeEventListener(`touchend`,r),e.removeEventListener(`touchcancel`,ne)}},[re,R,z,ne]),(0,v.useEffect)(()=>()=>y.current?.stop(),[]);let ie=e=>{e.pointerType===`touch`||!z(e.target)||e.button!==0||e.currentTarget.scrollTop>0||r||I||(UA(e.currentTarget,e.pointerId),_.current={active:!0,startX:e.clientX,startY:e.clientY,pointerId:e.pointerId})},ae=e=>{let t=_.current;if(!t.active||t.pointerId!==e.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY;r<0||Math.abs(n)>r||(e.preventDefault(),R(r))},oe=w===`refreshing`?l:w===`ready`?c:s;return(0,G.jsxs)(`section`,{ref:g,"aria-label":u,"aria-busy":I,"data-state":w,"data-disabled":r||void 0,onPointerDown:ie,onPointerMove:ae,onPointerUp:e=>{_.current.pointerId===e.pointerId&&re()},onPointerCancel:e=>{_.current.pointerId===e.pointerId&&ne()},className:J(`relative w-full overflow-y-auto overscroll-contain bg-background`,!m&&`[-webkit-touch-callout:none] pointer-coarse:select-none`,w===`pulling`||w===`ready`?`cursor-grabbing select-none`:`cursor-grab`,(r||I)&&`cursor-default`,d),children:[(0,G.jsxs)(q.div,{"aria-live":`polite`,"aria-atomic":`true`,style:O?{opacity:P}:{opacity:P,scale:F},className:J(`pointer-events-none absolute inset-x-0 top-0 z-20 flex h-[4.25rem] flex-col items-center justify-center gap-0.5 bg-gradient-to-b from-background via-background/95 to-transparent text-[11px] font-medium text-muted-foreground`,p),children:[(0,G.jsx)(XA,{progress:N,status:w,reduce:!!O}),(0,G.jsx)(`span`,{className:`relative h-4 min-w-24 text-center`,children:(0,G.jsx)(BE,{initial:!1,mode:`wait`,children:(0,G.jsx)(q.span,{initial:O?{opacity:0}:{opacity:0,y:3},animate:O?{opacity:1}:{opacity:1,y:0},exit:O?{opacity:0}:{opacity:0,y:-3},transition:JA,className:`absolute inset-x-0 whitespace-nowrap`,children:oe},w)})})]}),(0,G.jsx)(q.div,{style:O?void 0:{y:M},className:J(`relative z-10 min-h-full bg-inherit will-change-transform`,f),children:t})]})}function QA({enabled:e,disabled:t=!1,onRefresh:n,children:r}){let i=(0,v.useRef)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),d=async()=>{if(!(i.current||t)){i.current=!0,o(!0),c(``),u(!1);try{await n(),c(`Dashboard data refreshed`)}catch{u(!0),c(`Refresh failed. Previous data kept; try again.`)}finally{i.current=!1,o(!1)}}};return e?(0,G.jsxs)(ZA,{handleOnly:!0,onRefresh:d,refreshing:a,disabled:t,ariaLabel:`Refresh dashboard data`,className:`overflow-visible bg-transparent cursor-default`,contentClassName:`min-h-0`,pullingLabel:`Pull to reload dashboard data`,refreshingLabel:`Reading dashboard data…`,children:[(0,G.jsxs)(`div`,{"data-refresh-handle":!0,className:`mb-4 flex flex-wrap items-center gap-2 rounded-xl border border-dashed border-border px-3 py-2 text-xs text-muted-foreground cursor-grab active:cursor-grabbing`,children:[(0,G.jsx)(uu,{className:`size-4 text-primary`}),(0,G.jsx)(`span`,{className:`flex-1`,children:t?`Resume the feed to refresh`:`Pull down here to refresh · read-only`}),(0,G.jsxs)(nO,{size:`sm`,variant:`ghost`,disabled:a||t,onClick:()=>void d(),children:[(0,G.jsx)(nd,{className:a?`animate-spin motion-reduce:animate-none`:``}),a?`Refreshing…`:`Refresh data`]})]}),s&&(0,G.jsx)(`p`,{role:l?`alert`:`status`,className:`mb-3 text-xs ${l?`text-destructive`:`text-muted-foreground`}`,children:s}),r]}):r}var $A=new Set;function ej(e,t){for(let n of $A)if(n!==e&&n(t))return!0;return!1}function tj(e){let t=e=>{e.preventDefault(),e.stopPropagation(),r()},n=t=>{t!==e&&r()};function r(){window.removeEventListener(`click`,t,!0),window.removeEventListener(`pointerdown`,n,!0),window.removeEventListener(`pointercancel`,n,!0),window.removeEventListener(`keydown`,r,!0)}window.addEventListener(`click`,t,!0),window.addEventListener(`pointerdown`,n,!0),window.addEventListener(`pointercancel`,n,!0),window.addEventListener(`keydown`,r,!0)}function nj(e,t,n,{behavior:r=`pass-through`,escape:i=!0,ignore:a}={}){(0,v.useEffect)(()=>{if(!e)return;let o=e=>!!n?.current?.contains(e)||!!a?.(e),s=e=>{i&&e.key===`Escape`&&t()},c=e=>{let n=e.target;n&&!o(n)&&(r===`consume`&&!ej(o,n)&&tj(e),t())};return $A.add(o),window.addEventListener(`keydown`,s),window.addEventListener(`pointerdown`,c,!0),()=>{$A.delete(o),window.removeEventListener(`keydown`,s),window.removeEventListener(`pointerdown`,c,!0)}},[e,t,n,r,i,a])}function rj(){let e=(0,v.useRef)(new Set);return(0,v.useMemo)(()=>({enter:t=>WA(t)?(e.current.delete(t.pointerId),!0):(e.current.add(t.pointerId),!1),leave:t=>!e.current.delete(t.pointerId)&&t.pointerType!==`touch`}),[])}function ij(){let e=(0,v.useRef)(null);return(0,v.useMemo)(()=>({start:(t,n)=>{e.current={pointerType:t.pointerType,state:n}},take:()=>{let t=e.current;return e.current=null,t},drop:()=>{e.current=null}}),[])}var aj={type:`spring`,stiffness:460,damping:34,mass:.62},oj={type:`spring`,stiffness:380,damping:32,mass:.7},sj={sm:`min-h-9 gap-1 p-1 text-xs`,md:`min-h-11 gap-1.5 p-1.5 text-sm`},cj={sm:`h-7 min-w-7 px-1.5`,md:`h-8 min-w-8 px-2`},lj={sm:`h-3.5 w-3.5`,md:`h-4 w-4`};function uj({expanded:e,defaultExpanded:t,onExpandedChange:n}){let[r,i]=(0,v.useState)(t??!1),a=e!==void 0;return[e??r,(0,v.useCallback)(e=>{a||i(e),n?.(e)},[a,n])]}function dj({items:e,expanded:t,defaultExpanded:n=!1,onExpandedChange:r,activeId:i,onAction:a,size:o=`md`,expandOnHover:s=!0,expandOnFocus:c=!0,collapseDelay:l=90,className:u,classNames:d,renderItem:f}){let p=RD(),m=(0,v.useId)(),[h,g]=uj({expanded:t,defaultExpanded:n,onExpandedChange:r}),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(null),C=(0,v.useRef)(null),w=ij(),T=rj(),E=(0,v.useCallback)(()=>{S.current&&window.clearTimeout(S.current),S.current=null},[]),D=(0,v.useCallback)(()=>{E(),g(!0)},[E,g]),O=(0,v.useCallback)(()=>{E();let e=window.setTimeout(()=>{g(!1),y(null),x(!1)},l);S.current=e},[E,l,g]);(0,v.useEffect)(()=>E,[E]);let k=(0,v.useRef)(h);(0,v.useEffect)(()=>{k.current&&!h&&x(!1),k.current=h},[h]),nj(b&&h,O,C,{behavior:`consume`});let A=e=>{T.enter(e)&&s&&D()},j=e=>{T.leave(e)&&(y(null),s&&O())},M=()=>{c&&D()},N=e=>{!e.currentTarget.contains(e.relatedTarget)&&c&&O()},P=i??e.find(e=>e.active)?.id,F=_??P;return(0,G.jsx)(KE,{id:m,children:(0,G.jsx)(q.div,{layout:`size`,onPointerEnter:A,onPointerLeave:j,onFocus:M,onBlur:N,transition:aj,className:J(`inline-flex max-w-full`,d?.root,u),children:(0,G.jsx)(q.div,{ref:C,layout:`size`,className:J(`scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl`,sj[o],d?.track),transition:aj,children:e.map(e=>{let t=e.active||i===e.id,n=F===e.id;return(0,G.jsxs)(q.button,{layout:`position`,type:`button`,disabled:e.disabled,title:typeof e.label==`string`?e.label:void 0,"aria-label":typeof e.label==`string`?e.label:void 0,onPointerEnter:t=>{T.enter(t)&&(E(),y(e.id))},onPointerDown:e=>{w.start(e,h)},onPointerCancel:w.drop,onKeyDown:w.drop,onClick:t=>{t.detail>0&&t.currentTarget.blur();let n=w.take();if(n!==null&&n.pointerType!==`mouse`&&!n.state&&!b&&s){x(!0),D(),y(e.id);return}e.onClick?.(),a?.(e)},whileTap:p||e.disabled?void 0:{scale:.96},transition:aj,className:J(`relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out`,`focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40`,n&&`text-foreground`,cj[o],d?.item,t&&d?.activeItem),children:[n?(0,G.jsx)(q.span,{layoutId:`action-bar-highlight`,className:`absolute inset-0 -z-10 rounded-full bg-primary/[0.07]`,transition:aj}):null,f?f(e,{expanded:h,active:t}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center`,lj[o],d?.icon),children:e.icon}),(0,G.jsx)(q.span,{"aria-hidden":!h,animate:p?{width:h?`auto`:0,opacity:+!!h,marginLeft:h?8:0,x:0,filter:`blur(0px)`}:{width:h?`auto`:0,opacity:+!!h,x:h?0:-4,marginLeft:h?8:0,filter:h?`blur(0px)`:`blur(3px)`},transition:p?{duration:0}:oj,className:J(`inline-block overflow-hidden whitespace-nowrap`,d?.label),children:e.label}),e.shortcut?(0,G.jsx)(q.span,{"aria-hidden":!h,animate:{width:h?`auto`:0,opacity:+!!h,marginLeft:h?4:0},transition:oj,className:J(`hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block`,d?.shortcut),children:e.shortcut}):null,e.badge?(0,G.jsx)(`span`,{className:J(`ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] leading-none text-primary-foreground`,!h&&`absolute right-0.5 top-0.5`,d?.badge),children:e.badge}):null]})]},e.id)})})})})}function fj({paused:e,count:t,onPause:n,onExport:r,onClear:i,onDelete:a}){return(0,G.jsx)(`div`,{role:`group`,"aria-label":`Live Feed actions`,className:`max-w-full`,children:(0,G.jsx)(dj,{size:`sm`,classNames:{track:`rounded-xl shadow-none`,item:`rounded-lg focus-visible:ring-2 focus-visible:ring-ring`},items:[{id:`pause`,label:e?`Resume`:`Pause`,icon:e?(0,G.jsx)(Ju,{}):(0,G.jsx)(Bu,{}),active:e,onClick:n},{id:`csv`,label:`Export CSV`,icon:(0,G.jsx)(eu,{}),badge:t||void 0,onClick:()=>r(`csv`)},{id:`json`,label:`Export JSON`,icon:(0,G.jsx)(Ql,{}),badge:t||void 0,onClick:()=>r(`json`)},{id:`clear`,label:`Clear filters`,icon:(0,G.jsx)(Su,{}),onClick:i},{id:`delete`,label:`Delete selected`,icon:(0,G.jsx)(Kd,{}),badge:t||void 0,disabled:t===0,onClick:a}]})})}var pj={ascii:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],"ascii-line":[`|`,`/`,`-`,`\\`],"ascii-braille":[`⣾`,`⣽`,`⣻`,`⢿`,`⡿`,`⣟`,`⣯`,`⣷`],"ascii-blocks":[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`,`▇`,`▆`,`▅`,`▄`,`▃`,`▂`],"ascii-bounce":[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`]},mj={animate:{opacity:[1,.4,1]},transition:{duration:1.4,ease:JD,repeat:1/0}};function hj({variant:e=`spinner`,size:t=32,speed:n=1,label:r=`Loading`,className:i}){let a=RD()??!1;return(0,G.jsxs)(`span`,{role:`status`,"aria-label":r,className:J(`inline-flex items-center justify-center text-foreground`,i),children:[e===`spinner`&&(0,G.jsx)(gj,{size:t,speed:n,reduce:a}),e===`dots`&&(0,G.jsx)(_j,{size:t,speed:n,reduce:a}),e===`bars`&&(0,G.jsx)(Lj,{size:t,speed:n,reduce:a}),e===`dot-matrix`&&(0,G.jsx)(wre,{size:t,speed:n,reduce:a}),e===`dither`&&(0,G.jsx)(Tre,{size:t,speed:n,reduce:a}),pj[e]&&(0,G.jsx)(vj,{frames:pj[e],size:t,speed:n,reduce:a}),e===`morph`&&(0,G.jsx)(Ej,{size:t,speed:n,reduce:a}),e===`comet`&&(0,G.jsx)(Oj,{size:t,speed:n,reduce:a}),e===`scramble`&&(0,G.jsx)(jj,{size:t,speed:n,reduce:a}),e===`metaballs`&&(0,G.jsx)(Mj,{size:t,speed:n,reduce:a}),e===`newton`&&(0,G.jsx)(Pj,{size:t,speed:n,reduce:a}),e===`helix`&&(0,G.jsx)(Fj,{size:t,speed:n,reduce:a}),e===`percent`&&(0,G.jsx)(Ij,{size:t,speed:n,reduce:a}),(0,G.jsx)(`span`,{className:`sr-only`,children:r})]})}function gj({size:e,speed:t,reduce:n}){let r=Math.max(2,e*.09),i=(e-r)/2;return(0,G.jsxs)(q.svg,{width:e,height:e,viewBox:`0 0 ${e} ${e}`,animate:n?mj.animate:{rotate:360},transition:n?mj.transition:{duration:t,ease:`linear`,repeat:1/0},children:[(0,G.jsx)(`circle`,{cx:e/2,cy:e/2,r:i,fill:`none`,stroke:`currentColor`,strokeOpacity:.2,strokeWidth:r}),(0,G.jsx)(`path`,{d:`M ${e/2} ${e/2-i} A ${i} ${i} 0 0 1 ${e/2+i} ${e/2}`,fill:`none`,stroke:`currentColor`,strokeWidth:r,strokeLinecap:`round`})]})}function _j({size:e,speed:t,reduce:n}){let r=e*.24;return(0,G.jsx)(`span`,{className:`flex items-center`,style:{gap:e*.14},children:[0,1,2].map(i=>(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:r,height:r},animate:n?{opacity:[.4,1,.4]}:{y:[0,-e*.3,0],opacity:[.5,1,.5]},transition:{duration:t,ease:JD,repeat:1/0,delay:i*t*.16}},i))})}function vj({frames:e,size:t,speed:n,reduce:r}){let[i,a]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let t=(r?n*2.5:n)/e.length*1e3,i=setInterval(()=>a(t=>(t+1)%e.length),t);return()=>clearInterval(i)},[e.length,n,r]),(0,G.jsx)(`span`,{className:`font-mono leading-none tabular-nums`,style:{fontSize:t,lineHeight:1},children:e[i%e.length]})}var yj=24;function bj(e,t,n=0){let r=2*Math.PI/t,i=((e-n)%r+r)%r-r/2;return Math.cos(Math.PI/t)/Math.cos(i)}function xj(e){let t=[];for(let n=0;n<yj;n++){let r=n/yj*2*Math.PI-Math.PI/2,i=Math.min(1.05,e(r)),a=(50+Math.cos(r)*46*i).toFixed(2),o=(50+Math.sin(r)*46*i).toFixed(2);t.push(`${n===0?`M`:`L`}${a} ${o}`)}return`${t.join(` `)} Z`}var Sj=[xj(()=>1),xj(e=>bj(e,4,Math.PI/4)),xj(e=>bj(e,3)),xj(e=>bj(e,6)),xj(e=>bj(e,4))],Cj=[...Sj.flatMap(e=>[e,e]),Sj[0]],wj=[0,0,72,72,144,144,216,216,288,288,360],Tj=[1,1,.88,.88,1,1,.88,.88,1,1,1];function Ej({size:e,speed:t,reduce:n}){return(0,G.jsxs)(q.svg,{width:e,height:e,viewBox:`0 0 100 100`,role:`img`,animate:n?{opacity:[1,.4,1]}:{rotate:wj,scale:Tj},transition:n?{duration:1.4,ease:JD,repeat:1/0}:{duration:t*5,ease:JD,repeat:1/0},children:[(0,G.jsx)(`title`,{children:`Loading`}),(0,G.jsx)(q.path,{fill:`currentColor`,d:Sj[0],animate:n?void 0:{d:Cj},transition:n?void 0:{duration:t*5,ease:JD,repeat:1/0}})]})}var Dj=[0,1,2,3,4,5];function Oj({size:e,speed:t,reduce:n}){let r=e*.2,i=e/2-r/2;return(0,G.jsx)(`span`,{className:`relative`,style:{width:e,height:e},children:(0,G.jsx)(q.span,{className:`absolute inset-0`,animate:n?mj.animate:{rotate:360},transition:n?mj.transition:{duration:t,ease:`linear`,repeat:1/0},children:Dj.map(e=>{let t=1-e*.13,n=r*t;return(0,G.jsx)(`span`,{className:`absolute top-1/2 left-1/2 rounded-full bg-current`,style:{width:n,height:n,marginLeft:-n/2,marginTop:-n/2,opacity:1-e*.16,transform:`rotate(${-e*15}deg) translateY(${-i}px)`}},e)})})})}var kj=`LOADING`,Aj=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>/*#@`;function jj({size:e,speed:t,reduce:n}){let[r,i]=(0,v.useState)(kj);return(0,v.useEffect)(()=>{if(n){i(kj);return}let e=0,r=setInterval(()=>{let t=e%11,n=``;for(let e=0;e<7;e++)n+=e<t?kj[e]:Aj[Math.floor(Math.random()*42)];i(n),e++},t/7*1e3*.55);return()=>clearInterval(r)},[t,n]),(0,G.jsx)(`span`,{className:`font-mono font-medium tracking-[0.2em] tabular-nums`,style:{fontSize:e*.42},children:r})}function Mj({size:e,speed:t,reduce:n}){let r=(0,v.useId)().replace(/:/g,``);return(0,G.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 100 100`,role:`img`,children:[(0,G.jsx)(`title`,{children:`Loading`}),(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`filter`,{id:r,children:[(0,G.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`5`,result:`b`}),(0,G.jsx)(`feColorMatrix`,{in:`b`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8`})]})}),(0,G.jsxs)(`g`,{filter:`url(#${r})`,fill:`currentColor`,children:[(0,G.jsx)(q.circle,{cy:`50`,r:`15`,animate:n?{opacity:[.4,1,.4]}:{cx:[30,70,30]},transition:{duration:t*1.6,ease:JD,repeat:1/0},cx:n?40:30}),(0,G.jsx)(q.circle,{cy:`50`,r:`15`,animate:n?{opacity:[.4,1,.4]}:{cx:[70,30,70]},transition:{duration:t*1.6,ease:JD,repeat:1/0},cx:n?60:70})]})]})}var Nj=[0,1,2,3,4];function Pj({size:e,speed:t,reduce:n}){let r=e*.2,i=r*1.1,a={0:{x:[0,-i,0,0],times:[0,.28,.5,1]},4:{x:[0,0,i,0],times:[0,.5,.78,1]}};return(0,G.jsx)(`span`,{className:`flex items-center justify-center`,style:{height:r},children:Nj.map(e=>{let i=a[e];return(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:r,height:r},animate:n||!i?void 0:{x:i.x},transition:n||!i?void 0:{duration:t*1.5,ease:JD,repeat:1/0,times:i.times}},e)})})}function Fj({size:e,speed:t,reduce:n}){let r=e*.14,i=e*.32;return(0,G.jsx)(`span`,{className:`relative`,style:{width:e,height:e},children:Array.from({length:7},(a,o)=>{let s=o/6*(e-r),c=o/7*t;return(0,G.jsxs)(`span`,{children:[(0,G.jsx)(q.span,{className:`absolute rounded-full bg-current`,style:{width:r,height:r,left:e/2-r/2,top:s},animate:n?{opacity:[.4,1,.4]}:{x:[i,-i,i],scale:[1,.5,1],opacity:[1,.45,1]},transition:{duration:t,ease:JD,repeat:1/0,delay:c}}),(0,G.jsx)(q.span,{className:`absolute rounded-full bg-current`,style:{width:r,height:r,left:e/2-r/2,top:s},animate:n?{opacity:[.4,1,.4]}:{x:[-i,i,-i],scale:[.5,1,.5],opacity:[.45,1,.45]},transition:{duration:t,ease:JD,repeat:1/0,delay:c}})]},`row-${s}`)})})}function Ij({size:e,speed:t,reduce:n}){let[r,i]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let e=(n?t*2:t)*1e3,r={t:0},a=setInterval(()=>{r.t+=40;let t=Math.min(100,Math.round(r.t/e*100));i(t),t>=100&&(r.t=0)},40);return()=>clearInterval(a)},[t,n]),(0,G.jsxs)(`span`,{className:`flex flex-col items-center`,style:{gap:e*.14,width:e*1.4},children:[(0,G.jsxs)(`span`,{className:`font-mono font-medium tabular-nums`,style:{fontSize:e*.42,lineHeight:1},children:[r,`%`]}),(0,G.jsx)(`span`,{className:`w-full overflow-hidden rounded-full bg-current/15`,style:{height:Math.max(3,e*.1)},children:(0,G.jsx)(`span`,{className:`block h-full rounded-full bg-current`,style:{width:`${r}%`}})})]})}function Lj({size:e,speed:t,reduce:n}){let r=e*.16;return(0,G.jsx)(`span`,{className:`flex items-center`,style:{gap:e*.1,height:e},children:[0,1,2,3].map(i=>(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:r,height:e,originY:1},animate:n?{opacity:[.4,1,.4]}:{scaleY:[.3,1,.3]},transition:{duration:t,ease:JD,repeat:1/0,delay:i*t*.12}},i))})}function wre({size:e,speed:t,reduce:n}){let r=e*.14,i=(e-r*2)/3,a=Array.from({length:9},(e,t)=>t);return(0,G.jsx)(`span`,{className:`grid`,style:{gap:r,gridTemplateColumns:`repeat(3, ${i}px)`},children:a.map(e=>{let r=(e%3+Math.floor(e/3))/4*t;return(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:i,height:i},animate:n?{opacity:[.3,1,.3]}:{opacity:[.2,1,.2],scale:[.7,1,.7]},transition:{duration:t,ease:JD,repeat:1/0,delay:r}},e)})})}var Rj=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function Tre({size:e,speed:t,reduce:n}){let r=Math.max(1,e*.05),i=(e-r*3)/4;return(0,G.jsx)(`span`,{className:`grid`,style:{gap:r,gridTemplateColumns:`repeat(4, ${i}px)`},children:Rj.map((e,r)=>(0,G.jsx)(q.span,{className:`bg-current`,style:{width:i,height:i},animate:n?{opacity:[.3,1,.3]}:{opacity:[.1,1,.1]},transition:{duration:t,ease:JD,repeat:1/0,delay:e/Rj.length*t}},r))})}var Ere=Z_(`relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current`}},defaultVariants:{variant:`default`}});function Dre({className:e,variant:t,...n}){return(0,G.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:K(Ere({variant:t}),e),...n})}function Ore({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`alert-description`,className:K(`col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed`,e),...t})}var zj=Z_(`inline-flex 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-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function Bj({className:e,variant:t=`default`,asChild:n=!1,...r}){return n?(0,G.jsx)(bf,{className:K(zj({variant:t}),e),...r}):(0,G.jsx)(nA,{status:t===`destructive`?`danger`:t==="default"?`info`:`neutral`,size:`sm`,showIcon:!1,"data-slot":`badge`,"data-variant":t,className:K(zj({variant:t}),e),...r})}var Vj={duration:0},kre={type:`spring`,duration:.4,bounce:.3},Are={hidden:{},show:{transition:{staggerChildren:.035,delayChildren:.05}}},jre={hidden:{opacity:0,y:-6,filter:`blur(3px)`},show:{opacity:1,y:0,filter:`blur(0px)`}},Hj=(0,v.createContext)(null);function Uj(e){let t=(0,v.useContext)(Hj);if(!t)throw Error(`${e} must be used within <Select>`);return t}function Mre({value:e,defaultValue:t,onValueChange:n,open:r,defaultOpen:i=!1,onOpenChange:a,disabled:o=!1,className:s,children:c}){let l=RD()??!1,u=(0,v.useId)(),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),[m,h]=(0,v.useState)(`${u}-trigger`),[g,_]=(0,v.useState)(i),[y,b]=(0,v.useState)(t),[x,S]=(0,v.useState)(new Map),[C,w]=(0,v.useState)(`bottom`),T=e!==void 0,E=T?e:y,D=r!==void 0,O=!o&&(D?r:g),k=(0,v.useCallback)(e=>{D||_(e),a?.(e)},[a,D]),A=(0,v.useCallback)(e=>{T||b(e),n?.(e),k(!1),f.current?.focus({preventScroll:!0})},[T,n,k]),j=(0,v.useCallback)((e,t)=>{S(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),M=(0,v.useCallback)(e=>{S(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]);(0,v.useEffect)(()=>{if(!O)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),k(!1),f.current?.focus())},t=e=>{d.current&&!d.current.contains(e.target)&&!p.current?.contains(e.target)&&k(!1)};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`pointerdown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`pointerdown`,t)}},[O,k]);let N=(0,v.useMemo)(()=>({value:E,open:O,setOpen:k,select:A,register:j,unregister:M,labelFor:e=>e===void 0?void 0:x.get(e),reduce:l,triggerId:m,setTriggerId:h,triggerRef:f,contentRef:p,listId:`${u}-list`,disabled:o,placement:C,setPlacement:w}),[E,O,k,A,j,M,x,l,u,m,o,C]);return(0,G.jsx)(Hj.Provider,{value:N,children:(0,G.jsx)(`div`,{ref:d,className:J(`relative`,s),children:c})})}function Nre({className:e,children:t,id:n,onClick:r,onKeyDown:i,ref:a,...o}){let s=Uj(`SelectTrigger`);(0,v.useLayoutEffect)(()=>{n&&s.setTriggerId(n)},[n,s.setTriggerId]);let c=s.placement===`top`,l=s.open?[0,0,12]:[12,0,12],u=s.reduce?{duration:0}:s.open?{duration:.6,times:[0,.4,1],ease:qD}:{duration:.42,times:[0,.5,1],ease:qD};return(0,G.jsxs)(q.button,{...o,ref:e=>{s.triggerRef.current=e,typeof a==`function`?a(e):a&&(a.current=e)},role:`combobox`,type:`button`,id:s.triggerId,disabled:s.disabled,"aria-haspopup":`listbox`,"aria-expanded":s.open,"aria-controls":s.listId,onClick:e=>{r?.(e),e.defaultPrevented||s.setOpen(!s.open)},onKeyDown:e=>{i?.(e),!e.defaultPrevented&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&(e.preventDefault(),s.setOpen(!0))},initial:!1,animate:{borderTopLeftRadius:c?l:12,borderTopRightRadius:c?l:12,borderBottomLeftRadius:c?12:l,borderBottomRightRadius:c?12:l},transition:{borderTopLeftRadius:c?u:Vj,borderTopRightRadius:c?u:Vj,borderBottomLeftRadius:c?Vj:u,borderBottomRightRadius:c?Vj:u},className:J(`relative z-10 flex w-full items-center justify-between gap-2 rounded-xl border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors`,`hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20`,`disabled:pointer-events-none disabled:opacity-50`,e),children:[t,(0,G.jsx)(q.span,{"aria-hidden":!0,animate:{rotate:s.open?180:0},transition:s.reduce?{duration:0}:kre,className:`text-muted-foreground`,children:(0,G.jsx)(ul,{className:`h-4 w-4`})})]})}function Wj({placeholder:e,className:t,children:n}){let r=Uj(`SelectValue`),i=r.labelFor(r.value);return(0,G.jsx)(`span`,{className:J(i?`text-foreground`:`text-muted-foreground`,t),children:n??i??e??`Select`})}function Pre({className:e,children:t}){let n=Uj(`SelectContent`),r=(0,v.useRef)(null),[i,a]=(0,v.useState)(0),o=n.open,{setPlacement:s}=n,[c,l]=(0,v.useState)({left:0,top:0,width:0,maxHeight:300}),u=(0,v.useRef)({text:``,at:0}),[d,f]=(0,v.useState)(null);(0,v.useLayoutEffect)(()=>{f(n.triggerRef.current?.closest(`[role="dialog"], [role="alertdialog"]`)??document.body)},[n.triggerRef]),(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.offsetHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[d]),(0,v.useLayoutEffect)(()=>{if(!o)return;let e=n.triggerRef.current,t=r.current;if(!e||!t)return;let i=()=>{let n=e.getBoundingClientRect(),r=d===document.body?null:d,i=r?.getBoundingClientRect(),a=Math.min(window.innerHeight,i?.bottom??window.innerHeight)-n.bottom,o=n.top-Math.max(0,i?.top??0),c=Math.max(8,(i?.left??0)+8),u=Math.min(window.innerWidth-8,(i?.right??window.innerWidth)-8),f=Math.max(0,u-c);t.style.maxWidth=`${f}px`,t.style.minWidth=`${Math.min(n.width,f)}px`;let p=Math.min(f,Math.max(n.width,t.offsetWidth+2)),m=a<Math.min(t.offsetHeight,300)+16&&o>a;s(m?`top`:`bottom`),l({left:Math.max(c,Math.min(n.left,u-p))-(i?.left??0)+(r?.scrollLeft??0),top:r?(m?n.top:n.bottom)-(i?.top??0)+r.scrollTop:m?window.innerHeight-n.top:n.bottom,width:p,maxHeight:Math.max(60,Math.min(300,(m?o:a)-24))})};i(),(t.querySelector(`[role="option"][aria-selected="true"]:not(:disabled)`)??t.querySelector(`[role="option"]:not(:disabled)`))?.focus({preventScroll:!0});let a=new ResizeObserver(i);return a.observe(t),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,i,!0),()=>{a.disconnect(),window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,i,!0)}},[o,n.triggerRef,s,d]);let p=n.placement===`top`,m=o?8:0,h=o?12:0,g=o?{type:`spring`,duration:.6,bounce:.5,delay:.12}:{type:`spring`,duration:.3,bounce:.1},_=o?{duration:.3,ease:qD,delay:.14}:{duration:.16,ease:qD};if(!d)return null;let y=d!==document.body;return(0,Ff.createPortal)((0,G.jsx)(q.div,{ref:n.contentRef,id:n.listId,role:`listbox`,"aria-labelledby":n.triggerId,"aria-hidden":!o,inert:!o,onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role="option"]:not(:disabled)`)),r=t.indexOf(document.activeElement);if(e.key===`Tab`){n.setOpen(!1),n.triggerRef.current?.focus();return}let i;if(e.key===`ArrowDown`)i=t[(r+1)%t.length];else if(e.key===`ArrowUp`)i=t[(r-1+t.length)%t.length];else if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t.at(-1);else if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&e.key!==` `){let n=Date.now();u.current={text:(n-u.current.at<700?u.current.text:``)+e.key.toLowerCase(),at:n},i=t.find(e=>e.textContent?.trim().toLowerCase().startsWith(u.current.text))}i&&(e.preventDefault(),i.focus())},initial:!1,animate:n.reduce?{opacity:+!!o,height:o?i:0}:{opacity:+!!o,height:o?i:0,marginTop:p?0:m,marginBottom:p?m:0,borderTopLeftRadius:p?12:h,borderTopRightRadius:p?12:h,borderBottomLeftRadius:p?h:12,borderBottomRightRadius:p?h:12},transition:n.reduce?{duration:.12}:{opacity:o?{duration:.18}:{duration:.16,delay:.12},height:o?{type:`spring`,duration:.42,bounce:.14}:{duration:.26,ease:qD,delay:.14},marginTop:p?Vj:g,marginBottom:p?g:Vj,borderTopLeftRadius:p?Vj:_,borderTopRightRadius:p?Vj:_,borderBottomLeftRadius:p?_:Vj,borderBottomRightRadius:p?_:Vj},style:{position:y?`absolute`:`fixed`,left:c.left,width:c.width,zIndex:80,top:y||!p?c.top:`auto`,bottom:!y&&p?c.top:`auto`,translate:y&&p?`0 -100%`:void 0,transformOrigin:p?`bottom`:`top`,overflow:`hidden`,pointerEvents:o?`auto`:`none`},className:J(`rounded-xl border border-border bg-popover text-popover-foreground shadow-xl`,e),children:(0,G.jsx)(q.div,{ref:r,variants:n.reduce?void 0:Are,initial:!1,animate:o?`show`:`hidden`,className:`grid w-max gap-1.5 overflow-y-auto overscroll-contain p-1.5`,style:{maxHeight:c.maxHeight},children:t})}),d)}function Gj({value:e,disabled:t=!1,className:n,children:r,textValue:i}){let a=Uj(`SelectItem`),o=a.value===e,s=i??r;return(0,v.useLayoutEffect)(()=>(a.register(e,s),()=>a.unregister(e)),[a.register,a.unregister,e,s]),(0,G.jsx)(q.div,{role:`presentation`,variants:a.reduce?void 0:jre,children:(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":o,disabled:t,onClick:()=>a.select(e),className:J(`flex min-h-9 w-full items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left text-[13px] leading-5 outline-none transition-colors duration-150`,o?`border-primary/25 bg-primary/12 text-foreground`:`border-transparent text-foreground/80`,`hover:border-primary/45 hover:bg-primary/25 hover:text-foreground focus-visible:border-primary/60 focus-visible:bg-primary/25 focus-visible:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`,n),children:[(0,G.jsx)(`span`,{className:`min-w-0 whitespace-normal [overflow-wrap:anywhere]`,children:r}),(0,G.jsx)(cl,{"aria-hidden":`true`,className:J(`h-3.5 w-3.5 shrink-0`,!o&&`invisible`)})]})})}function Kj(e){return(0,G.jsx)(Mre,{...e})}function qj({className:e,size:t=`default`,...n}){return(0,G.jsx)(Nre,{...n,"data-slot":`select-trigger`,"data-size":t,className:K(`min-w-0 shadow-xs`,t===`sm`?`h-8`:`h-9`,e)})}function Jj({position:e,align:t,...n}){return(0,G.jsx)(Pre,{...n})}var Fre={default:`default`,secondary:`secondary`,error:`destructive`,success:`ghost`,warning:`ghost`,accent:`ghost`},Ire={default:``,secondary:``,error:``,success:`bg-success text-white hover:bg-success/90`,warning:`bg-warning text-white hover:bg-warning/90`,accent:`bg-brand text-brand-foreground hover:bg-brand/90`},Lre={default:`border bg-transparent text-foreground hover:bg-accent`,secondary:`border bg-transparent text-muted-foreground hover:bg-accent`,error:`border border-destructive/40 bg-transparent text-destructive hover:bg-destructive/10`,success:`border border-success/40 bg-transparent text-success hover:bg-success/10`,warning:`border border-warning/40 bg-transparent text-warning hover:bg-warning/10`,accent:`border border-brand/40 bg-transparent text-brand hover:bg-brand/10`};function Z({type:e=`default`,size:t=`md`,ghost:n=!1,loading:r=!1,icon:i,className:a,children:o,disabled:s,...c}){return(0,G.jsxs)(nO,{type:`button`,variant:n?`ghost`:Fre[e],size:t===`sm`?`sm`:`default`,className:K(n?Lre[e]:Ire[e],a),disabled:s||r,...c,children:[r?(0,G.jsx)(Qj,{small:!0}):i,o!=null&&(0,G.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:o})]})}var Rre={default:``,secondary:`text-muted-foreground`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,error:`border-destructive/40 text-destructive`,accent:`border-brand/40 text-brand`};function Yj({type:e=`default`,label:t,children:n,className:r}){let i=t===!1?null:t??e;return(0,G.jsx)(Dre,{role:`note`,className:K(Rre[e],r),children:(0,G.jsxs)(Ore,{className:`text-current`,children:[i!=null&&(0,G.jsxs)(`b`,{className:`font-semibold`,children:[i,`:`]}),` `,n]})})}var zre={default:`default`,secondary:`secondary`,error:`destructive`,success:`outline`,warning:`outline`,accent:`outline`},Bre={default:``,secondary:``,error:``,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,accent:`border-brand/40 text-brand`};function Xj({type:e=`default`,children:t,className:n}){return(0,G.jsx)(Bj,{variant:zre[e],className:K(`font-mono`,Bre[e],n),children:t})}var Vre={default:`bg-muted-foreground`,secondary:`bg-muted-foreground/60`,success:`bg-success`,warning:`bg-warning`,error:`bg-destructive`,accent:`bg-brand`};function Zj({type:e=`default`,pulse:t=!1,color:n,className:r}){return(0,G.jsx)(`span`,{className:K(`inline-block size-2 shrink-0 rounded-full`,!n&&Vre[e],t&&`animate-pulse`,r),style:n?{background:n}:void 0})}function Qj({small:e=!1}){return(0,G.jsx)(hj,{variant:`spinner`,size:e?12:16,label:`Loading`,className:`text-current`})}function $j({className:e,...t}){return(0,G.jsx)(Ok,{className:K(`font-mono`,e),...t})}var eM=`\0empty`,tM=e=>e===``?eM:e,Hre=e=>e===eM?``:e;function nM({value:e,onValueChange:t,options:n,placeholder:r,className:i,disabled:a,size:o=`md`,"aria-label":s}){return(0,G.jsxs)(Kj,{value:tM(e),onValueChange:e=>t(Hre(e)),disabled:a,children:[(0,G.jsx)(qj,{size:o===`sm`?`sm`:`default`,"aria-label":s,className:K(`font-mono`,i),children:(0,G.jsx)(Wj,{placeholder:r})}),(0,G.jsx)(Jj,{children:n.map(e=>(0,G.jsx)(Gj,{value:tM(e.value),className:`font-mono`,children:e.label},e.value))})]})}function rM({children:e,className:t,hoverable:n=!1}){return(0,G.jsx)(rk,{className:K(`gap-0 py-0`,n&&`transition-colors hover:border-brand/40`,t),children:e})}function Ure(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)({show_sensitive:!1,verbose:!1,compact:!1,terse:!1}),C=(0,v.useRef)(null),w=(0,v.useCallback)(()=>{U(`/api/backups`).then(e=>{t(e),p(t=>t||e.devices[0]||``)}).catch(()=>t({dir:``,devices:[],backups:[]}))},[]);(0,v.useEffect)(()=>w(),[w]);let T=(e,t)=>_c(e,t).catch(()=>({error:`request failed`})),E=async()=>{a(!0),r(`Capturing /export…`);let e=await _c(`/api/backups/create`,{device:f||void 0,label:y.trim()||void 0,show_sensitive:x.show_sensitive,verbose:x.verbose,compact:!x.verbose&&x.compact,terse:x.terse}).catch(()=>({error:`request failed`}));a(!1),r(e.ok?`Created ${e.name} (${e.bytes} bytes)`:`Create failed: ${e.error}`),e.ok?(Y.success(`Backup created`),w()):Y.error(`Create failed: ${e.error}`)},D=e=>S(t=>({...t,[e]:!t[e]})),O=async e=>{let t=await e.text(),n=await T(`/api/backups/upload`,{name:e.name,content:t});r(n.ok?`Uploaded ${n.name}`:`Upload failed: ${n.error}`),n.ok?(Y.success(`Backup uploaded`),w()):Y.error(`Upload failed: ${n.error}`)},k=async e=>{s(null);let t=await T(`/api/backups/delete`,{name:e});r(t.ok?`Deleted ${e}`:`Delete failed: ${t.error}`),t.ok?(Y.success(`Backup deleted`),w()):Y.error(`Delete failed: ${t.error}`)},A=async()=>{if(!u)return;let{name:e,value:t}=u;if(d(null),!t||t===e)return;let n=await T(`/api/backups/rename`,{name:e,new_name:t});r(n.ok?`Renamed to ${n.name}`:`Rename failed: ${n.error}`),n.ok?(Y.success(`Backup renamed`),w()):Y.error(`Rename failed: ${n.error}`)},j=async e=>{if(!c)return;a(!0),r(e?`Restoring in Safe Mode…`:`Dry-run restore in Safe Mode…`);let t=await _c(`/api/backups/restore`,{name:c,device:f||void 0,confirm:e}).catch(()=>({ok:!1,message:`request failed`}));a(!1),r(t.ok?t.committed?`Restored ${c} → ${f}: ${t.message}`:`Dry-run OK (${t.applied} cmds, rolled back). Click “Restore (commit)” to apply for real.`:`Restore failed: ${t.message}`),t.ok?Y.success(t.committed?`Backup restored`:`Dry-run restore OK`):Y.error(`Restore failed: ${t.message}`),t.ok&&e&&l(null)},M=e=>{U(`/api/backups/get?name=${encodeURIComponent(e)}`).then(h).catch(()=>{})},N=async()=>{if(g===null)return;let t=g.trim();if(!t||t===e?.dir){_(null);return}a(!0);let n=await _c(`/api/backups/dir`,{dir:t}).catch(()=>({error:`request failed`}));a(!1),_(null),n.ok?(r(n.persisted?`Backup path saved → ${n.dir}`:n.warning??`Path applied → ${n.dir}`),Y.success(`Backup directory updated`)):(r(`Path change failed: ${n.error}`),Y.error(`Path change failed: ${n.error}`)),n.ok&&w()};if(!e)return(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading backups…`});let P=e.devices.length===0?[{value:``,label:`no devices`}]:e.devices.map(e=>({value:e,label:e}));return(0,G.jsxs)(`section`,{className:`grid content-start gap-[18px]`,children:[(0,G.jsxs)(X,{title:`Local backup vault`,className:`reveal`,extra:g===null?(0,G.jsxs)(`span`,{className:`inline-flex max-w-[min(60vw,520px)] items-center gap-2 text-muted-foreground text-[11px]`,children:[(0,G.jsx)(`span`,{className:`truncate`,title:e.dir,children:e.dir}),(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 whitespace-nowrap text-brand hover:underline`,title:`Change backup directory`,onClick:()=>_(e.dir),children:[(0,G.jsx)(Hu,{className:`size-3`}),` edit path`]})]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)($j,{className:`w-[min(48vw,380px)] text-xs`,value:g,autoFocus:!0,spellCheck:!1,placeholder:`~/.mikrotik-mcp/backups`,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N(),e.key===`Escape`&&_(null)}}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,onClick:()=>void N(),disabled:i,children:`Save path`}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>_(null),children:`Cancel`})]}),children:[n&&(0,G.jsx)(`div`,{className:`mb-3 font-mono text-xs text-muted-foreground`,children:n}),(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(nM,{value:f,onValueChange:p,"aria-label":`Device`,options:P}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,icon:(0,G.jsx)(Xu,{}),onClick:()=>void E(),disabled:i||!f,children:`Create backup`}),(0,G.jsx)(Z,{size:`sm`,icon:(0,G.jsx)(ef,{}),onClick:()=>C.current?.click(),children:`Upload .rsc`}),(0,G.jsx)(`input`,{ref:C,type:`file`,accept:`.rsc,text/plain`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&O(t),e.currentTarget.value=``}}),(0,G.jsx)(Z,{size:`sm`,icon:(0,G.jsx)(nd,{}),onClick:w,children:`Refresh`})]}),(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2.5`,children:[(0,G.jsx)($j,{className:`max-w-[200px] text-xs`,value:y,spellCheck:!1,placeholder:`label (optional), e.g. pre-upgrade`,onChange:e=>b(e.target.value)}),[[`show_sensitive`,`show-sensitive`,`Include secrets (keys/passwords)`],[`verbose`,`verbose`,`Include every parameter, even defaults`],[`compact`,`compact`,`Only non-default values (ignored if verbose)`],[`terse`,`terse`,`One machine-readable line per item`]].map(([e,t,n])=>{let r=e===`compact`&&x.verbose;return(0,G.jsxs)(`label`,{className:K(`inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 py-1.5 font-mono text-[11px] select-none`,x[e]?`border-brand/55 bg-brand/10 text-foreground`:`border-border bg-muted/40 text-muted-foreground`,r&&`cursor-not-allowed opacity-45`),title:n,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`accent-brand`,checked:x[e],disabled:r,onChange:()=>D(e)}),t]},e)})]}),c&&(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-warning/45 bg-warning/10 px-3 py-2.5 text-xs`,children:[(0,G.jsxs)(`strong`,{children:[`Restore `,c]}),` onto`,` `,(0,G.jsx)(nM,{value:f,onValueChange:p,size:`sm`,"aria-label":`Restore target device`,options:e.devices.map(e=>({value:e,label:e}))}),` `,`via Safe Mode (auto-reverts on lock-out).`,(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>void j(!1),disabled:i,children:`Dry-run`}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,onClick:()=>void j(!0),disabled:i,children:`Restore (commit)`}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>l(null),children:`Cancel`})]}),e.backups.length===0?(0,G.jsx)(`div`,{className:`p-3 text-muted-foreground text-[11px]`,children:"No backups yet. Click “Create backup” to capture this device’s config, or upload a `.rsc`."}):(0,G.jsx)(`div`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border`,children:(0,G.jsxs)(ZO,{className:`min-w-[980px] table-fixed`,children:[(0,G.jsx)(QO,{className:`bg-card sticky top-0 z-10`,children:(0,G.jsxs)(ek,{children:[(0,G.jsx)(tk,{children:`name`}),(0,G.jsx)(tk,{className:`w-[130px]`,children:`device`}),(0,G.jsx)(tk,{className:`w-[90px] text-right`,children:`size`}),(0,G.jsx)(tk,{className:`w-[170px]`,children:`captured`}),(0,G.jsx)(tk,{className:`w-[380px]`,children:`actions`})]})}),(0,G.jsx)($O,{children:e.backups.map(e=>(0,G.jsxs)(ek,{"data-state":m?.name===e.name?`selected`:void 0,children:[(0,G.jsx)(nk,{className:`truncate font-mono`,title:e.name,children:e.name}),(0,G.jsx)(nk,{className:`truncate`,children:e.device??`—`}),(0,G.jsx)(nk,{className:`text-right tabular-nums`,children:Vk(e.bytes)}),(0,G.jsx)(nk,{className:`tabular-nums whitespace-nowrap`,children:new Date(e.modified).toLocaleString(void 0,{hour12:!1})}),(0,G.jsx)(nk,{onClick:e=>e.stopPropagation(),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Z,{size:`sm`,onClick:()=>M(e.name),children:`view`}),(0,G.jsx)(`a`,{className:`inline-flex items-center rounded-md border border-border px-2 py-1 text-xs hover:bg-accent`,href:gc(`/api/backups/raw?name=${encodeURIComponent(e.name)}`),download:e.name,title:`Download`,children:(0,G.jsx)(Hl,{className:`size-3.5`})}),u?.name===e.name?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)($j,{className:`inline-block w-[120px] text-xs`,value:u.value,autoFocus:!0,onChange:t=>d({name:e.name,value:t.target.value}),onKeyDown:e=>e.key===`Enter`&&void A()}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,icon:(0,G.jsx)(cl,{}),onClick:()=>void A()}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,icon:(0,G.jsx)(df,{}),onClick:()=>d(null)})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{size:`sm`,onClick:()=>d({name:e.name,value:e.name}),children:`rename`}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,onClick:()=>l(e.name),children:`restore`})]}),o===e.name?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{type:`error`,size:`sm`,ghost:!0,icon:(0,G.jsx)(cl,{}),onClick:()=>void k(e.name)}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,icon:(0,G.jsx)(df,{}),onClick:()=>s(null)})]}):(0,G.jsx)(Z,{type:`error`,size:`sm`,ghost:!0,icon:(0,G.jsx)(Kd,{}),onClick:()=>s(e.name)})]})})]},e.name))})]})})]}),m&&(0,G.jsx)(X,{title:`Backup · ${m.name}`,className:`reveal`,extra:(0,G.jsx)(Z,{type:`secondary`,size:`sm`,icon:(0,G.jsx)(df,{}),onClick:()=>h(null),children:`Close`}),children:(0,G.jsx)(`pre`,{className:`m-0 overflow-auto rounded border border-border bg-background p-3 font-mono text-xs break-words whitespace-pre-wrap`,style:{maxHeight:460},children:m.content||`(empty)`})})]})}var iM=`http://www.w3.org/2000/svg`,aM=864e5,oM=e=>new Date(e).toISOString().slice(0,10);function sM(){let e=new Date;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function Wre(e){return new Date(`${e}T00:00:00Z`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`})}function cM({endpoint:e,days:t=90}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0);(0,v.useEffect)(()=>{let t=!0;return a(!0),U(e).then(e=>{t&&r(e)}).catch(()=>{t&&r(null)}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let o=(0,v.useMemo)(()=>{let e=new Map((n?.series??[]).map(e=>[e.day,e])),r=sM(),i=[];for(let n=t-1;n>=0;n--){let t=oM(r-n*aM),a=e.get(t);i.push(a??{day:t,rx:0,tx:0})}return i},[n,t]);if(i)return(0,G.jsx)(`div`,{className:`px-1 py-4 text-[12.5px] text-muted-foreground`,children:`loading usage…`});if(!((n?.totalRx??0)+(n?.totalTx??0)>0))return(0,G.jsx)(`div`,{className:`px-1 py-4 text-[12.5px] text-muted-foreground`,children:`No usage recorded yet. The dashboard samples on a configurable interval (1 minute by default — see the RADIUS & UM Settings tab); history fills in over time (kept ~3 months).`});let s=Math.max(1,...o.flatMap(e=>[e.rx,e.tx])),c=e=>8+e*624/Math.max(1,o.length-1),l=e=>142-e/s*134,u=e=>o.map((t,n)=>`${c(n).toFixed(1)},${l(e(t)).toFixed(1)}`).join(` `),d=e=>{let t=c(0).toFixed(1),n=c(o.length-1).toFixed(1);return`${t},${142 .toFixed(1)} ${u(e)} ${n},${142 .toFixed(1)}`};return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline gap-3.5 text-xs tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`font-semibold text-chart-3`,children:[`↓ `,Vk(n?.totalRx??0),` down`]}),(0,G.jsxs)(`span`,{className:`font-semibold text-chart-4`,children:[`↑ `,Vk(n?.totalTx??0),` up`]}),(0,G.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`· peak/day `,Vk(s),` · last `,t,` days`]})]}),(0,G.jsxs)(`svg`,{className:`block h-40 w-full rounded-md border border-border bg-card`,viewBox:`0 0 640 150`,preserveAspectRatio:`none`,xmlns:iM,role:`img`,children:[(0,G.jsx)(`polygon`,{className:`fill-chart-3/20`,points:d(e=>e.rx)}),(0,G.jsx)(`polygon`,{className:`fill-chart-4/15`,points:d(e=>e.tx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-chart-3 stroke-2 [vector-effect:non-scaling-stroke]`,points:u(e=>e.rx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-chart-4 stroke-2 [vector-effect:non-scaling-stroke]`,points:u(e=>e.tx)})]})]})}var lM=12,Gre=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],uM=[`var(--muted)`,`color-mix(in srgb, var(--chart-3) 30%, var(--muted))`,`color-mix(in srgb, var(--chart-3) 50%, var(--muted))`,`color-mix(in srgb, var(--chart-3) 72%, transparent)`,`var(--chart-3)`];function dM({endpoint:e,label:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(null);(0,v.useEffect)(()=>{let t=!0;return U(e).then(e=>{t&&r(e)}).catch(()=>{t&&r({days:[],total:0,max:0})}),()=>{t=!1}},[e]);let{cells:s,monthLabels:c}=(0,v.useMemo)(()=>{let e=new Map((n?.days??[]).map(e=>[e.day,e.count])),t=sM(),r=t-(new Date(t).getUTCDay()+364)*aM,i=[],a=[],o=-1;for(let n=0;n<371;n++){let s=r+n*aM;if(s>t)break;let c=Math.floor(n/7),l=new Date(s).getUTCDay(),u=oM(s);if(i.push({day:u,count:e.get(u)??0,col:c,row:l,ms:s}),l===0){let e=new Date(s).getUTCMonth();e!==o&&(a.push({col:c,text:Gre[e]}),o=e)}}return{cells:i,monthLabels:a}},[n]),l=Math.max(1,n?.max??1),u=e=>e<=0?0:Math.min(4,Math.ceil(e/l*4)),d=(e,t)=>{let n=o.current;if(!n)return;let r=e.currentTarget.getBoundingClientRect(),i=n.getBoundingClientRect();a({left:r.left-i.left+r.width/2,top:r.top-i.top,day:t.day,count:t.count,lvl:u(t.count)})};return(0,G.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline gap-2.5`,children:[(0,G.jsx)(`span`,{className:`text-[12.5px] font-semibold`,children:t??`Connections`}),(0,G.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n?`${n.total} total`:`…`})]}),(0,G.jsx)(`div`,{className:`overflow-x-auto pb-1`,onMouseLeave:()=>a(null),children:(0,G.jsxs)(`svg`,{className:`block`,viewBox:`0 0 823 121`,width:823,height:121,xmlns:iM,role:`img`,children:[c.map(e=>(0,G.jsx)(`text`,{className:`fill-muted-foreground text-[9px]`,x:28+e.col*15,y:11,children:e.text},`${e.col}-${e.text}`)),[`Mon`,`Wed`,`Fri`].map((e,t)=>(0,G.jsx)(`text`,{className:`fill-muted-foreground text-[9px]`,x:0,y:16+(t*2+1)*15+lM-2,children:e},e)),s.map(e=>(0,G.jsx)(`rect`,{className:`cursor-pointer stroke-1 [transition:stroke_0.1s_ease] ${i?.day===e.day?`stroke-foreground stroke-[1.5px]`:`stroke-border/60`}`,style:{fill:uM[u(e.count)]},x:28+e.col*15,y:16+e.row*15,width:lM,height:lM,rx:2,onMouseEnter:t=>d(t,e)},e.day))]})}),i&&(0,G.jsxs)(`div`,{className:`pointer-events-none absolute z-30 min-w-[150px] -translate-x-1/2 translate-y-[calc(-100%-9px)] rounded-[10px] border border-chart-3/35 bg-popover px-2.5 py-2 shadow-xl`,style:{left:i.left,top:i.top},role:`tooltip`,children:[(0,G.jsx)(`span`,{className:`absolute -bottom-1.5 left-1/2 size-[11px] -translate-x-1/2 rotate-45 border-r border-b border-chart-3/35 bg-popover`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,G.jsx)(`span`,{className:`inline-block size-[12px] rounded-[2px]`,style:{background:uM[i.lvl]}}),(0,G.jsx)(`b`,{className:`font-semibold`,children:i.count===0?`No connections`:`${i.count} connection${i.count===1?``:`s`}`})]}),(0,G.jsx)(`div`,{className:`mt-[3px] text-[11.5px] text-muted-foreground tabular-nums`,children:Wre(i.day)})]}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-muted-foreground`,children:[`Less`,[0,1,2,3,4].map(e=>(0,G.jsx)(`span`,{className:`inline-block size-[11px] rounded-[2px]`,style:{background:uM[e]}},e)),`More`]})]})}var fM=e=>(e.flags??``).includes(`X`)||e.disabled===`yes`;function Kre(e,t){return e[t.idKey]||e.name||e.address||e.user||`(row)`}var pM=`mb-3.5 rounded-md border border-border bg-card p-3.5`,mM=`mb-2.5 text-[13px] font-semibold`,hM=`grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-x-3.5 gap-y-2.5`,gM=`mt-3.5 flex items-center gap-2.5`,_M=`flex flex-col gap-1`,vM=`text-[11.5px] text-muted-foreground`;function yM({config:e,device:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)({}),m=(0,v.useCallback)(async()=>{try{let n=t?`?device=${encodeURIComponent(t)}`:``;r(await U(`/api/aaa/list/${e.slug}${n}`)),a(null)}catch(e){a(e instanceof Error?e.message:String(e))}},[e.slug,t]);(0,v.useEffect)(()=>{r(null),d(null),m()},[m]);let h=(0,v.useCallback)(async(n,r)=>{s(!0),a(null);try{let i=await _c(`/api/aaa/${n}`,{device:t,slug:e.slug,...r}),o=n===`add`?`Entry added`:n===`update`?`Entry saved`:n===`remove`?`Entry removed`:n===`toggle`?r.enable?`Entry enabled`:`Entry disabled`:`Done`;return i.ok?(await m(),Y.success(o),!0):(a(i.message),Y.error(i.message||`${o} failed`),!1)}catch(e){return a(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Action failed`),!1}finally{s(!1)}},[t,e.slug,m]),g=()=>{d(`new`),p({})},_=t=>{d(t[e.idKey]);let n={};for(let r of e.fields)r.type!==`password`&&(r.key===`disabled`?n.disabled=fM(t)?`yes`:`no`:t[r.key]!=null&&(n[r.key]=t[r.key]));p(n)},y=async()=>{(u===`new`?await h(`add`,{fields:f}):await h(`update`,{id:u,fields:f}))&&d(null)},b=(0,v.useMemo)(()=>{let t=n?.rows??[],r=c.trim().toLowerCase();return r?t.filter(t=>e.columns.some(e=>(t[e.key]??``).toLowerCase().includes(r))):t},[n,c,e.columns]);return n&&!n.available?(0,G.jsxs)(Yj,{type:`warning`,label:`User Manager not installed`,children:[`This device doesn't have the `,(0,G.jsx)(`code`,{children:`user-manager`}),` package. Install it (System → Packages) and reboot to manage the built-in RADIUS server here.`]}):(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2.5`,children:[(0,G.jsx)($j,{className:`w-[200px]`,placeholder:`Filter…`,value:c,onChange:e=>l(e.target.value)}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[b.length,` rows`]}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,icon:(0,G.jsx)(nd,{}),onClick:()=>void m(),children:`Refresh`}),(0,G.jsx)(Z,{size:`sm`,type:`accent`,icon:(0,G.jsx)(Xu,{}),onClick:g,children:`Add`})]}),i&&(0,G.jsx)(Yj,{type:`error`,className:`mb-2.5`,children:i}),u&&(0,G.jsxs)(`div`,{className:pM,children:[(0,G.jsx)(`div`,{className:mM,children:u===`new`?`New ${e.slug}`:`Edit ${u}`}),(0,G.jsx)(`div`,{className:hM,children:e.fields.map(e=>(0,G.jsxs)(`label`,{className:_M,children:[(0,G.jsxs)(`span`,{className:vM,children:[e.label,e.required&&u===`new`?` *`:``]}),e.type===`bool`?(0,G.jsx)(nM,{value:f[e.key]??``,onValueChange:t=>p({...f,[e.key]:t}),options:[{value:``,label:`—`},{value:`no`,label:`no`},{value:`yes`,label:`yes`}]}):e.type===`select`?(0,G.jsx)(nM,{value:f[e.key]??``,onValueChange:t=>p({...f,[e.key]:t}),options:[{value:``,label:`—`},...(e.options??[]).map(e=>({value:e,label:e}))]}):(0,G.jsx)($j,{type:e.type===`password`?`password`:e.type===`number`?`number`:`text`,placeholder:e.placeholder??(e.type===`password`?`(unchanged)`:``),value:f[e.key]??``,onChange:t=>p({...f,[e.key]:t.target.value})})]},e.key))}),(0,G.jsxs)(`div`,{className:gM,children:[(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:o,onClick:()=>void y(),children:u===`new`?`Create`:`Save`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,onClick:()=>d(null),children:`Cancel`})]})]}),n?b.length===0?(0,G.jsx)(`div`,{className:`px-1 py-5 text-muted-foreground text-[11px]`,children:e.empty??`Nothing here yet.`}):(0,G.jsxs)(ZO,{className:`text-[13px]`,children:[(0,G.jsx)(QO,{children:(0,G.jsxs)(ek,{children:[e.columns.map(e=>(0,G.jsx)(tk,{children:e.label},e.key)),(0,G.jsx)(tk,{className:`text-right`,children:`Actions`})]})}),(0,G.jsx)($O,{children:b.map(t=>{let n=t[e.idKey],r=fM(t);return(0,G.jsxs)(ek,{children:[e.columns.map(e=>(0,G.jsx)(nk,{className:K(r&&`text-muted-foreground`),title:t[e.key]??``,children:e.key===`_status`?(0,G.jsx)(Xj,{type:r?`secondary`:`success`,children:r?`disabled`:`enabled`}):t[e.key]??``},e.key)),(0,G.jsx)(nk,{className:`text-right`,children:(0,G.jsxs)(`span`,{className:`flex justify-end gap-1.5`,children:[e.toggle&&(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:o,onClick:()=>void h(`toggle`,{id:n,enable:r}),children:r?`Enable`:`Disable`}),!e.addOnly&&(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:o,onClick:()=>_(t),children:`Edit`}),(0,G.jsx)(Z,{size:`sm`,type:`error`,ghost:!0,disabled:o,onClick:()=>void h(`remove`,{id:n}),children:`Remove`})]})})]},n||Kre(t,e))})})]}):(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading…`})]})}var bM=[`user`,`calling-station-id`,`nas-ip-address`,`started`,`ended`,`uptime`,`download`,`upload`,`status`];function qre({device:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),s=(0,v.useCallback)(async()=>{try{let t=e?`?device=${encodeURIComponent(e)}`:``;n(await U(`/api/aaa/list/um-sessions${t}`)),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}},[e]);if((0,v.useEffect)(()=>{n(null),s();let e=setInterval(()=>void s(),1e4);return()=>clearInterval(e)},[s]),t&&!t.available)return(0,G.jsxs)(Yj,{type:`warning`,label:`User Manager not installed`,children:[`The `,(0,G.jsx)(`code`,{children:`user-manager`}),` package isn't installed on this device.`]});let c=(t?.rows??[]).filter(e=>!a.trim()||(e.user??``).toLowerCase().includes(a.trim().toLowerCase()));return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2.5`,children:[(0,G.jsx)($j,{className:`w-[200px]`,placeholder:`Filter by user…`,value:a,onChange:e=>o(e.target.value)}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[c.length,` sessions`]}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,icon:(0,G.jsx)(nd,{}),onClick:()=>void s(),children:`Refresh`})]}),r&&(0,G.jsx)(Yj,{type:`error`,children:r}),t?c.length===0?(0,G.jsx)(`div`,{className:`px-1 py-5 text-muted-foreground text-[11px]`,children:`No accounting sessions recorded.`}):(0,G.jsxs)(ZO,{className:`text-[13px]`,children:[(0,G.jsx)(QO,{children:(0,G.jsx)(ek,{children:bM.map(e=>(0,G.jsx)(tk,{children:e.replace(/-/g,` `)},e))})}),(0,G.jsx)($O,{children:c.map((e,t)=>(0,G.jsx)(ek,{children:bM.map(t=>(0,G.jsx)(nk,{title:e[t]??``,children:e[t]??``},t))},e[`.id`]||t))})]}):(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading…`})]})}function xM({device:e,getPath:t,setPath:n,fields:r,title:i,unwrap:a,extra:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)({}),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(!1),_=(0,v.useCallback)(async()=>{let{available:n,row:r}=a(await U(`${t}${e?`?device=${encodeURIComponent(e)}`:``}`).catch(()=>null));u(n),c(r),f({})},[e,t,a]);(0,v.useEffect)(()=>{_()},[_]);let y=async()=>{g(!0),m(null);try{let t=await _c(n,{device:e,fields:d});m(t.message),t.ok?(await _(),Y.success(`Settings saved`)):Y.error(t.message||`Save failed`)}catch(e){Y.error(e instanceof Error?e.message:`Save failed`)}finally{g(!1)}};return l?(0,G.jsxs)(`div`,{className:pM,children:[(0,G.jsx)(`div`,{className:mM,children:i}),s&&(0,G.jsx)(`div`,{className:`mb-3 text-muted-foreground text-xs`,children:r.map(e=>`${e.label}: ${s[e.key]??`—`}`).join(` · `)}),(0,G.jsx)(`div`,{className:hM,children:r.map(e=>(0,G.jsxs)(`label`,{className:_M,children:[(0,G.jsx)(`span`,{className:vM,children:e.label}),e.type===`bool`?(0,G.jsx)(nM,{value:d[e.key]??``,onValueChange:t=>f({...d,[e.key]:t}),options:[{value:``,label:`(unchanged)`},{value:`no`,label:`no`},{value:`yes`,label:`yes`}]}):(0,G.jsx)($j,{type:e.type===`number`?`number`:`text`,placeholder:e.placeholder??s?.[e.key]??``,value:d[e.key]??``,onChange:t=>f({...d,[e.key]:t.target.value})})]},e.key))}),(0,G.jsxs)(`div`,{className:gM,children:[(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:h,onClick:()=>void y(),children:`Save`}),o,p&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:p})]})]}):(0,G.jsxs)(Yj,{type:`warning`,label:`Not available`,children:[i,` is not available on this device.`]})}var Jre={slug:`radius`,idKey:`.id`,toggle:!0,columns:[{key:`address`,label:`Address`},{key:`service`,label:`Service`},{key:`authentication-port`,label:`Auth`},{key:`accounting-port`,label:`Acct`},{key:`protocol`,label:`Proto`},{key:`_status`,label:`Status`}],empty:`No RADIUS servers configured.`,fields:[{key:`address`,label:`Address`,required:!0,placeholder:`1.2.3.4 or host`},{key:`secret`,label:`Secret`,type:`password`,required:!0},{key:`service`,label:`Service`,required:!0,placeholder:`login,ppp,hotspot,wireless,dhcp,ipsec,dot1x`},{key:`authentication-port`,label:`Auth port`,type:`number`,placeholder:`1812`},{key:`accounting-port`,label:`Acct port`,type:`number`,placeholder:`1813`},{key:`timeout`,label:`Timeout`,placeholder:`300ms`},{key:`src-address`,label:`Src address`},{key:`realm`,label:`Realm`},{key:`called-id`,label:`Called ID`},{key:`domain`,label:`Domain`},{key:`protocol`,label:`Protocol`,type:`select`,options:[`udp`,`radsec`]},{key:`certificate`,label:`Certificate`},{key:`accounting-backup`,label:`Acct backup`,type:`bool`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},Yre={slug:`um-users`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared`},{key:`caller-id`,label:`Caller ID`},{key:`comment`,label:`Comment`},{key:`_status`,label:`Status`}],empty:`No RADIUS users.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`password`,label:`Password`,type:`password`,required:!0},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared users`,type:`number`,placeholder:`1`},{key:`attributes`,label:`RADIUS attributes`},{key:`caller-id`,label:`Caller ID (MAC)`},{key:`otp-secret`,label:`OTP secret`,type:`password`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},Xre={slug:`um-profiles`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`name-for-users`,label:`Display`},{key:`validity`,label:`Validity`},{key:`price`,label:`Price`},{key:`starts-when`,label:`Starts`}],empty:`No service profiles.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`name-for-users`,label:`Display name`},{key:`validity`,label:`Validity`,placeholder:`30d`},{key:`price`,label:`Price`,type:`number`},{key:`starts-when`,label:`Starts when`,type:`select`,options:[`assigned`,`first-auth`]},{key:`override-shared-users`,label:`Override shared-users`},{key:`comment`,label:`Comment`}]},Zre={slug:`um-limitations`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`rate-limit-rx`,label:`Rate ↓`},{key:`rate-limit-tx`,label:`Rate ↑`},{key:`transfer-limit`,label:`Transfer`},{key:`uptime-limit`,label:`Uptime`}],empty:`No limitation templates.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`rate-limit-rx`,label:`Download rate`,placeholder:`10M`},{key:`rate-limit-tx`,label:`Upload rate`,placeholder:`10M`},{key:`rate-limit-min-rx`,label:`Min download (CIR)`,placeholder:`2M`},{key:`rate-limit-min-tx`,label:`Min upload (CIR)`,placeholder:`2M`},{key:`rate-limit-burst-rx`,label:`Burst download`,placeholder:`20M`},{key:`rate-limit-burst-tx`,label:`Burst upload`,placeholder:`20M`},{key:`rate-limit-burst-threshold-rx`,label:`Burst thr. ↓`},{key:`rate-limit-burst-threshold-tx`,label:`Burst thr. ↑`},{key:`rate-limit-burst-time-rx`,label:`Burst time ↓`,placeholder:`10s`},{key:`rate-limit-burst-time-tx`,label:`Burst time ↑`,placeholder:`10s`},{key:`rate-limit-priority`,label:`Priority (1-8)`,type:`number`},{key:`download-limit`,label:`Download cap`,placeholder:`5G`},{key:`upload-limit`,label:`Upload cap`,placeholder:`5G`},{key:`transfer-limit`,label:`Total transfer cap`,placeholder:`10G`},{key:`uptime-limit`,label:`Uptime cap`,placeholder:`1d`},{key:`reset-counters-interval`,label:`Reset interval`},{key:`reset-counters-start-time`,label:`Reset start time`},{key:`comment`,label:`Comment`}]},Qre={slug:`um-routers`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`address`,label:`Address`},{key:`coa-port`,label:`CoA port`},{key:`protocol`,label:`Proto`},{key:`comment`,label:`Comment`},{key:`_status`,label:`Status`}],empty:`No NAS clients registered.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`address`,label:`Address`,required:!0,placeholder:`192.168.88.1`},{key:`shared-secret`,label:`Shared secret`,type:`password`,required:!0},{key:`coa-port`,label:`CoA port`,type:`number`},{key:`protocol`,label:`Protocol`,placeholder:`radius`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},$re={slug:`um-user-profiles`,idKey:`.id`,addOnly:!0,columns:[{key:`user`,label:`User`},{key:`profile`,label:`Profile`},{key:`state`,label:`State`},{key:`end-time`,label:`Ends`}],empty:`No profile assignments.`,fields:[{key:`user`,label:`User`,required:!0},{key:`profile`,label:`Profile`,required:!0}]},eie=[{id:`radius`,label:`RADIUS Servers`},{id:`users`,label:`Users`},{id:`profiles`,label:`Profiles`},{id:`limitations`,label:`Limitations`},{id:`nas`,label:`NAS Clients`},{id:`assignments`,label:`Assignments`},{id:`sessions`,label:`Sessions`},{id:`usage`,label:`Usage & Heatmap`},{id:`settings`,label:`Settings`}],tie=[{key:`accept`,label:`Accept CoA`,type:`bool`},{key:`port`,label:`CoA port`,type:`number`,placeholder:`3799`}],nie=[{key:`enabled`,label:`Enabled`,type:`bool`},{key:`use-profiles`,label:`Use profiles`,type:`bool`},{key:`certificate`,label:`Certificate`},{key:`authentication-port`,label:`Auth port`,type:`number`},{key:`accounting-port`,label:`Acct port`,type:`number`}];function rie({device:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``);(0,v.useEffect)(()=>{U(`/api/usage/um-users${e?`?device=${encodeURIComponent(e)}`:``}`).then(e=>{n(e.users),i(t=>t||e.users[0]||``)}).catch(()=>n([]))},[e]);let a=e?`&device=${encodeURIComponent(e)}`:``;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`User`}),(0,G.jsx)(nM,{value:r,onValueChange:i,"aria-label":`User`,options:t&&t.length>0?t.map(e=>({value:e,label:e})):[{value:``,label:`— no sessions recorded yet —`}]})]}),t&&t.length===0?(0,G.jsx)(Yj,{type:`secondary`,label:`No data yet`,children:`No User Manager sessions have been recorded yet. The dashboard ingests sessions on a configurable interval (1 minute by default — change it under the Settings tab) and keeps them forever, so usage and the heatmap fill in over time.`}):r&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:`Download / upload · last 3 months`}),(0,G.jsx)(cM,{endpoint:`/api/usage/um-user?user=${encodeURIComponent(r)}${a}&days=90`,days:90})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:[`Connection heatmap · `,r]}),(0,G.jsx)(dM,{endpoint:`/api/usage/heatmap?user=${encodeURIComponent(r)}${a}&days=371`,label:`${r} — connections`})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:`All users · connections`}),(0,G.jsx)(dM,{endpoint:`/api/usage/heatmap?days=371${a}`,label:`All users`})]})]})]})}function iie(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(async()=>{try{let e=await U(`/api/usage/sampler`);r(e.intervalMs)}catch{r(null)}},[]);(0,v.useEffect)(()=>{c()},[c]);let l=async()=>{let n=Number(e);if(!Number.isFinite(n)||n<=0){s(`Enter a positive number of minutes.`),Y.error(`Enter a positive number of minutes`);return}a(!0),s(null);try{let e=await _c(`/api/usage/sampler`,{intervalMs:Math.round(n*6e4)});r(e.intervalMs),t(``),s(`Now sampling every ${SM(e.intervalMs)}.`),Y.success(`Now sampling every ${SM(e.intervalMs)}`)}catch(e){s(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Save failed`)}finally{a(!1)}};return(0,G.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3.5`,children:[(0,G.jsx)(`div`,{className:mM,children:`Usage sampling`}),(0,G.jsxs)(`div`,{className:`mb-3 text-muted-foreground text-xs`,children:[`How often client traffic + User Manager sessions are recorded into the usage history. Current: `,n==null?`…`:SM(n),` · default 1 minute · range 30s–6h.`]}),(0,G.jsx)(`div`,{className:hM,children:(0,G.jsxs)(`label`,{className:_M,children:[(0,G.jsx)(`span`,{className:vM,children:`Interval (minutes)`}),(0,G.jsx)($j,{type:`number`,step:`0.5`,min:`0.5`,placeholder:n?String(n/6e4):`1`,value:e,onChange:e=>t(e.target.value)})]})}),(0,G.jsxs)(`div`,{className:gM,children:[(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:i,onClick:()=>void l(),children:`Save`}),[1,5,10,30].map(e=>(0,G.jsxs)(Z,{size:`sm`,ghost:!0,onClick:()=>{t(String(e))},children:[e,`m`]},e)),o&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:o})]})]})}function SM(e){if(e<6e4)return`${Math.round(e/1e3)}s`;let t=e/6e4;return`${Number.isInteger(t)?t:t.toFixed(1)} min`}function aie(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(`radius`);(0,v.useEffect)(()=>{U(`/api/devices`).then(e=>{t(e),r(t=>t||e.defaultDevice||e.devices[0]?.name||``)}).catch(()=>t({server:``,defaultDevice:``,devices:[]}))},[]);let o=e?.devices??[];return(0,G.jsx)(`section`,{className:`grid content-start gap-[18px]`,children:(0,G.jsx)(X,{title:`RADIUS & User Manager`,className:`reveal`,extra:o.length>1?(0,G.jsx)(nM,{value:n,onValueChange:r,"aria-label":`Router`,options:o.map(e=>({value:e.name,label:`${e.name}${e.isDefault?` (default)`:``}`}))}):void 0,children:(0,G.jsxs)(AA,{value:i,onValueChange:e=>a(e),children:[(0,G.jsx)(jA,{className:`mb-3.5 h-auto w-full flex-wrap justify-start border-b border-border`,children:eie.map(e=>(0,G.jsx)(MA,{value:e.id,children:e.label},e.id))}),(0,G.jsx)(NA,{value:`radius`,children:(0,G.jsx)(yM,{config:Jre,device:n})}),(0,G.jsx)(NA,{value:`users`,children:(0,G.jsx)(yM,{config:Yre,device:n})}),(0,G.jsx)(NA,{value:`profiles`,children:(0,G.jsx)(yM,{config:Xre,device:n})}),(0,G.jsx)(NA,{value:`limitations`,children:(0,G.jsx)(yM,{config:Zre,device:n})}),(0,G.jsx)(NA,{value:`nas`,children:(0,G.jsx)(yM,{config:Qre,device:n})}),(0,G.jsx)(NA,{value:`assignments`,children:(0,G.jsx)(yM,{config:$re,device:n})}),(0,G.jsx)(NA,{value:`sessions`,children:(0,G.jsx)(qre,{device:n})}),(0,G.jsx)(NA,{value:`usage`,children:(0,G.jsx)(rie,{device:n})}),(0,G.jsx)(NA,{value:`settings`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(xM,{device:n,getPath:`/api/aaa/radius-incoming`,setPath:`/api/aaa/radius-incoming`,title:`RADIUS Incoming (CoA listener)`,fields:tie,unwrap:e=>({available:!0,row:e??{}}),extra:(0,G.jsx)(Z,{size:`sm`,ghost:!0,onClick:()=>void _c(`/api/aaa/radius-reset-counters`,{device:n}).then(()=>Y.success(`Counters reset`)).catch(()=>Y.error(`Reset counters failed`)),children:`Reset RADIUS counters`})}),(0,G.jsx)(xM,{device:n,getPath:`/api/aaa/um-settings`,setPath:`/api/aaa/um-settings`,title:`User Manager (built-in RADIUS server)`,fields:nie,unwrap:e=>{let t=e??{};return{available:t.available!==!1,row:t.settings??{}}}}),(0,G.jsx)(iie,{})]})})]})})})}var CM=new Set;function wM(e){return CM.add(e),()=>CM.delete(e)}function oie(e){for(let t of CM)t(e)}var TM=new Set;function EM(e){return TM.add(e),()=>TM.delete(e)}function DM(e){for(let t of TM)t(e)}function OM(e,t){let n=(0,v.useRef)(e),r=(0,v.useRef)(t);n.current=e,r.current=t,(0,v.useEffect)(()=>{let e=!1,t=null,i=null,a=()=>{t&&=(t.onopen=t.onerror=t.onmessage=t.onclose=null,t.close(),null),i&&=(i.close(),null)},o=()=>{e||(i=new EventSource(gc(`/api/sse`)),i.addEventListener(`hello`,()=>r.current(`sse`)),i.addEventListener(`tool`,e=>{try{n.current(JSON.parse(e.data))}catch{}}),i.onerror=()=>{i&&i.readyState===EventSource.CONNECTING&&r.current(`off`)})},s=()=>{if(e)return;let i=location.protocol===`https:`?`wss`:`ws`;t=new WebSocket(gc(`${i}://${location.host}/api/stream`));let a=!1;t.onopen=()=>{a=!0,r.current(`ws`)},t.onerror=()=>t?.close(),t.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`event`&&t.event&&n.current(t.event),t.type===`txn`&&t.update&&oie(t.update),t.type===`rollout`&&t.update&&DM(t.update)}catch{}},t.onclose=()=>{e||(r.current(`off`),a?setTimeout(s,2e3):o())}},c=()=>t?.readyState===WebSocket.OPEN||i?.readyState===EventSource.OPEN,l=()=>{e||c()||(a(),s())},u=()=>{document.visibilityState===`visible`&&l()};return s(),document.addEventListener(`visibilitychange`,u),window.addEventListener(`online`,l),()=>{e=!0,document.removeEventListener(`visibilitychange`,u),window.removeEventListener(`online`,l),a()}},[])}function kM(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;document.documentElement.classList.add(`js-motion`);let n=new WeakSet,r=e=>{n.has(e)||(n.add(e),zi.set(e,{opacity:0,y:26}),ac.create({trigger:e,start:`top 90%`,once:!0,onEnter:()=>zi.to(e,{opacity:1,y:0,duration:.7,ease:`power3.out`})}))},i=e=>{for(let t of e.querySelectorAll(`.reveal`))r(t)};i(t);let a=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof Element&&(e.matches(`.reveal`)&&r(e),i(e))});a.observe(t,{childList:!0,subtree:!0});let o=setInterval(()=>ac.refresh(),1200),s=setTimeout(()=>clearInterval(o),7e3);return()=>{a.disconnect(),clearInterval(o),clearTimeout(s);for(let e of ac.getAll())e.kill();document.documentElement.classList.remove(`js-motion`)}},[e])}var AM={completed:`success`,"completed-with-failures":`warning`,halted:`warning`,reverted:`secondary`,"needs-attention":`error`,aborted:`secondary`},jM={completed:`Every device applied the change.`,"completed-with-failures":`The rollout finished, but a gate failed along the way.`,halted:`Stopped at a failed gate. The devices already changed are still changed.`,reverted:`Stopped and put back — the fleet is where it started.`,"needs-attention":`A revert itself failed. Restore the flagged device(s) by hand from the snapshot named below.`,aborted:`A human stopped it; whatever had been applied was reverted.`},MM={pending:`bg-muted/30 text-muted-foreground`,applied:`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400`,failed:`bg-red-500/15 text-red-600 dark:text-red-400`,reverted:`bg-amber-500/15 text-amber-600 dark:text-amber-400`,"revert-failed":`bg-red-500/25 text-red-600 dark:text-red-400 font-semibold`,skipped:`bg-muted/20 text-muted-foreground line-through`};function NM(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function PM({rollout:e}){let t=t=>e.gates.find(e=>e.wave===t);return(0,G.jsx)(`div`,{className:`space-y-3`,children:e.waves.map(n=>{let r=t(n.index),i=n.devices.map(t=>e.devices.find(e=>e.device===t)).filter(e=>e!==void 0),a=e.outcome===void 0&&i.some(e=>e.stage===`pending`);return(0,G.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[`Wave `,n.index+1,n.isCanary&&(0,G.jsx)(`span`,{className:`ml-2 rounded-sm bg-amber-500/15 px-1.5 py-0.5 text-xs text-amber-600 dark:text-amber-400`,children:`canary`})]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.length,` device(s)`]}),a&&(0,G.jsx)(Zj,{type:`warning`,pulse:!0}),r&&(0,G.jsxs)(Xj,{type:r.ok?`success`:`error`,className:`ml-auto`,children:[`gate `,r.ok?`pass`:`fail`]})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i.map(e=>(0,G.jsx)(`span`,{title:e.error??e.stage,className:K(`rounded-md px-2 py-1 font-mono text-xs`,MM[e.stage]??MM.pending),children:e.device},e.device))}),r&&!r.ok&&(0,G.jsxs)(`ul`,{className:`mt-2 space-y-1 text-xs text-red-600 dark:text-red-400`,children:[r.collateral&&(0,G.jsx)(`li`,{className:`font-medium`,children:`An UNTOUCHED device went dark — the change affected the wider fleet.`}),r.failures.map(e=>(0,G.jsxs)(`li`,{children:[e.device,`: `,e.reason]},e.device))]})]},n.index)})})}function FM({id:e,onClose:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)([]),[o,s]=(0,v.useState)(!1),c=(0,v.useCallback)(async()=>{try{let t=await U(`/api/rollout/${encodeURIComponent(e)}`);r(t.rollout),a(t.events)}catch(e){Y.error(`Failed to load rollout: ${e instanceof Error?e.message:String(e)}`)}},[e]);(0,v.useEffect)(()=>(c(),EM(t=>{t.rolloutId===e&&c()})),[e,c]);let l=async t=>{s(!0);try{let n=await _c(`/api/rollout/${encodeURIComponent(e)}/${t}`,{});n.error?Y.error(n.error):Y.success(n.outcome??(t===`hold`?`Held`:`Done`)),await c()}finally{s(!1)}};if(!n)return(0,G.jsx)(X,{title:`Rollout`,children:`Loading…`});let u=n.outcome===void 0,d=n.devices.filter(e=>e.stage===`failed`||e.stage===`revert-failed`);return(0,G.jsxs)(X,{title:n.label?`${n.label} — ${n.id}`:n.id,extra:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{size:`sm`,type:`secondary`,disabled:o,onClick:()=>void l(`hold`),children:`Hold`}),(0,G.jsx)(Z,{size:`sm`,type:`secondary`,disabled:o,onClick:()=>void l(`resume`),children:`Resume`}),(0,G.jsx)(Z,{size:`sm`,type:`error`,disabled:o,onClick:()=>void l(`abort`),children:`Abort`})]}),(0,G.jsx)(Z,{size:`sm`,type:`secondary`,onClick:t,children:`Close`})]}),children:[(0,G.jsxs)(`div`,{className:K(`mb-4 rounded-md border p-3 text-sm`,n.outcome===`needs-attention`&&`border-red-500/40 bg-red-500/10`,n.outcome===`completed`&&`border-emerald-500/40 bg-emerald-500/10`,u&&`border-amber-500/40 bg-amber-500/10`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,G.jsx)(Zj,{type:n.outcome?AM[n.outcome]:`warning`,pulse:u}),n.outcome??`IN FLIGHT — wave ${n.phase}`]}),(0,G.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n.outcome?jM[n.outcome]:`Applying wave by wave; each wave is gated and soaked before the next.`})]}),(0,G.jsx)(PM,{rollout:n}),d.length>0&&(0,G.jsxs)(`div`,{className:`mt-4 rounded-md border border-red-500/40 p-3 text-sm`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`Failures`}),(0,G.jsx)(`ul`,{className:`mt-1 space-y-1 font-mono text-xs text-muted-foreground`,children:d.map(e=>(0,G.jsxs)(`li`,{children:[e.device,` · `,e.stage,e.error?` — ${e.error}`:``,e.stage===`revert-failed`&&e.snapshotId?` · restore with diff_config_snapshots ${e.snapshotId} live`:``]},e.device))})]}),n.notes.length>0&&(0,G.jsx)(`ul`,{className:`mt-4 space-y-1 text-sm text-amber-600 dark:text-amber-400`,children:n.notes.map(e=>(0,G.jsxs)(`li`,{children:[`• `,e]},e))}),(0,G.jsx)(`h4`,{className:`mt-6 mb-2 text-sm font-medium`,children:`Commands`}),(0,G.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-muted/30 p-2 font-mono text-xs`,children:n.commands.join(`
177
+ `,HO={"top-left":`inset(0 100% 100% 0)`,"top-right":`inset(0 0 100% 100%)`,"bottom-left":`inset(100% 100% 0 0)`,"bottom-right":`inset(100% 0 0 100%)`,center:`inset(50% 50% 50% 50%)`,"bottom-up":`inset(100% 0 0 0)`},UO={"top-left":`0% 0%`,"top-right":`100% 0%`,"bottom-left":`0% 100%`,"bottom-right":`100% 100%`,center:`50% 50%`,"bottom-up":`50% 100%`};function WO({variant:e=`rectangle`,start:t=`bottom-up`}={}){let[n,r]=JO(),i=RD()??!1,[a,o]=(0,v.useState)(!1);(0,v.useEffect)(()=>o(!0),[]),(0,v.useEffect)(()=>{if(document.getElementById(BO))return;let e=document.createElement(`style`);e.id=BO,e.textContent=VO,document.head.appendChild(e)},[]);let s=a&&n===`dark`;return{isDark:s,mounted:a,toggle:()=>{let n=s?`light`:`dark`;if(i||!(`startViewTransition`in document)){r(n);return}let a=document.documentElement;e===`rectangle`?(a.style.setProperty(`--beui-vt-from`,HO[t]),a.dataset.beuiVt=`rect`):e===`blinds`?a.dataset.beuiVt=`blinds`:(a.style.setProperty(`--beui-vt-origin`,UO[t]),a.dataset.beuiVt=e),document.startViewTransition(()=>r(n)).finished.finally(()=>{delete a.dataset.beuiVt})}}}function GO({variant:e=`rectangle`,start:t=`bottom-up`,className:n,iconClassName:r,...i}){let{isDark:a,mounted:o,toggle:s}=WO({variant:e,start:t});return(0,G.jsx)(`button`,{type:`button`,"aria-label":o&&a?`Switch to light mode`:`Switch to dark mode`,onClick:s,className:J(`flex items-center justify-center`,n),...i,children:o?(0,G.jsx)(zO,{value:a?`dark`:`light`,animation:`blur`,className:r,children:a?(0,G.jsx)(Hd,{className:r}):(0,G.jsx)(Iu,{className:r})}):(0,G.jsx)(`span`,{className:r,"aria-hidden":`true`})})}var KO=`mt-theme`;function qO(){try{return localStorage.getItem(KO)===`light`?`light`:`dark`}catch{return`dark`}}function JO(){let[e,t]=(0,v.useState)(qO);return(0,v.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e===`dark`)},[e]),[e,(0,v.useCallback)(e=>{t(e);try{localStorage.setItem(KO,e)}catch{}},[])]}function YO(){return(0,G.jsx)(GO,{variant:`circle`,className:`size-9 rounded-md hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,iconClassName:`size-4`})}function XO(e){let[t]=JO();return(0,G.jsx)(MO,{theme:t,className:`toaster group`,position:`bottom-right`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground`,error:`group-[.toast]:text-destructive`,success:`group-[.toast]:text-foreground`}},...e})}function ZO({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,G.jsx)(`table`,{"data-slot":`table`,className:K(`w-full caption-bottom text-sm`,e),...t})})}function QO({className:e,...t}){return(0,G.jsx)(`thead`,{"data-slot":`table-header`,className:K(`[&_tr]:border-b`,e),...t})}function $O({className:e,...t}){return(0,G.jsx)(`tbody`,{"data-slot":`table-body`,className:K(`[&_tr:last-child]:border-0`,e),...t})}function ek({className:e,...t}){return(0,G.jsx)(`tr`,{"data-slot":`table-row`,className:K(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function tk({className:e,...t}){return(0,G.jsx)(`th`,{"data-slot":`table-head`,className:K(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function nk({className:e,...t}){return(0,G.jsx)(`td`,{"data-slot":`table-cell`,className:K(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function rk({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card`,className:K(`flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm`,e),...t})}function pre({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-header`,className:K(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function mre({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-title`,className:K(`leading-none font-semibold`,e),...t})}function hre({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`card-content`,className:K(`px-6`,e),...t})}function X({title:e,extra:t,children:n,className:r}){return(0,G.jsxs)(rk,{className:K(`dashboard-panel gap-0 py-5`,r),children:[e!=null&&(0,G.jsxs)(pre,{className:`flex flex-row flex-wrap items-center gap-3 px-5 pb-3`,children:[(0,G.jsx)(mre,{className:`text-base font-semibold`,children:e}),t!=null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`flex-1`}),t]})]}),(0,G.jsx)(hre,{className:`px-5`,children:n})]})}function ik({k:e,v:t,sub:n,cls:r}){return(0,G.jsxs)(rk,{className:`dashboard-stat gap-2 px-4 py-4`,children:[(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs tracking-wide uppercase`,children:e}),(0,G.jsxs)(`div`,{className:K(`text-2xl font-semibold tabular-nums`,r),children:[t,n!=null&&(0,G.jsxs)(`small`,{className:`text-muted-foreground ml-1 text-sm`,children:[` `,n]})]})]})}function ak({rows:e}){let t=Math.max(1,...e.map(e=>e.value));return(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_1fr_auto] items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,title:e.label,children:e.label}),(0,G.jsx)(`div`,{className:`bg-muted h-2 overflow-hidden rounded-full`,children:(0,G.jsx)(`div`,{className:K(`h-full rounded-full`,!e.color&&`bg-brand`),style:{width:`${e.value/t*100}%`,background:e.color}})}),(0,G.jsx)(`span`,{className:`text-xs tabular-nums`,children:e.sub??String(e.value)})]},e.label))})}function ok({text:e,label:t=`Copy`,className:n,icon:r=!1,title:i}){let[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>void(s.current&&clearTimeout(s.current)),[]),(0,G.jsxs)(nO,{type:`button`,variant:`outline`,size:r?`icon-sm`:`sm`,className:n,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{o(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>o(!1),1400)},()=>{})},title:i??`Copy to clipboard`,"aria-label":i??`Copy to clipboard`,children:[a?(0,G.jsx)(cl,{className:`text-success`}):r?(0,G.jsx)(Pl,{}):t,a&&(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`Copied!`})]})}var gre=[50,100,200,500,1e3,2e3],_re={initial:{opacity:0,filter:`blur(6px)`},animate:{opacity:1,filter:`blur(0px)`},exit:e=>e?{}:{opacity:0,filter:`blur(6px)`}},vre={initial:{opacity:0},animate:{opacity:1},exit:e=>e?{}:{opacity:0}},yre=(0,v.forwardRef)(({children:e,as:t=`div`,className:n,onMouseLeave:r,pillClassName:i,pillContainerClassName:a,inset:o=20,...s},c)=>{let[l,u]=(0,v.useState)(null),d=(0,v.useId)(),f=RD(),p=v.Children.toArray(e).filter(v.isValidElement).map((e,t)=>{let n=e,r=n.key?String(n.key):`item-${t}`;return(0,v.cloneElement)(n,{key:r,className:J(`relative`,n.props.className),onMouseEnter:()=>{n.props.onMouseEnter?.(),u(r)}},(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(BE,{custom:l!==null,children:l===null?null:(0,G.jsx)(q.div,{variants:f?vre:_re,initial:`initial`,animate:`animate`,exit:`exit`,custom:l!==null,className:J(`pointer-events-none absolute inset-y-0`,a),style:{left:-o,right:-o},children:l===r?(0,G.jsx)(q.div,{layoutId:`shared-bg-${d}`,transition:f?{duration:0}:ZD,className:J(`pointer-events-none h-full w-full rounded-2xl bg-primary/[0.06]`,i)}):null})}),(0,G.jsx)(`div`,{className:`relative z-10`,children:n.props.children})]}))}),m=e=>{u(null),r?.(e)};return t===`ul`?(0,G.jsx)(q.ul,{...s,ref:c,layoutRoot:!0,onMouseLeave:m,className:J(`flex w-full flex-col`,n),children:p}):(0,G.jsx)(q.div,{...s,ref:c,layoutRoot:!0,onMouseLeave:m,className:J(`flex w-full flex-col`,n),children:p})}),sk=`(max-width: 899px)`,bre=`b`,ck={duration:.36,ease:Kne},xre={type:`spring`,stiffness:380,damping:35,mass:.75},Sre={duration:.2,delay:.08,ease:qD},Cre={duration:.12,ease:qD},lk={duration:.18,ease:qD},uk={closed:{opacity:0,clipPath:`inset(0 0 100% 0 round 8px)`,transition:{duration:.14,ease:qD,staggerChildren:.025,staggerDirection:-1}},open:{opacity:1,clipPath:`inset(0 0 0% 0 round 8px)`,transition:{duration:.2,delayChildren:.035,ease:qD,staggerChildren:.045}}},dk={closed:{opacity:0,y:-6,filter:`blur(3px)`},open:{opacity:1,y:0,filter:`blur(0px)`,transition:lk}},fk={duration:.16,ease:qD},pk=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex='-1'])`].join(`,`);function mk(e){let t=window.matchMedia(sk);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function hk(){return window.matchMedia(sk).matches}function gk(){return!1}function _k(){return(0,v.useSyncExternalStore)(mk,hk,gk)}var vk=(0,v.createContext)(null),yk=(0,v.createContext)(null);function bk(){let e=(0,v.useContext)(vk);if(!e)throw Error(`useAnimatedSidebar must be used inside AnimatedSidebarProvider.`);return e}function xk(){let e=(0,v.useContext)(yk);if(!e)throw Error(`Animated Sidebar parts must be used inside AnimatedSidebar.`);return e}function Sk({children:e,open:t,defaultOpen:n=!0,onOpenChange:r,openMobile:i,defaultOpenMobile:a=!1,onOpenMobileChange:o,className:s,style:c,...l}){let[u,d]=(0,v.useState)(n),[f,p]=(0,v.useState)(a),m=_k(),h=RD()??!1,g=(0,v.useId)(),_=(0,v.useRef)(null),y=t??u,b=i??f,x=(0,v.useCallback)(e=>{t===void 0&&d(e),r?.(e)},[r,t]),S=(0,v.useCallback)(e=>{i===void 0&&p(e),o?.(e)},[o,i]),C=(0,v.useCallback)(()=>{m?S(!b):x(!y)},[y,m,b,x,S]);return(0,v.useEffect)(()=>{let e=e=>{e.key.toLowerCase()===bre&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]),(0,G.jsx)(vk.Provider,{value:{isMobile:m,layoutId:`${g}-active`,open:y,openMobile:b,reduce:h,setOpen:x,setOpenMobile:S,state:y?`expanded`:`collapsed`,toggleSidebar:C,triggerRef:_},children:(0,G.jsx)(`div`,{...l,"data-slot":`sidebar-wrapper`,"data-state":y?`expanded`:`collapsed`,style:{"--sidebar-width":`16rem`,"--sidebar-width-icon":`4.25rem`,"--sidebar-width-mobile":`18rem`,...c},className:J(`group/sidebar-wrapper flex min-h-svh w-full min-w-0`,s),children:e})})}function Ck({ariaLabel:e,children:t,className:n,side:r}){let i=bk(),a=(0,v.useRef)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!i.openMobile),u=(0,v.useRef)(i.openMobile),d=(0,v.useCallback)(()=>{let e=a.current;e&&!e.contains(document.activeElement)&&([...e.querySelectorAll(pk)].find(e=>e.getClientRects().length>0&&!e.closest(`[inert], [hidden]`))??e).focus({preventScroll:!0})},[]);return(0,v.useEffect)(()=>s(!0),[]),(0,v.useEffect)(()=>{u.current=i.openMobile,i.openMobile&&l(!1)},[i.openMobile]),(0,v.useEffect)(()=>{if(!i.openMobile)return;let e=document.body,t=window.scrollY,n={left:e.style.left,overflow:e.style.overflow,position:e.style.position,right:e.style.right,top:e.style.top};e.style.position=`fixed`,e.style.top=`-${t}px`,e.style.left=`0`,e.style.right=`0`,e.style.overflow=`hidden`;let r=requestAnimationFrame(d);return()=>{cancelAnimationFrame(r),e.style.position=n.position,e.style.top=n.top,e.style.left=n.left,e.style.right=n.right,e.style.overflow=n.overflow,window.scrollTo(0,t),i.triggerRef.current?.focus({preventScroll:!0})}},[i.openMobile,i.triggerRef,d]),o?(0,Ff.createPortal)((0,G.jsxs)(`div`,{className:J(`pointer-events-none fixed left-0 top-0 z-[45] size-0 min-[900px]:hidden`,c&&!i.openMobile?`invisible`:`visible`),children:[(0,G.jsx)(q.button,{type:`button`,"aria-label":`Close sidebar`,tabIndex:i.openMobile?0:-1,initial:!1,animate:{opacity:+!!i.openMobile},transition:i.reduce?fk:ck,onClick:()=>i.setOpenMobile(!1),className:J(`fixed inset-0 bg-black/40`,i.openMobile?`pointer-events-auto`:`pointer-events-none`)}),(0,G.jsx)(q.div,{ref:a,role:`dialog`,"aria-modal":`true`,"aria-label":e,"aria-hidden":!i.openMobile,inert:!i.openMobile,tabIndex:-1,"data-mobile":`true`,"data-state":i.openMobile?`expanded`:`collapsed`,"data-side":r,initial:!1,animate:{opacity:i.reduce?+!!i.openMobile:1,x:i.reduce?0:i.openMobile?`0%`:r===`left`?`-100%`:`100%`},transition:i.reduce?fk:ck,onAnimationComplete:()=>{u.current?d():l(!0)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),i.setOpenMobile(!1);return}if(e.key!==`Tab`)return;let t=a.current?Array.from(a.current.querySelectorAll(pk)).filter(e=>e.getClientRects().length>0&&!e.closest(`[inert], [hidden]`)):[];if(t.length===0){e.preventDefault(),a.current?.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())},className:J(`pointer-events-auto fixed inset-y-0 flex h-dvh w-(--sidebar-width-mobile) max-w-[88vw] flex-col overflow-hidden`,`border-border bg-background shadow-2xl will-change-transform`,r===`left`?`left-0 border-r`:`right-0 border-l`,!i.openMobile&&`pointer-events-none`,n),children:(0,G.jsx)(yk.Provider,{value:{collapsed:!1,collapsible:`none`,side:r},children:t})})]}),document.body):null}var wk=(0,v.forwardRef)(({side:e=`left`,variant:t=`sidebar`,collapsible:n=`icon`,ariaLabel:r=`Sidebar`,children:i,className:a,panelClassName:o,style:s,...c},l)=>{let u=bk(),d=n!==`none`&&!u.open,f=d&&n===`offcanvas`,p=f?`0px`:d?`var(--sidebar-width-icon)`:`var(--sidebar-width)`;return u.isMobile?(0,G.jsx)(Ck,{ariaLabel:r,className:a,side:e,children:i}):(0,G.jsx)(q.aside,{...c,ref:l,initial:!1,"aria-label":r,"data-slot":`sidebar`,"data-state":d?`collapsed`:`expanded`,"data-collapsible":n,"data-variant":t,"data-side":e,animate:{width:p},transition:u.reduce?{duration:0}:xre,style:s,className:J(`group/sidebar relative hidden h-auto shrink-0 min-[900px]:block will-change-[width]`,`peer`,e===`right`&&`order-last`,a),children:(0,G.jsx)(q.div,{initial:!1,animate:{opacity:+!f,x:f?e===`left`?`-100%`:`100%`:`0%`},transition:u.reduce?fk:ck,className:J(`sticky top-0 flex h-svh w-full flex-col overflow-hidden bg-background`,n===`offcanvas`&&`w-[var(--sidebar-width)]`,t===`sidebar`&&(e===`left`?`border-border border-r`:`border-border border-l`),t===`floating`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl border border-border shadow-sm`,t===`inset`&&`m-2 h-[calc(100svh-1rem)] rounded-2xl`,o),children:(0,G.jsx)(yk.Provider,{value:{collapsed:d,collapsible:n,side:e},children:i})})})}),Tk=(0,v.forwardRef)(({className:e,onClick:t,type:n=`button`,...r},i)=>{let a=bk(),o=a.isMobile?a.openMobile:a.open;return(0,G.jsx)(`button`,{...r,ref:e=>{a.triggerRef.current=e,typeof i==`function`?i(e):i&&(i.current=e)},type:n,"aria-label":r[`aria-label`]??`Toggle sidebar`,"aria-expanded":o,"data-slot":`sidebar-trigger`,"data-state":o?`expanded`:`collapsed`,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:J(`inline-flex size-10 shrink-0 items-center justify-center rounded-xl outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,e)})});(0,v.forwardRef)(({className:e,onClick:t,type:n=`button`,...r},i)=>{let a=bk();return(0,G.jsx)(`button`,{...r,ref:i,type:n,"aria-label":r[`aria-label`]??`Close sidebar`,onClick:e=>{t?.(e),!e.defaultPrevented&&(a.isMobile?a.setOpenMobile(!1):a.setOpen(!1))},className:J(`inline-flex size-10 shrink-0 items-center justify-center rounded-xl outline-none`,`focus-visible:ring-2 focus-visible:ring-ring`,e)})}),(0,v.forwardRef)(({className:e,onClick:t,type:n=`button`,...r},i)=>{let a=bk(),o=xk();return(0,G.jsx)(`button`,{...r,ref:i,type:n,"data-side":o.side,"aria-label":r[`aria-label`]??`Toggle sidebar`,title:`Toggle sidebar`,tabIndex:-1,onClick:e=>{t?.(e),e.defaultPrevented||a.toggleSidebar()},className:J(`absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 outline-none md:block`,`after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent after:transition-colors hover:after:bg-border`,`data-[side=right]:right-0 data-[side=right]:translate-x-1/2 data-[side=left]:left-full`,e)})}),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(q.main,{...t,ref:n,"data-slot":`sidebar-inset`,className:J(`relative flex min-h-svh min-w-0 flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl md:peer-data-[variant=inset]:shadow-sm`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-header`,className:J(`flex shrink-0 flex-col gap-2 p-3`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-content`,className:J(`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-2`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-footer`,className:J(`flex shrink-0 flex-col gap-2 border-border border-t p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,e)})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group`,className:J(`flex w-full min-w-0 flex-col px-1 py-1.5`,e)})),(0,v.forwardRef)(({children:e,className:t,...n},r)=>{let{collapsed:i}=xk();return(0,G.jsx)(`div`,{...n,ref:r,"aria-hidden":i,"data-slot":`sidebar-group-label`,className:J(`mb-1 h-7 overflow-hidden px-2 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-opacity`,i?`opacity-0`:`opacity-100`,t),children:e})}),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{...t,ref:n,"data-slot":`sidebar-group-content`,className:J(`w-full min-w-0`,e)})),(0,v.forwardRef)(({children:e,className:t,...n},r)=>(0,G.jsx)(yre,{...n,ref:r,as:`ul`,inset:0,pillClassName:`rounded-xl bg-muted/70`,pillContainerClassName:`inset-y-auto top-0 h-9`,"data-slot":`sidebar-menu`,className:J(`flex w-full min-w-0 list-none flex-col gap-0.5`,t),children:e})),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(q.li,{...t,ref:n,layout:`position`,transition:ZD,"data-slot":`sidebar-menu-item`,className:J(`relative`,e)})),(0,v.forwardRef)(({open:e,children:t,className:n,...r},i)=>{let a=bk(),o=xk();return(0,G.jsx)(BE,{initial:!1,mode:`popLayout`,children:e&&!o.collapsed?(0,v.createElement)(q.ul,{...r,ref:i,key:`sidebar-submenu`,variants:a.reduce?void 0:uk,initial:!a.reduce&&`closed`,animate:a.reduce?{opacity:1}:`open`,exit:a.reduce?{opacity:0}:`closed`,transition:a.reduce?{duration:.12}:void 0,"data-slot":`sidebar-menu-sub`,className:J(`relative mt-1 ml-5 flex min-w-0 flex-col gap-0.5 border-border border-l pl-3`,n)},t):null})}),(0,v.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(q.li,{...t,ref:n,variants:dk,"data-slot":`sidebar-menu-sub-item`,className:J(`relative min-w-0`,e)}));function Ek({children:e,icon:t,badge:n,accessibleLabel:r,href:i,isActive:a=!1,ariaExpanded:o,disabled:s=!1,closeOnSelect:c,target:l,rel:u,onSelect:d,className:f,activeLayoutId:p}){let m=bk(),h=xk(),g=typeof e==`string`?e:void 0,_=e=>{if(s){e.preventDefault();return}if(i&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))return;i&&d&&e.preventDefault(),d?.();let t=c??o===void 0;m.isMobile&&t&&m.setOpenMobile(!1),o!==void 0&&h.collapsed&&!m.isMobile&&m.setOpen(!0)},v=(0,G.jsxs)(G.Fragment,{children:[a?(0,G.jsx)(q.span,{layoutId:p?`${m.layoutId}-${p}`:m.layoutId,transition:m.reduce?{duration:0}:ZD,className:`absolute inset-0 rounded-xl bg-muted`}):null,t?(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`relative z-10 grid size-5 shrink-0 place-items-center`,children:t}):null,(0,G.jsx)(q.span,{initial:!1,animate:{opacity:+!h.collapsed,x:h.collapsed?-4:0},transition:m.reduce?fk:h.collapsed?Cre:Sre,"aria-hidden":h.collapsed,"data-slot":`sidebar-menu-label`,className:J(`relative z-10 min-w-0 flex-1 truncate`,h.collapsed&&`pointer-events-none`),children:e}),n&&!h.collapsed?(0,G.jsx)(`span`,{className:`relative z-10 shrink-0 text-xs text-muted-foreground`,children:n}):null,o===void 0?null:(0,G.jsx)(q.span,{"aria-hidden":`true`,initial:!1,animate:{opacity:+!h.collapsed,rotate:o?90:0,x:h.collapsed?4:0},transition:m.reduce?{duration:0}:ZD,className:`relative z-10 grid size-4 shrink-0 place-items-center text-muted-foreground`,children:(0,G.jsx)(fl,{className:`size-3.5`})})]}),y=J(`relative flex min-h-9 w-full min-w-0 items-center gap-2.5 overflow-hidden rounded-xl px-3 text-left text-sm font-medium outline-none`,`text-muted-foreground transition-colors hover:text-foreground`,`focus-visible:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring`,a&&`text-foreground`,s&&`cursor-not-allowed opacity-40`,f);return i?(0,G.jsx)(q.a,{href:i,target:l,rel:u??(l===`_blank`?`noreferrer noopener`:void 0),"aria-current":a?`page`:void 0,"aria-expanded":o,"aria-disabled":s||void 0,"aria-label":r??(h.collapsed?g:void 0),title:h.collapsed?r??g:void 0,tabIndex:s?-1:void 0,onClick:_,whileTap:m.reduce||s?void 0:{scale:.98},transition:YD,className:y,children:v}):(0,G.jsx)(q.button,{type:`button`,disabled:s,"aria-current":a?`page`:void 0,"aria-expanded":o,"aria-label":r??(h.collapsed?g:void 0),title:h.collapsed?r??g:void 0,onClick:_,whileTap:m.reduce||s?void 0:{scale:.98},transition:YD,className:y,children:v})}var Dk=(0,v.forwardRef)(({label:e,value:t,defaultValue:n,onChange:r,onInputChange:i,onFocus:a,onBlur:o,error:s,reserveErrorLine:c=!1,success:l,leftIcon:u,rightIcon:d,className:f,classNames:p,disabled:m,id:h,type:g,..._},y)=>{let b=(0,v.useId)(),x=h??b,S=RD(),C=t!==void 0,[w,T]=(0,v.useState)(n??``),E=C?t??``:w,[D,O]=(0,v.useState)(!1),k=(0,v.useRef)(null),A=!!s,j=typeof s==`string`?s:null,M=l?null:d;(0,v.useEffect)(()=>{k.current&&!S&&A&&KD(k.current,{x:[0,-6,6,-4,4,-2,0]},{duration:.45})},[A,S]);let N=e=>{C||T(e),r?.(e)};return(0,G.jsxs)(`div`,{className:J(`flex flex-col gap-1.5`,f,p?.root),children:[e?(0,G.jsx)(`label`,{htmlFor:x,className:J(`px-1 text-sm font-medium text-foreground`,p?.label),children:e}):null,(0,G.jsxs)(`div`,{ref:k,"data-state":A?`error`:l?`success`:D?`focused`:`idle`,className:J(`relative h-11 overflow-hidden rounded-full border transition-colors duration-200`,`border-border`,D&&!A&&`border-foreground/40 ring-2 ring-ring/40`,A&&`border-destructive ring-2 ring-destructive/25`,m&&`opacity-60`,p?.field),children:[u?(0,G.jsx)(`span`,{className:J(`pointer-events-none absolute left-3 top-1/2 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:h-4 [&_svg]:w-4`,p?.leftIcon),children:u}):null,(0,G.jsx)(`input`,{ref:y,id:x,type:g,value:g===`file`?void 0:E,disabled:m,"aria-invalid":A||void 0,"aria-describedby":j?`${x}-error`:void 0,..._,onChange:e=>{g!==`file`&&N(e.target.value),i?.(e)},onFocus:e=>{O(!0),a?.(e)},onBlur:e=>{O(!1),o?.(e)},className:J(`peer h-full w-full bg-transparent text-base leading-6 text-foreground caret-foreground outline-none`,`placeholder:text-muted-foreground/60`,u?`pl-10`:`pl-3.5`,M||l?`pr-10`:`pr-3.5`,m&&`cursor-not-allowed`,p?.input)}),l?(0,G.jsx)(q.svg,{viewBox:`0 0 24 24`,fill:`none`,className:J(`absolute right-3.5 top-1/2 h-5 w-5 -translate-y-1/2 text-(--color-success)`,p?.successIcon),children:(0,G.jsx)(q.path,{d:`M5 12.5l4.5 4.5L19 7.5`,stroke:`currentColor`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`,initial:S?{pathLength:1}:{pathLength:0},animate:{pathLength:1},transition:{duration:.35,ease:`easeOut`}})}):M?(0,G.jsx)(`span`,{className:J(`absolute right-0 top-0 flex h-full items-center text-muted-foreground [&_button]:grid [&_button]:size-11 [&_button]:place-items-center [&_svg]:h-4 [&_svg]:w-4`,p?.rightIcon),children:M}):null]}),(0,G.jsx)(`div`,{className:c?`min-h-4`:`contents`,children:(0,G.jsx)(BE,{initial:!1,children:j?(0,G.jsx)(q.p,{id:`${x}-error`,role:`alert`,initial:S?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},animate:{opacity:1,y:0,filter:`blur(0px)`},exit:S?{opacity:0}:{opacity:0,y:-4,filter:`blur(4px)`},transition:{duration:.2},className:J(`px-1 text-xs text-destructive`,p?.errorMessage),children:j}):null})})]})});function Ok({className:e,value:t,defaultValue:n,onChange:r,...i}){return(0,G.jsx)(Dk,{...i,"data-slot":`input`,value:t==null?void 0:String(t),defaultValue:n==null?void 0:String(n),onInputChange:r,className:`min-w-0`,classNames:{field:`h-9 rounded-xl`,input:K(`text-[13px] leading-5`,e)}})}var kk=[{id:`home-internet`,label:`Home Internet`,sub:`Understand slowdowns, manage your household & compare paths`},{id:`overview`,label:`Overview`,sub:`Calls, latency & risk at a glance`},{id:`devices`,label:`Devices`,sub:`Connectivity radar & system health`},{id:`clients`,label:`Clients`,sub:`Connected LAN devices — usage, block/allow, pin IP`},{id:`investigations`,label:`Investigations`,sub:`Client and service evidence across routers`},{id:`service-contracts`,label:`Service Health`,sub:`Approved endpoint checks, contracts and evidence`},{id:`aaa`,label:`RADIUS & UM`,sub:`RADIUS client & User Manager RADIUS server`},{id:`topology`,label:`Topology`,sub:`Layer-2 neighbours via MNDP / CDP / LLDP`},{id:`round-trip`,label:`Round-trip Lab`,sub:`Forward and return paths across snapshots`},{id:`fabric`,label:`L2 Fabric`,sub:`Which host sits on which physical bridge port`},{id:`vulns`,label:`Vulnerabilities`,sub:`Published CVEs matched to this version, ranked by real exposure`},{id:`access`,label:`Access Scope`,sub:`What this session may call — and what it blocked`},{id:`packets`,label:`Packets`,sub:`Live TZSP capture & decode`},{id:`flows`,label:`Flows`,sub:`NetFlow/IPFIX top talkers, conversations & anomalies`},{id:`snapshots`,label:`Snapshots`,sub:`Config history & time-travel diff`},{id:`drift`,label:`Drift Guard`,sub:`Golden config baselines & live drift detection`},{id:`attacks`,label:`Attacks`,sub:`Live attack incidents, evidence and guarded blocking`},{id:`policies`,label:`Policies`,sub:`Your own compliance rules, linted against config`},{id:`explain`,label:`Explain`,sub:`Config → architecture document, diagram and consequence diffs`},{id:`simulator`,label:`Simulator`,sub:`Trace a hypothetical packet — no device touched`},{id:`schedules`,label:`Schedules`,sub:`Auditors on a cron — alerting only on what changed`},{id:`txn`,label:`Transactions`,sub:`Cross-device two-phase commit — prepare, verify, commit everywhere`},{id:`plan`,label:`Change Plan`,sub:`Dry-run intended RouterOS commands`},{id:`s3`,label:`S3 Backups`,sub:`List, download & delete S3 backup objects`},{id:`backups`,label:`Backups`,sub:`Local config vault — create, restore, manage`},{id:`modules`,label:`Modules`,sub:`Enable/disable tool modules — curate the surface`},{id:`config`,label:`Config`,sub:`Effective configuration & safe editor`},{id:`memory`,label:`Memory`,sub:`Knowledge graph — entities, relations & observations`},{id:`alerts`,label:`Alerts`,sub:`Rules that reach out — Slack, Discord, ntfy, webhook, MCP`},{id:`releases`,label:`Releases`,sub:`Update, downgrade & read every version's notes`},{id:`capsman`,label:`CAPsMAN`,sub:`Wi-Fi fabric: coverage, weak signal, load, FT & HA`},{id:`feed`,label:`Live Feed`,sub:`Every tool call, in real time`}],Ak=[{id:`observe`,label:`Observe`,views:[`overview`,`home-internet`,`devices`,`clients`,`feed`]},{id:`investigate`,label:`Investigate`,views:[`investigations`,`service-contracts`,`round-trip`,`topology`,`fabric`,`flows`,`packets`]},{id:`protect`,label:`Protect`,views:[`attacks`,`vulns`,`policies`,`access`,`aaa`,`capsman`]},{id:`operate`,label:`Operate`,views:[`plan`,`simulator`,`txn`,`snapshots`,`drift`,`backups`,`s3`,`schedules`,`explain`]},{id:`workspace`,label:`Workspace`,views:[`modules`,`config`,`memory`,`alerts`,`releases`]}];function jk(e){return Ak.find(t=>t.views.includes(e))??Ak[0]}function Mk(e){let t=e.replace(/^#\/?/,``);return kk.find(e=>e.id===t)?.id??null}function Nk(e){let t=e.trim().toLowerCase().split(/\s+/).filter(Boolean);return Ak.map(e=>({...e,items:e.views.map(e=>kk.find(t=>t.id===e)).filter(n=>t.every(t=>`${n.label} ${n.sub} ${e.label}`.toLowerCase().includes(t)))})).filter(e=>e.items.length>0)}var Pk=`mt-pinned-pages`,Fk=new Set(kk.map(e=>e.id));function Ik(e){try{let t=JSON.parse(e??`[]`);return Array.isArray(t)?[...new Set(t.filter(e=>typeof e==`string`&&Fk.has(e)))]:[]}catch{return[]}}function Lk(e){try{return Ik((e??window.localStorage).getItem(Pk))}catch{return[]}}function Rk(e,t){try{return(t??window.localStorage).setItem(Pk,JSON.stringify(e)),!0}catch{return!1}}function zk(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}var Bk=e=>e<1?`<1ms`:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`;function Vk(e){let t=[`B`,`KiB`,`MiB`,`GiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(+!!n)} ${t[n]}`}var Hk=e=>new Date(e).toLocaleTimeString(void 0,{hour12:!1}),Uk=e=>e.toLocaleString(),Wk=e=>e==null?`?`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e),Gk={cpu:`var(--chart-1)`,mem:`var(--chart-5)`,disk:`var(--chart-2)`,latency:`var(--chart-4)`},Kk={READ:`var(--chart-3)`,WRITE:`var(--chart-1)`,WRITE_IDEMPOTENT:`var(--chart-2)`,DESTRUCTIVE:`var(--chart-4)`,DANGEROUS:`var(--destructive)`},qk={READ:`border-chart-3/40 text-chart-3`,WRITE:`border-chart-1/40 text-chart-1`,WRITE_IDEMPOTENT:`border-chart-2/40 text-chart-2`,DESTRUCTIVE:`border-chart-4/40 text-chart-4`,DANGEROUS:`border-destructive/40 text-destructive`},Jk=[[`5m`,3e5],[`15m`,9e5],[`1h`,36e5],[`6h`,216e5],[`24h`,864e5]],Yk=1e4,Xk={neutral:`border-border bg-card text-muted-foreground`,info:`border-primary/30 bg-primary/10 text-primary`,success:`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`border-destructive/30 bg-destructive/10 text-destructive`,loading:`border-primary/30 bg-primary/10 text-primary`},Zk={sm:`h-6 gap-1.5 px-2 text-[11px]`,md:`h-8 gap-2 px-3 text-xs`},Qk={sm:`h-3 w-3`,md:`h-3.5 w-3.5`},$k={neutral:wl,info:gu,success:cl,warning:Jd,danger:df,loading:wu},eA={initial:{opacity:.72,y:`80%`,scale:.92,rotate:-8,filter:`blur(6px)`},animate:{opacity:1,y:`0%`,scale:1,rotate:0,filter:`blur(0px)`,transition:{y:{type:`spring`,stiffness:210,damping:24,mass:.85},scale:{type:`spring`,stiffness:250,damping:24,mass:.75},rotate:{duration:.28,ease:qD},opacity:{duration:.28,ease:qD},filter:{duration:.42,ease:qD}}},exit:{opacity:.5,y:`-80%`,scale:.96,rotate:8,filter:`blur(6px)`,transition:{duration:.22,ease:qD}}},tA={initial:{opacity:.76,y:`85%`,filter:`blur(6px)`},animate:{opacity:1,y:`0%`,filter:`blur(0px)`,transition:{y:{type:`spring`,stiffness:210,damping:24,mass:.85},opacity:{duration:.3,ease:qD},filter:{duration:.42,ease:qD}}},exit:{opacity:.5,y:`-85%`,filter:`blur(6px)`,transition:{duration:.2,ease:qD}}};function nA({status:e=`neutral`,size:t=`md`,children:n,icon:r,showIcon:i=!0,pulse:a=e===`loading`,contentKey:o,className:s,...c}){let l=RD(),u=$k[e],d=o??(typeof n==`string`||typeof n==`number`?n:e);return(0,G.jsxs)(q.span,{layout:!l,transition:l?{duration:0}:{type:`spring`,stiffness:420,damping:30,mass:.7},className:J(`relative inline-flex shrink-0 items-center overflow-hidden whitespace-nowrap rounded-full border font-medium tabular-nums`,`transition-colors duration-300`,Xk[e],Zk[t],s),...c,children:[a&&!l?(0,G.jsx)(q.span,{"aria-hidden":!0,className:`absolute inset-0 rounded-full bg-current opacity-10`,animate:{scale:[.94,1.08,.94],opacity:[.08,.16,.08]},transition:{duration:1.6,repeat:1/0,ease:`easeInOut`}}):null,i?(0,G.jsx)(`span`,{className:`relative z-10 inline-flex items-center justify-center overflow-hidden`,children:(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:(0,G.jsx)(q.span,{"aria-hidden":!0,"data-badge-icon":!0,variants:eA,initial:!l&&`initial`,animate:l?{opacity:1}:`animate`,exit:l?void 0:`exit`,className:`inline-flex will-change-transform`,children:e===`loading`&&!l&&!r?(0,G.jsx)(q.span,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:`linear`},className:`inline-flex`,children:(0,G.jsx)(u,{className:Qk[t]})}):r??(0,G.jsx)(u,{className:Qk[t]})},e)})}):null,n==null?null:(0,G.jsx)(`span`,{className:`relative z-10 inline-flex overflow-hidden`,children:(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:(0,G.jsx)(q.span,{"data-badge-label":!0,variants:tA,initial:!l&&`initial`,animate:l?{opacity:1}:`animate`,exit:l?void 0:`exit`,className:`inline-block will-change-transform`,children:n},d)})})]})}var rA={"home-internet":`5.12.0`,overview:null,devices:null,clients:null,investigations:null,"service-contracts":null,"round-trip":null,aaa:null,topology:null,fabric:null,vulns:null,access:null,packets:null,flows:null,snapshots:null,drift:null,policies:null,simulator:null,schedules:null,explain:null,attacks:null,txn:null,plan:null,s3:null,backups:null,modules:null,config:null,memory:null,alerts:null,releases:null,capsman:null,feed:null};function iA(e){return e?.trim().match(/^v?((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?)(?:\+[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?$/)?.[1]??null}function aA(e,t){let n=iA(rA[e]);return n&&n===iA(t)?n:null}function oA({view:e,version:t,placement:n=`menu`}){let r=aA(e,t);if(!r)return null;let i=`New in v${r}`,a=`${i} · Highlighted for this release, even after you visit.`;return n===`icon`?(0,G.jsx)(`span`,{className:`feature-new-dot`,title:a,"aria-label":i,"data-feature-release":r}):(0,G.jsx)(nA,{status:`info`,size:`sm`,pulse:!1,icon:(0,G.jsx)(Pd,{size:12}),showIcon:n===`page`,className:`feature-new-badge feature-new-${n}`,title:a,"aria-label":i,"data-feature-release":r,children:n===`page`?`New in v${r}`:`NEW`})}function sA({mode:e}){return(0,G.jsxs)(`span`,{className:`shell-stream`,"data-connected":e!==`off`,title:`Dashboard event stream, not router health`,children:[(0,G.jsx)(`span`,{className:`shell-stream-dot`,"aria-hidden":`true`}),e===`off`?`Stream offline`:`Live stream`,e!==`off`&&(0,G.jsx)(`span`,{className:`shell-stream-protocol`,children:e.toUpperCase()})]})}function cA({view:e,onNavigate:t,renderIcon:n,onMobileOpenChange:r,liveMode:i,version:a,transport:o,eventCount:s,feedCount:c,firingCount:l,releaseAvailable:u,onReleaseNotes:d,controls:f}){let p=bk(),m=!p.open&&!p.isMobile,[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(()=>Lk()),[b,x]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>{e.storageArea===window.localStorage&&(e.key===`mt-pinned-pages`||e.key===null)&&(y(Ik(e.newValue)),x(``))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let S=jk(e).id,[C,w]=(0,v.useState)(()=>({view:e,expanded:new Set([S])})),T=C.view===e?C.expanded:new Set([S]);(0,v.useEffect)(()=>{let e=window.matchMedia(`(min-width: 900px)`),t=()=>{e.matches&&r(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[r]);let E=Nk(h),D=e=>{t(e),r(!1),g(``)},O=e=>{let t=zk(_,e);y(t);let n=Rk(t),r=kk.find(t=>t.id===e).label;x(`${r} ${t.includes(e)?`pinned`:`unpinned`}.${n?``:` Browser storage unavailable; kept for this session only.`}`)},k=(t,r,i=!1)=>{let o=_.includes(t.id),s=aA(t.id,a);return(0,G.jsxs)(`div`,{className:`shell-nav-row`,children:[(0,G.jsx)(Ek,{href:`#${t.id}`,accessibleLabel:s?`${t.label} · New in v${s}`:void 0,isActive:e===t.id,activeLayoutId:i?`pinned`:`categories`,className:`shell-nav-link`,onSelect:()=>D(t.id),icon:(0,G.jsxs)(G.Fragment,{children:[n(t.id),m&&(0,G.jsx)(oA,{view:t.id,version:a,placement:`icon`})]}),badge:(0,G.jsxs)(`span`,{className:`shell-nav-badges`,children:[(0,G.jsx)(oA,{view:t.id,version:a}),t.id===`alerts`&&l>0&&(0,G.jsx)(`span`,{className:`shell-nav-count shell-nav-count-alert`,children:l}),t.id===`feed`&&c>0&&(0,G.jsx)(`span`,{className:`shell-nav-count`,children:c>999?`999+`:c})]}),children:t.label}),(0,G.jsx)(nO,{variant:`ghost`,size:`icon-xs`,type:`button`,className:`shell-pin-toggle`,"aria-label":`${o?`Unpin`:`Pin`} ${t.label}`,"aria-pressed":o,title:`${o?`Unpin`:`Pin`} ${t.label}`,onClick:()=>{O(t.id),i&&document.getElementById(`${r}-search`)?.focus()},children:o?(0,G.jsx)(Wu,{size:13,"aria-hidden":`true`}):(0,G.jsx)(Ku,{size:13,"aria-hidden":`true`})})]},t.id)};return(0,G.jsxs)(wk,{ariaLabel:`Dashboard navigation`,collapsible:`icon`,className:p.isMobile?`shell-mobile-nav`:`shell-animated-sidebar`,panelClassName:`shell-sidebar`,children:[p.isMobile&&(0,G.jsxs)(nO,{variant:`ghost`,size:`sm`,onClick:()=>p.setOpenMobile(!1),className:`self-end`,children:[(0,G.jsx)(df,{size:14}),`Close navigation`]}),(t=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`a`,{href:`#overview`,className:`shell-brand`,onClick:e=>{e.preventDefault(),D(`overview`)},"aria-label":`MikroTik MCP overview`,children:[(0,G.jsx)(`span`,{className:`shell-brand-mark`,"aria-hidden":`true`,children:(0,G.jsxs)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,children:[(0,G.jsx)(`path`,{d:`M10 11 20 21 30 11M20 21v10`,stroke:`currentColor`,strokeWidth:`2`}),(0,G.jsx)(`circle`,{cx:`10`,cy:`11`,r:`3`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`30`,cy:`11`,r:`3`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`20`,cy:`31`,r:`3`,fill:`currentColor`}),(0,G.jsx)(`circle`,{cx:`20`,cy:`21`,r:`4`,fill:`currentColor`})]})}),(0,G.jsxs)(`span`,{children:[(0,G.jsxs)(`strong`,{children:[`MikroTik `,(0,G.jsx)(`span`,{children:`MCP`})]}),(0,G.jsx)(`small`,{children:`Network operations`})]})]}),(0,G.jsxs)(`div`,{className:`shell-workspace`,children:[(0,G.jsx)(`span`,{className:`shell-workspace-icon`,children:(0,G.jsx)(Pc,{size:17,"aria-hidden":`true`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Observability`}),(0,G.jsx)(`span`,{children:o?`${o.toUpperCase()} workspace`:`Dashboard workspace`})]}),(0,G.jsx)(`span`,{className:`shell-workspace-indicator`,"aria-hidden":`true`})]}),(0,G.jsxs)(`div`,{className:`shell-nav-search`,children:[(0,G.jsx)(md,{size:15,"aria-hidden":`true`}),(0,G.jsx)(Ok,{id:`${t}-search`,"aria-label":`Find a page`,placeholder:`Find a page…`,value:h,onChange:e=>g(e.target.value)}),h&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Clear page search`,onClick:()=>{g(``),document.getElementById(`${t}-search`)?.focus()},children:(0,G.jsx)(df,{size:14})})]}),(0,G.jsxs)(`nav`,{className:`shell-nav`,"aria-label":`Dashboard navigation`,children:[!h.trim()&&(0,G.jsxs)(`section`,{className:`shell-pinned`,"aria-label":`Pinned pages`,children:[(0,G.jsxs)(`div`,{className:`shell-pinned-heading`,children:[(0,G.jsx)(Ku,{size:12,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:`Pinned`}),(0,G.jsx)(`span`,{children:_.length})]}),_.length>0?(0,G.jsx)(`div`,{className:`shell-nav-track`,children:_.map(e=>k(kk.find(t=>t.id===e),t,!0))}):(0,G.jsx)(`p`,{className:`shell-pin-hint`,children:`Pin your go-to pages for quick access.`})]}),(0,G.jsx)(`p`,{className:b.includes(`unavailable`)?`shell-pin-hint`:`sr-only`,role:`status`,children:b}),E.map(n=>{let r=m||!!h.trim()||T.has(n.id);return(0,G.jsxs)(`section`,{className:`shell-nav-group`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`shell-group-heading`,"aria-expanded":r,"aria-controls":`${t}-${n.id}`,onClick:()=>w(()=>{let t=new Set(T);return t.has(n.id)?t.delete(n.id):t.add(n.id),{view:e,expanded:t}}),children:[(0,G.jsx)(`span`,{children:n.label}),(0,G.jsxs)(`span`,{className:`shell-group-meta`,children:[n.views.includes(`alerts`)&&l>0&&(0,G.jsx)(`span`,{className:`shell-alert-dot`,"aria-label":`${l} alerts firing`}),r?(0,G.jsx)(ul,{size:13}):(0,G.jsx)(fl,{size:13})]})]}),(0,G.jsx)(`div`,{id:`${t}-${n.id}`,className:`shell-nav-track`,hidden:!r,children:n.items.map(e=>k(e,t))})]},n.id)}),E.length===0&&(0,G.jsxs)(`div`,{className:`shell-nav-empty`,role:`status`,children:[(0,G.jsx)(md,{size:20}),(0,G.jsx)(`strong`,{children:`No matching pages`}),(0,G.jsx)(`span`,{children:`Try “flows”, “backup” or “router”.`})]})]}),(0,G.jsxs)(`footer`,{className:`shell-sidebar-footer`,children:[(0,G.jsxs)(`div`,{className:`shell-instance`,children:[(0,G.jsx)(sA,{mode:i}),(0,G.jsx)(`span`,{children:s==null?`Waiting for server`:`${Uk(s)} recorded events`})]}),(0,G.jsx)(`div`,{className:`shell-server-controls`,children:f}),(0,G.jsxs)(`button`,{type:`button`,className:`shell-version`,disabled:!d,onClick:d,children:[(0,G.jsxs)(`span`,{children:[`MikroTik MCP `,(0,G.jsx)(`b`,{children:a?`v${a}`:`—`})]}),u?(0,G.jsx)(`span`,{className:`shell-release-dot`,"aria-label":`New release available`}):(0,G.jsx)(Wc,{size:13,"aria-hidden":`true`})]})]})]}))(p.isMobile?`mobile-nav`:`desktop-nav`)]})}var lA=(0,v.createContext)(null),uA={type:`spring`,duration:.8,bounce:.2},dA={type:`spring`,duration:.8,bounce:.35},fA=32,pA=126,mA=37;function hA(){let e=(0,v.useRef)(null),[t,n]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let t=e.current;t&&n({width:t.offsetWidth,height:t.offsetHeight})},[]),(0,v.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n({width:t.offsetWidth,height:t.offsetHeight})});return r.observe(t),()=>r.disconnect()},[]),[e,t]}function gA({keyId:e,children:t,className:n,ref:r}){let i=RD(),a=(0,v.useContext)(lA)?.anchor===`bottom`;return(0,G.jsx)(q.div,{ref:r,initial:i?{opacity:0,filter:`blur(0px)`}:{opacity:0,scale:a?1:.9,y:a?0:-8,filter:`blur(5px)`},animate:i?{opacity:1,filter:`blur(0px)`}:{opacity:1,scale:1,y:0,filter:`blur(0px)`},exit:i?{opacity:0,filter:`blur(0px)`,transition:{duration:.1}}:{opacity:0,scale:a?1:.9,y:a?0:-6,filter:`blur(0px)`,transition:{duration:.08,ease:qD}},transition:i?{duration:.1}:a?{duration:.16,ease:qD}:dA,style:{transformOrigin:a?`bottom center`:`top center`},className:J(`flex items-center justify-center`,n),children:t},e)}function _A({view:e,compact:t,children:n,className:r,announce:i=!0,anchor:a=`top`}){let o=RD(),s=e!==null,[c,l]=hA(),u=(0,v.useMemo)(()=>({view:e,anchor:a}),[e,a]);return(0,G.jsx)(lA.Provider,{value:u,children:(0,G.jsx)(q.div,{"data-anchor":a,role:i?`status`:void 0,"aria-live":i?`polite`:void 0,initial:!1,animate:l?{width:l.width,height:l.height}:{width:pA,height:mA},transition:o?{duration:0}:a===`bottom`?{duration:.26,ease:qD}:uA,style:{borderRadius:fA},className:J(`relative inline-flex justify-center overflow-hidden`,a===`bottom`?`items-end`:`items-start`,`bg-foreground text-background shadow-2xl`,r),children:(0,G.jsxs)(`div`,{ref:c,className:`relative w-max shrink-0`,children:[(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:!s&&t?(0,G.jsx)(gA,{keyId:`compact`,className:`min-h-[37px] min-w-[126px] gap-2 px-4 py-1.5 text-xs font-medium`,children:t},`compact`):null}),n]})})})}function vA({id:e,children:t,className:n}){let r=(0,v.useContext)(lA);if(!r)throw Error(`DynamicIslandView must be used inside <DynamicIsland>`);let i=r.view===e;return(0,G.jsx)(BE,{mode:`popLayout`,initial:!1,children:i?(0,G.jsx)(gA,{keyId:e,className:J(`px-6 py-4`,n),children:t}):null})}var yA=[.16,1,.3,1],bA={enter:({direction:e,reduceMotion:t})=>({opacity:0,transform:t?`none`:`translateY(${e===`up`?`45%`:`-45%`})`}),visible:{opacity:1,transform:`translateY(0%)`},exit:({direction:e,reduceMotion:t})=>({opacity:0,transform:t?`none`:`translateY(${e===`up`?`-45%`:`45%`})`})};function xA({value:e,animationKey:t,direction:n=`up`,duration:r=.18,stagger:i=.006,suffixLength:a=0,className:o,glyphClassName:s,suffixClassName:c}){let l=RD()??!1,u=String(e),d=Math.max(0,u.length-Math.max(0,a)),f={direction:n,reduceMotion:l},p=Array.from(u,(e,t)=>({character:e,id:`glyph-${t}`,position:t}));return(0,G.jsxs)(`span`,{"data-slot":`digit-swap`,"data-direction":n,className:K(`inline-flex items-center whitespace-nowrap`,o),children:[(0,G.jsx)(`span`,{className:`sr-only`,children:u}),(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex items-center`,children:p.map(({character:e,id:n,position:a})=>{if(e===` `)return(0,G.jsx)(`span`,{className:`inline-block w-[0.7ch]`},n);let o=t===void 0?`${n}-${e}`:`${n}-${e}-${t}`;return(0,G.jsx)(`span`,{"data-slot":`digit-swap-glyph`,className:`relative inline-block h-[1.1em] w-[1ch] shrink-0 overflow-hidden align-bottom`,children:(0,G.jsx)(BE,{initial:!1,custom:f,children:(0,G.jsx)(q.span,{custom:f,variants:bA,initial:`enter`,animate:`visible`,exit:`exit`,transition:{duration:l?Math.min(r,.12):r,delay:l?0:a*i,ease:yA},className:K(`absolute inset-0 flex items-center justify-center leading-none`,s,a>=d?c:void 0),children:e},o)})},n)})})]})}var SA=(0,v.createContext)(null);function CA(){let e=(0,v.useContext)(SA);if(!e)throw Error(`Tabs.* must be used inside <Tabs>`);return e}var wA={type:`spring`,stiffness:170,damping:30,mass:1.2};function TA({defaultValue:e,value:t,onValueChange:n,variant:r=`pill`,children:i,className:a}){let[o,s]=(0,v.useState)(e??``),c=(0,v.useId)(),l=RD(),u=t!==void 0,d=u?t:o,f=(0,v.useCallback)(e=>{u||s(e),n?.(e)},[u,n]),p=(0,v.useMemo)(()=>({value:d,setValue:f,layoutId:c,variant:r}),[d,c,f,r]);return(0,G.jsx)(ZE,{transition:l?{duration:0}:wA,children:(0,G.jsx)(SA.Provider,{value:p,children:(0,G.jsx)(q.div,{layoutRoot:!0,className:a,children:i})})})}var EA={pill:`inline-flex items-center gap-1 rounded-full bg-card p-1`,underline:`inline-flex items-center gap-1 border-b border-border`,segment:`inline-flex items-center gap-0 rounded-lg bg-card p-0.5`};function DA({children:e,className:t,onKeyDown:n,...r}){let{variant:i}=CA();return(0,G.jsx)(`div`,{...r,role:`tablist`,className:J(EA[i],t),onKeyDown:e=>{if(n?.(e),e.defaultPrevented)return;let t=Array.from(e.currentTarget.querySelectorAll(`[role="tab"]:not(:disabled)`)),r=t.indexOf(document.activeElement),i=e.key===`Home`?t[0]:e.key===`End`?t.at(-1):e.key===`ArrowRight`?t[(r+1)%t.length]:e.key===`ArrowLeft`?t[(r-1+t.length)%t.length]:null;i&&(e.preventDefault(),i.focus(),i.click())},children:e})}function OA({value:e,children:t,className:n,indicatorClassName:r,disabled:i,onClick:a,...o}){let{value:s,setValue:c,layoutId:l,variant:u}=CA(),d=s===e,f={...o,id:`${l}-tab-${e}`,"aria-controls":`${l}-panel-${e}`,"data-state":d?`active`:`inactive`,tabIndex:d?0:-1,disabled:i,onClick:t=>{a?.(t),!t.defaultPrevented&&!i&&c(e)}};if(u===`underline`)return(0,G.jsxs)(`button`,{...f,type:`button`,role:`tab`,"aria-selected":d,className:J(`relative isolate px-3 pb-2.5 pt-1 -mb-px text-sm font-medium transition-colors min-h-[44px] inline-flex items-center`,d?`text-foreground`:`text-muted-foreground hover:text-foreground`,n),children:[t,d?(0,G.jsx)(q.span,{layoutId:l,layout:`position`,className:J(`absolute -bottom-px left-0 right-0 h-px bg-primary`,r)}):null]});let p=u===`pill`?`rounded-full`:`rounded-md`;return(0,G.jsxs)(`div`,{className:`relative`,children:[d?(0,G.jsx)(q.span,{layoutId:l,layout:`position`,style:{borderRadius:u===`pill`?9999:8},className:J(`absolute inset-0 bg-primary`,p,r)}):null,(0,G.jsx)(`button`,{...f,type:`button`,role:`tab`,"aria-selected":d,className:J(`relative z-10 inline-flex items-center justify-center whitespace-nowrap bg-transparent px-3.5 py-1.5 text-sm font-medium outline-none`,`transition-colors`,d?`text-primary-foreground`:`text-muted-foreground hover:text-foreground`,p,n),children:t})]})}function kA({value:e,children:t,className:n,forceMount:r}){let{value:i,layoutId:a}=CA(),o=RD(),s=i===e;return!s&&!r?null:(0,G.jsx)(q.div,{role:`tabpanel`,hidden:!s,id:`${a}-panel-${e}`,"aria-labelledby":`${a}-tab-${e}`,tabIndex:0,initial:{opacity:0,y:o?0:4},animate:{opacity:1,y:0},transition:{duration:.18,ease:qD},className:J(`mt-4`,n),children:t},e)}function AA({className:e,...t}){return(0,G.jsx)(TA,{...t,variant:`segment`,className:K(`flex min-w-0 flex-col gap-2`,e)})}function jA({className:e,...t}){return(0,G.jsx)(DA,{...t,className:K(`w-fit max-w-full gap-1 rounded-xl border p-1`,e)})}function MA({className:e,...t}){return(0,G.jsx)(OA,{...t,className:K(`gap-1.5 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`,e)})}function NA({className:e,...t}){return(0,G.jsx)(kA,{...t,className:K(`flex-1 outline-none`,e)})}var PA=3e4;function FA(e,t,n=PA){return typeof e==`number`&&Number.isFinite(e)&&e>0&&t>=e&&t-e<=n}function IA(e,t,n){return e.disabled?`disabled`:!n||!FA(e.status.checkedAt,t,12e4)?`unknown`:e.status.reachable===!0?`reachable`:e.status.reachable===!1?`unreachable`:`unknown`}function LA({mode:e,paused:t,now:n,liveEvent:r,liveEventAt:i,pool:a,poolAt:o,alerts:s,alertsAt:c}){if(e===`off`)return{kind:`offline`,label:`Stream offline`,detail:`Reconnecting automatically`};if(t)return{kind:`paused`,label:`Dashboard paused`,detail:`Displayed activity is frozen`};let l=r&&FA(i,n,1e4);return l&&r.isError?{kind:`error`,label:`Tool call failed`,detail:r.tool}:s!=null&&s>0&&FA(c,n,45e3)?{kind:`alerts`,label:`Alerts need attention`,detail:`Active alert rules`,count:s}:a?.enabled&&FA(o,n)&&Number.isFinite(a.aggregate.totalInflight)&&a.aggregate.totalInflight>0?{kind:`busy`,label:`SSH channels busy`,detail:`Observed in the connection pool`,count:a.aggregate.totalInflight}:l?{kind:`completed`,label:`Tool call completed`,detail:r.tool}:{kind:`listening`,label:`Listening for activity`,detail:e===`sse`?`SSE fallback connected`:`WebSocket connected`}}function RA(e){return Number.isFinite(e.durationMs)&&e.durationMs>=0?e.ts+e.durationMs:NaN}function zA(e,t){let n=new Set;return e.filter(e=>{let r=RA(e);return!e.id||n.has(e.id)||!Number.isFinite(r)||r>t?!1:(n.add(e.id),!0)}).sort((e,t)=>RA(t)-RA(e)).slice(0,4)}function BA(e,t){if(e==null||!Number.isFinite(e)||e<=0||e>t)return`Not observed`;let n=Math.floor((t-e)/1e3);return n<5?`Just now`:n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}var VA={offline:Qd,paused:Bu,error:vl,alerts:Qc,busy:Pc,completed:cl,listening:ed};function HA(e){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(`pulse`),[a,o]=(0,v.useState)(Date.now),s=Math.max(a,e.statsAt??0,e.poolAt??0,e.alertsAt??0,e.liveEventAt??0),c=(0,v.useRef)(null),l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(!1);(0,v.useEffect)(()=>{let e=setInterval(()=>{document.visibilityState===`visible`&&o(Date.now())},1e3),t=()=>o(Date.now());return document.addEventListener(`visibilitychange`,t),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,t)}},[]),(0,v.useEffect)(()=>{if(!t){d.current&&l.current?.focus({preventScroll:!0}),d.current=!1;return}u.current?.focus({preventScroll:!0});let e=e=>{c.current?.contains(e.target)||n(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[t]);let f=LA({...e,now:s}),p=VA[f.kind],m=e.mode!==`off`&&!e.paused,h=m&&FA(e.statsAt,s),g=m&&FA(e.poolAt,s),_=m&&FA(e.alertsAt,s,45e3),y=(0,v.useMemo)(()=>zA(e.events,s),[e.events,s]),b=e.devices?.devices??[],x=b.filter(e=>IA(e,s,m)===`reachable`).length,S=e.stats?.series.filter(e=>Number.isFinite(e.ok)&&Number.isFinite(e.error)&&e.ok>=0&&e.error>=0).slice(-18)??[],C=Math.max(1,...S.map(e=>e.ok+e.error)),w=()=>{d.current=!0,n(!1)},T=t=>{n(!1),e.onNavigate(t)},E=e.stats?`${Math.round(e.stats.windowMs/6e4)} min window`:`Waiting for analytics`,D=(e,t=Uk)=>e!=null&&Number.isFinite(e)?t(e):`—`;return(0,G.jsxs)(`aside`,{ref:c,className:`operations-island-anchor`,"aria-label":`Operations Island`,onKeyDown:e=>{e.key===`Escape`&&t&&(e.preventDefault(),e.stopPropagation(),w())},"data-signal":f.kind,children:[(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:f.label}),(0,G.jsx)(_A,{announce:!1,anchor:`bottom`,view:t?`operations`:null,className:`operations-island`,compact:(0,G.jsxs)(nO,{ref:l,variant:`ghost`,className:`island-compact`,"aria-label":`Open Operations Island: ${f.label}`,"aria-expanded":t,"aria-controls":`operations-island-panel`,onClick:()=>n(!0),children:[(0,G.jsx)(`span`,{className:`island-signal-icon`,children:(0,G.jsx)(p,{size:17})}),(0,G.jsxs)(`span`,{className:`island-compact-copy`,children:[(0,G.jsx)(`strong`,{children:f.label}),(0,G.jsx)(`span`,{children:f.detail})]}),f.count==null?(0,G.jsxs)(`span`,{className:`island-equalizer`,"data-moving":f.kind===`busy`,"aria-hidden":`true`,children:[(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{}),(0,G.jsx)(`i`,{})]}):(0,G.jsx)(`span`,{className:`island-count`,children:(0,G.jsx)(xA,{value:f.count})}),(0,G.jsx)(ml,{size:14,className:`island-chevron`})]}),children:(0,G.jsx)(vA,{id:`operations`,className:`island-expanded-slot`,children:(0,G.jsxs)(`section`,{id:`operations-island-panel`,className:`island-panel`,"aria-label":`Operations summary`,children:[(0,G.jsxs)(`header`,{className:`island-header`,children:[(0,G.jsx)(`span`,{className:`island-signal-icon`,children:(0,G.jsx)(p,{size:20})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{children:`OPERATIONS PULSE`}),(0,G.jsx)(`h2`,{children:f.label})]}),(0,G.jsx)(nO,{ref:u,size:`icon-sm`,variant:`ghost`,className:`island-close`,"aria-label":`Collapse Operations Island`,onClick:w,children:(0,G.jsx)(df,{size:16})})]}),(0,G.jsxs)(`div`,{className:`island-connection`,children:[(0,G.jsx)(`span`,{className:m?`island-dot is-connected`:`island-dot`}),(0,G.jsx)(`span`,{children:e.mode===`off`?`Disconnected · last-known data only`:e.paused?`Stream connected · dashboard updates paused`:`${e.mode.toUpperCase()} connected · no extra router probes`})]}),(0,G.jsxs)(AA,{value:r,onValueChange:i,className:`island-tabs`,children:[(0,G.jsxs)(jA,{"aria-label":`Operations views`,className:`island-tab-list`,children:[(0,G.jsxs)(MA,{value:`pulse`,children:[(0,G.jsx)(Pc,{size:13}),`Pulse`]}),(0,G.jsxs)(MA,{value:`fleet`,children:[(0,G.jsx)(ud,{size:13}),`Routers`]}),(0,G.jsxs)(MA,{value:`activity`,children:[(0,G.jsx)(El,{size:13}),`Activity`]})]}),(0,G.jsxs)(NA,{value:`pulse`,className:`island-tab-panel`,children:[(0,G.jsxs)(`div`,{className:`island-chart-heading`,children:[(0,G.jsx)(`span`,{children:`TOOL CALL VOLUME`}),(0,G.jsx)(`span`,{children:E})]}),(0,G.jsx)(`div`,{className:`island-volume`,"aria-hidden":`true`,"data-stale":!h,children:S.some(e=>e.ok+e.error>0)?S.map(e=>(0,G.jsxs)(`div`,{className:`island-bar-track`,children:[(0,G.jsx)(`span`,{className:`island-bar-ok`,style:{height:`${e.ok/C*100}%`}}),(0,G.jsx)(`span`,{className:`island-bar-error`,style:{height:`${e.error/C*100}%`}})]},e.t)):(0,G.jsx)(`span`,{className:`island-empty-chart`,children:e.stats?`No calls in this window`:`Waiting for recorded activity`})}),(0,G.jsxs)(`div`,{className:`island-chart-caption`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`i`,{}),`Successful `,(0,G.jsx)(`i`,{className:`is-error`}),`Failed`]}),(0,G.jsxs)(`span`,{children:[h?`Updated`:`Snapshot`,` · `,BA(e.statsAt,s)]})]}),(0,G.jsxs)(`div`,{className:`island-metrics`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{children:`Calls / min`}),(0,G.jsx)(`strong`,{children:D(e.stats?.callsPerMin,e=>e.toFixed(1))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{children:`Tool p95`}),(0,G.jsx)(`strong`,{children:D(e.stats&&e.stats.total>0?e.stats.latency.p95:void 0,Bk)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{children:`Failed calls`}),(0,G.jsx)(`strong`,{className:e.stats?.errors?`island-error-text`:``,children:D(e.stats?.errors)})]})]}),(0,G.jsxs)(`div`,{className:`island-insights`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(ou,{size:13}),g&&e.pool?e.pool.enabled?`${e.pool.aggregate.totalInflight} SSH channels in flight`:`SSH pooling disabled`:`SSH pool status unavailable`]}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(Qc,{size:13}),_&&e.alerts!=null?`${e.alerts} active alert rules`:`Alert status unavailable`]})]}),(0,G.jsxs)(nO,{variant:`ghost`,className:`island-link`,onClick:()=>T(`overview`),children:[`Open analytics`,(0,G.jsx)(Wc,{size:14})]})]}),(0,G.jsxs)(NA,{value:`fleet`,className:`island-tab-panel`,children:[(0,G.jsxs)(`div`,{className:`island-chart-heading`,children:[(0,G.jsx)(`span`,{children:`LAST ROUTER CHECKS`}),(0,G.jsx)(`span`,{children:e.devices?`${x} / ${b.filter(e=>!e.disabled).length} reachable`:`Not loaded`})]}),(0,G.jsx)(`div`,{className:`island-scroll-list`,children:b.length?b.map(e=>{let t=IA(e,s,m);return(0,G.jsxs)(`div`,{className:`island-device`,"data-state":t,children:[(0,G.jsx)(`span`,{className:`island-router-icon`,children:(0,G.jsx)(ud,{size:18})}),(0,G.jsxs)(`div`,{className:`island-row-copy`,children:[(0,G.jsx)(`strong`,{children:e.name}),(0,G.jsxs)(`span`,{children:[t===`unknown`?`Unknown / stale`:t,` ·`,` `,BA(e.status.checkedAt,s)]})]}),(0,G.jsx)(`span`,{className:`island-device-latency`,children:t===`reachable`&&e.status.latencyMs!=null?Bk(e.status.latencyMs):`—`})]},e.name)}):(0,G.jsx)(`p`,{className:`island-empty`,children:`Router status has not loaded. No healthy state is assumed.`})}),(0,G.jsx)(`p`,{className:`island-footnote`,children:`Management reachability is not proof of client or VPN health.`}),(0,G.jsxs)(nO,{variant:`ghost`,className:`island-link`,onClick:()=>T(`devices`),children:[`Open devices`,(0,G.jsx)(Wc,{size:14})]})]}),(0,G.jsxs)(NA,{value:`activity`,className:`island-tab-panel`,children:[(0,G.jsxs)(`div`,{className:`island-chart-heading`,children:[(0,G.jsx)(`span`,{children:`RECORDED COMPLETIONS`}),(0,G.jsxs)(`span`,{children:[`Latest `,y.length]})]}),(0,G.jsx)(`div`,{className:`island-scroll-list`,children:y.length?y.map(t=>(0,G.jsxs)(nO,{variant:`ghost`,className:`island-event`,onClick:()=>{n(!1),e.onEvent(t)},children:[(0,G.jsx)(`span`,{className:t.isError?`island-error-text`:`island-success-text`,children:t.isError?(0,G.jsx)(vl,{size:16}):(0,G.jsx)(cl,{size:16})}),(0,G.jsxs)(`span`,{className:`island-row-copy`,children:[(0,G.jsx)(`strong`,{children:t.tool}),(0,G.jsxs)(`span`,{children:[t.device??`Server`,` · `,BA(RA(t),s)]})]}),(0,G.jsxs)(`span`,{className:`island-event-duration`,children:[Bk(t.durationMs),(0,G.jsx)(Wc,{size:12})]})]},t.id)):(0,G.jsx)(`p`,{className:`island-empty`,children:`No recorded calls yet. Activity appears when MCP tools complete.`})}),(0,G.jsx)(`p`,{className:`island-footnote`,children:`Completed tool calls, not a live packet trace. Open a call for its evidence.`}),(0,G.jsxs)(nO,{variant:`ghost`,className:`island-link`,onClick:()=>T(`feed`),children:[`Open Live Feed`,(0,G.jsx)(Wc,{size:14})]})]})]}),(0,G.jsxs)(`footer`,{className:`island-footer`,children:[(0,G.jsx)(ed,{size:11}),(0,G.jsx)(`span`,{children:`OBSERVE ONLY`}),(0,G.jsx)(`span`,{children:`No configuration changes`})]})]})})})]})}function UA(e,t){try{e.setPointerCapture(t)}catch{}}var WA=e=>e.pointerType!==`touch`&&e.buttons===0,GA={active:!1,startX:0,startY:0,pointerId:null},KA={duration:.9,ease:JD,repeat:1/0},qA={duration:1.2,ease:JD,repeat:1/0},JA={duration:.16,ease:qD};function YA(e,t){return t*(1-Math.exp(-Math.max(0,e)/t))}function XA({progress:e,status:t,reduce:n}){let r=ID(e,[0,1],[-7,0]),i=ID(e,[0,1],[-10,0]),a=ID(e,[0,.55,1],[.68,1.1,.92]),o=t===`ready`,s=t===`refreshing`;return(0,G.jsx)(q.span,{style:n?void 0:{y:r,rotate:i,scaleY:a},className:`block h-9 w-9 origin-bottom`,children:(0,G.jsxs)(q.svg,{"aria-hidden":`true`,viewBox:`0 0 36 36`,style:{opacity:1},className:`h-full w-full overflow-visible`,animate:s?n?{opacity:[.55,1,.55]}:{y:[0,-2,0],rotate:[-3,3,-3]}:n?{opacity:1}:{y:0,rotate:0,scale:o?1.08:1},transition:s?n?qA:KA:XD,children:[(0,G.jsxs)(q.g,{style:{transformOrigin:`18px 18px`},animate:s&&!n?{rotate:[0,360]}:n?void 0:{rotate:o?0:-35},transition:s?n?qA:KA:XD,className:J(`transition-opacity duration-150`,o||s?`opacity-100`:`opacity-0`),children:[(0,G.jsx)(`path`,{d:`M18 2.5a15.5 15.5 0 0 1 12.7 6.6`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,className:`text-muted-foreground`}),(0,G.jsx)(`circle`,{cx:`31.3`,cy:`10.2`,r:`2.2`,className:`fill-foreground`})]}),(0,G.jsx)(`rect`,{x:`7`,y:`7`,width:`22`,height:`22`,rx:`9`,className:`fill-foreground`}),(0,G.jsxs)(q.g,{style:{opacity:1,transformOrigin:`18px 16px`},animate:s&&!n?{scaleY:[1,1,.15,1,1]}:n?{opacity:1}:{scaleY:o?1.18:1},transition:s&&!n?KA:XD,children:[(0,G.jsx)(`circle`,{cx:`14.2`,cy:`16`,r:`1.45`,className:`fill-background`}),(0,G.jsx)(`circle`,{cx:`21.8`,cy:`16`,r:`1.45`,className:`fill-background`})]}),(0,G.jsx)(`path`,{d:`M14.5 21h7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,className:J(`text-background transition-opacity duration-150`,o||s?`opacity-0`:`opacity-100`)}),(0,G.jsx)(`path`,{d:`M14 20.5c1 2.4 7 2.4 8 0`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,className:J(`text-background transition-opacity duration-150`,o?`opacity-100`:`opacity-0`)}),(0,G.jsx)(`circle`,{cx:`18`,cy:`21`,r:`1.6`,className:J(`fill-background transition-opacity duration-150`,s?`opacity-100`:`opacity-0`)})]})})}function ZA({onRefresh:e,children:t,refreshing:n=!1,disabled:r=!1,threshold:i=76,maxPull:a=132,holdDistance:o=68,pullingLabel:s=`Pull to refresh`,releaseLabel:c=`Release to refresh`,refreshingLabel:l=`Refreshing`,ariaLabel:u=`Refreshable content`,className:d,contentClassName:f,indicatorClassName:p,handleOnly:m=!1,onRefreshError:h}){let g=(0,v.useRef)(null),_=(0,v.useRef)({...GA}),y=(0,v.useRef)(null),b=(0,v.useRef)(`idle`),x=(0,v.useRef)(r),S=(0,v.useRef)(n),C=(0,v.useRef)(n),[w,T]=(0,v.useState)(`idle`),[E,D]=(0,v.useState)(!1),O=RD(),k=Math.max(24,i),A=Math.max(a,k+24),j=Math.min(Math.max(0,o),k),M=PD(0),N=ID(M,[0,k],[0,1]),P=ID(M,[0,10,k],[0,.45,1]),F=ID(M,[0,k],[.86,1]),I=n||E;x.current=r,S.current=n,C.current=I;let ee=(0,v.useCallback)(e=>{b.current!==e&&(b.current=e,T(e))},[]),L=(0,v.useCallback)(e=>{if(y.current?.stop(),O){M.set(e);return}y.current=KD(M,e,Jne)},[O,M]),R=(0,v.useCallback)(e=>{if(x.current||C.current)return;y.current?.stop();let t=YA(e,A);M.set(t),ee(t>=k?`ready`:`pulling`)},[A,k,ee,M]),te=(0,v.useCallback)(async()=>{if(!(x.current||C.current)){C.current=!0,D(!0),ee(`refreshing`),L(j);try{await e()}catch(e){h?.(e)}finally{D(!1),S.current||(C.current=!1,ee(`idle`),L(0))}}},[e,h,j,ee,L]),z=(0,v.useCallback)(e=>!(e instanceof Element)||e.closest(`button, a, input, textarea, select, [contenteditable="true"], [role="button"]`)?!1:!m||!!e.closest(`[data-refresh-handle]`),[m]),ne=(0,v.useCallback)(()=>{_.current={...GA},C.current||(ee(`idle`),L(0))},[ee,L]),re=(0,v.useCallback)(()=>{let e=M.get()>=k&&!x.current&&!C.current;if(_.current={...GA},e){te();return}ee(`idle`),L(0)},[k,te,ee,L,M]);(0,v.useEffect)(()=>{if(I){ee(`refreshing`),L(j);return}b.current===`refreshing`&&(ee(`idle`),L(0))},[I,j,ee,L]),(0,v.useEffect)(()=>{let e=g.current;if(!e)return;let t=t=>{if(t.touches.length!==1||!z(t.target)||e.scrollTop>0||x.current||C.current)return;let n=t.touches[0];_.current={active:!0,startX:n.clientX,startY:n.clientY,pointerId:null}},n=t=>{let n=_.current,r=t.touches[0];if(!n.active||!r)return;let i=r.clientX-n.startX,a=r.clientY-n.startY;if(e.scrollTop>0||a<0){_.current={...GA};return}Math.abs(i)>a||(t.preventDefault(),R(a))},r=()=>{_.current.active&&re()};return e.addEventListener(`touchstart`,t,{passive:!0}),e.addEventListener(`touchmove`,n,{passive:!1}),e.addEventListener(`touchend`,r),e.addEventListener(`touchcancel`,ne),()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchmove`,n),e.removeEventListener(`touchend`,r),e.removeEventListener(`touchcancel`,ne)}},[re,R,z,ne]),(0,v.useEffect)(()=>()=>y.current?.stop(),[]);let ie=e=>{e.pointerType===`touch`||!z(e.target)||e.button!==0||e.currentTarget.scrollTop>0||r||I||(UA(e.currentTarget,e.pointerId),_.current={active:!0,startX:e.clientX,startY:e.clientY,pointerId:e.pointerId})},ae=e=>{let t=_.current;if(!t.active||t.pointerId!==e.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY;r<0||Math.abs(n)>r||(e.preventDefault(),R(r))},oe=w===`refreshing`?l:w===`ready`?c:s;return(0,G.jsxs)(`section`,{ref:g,"aria-label":u,"aria-busy":I,"data-state":w,"data-disabled":r||void 0,onPointerDown:ie,onPointerMove:ae,onPointerUp:e=>{_.current.pointerId===e.pointerId&&re()},onPointerCancel:e=>{_.current.pointerId===e.pointerId&&ne()},className:J(`relative w-full overflow-y-auto overscroll-contain bg-background`,!m&&`[-webkit-touch-callout:none] pointer-coarse:select-none`,w===`pulling`||w===`ready`?`cursor-grabbing select-none`:`cursor-grab`,(r||I)&&`cursor-default`,d),children:[(0,G.jsxs)(q.div,{"aria-live":`polite`,"aria-atomic":`true`,style:O?{opacity:P}:{opacity:P,scale:F},className:J(`pointer-events-none absolute inset-x-0 top-0 z-20 flex h-[4.25rem] flex-col items-center justify-center gap-0.5 bg-gradient-to-b from-background via-background/95 to-transparent text-[11px] font-medium text-muted-foreground`,p),children:[(0,G.jsx)(XA,{progress:N,status:w,reduce:!!O}),(0,G.jsx)(`span`,{className:`relative h-4 min-w-24 text-center`,children:(0,G.jsx)(BE,{initial:!1,mode:`wait`,children:(0,G.jsx)(q.span,{initial:O?{opacity:0}:{opacity:0,y:3},animate:O?{opacity:1}:{opacity:1,y:0},exit:O?{opacity:0}:{opacity:0,y:-3},transition:JA,className:`absolute inset-x-0 whitespace-nowrap`,children:oe},w)})})]}),(0,G.jsx)(q.div,{style:O?void 0:{y:M},className:J(`relative z-10 min-h-full bg-inherit will-change-transform`,f),children:t})]})}function QA({enabled:e,disabled:t=!1,onRefresh:n,children:r}){let i=(0,v.useRef)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),d=async()=>{if(!(i.current||t)){i.current=!0,o(!0),c(``),u(!1);try{await n(),c(`Dashboard data refreshed`)}catch{u(!0),c(`Refresh failed. Previous data kept; try again.`)}finally{i.current=!1,o(!1)}}};return e?(0,G.jsxs)(ZA,{handleOnly:!0,onRefresh:d,refreshing:a,disabled:t,ariaLabel:`Refresh dashboard data`,className:`overflow-visible bg-transparent cursor-default`,contentClassName:`min-h-0`,pullingLabel:`Pull to reload dashboard data`,refreshingLabel:`Reading dashboard data…`,children:[(0,G.jsxs)(`div`,{"data-refresh-handle":!0,className:`mb-4 flex flex-wrap items-center gap-2 rounded-xl border border-dashed border-border px-3 py-2 text-xs text-muted-foreground cursor-grab active:cursor-grabbing`,children:[(0,G.jsx)(uu,{className:`size-4 text-primary`}),(0,G.jsx)(`span`,{className:`flex-1`,children:t?`Resume the feed to refresh`:`Pull down here to refresh · read-only`}),(0,G.jsxs)(nO,{size:`sm`,variant:`ghost`,disabled:a||t,onClick:()=>void d(),children:[(0,G.jsx)(nd,{className:a?`animate-spin motion-reduce:animate-none`:``}),a?`Refreshing…`:`Refresh data`]})]}),s&&(0,G.jsx)(`p`,{role:l?`alert`:`status`,className:`mb-3 text-xs ${l?`text-destructive`:`text-muted-foreground`}`,children:s}),r]}):r}var $A=new Set;function ej(e,t){for(let n of $A)if(n!==e&&n(t))return!0;return!1}function tj(e){let t=e=>{e.preventDefault(),e.stopPropagation(),r()},n=t=>{t!==e&&r()};function r(){window.removeEventListener(`click`,t,!0),window.removeEventListener(`pointerdown`,n,!0),window.removeEventListener(`pointercancel`,n,!0),window.removeEventListener(`keydown`,r,!0)}window.addEventListener(`click`,t,!0),window.addEventListener(`pointerdown`,n,!0),window.addEventListener(`pointercancel`,n,!0),window.addEventListener(`keydown`,r,!0)}function nj(e,t,n,{behavior:r=`pass-through`,escape:i=!0,ignore:a}={}){(0,v.useEffect)(()=>{if(!e)return;let o=e=>!!n?.current?.contains(e)||!!a?.(e),s=e=>{i&&e.key===`Escape`&&t()},c=e=>{let n=e.target;n&&!o(n)&&(r===`consume`&&!ej(o,n)&&tj(e),t())};return $A.add(o),window.addEventListener(`keydown`,s),window.addEventListener(`pointerdown`,c,!0),()=>{$A.delete(o),window.removeEventListener(`keydown`,s),window.removeEventListener(`pointerdown`,c,!0)}},[e,t,n,r,i,a])}function rj(){let e=(0,v.useRef)(new Set);return(0,v.useMemo)(()=>({enter:t=>WA(t)?(e.current.delete(t.pointerId),!0):(e.current.add(t.pointerId),!1),leave:t=>!e.current.delete(t.pointerId)&&t.pointerType!==`touch`}),[])}function ij(){let e=(0,v.useRef)(null);return(0,v.useMemo)(()=>({start:(t,n)=>{e.current={pointerType:t.pointerType,state:n}},take:()=>{let t=e.current;return e.current=null,t},drop:()=>{e.current=null}}),[])}var aj={type:`spring`,stiffness:460,damping:34,mass:.62},oj={type:`spring`,stiffness:380,damping:32,mass:.7},sj={sm:`min-h-9 gap-1 p-1 text-xs`,md:`min-h-11 gap-1.5 p-1.5 text-sm`},cj={sm:`h-7 min-w-7 px-1.5`,md:`h-8 min-w-8 px-2`},lj={sm:`h-3.5 w-3.5`,md:`h-4 w-4`};function uj({expanded:e,defaultExpanded:t,onExpandedChange:n}){let[r,i]=(0,v.useState)(t??!1),a=e!==void 0;return[e??r,(0,v.useCallback)(e=>{a||i(e),n?.(e)},[a,n])]}function dj({items:e,expanded:t,defaultExpanded:n=!1,onExpandedChange:r,activeId:i,onAction:a,size:o=`md`,expandOnHover:s=!0,expandOnFocus:c=!0,collapseDelay:l=90,className:u,classNames:d,renderItem:f}){let p=RD(),m=(0,v.useId)(),[h,g]=uj({expanded:t,defaultExpanded:n,onExpandedChange:r}),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(null),C=(0,v.useRef)(null),w=ij(),T=rj(),E=(0,v.useCallback)(()=>{S.current&&window.clearTimeout(S.current),S.current=null},[]),D=(0,v.useCallback)(()=>{E(),g(!0)},[E,g]),O=(0,v.useCallback)(()=>{E();let e=window.setTimeout(()=>{g(!1),y(null),x(!1)},l);S.current=e},[E,l,g]);(0,v.useEffect)(()=>E,[E]);let k=(0,v.useRef)(h);(0,v.useEffect)(()=>{k.current&&!h&&x(!1),k.current=h},[h]),nj(b&&h,O,C,{behavior:`consume`});let A=e=>{T.enter(e)&&s&&D()},j=e=>{T.leave(e)&&(y(null),s&&O())},M=()=>{c&&D()},N=e=>{!e.currentTarget.contains(e.relatedTarget)&&c&&O()},P=i??e.find(e=>e.active)?.id,F=_??P;return(0,G.jsx)(KE,{id:m,children:(0,G.jsx)(q.div,{layout:`size`,onPointerEnter:A,onPointerLeave:j,onFocus:M,onBlur:N,transition:aj,className:J(`inline-flex max-w-full`,d?.root,u),children:(0,G.jsx)(q.div,{ref:C,layout:`size`,className:J(`scrollbar-hide relative inline-flex max-w-full items-center overflow-x-auto overflow-y-hidden rounded-full border border-border bg-card/90 shadow-2xl backdrop-blur-xl`,sj[o],d?.track),transition:aj,children:e.map(e=>{let t=e.active||i===e.id,n=F===e.id;return(0,G.jsxs)(q.button,{layout:`position`,type:`button`,disabled:e.disabled,title:typeof e.label==`string`?e.label:void 0,"aria-label":typeof e.label==`string`?e.label:void 0,onPointerEnter:t=>{T.enter(t)&&(E(),y(e.id))},onPointerDown:e=>{w.start(e,h)},onPointerCancel:w.drop,onKeyDown:w.drop,onClick:t=>{t.detail>0&&t.currentTarget.blur();let n=w.take();if(n!==null&&n.pointerType!==`mouse`&&!n.state&&!b&&s){x(!0),D(),y(e.id);return}e.onClick?.(),a?.(e)},whileTap:p||e.disabled?void 0:{scale:.96},transition:aj,className:J(`relative isolate inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium text-muted-foreground outline-none transition-[color,background-color] duration-150 ease-out`,`focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-40`,n&&`text-foreground`,cj[o],d?.item,t&&d?.activeItem),children:[n?(0,G.jsx)(q.span,{layoutId:`action-bar-highlight`,className:`absolute inset-0 -z-10 rounded-full bg-primary/[0.07]`,transition:aj}):null,f?f(e,{expanded:h,active:t}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center`,lj[o],d?.icon),children:e.icon}),(0,G.jsx)(q.span,{"aria-hidden":!h,animate:p?{width:h?`auto`:0,opacity:+!!h,marginLeft:h?8:0,x:0,filter:`blur(0px)`}:{width:h?`auto`:0,opacity:+!!h,x:h?0:-4,marginLeft:h?8:0,filter:h?`blur(0px)`:`blur(3px)`},transition:p?{duration:0}:oj,className:J(`inline-block overflow-hidden whitespace-nowrap`,d?.label),children:e.label}),e.shortcut?(0,G.jsx)(q.span,{"aria-hidden":!h,animate:{width:h?`auto`:0,opacity:+!!h,marginLeft:h?4:0},transition:oj,className:J(`hidden overflow-hidden whitespace-nowrap text-[10px] text-muted-foreground sm:inline-block`,d?.shortcut),children:e.shortcut}):null,e.badge?(0,G.jsx)(`span`,{className:J(`ml-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] leading-none text-primary-foreground`,!h&&`absolute right-0.5 top-0.5`,d?.badge),children:e.badge}):null]})]},e.id)})})})})}function fj({paused:e,count:t,onPause:n,onExport:r,onClear:i,onDelete:a}){return(0,G.jsx)(`div`,{role:`group`,"aria-label":`Live Feed actions`,className:`max-w-full`,children:(0,G.jsx)(dj,{size:`sm`,classNames:{track:`rounded-xl shadow-none`,item:`rounded-lg focus-visible:ring-2 focus-visible:ring-ring`},items:[{id:`pause`,label:e?`Resume`:`Pause`,icon:e?(0,G.jsx)(Ju,{}):(0,G.jsx)(Bu,{}),active:e,onClick:n},{id:`csv`,label:`Export CSV`,icon:(0,G.jsx)(eu,{}),badge:t||void 0,onClick:()=>r(`csv`)},{id:`json`,label:`Export JSON`,icon:(0,G.jsx)(Ql,{}),badge:t||void 0,onClick:()=>r(`json`)},{id:`clear`,label:`Clear filters`,icon:(0,G.jsx)(Su,{}),onClick:i},{id:`delete`,label:`Delete selected`,icon:(0,G.jsx)(Kd,{}),badge:t||void 0,disabled:t===0,onClick:a}]})})}var pj={ascii:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],"ascii-line":[`|`,`/`,`-`,`\\`],"ascii-braille":[`⣾`,`⣽`,`⣻`,`⢿`,`⡿`,`⣟`,`⣯`,`⣷`],"ascii-blocks":[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`,`▇`,`▆`,`▅`,`▄`,`▃`,`▂`],"ascii-bounce":[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`]},mj={animate:{opacity:[1,.4,1]},transition:{duration:1.4,ease:JD,repeat:1/0}};function hj({variant:e=`spinner`,size:t=32,speed:n=1,label:r=`Loading`,className:i}){let a=RD()??!1;return(0,G.jsxs)(`span`,{role:`status`,"aria-label":r,className:J(`inline-flex items-center justify-center text-foreground`,i),children:[e===`spinner`&&(0,G.jsx)(gj,{size:t,speed:n,reduce:a}),e===`dots`&&(0,G.jsx)(_j,{size:t,speed:n,reduce:a}),e===`bars`&&(0,G.jsx)(Lj,{size:t,speed:n,reduce:a}),e===`dot-matrix`&&(0,G.jsx)(wre,{size:t,speed:n,reduce:a}),e===`dither`&&(0,G.jsx)(Tre,{size:t,speed:n,reduce:a}),pj[e]&&(0,G.jsx)(vj,{frames:pj[e],size:t,speed:n,reduce:a}),e===`morph`&&(0,G.jsx)(Ej,{size:t,speed:n,reduce:a}),e===`comet`&&(0,G.jsx)(Oj,{size:t,speed:n,reduce:a}),e===`scramble`&&(0,G.jsx)(jj,{size:t,speed:n,reduce:a}),e===`metaballs`&&(0,G.jsx)(Mj,{size:t,speed:n,reduce:a}),e===`newton`&&(0,G.jsx)(Pj,{size:t,speed:n,reduce:a}),e===`helix`&&(0,G.jsx)(Fj,{size:t,speed:n,reduce:a}),e===`percent`&&(0,G.jsx)(Ij,{size:t,speed:n,reduce:a}),(0,G.jsx)(`span`,{className:`sr-only`,children:r})]})}function gj({size:e,speed:t,reduce:n}){let r=Math.max(2,e*.09),i=(e-r)/2;return(0,G.jsxs)(q.svg,{width:e,height:e,viewBox:`0 0 ${e} ${e}`,animate:n?mj.animate:{rotate:360},transition:n?mj.transition:{duration:t,ease:`linear`,repeat:1/0},children:[(0,G.jsx)(`circle`,{cx:e/2,cy:e/2,r:i,fill:`none`,stroke:`currentColor`,strokeOpacity:.2,strokeWidth:r}),(0,G.jsx)(`path`,{d:`M ${e/2} ${e/2-i} A ${i} ${i} 0 0 1 ${e/2+i} ${e/2}`,fill:`none`,stroke:`currentColor`,strokeWidth:r,strokeLinecap:`round`})]})}function _j({size:e,speed:t,reduce:n}){let r=e*.24;return(0,G.jsx)(`span`,{className:`flex items-center`,style:{gap:e*.14},children:[0,1,2].map(i=>(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:r,height:r},animate:n?{opacity:[.4,1,.4]}:{y:[0,-e*.3,0],opacity:[.5,1,.5]},transition:{duration:t,ease:JD,repeat:1/0,delay:i*t*.16}},i))})}function vj({frames:e,size:t,speed:n,reduce:r}){let[i,a]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let t=(r?n*2.5:n)/e.length*1e3,i=setInterval(()=>a(t=>(t+1)%e.length),t);return()=>clearInterval(i)},[e.length,n,r]),(0,G.jsx)(`span`,{className:`font-mono leading-none tabular-nums`,style:{fontSize:t,lineHeight:1},children:e[i%e.length]})}var yj=24;function bj(e,t,n=0){let r=2*Math.PI/t,i=((e-n)%r+r)%r-r/2;return Math.cos(Math.PI/t)/Math.cos(i)}function xj(e){let t=[];for(let n=0;n<yj;n++){let r=n/yj*2*Math.PI-Math.PI/2,i=Math.min(1.05,e(r)),a=(50+Math.cos(r)*46*i).toFixed(2),o=(50+Math.sin(r)*46*i).toFixed(2);t.push(`${n===0?`M`:`L`}${a} ${o}`)}return`${t.join(` `)} Z`}var Sj=[xj(()=>1),xj(e=>bj(e,4,Math.PI/4)),xj(e=>bj(e,3)),xj(e=>bj(e,6)),xj(e=>bj(e,4))],Cj=[...Sj.flatMap(e=>[e,e]),Sj[0]],wj=[0,0,72,72,144,144,216,216,288,288,360],Tj=[1,1,.88,.88,1,1,.88,.88,1,1,1];function Ej({size:e,speed:t,reduce:n}){return(0,G.jsxs)(q.svg,{width:e,height:e,viewBox:`0 0 100 100`,role:`img`,animate:n?{opacity:[1,.4,1]}:{rotate:wj,scale:Tj},transition:n?{duration:1.4,ease:JD,repeat:1/0}:{duration:t*5,ease:JD,repeat:1/0},children:[(0,G.jsx)(`title`,{children:`Loading`}),(0,G.jsx)(q.path,{fill:`currentColor`,d:Sj[0],animate:n?void 0:{d:Cj},transition:n?void 0:{duration:t*5,ease:JD,repeat:1/0}})]})}var Dj=[0,1,2,3,4,5];function Oj({size:e,speed:t,reduce:n}){let r=e*.2,i=e/2-r/2;return(0,G.jsx)(`span`,{className:`relative`,style:{width:e,height:e},children:(0,G.jsx)(q.span,{className:`absolute inset-0`,animate:n?mj.animate:{rotate:360},transition:n?mj.transition:{duration:t,ease:`linear`,repeat:1/0},children:Dj.map(e=>{let t=1-e*.13,n=r*t;return(0,G.jsx)(`span`,{className:`absolute top-1/2 left-1/2 rounded-full bg-current`,style:{width:n,height:n,marginLeft:-n/2,marginTop:-n/2,opacity:1-e*.16,transform:`rotate(${-e*15}deg) translateY(${-i}px)`}},e)})})})}var kj=`LOADING`,Aj=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>/*#@`;function jj({size:e,speed:t,reduce:n}){let[r,i]=(0,v.useState)(kj);return(0,v.useEffect)(()=>{if(n){i(kj);return}let e=0,r=setInterval(()=>{let t=e%11,n=``;for(let e=0;e<7;e++)n+=e<t?kj[e]:Aj[Math.floor(Math.random()*42)];i(n),e++},t/7*1e3*.55);return()=>clearInterval(r)},[t,n]),(0,G.jsx)(`span`,{className:`font-mono font-medium tracking-[0.2em] tabular-nums`,style:{fontSize:e*.42},children:r})}function Mj({size:e,speed:t,reduce:n}){let r=(0,v.useId)().replace(/:/g,``);return(0,G.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 100 100`,role:`img`,children:[(0,G.jsx)(`title`,{children:`Loading`}),(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`filter`,{id:r,children:[(0,G.jsx)(`feGaussianBlur`,{in:`SourceGraphic`,stdDeviation:`5`,result:`b`}),(0,G.jsx)(`feColorMatrix`,{in:`b`,values:`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8`})]})}),(0,G.jsxs)(`g`,{filter:`url(#${r})`,fill:`currentColor`,children:[(0,G.jsx)(q.circle,{cy:`50`,r:`15`,animate:n?{opacity:[.4,1,.4]}:{cx:[30,70,30]},transition:{duration:t*1.6,ease:JD,repeat:1/0},cx:n?40:30}),(0,G.jsx)(q.circle,{cy:`50`,r:`15`,animate:n?{opacity:[.4,1,.4]}:{cx:[70,30,70]},transition:{duration:t*1.6,ease:JD,repeat:1/0},cx:n?60:70})]})]})}var Nj=[0,1,2,3,4];function Pj({size:e,speed:t,reduce:n}){let r=e*.2,i=r*1.1,a={0:{x:[0,-i,0,0],times:[0,.28,.5,1]},4:{x:[0,0,i,0],times:[0,.5,.78,1]}};return(0,G.jsx)(`span`,{className:`flex items-center justify-center`,style:{height:r},children:Nj.map(e=>{let i=a[e];return(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:r,height:r},animate:n||!i?void 0:{x:i.x},transition:n||!i?void 0:{duration:t*1.5,ease:JD,repeat:1/0,times:i.times}},e)})})}function Fj({size:e,speed:t,reduce:n}){let r=e*.14,i=e*.32;return(0,G.jsx)(`span`,{className:`relative`,style:{width:e,height:e},children:Array.from({length:7},(a,o)=>{let s=o/6*(e-r),c=o/7*t;return(0,G.jsxs)(`span`,{children:[(0,G.jsx)(q.span,{className:`absolute rounded-full bg-current`,style:{width:r,height:r,left:e/2-r/2,top:s},animate:n?{opacity:[.4,1,.4]}:{x:[i,-i,i],scale:[1,.5,1],opacity:[1,.45,1]},transition:{duration:t,ease:JD,repeat:1/0,delay:c}}),(0,G.jsx)(q.span,{className:`absolute rounded-full bg-current`,style:{width:r,height:r,left:e/2-r/2,top:s},animate:n?{opacity:[.4,1,.4]}:{x:[-i,i,-i],scale:[.5,1,.5],opacity:[.45,1,.45]},transition:{duration:t,ease:JD,repeat:1/0,delay:c}})]},`row-${s}`)})})}function Ij({size:e,speed:t,reduce:n}){let[r,i]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let e=(n?t*2:t)*1e3,r={t:0},a=setInterval(()=>{r.t+=40;let t=Math.min(100,Math.round(r.t/e*100));i(t),t>=100&&(r.t=0)},40);return()=>clearInterval(a)},[t,n]),(0,G.jsxs)(`span`,{className:`flex flex-col items-center`,style:{gap:e*.14,width:e*1.4},children:[(0,G.jsxs)(`span`,{className:`font-mono font-medium tabular-nums`,style:{fontSize:e*.42,lineHeight:1},children:[r,`%`]}),(0,G.jsx)(`span`,{className:`w-full overflow-hidden rounded-full bg-current/15`,style:{height:Math.max(3,e*.1)},children:(0,G.jsx)(`span`,{className:`block h-full rounded-full bg-current`,style:{width:`${r}%`}})})]})}function Lj({size:e,speed:t,reduce:n}){let r=e*.16;return(0,G.jsx)(`span`,{className:`flex items-center`,style:{gap:e*.1,height:e},children:[0,1,2,3].map(i=>(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:r,height:e,originY:1},animate:n?{opacity:[.4,1,.4]}:{scaleY:[.3,1,.3]},transition:{duration:t,ease:JD,repeat:1/0,delay:i*t*.12}},i))})}function wre({size:e,speed:t,reduce:n}){let r=e*.14,i=(e-r*2)/3,a=Array.from({length:9},(e,t)=>t);return(0,G.jsx)(`span`,{className:`grid`,style:{gap:r,gridTemplateColumns:`repeat(3, ${i}px)`},children:a.map(e=>{let r=(e%3+Math.floor(e/3))/4*t;return(0,G.jsx)(q.span,{className:`rounded-full bg-current`,style:{width:i,height:i},animate:n?{opacity:[.3,1,.3]}:{opacity:[.2,1,.2],scale:[.7,1,.7]},transition:{duration:t,ease:JD,repeat:1/0,delay:r}},e)})})}var Rj=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function Tre({size:e,speed:t,reduce:n}){let r=Math.max(1,e*.05),i=(e-r*3)/4;return(0,G.jsx)(`span`,{className:`grid`,style:{gap:r,gridTemplateColumns:`repeat(4, ${i}px)`},children:Rj.map((e,r)=>(0,G.jsx)(q.span,{className:`bg-current`,style:{width:i,height:i},animate:n?{opacity:[.3,1,.3]}:{opacity:[.1,1,.1]},transition:{duration:t,ease:JD,repeat:1/0,delay:e/Rj.length*t}},r))})}var Ere=Z_(`relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current`}},defaultVariants:{variant:`default`}});function Dre({className:e,variant:t,...n}){return(0,G.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:K(Ere({variant:t}),e),...n})}function Ore({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`alert-description`,className:K(`col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed`,e),...t})}var zj=Z_(`inline-flex 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-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function Bj({className:e,variant:t=`default`,asChild:n=!1,...r}){return n?(0,G.jsx)(bf,{className:K(zj({variant:t}),e),...r}):(0,G.jsx)(nA,{status:t===`destructive`?`danger`:t==="default"?`info`:`neutral`,size:`sm`,showIcon:!1,"data-slot":`badge`,"data-variant":t,className:K(zj({variant:t}),e),...r})}var Vj={duration:0},kre={type:`spring`,duration:.4,bounce:.3},Are={hidden:{},show:{transition:{staggerChildren:.035,delayChildren:.05}}},jre={hidden:{opacity:0,y:-6,filter:`blur(3px)`},show:{opacity:1,y:0,filter:`blur(0px)`}},Hj=(0,v.createContext)(null);function Uj(e){let t=(0,v.useContext)(Hj);if(!t)throw Error(`${e} must be used within <Select>`);return t}function Mre({value:e,defaultValue:t,onValueChange:n,open:r,defaultOpen:i=!1,onOpenChange:a,disabled:o=!1,className:s,children:c}){let l=RD()??!1,u=(0,v.useId)(),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),[m,h]=(0,v.useState)(`${u}-trigger`),[g,_]=(0,v.useState)(i),[y,b]=(0,v.useState)(t),[x,S]=(0,v.useState)(new Map),[C,w]=(0,v.useState)(`bottom`),T=e!==void 0,E=T?e:y,D=r!==void 0,O=!o&&(D?r:g),k=(0,v.useCallback)(e=>{D||_(e),a?.(e)},[a,D]),A=(0,v.useCallback)(e=>{T||b(e),n?.(e),k(!1),f.current?.focus({preventScroll:!0})},[T,n,k]),j=(0,v.useCallback)((e,t)=>{S(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),M=(0,v.useCallback)(e=>{S(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]);(0,v.useEffect)(()=>{if(!O)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),k(!1),f.current?.focus())},t=e=>{d.current&&!d.current.contains(e.target)&&!p.current?.contains(e.target)&&k(!1)};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`pointerdown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`pointerdown`,t)}},[O,k]);let N=(0,v.useMemo)(()=>({value:E,open:O,setOpen:k,select:A,register:j,unregister:M,labelFor:e=>e===void 0?void 0:x.get(e),reduce:l,triggerId:m,setTriggerId:h,triggerRef:f,contentRef:p,listId:`${u}-list`,disabled:o,placement:C,setPlacement:w}),[E,O,k,A,j,M,x,l,u,m,o,C]);return(0,G.jsx)(Hj.Provider,{value:N,children:(0,G.jsx)(`div`,{ref:d,className:J(`relative`,s),children:c})})}function Nre({className:e,children:t,id:n,onClick:r,onKeyDown:i,ref:a,...o}){let s=Uj(`SelectTrigger`);(0,v.useLayoutEffect)(()=>{n&&s.setTriggerId(n)},[n,s.setTriggerId]);let c=s.placement===`top`,l=s.open?[0,0,12]:[12,0,12],u=s.reduce?{duration:0}:s.open?{duration:.6,times:[0,.4,1],ease:qD}:{duration:.42,times:[0,.5,1],ease:qD};return(0,G.jsxs)(q.button,{...o,ref:e=>{s.triggerRef.current=e,typeof a==`function`?a(e):a&&(a.current=e)},role:`combobox`,type:`button`,id:s.triggerId,disabled:s.disabled,"aria-haspopup":`listbox`,"aria-expanded":s.open,"aria-controls":s.listId,onClick:e=>{r?.(e),e.defaultPrevented||s.setOpen(!s.open)},onKeyDown:e=>{i?.(e),!e.defaultPrevented&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&(e.preventDefault(),s.setOpen(!0))},initial:!1,animate:{borderTopLeftRadius:c?l:12,borderTopRightRadius:c?l:12,borderBottomLeftRadius:c?12:l,borderBottomRightRadius:c?12:l},transition:{borderTopLeftRadius:c?u:Vj,borderTopRightRadius:c?u:Vj,borderBottomLeftRadius:c?Vj:u,borderBottomRightRadius:c?Vj:u},className:J(`relative z-10 flex w-full items-center justify-between gap-2 rounded-xl border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors`,`hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20`,`disabled:pointer-events-none disabled:opacity-50`,e),children:[t,(0,G.jsx)(q.span,{"aria-hidden":!0,animate:{rotate:s.open?180:0},transition:s.reduce?{duration:0}:kre,className:`text-muted-foreground`,children:(0,G.jsx)(ul,{className:`h-4 w-4`})})]})}function Wj({placeholder:e,className:t,children:n}){let r=Uj(`SelectValue`),i=r.labelFor(r.value);return(0,G.jsx)(`span`,{className:J(i?`text-foreground`:`text-muted-foreground`,t),children:n??i??e??`Select`})}function Pre({className:e,children:t}){let n=Uj(`SelectContent`),r=(0,v.useRef)(null),[i,a]=(0,v.useState)(0),o=n.open,{setPlacement:s}=n,[c,l]=(0,v.useState)({left:0,top:0,width:0,maxHeight:300}),u=(0,v.useRef)({text:``,at:0}),[d,f]=(0,v.useState)(null);(0,v.useLayoutEffect)(()=>{f(n.triggerRef.current?.closest(`[role="dialog"], [role="alertdialog"]`)??document.body)},[n.triggerRef]),(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.offsetHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[d]),(0,v.useLayoutEffect)(()=>{if(!o)return;let e=n.triggerRef.current,t=r.current;if(!e||!t)return;let i=()=>{let n=e.getBoundingClientRect(),r=d===document.body?null:d,i=r?.getBoundingClientRect(),a=Math.min(window.innerHeight,i?.bottom??window.innerHeight)-n.bottom,o=n.top-Math.max(0,i?.top??0),c=Math.max(8,(i?.left??0)+8),u=Math.min(window.innerWidth-8,(i?.right??window.innerWidth)-8),f=Math.max(0,u-c);t.style.maxWidth=`${f}px`,t.style.minWidth=`${Math.min(n.width,f)}px`;let p=Math.min(f,Math.max(n.width,t.offsetWidth+2)),m=a<Math.min(t.offsetHeight,300)+16&&o>a;s(m?`top`:`bottom`),l({left:Math.max(c,Math.min(n.left,u-p))-(i?.left??0)+(r?.scrollLeft??0),top:r?(m?n.top:n.bottom)-(i?.top??0)+r.scrollTop:m?window.innerHeight-n.top:n.bottom,width:p,maxHeight:Math.max(60,Math.min(300,(m?o:a)-24))})};i(),(t.querySelector(`[role="option"][aria-selected="true"]:not(:disabled)`)??t.querySelector(`[role="option"]:not(:disabled)`))?.focus({preventScroll:!0});let a=new ResizeObserver(i);return a.observe(t),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,i,!0),()=>{a.disconnect(),window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,i,!0)}},[o,n.triggerRef,s,d]);let p=n.placement===`top`,m=o?8:0,h=o?12:0,g=o?{type:`spring`,duration:.6,bounce:.5,delay:.12}:{type:`spring`,duration:.3,bounce:.1},_=o?{duration:.3,ease:qD,delay:.14}:{duration:.16,ease:qD};if(!d)return null;let y=d!==document.body;return(0,Ff.createPortal)((0,G.jsx)(q.div,{ref:n.contentRef,id:n.listId,role:`listbox`,"aria-labelledby":n.triggerId,"aria-hidden":!o,inert:!o,onKeyDown:e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role="option"]:not(:disabled)`)),r=t.indexOf(document.activeElement);if(e.key===`Tab`){n.setOpen(!1),n.triggerRef.current?.focus();return}let i;if(e.key===`ArrowDown`)i=t[(r+1)%t.length];else if(e.key===`ArrowUp`)i=t[(r-1+t.length)%t.length];else if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t.at(-1);else if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&e.key!==` `){let n=Date.now();u.current={text:(n-u.current.at<700?u.current.text:``)+e.key.toLowerCase(),at:n},i=t.find(e=>e.textContent?.trim().toLowerCase().startsWith(u.current.text))}i&&(e.preventDefault(),i.focus())},initial:!1,animate:n.reduce?{opacity:+!!o,height:o?i:0}:{opacity:+!!o,height:o?i:0,marginTop:p?0:m,marginBottom:p?m:0,borderTopLeftRadius:p?12:h,borderTopRightRadius:p?12:h,borderBottomLeftRadius:p?h:12,borderBottomRightRadius:p?h:12},transition:n.reduce?{duration:.12}:{opacity:o?{duration:.18}:{duration:.16,delay:.12},height:o?{type:`spring`,duration:.42,bounce:.14}:{duration:.26,ease:qD,delay:.14},marginTop:p?Vj:g,marginBottom:p?g:Vj,borderTopLeftRadius:p?Vj:_,borderTopRightRadius:p?Vj:_,borderBottomLeftRadius:p?_:Vj,borderBottomRightRadius:p?_:Vj},style:{position:y?`absolute`:`fixed`,left:c.left,width:c.width,zIndex:80,top:y||!p?c.top:`auto`,bottom:!y&&p?c.top:`auto`,translate:y&&p?`0 -100%`:void 0,transformOrigin:p?`bottom`:`top`,overflow:`hidden`,pointerEvents:o?`auto`:`none`},className:J(`rounded-xl border border-border bg-popover text-popover-foreground shadow-xl`,e),children:(0,G.jsx)(q.div,{ref:r,variants:n.reduce?void 0:Are,initial:!1,animate:o?`show`:`hidden`,className:`grid w-max gap-1.5 overflow-y-auto overscroll-contain p-1.5`,style:{maxHeight:c.maxHeight},children:t})}),d)}function Gj({value:e,disabled:t=!1,className:n,children:r,textValue:i}){let a=Uj(`SelectItem`),o=a.value===e,s=i??r;return(0,v.useLayoutEffect)(()=>(a.register(e,s),()=>a.unregister(e)),[a.register,a.unregister,e,s]),(0,G.jsx)(q.div,{role:`presentation`,variants:a.reduce?void 0:jre,children:(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":o,disabled:t,onClick:()=>a.select(e),className:J(`flex min-h-9 w-full items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left text-[13px] leading-5 outline-none transition-colors duration-150`,o?`border-primary/25 bg-primary/12 text-foreground`:`border-transparent text-foreground/80`,`hover:border-primary/45 hover:bg-primary/25 hover:text-foreground focus-visible:border-primary/60 focus-visible:bg-primary/25 focus-visible:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`,n),children:[(0,G.jsx)(`span`,{className:`min-w-0 whitespace-normal [overflow-wrap:anywhere]`,children:r}),(0,G.jsx)(cl,{"aria-hidden":`true`,className:J(`h-3.5 w-3.5 shrink-0`,!o&&`invisible`)})]})})}function Kj(e){return(0,G.jsx)(Mre,{...e})}function qj({className:e,size:t=`default`,...n}){return(0,G.jsx)(Nre,{...n,"data-slot":`select-trigger`,"data-size":t,className:K(`min-w-0 shadow-xs`,t===`sm`?`h-8`:`h-9`,e)})}function Jj({position:e,align:t,...n}){return(0,G.jsx)(Pre,{...n})}var Fre={default:`default`,secondary:`secondary`,error:`destructive`,success:`ghost`,warning:`ghost`,accent:`ghost`},Ire={default:``,secondary:``,error:``,success:`bg-success text-white hover:bg-success/90`,warning:`bg-warning text-white hover:bg-warning/90`,accent:`bg-brand text-brand-foreground hover:bg-brand/90`},Lre={default:`border bg-transparent text-foreground hover:bg-accent`,secondary:`border bg-transparent text-muted-foreground hover:bg-accent`,error:`border border-destructive/40 bg-transparent text-destructive hover:bg-destructive/10`,success:`border border-success/40 bg-transparent text-success hover:bg-success/10`,warning:`border border-warning/40 bg-transparent text-warning hover:bg-warning/10`,accent:`border border-brand/40 bg-transparent text-brand hover:bg-brand/10`};function Z({type:e=`default`,size:t=`md`,ghost:n=!1,loading:r=!1,icon:i,className:a,children:o,disabled:s,...c}){return(0,G.jsxs)(nO,{type:`button`,variant:n?`ghost`:Fre[e],size:t===`sm`?`sm`:`default`,className:K(n?Lre[e]:Ire[e],a),disabled:s||r,...c,children:[r?(0,G.jsx)(Qj,{small:!0}):i,o!=null&&(0,G.jsx)(`span`,{className:`inline-flex items-center gap-1.5`,children:o})]})}var Rre={default:``,secondary:`text-muted-foreground`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,error:`border-destructive/40 text-destructive`,accent:`border-brand/40 text-brand`};function Yj({type:e=`default`,label:t,children:n,className:r}){let i=t===!1?null:t??e;return(0,G.jsx)(Dre,{role:`note`,className:K(Rre[e],r),children:(0,G.jsxs)(Ore,{className:`text-current`,children:[i!=null&&(0,G.jsxs)(`b`,{className:`font-semibold`,children:[i,`:`]}),` `,n]})})}var zre={default:`default`,secondary:`secondary`,error:`destructive`,success:`outline`,warning:`outline`,accent:`outline`},Bre={default:``,secondary:``,error:``,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,accent:`border-brand/40 text-brand`};function Xj({type:e=`default`,children:t,className:n}){return(0,G.jsx)(Bj,{variant:zre[e],className:K(`font-mono`,Bre[e],n),children:t})}var Vre={default:`bg-muted-foreground`,secondary:`bg-muted-foreground/60`,success:`bg-success`,warning:`bg-warning`,error:`bg-destructive`,accent:`bg-brand`};function Zj({type:e=`default`,pulse:t=!1,color:n,className:r}){return(0,G.jsx)(`span`,{className:K(`inline-block size-2 shrink-0 rounded-full`,!n&&Vre[e],t&&`animate-pulse`,r),style:n?{background:n}:void 0})}function Qj({small:e=!1}){return(0,G.jsx)(hj,{variant:`spinner`,size:e?12:16,label:`Loading`,className:`text-current`})}function $j({className:e,...t}){return(0,G.jsx)(Ok,{className:K(`font-mono`,e),...t})}var eM=`\0empty`,tM=e=>e===``?eM:e,Hre=e=>e===eM?``:e;function nM({value:e,onValueChange:t,options:n,placeholder:r,className:i,disabled:a,size:o=`md`,"aria-label":s}){return(0,G.jsxs)(Kj,{value:tM(e),onValueChange:e=>t(Hre(e)),disabled:a,children:[(0,G.jsx)(qj,{size:o===`sm`?`sm`:`default`,"aria-label":s,className:K(`font-mono`,i),children:(0,G.jsx)(Wj,{placeholder:r})}),(0,G.jsx)(Jj,{children:n.map(e=>(0,G.jsx)(Gj,{value:tM(e.value),className:`font-mono`,children:e.label},e.value))})]})}function rM({children:e,className:t,hoverable:n=!1}){return(0,G.jsx)(rk,{className:K(`gap-0 py-0`,n&&`transition-colors hover:border-brand/40`,t),children:e})}function Ure(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)({show_sensitive:!1,verbose:!1,compact:!1,terse:!1}),C=(0,v.useRef)(null),w=(0,v.useCallback)(()=>{U(`/api/backups`).then(e=>{t(e),p(t=>t||e.devices[0]||``)}).catch(()=>t({dir:``,devices:[],backups:[]}))},[]);(0,v.useEffect)(()=>w(),[w]);let T=(e,t)=>_c(e,t).catch(()=>({error:`request failed`})),E=async()=>{a(!0),r(`Capturing /export…`);let e=await _c(`/api/backups/create`,{device:f||void 0,label:y.trim()||void 0,show_sensitive:x.show_sensitive,verbose:x.verbose,compact:!x.verbose&&x.compact,terse:x.terse}).catch(()=>({error:`request failed`}));a(!1),r(e.ok?`Created ${e.name} (${e.bytes} bytes)`:`Create failed: ${e.error}`),e.ok?(Y.success(`Backup created`),w()):Y.error(`Create failed: ${e.error}`)},D=e=>S(t=>({...t,[e]:!t[e]})),O=async e=>{let t=await e.text(),n=await T(`/api/backups/upload`,{name:e.name,content:t});r(n.ok?`Uploaded ${n.name}`:`Upload failed: ${n.error}`),n.ok?(Y.success(`Backup uploaded`),w()):Y.error(`Upload failed: ${n.error}`)},k=async e=>{s(null);let t=await T(`/api/backups/delete`,{name:e});r(t.ok?`Deleted ${e}`:`Delete failed: ${t.error}`),t.ok?(Y.success(`Backup deleted`),w()):Y.error(`Delete failed: ${t.error}`)},A=async()=>{if(!u)return;let{name:e,value:t}=u;if(d(null),!t||t===e)return;let n=await T(`/api/backups/rename`,{name:e,new_name:t});r(n.ok?`Renamed to ${n.name}`:`Rename failed: ${n.error}`),n.ok?(Y.success(`Backup renamed`),w()):Y.error(`Rename failed: ${n.error}`)},j=async e=>{if(!c)return;a(!0),r(e?`Restoring in Safe Mode…`:`Dry-run restore in Safe Mode…`);let t=await _c(`/api/backups/restore`,{name:c,device:f||void 0,confirm:e}).catch(()=>({ok:!1,message:`request failed`}));a(!1),r(t.ok?t.committed?`Restored ${c} → ${f}: ${t.message}`:`Dry-run OK (${t.applied} cmds, rolled back). Click “Restore (commit)” to apply for real.`:`Restore failed: ${t.message}`),t.ok?Y.success(t.committed?`Backup restored`:`Dry-run restore OK`):Y.error(`Restore failed: ${t.message}`),t.ok&&e&&l(null)},M=e=>{U(`/api/backups/get?name=${encodeURIComponent(e)}`).then(h).catch(()=>{})},N=async()=>{if(g===null)return;let t=g.trim();if(!t||t===e?.dir){_(null);return}a(!0);let n=await _c(`/api/backups/dir`,{dir:t}).catch(()=>({error:`request failed`}));a(!1),_(null),n.ok?(r(n.persisted?`Backup path saved → ${n.dir}`:n.warning??`Path applied → ${n.dir}`),Y.success(`Backup directory updated`)):(r(`Path change failed: ${n.error}`),Y.error(`Path change failed: ${n.error}`)),n.ok&&w()};if(!e)return(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading backups…`});let P=e.devices.length===0?[{value:``,label:`no devices`}]:e.devices.map(e=>({value:e,label:e}));return(0,G.jsxs)(`section`,{className:`grid content-start gap-[18px]`,children:[(0,G.jsxs)(X,{title:`Local backup vault`,className:`reveal`,extra:g===null?(0,G.jsxs)(`span`,{className:`inline-flex max-w-[min(60vw,520px)] items-center gap-2 text-muted-foreground text-[11px]`,children:[(0,G.jsx)(`span`,{className:`truncate`,title:e.dir,children:e.dir}),(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 whitespace-nowrap text-brand hover:underline`,title:`Change backup directory`,onClick:()=>_(e.dir),children:[(0,G.jsx)(Hu,{className:`size-3`}),` edit path`]})]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)($j,{className:`w-[min(48vw,380px)] text-xs`,value:g,autoFocus:!0,spellCheck:!1,placeholder:`~/.mikrotik-mcp/backups`,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N(),e.key===`Escape`&&_(null)}}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,onClick:()=>void N(),disabled:i,children:`Save path`}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>_(null),children:`Cancel`})]}),children:[n&&(0,G.jsx)(`div`,{className:`mb-3 font-mono text-xs text-muted-foreground`,children:n}),(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(nM,{value:f,onValueChange:p,"aria-label":`Device`,options:P}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,icon:(0,G.jsx)(Xu,{}),onClick:()=>void E(),disabled:i||!f,children:`Create backup`}),(0,G.jsx)(Z,{size:`sm`,icon:(0,G.jsx)(ef,{}),onClick:()=>C.current?.click(),children:`Upload .rsc`}),(0,G.jsx)(`input`,{ref:C,type:`file`,accept:`.rsc,text/plain`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&O(t),e.currentTarget.value=``}}),(0,G.jsx)(Z,{size:`sm`,icon:(0,G.jsx)(nd,{}),onClick:w,children:`Refresh`})]}),(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2.5`,children:[(0,G.jsx)($j,{className:`max-w-[200px] text-xs`,value:y,spellCheck:!1,placeholder:`label (optional), e.g. pre-upgrade`,onChange:e=>b(e.target.value)}),[[`show_sensitive`,`show-sensitive`,`Include secrets (keys/passwords)`],[`verbose`,`verbose`,`Include every parameter, even defaults`],[`compact`,`compact`,`Only non-default values (ignored if verbose)`],[`terse`,`terse`,`One machine-readable line per item`]].map(([e,t,n])=>{let r=e===`compact`&&x.verbose;return(0,G.jsxs)(`label`,{className:K(`inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 py-1.5 font-mono text-[11px] select-none`,x[e]?`border-brand/55 bg-brand/10 text-foreground`:`border-border bg-muted/40 text-muted-foreground`,r&&`cursor-not-allowed opacity-45`),title:n,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`accent-brand`,checked:x[e],disabled:r,onChange:()=>D(e)}),t]},e)})]}),c&&(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-warning/45 bg-warning/10 px-3 py-2.5 text-xs`,children:[(0,G.jsxs)(`strong`,{children:[`Restore `,c]}),` onto`,` `,(0,G.jsx)(nM,{value:f,onValueChange:p,size:`sm`,"aria-label":`Restore target device`,options:e.devices.map(e=>({value:e,label:e}))}),` `,`via Safe Mode (auto-reverts on lock-out).`,(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>void j(!1),disabled:i,children:`Dry-run`}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,onClick:()=>void j(!0),disabled:i,children:`Restore (commit)`}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,onClick:()=>l(null),children:`Cancel`})]}),e.backups.length===0?(0,G.jsx)(`div`,{className:`p-3 text-muted-foreground text-[11px]`,children:"No backups yet. Click “Create backup” to capture this device’s config, or upload a `.rsc`."}):(0,G.jsx)(`div`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border`,children:(0,G.jsxs)(ZO,{className:`min-w-[980px] table-fixed`,children:[(0,G.jsx)(QO,{className:`bg-card sticky top-0 z-10`,children:(0,G.jsxs)(ek,{children:[(0,G.jsx)(tk,{children:`name`}),(0,G.jsx)(tk,{className:`w-[130px]`,children:`device`}),(0,G.jsx)(tk,{className:`w-[90px] text-right`,children:`size`}),(0,G.jsx)(tk,{className:`w-[170px]`,children:`captured`}),(0,G.jsx)(tk,{className:`w-[380px]`,children:`actions`})]})}),(0,G.jsx)($O,{children:e.backups.map(e=>(0,G.jsxs)(ek,{"data-state":m?.name===e.name?`selected`:void 0,children:[(0,G.jsx)(nk,{className:`truncate font-mono`,title:e.name,children:e.name}),(0,G.jsx)(nk,{className:`truncate`,children:e.device??`—`}),(0,G.jsx)(nk,{className:`text-right tabular-nums`,children:Vk(e.bytes)}),(0,G.jsx)(nk,{className:`tabular-nums whitespace-nowrap`,children:new Date(e.modified).toLocaleString(void 0,{hour12:!1})}),(0,G.jsx)(nk,{onClick:e=>e.stopPropagation(),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Z,{size:`sm`,onClick:()=>M(e.name),children:`view`}),(0,G.jsx)(`a`,{className:`inline-flex items-center rounded-md border border-border px-2 py-1 text-xs hover:bg-accent`,href:gc(`/api/backups/raw?name=${encodeURIComponent(e.name)}`),download:e.name,title:`Download`,children:(0,G.jsx)(Hl,{className:`size-3.5`})}),u?.name===e.name?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)($j,{className:`inline-block w-[120px] text-xs`,value:u.value,autoFocus:!0,onChange:t=>d({name:e.name,value:t.target.value}),onKeyDown:e=>e.key===`Enter`&&void A()}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,icon:(0,G.jsx)(cl,{}),onClick:()=>void A()}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,icon:(0,G.jsx)(df,{}),onClick:()=>d(null)})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{size:`sm`,onClick:()=>d({name:e.name,value:e.name}),children:`rename`}),(0,G.jsx)(Z,{type:`accent`,size:`sm`,onClick:()=>l(e.name),children:`restore`})]}),o===e.name?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{type:`error`,size:`sm`,ghost:!0,icon:(0,G.jsx)(cl,{}),onClick:()=>void k(e.name)}),(0,G.jsx)(Z,{type:`secondary`,size:`sm`,ghost:!0,icon:(0,G.jsx)(df,{}),onClick:()=>s(null)})]}):(0,G.jsx)(Z,{type:`error`,size:`sm`,ghost:!0,icon:(0,G.jsx)(Kd,{}),onClick:()=>s(e.name)})]})})]},e.name))})]})})]}),m&&(0,G.jsx)(X,{title:`Backup · ${m.name}`,className:`reveal`,extra:(0,G.jsx)(Z,{type:`secondary`,size:`sm`,icon:(0,G.jsx)(df,{}),onClick:()=>h(null),children:`Close`}),children:(0,G.jsx)(`pre`,{className:`m-0 overflow-auto rounded border border-border bg-background p-3 font-mono text-xs break-words whitespace-pre-wrap`,style:{maxHeight:460},children:m.content||`(empty)`})})]})}var iM=`http://www.w3.org/2000/svg`,aM=864e5,oM=e=>new Date(e).toISOString().slice(0,10);function sM(){let e=new Date;return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function Wre(e){return new Date(`${e}T00:00:00Z`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:`numeric`,timeZone:`UTC`})}function cM({endpoint:e,days:t=90}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!0,n,i=new AbortController;r(null),a(!0);let o=()=>{U(e,i.signal).then(e=>{t&&(r(e),s(!1))}).catch(()=>{t&&(r(null),s(!0))}).finally(()=>{t&&(a(!1),n=setTimeout(o,3e4))})};return o(),()=>{t=!1,i.abort(),clearTimeout(n)}},[e]);let c=(0,v.useMemo)(()=>{let e=new Map((n?.series??[]).map(e=>[e.day,e])),r=sM(),i=[];for(let n=t-1;n>=0;n--){let t=oM(r-n*aM),a=e.get(t);i.push(a??{day:t,rx:0,tx:0})}return i},[n,t]);if(i)return(0,G.jsx)(`div`,{className:`px-1 py-4 text-[12.5px] text-muted-foreground`,children:`loading usage…`});if(o)return(0,G.jsx)(`div`,{role:`status`,className:`px-1 py-4 text-[12.5px] text-destructive`,children:`Could not load usage history. Retrying automatically.`});if(!((n?.series.length??0)>0))return(0,G.jsx)(`div`,{className:`px-1 py-4 text-[12.5px] text-muted-foreground`,children:`No measured history yet. Client history needs two samples from an existing per-device counter (normally one minute apart). This chart refreshes automatically. Past usage before recording began cannot be reconstructed; retention is about three months.`});let l=Math.max(0,...c.flatMap(e=>[e.rx,e.tx])),u=Math.max(1,l),d=e=>8+e*624/Math.max(1,c.length-1),f=e=>142-e/u*134,p=e=>c.map((t,n)=>`${d(n).toFixed(1)},${f(e(t)).toFixed(1)}`).join(` `),m=e=>{let t=d(0).toFixed(1),n=d(c.length-1).toFixed(1);return`${t},${142 .toFixed(1)} ${p(e)} ${n},${142 .toFixed(1)}`};return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline gap-3.5 text-xs tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`font-semibold text-chart-3`,children:[`↓ `,Vk(n?.totalRx??0),` down`]}),(0,G.jsxs)(`span`,{className:`font-semibold text-chart-4`,children:[`↑ `,Vk(n?.totalTx??0),` up`]}),(0,G.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`· peak/day `,Vk(l),` · last `,t,` days · `,n?.series.length??0,` recorded days`]})]}),(0,G.jsxs)(`svg`,{className:`block h-40 w-full rounded-md border border-border bg-card`,viewBox:`0 0 640 150`,preserveAspectRatio:`none`,xmlns:iM,role:`img`,"aria-label":`Recorded daily download and upload usage`,children:[(0,G.jsx)(`polygon`,{className:`fill-chart-3/20`,points:m(e=>e.rx)}),(0,G.jsx)(`polygon`,{className:`fill-chart-4/15`,points:m(e=>e.tx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-chart-3 stroke-2 [vector-effect:non-scaling-stroke]`,points:p(e=>e.rx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-chart-4 stroke-2 [vector-effect:non-scaling-stroke]`,points:p(e=>e.tx)})]})]})}var lM=12,Gre=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],uM=[`var(--muted)`,`color-mix(in srgb, var(--chart-3) 30%, var(--muted))`,`color-mix(in srgb, var(--chart-3) 50%, var(--muted))`,`color-mix(in srgb, var(--chart-3) 72%, transparent)`,`var(--chart-3)`];function dM({endpoint:e,label:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(null);(0,v.useEffect)(()=>{let t=!0;return U(e).then(e=>{t&&r(e)}).catch(()=>{t&&r({days:[],total:0,max:0})}),()=>{t=!1}},[e]);let{cells:s,monthLabels:c}=(0,v.useMemo)(()=>{let e=new Map((n?.days??[]).map(e=>[e.day,e.count])),t=sM(),r=t-(new Date(t).getUTCDay()+364)*aM,i=[],a=[],o=-1;for(let n=0;n<371;n++){let s=r+n*aM;if(s>t)break;let c=Math.floor(n/7),l=new Date(s).getUTCDay(),u=oM(s);if(i.push({day:u,count:e.get(u)??0,col:c,row:l,ms:s}),l===0){let e=new Date(s).getUTCMonth();e!==o&&(a.push({col:c,text:Gre[e]}),o=e)}}return{cells:i,monthLabels:a}},[n]),l=Math.max(1,n?.max??1),u=e=>e<=0?0:Math.min(4,Math.ceil(e/l*4)),d=(e,t)=>{let n=o.current;if(!n)return;let r=e.currentTarget.getBoundingClientRect(),i=n.getBoundingClientRect();a({left:r.left-i.left+r.width/2,top:r.top-i.top,day:t.day,count:t.count,lvl:u(t.count)})};return(0,G.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline gap-2.5`,children:[(0,G.jsx)(`span`,{className:`text-[12.5px] font-semibold`,children:t??`Connections`}),(0,G.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n?`${n.total} total`:`…`})]}),(0,G.jsx)(`div`,{className:`overflow-x-auto pb-1`,onMouseLeave:()=>a(null),children:(0,G.jsxs)(`svg`,{className:`block`,viewBox:`0 0 823 121`,width:823,height:121,xmlns:iM,role:`img`,children:[c.map(e=>(0,G.jsx)(`text`,{className:`fill-muted-foreground text-[9px]`,x:28+e.col*15,y:11,children:e.text},`${e.col}-${e.text}`)),[`Mon`,`Wed`,`Fri`].map((e,t)=>(0,G.jsx)(`text`,{className:`fill-muted-foreground text-[9px]`,x:0,y:16+(t*2+1)*15+lM-2,children:e},e)),s.map(e=>(0,G.jsx)(`rect`,{className:`cursor-pointer stroke-1 [transition:stroke_0.1s_ease] ${i?.day===e.day?`stroke-foreground stroke-[1.5px]`:`stroke-border/60`}`,style:{fill:uM[u(e.count)]},x:28+e.col*15,y:16+e.row*15,width:lM,height:lM,rx:2,onMouseEnter:t=>d(t,e)},e.day))]})}),i&&(0,G.jsxs)(`div`,{className:`pointer-events-none absolute z-30 min-w-[150px] -translate-x-1/2 translate-y-[calc(-100%-9px)] rounded-[10px] border border-chart-3/35 bg-popover px-2.5 py-2 shadow-xl`,style:{left:i.left,top:i.top},role:`tooltip`,children:[(0,G.jsx)(`span`,{className:`absolute -bottom-1.5 left-1/2 size-[11px] -translate-x-1/2 rotate-45 border-r border-b border-chart-3/35 bg-popover`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13px]`,children:[(0,G.jsx)(`span`,{className:`inline-block size-[12px] rounded-[2px]`,style:{background:uM[i.lvl]}}),(0,G.jsx)(`b`,{className:`font-semibold`,children:i.count===0?`No connections`:`${i.count} connection${i.count===1?``:`s`}`})]}),(0,G.jsx)(`div`,{className:`mt-[3px] text-[11.5px] text-muted-foreground tabular-nums`,children:Wre(i.day)})]}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-muted-foreground`,children:[`Less`,[0,1,2,3,4].map(e=>(0,G.jsx)(`span`,{className:`inline-block size-[11px] rounded-[2px]`,style:{background:uM[e]}},e)),`More`]})]})}var fM=e=>(e.flags??``).includes(`X`)||e.disabled===`yes`;function Kre(e,t){return e[t.idKey]||e.name||e.address||e.user||`(row)`}var pM=`mb-3.5 rounded-md border border-border bg-card p-3.5`,mM=`mb-2.5 text-[13px] font-semibold`,hM=`grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-x-3.5 gap-y-2.5`,gM=`mt-3.5 flex items-center gap-2.5`,_M=`flex flex-col gap-1`,vM=`text-[11.5px] text-muted-foreground`;function yM({config:e,device:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)({}),m=(0,v.useCallback)(async()=>{try{let n=t?`?device=${encodeURIComponent(t)}`:``;r(await U(`/api/aaa/list/${e.slug}${n}`)),a(null)}catch(e){a(e instanceof Error?e.message:String(e))}},[e.slug,t]);(0,v.useEffect)(()=>{r(null),d(null),m()},[m]);let h=(0,v.useCallback)(async(n,r)=>{s(!0),a(null);try{let i=await _c(`/api/aaa/${n}`,{device:t,slug:e.slug,...r}),o=n===`add`?`Entry added`:n===`update`?`Entry saved`:n===`remove`?`Entry removed`:n===`toggle`?r.enable?`Entry enabled`:`Entry disabled`:`Done`;return i.ok?(await m(),Y.success(o),!0):(a(i.message),Y.error(i.message||`${o} failed`),!1)}catch(e){return a(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Action failed`),!1}finally{s(!1)}},[t,e.slug,m]),g=()=>{d(`new`),p({})},_=t=>{d(t[e.idKey]);let n={};for(let r of e.fields)r.type!==`password`&&(r.key===`disabled`?n.disabled=fM(t)?`yes`:`no`:t[r.key]!=null&&(n[r.key]=t[r.key]));p(n)},y=async()=>{(u===`new`?await h(`add`,{fields:f}):await h(`update`,{id:u,fields:f}))&&d(null)},b=(0,v.useMemo)(()=>{let t=n?.rows??[],r=c.trim().toLowerCase();return r?t.filter(t=>e.columns.some(e=>(t[e.key]??``).toLowerCase().includes(r))):t},[n,c,e.columns]);return n&&!n.available?(0,G.jsxs)(Yj,{type:`warning`,label:`User Manager not installed`,children:[`This device doesn't have the `,(0,G.jsx)(`code`,{children:`user-manager`}),` package. Install it (System → Packages) and reboot to manage the built-in RADIUS server here.`]}):(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2.5`,children:[(0,G.jsx)($j,{className:`w-[200px]`,placeholder:`Filter…`,value:c,onChange:e=>l(e.target.value)}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[b.length,` rows`]}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,icon:(0,G.jsx)(nd,{}),onClick:()=>void m(),children:`Refresh`}),(0,G.jsx)(Z,{size:`sm`,type:`accent`,icon:(0,G.jsx)(Xu,{}),onClick:g,children:`Add`})]}),i&&(0,G.jsx)(Yj,{type:`error`,className:`mb-2.5`,children:i}),u&&(0,G.jsxs)(`div`,{className:pM,children:[(0,G.jsx)(`div`,{className:mM,children:u===`new`?`New ${e.slug}`:`Edit ${u}`}),(0,G.jsx)(`div`,{className:hM,children:e.fields.map(e=>(0,G.jsxs)(`label`,{className:_M,children:[(0,G.jsxs)(`span`,{className:vM,children:[e.label,e.required&&u===`new`?` *`:``]}),e.type===`bool`?(0,G.jsx)(nM,{value:f[e.key]??``,onValueChange:t=>p({...f,[e.key]:t}),options:[{value:``,label:`—`},{value:`no`,label:`no`},{value:`yes`,label:`yes`}]}):e.type===`select`?(0,G.jsx)(nM,{value:f[e.key]??``,onValueChange:t=>p({...f,[e.key]:t}),options:[{value:``,label:`—`},...(e.options??[]).map(e=>({value:e,label:e}))]}):(0,G.jsx)($j,{type:e.type===`password`?`password`:e.type===`number`?`number`:`text`,placeholder:e.placeholder??(e.type===`password`?`(unchanged)`:``),value:f[e.key]??``,onChange:t=>p({...f,[e.key]:t.target.value})})]},e.key))}),(0,G.jsxs)(`div`,{className:gM,children:[(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:o,onClick:()=>void y(),children:u===`new`?`Create`:`Save`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,onClick:()=>d(null),children:`Cancel`})]})]}),n?b.length===0?(0,G.jsx)(`div`,{className:`px-1 py-5 text-muted-foreground text-[11px]`,children:e.empty??`Nothing here yet.`}):(0,G.jsxs)(ZO,{className:`text-[13px]`,children:[(0,G.jsx)(QO,{children:(0,G.jsxs)(ek,{children:[e.columns.map(e=>(0,G.jsx)(tk,{children:e.label},e.key)),(0,G.jsx)(tk,{className:`text-right`,children:`Actions`})]})}),(0,G.jsx)($O,{children:b.map(t=>{let n=t[e.idKey],r=fM(t);return(0,G.jsxs)(ek,{children:[e.columns.map(e=>(0,G.jsx)(nk,{className:K(r&&`text-muted-foreground`),title:t[e.key]??``,children:e.key===`_status`?(0,G.jsx)(Xj,{type:r?`secondary`:`success`,children:r?`disabled`:`enabled`}):t[e.key]??``},e.key)),(0,G.jsx)(nk,{className:`text-right`,children:(0,G.jsxs)(`span`,{className:`flex justify-end gap-1.5`,children:[e.toggle&&(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:o,onClick:()=>void h(`toggle`,{id:n,enable:r}),children:r?`Enable`:`Disable`}),!e.addOnly&&(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:o,onClick:()=>_(t),children:`Edit`}),(0,G.jsx)(Z,{size:`sm`,type:`error`,ghost:!0,disabled:o,onClick:()=>void h(`remove`,{id:n}),children:`Remove`})]})})]},n||Kre(t,e))})})]}):(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading…`})]})}var bM=[`user`,`calling-station-id`,`nas-ip-address`,`started`,`ended`,`uptime`,`download`,`upload`,`status`];function qre({device:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),s=(0,v.useCallback)(async()=>{try{let t=e?`?device=${encodeURIComponent(e)}`:``;n(await U(`/api/aaa/list/um-sessions${t}`)),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}},[e]);if((0,v.useEffect)(()=>{n(null),s();let e=setInterval(()=>void s(),1e4);return()=>clearInterval(e)},[s]),t&&!t.available)return(0,G.jsxs)(Yj,{type:`warning`,label:`User Manager not installed`,children:[`The `,(0,G.jsx)(`code`,{children:`user-manager`}),` package isn't installed on this device.`]});let c=(t?.rows??[]).filter(e=>!a.trim()||(e.user??``).toLowerCase().includes(a.trim().toLowerCase()));return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2.5`,children:[(0,G.jsx)($j,{className:`w-[200px]`,placeholder:`Filter by user…`,value:a,onChange:e=>o(e.target.value)}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[c.length,` sessions`]}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,icon:(0,G.jsx)(nd,{}),onClick:()=>void s(),children:`Refresh`})]}),r&&(0,G.jsx)(Yj,{type:`error`,children:r}),t?c.length===0?(0,G.jsx)(`div`,{className:`px-1 py-5 text-muted-foreground text-[11px]`,children:`No accounting sessions recorded.`}):(0,G.jsxs)(ZO,{className:`text-[13px]`,children:[(0,G.jsx)(QO,{children:(0,G.jsx)(ek,{children:bM.map(e=>(0,G.jsx)(tk,{children:e.replace(/-/g,` `)},e))})}),(0,G.jsx)($O,{children:c.map((e,t)=>(0,G.jsx)(ek,{children:bM.map(t=>(0,G.jsx)(nk,{title:e[t]??``,children:e[t]??``},t))},e[`.id`]||t))})]}):(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading…`})]})}function xM({device:e,getPath:t,setPath:n,fields:r,title:i,unwrap:a,extra:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)({}),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(!1),_=(0,v.useCallback)(async()=>{let{available:n,row:r}=a(await U(`${t}${e?`?device=${encodeURIComponent(e)}`:``}`).catch(()=>null));u(n),c(r),f({})},[e,t,a]);(0,v.useEffect)(()=>{_()},[_]);let y=async()=>{g(!0),m(null);try{let t=await _c(n,{device:e,fields:d});m(t.message),t.ok?(await _(),Y.success(`Settings saved`)):Y.error(t.message||`Save failed`)}catch(e){Y.error(e instanceof Error?e.message:`Save failed`)}finally{g(!1)}};return l?(0,G.jsxs)(`div`,{className:pM,children:[(0,G.jsx)(`div`,{className:mM,children:i}),s&&(0,G.jsx)(`div`,{className:`mb-3 text-muted-foreground text-xs`,children:r.map(e=>`${e.label}: ${s[e.key]??`—`}`).join(` · `)}),(0,G.jsx)(`div`,{className:hM,children:r.map(e=>(0,G.jsxs)(`label`,{className:_M,children:[(0,G.jsx)(`span`,{className:vM,children:e.label}),e.type===`bool`?(0,G.jsx)(nM,{value:d[e.key]??``,onValueChange:t=>f({...d,[e.key]:t}),options:[{value:``,label:`(unchanged)`},{value:`no`,label:`no`},{value:`yes`,label:`yes`}]}):(0,G.jsx)($j,{type:e.type===`number`?`number`:`text`,placeholder:e.placeholder??s?.[e.key]??``,value:d[e.key]??``,onChange:t=>f({...d,[e.key]:t.target.value})})]},e.key))}),(0,G.jsxs)(`div`,{className:gM,children:[(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:h,onClick:()=>void y(),children:`Save`}),o,p&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:p})]})]}):(0,G.jsxs)(Yj,{type:`warning`,label:`Not available`,children:[i,` is not available on this device.`]})}var Jre={slug:`radius`,idKey:`.id`,toggle:!0,columns:[{key:`address`,label:`Address`},{key:`service`,label:`Service`},{key:`authentication-port`,label:`Auth`},{key:`accounting-port`,label:`Acct`},{key:`protocol`,label:`Proto`},{key:`_status`,label:`Status`}],empty:`No RADIUS servers configured.`,fields:[{key:`address`,label:`Address`,required:!0,placeholder:`1.2.3.4 or host`},{key:`secret`,label:`Secret`,type:`password`,required:!0},{key:`service`,label:`Service`,required:!0,placeholder:`login,ppp,hotspot,wireless,dhcp,ipsec,dot1x`},{key:`authentication-port`,label:`Auth port`,type:`number`,placeholder:`1812`},{key:`accounting-port`,label:`Acct port`,type:`number`,placeholder:`1813`},{key:`timeout`,label:`Timeout`,placeholder:`300ms`},{key:`src-address`,label:`Src address`},{key:`realm`,label:`Realm`},{key:`called-id`,label:`Called ID`},{key:`domain`,label:`Domain`},{key:`protocol`,label:`Protocol`,type:`select`,options:[`udp`,`radsec`]},{key:`certificate`,label:`Certificate`},{key:`accounting-backup`,label:`Acct backup`,type:`bool`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},Yre={slug:`um-users`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared`},{key:`caller-id`,label:`Caller ID`},{key:`comment`,label:`Comment`},{key:`_status`,label:`Status`}],empty:`No RADIUS users.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`password`,label:`Password`,type:`password`,required:!0},{key:`group`,label:`Group`},{key:`shared-users`,label:`Shared users`,type:`number`,placeholder:`1`},{key:`attributes`,label:`RADIUS attributes`},{key:`caller-id`,label:`Caller ID (MAC)`},{key:`otp-secret`,label:`OTP secret`,type:`password`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},Xre={slug:`um-profiles`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`name-for-users`,label:`Display`},{key:`validity`,label:`Validity`},{key:`price`,label:`Price`},{key:`starts-when`,label:`Starts`}],empty:`No service profiles.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`name-for-users`,label:`Display name`},{key:`validity`,label:`Validity`,placeholder:`30d`},{key:`price`,label:`Price`,type:`number`},{key:`starts-when`,label:`Starts when`,type:`select`,options:[`assigned`,`first-auth`]},{key:`override-shared-users`,label:`Override shared-users`},{key:`comment`,label:`Comment`}]},Zre={slug:`um-limitations`,idKey:`name`,columns:[{key:`name`,label:`Name`},{key:`rate-limit-rx`,label:`Rate ↓`},{key:`rate-limit-tx`,label:`Rate ↑`},{key:`transfer-limit`,label:`Transfer`},{key:`uptime-limit`,label:`Uptime`}],empty:`No limitation templates.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`rate-limit-rx`,label:`Download rate`,placeholder:`10M`},{key:`rate-limit-tx`,label:`Upload rate`,placeholder:`10M`},{key:`rate-limit-min-rx`,label:`Min download (CIR)`,placeholder:`2M`},{key:`rate-limit-min-tx`,label:`Min upload (CIR)`,placeholder:`2M`},{key:`rate-limit-burst-rx`,label:`Burst download`,placeholder:`20M`},{key:`rate-limit-burst-tx`,label:`Burst upload`,placeholder:`20M`},{key:`rate-limit-burst-threshold-rx`,label:`Burst thr. ↓`},{key:`rate-limit-burst-threshold-tx`,label:`Burst thr. ↑`},{key:`rate-limit-burst-time-rx`,label:`Burst time ↓`,placeholder:`10s`},{key:`rate-limit-burst-time-tx`,label:`Burst time ↑`,placeholder:`10s`},{key:`rate-limit-priority`,label:`Priority (1-8)`,type:`number`},{key:`download-limit`,label:`Download cap`,placeholder:`5G`},{key:`upload-limit`,label:`Upload cap`,placeholder:`5G`},{key:`transfer-limit`,label:`Total transfer cap`,placeholder:`10G`},{key:`uptime-limit`,label:`Uptime cap`,placeholder:`1d`},{key:`reset-counters-interval`,label:`Reset interval`},{key:`reset-counters-start-time`,label:`Reset start time`},{key:`comment`,label:`Comment`}]},Qre={slug:`um-routers`,idKey:`name`,toggle:!0,columns:[{key:`name`,label:`Name`},{key:`address`,label:`Address`},{key:`coa-port`,label:`CoA port`},{key:`protocol`,label:`Proto`},{key:`comment`,label:`Comment`},{key:`_status`,label:`Status`}],empty:`No NAS clients registered.`,fields:[{key:`name`,label:`Name`,required:!0},{key:`address`,label:`Address`,required:!0,placeholder:`192.168.88.1`},{key:`shared-secret`,label:`Shared secret`,type:`password`,required:!0},{key:`coa-port`,label:`CoA port`,type:`number`},{key:`protocol`,label:`Protocol`,placeholder:`radius`},{key:`comment`,label:`Comment`},{key:`disabled`,label:`Disabled`,type:`bool`}]},$re={slug:`um-user-profiles`,idKey:`.id`,addOnly:!0,columns:[{key:`user`,label:`User`},{key:`profile`,label:`Profile`},{key:`state`,label:`State`},{key:`end-time`,label:`Ends`}],empty:`No profile assignments.`,fields:[{key:`user`,label:`User`,required:!0},{key:`profile`,label:`Profile`,required:!0}]},eie=[{id:`radius`,label:`RADIUS Servers`},{id:`users`,label:`Users`},{id:`profiles`,label:`Profiles`},{id:`limitations`,label:`Limitations`},{id:`nas`,label:`NAS Clients`},{id:`assignments`,label:`Assignments`},{id:`sessions`,label:`Sessions`},{id:`usage`,label:`Usage & Heatmap`},{id:`settings`,label:`Settings`}],tie=[{key:`accept`,label:`Accept CoA`,type:`bool`},{key:`port`,label:`CoA port`,type:`number`,placeholder:`3799`}],nie=[{key:`enabled`,label:`Enabled`,type:`bool`},{key:`use-profiles`,label:`Use profiles`,type:`bool`},{key:`certificate`,label:`Certificate`},{key:`authentication-port`,label:`Auth port`,type:`number`},{key:`accounting-port`,label:`Acct port`,type:`number`}];function rie({device:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``);(0,v.useEffect)(()=>{U(`/api/usage/um-users${e?`?device=${encodeURIComponent(e)}`:``}`).then(e=>{n(e.users),i(t=>t||e.users[0]||``)}).catch(()=>n([]))},[e]);let a=e?`&device=${encodeURIComponent(e)}`:``;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`User`}),(0,G.jsx)(nM,{value:r,onValueChange:i,"aria-label":`User`,options:t&&t.length>0?t.map(e=>({value:e,label:e})):[{value:``,label:`— no sessions recorded yet —`}]})]}),t&&t.length===0?(0,G.jsx)(Yj,{type:`secondary`,label:`No data yet`,children:`No User Manager sessions have been recorded yet. The dashboard ingests sessions on a configurable interval (1 minute by default — change it under the Settings tab) and keeps them forever, so usage and the heatmap fill in over time.`}):r&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:`Download / upload · last 3 months`}),(0,G.jsx)(cM,{endpoint:`/api/usage/um-user?user=${encodeURIComponent(r)}${a}&days=90`,days:90})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:[`Connection heatmap · `,r]}),(0,G.jsx)(dM,{endpoint:`/api/usage/heatmap?user=${encodeURIComponent(r)}${a}&days=371`,label:`${r} — connections`})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:`All users · connections`}),(0,G.jsx)(dM,{endpoint:`/api/usage/heatmap?days=371${a}`,label:`All users`})]})]})]})}function iie(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(async()=>{try{let e=await U(`/api/usage/sampler`);r(e.intervalMs)}catch{r(null)}},[]);(0,v.useEffect)(()=>{c()},[c]);let l=async()=>{let n=Number(e);if(!Number.isFinite(n)||n<=0){s(`Enter a positive number of minutes.`),Y.error(`Enter a positive number of minutes`);return}a(!0),s(null);try{let e=await _c(`/api/usage/sampler`,{intervalMs:Math.round(n*6e4)});r(e.intervalMs),t(``),s(`Now sampling every ${SM(e.intervalMs)}.`),Y.success(`Now sampling every ${SM(e.intervalMs)}`)}catch(e){s(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Save failed`)}finally{a(!1)}};return(0,G.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3.5`,children:[(0,G.jsx)(`div`,{className:mM,children:`Usage sampling`}),(0,G.jsxs)(`div`,{className:`mb-3 text-muted-foreground text-xs`,children:[`How often client traffic + User Manager sessions are recorded into the usage history. Current: `,n==null?`…`:SM(n),` · default 1 minute · range 30s–6h.`]}),(0,G.jsx)(`div`,{className:hM,children:(0,G.jsxs)(`label`,{className:_M,children:[(0,G.jsx)(`span`,{className:vM,children:`Interval (minutes)`}),(0,G.jsx)($j,{type:`number`,step:`0.5`,min:`0.5`,placeholder:n?String(n/6e4):`1`,value:e,onChange:e=>t(e.target.value)})]})}),(0,G.jsxs)(`div`,{className:gM,children:[(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:i,onClick:()=>void l(),children:`Save`}),[1,5,10,30].map(e=>(0,G.jsxs)(Z,{size:`sm`,ghost:!0,onClick:()=>{t(String(e))},children:[e,`m`]},e)),o&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:o})]})]})}function SM(e){if(e<6e4)return`${Math.round(e/1e3)}s`;let t=e/6e4;return`${Number.isInteger(t)?t:t.toFixed(1)} min`}function aie(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(`radius`);(0,v.useEffect)(()=>{U(`/api/devices`).then(e=>{t(e),r(t=>t||e.defaultDevice||e.devices[0]?.name||``)}).catch(()=>t({server:``,defaultDevice:``,devices:[]}))},[]);let o=e?.devices??[];return(0,G.jsx)(`section`,{className:`grid content-start gap-[18px]`,children:(0,G.jsx)(X,{title:`RADIUS & User Manager`,className:`reveal`,extra:o.length>1?(0,G.jsx)(nM,{value:n,onValueChange:r,"aria-label":`Router`,options:o.map(e=>({value:e.name,label:`${e.name}${e.isDefault?` (default)`:``}`}))}):void 0,children:(0,G.jsxs)(AA,{value:i,onValueChange:e=>a(e),children:[(0,G.jsx)(jA,{className:`mb-3.5 h-auto w-full flex-wrap justify-start border-b border-border`,children:eie.map(e=>(0,G.jsx)(MA,{value:e.id,children:e.label},e.id))}),(0,G.jsx)(NA,{value:`radius`,children:(0,G.jsx)(yM,{config:Jre,device:n})}),(0,G.jsx)(NA,{value:`users`,children:(0,G.jsx)(yM,{config:Yre,device:n})}),(0,G.jsx)(NA,{value:`profiles`,children:(0,G.jsx)(yM,{config:Xre,device:n})}),(0,G.jsx)(NA,{value:`limitations`,children:(0,G.jsx)(yM,{config:Zre,device:n})}),(0,G.jsx)(NA,{value:`nas`,children:(0,G.jsx)(yM,{config:Qre,device:n})}),(0,G.jsx)(NA,{value:`assignments`,children:(0,G.jsx)(yM,{config:$re,device:n})}),(0,G.jsx)(NA,{value:`sessions`,children:(0,G.jsx)(qre,{device:n})}),(0,G.jsx)(NA,{value:`usage`,children:(0,G.jsx)(rie,{device:n})}),(0,G.jsx)(NA,{value:`settings`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(xM,{device:n,getPath:`/api/aaa/radius-incoming`,setPath:`/api/aaa/radius-incoming`,title:`RADIUS Incoming (CoA listener)`,fields:tie,unwrap:e=>({available:!0,row:e??{}}),extra:(0,G.jsx)(Z,{size:`sm`,ghost:!0,onClick:()=>void _c(`/api/aaa/radius-reset-counters`,{device:n}).then(()=>Y.success(`Counters reset`)).catch(()=>Y.error(`Reset counters failed`)),children:`Reset RADIUS counters`})}),(0,G.jsx)(xM,{device:n,getPath:`/api/aaa/um-settings`,setPath:`/api/aaa/um-settings`,title:`User Manager (built-in RADIUS server)`,fields:nie,unwrap:e=>{let t=e??{};return{available:t.available!==!1,row:t.settings??{}}}}),(0,G.jsx)(iie,{})]})})]})})})}var CM=new Set;function wM(e){return CM.add(e),()=>CM.delete(e)}function oie(e){for(let t of CM)t(e)}var TM=new Set;function EM(e){return TM.add(e),()=>TM.delete(e)}function DM(e){for(let t of TM)t(e)}function OM(e,t){let n=(0,v.useRef)(e),r=(0,v.useRef)(t);n.current=e,r.current=t,(0,v.useEffect)(()=>{let e=!1,t=null,i=null,a=()=>{t&&=(t.onopen=t.onerror=t.onmessage=t.onclose=null,t.close(),null),i&&=(i.close(),null)},o=()=>{e||(i=new EventSource(gc(`/api/sse`)),i.addEventListener(`hello`,()=>r.current(`sse`)),i.addEventListener(`tool`,e=>{try{n.current(JSON.parse(e.data))}catch{}}),i.onerror=()=>{i&&i.readyState===EventSource.CONNECTING&&r.current(`off`)})},s=()=>{if(e)return;let i=location.protocol===`https:`?`wss`:`ws`;t=new WebSocket(gc(`${i}://${location.host}/api/stream`));let a=!1;t.onopen=()=>{a=!0,r.current(`ws`)},t.onerror=()=>t?.close(),t.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`event`&&t.event&&n.current(t.event),t.type===`txn`&&t.update&&oie(t.update),t.type===`rollout`&&t.update&&DM(t.update)}catch{}},t.onclose=()=>{e||(r.current(`off`),a?setTimeout(s,2e3):o())}},c=()=>t?.readyState===WebSocket.OPEN||i?.readyState===EventSource.OPEN,l=()=>{e||c()||(a(),s())},u=()=>{document.visibilityState===`visible`&&l()};return s(),document.addEventListener(`visibilitychange`,u),window.addEventListener(`online`,l),()=>{e=!0,document.removeEventListener(`visibilitychange`,u),window.removeEventListener(`online`,l),a()}},[])}function kM(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;document.documentElement.classList.add(`js-motion`);let n=new WeakSet,r=e=>{n.has(e)||(n.add(e),zi.set(e,{opacity:0,y:26}),ac.create({trigger:e,start:`top 90%`,once:!0,onEnter:()=>zi.to(e,{opacity:1,y:0,duration:.7,ease:`power3.out`})}))},i=e=>{for(let t of e.querySelectorAll(`.reveal`))r(t)};i(t);let a=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof Element&&(e.matches(`.reveal`)&&r(e),i(e))});a.observe(t,{childList:!0,subtree:!0});let o=setInterval(()=>ac.refresh(),1200),s=setTimeout(()=>clearInterval(o),7e3);return()=>{a.disconnect(),clearInterval(o),clearTimeout(s);for(let e of ac.getAll())e.kill();document.documentElement.classList.remove(`js-motion`)}},[e])}var AM={completed:`success`,"completed-with-failures":`warning`,halted:`warning`,reverted:`secondary`,"needs-attention":`error`,aborted:`secondary`},jM={completed:`Every device applied the change.`,"completed-with-failures":`The rollout finished, but a gate failed along the way.`,halted:`Stopped at a failed gate. The devices already changed are still changed.`,reverted:`Stopped and put back — the fleet is where it started.`,"needs-attention":`A revert itself failed. Restore the flagged device(s) by hand from the snapshot named below.`,aborted:`A human stopped it; whatever had been applied was reverted.`},MM={pending:`bg-muted/30 text-muted-foreground`,applied:`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400`,failed:`bg-red-500/15 text-red-600 dark:text-red-400`,reverted:`bg-amber-500/15 text-amber-600 dark:text-amber-400`,"revert-failed":`bg-red-500/25 text-red-600 dark:text-red-400 font-semibold`,skipped:`bg-muted/20 text-muted-foreground line-through`};function NM(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function PM({rollout:e}){let t=t=>e.gates.find(e=>e.wave===t);return(0,G.jsx)(`div`,{className:`space-y-3`,children:e.waves.map(n=>{let r=t(n.index),i=n.devices.map(t=>e.devices.find(e=>e.device===t)).filter(e=>e!==void 0),a=e.outcome===void 0&&i.some(e=>e.stage===`pending`);return(0,G.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[`Wave `,n.index+1,n.isCanary&&(0,G.jsx)(`span`,{className:`ml-2 rounded-sm bg-amber-500/15 px-1.5 py-0.5 text-xs text-amber-600 dark:text-amber-400`,children:`canary`})]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.length,` device(s)`]}),a&&(0,G.jsx)(Zj,{type:`warning`,pulse:!0}),r&&(0,G.jsxs)(Xj,{type:r.ok?`success`:`error`,className:`ml-auto`,children:[`gate `,r.ok?`pass`:`fail`]})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i.map(e=>(0,G.jsx)(`span`,{title:e.error??e.stage,className:K(`rounded-md px-2 py-1 font-mono text-xs`,MM[e.stage]??MM.pending),children:e.device},e.device))}),r&&!r.ok&&(0,G.jsxs)(`ul`,{className:`mt-2 space-y-1 text-xs text-red-600 dark:text-red-400`,children:[r.collateral&&(0,G.jsx)(`li`,{className:`font-medium`,children:`An UNTOUCHED device went dark — the change affected the wider fleet.`}),r.failures.map(e=>(0,G.jsxs)(`li`,{children:[e.device,`: `,e.reason]},e.device))]})]},n.index)})})}function FM({id:e,onClose:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)([]),[o,s]=(0,v.useState)(!1),c=(0,v.useCallback)(async()=>{try{let t=await U(`/api/rollout/${encodeURIComponent(e)}`);r(t.rollout),a(t.events)}catch(e){Y.error(`Failed to load rollout: ${e instanceof Error?e.message:String(e)}`)}},[e]);(0,v.useEffect)(()=>(c(),EM(t=>{t.rolloutId===e&&c()})),[e,c]);let l=async t=>{s(!0);try{let n=await _c(`/api/rollout/${encodeURIComponent(e)}/${t}`,{});n.error?Y.error(n.error):Y.success(n.outcome??(t===`hold`?`Held`:`Done`)),await c()}finally{s(!1)}};if(!n)return(0,G.jsx)(X,{title:`Rollout`,children:`Loading…`});let u=n.outcome===void 0,d=n.devices.filter(e=>e.stage===`failed`||e.stage===`revert-failed`);return(0,G.jsxs)(X,{title:n.label?`${n.label} — ${n.id}`:n.id,extra:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{size:`sm`,type:`secondary`,disabled:o,onClick:()=>void l(`hold`),children:`Hold`}),(0,G.jsx)(Z,{size:`sm`,type:`secondary`,disabled:o,onClick:()=>void l(`resume`),children:`Resume`}),(0,G.jsx)(Z,{size:`sm`,type:`error`,disabled:o,onClick:()=>void l(`abort`),children:`Abort`})]}),(0,G.jsx)(Z,{size:`sm`,type:`secondary`,onClick:t,children:`Close`})]}),children:[(0,G.jsxs)(`div`,{className:K(`mb-4 rounded-md border p-3 text-sm`,n.outcome===`needs-attention`&&`border-red-500/40 bg-red-500/10`,n.outcome===`completed`&&`border-emerald-500/40 bg-emerald-500/10`,u&&`border-amber-500/40 bg-amber-500/10`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,G.jsx)(Zj,{type:n.outcome?AM[n.outcome]:`warning`,pulse:u}),n.outcome??`IN FLIGHT — wave ${n.phase}`]}),(0,G.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n.outcome?jM[n.outcome]:`Applying wave by wave; each wave is gated and soaked before the next.`})]}),(0,G.jsx)(PM,{rollout:n}),d.length>0&&(0,G.jsxs)(`div`,{className:`mt-4 rounded-md border border-red-500/40 p-3 text-sm`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`Failures`}),(0,G.jsx)(`ul`,{className:`mt-1 space-y-1 font-mono text-xs text-muted-foreground`,children:d.map(e=>(0,G.jsxs)(`li`,{children:[e.device,` · `,e.stage,e.error?` — ${e.error}`:``,e.stage===`revert-failed`&&e.snapshotId?` · restore with diff_config_snapshots ${e.snapshotId} live`:``]},e.device))})]}),n.notes.length>0&&(0,G.jsx)(`ul`,{className:`mt-4 space-y-1 text-sm text-amber-600 dark:text-amber-400`,children:n.notes.map(e=>(0,G.jsxs)(`li`,{children:[`• `,e]},e))}),(0,G.jsx)(`h4`,{className:`mt-6 mb-2 text-sm font-medium`,children:`Commands`}),(0,G.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-muted/30 p-2 font-mono text-xs`,children:n.commands.join(`
178
178
  `)}),(0,G.jsx)(`h4`,{className:`mt-6 mb-2 text-sm font-medium`,children:`Timeline`}),i.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No steps recorded yet.`}):(0,G.jsx)(`ol`,{className:`space-y-1 font-mono text-xs`,children:i.map(e=>(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()}),(0,G.jsx)(`span`,{className:e.ok?`text-emerald-600 dark:text-emerald-400`:`text-red-500`,children:e.ok?`✓`:`✕`}),(0,G.jsxs)(`span`,{children:[e.kind,e.device?` ${e.device}`:``]})]},e.seq))})]})}function IM(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),o=(0,v.useCallback)(async()=>{try{let e=await U(`/api/rollout`);t(e.rollouts),a(e.error??null)}catch(e){a(e instanceof Error?e.message:String(e))}},[]);(0,v.useEffect)(()=>(o(),EM(()=>void o())),[o]);let s=e.filter(e=>e.outcome===void 0);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[n&&(0,G.jsx)(FM,{id:n,onClose:()=>r(null)}),i&&(0,G.jsx)(X,{title:`Rollout history`,children:(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The history could not be read (`,i,`); rollouts running right now are still shown.`]})}),(0,G.jsx)(X,{title:`Rollouts`,extra:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.length>0&&(0,G.jsxs)(Xj,{type:`warning`,children:[s.length,` in flight`]}),(0,G.jsx)(Z,{size:`sm`,type:`secondary`,onClick:()=>void o(),children:`Refresh`})]}),children:e.length===0?(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No rollouts yet. Preview one with `,(0,G.jsx)(`span`,{className:`font-mono`,children:`plan_rollout`}),`, then run it with `,(0,G.jsx)(`span`,{className:`font-mono`,children:`start_rollout`}),` — canary first, with a health gate and soak between waves.`]}):(0,G.jsx)(`ul`,{className:`divide-y divide-border`,children:e.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`flex w-full items-center gap-3 py-2 text-left hover:bg-muted/40`,children:[(0,G.jsx)(Xj,{type:e.outcome?AM[e.outcome]:`warning`,children:e.outcome??`LIVE`}),(0,G.jsxs)(`span`,{className:`flex-1 truncate`,children:[e.label??e.id,(0,G.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.devices.length,` device(s) · `,e.waves.length,` wave(s)`]})]}),(0,G.jsx)(`span`,{className:`whitespace-nowrap text-xs text-muted-foreground`,children:NM(e.ts)})]})},e.id))})})]})}function LM({className:e,...t}){return(0,G.jsx)(`textarea`,{"data-slot":`textarea`,className:K(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var RM={add:`+`,set:`~`,remove:`−`,enable:`▲`,disable:`▽`,move:`⇅`},zM={high:`border-l-destructive`,medium:`border-l-warning`,low:`border-l-success`};function BM(){let[e,t]=(0,v.useState)(`plan`),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),u=async()=>{l(!0),s(null);let e=await _c(`/api/plan`,{script:n}).catch(()=>({error:`request failed`}));if(l(!1),e.error||!e.plan){s(e.error??`no plan produced`),a(null),Y.error(e.error??`no plan produced`);return}a({plan:e.plan,text:e.text??``}),Y.success(`Plan ready`)},d=i?.plan.grade??``,f=d===`critical`||d===`high`,p=(0,G.jsxs)(`div`,{className:`mb-4 flex items-center gap-1`,children:[(0,G.jsx)(Z,{size:`sm`,type:e===`plan`?`default`:`secondary`,onClick:()=>t(`plan`),children:`Dry-run`}),(0,G.jsx)(Z,{size:`sm`,type:e===`rollout`?`default`:`secondary`,onClick:()=>t(`rollout`),children:`Rollout`})]});return e===`rollout`?(0,G.jsxs)(`div`,{children:[p,(0,G.jsx)(IM,{})]}):(0,G.jsxs)(G.Fragment,{children:[p,(0,G.jsxs)(`section`,{className:`grid content-start gap-[18px]`,children:[(0,G.jsxs)(X,{title:`Change plan — dry-run`,className:`reveal`,extra:(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`terraform-style preview · pure analysis, never touches a device`}),children:[(0,G.jsx)(LM,{className:`min-h-40 resize-y font-mono text-xs leading-relaxed`,spellCheck:!1,placeholder:`Paste intended RouterOS commands, one per line, e.g.
179
179
  /ip firewall filter add chain=input action=drop in-interface=WAN
180
180
  /ip address add address=10.0.0.1/24 interface=ether1
@@ -238,7 +238,7 @@ ${n.map(([e,n])=>{let r=n.theme?.[t]??n.color;return r?` --color-${e}: ${r};`:n
238
238
  `)}
239
239
  }
240
240
  `).join(`
241
- `)}}):null}var g5=W0;function _5({active:e,payload:t,className:n,indicator:r=`dot`,hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:c,formatter:l,color:u,nameKey:d,labelKey:f}){let{config:p}=zpe(),m=v.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=`${f??e?.dataKey??e?.name??`value`}`,r=v5(p,e,n),a=!f&&typeof o==`string`?p[o]?.label??o:r?.label;return s?(0,G.jsx)(`div`,{className:K(`font-medium`,c),children:s(a,t)}):a?(0,G.jsx)(`div`,{className:K(`font-medium`,c),children:a}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,G.jsxs)(`div`,{className:K(`grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl`,n),children:[h?null:m,(0,G.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=`${d??e.name??e.dataKey??`value`}`,i=v5(p,e,n),o=u??e.payload?.fill??e.color;return(0,G.jsx)(`div`,{className:K(`flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground`,r===`dot`&&`items-center`),children:l&&e?.value!==void 0&&e.name?l(e.value,e.name,e,t,e.payload):(0,G.jsxs)(G.Fragment,{children:[i?.icon?(0,G.jsx)(i.icon,{}):!a&&(0,G.jsx)(`div`,{className:K(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,{"h-2.5 w-2.5":r===`dot`,"w-1":r===`line`,"w-0 border-[1.5px] border-dashed bg-transparent":r===`dashed`,"my-0.5":h&&r===`dashed`}),style:{"--color-bg":o,"--color-border":o}}),(0,G.jsxs)(`div`,{className:K(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:i?.label??e.name})]}),e.value!=null&&(0,G.jsx)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:typeof e.value==`number`?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function v5(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return n in t&&typeof t[n]==`string`?i=t[n]:r&&n in r&&typeof r[n]==`string`&&(i=r[n]),i in e?e[i]:e[n]}function Vpe(e,t){return e===t||e.length===t.length&&e.every((e,n)=>e.t===t[n].t&&e.ok===t[n].ok&&e.error===t[n].error)}function Hpe(e){let t=e.filter(e=>Number.isFinite(e.t)&&Math.abs(e.t)<=864e13&&Number.isSafeInteger(e.ok)&&e.ok>=0&&Number.isSafeInteger(e.error)&&e.error>=0).sort((e,t)=>e.t-t.t);return{rows:t,omitted:e.length-t.length,ok:t.reduce((e,t)=>e+t.ok,0),error:t.reduce((e,t)=>e+t.error,0)}}var Upe={ok:{label:`Successful`,color:`var(--activity-ok)`},error:{label:`Errors`,color:`var(--activity-error)`}},Wpe=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),y5=e=>new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function Gpe(e){let t=window.matchMedia(`(prefers-reduced-motion: reduce)`);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}var Kpe=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,qpe=(0,v.memo)(({series:e})=>{let t=(0,v.useMemo)(()=>Hpe(e),[e]),n=(0,v.useSyncExternalStore)(Gpe,Kpe,()=>!0),[r,i]=(0,v.useState)(!1),a=!n&&!r,o=`activity-fill-${(0,v.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,s=(0,v.useId)(),c=t.rows[0],l=t.rows[t.rows.length-1],u=t.ok+t.error>0;return(0,G.jsxs)(`figure`,{className:`activity-chart`,"aria-label":`Calls over time`,"aria-describedby":s,"data-motion":a?`on`:`off`,children:[(0,G.jsxs)(`figcaption`,{className:`activity-toolbar`,children:[(0,G.jsxs)(`div`,{className:`activity-legend`,children:[(0,G.jsxs)(`span`,{className:`activity-legend-item`,children:[(0,G.jsx)(`i`,{className:`activity-key-line`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:`Successful`}),(0,G.jsx)(`strong`,{children:c?a?(0,G.jsx)(xA,{value:t.ok.toLocaleString()}):t.ok.toLocaleString():`—`})]}),(0,G.jsxs)(`span`,{className:`activity-legend-item`,children:[(0,G.jsx)(`i`,{className:`activity-key-bar`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:`Errors`}),(0,G.jsx)(`strong`,{children:c?a?(0,G.jsx)(xA,{value:t.error.toLocaleString()}):t.error.toLocaleString():`—`})]})]}),n?(0,G.jsx)(`span`,{className:`activity-motion-note`,children:`Reduced motion`}):(0,G.jsx)(nO,{variant:`ghost`,size:`icon-sm`,"aria-label":r?`Resume chart animation`:`Pause chart animation`,title:r?`Resume chart animation (data keeps updating)`:`Pause chart animation (data keeps updating)`,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?(0,G.jsx)(Ju,{size:14}):(0,G.jsx)(Bu,{size:14})})]}),(0,G.jsxs)(`div`,{className:`activity-plot`,children:[(0,G.jsx)(`span`,{className:`activity-axis-caption`,children:`Calls / interval`}),c?(0,G.jsx)(h5,{config:Upe,className:`activity-canvas h-[260px] w-full aspect-auto`,children:(0,G.jsxs)(Ipe,{data:t.rows,accessibilityLayer:!0,margin:{top:30,right:16,left:0,bottom:4},children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:o,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-ok)`,stopOpacity:.24}),(0,G.jsx)(`stop`,{offset:`80%`,stopColor:`var(--color-ok)`,stopOpacity:.03}),(0,G.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-ok)`,stopOpacity:0})]})}),(0,G.jsx)(m6,{vertical:!1,stroke:`var(--activity-grid)`,strokeOpacity:.5,strokeDasharray:`2 6`}),(0,G.jsx)(a8,{dataKey:`t`,ticks:t.rows.length===1?[c.t]:void 0,type:`number`,domain:c.t===l.t?[c.t-3e4,c.t+3e4]:[`dataMin`,`dataMax`],tickFormatter:Wpe,tick:{fontSize:10},tickLine:!1,axisLine:!1,minTickGap:50,tickMargin:12}),(0,G.jsx)(u8,{width:42,domain:[0,e=>Math.max(1,e)],tick:{fontSize:10},tickLine:!1,axisLine:!1,allowDecimals:!1,tickCount:4,tickMargin:8}),(0,G.jsx)(g5,{isAnimationActive:!1,cursor:{stroke:`var(--activity-cursor)`,strokeWidth:1,strokeDasharray:`4 4`},content:(0,G.jsx)(_5,{className:`activity-tooltip`,indicator:`line`,labelFormatter:(e,t)=>{let n=t?.[0]?.payload;return n?y5(n.t):``}})}),(0,G.jsx)(I6,{type:`monotoneX`,dataKey:`ok`,name:`ok`,stroke:`var(--color-ok)`,strokeWidth:2.5,fill:`url(#${o})`,baseValue:0,dot:t.rows.length===1&&{r:4,fill:`var(--color-ok)`,stroke:`var(--card)`,strokeWidth:2},activeDot:{r:5,fill:`var(--color-ok)`,stroke:`var(--card)`,strokeWidth:3},isAnimationActive:a,animationDuration:700,animationEasing:`ease-in-out`}),(0,G.jsx)(Z6,{dataKey:`error`,name:`error`,fill:`var(--color-error)`,maxBarSize:9,radius:[3,3,0,0],minPointSize:0,isAnimationActive:a,animationDuration:700,animationEasing:`ease-in-out`})]})}):(0,G.jsxs)(`div`,{className:`activity-no-data`,children:[(0,G.jsx)(Pc,{size:24}),(0,G.jsx)(`strong`,{children:`No activity samples yet`}),(0,G.jsx)(`span`,{children:`Intervals appear when statistics become available.`})]}),c&&!u&&(0,G.jsxs)(`div`,{className:`activity-zero`,children:[(0,G.jsx)(Pc,{size:18}),(0,G.jsx)(`span`,{children:`No tool calls in these intervals`})]})]}),(0,G.jsxs)(`div`,{className:`activity-footer`,id:s,children:[(0,G.jsx)(`span`,{children:`Successful calls & errors · same count scale`}),(0,G.jsxs)(`span`,{children:[t.rows.length,` intervals`]})]}),t.omitted>0&&(0,G.jsxs)(`p`,{className:`activity-warning`,children:[t.omitted,` invalid interval(s) omitted; totals cover displayed data only.`]}),c&&(0,G.jsxs)(`details`,{className:`activity-data`,children:[(0,G.jsx)(`summary`,{children:`View interval data`}),(0,G.jsx)(`div`,{className:`activity-table-scroll`,children:(0,G.jsxs)(`table`,{children:[(0,G.jsx)(`caption`,{className:`sr-only`,children:`Exact counts for every displayed interval`}),(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,children:`Interval start`}),(0,G.jsx)(`th`,{scope:`col`,children:`Successful`}),(0,G.jsx)(`th`,{scope:`col`,children:`Errors`})]})}),(0,G.jsx)(`tbody`,{children:t.rows.map((e,t)=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`row`,children:y5(e.t)}),(0,G.jsx)(`td`,{children:e.ok.toLocaleString()}),(0,G.jsx)(`td`,{children:e.error.toLocaleString()})]},`${e.t}-${t}`))})]})})]})]})},(e,t)=>Vpe(e.series,t.series));function b5({segments:e,centerLabel:t=`calls`}){let n=e.filter(e=>e.value>0),r=e.reduce((e,t)=>e+t.value,0),i=Object.fromEntries(n.map(e=>[e.label,{label:e.label,color:e.color}]));return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3`,children:[(0,G.jsx)(h5,{config:i,className:`mx-auto aspect-square w-full max-w-[180px]`,children:(0,G.jsxs)(Mpe,{children:[(0,G.jsx)(g5,{content:(0,G.jsx)(_5,{hideLabel:!0})}),(0,G.jsx)(C3,{data:n,dataKey:`value`,nameKey:`label`,innerRadius:58,outerRadius:80,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,children:n.map(e=>(0,G.jsx)(G0,{fill:e.color},e.label))}),(0,G.jsx)(`text`,{x:`50%`,y:`47%`,textAnchor:`middle`,className:`fill-foreground`,fontSize:22,fontWeight:600,children:r.toLocaleString()}),(0,G.jsx)(`text`,{x:`50%`,y:`59%`,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:10,children:t})]})}),(0,G.jsx)(`div`,{className:`flex flex-wrap justify-center gap-x-3.5 gap-y-1.5 text-[11px] text-muted-foreground`,children:n.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-[9px] rounded-[3px]`,style:{background:e.color}}),e.label,` `,(0,G.jsx)(`b`,{className:`font-medium text-foreground`,children:e.value})]},e.label))})]})}function x5({values:e,color:t,unit:n,maxValue:r,id:i}){let a=e.filter(e=>e!=null);if(a.length===0)return(0,G.jsx)(`div`,{className:`px-1.5 py-3 text-center text-[11px] text-muted-foreground`,children:`no samples yet`});let o=e.map((e,t)=>({i:t,v:e})),s=a[a.length-1],c=`ma-${(i??t).replace(/[^a-z0-9]/gi,``)}`,l={v:{label:`value`,color:t}},u=Math.min(...a),d=Math.max(...a),f=Math.max(0,(n===`%`?10:0)-(d-u))/2,p=u-f,m=d+f,h=(m-p)*.15||1;return p=Math.max(0,p-h),m+=h,r!=null&&(m=Math.min(r,m)),m<=p&&(m=p+1),(0,G.jsxs)(`div`,{className:`relative w-full`,children:[(0,G.jsxs)(`span`,{className:`absolute right-0.5 top-0 z-10 text-[10px] font-semibold`,style:{color:t},children:[s.toFixed(n===`%`?0:1),n??``]}),(0,G.jsx)(h5,{config:l,className:`h-[46px] w-full`,children:(0,G.jsxs)(Ppe,{data:o,margin:{top:4,right:2,left:2,bottom:0},children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:c,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-v)`,stopOpacity:.35}),(0,G.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-v)`,stopOpacity:0})]})}),(0,G.jsx)(u8,{hide:!0,domain:[p,m]}),(0,G.jsx)(g5,{content:(0,G.jsx)(_5,{hideLabel:!0,formatter:e=>(0,G.jsxs)(`span`,{className:`font-mono tabular-nums text-foreground`,children:[typeof e==`number`?e.toLocaleString():String(e),n??``]})})}),(0,G.jsx)(I6,{type:`monotone`,dataKey:`v`,stroke:`var(--color-v)`,fill:`url(#${c})`,strokeWidth:1.7,connectNulls:!1,isAnimationActive:!1,dot:!1})]})})]})}var Jpe=1e3,S5=`http://www.w3.org/2000/svg`,C5=e=>`${(e/1e6).toFixed(2)} Mbps`,w5=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:e>0?`${Math.round(e)}`:`0`;function Ype({history:e}){let t=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),n=e=>8+e*504/39,r=e=>142-e/t*134,i=t=>e.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),a=t=>{if(e.length<2)return``;let r=n(0).toFixed(1),a=n(e.length-1).toFixed(1);return`${r},${142 .toFixed(1)} ${i(t)} ${a},${142 .toFixed(1)}`};return(0,G.jsx)(`svg`,{className:`block h-[150px] w-full max-w-[520px] rounded-md border border-border bg-background`,viewBox:`0 0 520 150`,xmlns:S5,role:`img`,children:e.length>=2&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`polygon`,{className:`fill-success/20 stroke-none`,points:a(e=>e.rx)}),(0,G.jsx)(`polygon`,{className:`fill-warning/15 stroke-none`,points:a(e=>e.tx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-success stroke-2`,points:i(e=>e.rx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-warning stroke-2`,points:i(e=>e.tx)})]})})}function Xpe({history:e}){let t=`block h-[18px] w-20 shrink-0 rounded-[3px] bg-muted/40`;if(e.length<2)return(0,G.jsx)(`svg`,{className:t,viewBox:`0 0 80 18`});let n=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),r=e=>1+e*78/29,i=e=>17-e/n*16,a=t=>e.map((e,n)=>`${r(n).toFixed(1)},${i(t(e)).toFixed(1)}`).join(` `),o=t=>{let n=r(0).toFixed(1),i=r(e.length-1).toFixed(1),o=17 .toFixed(1);return`${n},${o} ${a(t)} ${i},${o}`};return(0,G.jsxs)(`svg`,{className:t,viewBox:`0 0 80 18`,xmlns:S5,children:[(0,G.jsx)(`polygon`,{className:`fill-success/20 stroke-none`,points:o(e=>e.rx)}),(0,G.jsx)(`polygon`,{className:`fill-warning/15 stroke-none`,points:o(e=>e.tx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-success stroke-1`,vectorEffect:`non-scaling-stroke`,points:a(e=>e.rx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-warning stroke-1`,vectorEffect:`non-scaling-stroke`,points:a(e=>e.tx)})]})}function Zpe({ip:e,deviceName:t,current:n,onSaved:r}){let[i,a]=(0,v.useState)(n.download),[o,s]=(0,v.useState)(n.upload),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{c||(a(n.download),s(n.upload))},[n.download,n.upload,c]);let m=(0,v.useCallback)(async(n,i)=>{d(!0),p(null);try{let a=await _c(`/api/clients/limits`,{ip:e,device:t,download:n,upload:i});p(a.message),a.ok?(l(!1),r(),Y.success(n||i?`Rate limits applied`:`Rate limits removed`)):Y.error(a.message||`Rate limits failed`)}catch(e){p(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Rate limits failed`)}finally{d(!1)}},[e,t,r]),h=!!(n.download||n.upload);return(0,G.jsxs)(`div`,{className:`mt-3.5 max-w-[520px] border-t border-border pt-3`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Rate limits`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[`current: ↓ `,n.download||`unlimited`,` · ↑ `,n.upload||`unlimited`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex flex-col gap-[3px] text-[11.5px]`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`↓ Download`}),(0,G.jsx)($j,{className:`w-[150px]`,placeholder:`10M · blank = unlimited`,value:i,onChange:e=>{l(!0),a(e.target.value)}})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-[3px] text-[11.5px]`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`↑ Upload`}),(0,G.jsx)($j,{className:`w-[150px]`,placeholder:`2M · blank = unlimited`,value:o,onChange:e=>{l(!0),s(e.target.value)}})]}),(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:u,onClick:()=>void m(i,o),children:`Apply`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:u||!h,onClick:()=>{a(``),s(``),m(``,``)},children:`Remove`})]}),f&&(0,G.jsx)(`div`,{className:`mt-1.5 text-muted-foreground text-xs`,children:f})]})}function Qpe({device:e,deviceName:t,traffic:n}){let r=n!==void 0;return(0,G.jsxs)(`div`,{className:`mt-3.5 border-t border-border pt-3.5`,children:[(0,G.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-baseline gap-3`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e.host||e.comment||e.ip}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[e.ip||`no IP`,` · `,e.mac,` · `,e.iface||`?`,` · `,e.status]})]}),r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mb-2 flex gap-[18px] tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`font-semibold text-success`,children:[`↓ `,C5(n.rxRate)]}),(0,G.jsxs)(`span`,{className:`font-semibold text-warning`,children:[`↑ `,C5(n.txRate)]})]}),(0,G.jsx)(Ype,{history:n.history}),(0,G.jsxs)(`div`,{className:`mt-2 text-muted-foreground text-xs tabular-nums`,children:[`total ↓ `,Vk(n.rxBytes),` · ↑ `,Vk(n.txBytes)]})]}):(0,G.jsxs)(Yj,{type:`secondary`,label:`No traffic yet`,children:[`No traffic seen for `,(0,G.jsx)(`code`,{children:e.ip}),` yet. Rates appear here as soon as the device sends or receives.`]}),e.ip&&(0,G.jsx)(Zpe,{ip:e.ip,deviceName:t,current:{download:n?.downloadLimit??``,upload:n?.uploadLimit??``},onSaved:()=>{}}),e.ip&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:`Usage history · last 3 months`}),(0,G.jsx)(cM,{endpoint:`/api/usage/client?ip=${encodeURIComponent(e.ip)}${t?`&device=${encodeURIComponent(t)}`:``}&days=90`,days:90})]})]})}var T5={map:new Map,source:`accounting`};function $pe(e,t){let n=new Set([...e.map.keys(),...Object.keys(t.hosts),...Object.keys(t.limits)]),r=new Map;for(let i of n){let n=t.hosts[i],a=n?.rxRate??0,o=n?.txRate??0,s=e.map.get(i),c=[...s?.history??[],{rx:a,tx:o}].slice(-30),l=t.limits[i];(l||c.some(e=>e.rx>0||e.tx>0))&&r.set(i,{rxRate:a,txRate:o,rxBytes:n?.rxBytes??s?.rxBytes??0,txBytes:n?.txBytes??s?.txBytes??0,downloadLimit:l?.download??``,uploadLimit:l?.upload??``,history:c})}return{map:r,source:t.source,note:t.note}}function eme(e){let[t,n]=(0,v.useState)(T5);return(0,v.useEffect)(()=>{n(T5)},[e]),(0,v.useEffect)(()=>{if(!e)return;let t=!1,r=null,i=null,a=null,o=`traffic=${encodeURIComponent(e)}`,s=e=>{t||n(t=>$pe(t,e))},c=()=>{if(t||a)return;let n=async()=>{try{s(await U(`/api/clients/traffic-bulk?device=${encodeURIComponent(e)}`))}catch{}};n(),a=setInterval(()=>void n(),Jpe)},l=()=>{if(t)return;i=new EventSource(gc(`/api/sse?${o}`));let e=!1;i.onopen=()=>{e=!0},i.addEventListener(`traffic`,e=>{try{s(JSON.parse(e.data))}catch{}}),i.onerror=()=>{!e&&i&&(i.close(),i=null,c())}},u=()=>{if(t)return;let e=location.protocol===`https:`?`wss`:`ws`;r=new WebSocket(gc(`${e}://${location.host}/api/stream?${o}`));let n=!1;r.onopen=()=>{n=!0},r.onerror=()=>r?.close(),r.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`traffic`&&t.sample&&s(t.sample)}catch{}},r.onclose=()=>{t||(n?setTimeout(u,2e3):l())}};return u(),()=>{t=!0,r?.close(),i?.close(),a&&clearInterval(a)}},[e]),t}function tme(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),{map:g,source:_,note:y}=eme(n);(0,v.useEffect)(()=>{U(`/api/devices`).then(e=>{t(e),r(t=>t||e.defaultDevice||e.devices[0]?.name||``)}).catch(()=>t({server:``,defaultDevice:``,devices:[]}))},[]);let b=(0,v.useCallback)(async()=>{try{let e=n?`?device=${encodeURIComponent(n)}`:``;a(await U(`/api/clients${e}`)),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}},[n]);(0,v.useEffect)(()=>{a(null),s(null),b();let e=setInterval(()=>void b(),15e3);return()=>clearInterval(e)},[b]);let x=(0,v.useCallback)(async(e,t,r)=>{l(t),d(null);try{let i=await _c(`/api/clients/${e}`,{mac:t,device:n,...r});i.view?a(i.view):await b();let o=e===`block`?`Client blocked`:e===`allow`?`Client allowed`:e===`pin`?`IP pinned`:e===`set-ip`?`IP set`:e===`label`?`Client labeled`:`Done`;i.ok?Y.success(o):(d(i.message),Y.error(i.message||`${o} failed`))}catch(e){d(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Action failed`)}finally{l(null)}},[n,b]),S=(0,v.useCallback)((e,t)=>{s(e.mac),h({mac:e.mac,field:t,value:t===`ip`?e.ip:e.comment||e.host})},[]),C=(0,v.useCallback)(async()=>{if(!m)return;let e=m.value.trim();m.field===`ip`?e&&await x(`set-ip`,m.mac,{ip:e}):await x(`label`,m.mac,{label:e}),h(null)},[m,x]),w=(0,v.useMemo)(()=>{let e=i?.devices??[],t=f.trim().toLowerCase();return t?e.filter(e=>e.ip.toLowerCase().includes(t)||e.mac.toLowerCase().includes(t)||e.host.toLowerCase().includes(t)||e.comment.toLowerCase().includes(t)):e},[i,f]),T=(0,v.useMemo)(()=>i?.devices.find(e=>e.mac===o)??null,[i,o]),E=e?.devices??[],D=i?.counts;return(0,G.jsx)(`section`,{className:`grid content-start gap-[18px]`,children:(0,G.jsxs)(X,{title:`Connected clients`,className:`reveal`,extra:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E.length>1&&(0,G.jsx)(nM,{value:n,onValueChange:r,"aria-label":`Router`,options:E.map(e=>({value:e.name,label:`${e.name}${e.isDefault?` (default)`:``}`}))}),(0,G.jsx)($j,{className:`w-[200px]`,placeholder:`Filter IP / MAC / name…`,value:f,onChange:e=>p(e.target.value)}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,icon:(0,G.jsx)(nd,{}),onClick:()=>void b(),children:`Refresh`})]}),children:[D&&(0,G.jsxs)(`div`,{className:`mb-2.5 text-muted-foreground text-xs`,children:[D.total,` total · `,D.static,` static · `,D.blocked,` blocked`]}),u&&(0,G.jsx)(Yj,{type:`error`,className:`mb-2.5`,children:u}),_===`none`&&y&&(0,G.jsxs)(Yj,{type:`warning`,label:`Traffic unavailable`,className:`mb-2.5`,children:[y,` The Traffic column needs per-host counters — `,(0,G.jsx)(`code`,{children:`/ip accounting`}),` `,`on RouterOS v6, or Kid Control on v7.`]}),i?w.length===0?(0,G.jsxs)(`div`,{className:`grid justify-items-center gap-2 rounded-lg border border-dashed border-border px-4 py-[54px] text-center`,children:[(0,G.jsx)(lf,{className:`size-7 text-muted-foreground opacity-80`}),(0,G.jsx)(`p`,{className:`m-0 font-semibold text-foreground`,children:`No connected devices`}),(0,G.jsxs)(`p`,{className:`m-0 max-w-[460px] text-muted-foreground text-xs`,children:[`Nothing in this router's DHCP-lease or ARP table`,f?` matches the filter`:``,`.`]})]}):(0,G.jsxs)(ZO,{className:`text-[13px]`,children:[(0,G.jsx)(QO,{children:(0,G.jsxs)(ek,{children:[(0,G.jsx)(tk,{children:`IP`}),(0,G.jsx)(tk,{children:`Name`}),(0,G.jsx)(tk,{children:`MAC`}),(0,G.jsx)(tk,{children:`Iface`}),(0,G.jsx)(tk,{children:`Status`}),(0,G.jsx)(tk,{children:`Traffic`}),(0,G.jsx)(tk,{className:`text-right`,children:`Actions`})]})}),(0,G.jsx)($O,{children:w.map(e=>{let t=e.mac===o,n=c===e.mac,r=e.ip?g.get(e.ip):void 0,i=e.blocked&&`text-muted-foreground line-through`;return(0,G.jsxs)(ek,{"data-state":t?`selected`:void 0,className:`cursor-pointer`,onClick:()=>s(t?null:e.mac),children:[(0,G.jsx)(nk,{className:K(`max-w-[120px] truncate`,i),children:e.ip||`—`}),(0,G.jsx)(nk,{className:K(`max-w-[200px] truncate`,i),children:e.host||e.comment||`(unknown)`}),(0,G.jsx)(nk,{className:`font-mono text-[11.5px] text-muted-foreground`,children:e.mac}),(0,G.jsx)(nk,{className:`text-muted-foreground text-[11px]`,children:e.iface||``}),(0,G.jsx)(nk,{children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.static&&(0,G.jsx)(Xj,{type:`secondary`,children:`static`}),e.blocked?(0,G.jsx)(Xj,{type:`error`,children:`blocked`}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:e.status})]})}),(0,G.jsx)(nk,{children:r?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 overflow-hidden tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-[48px] flex-col whitespace-nowrap leading-tight`,children:[(0,G.jsxs)(`span`,{className:`text-success`,children:[`↓`,w5(r.rxRate)]}),(0,G.jsxs)(`span`,{className:`text-warning`,children:[`↑`,w5(r.txRate)]})]}),(0,G.jsx)(Xpe,{history:r.history})]}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:e.ip?`—`:``})}),(0,G.jsx)(nk,{onClick:e=>e.stopPropagation(),children:(0,G.jsxs)(`span`,{className:`flex justify-end gap-1.5`,children:[e.blocked?(0,G.jsx)(Z,{size:`sm`,type:`success`,ghost:!0,loading:n,onClick:()=>void x(`allow`,e.mac),children:`Allow`}):(0,G.jsx)(Z,{size:`sm`,type:`error`,ghost:!0,loading:n,onClick:()=>void x(`block`,e.mac),children:`Block`}),!e.static&&(0,G.jsx)(Z,{size:`sm`,ghost:!0,loading:n,onClick:()=>void x(`pin`,e.mac),children:`Pin IP`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:n,onClick:()=>S(e,`ip`),children:`Set IP`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:n,onClick:()=>S(e,`label`),children:`Label`})]})})]},e.mac)})})]}):(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading connected devices…`}),m&&T?.mac===m.mac&&(0,G.jsxs)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2.5`,children:[(0,G.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[m.field===`ip`?`Reserve IP for`:`Label for`,` `,(0,G.jsx)(`b`,{children:T.host||T.mac}),`:`]}),(0,G.jsx)($j,{className:`w-[220px]`,autoFocus:!0,value:m.value,placeholder:m.field===`ip`?`e.g. 192.168.88.50`:`e.g. Ali phone`,onChange:e=>h({...m,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&C(),e.key===`Escape`&&h(null)}}),(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:c===m.mac,onClick:()=>void C(),children:`Save`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,onClick:()=>h(null),children:`Cancel`})]}),T&&(0,G.jsx)(`a`,{className:`inline-flex rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-muted`,href:(()=>{let e=new URL(location.href);return e.searchParams.set(`investigationDevice`,n),e.searchParams.set(`investigationClient`,T.ip||T.mac),e.hash=`investigations`,e.toString()})(),children:`Investigate this client and service`}),T&&(0,G.jsx)(Qpe,{device:T,deviceName:n,traffic:T.ip?g.get(T.ip):void 0})]})})}function E5({label:e,value:t,items:n,onChange:r,disabled:i=!1}){return(0,G.jsxs)(`div`,{className:`home-field`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsxs)(Kj,{value:t,onValueChange:r,disabled:i,children:[(0,G.jsx)(qj,{"aria-label":e,children:(0,G.jsx)(Wj,{placeholder:`Choose…`})}),(0,G.jsx)(Jj,{children:n.map(e=>(0,G.jsx)(Gj,{value:e.value,children:e.label},e.value))})]})]})}function nme(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let e=!1;return U(`/api/devices`).then(n=>{e||(t(n.devices.map(e=>e.name)),r(n.defaultDevice||n.devices[0]?.name||``))}).catch(()=>{e||a(`Could not load routers. Check the dashboard connection and reload.`)}),()=>{e=!0}},[]),(0,G.jsxs)(`div`,{className:`home-internet`,children:[(0,G.jsxs)(`header`,{className:`home-intro`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`home-eyebrow`,children:[(0,G.jsx)(mu,{size:14}),` YOUR EVERYDAY NETWORK`]}),(0,G.jsxs)(`h2`,{children:[`Less guessing.`,(0,G.jsx)(`br`,{}),(0,G.jsx)(`span`,{children:`More connection.`})]}),(0,G.jsx)(`p`,{children:`Find the slowdown, look after your household, and choose a path with evidence.`})]}),(0,G.jsx)(E5,{label:`Home router`,value:n,items:e.map(e=>({value:e,label:e})),onChange:r})]}),i&&(0,G.jsx)(`p`,{role:`alert`,className:`home-error`,children:i}),n&&(0,G.jsx)(rme,{device:n},n)]})}function rme({device:e}){let[t,n]=(0,v.useState)(`diagnosis`),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(`example.com`),[p,m]=(0,v.useState)(`1.1.1.1`),[h,g]=(0,v.useState)([]),[_,y]=(0,v.useState)(`calls`),[b,x]=(0,v.useState)(),[S,C]=(0,v.useState)(),[w,T]=(0,v.useState)(`pause`),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(`30`),[A,j]=(0,v.useState)(`0`),[M,N]=(0,v.useState)(),[P,F]=(0,v.useState)(!1),[I,ee]=(0,v.useState)(),[L,R]=(0,v.useState)(``),[te,z]=(0,v.useState)(``),[ne,re]=(0,v.useState)(``),ie=`?device=${encodeURIComponent(e)}`,[ae,oe]=(0,v.useState)(()=>Date.now());(0,v.useEffect)(()=>{let e=window.setInterval(()=>oe(Date.now()),1e4);return()=>window.clearInterval(e)},[]);async function se(){let e=await U(`/api/home-internet${ie}`);i(e.clients),o(e.policies)}(0,v.useEffect)(()=>{let e=new AbortController;return U(`/api/home-internet${ie}`,e.signal).then(t=>{e.signal.aborted||(i(t.clients),o(t.policies))}).catch(()=>{e.signal.aborted||z(`Could not load the saved household. Retry with Refresh saved data.`)}),()=>e.abort()},[ie]);async function ce(e,t){let n=await _c(`/api/home-internet/${e}${ie}`,t);if(n.error)throw Error(n.error);return n}async function le(e,t){if(!L){R(e),z(``),re(``);try{await t()}catch(e){z(e instanceof Error?e.message:`Request failed. No success has been confirmed.`)}finally{R(``)}}}let B=r.find(e=>e.mac===l),V=r.filter(e=>e.ip).map(e=>({value:e.mac,label:`${e.name||e.hostname||`Unnamed device`} · ${e.ip}`})),ue=r.filter(e=>!e.acknowledged),de=()=>{N(void 0),F(!1)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`home-sections`,"aria-label":`Home Internet sections`,children:[{id:`diagnosis`,title:`Find the slowdown`,sub:`Understand what to check`,icon:Pc},{id:`people`,title:`Your household`,sub:`People, devices & quiet time`,icon:nf},{id:`paths`,title:`Choose a path`,sub:`Compare before switching`,icon:cd}].map(({id:e,title:r,sub:i,icon:a})=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":t===e,onClick:()=>n(e),children:[(0,G.jsx)(a,{size:20}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`strong`,{children:r}),(0,G.jsx)(`small`,{children:i})]}),e===`people`&&ue.length>0&&(0,G.jsxs)(`b`,{className:`home-new`,children:[ue.length,` new`]})]},e))}),(0,G.jsxs)(`div`,{className:`home-toolbar`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(Sd,{size:16}),` No router changes without a reviewed preview.`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(nO,{variant:`ghost`,size:`sm`,disabled:!!L,onClick:()=>void le(`Loading saved data`,se),children:`Refresh saved data`}),(0,G.jsxs)(nO,{variant:`outline`,size:`sm`,disabled:!!L,onClick:()=>void le(`Discovering household`,async()=>{let e=await ce(`refresh`,{});i(e.clients),c(e.tables),g(t=>t.filter(t=>e.tables.includes(t))),re(`DHCP inventory updated. New-device notices appear after the first baseline scan; no router configuration changed.`)}),children:[(0,G.jsx)(nd,{size:14}),` Discover devices & paths`]})]})]}),L&&(0,G.jsxs)(`p`,{className:`home-status`,role:`status`,children:[(0,G.jsx)(`span`,{className:`home-pulse`}),L,`…`]}),te&&(0,G.jsx)(`p`,{className:`home-error`,role:`alert`,children:te}),ne&&(0,G.jsxs)(`p`,{className:`home-status`,role:`status`,children:[(0,G.jsx)(cl,{size:16}),ne]}),t===`diagnosis`&&(0,G.jsxs)(`section`,{className:`home-grid`,children:[(0,G.jsxs)(`div`,{className:`home-card`,children:[(0,G.jsx)(`div`,{className:`home-eyebrow`,children:`A SMALL, READ-ONLY CHECK`}),(0,G.jsx)(`h3`,{children:`What feels slow?`}),(0,G.jsx)(`p`,{children:`Choose a device and a website. We check the router, DNS, Wi-Fi evidence and a few small internet probes.`}),(0,G.jsxs)(`div`,{className:`home-form`,children:[(0,G.jsx)(E5,{label:`Affected device`,value:l,items:V,onChange:u,disabled:!!L}),(0,G.jsxs)(`label`,{className:`home-field`,children:[`Website or IPv4`,(0,G.jsx)(Ok,{value:d,onChange:e=>f(e.target.value),placeholder:`example.com`})]}),(0,G.jsxs)(nO,{disabled:!!L||!B?.ip||!d,onClick:()=>void le(`Checking the connection`,async()=>{x(void 0),x(await ce(`diagnose`,{client:B.ip,target:d}))}),children:[(0,G.jsx)(Pc,{size:16}),` Check my connection `,(0,G.jsx)(Hc,{size:16})]})]}),!r.length&&(0,G.jsxs)(`p`,{className:`home-hint`,children:[`Start with “Discover devices & paths” above. Devices without DHCP records can still be investigated in `,(0,G.jsx)(`a`,{href:`#investigations`,children:`Investigations`}),`.`]})]}),(0,G.jsxs)(`aside`,{className:`home-explainer`,children:[(0,G.jsx)(Ad,{size:32}),(0,G.jsx)(`h3`,{children:`Follow the evidence.`}),(0,G.jsxs)(`ol`,{children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`b`,{children:`Observed`}),(0,G.jsx)(`span`,{children:`Something the router actually reported.`})]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`b`,{children:`Suspected`}),(0,G.jsx)(`span`,{children:`A possible explanation, not a confirmed cause.`})]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`b`,{children:`Unknown`}),(0,G.jsx)(`span`,{children:`A missing measurement, never a green check.`})]})]}),(0,G.jsx)(`p`,{children:`This is not a speed test. Client application health, VPN throughput and MTU remain unverified.`})]}),b&&(0,G.jsxs)(`div`,{className:`home-results`,children:[(0,G.jsxs)(`header`,{children:[(0,G.jsx)(`h3`,{children:`Your connection report`}),(0,G.jsxs)(`small`,{children:[b.client,` → `,b.target,` ·`,` `,new Date(b.at).toLocaleTimeString()]})]}),(0,G.jsx)(`div`,{className:`home-findings`,children:b.findings.map(e=>(0,G.jsxs)(`article`,{"data-state":e.state,children:[(0,G.jsxs)(`div`,{className:`home-finding-label`,children:[(0,G.jsx)(`span`,{children:e.area}),(0,G.jsx)(`b`,{children:e.state})]}),(0,G.jsx)(`h4`,{children:e.title}),(0,G.jsx)(`p`,{children:e.detail}),(0,G.jsxs)(`footer`,{children:[(0,G.jsx)(Hc,{size:14}),(0,G.jsx)(`span`,{children:e.next})]})]},e.area))})]})]}),t===`people`&&(0,G.jsxs)(`section`,{className:`home-grid`,children:[(0,G.jsxs)(`div`,{className:`home-card`,children:[(0,G.jsx)(`div`,{className:`home-eyebrow`,children:`PEOPLE, NOT MAC ADDRESSES`}),(0,G.jsx)(`h3`,{children:`Give each device a place.`}),(0,G.jsx)(`p`,{children:`Friendly names stay in this MCP. Notices are based on explicit discovery scans, not continuous surveillance. Private/random MACs can appear as new devices.`}),(0,G.jsxs)(`div`,{className:`home-client-list`,children:[r.length===0&&(0,G.jsx)(`p`,{className:`home-empty`,children:`No household inventory yet. Discover devices to establish your first baseline.`}),r.map(e=>(0,G.jsx)(ime,{client:e,disabled:!!L,onSave:(t,n)=>void le(`Saving device name`,async()=>{await ce(`name`,{mac:e.mac,name:t,person:n}),await se(),re(`Name saved locally; new-device notice acknowledged.`)}),onChoose:()=>{u(e.mac),de()},selected:l===e.mac},e.mac))]})]}),(0,G.jsxs)(`aside`,{className:`home-card`,children:[(0,G.jsxs)(`div`,{className:`home-eyebrow`,children:[(0,G.jsx)(Ol,{size:14}),` TEMPORARY, BY DESIGN`]}),(0,G.jsx)(`h3`,{children:`A little quiet. Or meeting time.`}),(0,G.jsx)(`p`,{children:`Pause routed access or prioritize a device within an existing QoS setup. A static DHCP lease is required; IPv6 and FastTrack limitations are checked before a preview is created.`}),(0,G.jsx)(E5,{label:`Household device`,value:l,items:V,onChange:e=>{u(e),de()},disabled:!!L}),(0,G.jsx)(E5,{label:`Temporary action`,value:w===`route`?`pause`:w,items:[{value:`pause`,label:`Pause routed access`},{value:`priority`,label:`Meeting priority`}],onChange:e=>{T(e),de()},disabled:!!L}),(0,G.jsx)(D5,{minutes:O,delay:A,setMinutes:e=>{k(e),de()},setDelay:e=>{j(e),de()}}),(0,G.jsxs)(nO,{disabled:!!L||!B,onClick:()=>void le(`Checking policy prerequisites`,async()=>{de(),N(await ce(`preview`,{mac:l,action:w===`route`?`pause`:w,minutes:Number(O),startInMinutes:Number(A)}))}),children:[`Review temporary change `,(0,G.jsx)(Hc,{size:15})]})]})]}),t===`paths`&&(0,G.jsxs)(`section`,{className:`home-grid`,children:[(0,G.jsxs)(`div`,{className:`home-card`,children:[(0,G.jsx)(`div`,{className:`home-eyebrow`,children:`TRY THE PATH, NOT YOUR LUCK`}),(0,G.jsx)(`h3`,{children:`Which route looks steadier?`}),(0,G.jsx)(`p`,{children:`Compare up to three existing routing tables. Five small probes per path; no traffic is switched and no large files are downloaded.`}),(0,G.jsxs)(`div`,{className:`home-form`,children:[(0,G.jsx)(E5,{label:`What matters most?`,value:_,items:[{value:`calls`,label:`Stable calls`},{value:`gaming`,label:`Responsive gaming`},{value:`download`,label:`Downloads — measurements only`}],onChange:y}),(0,G.jsxs)(`label`,{className:`home-field`,children:[`Same IPv4 destination for every path`,(0,G.jsx)(Ok,{value:p,onChange:e=>m(e.target.value)})]}),(0,G.jsxs)(`fieldset`,{children:[(0,G.jsx)(`legend`,{children:`Paths to compare · up to three`}),(0,G.jsx)(`div`,{className:`home-path-options`,children:s.map(e=>(0,G.jsxs)(`label`,{children:[(0,G.jsx)(fO,{checked:h.includes(e),disabled:!h.includes(e)&&h.length>=3,onCheckedChange:t=>g(n=>t?[...n,e]:n.filter(t=>t!==e))}),(0,G.jsx)(`span`,{children:e})]},e))}),!s.length&&(0,G.jsx)(`p`,{className:`home-hint`,children:`Discover devices & paths to load the router's available tables.`})]}),(0,G.jsxs)(nO,{disabled:!!L||!h.length,onClick:()=>void le(`Comparing internet paths`,async()=>{C(void 0),C(await ce(`compare`,{tables:h,target:p,goal:_}))}),children:[(0,G.jsx)(cd,{size:16}),` Compare paths`]})]})]}),(0,G.jsxs)(`aside`,{className:`home-card`,children:[(0,G.jsx)(`h3`,{children:`Try a path for one device.`}),(0,G.jsx)(`p`,{children:`Only an existing, ready routing table can be selected. IPv6 keeps its current route; local/private destinations are excluded.`}),(0,G.jsx)(E5,{label:`Device to switch`,value:l,items:V,onChange:e=>{u(e),de()},disabled:!!L}),(0,G.jsx)(E5,{label:`Route table`,value:E,items:s.map(e=>({value:e,label:e})),onChange:e=>{D(e),de()},disabled:!!L}),(0,G.jsx)(D5,{minutes:O,delay:A,setMinutes:e=>{k(e),de()},setDelay:e=>{j(e),de()}}),(0,G.jsxs)(nO,{disabled:!!L||!l||!E,onClick:()=>void le(`Preparing path preview`,async()=>{de(),N(await ce(`preview`,{mac:l,action:`route`,table:E,minutes:Number(O),startInMinutes:Number(A)}))}),children:[`Review path change `,(0,G.jsx)(Hc,{size:15})]})]}),S&&(0,G.jsxs)(`div`,{className:`home-results`,children:[(0,G.jsxs)(`header`,{children:[(0,G.jsx)(`h3`,{children:`Path comparison`}),(0,G.jsxs)(`small`,{children:[S.target,` · `,new Date(S.at).toLocaleTimeString()]})]}),(0,G.jsx)(`p`,{children:S.explanation}),(0,G.jsx)(`div`,{className:`home-paths`,children:S.paths.map(e=>(0,G.jsxs)(`article`,{className:S.recommended===e.table?`home-recommended`:``,children:[(0,G.jsxs)(`div`,{className:`home-path-line`,children:[(0,G.jsx)(Pu,{}),(0,G.jsx)(`span`,{}),(0,G.jsx)(cd,{}),(0,G.jsx)(`span`,{}),(0,G.jsx)(Ad,{})]}),(0,G.jsx)(`h4`,{children:e.table}),S.recommended===e.table&&(0,G.jsx)(`b`,{className:`home-new`,children:`Best in this small sample`}),(0,G.jsxs)(`dl`,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Loss`}),(0,G.jsx)(`dd`,{children:e.loss===null?`Unknown`:`${e.loss.toFixed(0)}%`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Average RTT`}),(0,G.jsx)(`dd`,{children:e.latency===null?`Unknown`:`${e.latency.toFixed(1)} ms`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`RTT range`}),(0,G.jsx)(`dd`,{children:e.spread===null?`Unknown`:`${e.spread.toFixed(1)} ms`})]})]}),(0,G.jsx)(`p`,{children:e.note}),(0,G.jsx)(nO,{variant:`outline`,size:`sm`,onClick:()=>{D(e.table),de()},children:`Choose for preview`})]},e.table))})]})]}),M&&(0,G.jsxs)(`section`,{className:`home-review`,"aria-label":`Review temporary change`,children:[(0,G.jsxs)(`header`,{children:[(0,G.jsx)(Sd,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{children:`Review before anything changes`}),(0,G.jsxs)(`p`,{children:[M.device,` · `,M.input.mac,` · `,M.ip,` · `,M.input.action,M.input.table?` → ${M.input.table}`:``]})]})]}),(0,G.jsxs)(`p`,{children:[`Starts`,` `,M.input.startInMinutes?`in ${M.input.startInMinutes} minutes`:`after confirmation`,`; lasts `,M.input.minutes,` minutes. Preview expires`,` `,new Date(M.previewExpiresAt).toLocaleTimeString(),`.`]}),(0,G.jsx)(`ul`,{children:M.warnings.map(e=>(0,G.jsx)(`li`,{children:e},e))}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{children:`Exact RouterOS changes and rollback`}),(0,G.jsxs)(`pre`,{children:[M.commands.join(`
241
+ `)}}):null}var g5=W0;function _5({active:e,payload:t,className:n,indicator:r=`dot`,hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:c,formatter:l,color:u,nameKey:d,labelKey:f}){let{config:p}=zpe(),m=v.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=`${f??e?.dataKey??e?.name??`value`}`,r=v5(p,e,n),a=!f&&typeof o==`string`?p[o]?.label??o:r?.label;return s?(0,G.jsx)(`div`,{className:K(`font-medium`,c),children:s(a,t)}):a?(0,G.jsx)(`div`,{className:K(`font-medium`,c),children:a}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,G.jsxs)(`div`,{className:K(`grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl`,n),children:[h?null:m,(0,G.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=`${d??e.name??e.dataKey??`value`}`,i=v5(p,e,n),o=u??e.payload?.fill??e.color;return(0,G.jsx)(`div`,{className:K(`flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground`,r===`dot`&&`items-center`),children:l&&e?.value!==void 0&&e.name?l(e.value,e.name,e,t,e.payload):(0,G.jsxs)(G.Fragment,{children:[i?.icon?(0,G.jsx)(i.icon,{}):!a&&(0,G.jsx)(`div`,{className:K(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,{"h-2.5 w-2.5":r===`dot`,"w-1":r===`line`,"w-0 border-[1.5px] border-dashed bg-transparent":r===`dashed`,"my-0.5":h&&r===`dashed`}),style:{"--color-bg":o,"--color-border":o}}),(0,G.jsxs)(`div`,{className:K(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:i?.label??e.name})]}),e.value!=null&&(0,G.jsx)(`span`,{className:`font-mono font-medium text-foreground tabular-nums`,children:typeof e.value==`number`?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function v5(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return n in t&&typeof t[n]==`string`?i=t[n]:r&&n in r&&typeof r[n]==`string`&&(i=r[n]),i in e?e[i]:e[n]}function Vpe(e,t){return e===t||e.length===t.length&&e.every((e,n)=>e.t===t[n].t&&e.ok===t[n].ok&&e.error===t[n].error)}function Hpe(e){let t=e.filter(e=>Number.isFinite(e.t)&&Math.abs(e.t)<=864e13&&Number.isSafeInteger(e.ok)&&e.ok>=0&&Number.isSafeInteger(e.error)&&e.error>=0).sort((e,t)=>e.t-t.t);return{rows:t,omitted:e.length-t.length,ok:t.reduce((e,t)=>e+t.ok,0),error:t.reduce((e,t)=>e+t.error,0)}}var Upe={ok:{label:`Successful`,color:`var(--activity-ok)`},error:{label:`Errors`,color:`var(--activity-error)`}},Wpe=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),y5=e=>new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function Gpe(e){let t=window.matchMedia(`(prefers-reduced-motion: reduce)`);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}var Kpe=()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,qpe=(0,v.memo)(({series:e})=>{let t=(0,v.useMemo)(()=>Hpe(e),[e]),n=(0,v.useSyncExternalStore)(Gpe,Kpe,()=>!0),[r,i]=(0,v.useState)(!1),a=!n&&!r,o=`activity-fill-${(0,v.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,s=(0,v.useId)(),c=t.rows[0],l=t.rows[t.rows.length-1],u=t.ok+t.error>0;return(0,G.jsxs)(`figure`,{className:`activity-chart`,"aria-label":`Calls over time`,"aria-describedby":s,"data-motion":a?`on`:`off`,children:[(0,G.jsxs)(`figcaption`,{className:`activity-toolbar`,children:[(0,G.jsxs)(`div`,{className:`activity-legend`,children:[(0,G.jsxs)(`span`,{className:`activity-legend-item`,children:[(0,G.jsx)(`i`,{className:`activity-key-line`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:`Successful`}),(0,G.jsx)(`strong`,{children:c?a?(0,G.jsx)(xA,{value:t.ok.toLocaleString()}):t.ok.toLocaleString():`—`})]}),(0,G.jsxs)(`span`,{className:`activity-legend-item`,children:[(0,G.jsx)(`i`,{className:`activity-key-bar`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:`Errors`}),(0,G.jsx)(`strong`,{children:c?a?(0,G.jsx)(xA,{value:t.error.toLocaleString()}):t.error.toLocaleString():`—`})]})]}),n?(0,G.jsx)(`span`,{className:`activity-motion-note`,children:`Reduced motion`}):(0,G.jsx)(nO,{variant:`ghost`,size:`icon-sm`,"aria-label":r?`Resume chart animation`:`Pause chart animation`,title:r?`Resume chart animation (data keeps updating)`:`Pause chart animation (data keeps updating)`,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?(0,G.jsx)(Ju,{size:14}):(0,G.jsx)(Bu,{size:14})})]}),(0,G.jsxs)(`div`,{className:`activity-plot`,children:[(0,G.jsx)(`span`,{className:`activity-axis-caption`,children:`Calls / interval`}),c?(0,G.jsx)(h5,{config:Upe,className:`activity-canvas h-[260px] w-full aspect-auto`,children:(0,G.jsxs)(Ipe,{data:t.rows,accessibilityLayer:!0,margin:{top:30,right:16,left:0,bottom:4},children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:o,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-ok)`,stopOpacity:.24}),(0,G.jsx)(`stop`,{offset:`80%`,stopColor:`var(--color-ok)`,stopOpacity:.03}),(0,G.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-ok)`,stopOpacity:0})]})}),(0,G.jsx)(m6,{vertical:!1,stroke:`var(--activity-grid)`,strokeOpacity:.5,strokeDasharray:`2 6`}),(0,G.jsx)(a8,{dataKey:`t`,ticks:t.rows.length===1?[c.t]:void 0,type:`number`,domain:c.t===l.t?[c.t-3e4,c.t+3e4]:[`dataMin`,`dataMax`],tickFormatter:Wpe,tick:{fontSize:10},tickLine:!1,axisLine:!1,minTickGap:50,tickMargin:12}),(0,G.jsx)(u8,{width:42,domain:[0,e=>Math.max(1,e)],tick:{fontSize:10},tickLine:!1,axisLine:!1,allowDecimals:!1,tickCount:4,tickMargin:8}),(0,G.jsx)(g5,{isAnimationActive:!1,cursor:{stroke:`var(--activity-cursor)`,strokeWidth:1,strokeDasharray:`4 4`},content:(0,G.jsx)(_5,{className:`activity-tooltip`,indicator:`line`,labelFormatter:(e,t)=>{let n=t?.[0]?.payload;return n?y5(n.t):``}})}),(0,G.jsx)(I6,{type:`monotoneX`,dataKey:`ok`,name:`ok`,stroke:`var(--color-ok)`,strokeWidth:2.5,fill:`url(#${o})`,baseValue:0,dot:t.rows.length===1&&{r:4,fill:`var(--color-ok)`,stroke:`var(--card)`,strokeWidth:2},activeDot:{r:5,fill:`var(--color-ok)`,stroke:`var(--card)`,strokeWidth:3},isAnimationActive:a,animationDuration:700,animationEasing:`ease-in-out`}),(0,G.jsx)(Z6,{dataKey:`error`,name:`error`,fill:`var(--color-error)`,maxBarSize:9,radius:[3,3,0,0],minPointSize:0,isAnimationActive:a,animationDuration:700,animationEasing:`ease-in-out`})]})}):(0,G.jsxs)(`div`,{className:`activity-no-data`,children:[(0,G.jsx)(Pc,{size:24}),(0,G.jsx)(`strong`,{children:`No activity samples yet`}),(0,G.jsx)(`span`,{children:`Intervals appear when statistics become available.`})]}),c&&!u&&(0,G.jsxs)(`div`,{className:`activity-zero`,children:[(0,G.jsx)(Pc,{size:18}),(0,G.jsx)(`span`,{children:`No tool calls in these intervals`})]})]}),(0,G.jsxs)(`div`,{className:`activity-footer`,id:s,children:[(0,G.jsx)(`span`,{children:`Successful calls & errors · same count scale`}),(0,G.jsxs)(`span`,{children:[t.rows.length,` intervals`]})]}),t.omitted>0&&(0,G.jsxs)(`p`,{className:`activity-warning`,children:[t.omitted,` invalid interval(s) omitted; totals cover displayed data only.`]}),c&&(0,G.jsxs)(`details`,{className:`activity-data`,children:[(0,G.jsx)(`summary`,{children:`View interval data`}),(0,G.jsx)(`div`,{className:`activity-table-scroll`,children:(0,G.jsxs)(`table`,{children:[(0,G.jsx)(`caption`,{className:`sr-only`,children:`Exact counts for every displayed interval`}),(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,children:`Interval start`}),(0,G.jsx)(`th`,{scope:`col`,children:`Successful`}),(0,G.jsx)(`th`,{scope:`col`,children:`Errors`})]})}),(0,G.jsx)(`tbody`,{children:t.rows.map((e,t)=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`row`,children:y5(e.t)}),(0,G.jsx)(`td`,{children:e.ok.toLocaleString()}),(0,G.jsx)(`td`,{children:e.error.toLocaleString()})]},`${e.t}-${t}`))})]})})]})]})},(e,t)=>Vpe(e.series,t.series));function b5({segments:e,centerLabel:t=`calls`}){let n=e.filter(e=>e.value>0),r=e.reduce((e,t)=>e+t.value,0),i=Object.fromEntries(n.map(e=>[e.label,{label:e.label,color:e.color}]));return(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3`,children:[(0,G.jsx)(h5,{config:i,className:`mx-auto aspect-square w-full max-w-[180px]`,children:(0,G.jsxs)(Mpe,{children:[(0,G.jsx)(g5,{content:(0,G.jsx)(_5,{hideLabel:!0})}),(0,G.jsx)(C3,{data:n,dataKey:`value`,nameKey:`label`,innerRadius:58,outerRadius:80,paddingAngle:2,strokeWidth:0,isAnimationActive:!1,children:n.map(e=>(0,G.jsx)(G0,{fill:e.color},e.label))}),(0,G.jsx)(`text`,{x:`50%`,y:`47%`,textAnchor:`middle`,className:`fill-foreground`,fontSize:22,fontWeight:600,children:r.toLocaleString()}),(0,G.jsx)(`text`,{x:`50%`,y:`59%`,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:10,children:t})]})}),(0,G.jsx)(`div`,{className:`flex flex-wrap justify-center gap-x-3.5 gap-y-1.5 text-[11px] text-muted-foreground`,children:n.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-[9px] rounded-[3px]`,style:{background:e.color}}),e.label,` `,(0,G.jsx)(`b`,{className:`font-medium text-foreground`,children:e.value})]},e.label))})]})}function x5({values:e,color:t,unit:n,maxValue:r,id:i}){let a=e.filter(e=>e!=null);if(a.length===0)return(0,G.jsx)(`div`,{className:`px-1.5 py-3 text-center text-[11px] text-muted-foreground`,children:`no samples yet`});let o=e.map((e,t)=>({i:t,v:e})),s=a[a.length-1],c=`ma-${(i??t).replace(/[^a-z0-9]/gi,``)}`,l={v:{label:`value`,color:t}},u=Math.min(...a),d=Math.max(...a),f=Math.max(0,(n===`%`?10:0)-(d-u))/2,p=u-f,m=d+f,h=(m-p)*.15||1;return p=Math.max(0,p-h),m+=h,r!=null&&(m=Math.min(r,m)),m<=p&&(m=p+1),(0,G.jsxs)(`div`,{className:`relative w-full`,children:[(0,G.jsxs)(`span`,{className:`absolute right-0.5 top-0 z-10 text-[10px] font-semibold`,style:{color:t},children:[s.toFixed(n===`%`?0:1),n??``]}),(0,G.jsx)(h5,{config:l,className:`h-[46px] w-full`,children:(0,G.jsxs)(Ppe,{data:o,margin:{top:4,right:2,left:2,bottom:0},children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:c,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-v)`,stopOpacity:.35}),(0,G.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-v)`,stopOpacity:0})]})}),(0,G.jsx)(u8,{hide:!0,domain:[p,m]}),(0,G.jsx)(g5,{content:(0,G.jsx)(_5,{hideLabel:!0,formatter:e=>(0,G.jsxs)(`span`,{className:`font-mono tabular-nums text-foreground`,children:[typeof e==`number`?e.toLocaleString():String(e),n??``]})})}),(0,G.jsx)(I6,{type:`monotone`,dataKey:`v`,stroke:`var(--color-v)`,fill:`url(#${c})`,strokeWidth:1.7,connectNulls:!1,isAnimationActive:!1,dot:!1})]})})]})}var S5={map:new Map,source:`none`,limits:{}};function Jpe(e,t){let n=new Map;for(let[r,i]of Object.entries(t.hosts)){let a=e.source===t.source?e.map.get(r):void 0,o=t.limits[r];n.set(r,{...i,downloadLimit:o?.download??``,uploadLimit:o?.upload??``,history:[...a?.history??[],{rx:i.rxRate,tx:i.txRate}].slice(-30)})}return{map:n,source:t.source,note:t.note,limits:t.limits}}var Ype=1e3,C5=`http://www.w3.org/2000/svg`,w5=e=>`${(e/1e6).toFixed(2)} Mbps`,T5=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:e>0?`${Math.round(e)}`:`0`;function Xpe({history:e}){let t=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),n=e=>8+e*504/39,r=e=>142-e/t*134,i=t=>e.map((e,i)=>`${n(i).toFixed(1)},${r(t(e)).toFixed(1)}`).join(` `),a=t=>{if(e.length<2)return``;let r=n(0).toFixed(1),a=n(e.length-1).toFixed(1);return`${r},${142 .toFixed(1)} ${i(t)} ${a},${142 .toFixed(1)}`};return(0,G.jsx)(`svg`,{className:`block h-[150px] w-full max-w-[520px] rounded-md border border-border bg-background`,viewBox:`0 0 520 150`,xmlns:C5,role:`img`,children:e.length>=2&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`polygon`,{className:`fill-success/20 stroke-none`,points:a(e=>e.rx)}),(0,G.jsx)(`polygon`,{className:`fill-warning/15 stroke-none`,points:a(e=>e.tx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-success stroke-2`,points:i(e=>e.rx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-warning stroke-2`,points:i(e=>e.tx)})]})})}function Zpe({history:e}){let t=`block h-[18px] w-20 shrink-0 rounded-[3px] bg-muted/40`;if(e.length<2)return(0,G.jsx)(`svg`,{className:t,viewBox:`0 0 80 18`});let n=Math.max(1,...e.flatMap(e=>[e.rx,e.tx])),r=e=>1+e*78/29,i=e=>17-e/n*16,a=t=>e.map((e,n)=>`${r(n).toFixed(1)},${i(t(e)).toFixed(1)}`).join(` `),o=t=>{let n=r(0).toFixed(1),i=r(e.length-1).toFixed(1),o=17 .toFixed(1);return`${n},${o} ${a(t)} ${i},${o}`};return(0,G.jsxs)(`svg`,{className:t,viewBox:`0 0 80 18`,xmlns:C5,children:[(0,G.jsx)(`polygon`,{className:`fill-success/20 stroke-none`,points:o(e=>e.rx)}),(0,G.jsx)(`polygon`,{className:`fill-warning/15 stroke-none`,points:o(e=>e.tx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-success stroke-1`,vectorEffect:`non-scaling-stroke`,points:a(e=>e.rx)}),(0,G.jsx)(`polyline`,{className:`fill-none stroke-warning stroke-1`,vectorEffect:`non-scaling-stroke`,points:a(e=>e.tx)})]})}function Qpe({ip:e,deviceName:t,current:n,onSaved:r}){let[i,a]=(0,v.useState)(n.download),[o,s]=(0,v.useState)(n.upload),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{c||(a(n.download),s(n.upload))},[n.download,n.upload,c]);let m=(0,v.useCallback)(async(n,i)=>{d(!0),p(null);try{let a=await _c(`/api/clients/limits`,{ip:e,device:t,download:n,upload:i});p(a.message),a.ok?(l(!1),r(),Y.success(n||i?`Rate limits applied`:`Rate limits removed`)):Y.error(a.message||`Rate limits failed`)}catch(e){p(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Rate limits failed`)}finally{d(!1)}},[e,t,r]),h=!!(n.download||n.upload);return(0,G.jsxs)(`div`,{className:`mt-3.5 max-w-[520px] border-t border-border pt-3`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Rate limits`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[`current: ↓ `,n.download||`unlimited`,` · ↑ `,n.upload||`unlimited`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex flex-col gap-[3px] text-[11.5px]`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`↓ Download`}),(0,G.jsx)($j,{className:`w-[150px]`,placeholder:`10M · blank = unlimited`,value:i,onChange:e=>{l(!0),a(e.target.value)}})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-[3px] text-[11.5px]`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`↑ Upload`}),(0,G.jsx)($j,{className:`w-[150px]`,placeholder:`2M · blank = unlimited`,value:o,onChange:e=>{l(!0),s(e.target.value)}})]}),(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:u,onClick:()=>void m(i,o),children:`Apply`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:u||!h,onClick:()=>{a(``),s(``),m(``,``)},children:`Remove`})]}),f&&(0,G.jsx)(`div`,{className:`mt-1.5 text-muted-foreground text-xs`,children:f})]})}function $pe({device:e,deviceName:t,traffic:n,limits:r}){let i=n!==void 0;return(0,G.jsxs)(`div`,{className:`mt-3.5 border-t border-border pt-3.5`,children:[(0,G.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-baseline gap-3`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e.host||e.comment||e.ip}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-[11px]`,children:[e.ip||`no IP`,` · `,e.mac,` · `,e.iface||`?`,` · `,e.status]})]}),i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mb-2 flex gap-[18px] tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`font-semibold text-success`,children:[`↓ `,w5(n.rxRate)]}),(0,G.jsxs)(`span`,{className:`font-semibold text-warning`,children:[`↑ `,w5(n.txRate)]})]}),(0,G.jsx)(Xpe,{history:n.history}),(0,G.jsxs)(`div`,{className:`mt-2 text-muted-foreground text-xs tabular-nums`,children:[`Router counter totals ↓ `,Vk(n.rxBytes),` · ↑ `,Vk(n.txBytes)]})]}):(0,G.jsxs)(Yj,{type:`secondary`,label:`No traffic yet`,children:[`No counter was returned for `,(0,G.jsx)(`code`,{children:e.ip}),`. This is unavailable data, not zero usage. Check the traffic source notice above.`]}),e.ip&&(0,G.jsx)(Qpe,{ip:e.ip,deviceName:t,current:{download:r?.download??``,upload:r?.upload??``},onSaved:()=>{}}),e.ip&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-muted-foreground`,children:`Usage history · last 3 months`}),(0,G.jsx)(cM,{endpoint:`/api/usage/client?ip=${encodeURIComponent(e.ip)}${t?`&device=${encodeURIComponent(t)}`:``}&days=90`,days:90})]})]})}function eme(e){let[t,n]=(0,v.useState)(S5);return(0,v.useEffect)(()=>{n(S5)},[e]),(0,v.useEffect)(()=>{if(!e)return;let t=!1,r=null,i=null,a=null,o=`traffic=${encodeURIComponent(e)}`,s=e=>{t||n(t=>Jpe(t,e))},c=()=>{if(t||a)return;let n=async()=>{try{s(await U(`/api/clients/traffic-bulk?device=${encodeURIComponent(e)}`))}catch(e){s({ts:Date.now(),source:`none`,hosts:{},limits:{},note:e instanceof Error?e.message:`Traffic request failed`})}};n(),a=setInterval(()=>void n(),Ype)},l=()=>{if(t)return;i=new EventSource(gc(`/api/sse?${o}`));let e=!1;i.onopen=()=>{e=!0},i.addEventListener(`traffic`,e=>{try{s(JSON.parse(e.data))}catch{}}),i.onerror=()=>{!e&&i&&(i.close(),i=null,c())}},u=()=>{if(t)return;let e=location.protocol===`https:`?`wss`:`ws`;r=new WebSocket(gc(`${e}://${location.host}/api/stream?${o}`));let n=!1;r.onopen=()=>{n=!0},r.onerror=()=>r?.close(),r.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`traffic`&&t.sample&&s(t.sample)}catch{}},r.onclose=()=>{t||(n?setTimeout(u,2e3):l())}};return u(),()=>{t=!0,r?.close(),i?.close(),a&&clearInterval(a)}},[e]),t}function tme(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),{map:g,source:_,note:y,limits:b}=eme(n);(0,v.useEffect)(()=>{U(`/api/devices`).then(e=>{t(e),r(t=>t||e.defaultDevice||e.devices[0]?.name||``)}).catch(()=>t({server:``,defaultDevice:``,devices:[]}))},[]);let x=(0,v.useCallback)(async()=>{try{let e=n?`?device=${encodeURIComponent(n)}`:``;a(await U(`/api/clients${e}`)),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}},[n]);(0,v.useEffect)(()=>{a(null),s(null),x();let e=setInterval(()=>void x(),15e3);return()=>clearInterval(e)},[x]);let S=(0,v.useCallback)(async(e,t,r)=>{l(t),d(null);try{let i=await _c(`/api/clients/${e}`,{mac:t,device:n,...r});i.view?a(i.view):await x();let o=e===`block`?`Client blocked`:e===`allow`?`Client allowed`:e===`pin`?`IP pinned`:e===`set-ip`?`IP set`:e===`label`?`Client labeled`:`Done`;i.ok?Y.success(o):(d(i.message),Y.error(i.message||`${o} failed`))}catch(e){d(e instanceof Error?e.message:String(e)),Y.error(e instanceof Error?e.message:`Action failed`)}finally{l(null)}},[n,x]),C=(0,v.useCallback)((e,t)=>{s(e.mac),h({mac:e.mac,field:t,value:t===`ip`?e.ip:e.comment||e.host})},[]),w=(0,v.useCallback)(async()=>{if(!m)return;let e=m.value.trim();m.field===`ip`?e&&await S(`set-ip`,m.mac,{ip:e}):await S(`label`,m.mac,{label:e}),h(null)},[m,S]),T=(0,v.useMemo)(()=>{let e=i?.devices??[],t=f.trim().toLowerCase();return t?e.filter(e=>e.ip.toLowerCase().includes(t)||e.mac.toLowerCase().includes(t)||e.host.toLowerCase().includes(t)||e.comment.toLowerCase().includes(t)):e},[i,f]),E=(0,v.useMemo)(()=>i?.devices.find(e=>e.mac===o)??null,[i,o]),D=e?.devices??[],O=i?.counts;return(0,G.jsx)(`section`,{className:`grid content-start gap-[18px]`,children:(0,G.jsxs)(X,{title:`Connected clients`,className:`reveal`,extra:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D.length>1&&(0,G.jsx)(nM,{value:n,onValueChange:r,"aria-label":`Router`,options:D.map(e=>({value:e.name,label:`${e.name}${e.isDefault?` (default)`:``}`}))}),(0,G.jsx)($j,{className:`w-[200px]`,placeholder:`Filter IP / MAC / name…`,value:f,onChange:e=>p(e.target.value)}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,icon:(0,G.jsx)(nd,{}),onClick:()=>void x(),children:`Refresh`})]}),children:[O&&(0,G.jsxs)(`div`,{className:`mb-2.5 text-muted-foreground text-xs`,children:[O.total,` total · `,O.static,` static · `,O.blocked,` blocked`]}),u&&(0,G.jsx)(Yj,{type:`error`,className:`mb-2.5`,children:u}),y&&(0,G.jsxs)(Yj,{type:`warning`,label:`Traffic unavailable`,className:`mb-2.5`,children:[y,` The Traffic column needs per-host counters — `,(0,G.jsx)(`code`,{children:`/ip accounting`}),` `,`on RouterOS v6, or Kid Control on v7.`]}),_===`kid-control`&&!y&&(0,G.jsx)(`p`,{className:`mb-2.5 text-xs text-muted-foreground`,children:`Live device counters · ↓ download / ↑ upload · includes IPv4 + IPv6 for each device. Router counters may reset; these are not billing totals.`}),i?T.length===0?(0,G.jsxs)(`div`,{className:`grid justify-items-center gap-2 rounded-lg border border-dashed border-border px-4 py-[54px] text-center`,children:[(0,G.jsx)(lf,{className:`size-7 text-muted-foreground opacity-80`}),(0,G.jsx)(`p`,{className:`m-0 font-semibold text-foreground`,children:`No connected devices`}),(0,G.jsxs)(`p`,{className:`m-0 max-w-[460px] text-muted-foreground text-xs`,children:[`Nothing in this router's DHCP-lease or ARP table`,f?` matches the filter`:``,`.`]})]}):(0,G.jsxs)(ZO,{className:`text-[13px]`,children:[(0,G.jsx)(QO,{children:(0,G.jsxs)(ek,{children:[(0,G.jsx)(tk,{children:`IP`}),(0,G.jsx)(tk,{children:`Name`}),(0,G.jsx)(tk,{children:`MAC`}),(0,G.jsx)(tk,{children:`Iface`}),(0,G.jsx)(tk,{children:`Status`}),(0,G.jsx)(tk,{children:`Traffic`}),(0,G.jsx)(tk,{className:`text-right`,children:`Actions`})]})}),(0,G.jsx)($O,{children:T.map(e=>{let t=e.mac===o,n=c===e.mac,r=e.ip?g.get(e.ip):void 0,i=e.blocked&&`text-muted-foreground line-through`;return(0,G.jsxs)(ek,{"data-state":t?`selected`:void 0,className:`cursor-pointer`,onClick:()=>s(t?null:e.mac),children:[(0,G.jsx)(nk,{className:K(`max-w-[120px] truncate`,i),children:e.ip||`—`}),(0,G.jsx)(nk,{className:K(`max-w-[200px] truncate`,i),children:e.host||e.comment||`(unknown)`}),(0,G.jsx)(nk,{className:`font-mono text-[11.5px] text-muted-foreground`,children:e.mac}),(0,G.jsx)(nk,{className:`text-muted-foreground text-[11px]`,children:e.iface||``}),(0,G.jsx)(nk,{children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.static&&(0,G.jsx)(Xj,{type:`secondary`,children:`static`}),e.blocked?(0,G.jsx)(Xj,{type:`error`,children:`blocked`}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:e.status})]})}),(0,G.jsx)(nk,{children:r?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 overflow-hidden tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-[48px] flex-col whitespace-nowrap leading-tight`,children:[(0,G.jsxs)(`span`,{className:`text-success`,children:[`↓`,T5(r.rxRate)]}),(0,G.jsxs)(`span`,{className:`text-warning`,children:[`↑`,T5(r.txRate)]})]}),(0,G.jsx)(Zpe,{history:r.history})]}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:e.ip?`No counter`:``})}),(0,G.jsx)(nk,{onClick:e=>e.stopPropagation(),children:(0,G.jsxs)(`span`,{className:`flex justify-end gap-1.5`,children:[e.blocked?(0,G.jsx)(Z,{size:`sm`,type:`success`,ghost:!0,loading:n,onClick:()=>void S(`allow`,e.mac),children:`Allow`}):(0,G.jsx)(Z,{size:`sm`,type:`error`,ghost:!0,loading:n,onClick:()=>void S(`block`,e.mac),children:`Block`}),!e.static&&(0,G.jsx)(Z,{size:`sm`,ghost:!0,loading:n,onClick:()=>void S(`pin`,e.mac),children:`Pin IP`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:n,onClick:()=>C(e,`ip`),children:`Set IP`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,disabled:n,onClick:()=>C(e,`label`),children:`Label`})]})})]},e.mac)})})]}):(0,G.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:`loading connected devices…`}),m&&E?.mac===m.mac&&(0,G.jsxs)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-3 py-2.5`,children:[(0,G.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[m.field===`ip`?`Reserve IP for`:`Label for`,` `,(0,G.jsx)(`b`,{children:E.host||E.mac}),`:`]}),(0,G.jsx)($j,{className:`w-[220px]`,autoFocus:!0,value:m.value,placeholder:m.field===`ip`?`e.g. 192.168.88.50`:`e.g. Ali phone`,onChange:e=>h({...m,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&w(),e.key===`Escape`&&h(null)}}),(0,G.jsx)(Z,{size:`sm`,type:`accent`,loading:c===m.mac,onClick:()=>void w(),children:`Save`}),(0,G.jsx)(Z,{size:`sm`,ghost:!0,onClick:()=>h(null),children:`Cancel`})]}),E&&(0,G.jsx)(`a`,{className:`inline-flex rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-muted`,href:(()=>{let e=new URL(location.href);return e.searchParams.set(`investigationDevice`,n),e.searchParams.set(`investigationClient`,E.ip||E.mac),e.hash=`investigations`,e.toString()})(),children:`Investigate this client and service`}),E&&(0,G.jsx)($pe,{device:E,deviceName:n,traffic:E.ip?g.get(E.ip):void 0,limits:b[E.ip]})]})})}function E5({label:e,value:t,items:n,onChange:r,disabled:i=!1}){return(0,G.jsxs)(`div`,{className:`home-field`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsxs)(Kj,{value:t,onValueChange:r,disabled:i,children:[(0,G.jsx)(qj,{"aria-label":e,children:(0,G.jsx)(Wj,{placeholder:`Choose…`})}),(0,G.jsx)(Jj,{children:n.map(e=>(0,G.jsx)(Gj,{value:e.value,children:e.label},e.value))})]})]})}function nme(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let e=!1;return U(`/api/devices`).then(n=>{e||(t(n.devices.map(e=>e.name)),r(n.defaultDevice||n.devices[0]?.name||``))}).catch(()=>{e||a(`Could not load routers. Check the dashboard connection and reload.`)}),()=>{e=!0}},[]),(0,G.jsxs)(`div`,{className:`home-internet`,children:[(0,G.jsxs)(`header`,{className:`home-intro`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`home-eyebrow`,children:[(0,G.jsx)(mu,{size:14}),` YOUR EVERYDAY NETWORK`]}),(0,G.jsxs)(`h2`,{children:[`Less guessing.`,(0,G.jsx)(`br`,{}),(0,G.jsx)(`span`,{children:`More connection.`})]}),(0,G.jsx)(`p`,{children:`Find the slowdown, look after your household, and choose a path with evidence.`})]}),(0,G.jsx)(E5,{label:`Home router`,value:n,items:e.map(e=>({value:e,label:e})),onChange:r})]}),i&&(0,G.jsx)(`p`,{role:`alert`,className:`home-error`,children:i}),n&&(0,G.jsx)(rme,{device:n},n)]})}function rme({device:e}){let[t,n]=(0,v.useState)(`diagnosis`),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(`example.com`),[p,m]=(0,v.useState)(`1.1.1.1`),[h,g]=(0,v.useState)([]),[_,y]=(0,v.useState)(`calls`),[b,x]=(0,v.useState)(),[S,C]=(0,v.useState)(),[w,T]=(0,v.useState)(`pause`),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(`30`),[A,j]=(0,v.useState)(`0`),[M,N]=(0,v.useState)(),[P,F]=(0,v.useState)(!1),[I,ee]=(0,v.useState)(),[L,R]=(0,v.useState)(``),[te,z]=(0,v.useState)(``),[ne,re]=(0,v.useState)(``),ie=`?device=${encodeURIComponent(e)}`,[ae,oe]=(0,v.useState)(()=>Date.now());(0,v.useEffect)(()=>{let e=window.setInterval(()=>oe(Date.now()),1e4);return()=>window.clearInterval(e)},[]);async function se(){let e=await U(`/api/home-internet${ie}`);i(e.clients),o(e.policies)}(0,v.useEffect)(()=>{let e=new AbortController;return U(`/api/home-internet${ie}`,e.signal).then(t=>{e.signal.aborted||(i(t.clients),o(t.policies))}).catch(()=>{e.signal.aborted||z(`Could not load the saved household. Retry with Refresh saved data.`)}),()=>e.abort()},[ie]);async function ce(e,t){let n=await _c(`/api/home-internet/${e}${ie}`,t);if(n.error)throw Error(n.error);return n}async function le(e,t){if(!L){R(e),z(``),re(``);try{await t()}catch(e){z(e instanceof Error?e.message:`Request failed. No success has been confirmed.`)}finally{R(``)}}}let B=r.find(e=>e.mac===l),V=r.filter(e=>e.ip).map(e=>({value:e.mac,label:`${e.name||e.hostname||`Unnamed device`} · ${e.ip}`})),ue=r.filter(e=>!e.acknowledged),de=()=>{N(void 0),F(!1)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`nav`,{className:`home-sections`,"aria-label":`Home Internet sections`,children:[{id:`diagnosis`,title:`Find the slowdown`,sub:`Understand what to check`,icon:Pc},{id:`people`,title:`Your household`,sub:`People, devices & quiet time`,icon:nf},{id:`paths`,title:`Choose a path`,sub:`Compare before switching`,icon:cd}].map(({id:e,title:r,sub:i,icon:a})=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":t===e,onClick:()=>n(e),children:[(0,G.jsx)(a,{size:20}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`strong`,{children:r}),(0,G.jsx)(`small`,{children:i})]}),e===`people`&&ue.length>0&&(0,G.jsxs)(`b`,{className:`home-new`,children:[ue.length,` new`]})]},e))}),(0,G.jsxs)(`div`,{className:`home-toolbar`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(Sd,{size:16}),` No router changes without a reviewed preview.`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(nO,{variant:`ghost`,size:`sm`,disabled:!!L,onClick:()=>void le(`Loading saved data`,se),children:`Refresh saved data`}),(0,G.jsxs)(nO,{variant:`outline`,size:`sm`,disabled:!!L,onClick:()=>void le(`Discovering household`,async()=>{let e=await ce(`refresh`,{});i(e.clients),c(e.tables),g(t=>t.filter(t=>e.tables.includes(t))),re(`DHCP inventory updated. New-device notices appear after the first baseline scan; no router configuration changed.`)}),children:[(0,G.jsx)(nd,{size:14}),` Discover devices & paths`]})]})]}),L&&(0,G.jsxs)(`p`,{className:`home-status`,role:`status`,children:[(0,G.jsx)(`span`,{className:`home-pulse`}),L,`…`]}),te&&(0,G.jsx)(`p`,{className:`home-error`,role:`alert`,children:te}),ne&&(0,G.jsxs)(`p`,{className:`home-status`,role:`status`,children:[(0,G.jsx)(cl,{size:16}),ne]}),t===`diagnosis`&&(0,G.jsxs)(`section`,{className:`home-grid`,children:[(0,G.jsxs)(`div`,{className:`home-card`,children:[(0,G.jsx)(`div`,{className:`home-eyebrow`,children:`A SMALL, READ-ONLY CHECK`}),(0,G.jsx)(`h3`,{children:`What feels slow?`}),(0,G.jsx)(`p`,{children:`Choose a device and a website. We check the router, DNS, Wi-Fi evidence and a few small internet probes.`}),(0,G.jsxs)(`div`,{className:`home-form`,children:[(0,G.jsx)(E5,{label:`Affected device`,value:l,items:V,onChange:u,disabled:!!L}),(0,G.jsxs)(`label`,{className:`home-field`,children:[`Website or IPv4`,(0,G.jsx)(Ok,{value:d,onChange:e=>f(e.target.value),placeholder:`example.com`})]}),(0,G.jsxs)(nO,{disabled:!!L||!B?.ip||!d,onClick:()=>void le(`Checking the connection`,async()=>{x(void 0),x(await ce(`diagnose`,{client:B.ip,target:d}))}),children:[(0,G.jsx)(Pc,{size:16}),` Check my connection `,(0,G.jsx)(Hc,{size:16})]})]}),!r.length&&(0,G.jsxs)(`p`,{className:`home-hint`,children:[`Start with “Discover devices & paths” above. Devices without DHCP records can still be investigated in `,(0,G.jsx)(`a`,{href:`#investigations`,children:`Investigations`}),`.`]})]}),(0,G.jsxs)(`aside`,{className:`home-explainer`,children:[(0,G.jsx)(Ad,{size:32}),(0,G.jsx)(`h3`,{children:`Follow the evidence.`}),(0,G.jsxs)(`ol`,{children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`b`,{children:`Observed`}),(0,G.jsx)(`span`,{children:`Something the router actually reported.`})]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`b`,{children:`Suspected`}),(0,G.jsx)(`span`,{children:`A possible explanation, not a confirmed cause.`})]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`b`,{children:`Unknown`}),(0,G.jsx)(`span`,{children:`A missing measurement, never a green check.`})]})]}),(0,G.jsx)(`p`,{children:`This is not a speed test. Client application health, VPN throughput and MTU remain unverified.`})]}),b&&(0,G.jsxs)(`div`,{className:`home-results`,children:[(0,G.jsxs)(`header`,{children:[(0,G.jsx)(`h3`,{children:`Your connection report`}),(0,G.jsxs)(`small`,{children:[b.client,` → `,b.target,` ·`,` `,new Date(b.at).toLocaleTimeString()]})]}),(0,G.jsx)(`div`,{className:`home-findings`,children:b.findings.map(e=>(0,G.jsxs)(`article`,{"data-state":e.state,children:[(0,G.jsxs)(`div`,{className:`home-finding-label`,children:[(0,G.jsx)(`span`,{children:e.area}),(0,G.jsx)(`b`,{children:e.state})]}),(0,G.jsx)(`h4`,{children:e.title}),(0,G.jsx)(`p`,{children:e.detail}),(0,G.jsxs)(`footer`,{children:[(0,G.jsx)(Hc,{size:14}),(0,G.jsx)(`span`,{children:e.next})]})]},e.area))})]})]}),t===`people`&&(0,G.jsxs)(`section`,{className:`home-grid`,children:[(0,G.jsxs)(`div`,{className:`home-card`,children:[(0,G.jsx)(`div`,{className:`home-eyebrow`,children:`PEOPLE, NOT MAC ADDRESSES`}),(0,G.jsx)(`h3`,{children:`Give each device a place.`}),(0,G.jsx)(`p`,{children:`Friendly names stay in this MCP. Notices are based on explicit discovery scans, not continuous surveillance. Private/random MACs can appear as new devices.`}),(0,G.jsxs)(`div`,{className:`home-client-list`,children:[r.length===0&&(0,G.jsx)(`p`,{className:`home-empty`,children:`No household inventory yet. Discover devices to establish your first baseline.`}),r.map(e=>(0,G.jsx)(ime,{client:e,disabled:!!L,onSave:(t,n)=>void le(`Saving device name`,async()=>{await ce(`name`,{mac:e.mac,name:t,person:n}),await se(),re(`Name saved locally; new-device notice acknowledged.`)}),onChoose:()=>{u(e.mac),de()},selected:l===e.mac},e.mac))]})]}),(0,G.jsxs)(`aside`,{className:`home-card`,children:[(0,G.jsxs)(`div`,{className:`home-eyebrow`,children:[(0,G.jsx)(Ol,{size:14}),` TEMPORARY, BY DESIGN`]}),(0,G.jsx)(`h3`,{children:`A little quiet. Or meeting time.`}),(0,G.jsx)(`p`,{children:`Pause routed access or prioritize a device within an existing QoS setup. A static DHCP lease is required; IPv6 and FastTrack limitations are checked before a preview is created.`}),(0,G.jsx)(E5,{label:`Household device`,value:l,items:V,onChange:e=>{u(e),de()},disabled:!!L}),(0,G.jsx)(E5,{label:`Temporary action`,value:w===`route`?`pause`:w,items:[{value:`pause`,label:`Pause routed access`},{value:`priority`,label:`Meeting priority`}],onChange:e=>{T(e),de()},disabled:!!L}),(0,G.jsx)(D5,{minutes:O,delay:A,setMinutes:e=>{k(e),de()},setDelay:e=>{j(e),de()}}),(0,G.jsxs)(nO,{disabled:!!L||!B,onClick:()=>void le(`Checking policy prerequisites`,async()=>{de(),N(await ce(`preview`,{mac:l,action:w===`route`?`pause`:w,minutes:Number(O),startInMinutes:Number(A)}))}),children:[`Review temporary change `,(0,G.jsx)(Hc,{size:15})]})]})]}),t===`paths`&&(0,G.jsxs)(`section`,{className:`home-grid`,children:[(0,G.jsxs)(`div`,{className:`home-card`,children:[(0,G.jsx)(`div`,{className:`home-eyebrow`,children:`TRY THE PATH, NOT YOUR LUCK`}),(0,G.jsx)(`h3`,{children:`Which route looks steadier?`}),(0,G.jsx)(`p`,{children:`Compare up to three existing routing tables. Five small probes per path; no traffic is switched and no large files are downloaded.`}),(0,G.jsxs)(`div`,{className:`home-form`,children:[(0,G.jsx)(E5,{label:`What matters most?`,value:_,items:[{value:`calls`,label:`Stable calls`},{value:`gaming`,label:`Responsive gaming`},{value:`download`,label:`Downloads — measurements only`}],onChange:y}),(0,G.jsxs)(`label`,{className:`home-field`,children:[`Same IPv4 destination for every path`,(0,G.jsx)(Ok,{value:p,onChange:e=>m(e.target.value)})]}),(0,G.jsxs)(`fieldset`,{children:[(0,G.jsx)(`legend`,{children:`Paths to compare · up to three`}),(0,G.jsx)(`div`,{className:`home-path-options`,children:s.map(e=>(0,G.jsxs)(`label`,{children:[(0,G.jsx)(fO,{checked:h.includes(e),disabled:!h.includes(e)&&h.length>=3,onCheckedChange:t=>g(n=>t?[...n,e]:n.filter(t=>t!==e))}),(0,G.jsx)(`span`,{children:e})]},e))}),!s.length&&(0,G.jsx)(`p`,{className:`home-hint`,children:`Discover devices & paths to load the router's available tables.`})]}),(0,G.jsxs)(nO,{disabled:!!L||!h.length,onClick:()=>void le(`Comparing internet paths`,async()=>{C(void 0),C(await ce(`compare`,{tables:h,target:p,goal:_}))}),children:[(0,G.jsx)(cd,{size:16}),` Compare paths`]})]})]}),(0,G.jsxs)(`aside`,{className:`home-card`,children:[(0,G.jsx)(`h3`,{children:`Try a path for one device.`}),(0,G.jsx)(`p`,{children:`Only an existing, ready routing table can be selected. IPv6 keeps its current route; local/private destinations are excluded.`}),(0,G.jsx)(E5,{label:`Device to switch`,value:l,items:V,onChange:e=>{u(e),de()},disabled:!!L}),(0,G.jsx)(E5,{label:`Route table`,value:E,items:s.map(e=>({value:e,label:e})),onChange:e=>{D(e),de()},disabled:!!L}),(0,G.jsx)(D5,{minutes:O,delay:A,setMinutes:e=>{k(e),de()},setDelay:e=>{j(e),de()}}),(0,G.jsxs)(nO,{disabled:!!L||!l||!E,onClick:()=>void le(`Preparing path preview`,async()=>{de(),N(await ce(`preview`,{mac:l,action:`route`,table:E,minutes:Number(O),startInMinutes:Number(A)}))}),children:[`Review path change `,(0,G.jsx)(Hc,{size:15})]})]}),S&&(0,G.jsxs)(`div`,{className:`home-results`,children:[(0,G.jsxs)(`header`,{children:[(0,G.jsx)(`h3`,{children:`Path comparison`}),(0,G.jsxs)(`small`,{children:[S.target,` · `,new Date(S.at).toLocaleTimeString()]})]}),(0,G.jsx)(`p`,{children:S.explanation}),(0,G.jsx)(`div`,{className:`home-paths`,children:S.paths.map(e=>(0,G.jsxs)(`article`,{className:S.recommended===e.table?`home-recommended`:``,children:[(0,G.jsxs)(`div`,{className:`home-path-line`,children:[(0,G.jsx)(Pu,{}),(0,G.jsx)(`span`,{}),(0,G.jsx)(cd,{}),(0,G.jsx)(`span`,{}),(0,G.jsx)(Ad,{})]}),(0,G.jsx)(`h4`,{children:e.table}),S.recommended===e.table&&(0,G.jsx)(`b`,{className:`home-new`,children:`Best in this small sample`}),(0,G.jsxs)(`dl`,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Loss`}),(0,G.jsx)(`dd`,{children:e.loss===null?`Unknown`:`${e.loss.toFixed(0)}%`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Average RTT`}),(0,G.jsx)(`dd`,{children:e.latency===null?`Unknown`:`${e.latency.toFixed(1)} ms`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`RTT range`}),(0,G.jsx)(`dd`,{children:e.spread===null?`Unknown`:`${e.spread.toFixed(1)} ms`})]})]}),(0,G.jsx)(`p`,{children:e.note}),(0,G.jsx)(nO,{variant:`outline`,size:`sm`,onClick:()=>{D(e.table),de()},children:`Choose for preview`})]},e.table))})]})]}),M&&(0,G.jsxs)(`section`,{className:`home-review`,"aria-label":`Review temporary change`,children:[(0,G.jsxs)(`header`,{children:[(0,G.jsx)(Sd,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{children:`Review before anything changes`}),(0,G.jsxs)(`p`,{children:[M.device,` · `,M.input.mac,` · `,M.ip,` · `,M.input.action,M.input.table?` → ${M.input.table}`:``]})]})]}),(0,G.jsxs)(`p`,{children:[`Starts`,` `,M.input.startInMinutes?`in ${M.input.startInMinutes} minutes`:`after confirmation`,`; lasts `,M.input.minutes,` minutes. Preview expires`,` `,new Date(M.previewExpiresAt).toLocaleTimeString(),`.`]}),(0,G.jsx)(`ul`,{children:M.warnings.map(e=>(0,G.jsx)(`li`,{children:e},e))}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{children:`Exact RouterOS changes and rollback`}),(0,G.jsxs)(`pre`,{children:[M.commands.join(`
242
242
  `),`
243
243
 
244
244
  # Undo only this policy